/** * This method prepare the report model object to display on jsp page. * * @param invoices * @param results */ protected void populateReportDetails( List<ContractsGrantsInvoiceDocument> invoices, List results) { for (ContractsGrantsInvoiceDocument invoice : invoices) { ContractsGrantsAgingOpenInvoicesReport detail = new ContractsGrantsAgingOpenInvoicesReport(); // Document Type detail.setDocumentType( invoice.getDocumentHeader().getWorkflowDocument().getDocumentTypeName()); // Document Number detail.setDocumentNumber(invoice.getDocumentNumber()); // Document Description String documentDescription = invoice.getDocumentHeader().getDocumentDescription(); if (ObjectUtils.isNotNull(documentDescription)) { detail.setDocumentDescription(documentDescription); } else { detail.setDocumentDescription(""); } // Billing Date detail.setBillingDate(invoice.getBillingDate()); // Due Date detail.setDueApprovedDate(invoice.getInvoiceDueDate()); // Document Payment Amount detail.setDocumentPaymentAmount( invoice.getFinancialSystemDocumentHeader().getFinancialDocumentTotalAmount()); // Unpaid/Unapplied Amount detail.setUnpaidUnappliedAmount( customerInvoiceDocumentService.getOpenAmountForCustomerInvoiceDocument(invoice)); detail.setFinalInvoice( !ObjectUtils.isNull(invoice.getInvoiceGeneralDetail()) && invoice.getInvoiceGeneralDetail().isFinalBillIndicator() ? KFSConstants.ParameterValues.STRING_YES : KFSConstants.ParameterValues.STRING_NO); // set agency number, proposal number, account number if (!ObjectUtils.isNull(invoice.getInvoiceGeneralDetail()) && !ObjectUtils.isNull(invoice.getInvoiceGeneralDetail().getProposalNumber())) { detail.setProposalNumber(invoice.getInvoiceGeneralDetail().getProposalNumber().toString()); } // Set Agency Number ContractsAndGrantsBillingAgency cgAgency = this.getAgencyByCustomer( invoice.getAccountsReceivableDocumentHeader().getCustomerNumber()); if (ObjectUtils.isNotNull(cgAgency)) { detail.setAgencyNumber(cgAgency.getAgencyNumber()); } // Set Account number List<CustomerInvoiceDetail> details = invoice.getSourceAccountingLines(); String accountNum = (CollectionUtils.isNotEmpty(details) && ObjectUtils.isNotNull(details.get(0))) ? details.get(0).getAccountNumber() : ""; detail.setAccountNumber(accountNum); results.add(detail); } }
/** * This method calculates the payment amount for the customers. * * @param cgDocs * @param begin * @param end * @return */ private KualiDecimal calculatePaymentAmountForCustomer( Collection<ContractsGrantsInvoiceDocument> cgDocs, java.sql.Date begin, java.sql.Date end) { KualiDecimal invoiceAmt = KualiDecimal.ZERO; if (ObjectUtils.isNotNull(cgDocs) && !cgDocs.isEmpty()) { for (ContractsGrantsInvoiceDocument cgDoc : cgDocs) { if (ObjectUtils.isNotNull(cgDoc.getBillingDate())) { if (ObjectUtils.isNotNull(begin)) { if (cgDoc.getBillingDate().compareTo(begin) >= 0 && cgDoc.getBillingDate().compareTo(end) <= 0) { invoiceAmt = invoiceAmt.add(cgDoc.getPaymentAmount()); } } else { if (cgDoc.getBillingDate().compareTo(end) <= 0) { invoiceAmt = invoiceAmt.add(cgDoc.getPaymentAmount()); } } } } } return invoiceAmt; }