private IEnumerable <JointCheckGenerationModel> CreateCheckGenerationModels() { var jointPayeePayments = InvoiceJointPayeePayments.Where(jpp => jpp.JointAmountToPay > 0).ToList(); var jointPayeeGroups = GetJointPayeeGroups(jointPayeePayments); return(jointPayeeGroups.Select(jp => JointCheckGenerationModel.Create(jointPayeePayments, jp)) .OrderBy(gm => gm.InvoiceJointPayeePayments.Min(jpp => jpp.JointPayeeId))); }
private void CreateZeroAmountJointPayeePaymentsForJointCheck( JointCheckGenerationModel jointCheckGenerationModel) { var invoiceJointPayeePayments = jointCheckGenerationModel.InvoiceJointPayeePayments.ToList(); var jointPayeeIds = InvoiceJointPayeePayments .Where(jpp => !invoiceJointPayeePayments.Contains(jpp) && jointCheckGenerationModel.BillLineNumbers.Contains(jpp.BillLineNumber)) .Select(jpp => jpp.JointPayeeId); CreateZeroAmountJointPayeePayments(jointCheckGenerationModel.CreatedPayment, jointPayeeIds); }
private IEnumerable <APAdjust> GetSortedAdjustments() { var billLinesWithJointAmountsToPay = InvoiceJointPayeePayments .Where(jpp => jpp.JointAmountToPay.GetValueOrDefault() != 0) .Select(x => x.BillLineNumber).Distinct(); var adjustments = PaymentEntry.Adjustments.SelectMain(); var sortedAdjustments = billLinesWithJointAmountsToPay .Select(billLine => adjustments.FirstOrDefault(x => x.AdjdLineNbr == billLine)).ToList(); sortedAdjustments.AddRange(adjustments.Where(adjustment => !sortedAdjustments.Contains(adjustment))); return(sortedAdjustments); }
private decimal?GetAdjustmentAmountPerLine(APAdjust adjustment) { var jointPayeePaymentsTotalAmountToPayForLine = InvoiceJointPayeePayments .Where(jpp => jpp.BillLineNumber == adjustment.AdjdLineNbr) .Sum(jpp => jpp.JointAmountToPay); var vendorBalancePerLine = vendorBalancePerLineCalculationService.GetVendorBalancePerLine(adjustment); var transactionBalance = TransactionDataProvider.GetTransaction( PaymentEntry, adjustment.AdjdDocType, adjustment.AdjdRefNbr, adjustment.AdjdLineNbr).CuryTranBal; var minimumJointAmountToPay = transactionBalance - vendorBalancePerLine; return(jointPayeePaymentsTotalAmountToPayForLine > minimumJointAmountToPay ? transactionBalance - jointPayeePaymentsTotalAmountToPayForLine : vendorBalancePerLine); }
private void CreateZeroAmountJointPayeePaymentsForVendorCheck(IDocumentKey vendorCheck) { var jointPayeeIds = InvoiceJointPayeePayments.Select(jpp => jpp.JointPayeeId); CreateZeroAmountJointPayeePayments(vendorCheck, jointPayeeIds); }