public Dictionary <string, string> GetCategoryData(Ctx ctx, string fields) { string[] paramValue = fields.Split(','); int M_Product_Category_ID = 0; M_Product_Category_ID = Util.GetValueOfInt(paramValue[0].ToString()); MProductCategory pc = new MProductCategory(ctx, M_Product_Category_ID, null); Dictionary <string, string> retDic = new Dictionary <string, string>(); if (pc.Get_ColumnIndex("ProductType") > 0) { retDic["ProductType"] = pc.GetProductType(); } if (pc.Get_ColumnIndex("M_AttributeSet_ID") > 0) { retDic["M_AttributeSet_ID"] = Util.GetValueOfString(pc.GetM_AttributeSet_ID()); } if (pc.Get_ColumnIndex("C_TaxCategory_ID") > 0) { retDic["C_TaxCategory_ID"] = Util.GetValueOfString(pc.GetC_TaxCategory_ID()); } retDic["A_Asset_Group_ID"] = Util.GetValueOfString(pc.GetA_Asset_Group_ID()); if (pc.GetA_Asset_Group_ID() > 0) { MAssetGroup astGrp = new MAssetGroup(ctx, pc.GetA_Asset_Group_ID(), null); if (astGrp.Get_ColumnIndex("VA038_AmortizationTemplate_ID") > 0) { retDic["VA038_AmortizationTemplate_ID"] = Util.GetValueOfString(astGrp.Get_Value("VA038_AmortizationTemplate_ID")); } } return(retDic); }
/** * Create Asset for this product * @return true if asset is created */ public bool IsCreateAsset() { MProductCategory pc = MProductCategory.Get(GetCtx(), GetM_Product_Category_ID()); if (!Env.IsModuleInstalled("INT16_")) { return(pc.GetA_Asset_Group_ID() != 0); } else { return(pc.GetProductType() == "A"); } }
/// <summary> /// GetProductCategory /// </summary> /// <param name="ctx"></param> /// <param name="fields"></param> /// <returns></returns> public Dictionary <string, string> GetProductCategory(Ctx ctx, string fields) { string[] paramValue = fields.Split(','); int M_Product_Category_ID; M_Product_Category_ID = Util.GetValueOfInt(paramValue[0].ToString()); MProductCategory pc = new MProductCategory(ctx, M_Product_Category_ID, null); // mTab.setValue("IsPurchasedToOrder", pc.IsPurchasedToOrder()); bool IsPurchasedToOrder = false;//= pc.IsPurchasedToOrder(); //Temporay Commented BY sarab Dictionary <string, string> retDic = new Dictionary <string, string>(); retDic[""] = IsPurchasedToOrder.ToString(); return(retDic); }
public override String LoadDocumentDetails() { costupdate = (MCostUpdate)GetPO(); if (costupdate.GetM_Product_Category_ID() != 0) { mpc = MProductCategory.Get(GetCtx(), costupdate.GetM_Product_Category_ID()); } _lines = LoadLines(costupdate); m_ce = MCostElement.GetMaterialCostElement(MClient.Get(GetCtx()), X_C_AcctSchema.COSTINGMETHOD_StandardCosting); SetDateAcct(costupdate.GetDateAcct()); SetDateDoc(costupdate.GetDateAcct()); return(null); }
/** * Create One Asset Per UOM * @return individual asset */ public bool IsOneAssetPerUOM() { MProductCategory pc = MProductCategory.Get(GetCtx(), GetM_Product_Category_ID()); if (!Env.IsModuleInstalled("INT16_")) { if (pc.GetA_Asset_Group_ID() == 0) { return(false); } MAssetGroup ag = MAssetGroup.Get(GetCtx(), pc.GetA_Asset_Group_ID()); return(ag.IsOneAssetPerUOM()); } else { return(Convert.ToBoolean(pc.Get_Value("INT16_IsOneAssetPerUOM"))); } }
/** * Create Asset Group for this product * @return asset group id */ public int GetA_Asset_Group_ID() { MProductCategory pc = MProductCategory.Get(GetCtx(), GetM_Product_Category_ID()); return(pc.GetA_Asset_Group_ID()); }
} // createRequisition /// <summary> /// Create Inventory Movements /// </summary> private void CreateMovements() { int noMoves = 0; String info = ""; // MClient client = null; MMovement move = null; int M_Warehouse_ID = 0; int M_WarehouseSource_ID = 0; MWarehouse whSource = null; MWarehouse whTarget = null; string param = ""; if (_M_WareSource != null) { param = _M_WareSource; } else { param = "M_WarehouseSource_ID IS NOT NULL"; } X_T_Replenish[] replenishs = GetReplenish(param);; for (int i = 0; i < replenishs.Length; i++) { X_T_Replenish replenish = replenishs[i]; if (whSource == null || whSource.GetM_WarehouseSource_ID() != replenish.GetM_WarehouseSource_ID()) { whSource = MWarehouse.Get(GetCtx(), replenish.GetM_WarehouseSource_ID()); } if (whTarget == null || whTarget.GetM_Warehouse_ID() != replenish.GetM_Warehouse_ID()) { whTarget = MWarehouse.Get(GetCtx(), replenish.GetM_Warehouse_ID()); } if (client == null || client.GetAD_Client_ID() != whSource.GetAD_Client_ID()) { client = MClient.Get(GetCtx(), whSource.GetAD_Client_ID()); } // if (move == null || M_WarehouseSource_ID != replenish.GetM_WarehouseSource_ID() || M_Warehouse_ID != replenish.GetM_Warehouse_ID()) { M_WarehouseSource_ID = replenish.GetM_WarehouseSource_ID(); M_Warehouse_ID = replenish.GetM_Warehouse_ID(); move = new MMovement(GetCtx(), 0, Get_TrxName()); move.SetC_DocType_ID(_C_DocType_ID); move.SetDescription(Msg.GetMsg(GetCtx(), "Replenishment") + ": " + whSource.GetName() + "->" + whTarget.GetName()); // Set Org move.SetAD_Org_ID(whSource.GetAD_Org_ID()); if (!move.Save()) { return; } log.Fine(move.ToString()); noMoves++; info += " - " + move.GetDocumentNo(); } MProduct product = MProduct.Get(GetCtx(), replenish.GetM_Product_ID()); // To int M_LocatorTo_ID = GetLocator_ID(product, whTarget); // From: Look-up Storage MProductCategory pc = MProductCategory.Get(GetCtx(), product.GetM_Product_Category_ID()); String MMPolicy = pc.GetMMPolicy(); if (MMPolicy == null || MMPolicy.Length == 0) { MMPolicy = client.GetMMPolicy(); } // MStorage[] storages = MStorage.GetWarehouse(GetCtx(), whSource.GetM_Warehouse_ID(), replenish.GetM_Product_ID(), 0, 0, true, null, MClient.MMPOLICY_FiFo.Equals(MMPolicy), Get_TrxName()); if (storages == null || storages.Length == 0) { AddLog("No Inventory in " + whSource.GetName() + " for " + product.GetName()); continue; } // Decimal target = replenish.GetQtyToOrder(); for (int j = 0; j < storages.Length; j++) { MStorage storage = storages[j]; //if (storage.GetQtyOnHand().signum() <= 0) if (Env.Signum(storage.GetQtyOnHand()) <= 0) { continue; } Decimal moveQty = target; if (storage.GetQtyOnHand().CompareTo(moveQty) < 0) { moveQty = storage.GetQtyOnHand(); } // MMovementLine line = new MMovementLine(move); line.SetM_Product_ID(replenish.GetM_Product_ID()); line.SetMovementQty(moveQty); if (replenish.GetQtyToOrder().CompareTo(moveQty) != 0) { line.SetDescription("Total: " + replenish.GetQtyToOrder()); } line.SetM_Locator_ID(storage.GetM_Locator_ID()); // from line.SetM_AttributeSetInstance_ID(storage.GetM_AttributeSetInstance_ID()); line.SetM_LocatorTo_ID(M_LocatorTo_ID); // to line.SetM_AttributeSetInstanceTo_ID(storage.GetM_AttributeSetInstance_ID()); line.Save(); // //target = target.subtract(moveQty); target = Decimal.Subtract(target, moveQty); //if (target.signum() == 0) if (Env.Signum(target) == 0) { break; } } if (Env.Signum(target) != 0) { AddLog("Insufficient Inventory in " + whSource.GetName() + " for " + product.GetName() + " Qty=" + target); } } if (replenishs.Length == 0) { _info = "No Source Warehouse"; log.Warning(_info); } else { _info = "#" + noMoves + info; log.Info(_info); } } // createRequisition
/// <summary> /// Generate Shipments /// </summary> /// <param name="idr">Order Query</param> /// <returns>info</returns> private String Generate(IDataReader idr) { DataTable dt = new DataTable(); MClient client = MClient.Get(GetCtx()); try { dt.Load(idr); idr.Close(); //ResultSet dr = pstmt.executeQuery(); foreach (DataRow dr in dt.Rows)// while (dr.next ()) // Order { MOrder order = new MOrder(GetCtx(), dr, Get_TrxName()); // New Header different Shipper, Shipment Location if (!_consolidateDocument || (_shipment != null && (_shipment.GetC_BPartner_Location_ID() != order.GetC_BPartner_Location_ID() || _shipment.GetM_Shipper_ID() != order.GetM_Shipper_ID()))) { CompleteShipment(); } log.Fine("check: " + order + " - DeliveryRule=" + order.GetDeliveryRule()); // DateTime?minGuaranteeDate = _movementDate; bool completeOrder = MOrder.DELIVERYRULE_CompleteOrder.Equals(order.GetDeliveryRule()); // OrderLine WHERE String where = " AND M_Warehouse_ID=" + _M_Warehouse_ID; if (_datePromised != null) { where += " AND (TRUNC(DatePromised,'DD')<=" + DB.TO_DATE((DateTime?)_datePromised, true) + " OR DatePromised IS NULL)"; //where += " AND (TRUNC(DatePromised,'DD')<='" + String.Format("{0:dd-MMM-yy}", _datePromised) // + "' OR DatePromised IS NULL)"; } // Exclude Auto Delivery if not Force if (!MOrder.DELIVERYRULE_Force.Equals(order.GetDeliveryRule())) { where += " AND (C_OrderLine.M_Product_ID IS NULL" + " OR EXISTS (SELECT * FROM M_Product p " + "WHERE C_OrderLine.M_Product_ID=p.M_Product_ID" + " AND IsExcludeAutoDelivery='N'))"; } // Exclude Unconfirmed if (!_isUnconfirmedInOut) { where += " AND NOT EXISTS (SELECT * FROM M_InOutLine iol" + " INNER JOIN M_InOut io ON (iol.M_InOut_ID=io.M_InOut_ID) " + "WHERE iol.C_OrderLine_ID=C_OrderLine.C_OrderLine_ID AND io.DocStatus IN ('IP','WC'))"; } // Deadlock Prevention - Order by M_Product_ID MOrderLine[] lines = order.GetLines(where, "ORDER BY C_BPartner_Location_ID, M_Product_ID"); for (int i = 0; i < lines.Length; i++) { MOrderLine line = lines[i]; if (line.GetM_Warehouse_ID() != _M_Warehouse_ID) { continue; } log.Fine("check: " + line); Decimal onHand = Env.ZERO; Decimal toDeliver = Decimal.Subtract(line.GetQtyOrdered(), line.GetQtyDelivered()); MProduct product = line.GetProduct(); // Nothing to Deliver if (product != null && Env.Signum(toDeliver) == 0) { continue; } // Check / adjust for confirmations Decimal unconfirmedShippedQty = Env.ZERO; if (_isUnconfirmedInOut && product != null && Env.Signum(toDeliver) != 0) { String where2 = "EXISTS (SELECT * FROM M_InOut io WHERE io.M_InOut_ID=M_InOutLine.M_InOut_ID AND io.DocStatus IN ('IP','WC'))"; MInOutLine[] iols = MInOutLine.GetOfOrderLine(GetCtx(), line.GetC_OrderLine_ID(), where2, null); for (int j = 0; j < iols.Length; j++) { unconfirmedShippedQty = Decimal.Add(unconfirmedShippedQty, iols[j].GetMovementQty()); } String logInfo = "Unconfirmed Qty=" + unconfirmedShippedQty + " - ToDeliver=" + toDeliver + "->"; toDeliver = Decimal.Subtract(toDeliver, unconfirmedShippedQty); logInfo += toDeliver; if (Env.Signum(toDeliver) < 0) { toDeliver = Env.ZERO; logInfo += " (set to 0)"; } // Adjust On Hand onHand = Decimal.Subtract(onHand, unconfirmedShippedQty); log.Fine(logInfo); } // Comments & lines w/o product & services if ((product == null || !product.IsStocked()) && (Env.Signum(line.GetQtyOrdered()) == 0 || // comments Env.Signum(toDeliver) != 0)) // lines w/o product { if (!MOrder.DELIVERYRULE_CompleteOrder.Equals(order.GetDeliveryRule())) // printed later { CreateLine(order, line, toDeliver, null, false); } continue; } // Stored Product MProductCategory pc = MProductCategory.Get(order.GetCtx(), product.GetM_Product_Category_ID()); String MMPolicy = pc.GetMMPolicy(); if (MMPolicy == null || MMPolicy.Length == 0) { MMPolicy = client.GetMMPolicy(); } // MStorage[] storages = GetStorages(line.GetM_Warehouse_ID(), line.GetM_Product_ID(), line.GetM_AttributeSetInstance_ID(), product.GetM_AttributeSet_ID(), line.GetM_AttributeSetInstance_ID() == 0, (DateTime?)minGuaranteeDate, MClient.MMPOLICY_FiFo.Equals(MMPolicy)); for (int j = 0; j < storages.Length; j++) { MStorage storage = storages[j]; onHand = Decimal.Add(onHand, storage.GetQtyOnHand()); } bool fullLine = onHand.CompareTo(toDeliver) >= 0 || Env.Signum(toDeliver) < 0; // Complete Order if (completeOrder && !fullLine) { log.Fine("Failed CompleteOrder - OnHand=" + onHand + " (Unconfirmed=" + unconfirmedShippedQty + "), ToDeliver=" + toDeliver + " - " + line); completeOrder = false; break; } // Complete Line else if (fullLine && MOrder.DELIVERYRULE_CompleteLine.Equals(order.GetDeliveryRule())) { log.Fine("CompleteLine - OnHand=" + onHand + " (Unconfirmed=" + unconfirmedShippedQty + ", ToDeliver=" + toDeliver + " - " + line); // CreateLine(order, line, toDeliver, storages, false); } // Availability else if (MOrder.DELIVERYRULE_Availability.Equals(order.GetDeliveryRule()) && (Env.Signum(onHand) > 0 || Env.Signum(toDeliver) < 0)) { Decimal deliver = toDeliver; if (deliver.CompareTo(onHand) > 0) { deliver = onHand; } log.Fine("Available - OnHand=" + onHand + " (Unconfirmed=" + unconfirmedShippedQty + "), ToDeliver=" + toDeliver + ", Delivering=" + deliver + " - " + line); // CreateLine(order, line, deliver, storages, false); } // Force else if (MOrder.DELIVERYRULE_Force.Equals(order.GetDeliveryRule())) { Decimal deliver = toDeliver; log.Fine("Force - OnHand=" + onHand + " (Unconfirmed=" + unconfirmedShippedQty + "), ToDeliver=" + toDeliver + ", Delivering=" + deliver + " - " + line); // CreateLine(order, line, deliver, storages, true); } // Manual else if (MOrder.DELIVERYRULE_Manual.Equals(order.GetDeliveryRule())) { log.Fine("Manual - OnHand=" + onHand + " (Unconfirmed=" + unconfirmedShippedQty + ") - " + line); } else { log.Fine("Failed: " + order.GetDeliveryRule() + " - OnHand=" + onHand + " (Unconfirmed=" + unconfirmedShippedQty + "), ToDeliver=" + toDeliver + " - " + line); } } // for all order lines // Complete Order successful if (completeOrder && MOrder.DELIVERYRULE_CompleteOrder.Equals(order.GetDeliveryRule())) { for (int i = 0; i < lines.Length; i++) { MOrderLine line = lines[i]; if (line.GetM_Warehouse_ID() != _M_Warehouse_ID) { continue; } MProduct product = line.GetProduct(); Decimal toDeliver = Decimal.Subtract(line.GetQtyOrdered(), line.GetQtyDelivered()); // MStorage[] storages = null; if (product != null && product.IsStocked()) { MProductCategory pc = MProductCategory.Get(order.GetCtx(), product.GetM_Product_Category_ID()); String MMPolicy = pc.GetMMPolicy(); if (MMPolicy == null || MMPolicy.Length == 0) { MMPolicy = client.GetMMPolicy(); } // storages = GetStorages(line.GetM_Warehouse_ID(), line.GetM_Product_ID(), line.GetM_AttributeSetInstance_ID(), product.GetM_AttributeSet_ID(), line.GetM_AttributeSetInstance_ID() == 0, (DateTime?)minGuaranteeDate, MClient.MMPOLICY_FiFo.Equals(MMPolicy)); } // CreateLine(order, line, toDeliver, storages, false); } } _line += 1000; } // while order } catch (Exception e) { if (idr != null) { idr.Close(); } log.Log(Level.SEVERE, _sql, e); } finally { if (idr != null) { idr.Close(); } dt = null; } CompleteShipment(); return("@Created@ = " + _created); }