public virtual decimal?GetNonReleasedCashDiscountTakenExceptCurrentAdjustment(APAdjust apAdjust) { var adjustments = AdjustmentDataProvider.GetInvoiceAdjustments(Graph, apAdjust.AdjdRefNbr); var releasedCashDiscountTaken = InvoiceDataProvider .GetInvoice(Graph, apAdjust.AdjdDocType, apAdjust.AdjdRefNbr).CuryDiscTaken; var totalCashDiscountTaken = adjustments.Sum(adjustment => adjustment.CuryAdjgPPDAmt); return(totalCashDiscountTaken - releasedCashDiscountTaken - apAdjust.CuryAdjgPPDAmt); }
private IEnumerable <LienWaiverGenerationKey> CreateLienWaiverGroupingKeys( IReadOnlyCollection <JointPayee> jointPayees, APRegister payment, APTran transaction) { var adjustments = AdjustmentDataProvider.GetInvoiceAdjustments(Graph, transaction.RefNbr); return(adjustments.Any() ? CreateGroupingKeys(jointPayees, payment, transaction) : CreateGroupingKeysForPaymentByLines(jointPayees, payment, transaction)); }
protected virtual decimal GetAllowableCashDiscountConsiderBillBalance(APAdjust apAdjust) { var invoiceAdjustments = AdjustmentDataProvider.GetInvoiceAdjustments(Graph, apAdjust.AdjdRefNbr); var unappliedBalance = invoiceAdjustments .Sum(adjustment => adjustment.CuryAdjgAmt + adjustment.CuryAdjgPPDAmt); var billBalance = InvoiceDataProvider.GetInvoice(Graph, apAdjust.AdjdDocType, apAdjust.AdjdRefNbr) .CuryOrigDocAmt; var cashDiscount = billBalance - unappliedBalance + apAdjust.CuryAdjgPPDAmt; return(Math.Max(cashDiscount.GetValueOrDefault(), 0)); }
private void ValidateAmountPaidExceedsBillBalance(APAdjust adjustment, decimal?amountPaid, bool doNeedShowErrorOnPersist) { var invoiceAdjustments = AdjustmentDataProvider.GetInvoiceAdjustments(Graph, adjustment.AdjdRefNbr); var unappliedBalance = invoiceAdjustments .Sum(adjust => adjust.CuryAdjgAmt + adjust.CuryAdjgPPDAmt); var billBalance = InvoiceDataProvider.GetInvoice(Graph, adjustment.AdjdDocType, adjustment.AdjdRefNbr) .CuryOrigDocAmt.GetValueOrDefault(); var allowableAmountPaid = billBalance - unappliedBalance + amountPaid; if (amountPaid > allowableAmountPaid) { ShowErrorMessage <APAdjust.curyAdjgAmt>(adjustment, amountPaid, adjustment.AdjdLineNbr != 0 ? JointCheckMessages.AmountPaidExceedsBillLineBalance : JointCheckMessages.AmountPaidExceedsBillBalance, allowableAmountPaid); ShowErrorOnPersistIfRequired(Graph.Adjustments.Cache, doNeedShowErrorOnPersist); } }