/** * This method calculates the total credits for the customers. * * @param cgMapByCustomer * @param knownCustomers */ private void calculateTotalCreditsForCustomers( Map<String, List<ContractsGrantsInvoiceDocument>> cgMapByCustomer, Map<String, ContractsAndGrantsAgingReport> knownCustomers) { Set<String> customerIds = cgMapByCustomer.keySet(); KualiDecimal credits = KualiDecimal.ZERO; for (String customer : customerIds) { ContractsAndGrantsAgingReport agingReportDetail = pickContractsGrantsAgingReportDetail(knownCustomers, customer); List<ContractsGrantsInvoiceDocument> cgDocs = cgMapByCustomer.get(customer); if (ObjectUtils.isNotNull(cgDocs) && !cgDocs.isEmpty()) { credits = KualiDecimal.ZERO; for (ContractsGrantsInvoiceDocument cgDoc : cgDocs) { Collection<CustomerCreditMemoDocument> creditDocs = customerCreditMemoDocumentService.getCustomerCreditMemoDocumentByInvoiceDocument( cgDoc.getDocumentNumber()); if (ObjectUtils.isNotNull(creditDocs) && !creditDocs.isEmpty()) { for (CustomerCreditMemoDocument cm : creditDocs) { for (CustomerCreditMemoDetail cmDetail : cm.getCreditMemoDetails()) { credits = credits.add(cmDetail.getCreditMemoItemTotalAmount()); } } } } } agingReportDetail.setTotalCredits(credits); totalCredits = totalCredits.add(credits); } }
/** * 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); } }
protected void getEmailParameterList( Map<String, String> primaryKeys, ContractsGrantsInvoiceDocument invoice, CustomerAddress customerAddress) { String[] orgCode = invoice .getAward() .getAwardPrimaryFundManager() .getFundManager() .getPrimaryDepartmentCode() .split("-"); Map<String, Object> key = new HashMap<String, Object>(); key.put(KFSPropertyConstants.ORGANIZATION_CODE, orgCode[0].trim()); key.put(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE, orgCode[1].trim()); Organization org = businessObjectService.findByPrimaryKey(Organization.class, key); primaryKeys.put( "grantNumber", returnProperStringValue(invoice.getAward().getProposal().getGrantNumber())); primaryKeys.put("proposalNumber", returnProperStringValue(invoice.getProposalNumber())); primaryKeys.put("invoiceNumber", returnProperStringValue(invoice.getDocumentNumber())); primaryKeys.put( "customerName", returnProperStringValue(customerAddress.getCustomer().getCustomerName())); primaryKeys.put( "addressName", returnProperStringValue(customerAddress.getCustomerAddressName())); primaryKeys.put( "name", returnProperStringValue( invoice.getAward().getAwardPrimaryFundManager().getFundManager().getName())); primaryKeys.put( "title", returnProperStringValue( invoice.getAward().getAwardPrimaryFundManager().getAwardFundManagerProjectTitle())); if (ObjectUtils.isNotNull(org)) { primaryKeys.put("department", returnProperStringValue(org.getOrganizationName())); } primaryKeys.put( "phone", returnProperStringValue( invoice.getAward().getAwardPrimaryFundManager().getFundManager().getPhoneNumber())); primaryKeys.put( "email", returnProperStringValue( invoice.getAward().getAwardPrimaryFundManager().getFundManager().getEmailAddress())); }