private decimal?GetVendorBalance(APAdjust adjustment, APInvoice invoice) { var jointPayees = Base1.JointPayees.SelectMain().Where(jp => jp.BillId == invoice.NoteID); if (invoice.PaymentsByLinesAllowed == true) { var vendorBalancePerLineCalculationService = new VendorBalancePerLineCalculationService(Base, jointPayees); return(vendorBalancePerLineCalculationService.GetVendorBalancePerLine(adjustment)); } var vendorBalanceCalculationService = new VendorBalanceCalculationService(Base, jointPayees); return(vendorBalanceCalculationService.GetVendorBalancePerBill(invoice)); }
private void SetAdjustmentAmountPerLine(decimal?amountToPay) { var jointPayees = GetJointPayees(InvoiceJointPayeePayments); vendorBalancePerLineCalculationService = new VendorBalancePerLineCalculationService(PaymentEntry, jointPayees); foreach (var adjustment in GetSortedAdjustments()) { var adjustmentAmountPerLine = GetAdjustmentAmountPerLine(adjustment); adjustment.CuryAdjgAmt = amountToPay == decimal.Zero ? decimal.Zero : Math.Min(adjustmentAmountPerLine.GetValueOrDefault(), amountToPay.GetValueOrDefault()); amountToPay = amountToPay - adjustment.CuryAdjgAmt; PaymentEntry.Adjustments.Cache.Update(adjustment); } }