/// <summary> /// Shipment Line Constructor /// </summary> /// <param name="sLine">shipment line</param> /// <param name="dateTrx">optional date</param> /// <param name="qty">matched quantity</param> public MMatchPO(MInOutLine sLine, DateTime?dateTrx, Decimal qty) : this(sLine.GetCtx(), 0, sLine.Get_Trx()) { SetClientOrg(sLine); SetM_InOutLine_ID(sLine.GetM_InOutLine_ID()); SetC_OrderLine_ID(sLine.GetC_OrderLine_ID()); if (dateTrx != null) { SetDateTrx(dateTrx); } SetM_Product_ID(sLine.GetM_Product_ID()); SetM_AttributeSetInstance_ID(sLine.GetM_AttributeSetInstance_ID()); SetQty(qty); SetProcessed(true); // auto }
public void SetInoutLine(VAdvantage.Model.MInOutLine line) { int _CountDTD001 = Util.GetValueOfInt(DB.ExecuteScalar("SELECT COUNT(AD_MODULEINFO_ID) FROM AD_MODULEINFO WHERE PREFIX='DTD001_'")); if (_CountDTD001 > 0) { SetM_InOutLine_ID(line.GetM_InOut_ID()); SetDTD001_TotalQty(line.GetMovementQty()); SetM_Product_ID(line.GetM_Product_ID()); SetM_AttributeSetInstance_ID(line.GetM_AttributeSetInstance_ID()); decimal totalPackQty = Util.GetValueOfDecimal(DB.ExecuteScalar("SELECT SUM(Qty) FROM M_PackageLine WHERE M_InOutLine_ID=" + GetM_InOutLine_ID())); SetQty(line.GetMovementQty() - totalPackQty); SetDTD001_AlreadyPackQty(totalPackQty); SetConfirmedQty(line.GetMovementQty() - totalPackQty); SetDTD001_ConfirmDate(System.DateTime.Now); } }
/** * Before Save * @param newRecord new * @return true */ protected override bool BeforeSave(bool newRecord) { // Set Trx Date if (GetDateTrx() == null) { SetDateTrx(new DateTime(CommonFunctions.CurrentTimeMillis())); } // Set Acct Date if (GetDateAcct() == null) { DateTime?ts = GetNewerDateAcct(); if (ts == null) { ts = GetDateTrx(); } SetDateAcct(ts); } if (GetM_AttributeSetInstance_ID() == 0 && GetM_InOutLine_ID() != 0) { MInOutLine iol = new MInOutLine(GetCtx(), GetM_InOutLine_ID(), Get_TrxName()); SetM_AttributeSetInstance_ID(iol.GetM_AttributeSetInstance_ID()); } return(true); }
/// <summary> /// Set Shipment Line /// </summary> /// <param name="line">line</param> public void SetInOutLine(MInOutLine line, DateTime?moveDate, String DocumentNo, Int32 Client_ID, Int32 Org_ID) { SetM_InOutLine_ID(line.GetM_InOutLine_ID()); SetQty(line.GetMovementQty()); //Edited :Arpit Rai ,13 Sept,2017 //to Set Client,Org,Confirm Date,Confirm Date, Scrapped Qty, Difference Qty & Reference No SetAD_Client_ID(Client_ID); SetAD_Org_ID(Org_ID); SetM_Product_ID(line.GetM_Product_ID()); SetM_AttributeSetInstance_ID(line.GetM_AttributeSetInstance_ID()); if (Util.GetValueOfInt(DB.ExecuteQuery("SELECT COUNT(AD_MODULEINFO_ID) FROM AD_MODULEINFO WHERE PREFIX='DTD001_' AND IsActive='Y'")) > 0 ) { if (moveDate != null) { SetDTD001_ConfirmDate(moveDate); } SetDTD001_ReferenceNo(DocumentNo); //Set Reference No from MR/Shipment to package Lines } SetConfirmedQty(line.GetConfirmedQty()); SetScrappedQty(line.GetScrappedQty()); SetDifferenceQty(Decimal.Subtract(line.GetMovementQty(), line.GetConfirmedQty() + line.GetScrappedQty())); //Arpit }
/** * Shipment Constructor * @param shipment shipment * @param shipLine shipment line * @param deliveryCount 0 or number of delivery */ public MAsset(MInOut shipment, MInOutLine shipLine, int deliveryCount) : this(shipment.GetCtx(), 0, shipment.Get_TrxName()) { SetClientOrg(shipment); SetValueNameDescription(shipment, shipLine, deliveryCount); // Header // SetIsOwned(true); SetC_BPartner_ID(shipment.GetC_BPartner_ID()); SetC_BPartner_Location_ID(shipment.GetC_BPartner_Location_ID()); SetAD_User_ID(shipment.GetAD_User_ID()); SetM_Locator_ID(shipLine.GetM_Locator_ID()); SetIsInPosession(true); SetAssetServiceDate(shipment.GetDateAcct()); // Line MProduct product = shipLine.GetProduct(); SetM_Product_ID(product.GetM_Product_ID()); SetA_Asset_Group_ID(product.GetA_Asset_Group_ID()); //////////////////////////////* //Changes for vafam // SetAssetServiceDate(shipment.GetMovementDate()); //SetGuaranteeDate(TimeUtil.AddDays(shipment.GetMovementDate(), product.GetGuaranteeDays())); MAssetGroup _assetGroup = new MAssetGroup(GetCtx(), GetA_Asset_Group_ID(), shipment.Get_TrxName()); if (_assetGroup.IsOwned()) { SetIsOwned(true); //SetC_BPartner_ID(0); } if (_assetGroup.IsDepreciated()) { SetIsDepreciated(true); SetIsFullyDepreciated(false); } //Change by Sukhwinder for setting Asset type and amortization template on Asset window, MANTIS ID:1762 int countVA038 = Util.GetValueOfInt(DB.ExecuteScalar("SELECT COUNT(AD_MODULEINFO_ID) FROM AD_MODULEINFO WHERE PREFIX='VA038_' ")); int countVAFAM = Util.GetValueOfInt(DB.ExecuteScalar("SELECT COUNT(AD_MODULEINFO_ID) FROM AD_MODULEINFO WHERE PREFIX='VAFAM_' ")); if (countVA038 > 0) { Set_Value("VA038_AmortizationTemplate_ID", Utility.Util.GetValueOfInt(_assetGroup.Get_Value("VA038_AmortizationTemplate_ID"))); } if (countVAFAM > 0) { Set_Value("VAFAM_AssetType", _assetGroup.Get_Value("VAFAM_AssetType").ToString()); Set_Value("VAFAM_DepreciationType_ID", Utility.Util.GetValueOfInt(_assetGroup.Get_Value("VAFAM_DepreciationType_ID"))); } //////////////////////////////////// // Guarantee & Version SetGuaranteeDate(TimeUtil.AddDays(shipment.GetMovementDate(), product.GetGuaranteeDays())); SetVersionNo(product.GetVersionNo()); if (shipLine.GetM_AttributeSetInstance_ID() != 0) // Instance { MAttributeSetInstance asi = new MAttributeSetInstance(GetCtx(), shipLine.GetM_AttributeSetInstance_ID(), Get_TrxName()); SetM_AttributeSetInstance_ID(asi.GetM_AttributeSetInstance_ID()); SetLot(asi.GetLot()); SetSerNo(asi.GetSerNo()); } SetHelp(shipLine.GetDescription()); // Qty int units = product.GetSupportUnits(); if (units == 0) { units = 1; } if (deliveryCount != 0) // one asset per UOM { SetQty(shipLine.GetMovementQty(), units); } else { SetQty((Decimal)units); } SetM_InOutLine_ID(shipLine.GetM_InOutLine_ID()); // Activate MAssetGroup ag = MAssetGroup.Get(GetCtx(), GetA_Asset_Group_ID()); if (!ag.IsCreateAsActive()) { SetIsActive(false); } }
/// <summary> /// Before Save /// </summary> /// <param name="newRecord">new</param> /// <returns>true</returns> protected override bool BeforeSave(bool newRecord) { // Set Trx Date if (GetDateTrx() == null) { SetDateTrx(DateTime.Now); } // Set Acct Date if (GetDateAcct() == null) { DateTime?ts = GetNewerDateAcct(); if (ts == null) { ts = GetDateTrx(); } SetDateAcct((DateTime?)ts); } // Set ASI from Receipt if (GetM_AttributeSetInstance_ID() == 0 && GetM_InOutLine_ID() != 0) { MInOutLine iol = new MInOutLine(GetCtx(), GetM_InOutLine_ID(), Get_Trx()); SetM_AttributeSetInstance_ID(iol.GetM_AttributeSetInstance_ID()); } // Find OrderLine if (GetC_OrderLine_ID() == 0) { MInvoiceLine il = null; if (GetC_InvoiceLine_ID() != 0) { il = GetInvoiceLine(); if (il.GetC_OrderLine_ID() != 0) { SetC_OrderLine_ID(il.GetC_OrderLine_ID()); } } // get from invoice if (GetC_OrderLine_ID() == 0 && GetM_InOutLine_ID() != 0) { MInOutLine iol = new MInOutLine(GetCtx(), GetM_InOutLine_ID(), Get_Trx()); if (iol.GetC_OrderLine_ID() != 0) { SetC_OrderLine_ID(iol.GetC_OrderLine_ID()); if (il != null) { il.SetC_OrderLine_ID(iol.GetC_OrderLine_ID()); il.Save(); } } } // get from shipment } // find order line // Price Match Approval if (GetC_OrderLine_ID() != 0 && GetC_InvoiceLine_ID() != 0 && (newRecord || Is_ValueChanged("C_OrderLine_ID") || Is_ValueChanged("C_InvoiceLine_ID"))) { Decimal poPrice = GetOrderLine().GetPriceActual(); Decimal invPrice = GetInvoiceLine().GetPriceActual(); Decimal difference = Decimal.Subtract(poPrice, invPrice); if (Math.Sign(difference) != 0) { difference = Decimal.Multiply(difference, GetQty()); SetPriceMatchDifference(difference); // Approval //MBPGroup group = MBPGroup.getOfBPartner(GetCtx(), GetOrderLine().GetC_BPartner_ID()); Decimal mt = 0; //group.getPriceMatchTolerance(); if (Math.Sign(mt) != 0) { Decimal poAmt = Decimal.Multiply(poPrice, GetQty()); Decimal maxTolerance = Decimal.Multiply(poAmt, mt); //maxTolerance = Math.Abs(maxTolerance) // .divide(Env.ONEHUNDRED, 2, Decimal.ROUND_HALF_UP); maxTolerance = Decimal.Divide(Math.Abs(maxTolerance), Env.ONEHUNDRED); difference = Math.Abs(difference); bool ok = difference.CompareTo(maxTolerance) <= 0; //log.config("Difference=" + GetPriceMatchDifference() // + ", Max=" + maxTolerance + " => " + ok); SetIsApproved(ok); } } else { SetPriceMatchDifference(difference); SetIsApproved(true); } } return(true); }
/** * Find/Create PO(Inv) Match * @param iLine invoice line * @param sLine receipt line * @param dateTrx date * @param qty qty * @return Match Record */ public static MMatchPO Create(MInvoiceLine iLine, MInOutLine sLine, DateTime?dateTrx, Decimal qty) { Trx trxName = null; Ctx ctx = null; int C_OrderLine_ID = 0; if (iLine != null) { trxName = iLine.Get_Trx(); ctx = iLine.GetCtx(); C_OrderLine_ID = iLine.GetC_OrderLine_ID(); } if (sLine != null) { trxName = sLine.Get_Trx(); ctx = sLine.GetCtx(); C_OrderLine_ID = sLine.GetC_OrderLine_ID(); } MMatchPO retValue = null; String sql = "SELECT * FROM M_MatchPO WHERE C_OrderLine_ID=" + C_OrderLine_ID; // ArrayList list = new ArrayList(); DataSet ds = null; try { ds = DataBase.DB.ExecuteDataset(sql, null, trxName); foreach (DataRow dr in ds.Tables[0].Rows) { MMatchPO mpo = new MMatchPO(ctx, dr, trxName); if (qty.CompareTo(mpo.GetQty()) == 0) { if (iLine != null) { if (mpo.GetC_InvoiceLine_ID() == 0 || mpo.GetC_InvoiceLine_ID() == iLine.GetC_InvoiceLine_ID()) { mpo.SetC_InvoiceLine_ID(iLine); if (iLine.GetM_AttributeSetInstance_ID() != 0) { if (mpo.GetM_AttributeSetInstance_ID() == 0) { mpo.SetM_AttributeSetInstance_ID(iLine.GetM_AttributeSetInstance_ID()); } else if (mpo.GetM_AttributeSetInstance_ID() != iLine.GetM_AttributeSetInstance_ID()) { continue; } } } else { continue; } } if (sLine != null) { if (mpo.GetM_InOutLine_ID() == 0 || mpo.GetM_InOutLine_ID() == sLine.GetM_InOutLine_ID()) { mpo.SetM_InOutLine_ID(sLine.GetM_InOutLine_ID()); if (sLine.GetM_AttributeSetInstance_ID() != 0) { if (mpo.GetM_AttributeSetInstance_ID() == 0) { mpo.SetM_AttributeSetInstance_ID(sLine.GetM_AttributeSetInstance_ID()); } else if (mpo.GetM_AttributeSetInstance_ID() != sLine.GetM_AttributeSetInstance_ID()) { continue; } } } else { continue; } } retValue = mpo; break; } } } catch (Exception e) { s_log.Log(Level.SEVERE, sql, e); } // Create New if (retValue == null) { if (sLine != null) { retValue = new MMatchPO(sLine, dateTrx, qty); if (iLine != null) { retValue.SetC_InvoiceLine_ID(iLine); } } else if (iLine != null) { retValue = new MMatchPO(iLine, dateTrx, qty); } } return(retValue); }
/** * Shipment Constructor * @param shipment shipment * @param shipLine shipment line * @param deliveryCount 0 or number of delivery */ public MAsset(MInOut shipment, MInOutLine shipLine, int deliveryCount) : this(shipment.GetCtx(), 0, shipment.Get_TrxName()) { SetClientOrg(shipment); SetValueNameDescription(shipment, shipLine, deliveryCount); // Header // SetIsOwned(true); SetC_BPartner_ID(shipment.GetC_BPartner_ID()); SetC_BPartner_Location_ID(shipment.GetC_BPartner_Location_ID()); SetAD_User_ID(shipment.GetAD_User_ID()); SetM_Locator_ID(shipLine.GetM_Locator_ID()); SetIsInPosession(true); SetAssetServiceDate(shipment.GetDateAcct()); // Line MProduct product = shipLine.GetProduct(); SetM_Product_ID(product.GetM_Product_ID()); SetA_Asset_Group_ID(product.GetA_Asset_Group_ID()); //////////////////////////////* //Changes for vafam // SetAssetServiceDate(shipment.GetMovementDate()); //SetGuaranteeDate(TimeUtil.AddDays(shipment.GetMovementDate(), product.GetGuaranteeDays())); MAssetGroup _assetGroup = new MAssetGroup(GetCtx(), GetA_Asset_Group_ID(), shipment.Get_TrxName()); if (_assetGroup.IsOwned()) { SetIsOwned(true); //SetC_BPartner_ID(0); } if (_assetGroup.IsDepreciated()) { SetIsDepreciated(true); SetIsFullyDepreciated(false); } //Change by Sukhwinder for setting Asset type and amortization template on Asset window, MANTIS ID:1762 int countVA038 = Util.GetValueOfInt(DB.ExecuteScalar("SELECT COUNT(AD_MODULEINFO_ID) FROM AD_MODULEINFO WHERE PREFIX='VA038_' ")); int countVAFAM = Util.GetValueOfInt(DB.ExecuteScalar("SELECT COUNT(AD_MODULEINFO_ID) FROM AD_MODULEINFO WHERE PREFIX='VAFAM_' ")); if (countVA038 > 0) { Set_Value("VA038_AmortizationTemplate_ID", Utility.Util.GetValueOfInt(_assetGroup.Get_Value("VA038_AmortizationTemplate_ID"))); } if (countVAFAM > 0) { Set_Value("VAFAM_AssetType", _assetGroup.Get_Value("VAFAM_AssetType").ToString()); Set_Value("VAFAM_DepreciationType_ID", Utility.Util.GetValueOfInt(_assetGroup.Get_Value("VAFAM_DepreciationType_ID"))); } //////////////////////////////////// // Guarantee & Version SetGuaranteeDate(TimeUtil.AddDays(shipment.GetMovementDate(), product.GetGuaranteeDays())); SetVersionNo(product.GetVersionNo()); if (shipLine.GetM_AttributeSetInstance_ID() != 0) // Instance { MAttributeSetInstance asi = new MAttributeSetInstance(GetCtx(), shipLine.GetM_AttributeSetInstance_ID(), Get_TrxName()); SetM_AttributeSetInstance_ID(asi.GetM_AttributeSetInstance_ID()); SetLot(asi.GetLot()); SetSerNo(asi.GetSerNo()); } SetHelp(shipLine.GetDescription()); // Qty int units = product.GetSupportUnits(); if (units == 0) { units = 1; } if (deliveryCount != 0) // one asset per UOM { SetQty(shipLine.GetMovementQty(), units); } else { SetQty((Decimal)units); } SetM_InOutLine_ID(shipLine.GetM_InOutLine_ID()); // Activate MAssetGroup ag = MAssetGroup.Get(GetCtx(), GetA_Asset_Group_ID()); if (!ag.IsCreateAsActive()) { SetIsActive(false); } //Check if the Software Industry module installed, update following fields on Asset window if (Env.IsModuleInstalled("VA077_")) { //Set default values SetIsInPosession(false); SetIsOwned(false); SetIsActive(true); SetIsDisposed(false); Set_Value("VA077_SerialNo", shipLine.Get_Value("VA077_SerialNo")); Set_Value("VA077_CNAutodesk", shipLine.Get_Value("VA077_CNAutodesk")); Set_Value("VA077_RegEmail", shipLine.Get_Value("VA077_RegEmail")); Set_Value("VA077_IsCustAsset", "Y"); Set_Value("VA077_OldSN", shipLine.Get_Value("VA077_OldSN")); Set_Value("VA077_UserRef_ID", shipLine.Get_Value("VA077_UserRef_ID")); Set_Value("VA077_ProductInfo", shipLine.Get_Value("VA077_ProductInfo")); Set_Value("VA077_ServiceContract_ID", shipLine.Get_Value("VA077_ServiceContract_ID")); Set_Value("AD_OrgTrx_ID", shipLine.Get_Value("AD_OrgTrx_ID")); if (Util.GetValueOfBool(product.Get_Value("VA077_LicenceTracked"))) { Set_Value("VA077_LicenceTracked", "Y"); } else { Set_Value("VA077_LicenceTracked", "N"); } } }
/** * Shipment Constructor * @param shipment shipment * @param shipLine shipment line * @param deliveryCount 0 or number of delivery */ public MAsset(MInOut shipment, MInOutLine shipLine, int deliveryCount) : this(shipment.GetCtx(), 0, shipment.Get_TrxName()) { SetClientOrg(shipment); SetValueNameDescription(shipment, shipLine, deliveryCount); // Header SetIsOwned(true); SetC_BPartner_ID(shipment.GetC_BPartner_ID()); SetC_BPartner_Location_ID(shipment.GetC_BPartner_Location_ID()); SetAD_User_ID(shipment.GetAD_User_ID()); SetM_Locator_ID(shipLine.GetM_Locator_ID()); SetIsInPosession(true); // Line MProduct product = shipLine.GetProduct(); SetM_Product_ID(product.GetM_Product_ID()); SetA_Asset_Group_ID(product.GetA_Asset_Group_ID()); //////////////////////////////* //Changes for vafam // SetAssetServiceDate(shipment.GetMovementDate()); //SetGuaranteeDate(TimeUtil.AddDays(shipment.GetMovementDate(), product.GetGuaranteeDays())); MAssetGroup _assetGroup = new MAssetGroup(GetCtx(), GetA_Asset_Group_ID(), shipment.Get_TrxName()); if (_assetGroup.IsOwned()) { SetIsOwned(true); //SetC_BPartner_ID(0); } if (_assetGroup.IsDepreciated()) { SetIsDepreciated(true); SetIsFullyDepreciated(false); } //////////////////////////////////// // Guarantee & Version SetGuaranteeDate(TimeUtil.AddDays(shipment.GetMovementDate(), product.GetGuaranteeDays())); SetVersionNo(product.GetVersionNo()); if (shipLine.GetM_AttributeSetInstance_ID() != 0) // Instance { MAttributeSetInstance asi = new MAttributeSetInstance(GetCtx(), shipLine.GetM_AttributeSetInstance_ID(), Get_TrxName()); SetM_AttributeSetInstance_ID(asi.GetM_AttributeSetInstance_ID()); SetLot(asi.GetLot()); SetSerNo(asi.GetSerNo()); } SetHelp(shipLine.GetDescription()); // Qty int units = product.GetSupportUnits(); if (units == 0) { units = 1; } if (deliveryCount != 0) // one asset per UOM { SetQty(shipLine.GetMovementQty(), units); } else { SetQty((Decimal)units); } SetM_InOutLine_ID(shipLine.GetM_InOutLine_ID()); // Activate MAssetGroup ag = MAssetGroup.Get(GetCtx(), GetA_Asset_Group_ID()); if (!ag.IsCreateAsActive()) { SetIsActive(false); } }
/** * Create Difference Document * @param inout shipment/receipt * @param confirm confirm line * @return true if created */ private bool CreateDifferenceDoc(MInOut inout, MInOutLineConfirm confirm) { if (_processMsg == null) { _processMsg = ""; } else if (_processMsg.Length > 0) { _processMsg += "; "; } // Credit Memo if linked Document if (Env.Signum(confirm.GetDifferenceQty()) != 0 && !inout.IsSOTrx() && !inout.IsReturnTrx() && inout.GetRef_InOut_ID() != 0) { log.Info("Difference=" + confirm.GetDifferenceQty()); if (_creditMemo == null) { _creditMemo = new MInvoice(inout, null); _creditMemo.SetDescription(Msg.Translate(GetCtx(), "M_InOutConfirm_ID") + " " + GetDocumentNo()); _creditMemo.SetC_DocTypeTarget_ID(MDocBaseType.DOCBASETYPE_APCREDITMEMO); if (!_creditMemo.Save(Get_TrxName())) { _processMsg += "Credit Memo not created"; return(false); } SetC_Invoice_ID(_creditMemo.GetC_Invoice_ID()); } MInvoiceLine line = new MInvoiceLine(_creditMemo); line.SetShipLine(confirm.GetLine()); line.SetQty(confirm.GetDifferenceQty()); // Entered/Invoiced if (!line.Save(Get_TrxName())) { _processMsg += "Credit Memo Line not created"; return(false); } confirm.SetC_InvoiceLine_ID(line.GetC_InvoiceLine_ID()); } // Create Inventory Difference if (Env.Signum(confirm.GetScrappedQty()) != 0) { log.Info("Scrapped=" + confirm.GetScrappedQty()); if (_inventory == null) { MWarehouse wh = MWarehouse.Get(GetCtx(), inout.GetM_Warehouse_ID()); _inventory = new MInventory(wh); _inventory.SetDescription(Msg.Translate(GetCtx(), "M_InOutConfirm_ID") + " " + GetDocumentNo()); if (!_inventory.Save(Get_TrxName())) { _processMsg += "Inventory not created"; return(false); } SetM_Inventory_ID(_inventory.GetM_Inventory_ID()); } MInOutLine ioLine = confirm.GetLine(); MInventoryLine line = new MInventoryLine(_inventory, ioLine.GetM_Locator_ID(), ioLine.GetM_Product_ID(), ioLine.GetM_AttributeSetInstance_ID(), confirm.GetScrappedQty(), Env.ZERO); if (!line.Save(Get_TrxName())) { _processMsg += "Inventory Line not created"; return(false); } confirm.SetM_InventoryLine_ID(line.GetM_InventoryLine_ID()); } // if (!confirm.Save(Get_TrxName())) { _processMsg += "Confirmation Line not saved"; return(false); } return(true); }
/** * Split Shipment into confirmed and dispute * @param original original shipment * @param C_DocType_ID target DocType * @param confirmLines confirm lines */ private void SplitInOut(MInOut original, int C_DocType_ID, MInOutLineConfirm[] confirmLines) { MInOut split = new MInOut(original, C_DocType_ID, original.GetMovementDate()); split.AddDescription("Splitted from " + original.GetDocumentNo()); split.SetIsInDispute(true); //nnayak : Change for bug 1431337 split.SetRef_InOut_ID(original.Get_ID()); if (!split.Save(Get_TrxName())) { throw new Exception("Cannot save Split"); } original.AddDescription("Split: " + split.GetDocumentNo()); if (!original.Save(Get_TrxName())) { throw new Exception("Cannot update original Shipment"); } // Go through confirmations for (int i = 0; i < confirmLines.Length; i++) { MInOutLineConfirm confirmLine = confirmLines[i]; Decimal differenceQty = confirmLine.GetDifferenceQty(); if (differenceQty.CompareTo(Env.ZERO) == 0) { continue; } // MInOutLine oldLine = confirmLine.GetLine(); log.Fine("Qty=" + differenceQty + ", Old=" + oldLine); // MInOutLine splitLine = new MInOutLine(split); splitLine.SetC_OrderLine_ID(oldLine.GetC_OrderLine_ID()); splitLine.SetC_UOM_ID(oldLine.GetC_UOM_ID()); splitLine.SetDescription(oldLine.GetDescription()); splitLine.SetIsDescription(oldLine.IsDescription()); splitLine.SetLine(oldLine.GetLine()); splitLine.SetM_AttributeSetInstance_ID(oldLine.GetM_AttributeSetInstance_ID()); splitLine.SetM_Locator_ID(oldLine.GetM_Locator_ID()); splitLine.SetM_Product_ID(oldLine.GetM_Product_ID()); splitLine.SetM_Warehouse_ID(oldLine.GetM_Warehouse_ID()); splitLine.SetRef_InOutLine_ID(oldLine.GetRef_InOutLine_ID()); splitLine.AddDescription("Split: from " + oldLine.GetMovementQty()); // Qtys splitLine.SetQty(differenceQty); // Entered/Movement if (!splitLine.Save(Get_TrxName())) { throw new Exception("Cannot save Split Line"); } // Old oldLine.AddDescription("Splitted: from " + oldLine.GetMovementQty()); oldLine.SetQty(Decimal.Subtract(oldLine.GetMovementQty(), differenceQty)); if (!oldLine.Save(Get_TrxName())) { throw new Exception("Cannot save Splited Line"); } // Update Confirmation Line confirmLine.SetTargetQty(Decimal.Subtract(confirmLine.GetTargetQty(), differenceQty)); confirmLine.SetDifferenceQty(Env.ZERO); if (!confirmLine.Save(Get_TrxName())) { throw new Exception("Cannot save Split Confirmation"); } } // for all confirmations _processMsg = "Split @M_InOut_ID@=" + split.GetDocumentNo() + " - @M_InOutConfirm_ID@="; // Create Dispute Confirmation split.ProcessIt(DocActionVariables.ACTION_PREPARE); // split.createConfirmation(); split.Save(Get_TrxName()); MInOutConfirm[] splitConfirms = split.GetConfirmations(true); if (splitConfirms.Length > 0) { int index = 0; if (splitConfirms[index].IsProcessed()) { if (splitConfirms.Length > 1) { index++; // try just next } if (splitConfirms[index].IsProcessed()) { _processMsg += splitConfirms[index].GetDocumentNo() + " processed??"; return; } } splitConfirms[index].SetIsInDispute(true); splitConfirms[index].Save(Get_TrxName()); _processMsg += splitConfirms[index].GetDocumentNo(); // Set Lines to unconfirmed MInOutLineConfirm[] splitConfirmLines = splitConfirms[index].GetLines(false); for (int i = 0; i < splitConfirmLines.Length; i++) { MInOutLineConfirm splitConfirmLine = splitConfirmLines[i]; splitConfirmLine.SetScrappedQty(Env.ZERO); splitConfirmLine.SetConfirmedQty(Env.ZERO); splitConfirmLine.Save(Get_TrxName()); } } else { _processMsg += "??"; } }