private void ValidateAmountPaidGreaterThanTotalJointAmountToPay(APAdjust adjustment, decimal?amountPaid, bool doNeedShowErrorOnPersist) { var totalJointAmountToPay = jointAmountToPayCalculationService.GetTotalJointAmountToPay(adjustment); if (amountPaid < totalJointAmountToPay) { ShowErrorMessage <APAdjust.curyAdjgAmt>(adjustment, amountPaid, JointCheckMessages.AmountPaidShouldBeEqualOrGreaterErrorTemplate, totalJointAmountToPay); ShowErrorOnPersistIfRequired(Graph.Adjustments.Cache, doNeedShowErrorOnPersist); } }
public void ValidateVendorPaymentAmount(APAdjust adjustment, string errorMessage) { InitializeServices(adjustment.AdjdLineNbr != 0); var totalJointAmountToPay = jointAmountToPayCalculationService.GetTotalJointAmountToPay(adjustment); var vendorPaymentAmount = adjustment.CuryAdjgAmt - totalJointAmountToPay; var vendorPreparedBalance = VendorPreparedBalanceCalculationService.GetVendorPreparedBalance(adjustment); if (vendorPaymentAmount > vendorPreparedBalance) { var totalNonReleasedCashDiscountTaken = CashDiscountCalculationService.GetNonReleasedCashDiscountTakenExceptCurrentAdjustment(adjustment) + adjustment.CuryAdjgPPDAmt; var allowableAmountPaid = vendorPreparedBalance + totalJointAmountToPay - totalNonReleasedCashDiscountTaken; allowableAmountPaid = Math.Max(allowableAmountPaid.GetValueOrDefault(), 0); ShowErrorMessage <APAdjust.curyAdjgAmt>(adjustment, errorMessage, allowableAmountPaid); ShowErrorOnPersistIfRequired(Graph.Adjustments.Cache, true); } }