public virtual bool IsApplicable(PXGraph graph, LandedCostCode aCode, POReceiptLine aLine) { bool transferinsidewarehouse = false; if (aLine.ReceiptType == POReceiptType.TransferReceipt) { INTran ortran = INTran.PK.Find(graph, aLine.OrigDocType, aLine.OrigRefNbr, aLine.OrigLineNbr); transferinsidewarehouse = (ortran == null || ortran.SiteID == aLine.SiteID); } if (transferinsidewarehouse == false) { HasApplicableTransfers = true; } //Memo - in this release, non-stock Items are not applicable for the landed cost. Review later. return(!transferinsidewarehouse && (aCode.AllocationMethod != LandedCostAllocationMethod.None && (aLine.LineType == POLineType.GoodsForInventory || aLine.LineType == POLineType.GoodsForReplenishment || aLine.LineType == POLineType.GoodsForSalesOrder || aLine.LineType == POLineType.GoodsForDropShip || aLine.LineType == POLineType.NonStock || aLine.LineType == POLineType.NonStockForDropShip || aLine.LineType == POLineType.NonStockForSalesOrder || aLine.LineType == POLineType.GoodsForServiceOrder || aLine.LineType == POLineType.NonStockForServiceOrder || aLine.LineType == POLineType.GoodsForManufacturing || aLine.LineType == POLineType.NonStockForManufacturing))); }
public POLandedCostReceiptLineAdjustment(POReceiptLine receiptLine, POLandedCostReceiptLine landedCostReceiptLine, POLandedCostDetail landedCostDetail, decimal qtyToAssign, int?branchID) : base(receiptLine, qtyToAssign, branchID) { LandedCostReceiptLine = landedCostReceiptLine; LandedCostDetail = landedCostDetail; }
public bool IsApplicable(LandedCostCode aCode, POReceiptLine aLine) { bool transferinsidewarehouse = false; if (aLine.ReceiptType == POReceiptType.TransferReceipt) { INTran ortran = PXSelectReadonly <INTran, Where <INTran.tranType, Equal <Required <INTran.origTranType> >, And <INTran.refNbr, Equal <Required <INTran.origRefNbr> > > > > .SelectWindowed(_graph, 0, 1, aLine.OrigTranType, aLine.OrigRefNbr, aLine.OrigLineNbr); transferinsidewarehouse = (ortran == null || ortran.SiteID == aLine.SiteID); } if (transferinsidewarehouse == false) { HasApplicableTransfers = true; } //Memo - in this release, non-stock Items are not applicable for the landed cost. Review later. return(!transferinsidewarehouse && (aCode.AllocationMethod != LandedCostAllocationMethod.None && (aLine.LineType == POLineType.GoodsForInventory || aLine.LineType == POLineType.GoodsForReplenishment || aLine.LineType == POLineType.GoodsForSalesOrder || aLine.LineType == POLineType.GoodsForDropShip || aLine.LineType == POLineType.NonStock || aLine.LineType == POLineType.NonStockForDropShip || aLine.LineType == POLineType.NonStockForSalesOrder))); }
public static bool IsApplicable(LandedCostCode aCode, POReceiptLine aLine) { //Memo - in this release, non-stock Items are not applicable for the landed cost. Review later. return((aCode.AllocationMethod != LandedCostAllocationMethod.None) && aLine.LineType == POLineType.GoodsForInventory || aLine.LineType == POLineType.GoodsForReplenishment || aLine.LineType == POLineType.GoodsForSalesOrder || aLine.LineType == POLineType.GoodsForDropShip); }
protected void _(Events.FieldSelecting <POReceiptExt.usrTotalCost> e) { Decimal num = 0M; foreach (PXResult <POReceiptLine> pxResult in this.Base.transactions.Select()) { POReceiptLine poReceiptLine = (POReceiptLine)pxResult; num += poReceiptLine.TranCost.GetValueOrDefault(); } e.ReturnValue = (object)num; }
public static Decimal CalcAllocationValue(LandedCostCode aCode, POReceiptLine aLine, Decimal aBaseTotal, Decimal aAllocationTotal) { Decimal value = Decimal.Zero; if (IsApplicable(aCode, aLine)) { Decimal baseShare = GetBaseValue(aCode, aLine); value = (baseShare * aAllocationTotal) / aBaseTotal; } return(value); }
public virtual POReceiptLineAdjustment CreateReceiptLineAdjustment(AllocationItem allocationItem, POReceiptLine receiptLine, decimal qtyToAssign, int?branchID) { if ((allocationItem == null || allocationItem.ReceiptLine == null) && receiptLine == null) { var emptyReceiptLine = new POReceiptLine(); return(new POReceiptLineAdjustment(emptyReceiptLine, qtyToAssign, branchID)); } var result = new POReceiptLineAdjustment(receiptLine ?? allocationItem.ReceiptLine, qtyToAssign, branchID); return(result); }
public INCostAdjustmentInfo(POReceiptLine aLine) { this.InventoryID = aLine.InventoryID; this.SubItemID = aLine.SubItemID; this.SiteID = aLine.SiteID; this.LocationID = aLine.LocationID; this.LotSerialNbr = aLine.LotSerialNbr; this.Quantity = aLine.BaseReceiptQty; this.IsStockItem = aLine.IsStockItem(); this.POReceiptLineNbr = aLine.LineNbr; this.POReceiptNbr = aLine.ReceiptNbr; //Account values may be used for the non stock items this.AccountID = aLine.ExpenseAcctID; this.SubAccountID = aLine.ExpenseSubID; }
public virtual void Copy(POReceiptLine aDest, POLine aSrc, decimal aQtyAdj, decimal aBaseQtyAdj, CopyOrig del) { if (del != null) { del(aDest, aSrc, aQtyAdj, aBaseQtyAdj); } INItemPlan inItemPlanRow = PXSelect <INItemPlan, Where < INItemPlan.supplyPlanID, Equal <Required <INItemPlan.supplyPlanID> >, And <INItemPlan.planType, Equal <Required <INItemPlan.planType> > > > > .Select(Base, aSrc.PlanID, INPlanConstants.PlanF6); if (inItemPlanRow != null && inItemPlanRow.LocationID != null) { aDest.LocationID = inItemPlanRow.LocationID; } }
public override POReceiptLineAdjustment CreateReceiptLineAdjustment(AllocationItem allocationItem, POReceiptLine receiptLine, decimal qtyToAssign, int?branchID) { if ((allocationItem == null || allocationItem.ReceiptLine == null) && receiptLine == null) { var emptyReceiptLine = new POReceiptLine(); return(new POLandedCostReceiptLineAdjustment(emptyReceiptLine, null, null, qtyToAssign, branchID)); } if (!(allocationItem is LandedCostAllocationItem)) { return(base.CreateReceiptLineAdjustment(allocationItem, receiptLine, qtyToAssign, branchID)); } var lcAllocationItemitem = (LandedCostAllocationItem)allocationItem; var result = new POLandedCostReceiptLineAdjustment(receiptLine ?? allocationItem.ReceiptLine, lcAllocationItemitem.LandedCostReceiptLine, lcAllocationItemitem.LandedCostDetail, qtyToAssign, branchID); return(result); }
public static Decimal GetBaseValue(LandedCostCode aCode, POReceiptLine aLine) { Decimal value = Decimal.Zero; switch (aCode.AllocationMethod) { case LandedCostAllocationMethod.ByCost: value = aLine.CuryExtCost ?? Decimal.Zero; break; case LandedCostAllocationMethod.ByQuantity: value = aLine.BaseQty ?? Decimal.Zero; break; case LandedCostAllocationMethod.ByWeight: value = aLine.ExtWeight ?? Decimal.Zero; break; case LandedCostAllocationMethod.ByVolume: value = aLine.ExtVolume ?? Decimal.Zero; break; case LandedCostAllocationMethod.None: value = Decimal.One; break; //Line Count default: throw new PXException(Messages.UnknownLCAllocationMethod, aCode.LandedCostCodeID); } return(value); }
public Decimal CalcAllocationValue(LandedCostCode aCode, POReceiptLineSplit aSplit, POReceiptLine aLine, Decimal aBaseTotal, Decimal aAllocationTotal) { var res = CalcAllocationValue(aCode, aLine, aBaseTotal, aAllocationTotal); return(res * ((aSplit.BaseQty / (aLine.BaseQty == 0 ? (decimal?)null : aLine.BaseQty)) ?? 1)); }
public virtual decimal AllocateOverRCTLine( PXGraph graph, List <POReceiptLineAdjustment> result, AllocationItem allocationItem, decimal toDistribute, Int32?branchID) { // the artificial object is used for allocating the landed cost amount between splits (by quantity) var nAllocationItem = new AllocationItem() { LandedCostCode = new LandedCostCode() { AllocationMethod = LandedCostAllocationMethod.ByQuantity }, ReceiptLine = allocationItem.ReceiptLine, }; InventoryItem ii = InventoryItem.PK.Find(graph, allocationItem.ReceiptLine.InventoryID.Value); bool requireLotSerial = (ii.ValMethod == INValMethod.Specific); List <Type> bql = new List <Type>(16) { typeof(Select4 <, ,>), typeof(POReceiptLineSplit), typeof(Where <POReceiptLineSplit.receiptType, Equal <Required <POReceiptLine.receiptType> >, And <POReceiptLineSplit.receiptNbr, Equal <Required <POReceiptLine.receiptNbr> >, And <POReceiptLineSplit.lineNbr, Equal <Required <POReceiptLine.lineNbr> > > > >), typeof(Aggregate <>), typeof(GroupBy <,>), typeof(POReceiptLineSplit.locationID), typeof(GroupBy <,>), typeof(POReceiptLineSplit.subItemID), typeof(Sum <>), typeof(POReceiptLineSplit.baseQty), }; if (requireLotSerial) { bql.Insert(bql.Count - 2, typeof(GroupBy <,>)); bql.Insert(bql.Count - 2, typeof(POReceiptLineSplit.lotSerialNbr)); } PXView splitsView = new PXView(graph, false, BqlCommand.CreateInstance(bql.ToArray())); var splits = splitsView.SelectMulti(allocationItem.ReceiptLine.ReceiptType, allocationItem.ReceiptLine.ReceiptNbr, allocationItem.ReceiptLine.LineNbr); bool hasSplits = false; decimal baseTotal = GetBaseValue(nAllocationItem); decimal allocatedBase = 0m; decimal allocatingBase = 0m; decimal allocatedAmt = 0m; POReceiptLineSplit maxSplit = null; foreach (POReceiptLineSplit split in splits) { hasSplits = true; allocatingBase += split.BaseQty ?? 0m; decimal handledSplitsAmt = (baseTotal == 0m) ? 0m : (allocatedBase + allocatingBase) * toDistribute / baseTotal; handledSplitsAmt = PXDBCurrencyAttribute.BaseRound(graph, handledSplitsAmt); decimal shareAmt = handledSplitsAmt - allocatedAmt; if (maxSplit == null || maxSplit.BaseQty < split.BaseQty) { maxSplit = split; } if (shareAmt != 0m) { POReceiptLine newPOReceiptLine = PXCache <POReceiptLine> .CreateCopy(allocationItem.ReceiptLine); newPOReceiptLine.LocationID = maxSplit.LocationID; newPOReceiptLine.SiteID = maxSplit.SiteID; newPOReceiptLine.SubItemID = maxSplit.SubItemID; newPOReceiptLine.LotSerialNbr = requireLotSerial ? maxSplit.LotSerialNbr : null; var adj = CreateReceiptLineAdjustment(allocationItem, newPOReceiptLine, shareAmt, branchID); result.Add(adj); allocatedAmt += shareAmt; allocatedBase += allocatingBase; allocatingBase = 0m; maxSplit = null; } } if (!hasSplits) { decimal shareAmt = toDistribute; shareAmt = PXDBCurrencyAttribute.BaseRound(graph, shareAmt); if (shareAmt != 0m) { var adj = CreateReceiptLineAdjustment(allocationItem, null, shareAmt, branchID); result.Add(adj); } allocatedAmt = shareAmt; } return(allocatedAmt); }
public bool IsApplicable(LandedCostTran aTran, LandedCostCode aCode, POReceiptLine aLine) { return(IsApplicable(aTran, null, aCode, aLine)); }
public bool IsApplicable(LandedCostTran aTran, IEnumerable <LandedCostTranSplit> aSplits, LandedCostCode aCode, POReceiptLine aLine) { if (!IsApplicable(aCode, aLine)) { return(false); } bool passes = false; if (aSplits != null) { foreach (LandedCostTranSplit it in aSplits) { if (it.POReceiptNbr == aLine.ReceiptNbr) { passes = true; if (passes && it.POReceiptLineNbr.HasValue) { if (it.POReceiptLineNbr != aLine.LineNbr) { passes = false; } } if (passes && it.InventoryID.HasValue) { if (it.InventoryID != aLine.InventoryID) { passes = false; } } } if (passes) { break; } } } if (!passes) { if (String.IsNullOrEmpty(aTran.POReceiptNbr) || (aTran.POReceiptNbr != aLine.ReceiptNbr)) { return(false); } if (aTran.POReceiptLineNbr.HasValue) { if (aTran.POReceiptLineNbr != aLine.LineNbr) { return(false); } } if (aTran.InventoryID.HasValue) { if (aTran.InventoryID != aLine.InventoryID) { return(false); } } passes = true; } if (passes) { if (aTran.SiteID.HasValue) { if (aTran.SiteID != aLine.SiteID) { return(false); } } if (aTran.LocationID.HasValue) { if (aTran.LocationID != aLine.LocationID) { return(false); } } } return(passes); }
//Graph passed in function must be the one using newly created sub in details - otherwise save will fail (inserted subs will be created in other graph) protected static void GetLCVarianceAccountSub(ref int?aAccountID, ref int?aSubID, PXGraph aGraph, POReceiptLine aRow) { if (aRow.InventoryID.HasValue) { PXResult <InventoryItem, INPostClass> res = (PXResult <InventoryItem, INPostClass>) PXSelectJoin <InventoryItem, LeftJoin <INPostClass, On <INPostClass.postClassID, Equal <InventoryItem.postClassID> > >, Where <InventoryItem.inventoryID, Equal <Required <POLine.inventoryID> > > > .Select(aGraph, aRow.InventoryID); if (res != null) { InventoryItem invItem = (InventoryItem)res; INPostClass postClass = (INPostClass)res; if ((bool)invItem.StkItem) { if (postClass == null) { throw new PXException(Messages.PostingClassIsNotDefinedForTheItemInReceiptRow, invItem.InventoryCD, aRow.ReceiptNbr, aRow.LineNbr); } INSite invSite = null; if (aRow.SiteID != null) { invSite = PXSelect <INSite, Where <INSite.siteID, Equal <Required <POReceiptLine.siteID> > > > .Select(aGraph, aRow.SiteID); } if (aRow.LineType == POLineType.GoodsForDropShip) { aAccountID = INReleaseProcess.GetAcctID <INPostClass.cOGSAcctID>(aGraph, postClass.COGSAcctDefault, invItem, invSite, postClass); if (aAccountID == null) { throw new PXException(Messages.COGSAccountCanNotBeFoundForItemInReceiptRow, invItem.InventoryCD, aRow.ReceiptNbr, aRow.LineNbr, postClass.PostClassID, invSite != null ? invSite.SiteCD : String.Empty); } try { aSubID = INReleaseProcess.GetSubID <INPostClass.cOGSSubID>(aGraph, postClass.COGSAcctDefault, postClass.COGSSubMask, invItem, invSite, postClass); } catch (PXException ex) { if (postClass.COGSSubID == null || string.IsNullOrEmpty(postClass.COGSSubMask) || invItem.COGSSubID == null || invSite == null || invSite.COGSSubID == null) { throw new PXException(Messages.COGSSubAccountCanNotBeFoundForItemInReceiptRow, invItem.InventoryCD, aRow.ReceiptNbr, aRow.LineNbr, postClass.PostClassID, invSite != null ? invSite.SiteCD : String.Empty); } else { throw ex; } } if (aSubID == null) { throw new PXException(Messages.COGSSubAccountCanNotBeFoundForItemInReceiptRow, invItem.InventoryCD, aRow.ReceiptNbr, aRow.LineNbr, postClass.PostClassID, invSite != null ? invSite.SiteCD : String.Empty); } } else { aAccountID = INReleaseProcess.GetAcctID <INPostClass.lCVarianceAcctID>(aGraph, postClass.LCVarianceAcctDefault, invItem, invSite, postClass); if (aAccountID == null) { throw new PXException(Messages.LCVarianceAccountCanNotBeFoundForItemInReceiptRow, invItem.InventoryCD, aRow.ReceiptNbr, aRow.LineNbr, postClass.PostClassID, invSite != null ? invSite.SiteCD : String.Empty); } try { aSubID = INReleaseProcess.GetSubID <INPostClass.lCVarianceSubID>(aGraph, postClass.LCVarianceAcctDefault, postClass.LCVarianceSubMask, invItem, invSite, postClass); } catch (PXException ex) { if (postClass.LCVarianceSubID == null || string.IsNullOrEmpty(postClass.LCVarianceSubMask) || invItem.LCVarianceSubID == null || invSite == null || invSite.LCVarianceSubID == null) { throw new PXException(Messages.LCVarianceSubAccountCanNotBeFoundForItemInReceiptRow, invItem.InventoryCD, aRow.ReceiptNbr, aRow.LineNbr, postClass.PostClassID, invSite != null ? invSite.SiteCD : String.Empty); } else { throw ex; } } if (aSubID == null) { throw new PXException(Messages.LCVarianceSubAccountCanNotBeFoundForItemInReceiptRow, invItem.InventoryCD, aRow.ReceiptNbr, aRow.LineNbr, postClass.PostClassID, invSite != null ? invSite.SiteCD : String.Empty); } } } else { aAccountID = aRow.ExpenseAcctID; aSubID = aRow.ExpenseSubID; } } else { throw new PXException(Messages.LCInventoryItemInReceiptRowIsNotFound, aRow.InventoryID, aRow.ReceiptNbr, aRow.LineNbr); } } else { aAccountID = aRow.ExpenseAcctID; aSubID = aRow.ExpenseSubID; } }
public POReceiptLineAdjustment(POReceiptLine receiptLine, decimal allocatedAmt, int?branchID) { ReceiptLine = receiptLine; AllocatedAmt = allocatedAmt; BranchID = branchID; }
string cancelPONonGoods(POReceipt pOReceipt, POReceiptLine pOReceiptLine) { string result = ""; PLNSC.ScreenService.OperationContext SSContextClass = new PLNSC.ScreenService.OperationContext() { district = districtCode, position = positionID, maxInstances = maxInstance }; ScreenService screenService = new ScreenService() { Timeout = sessionTimeout, Url = $"{urlPrefix(dbName)}ScreenService" }; ScreenDTO screenReply = new ScreenDTO(); ScreenSubmitRequestDTO submitRequest = new ScreenSubmitRequestDTO(); try { ClientConversation.authenticate(userName, password); screenReply = screenService.executeScreen(SSContextClass, "MSO155"); screenName = screenReply.mapName; if (screenName != "MSM155A") { throw new PXException(CustomMessage.NotMSO155); } ScreenNameValueDTO[] fields = { new ScreenNameValueDTO(), new ScreenNameValueDTO(), new ScreenNameValueDTO(), new ScreenNameValueDTO() }; fields[0].fieldName = "OPTION1I"; fields[0].value = "3"; fields[1].fieldName = "PO_NO1I"; fields[1].value = pOReceiptLine.PONbr; fields[2].fieldName = "PO_ITEM1I"; fields[2].value = pOReceiptLine.POLineNbr.ToString(); fields[3].fieldName = "AUTH_BY1I"; fields[3].value = "ADMIN"; submitRequest.screenFields = fields; submitRequest.screenKey = "1"; // OK screenReply = screenService.submit(SSContextClass, submitRequest); screenName = screenReply.mapName; errorMsg = screenReply.message; if (errorMsg.Trim() != "" && !screenReply.functionKeys.Contains("XMIT-Confirm")) { throw new PXException(errorMsg.Trim()); } if (screenName != "MSM156A") { throw new PXException(CustomMessage.NotMSM156A); } ScreenNameValueDTO[] fields156 = { new ScreenNameValueDTO(), new ScreenNameValueDTO(), new ScreenNameValueDTO(), new ScreenNameValueDTO() }; string receiptRef = pOReceipt.ReceiptNbr != null ? pOReceipt.ReceiptNbr.Trim() : " "; string cancelValue = Math.Round((pOReceiptLine.CuryExtCost * -1) ?? 0, 2).ToString().Trim(); fields156[0].fieldName = "VALUE_RECVD1I"; fields156[0].value = cancelValue; fields156[1].fieldName = "RECEIPT_REF1I"; fields156[1].value = "S-" + receiptRef + "RT"; fields156[2].fieldName = "RECEIPT_DATE1I"; fields156[2].value = DateTime.Now.ToString("yyyyMMdd"); fields156[3].fieldName = "ANSWER1I"; fields156[3].value = "N"; submitRequest.screenFields = fields156; submitRequest.screenKey = "1"; // OK screenReply = screenService.submit(SSContextClass, submitRequest); screenName = screenReply.mapName; errorMsg = screenReply.message; if (screenReply.functionKeys.Contains("XMIT-Confirm")) { submitRequest.screenKey = "1"; // OK screenReply = screenService.submit(SSContextClass, submitRequest); screenName = screenReply.mapName; errorMsg = screenReply.message; } screenService.positionToMenu(SSContextClass); result = "OK"; } catch (Exception ex) { result = ex.Message; throw new PXException(ex.Message); } return result; }
protected virtual void GetLCVarianceAccountSub(ref int?aAccountID, ref int?aSubID, POReceiptLine receiptLine) { if (receiptLine.InventoryID.HasValue) { var invItem = InventoryItem.PK.Find(_pxGraph, receiptLine.InventoryID); if (invItem != null) { INPostClass postClass = INPostClass.PK.Find(_pxGraph, invItem.PostClassID); if ((bool)invItem.StkItem) { if (postClass == null) { throw new PXException(Messages.PostingClassIsNotDefinedForTheItemInReceiptRow, invItem.InventoryCD, receiptLine.ReceiptNbr, receiptLine.LineNbr); } INSite invSite = null; if (receiptLine.SiteID != null) { invSite = INSite.PK.Find(_pxGraph, receiptLine.SiteID); } if (receiptLine.LineType == POLineType.GoodsForDropShip) { aAccountID = INReleaseProcess.GetAcctID <INPostClass.cOGSAcctID>(_pxGraph, postClass.COGSAcctDefault, invItem, invSite, postClass); if (aAccountID == null) { throw new PXException(Messages.COGSAccountCanNotBeFoundForItemInReceiptRow, invItem.InventoryCD, receiptLine.ReceiptNbr, receiptLine.LineNbr, postClass.PostClassID, invSite != null ? invSite.SiteCD : String.Empty); } try { aSubID = INReleaseProcess.GetSubID <INPostClass.cOGSSubID>(_pxGraph, postClass.COGSAcctDefault, postClass.COGSSubMask, invItem, invSite, postClass); } catch (PXException ex) { if (postClass.COGSSubID == null || string.IsNullOrEmpty(postClass.COGSSubMask) || invItem.COGSSubID == null || invSite == null || invSite.COGSSubID == null) { throw new PXException(Messages.COGSSubAccountCanNotBeFoundForItemInReceiptRow, invItem.InventoryCD, receiptLine.ReceiptNbr, receiptLine.LineNbr, postClass.PostClassID, invSite != null ? invSite.SiteCD : String.Empty); } else { throw ex; } } if (aSubID == null) { throw new PXException(Messages.COGSSubAccountCanNotBeFoundForItemInReceiptRow, invItem.InventoryCD, receiptLine.ReceiptNbr, receiptLine.LineNbr, postClass.PostClassID, invSite != null ? invSite.SiteCD : String.Empty); } } else { aAccountID = INReleaseProcess.GetAcctID <INPostClass.lCVarianceAcctID>(_pxGraph, postClass.LCVarianceAcctDefault, invItem, invSite, postClass); if (aAccountID == null) { throw new PXException(Messages.LCVarianceAccountCanNotBeFoundForItemInReceiptRow, invItem.InventoryCD, receiptLine.ReceiptNbr, receiptLine.LineNbr, postClass.PostClassID, invSite != null ? invSite.SiteCD : String.Empty); } try { aSubID = INReleaseProcess.GetSubID <INPostClass.lCVarianceSubID>(_pxGraph, postClass.LCVarianceAcctDefault, postClass.LCVarianceSubMask, invItem, invSite, postClass); } catch (PXException ex) { if (postClass.LCVarianceSubID == null || string.IsNullOrEmpty(postClass.LCVarianceSubMask) || invItem.LCVarianceSubID == null || invSite == null || invSite.LCVarianceSubID == null) { throw new PXException(Messages.LCVarianceSubAccountCanNotBeFoundForItemInReceiptRow, invItem.InventoryCD, receiptLine.ReceiptNbr, receiptLine.LineNbr, postClass.PostClassID, invSite != null ? invSite.SiteCD : String.Empty); } else { throw ex; } } if (aSubID == null) { throw new PXException(Messages.LCVarianceSubAccountCanNotBeFoundForItemInReceiptRow, invItem.InventoryCD, receiptLine.ReceiptNbr, receiptLine.LineNbr, postClass.PostClassID, invSite != null ? invSite.SiteCD : String.Empty); } } } else { aAccountID = receiptLine.ExpenseAcctID; aSubID = receiptLine.ExpenseSubID; } } else { throw new PXException(Messages.LCInventoryItemInReceiptRowIsNotFound, receiptLine.InventoryID, receiptLine.ReceiptNbr, receiptLine.LineNbr); } } else { aAccountID = receiptLine.ExpenseAcctID; aSubID = receiptLine.ExpenseSubID; } }
public decimal AllocateOverRCTLine(List <POReceiptLineAdjustment> result, POReceiptLine aLine, decimal toDistribute, Int32?branchID) { var aLCCode = new LandedCostCode(); aLCCode.AllocationMethod = LandedCostAllocationMethod.ByQuantity; decimal baseTotal = GetBaseValue(aLCCode, aLine); decimal shareAmt = Decimal.Zero; decimal allocatedAmt = Decimal.Zero; decimal allocatedBase = Decimal.Zero; List <Type> bql = new List <Type> { typeof(Select4 <, ,>), typeof(POReceiptLineSplit), typeof(Where <POReceiptLineSplit.receiptNbr, Equal <Required <POReceiptLine.receiptNbr> >, And <POReceiptLineSplit.lineNbr, Equal <Required <POReceiptLine.lineNbr> > > >), typeof(Aggregate <>), typeof(GroupBy <,>), typeof(POReceiptLineSplit.locationID), typeof(GroupBy <,>), typeof(POReceiptLineSplit.subItemID), typeof(Sum <,>), typeof(POReceiptLineSplit.baseQty), typeof(GroupBy <>), typeof(POReceiptLineSplit.lotSerialNbr) }; InventoryItem ii = (InventoryItem)PXSelectorAttribute.Select <POReceiptLine.inventoryID>(_graph.Caches[typeof(POReceiptLine)], aLine); bool requierelotserial = ii.ValMethod == INValMethod.Specific; if (!requierelotserial) { bql.RemoveAt(bql.Count - 1); bql.RemoveAt(bql.Count - 1); bql[bql.Count - 2] = typeof(Sum <>); } PXView splitsView = new PXView(_graph, false, BqlCommand.CreateInstance(bql.ToArray())); bool hasSplits = false; foreach (POReceiptLineSplit split in splitsView.SelectMulti(aLine.ReceiptNbr, aLine.LineNbr)) { hasSplits = true; decimal allocatingBase = split.BaseQty ?? 0m; shareAmt = CalcAllocationValue(aLCCode, split, aLine, baseTotal, toDistribute); shareAmt = PXDBCurrencyAttribute.BaseRound(_graph, shareAmt); //accu rounding shareAmt += PXCurrencyAttribute.BaseRound(_graph, (allocatedBase + allocatingBase) * toDistribute / baseTotal - shareAmt - allocatedAmt); if (shareAmt != Decimal.Zero) { POReceiptLine newPOReceiptLine = (POReceiptLine)_graph.Caches[typeof(POReceiptLine)].CreateCopy(aLine); newPOReceiptLine.LocationID = split.LocationID; newPOReceiptLine.SiteID = split.SiteID; newPOReceiptLine.SubItemID = split.SubItemID; newPOReceiptLine.LotSerialNbr = requierelotserial ? split.LotSerialNbr : null; result.Add(new POReceiptLineAdjustment(newPOReceiptLine, shareAmt, branchID)); allocatedAmt += shareAmt; allocatedBase += allocatingBase; } } if (!hasSplits) { shareAmt = toDistribute; shareAmt = PXDBCurrencyAttribute.BaseRound(_graph, shareAmt); if (shareAmt != Decimal.Zero) { result.Add(new POReceiptLineAdjustment(aLine, shareAmt, branchID)); } allocatedAmt = shareAmt; } return(allocatedAmt); }
public virtual bool IsApplicable(PXGraph graph, POLandedCostDetail aTran, LandedCostCode aCode, POReceiptLine aLine) { if (!IsApplicable(graph, aCode, aLine)) { return(false); } if (aTran.InventoryID.HasValue) { if (aTran.InventoryID != aLine.InventoryID) { return(false); } } return(true); }
public virtual decimal AllocateOverRCTLine(PXGraph graph, List <POReceiptLineAdjustment> result, POReceiptLine aLine, decimal toDistribute, Int32?branchID) { var allocationItem = new AllocationItem { LandedCostCode = new LandedCostCode(), ReceiptLine = aLine }; allocationItem.LandedCostCode.AllocationMethod = LandedCostAllocationMethod.ByQuantity; var rest = AllocateOverRCTLine(graph, result, allocationItem, toDistribute, branchID); return(rest); }
public virtual List <POLandedCostReceiptLineAdjustment> AllocateLCOverRCTLines( PXGraph graph, POLandedCostDetail landedCostDetail, IEnumerable <POLandedCostReceiptLine> landedCostReceiptLines, IEnumerable <PXResult <POLandedCostTax, Tax> > taxes, IEnumerable <POReceiptLine> receiptLines, IEnumerable <LandedCostCode> landedCostCodes, IEnumerable <POReceipt> receipts) { var landedCostCode = landedCostCodes.Single(t => t.LandedCostCodeID == landedCostDetail.LandedCostCodeID); var rctLinesList = receiptLines.Where(rl => IsApplicable(graph, landedCostDetail, landedCostCode, rl)).ToList(); var rctLinesAllocItems = new LandedCostAllocationItem[rctLinesList.Count]; Decimal toDistribute = GetAllocationAmount(landedCostDetail, taxes); Decimal baseTotal = decimal.Zero; for (int i = 0; i < rctLinesList.Count; i++) { POReceiptLine receiptLine = rctLinesList[i]; var landedCostReceiptLine = landedCostReceiptLines.Single(t => t.POReceiptType == receiptLine.ReceiptType && t.POReceiptNbr == receiptLine.ReceiptNbr && t.POReceiptLineNbr == receiptLine.LineNbr); rctLinesAllocItems[i] = new LandedCostAllocationItem() { LandedCostCode = landedCostCode, ReceiptLine = receiptLine, LandedCostDetail = landedCostDetail, LandedCostReceiptLine = landedCostReceiptLine }; baseTotal += GetBaseValue(rctLinesAllocItems[i]); } var result = new List <POReceiptLineAdjustment>(); decimal allocatedAmt = 0m; decimal handledLinesAllocAmt = 0m; int? maxLineIndex = null; decimal maxLineAllocAmt = 0m; for (int i = 0; i < rctLinesList.Count; i++) { decimal allocAmt = CalcAllocationValue(graph, rctLinesAllocItems[i], baseTotal, toDistribute); handledLinesAllocAmt += allocAmt; if (maxLineIndex == null || maxLineAllocAmt < allocAmt) { maxLineIndex = i; maxLineAllocAmt = allocAmt; } allocAmt = handledLinesAllocAmt - allocatedAmt; if (allocAmt > 0m) { POReceiptLine maxLine = rctLinesList[maxLineIndex.Value]; var poreceipt = receipts.Single(r => r.ReceiptType == maxLine.ReceiptType && r.ReceiptNbr == maxLine.ReceiptNbr); decimal lineAllocatedAmt = AllocateOverRCTLine(graph, result, rctLinesAllocItems[maxLineIndex.Value], allocAmt, poreceipt.BranchID); if (lineAllocatedAmt != 0m) { maxLineIndex = null; maxLineAllocAmt = 0m; allocatedAmt += lineAllocatedAmt; } } } AllocateRestOverRCTLines(result, toDistribute - allocatedAmt); var castResult = result.Cast <POLandedCostReceiptLineAdjustment>().ToList(); return(castResult); }
public POReceiptLineAdjustment(POReceiptLine receiptLine, decimal qtyToAssign, int?branchID) { ReceiptLine = receiptLine; QtyToAssign = qtyToAssign; BranchID = branchID; }