use of org.kuali.kfs.module.ar.businessobject.InvoiceGeneralDetail in project cu-kfs by CU-CommunityApps.
the class ContractsGrantsInvoiceDocumentServiceImpl method buildInvoiceGeneralDetailFieldsMap.
private Map<String, Object> buildInvoiceGeneralDetailFieldsMap(ContractsGrantsInvoiceDocument document) {
Map<String, Object> invoiceGeneralDetailFieldsMap = new HashMap<>();
InvoiceGeneralDetail invoiceGeneralDetail = document.getInvoiceGeneralDetail();
if (ObjectUtils.isNotNull(invoiceGeneralDetail)) {
invoiceGeneralDetailFieldsMap.put(ArPropertyConstants.ADVANCE_FLAG, ArConstants.BillingFrequencyValues.isPredeterminedBilling(invoiceGeneralDetail));
invoiceGeneralDetailFieldsMap.put(ArPropertyConstants.REIMBURSEMENT_FLAG, !ArConstants.BillingFrequencyValues.isPredeterminedBilling(invoiceGeneralDetail));
invoiceGeneralDetailFieldsMap.put(KFSPropertyConstants.PROPOSAL_NUMBER, invoiceGeneralDetail.getProposalNumber());
final String prefix = ArPropertyConstants.INVOICE_GENERAL_DETAIL + ".";
invoiceGeneralDetailFieldsMap.put(prefix + ArPropertyConstants.AWARD_DATE_RANGE, invoiceGeneralDetail.getAwardDateRange());
invoiceGeneralDetailFieldsMap.put(prefix + ArPropertyConstants.BILLING_FREQUENCY_CODE, invoiceGeneralDetail.getBillingFrequencyCode());
invoiceGeneralDetailFieldsMap.put(ArPropertyConstants.ContractsGrantsInvoiceDocumentFields.FINAL_BILL, invoiceGeneralDetail.isFinalBillIndicator());
invoiceGeneralDetailFieldsMap.put(prefix + ArPropertyConstants.BILLING_PERIOD, invoiceGeneralDetail.getBillingPeriod());
invoiceGeneralDetailFieldsMap.put(prefix + ArPropertyConstants.INSTRUMENT_TYPE_CODE, invoiceGeneralDetail.getInstrumentTypeCode());
invoiceGeneralDetailFieldsMap.put(prefix + ArConstants.AWARD_TOTAL, invoiceGeneralDetail.getAwardTotal());
invoiceGeneralDetailFieldsMap.put(prefix + ArPropertyConstants.AMOUNT_REMAINING_TO_BILL, invoiceGeneralDetail.getAmountRemainingToBill());
invoiceGeneralDetailFieldsMap.put(prefix + ArPropertyConstants.COST_SHARE_AMOUNT, invoiceGeneralDetail.getCostShareAmount());
invoiceGeneralDetailFieldsMap.put(prefix + ArPropertyConstants.LAST_BILLED_DATE, invoiceGeneralDetail.getLastBilledDate());
invoiceGeneralDetailFieldsMap.put(prefix + ArPropertyConstants.TOTAL_PREVIOUSLY_BILLED, invoiceGeneralDetail.getTotalPreviouslyBilled());
invoiceGeneralDetailFieldsMap.put(ArPropertyConstants.TOTAL_AMOUNT_DUE, getTotalAmountForInvoice(document));
invoiceGeneralDetailFieldsMap.put(ArPropertyConstants.CustomerInvoiceDocumentFields.CUSTOMER + "." + ArPropertyConstants.FULL_ADDRESS, contractsGrantsBillingUtilityService.buildFullAddress(invoiceGeneralDetail.getCustomerAddress()));
ContractsAndGrantsBillingAward award = invoiceGeneralDetail.getAward();
if (ObjectUtils.isNotNull(award)) {
invoiceGeneralDetailFieldsMap.putAll(buildAwardFieldsMap(award));
}
}
return invoiceGeneralDetailFieldsMap;
}
use of org.kuali.kfs.module.ar.businessobject.InvoiceGeneralDetail in project cu-kfs by CU-CommunityApps.
the class ContractsGrantsInvoiceDocumentServiceImpl method generateInvoicesForInvoiceAddresses.
@Override
public void generateInvoicesForInvoiceAddresses(ContractsGrantsInvoiceDocument document) {
InvoiceTemplate invoiceTemplate;
byte[] reportStream;
InvoiceGeneralDetail invoiceGeneralDetail = document.getInvoiceGeneralDetail();
if (ObjectUtils.isNotNull(invoiceGeneralDetail.getCustomerInvoiceTemplateCode())) {
CustomerAddress customerAddress = invoiceGeneralDetail.getCustomerAddress();
String customerAddressName = customerAddress.getCustomerAddressName();
invoiceTemplate = businessObjectService.findBySinglePrimaryKey(InvoiceTemplate.class, invoiceGeneralDetail.getCustomerInvoiceTemplateCode());
if (ObjectUtils.isNotNull(invoiceTemplate) && invoiceTemplate.isActive() && StringUtils.isNotBlank(invoiceTemplate.getFilename())) {
ModuleConfiguration systemConfiguration = kualiModuleService.getModuleServiceByNamespaceCode(KFSConstants.OptionalModuleNamespaces.ACCOUNTS_RECEIVABLE).getModuleConfiguration();
String templateFolderPath = ((FinancialSystemModuleConfiguration) systemConfiguration).getTemplateFileDirectories().get(KFSConstants.TEMPLATES_DIRECTORY_KEY);
String templateFilePath = templateFolderPath + File.separator + invoiceTemplate.getFilename();
File templateFile = new File(templateFilePath);
String outputFileName;
try {
Map<String, String> replacementList = getTemplateParameterList(document);
reportStream = PdfFormFillerUtil.populateTemplate(templateFile, replacementList);
outputFileName = buildFilenamePrefix(document, customerAddressName) + ArConstants.TemplateUploadSystem.EXTENSION;
String watermarkText = null;
if (ObjectUtils.isNotNull(document.getInvoiceGeneralDetail()) && document.getInvoiceGeneralDetail().isFinalBillIndicator()) {
watermarkText = getConfigurationService().getPropertyValueAsString(ArKeyConstants.INVOICE_ADDRESS_PDF_WATERMARK_FINAL);
}
Long noteId = buildAndAddInvoiceNote(document, reportStream, customerAddressName, outputFileName, ArKeyConstants.INVOICE_ADDRESS_PDF_FINAL_NOTE, watermarkText);
document.getInvoiceGeneralDetail().setInvoiceNoteId(noteId);
documentService.updateDocument(document);
} catch (IOException ex) {
addNoteForInvoiceReportFail(document);
}
} else {
addNoteForInvoiceReportFail(document);
}
} else {
addNoteForInvoiceReportFail(document);
}
}
use of org.kuali.kfs.module.ar.businessobject.InvoiceGeneralDetail in project cu-kfs by CU-CommunityApps.
the class ContractsGrantsInvoiceDocumentServiceImpl method determineContractControlAccountNumber.
// access relaxed for Cornell
protected String determineContractControlAccountNumber(ContractsGrantsInvoiceDocument document) {
final InvoiceGeneralDetail invoiceGeneralDetail = document.getInvoiceGeneralDetail();
if (ObjectUtils.isNotNull(invoiceGeneralDetail)) {
final ContractsAndGrantsBillingAward award = invoiceGeneralDetail.getAward();
if (ObjectUtils.isNotNull(award)) {
final List<Account> contractControlAccounts = getContractControlAccounts(award);
if (CollectionUtils.isNotEmpty(contractControlAccounts)) {
return contractControlAccounts.get(0).getAccountNumber();
}
}
}
final List<InvoiceAccountDetail> accountDetails = document.getAccountDetails();
if (CollectionUtils.isNotEmpty(accountDetails)) {
return accountDetails.get(0).getAccountNumber();
}
return null;
}
use of org.kuali.kfs.module.ar.businessobject.InvoiceGeneralDetail in project cu-kfs by CU-CommunityApps.
the class CuTotalAmountBilledToDateExceedsTotalBudgetSuspensionCategoryTest method prepareContractsGrantsInvoiceDocument.
private void prepareContractsGrantsInvoiceDocument(KualiDecimal totalAmountBilledToDate, KualiDecimal budgetTotal) {
PowerMockito.suppress(PowerMockito.constructor(DocumentBase.class));
contractsGrantsInvoiceDocument = PowerMockito.spy(new ContractsGrantsInvoiceDocument());
Award award = new Award();
AwardExtendedAttribute attribute = new AwardExtendedAttribute();
attribute.setBudgetTotalAmount(budgetTotal);
award.setExtension(attribute);
InvoiceGeneralDetail invoiceGeneralDetail = Mockito.mock(InvoiceGeneralDetail.class);
Mockito.when(invoiceGeneralDetail.getTotalAmountBilledToDate()).thenReturn(totalAmountBilledToDate);
Mockito.when(invoiceGeneralDetail.getAward()).thenReturn(award);
contractsGrantsInvoiceDocument.setInvoiceGeneralDetail(invoiceGeneralDetail);
}
use of org.kuali.kfs.module.ar.businessobject.InvoiceGeneralDetail in project cu-kfs by CU-CommunityApps.
the class AutoApproveDisabledSuspensionCategoryTest method prepareContractsGrantsInvoiceDocument.
private void prepareContractsGrantsInvoiceDocument(boolean autoApproveIndicator, String autoApproveReason) {
PowerMockito.suppress(PowerMockito.constructor(DocumentBase.class));
contractsGrantsInvoiceDocument = PowerMockito.spy(new ContractsGrantsInvoiceDocument());
Award award = new Award();
award.setAutoApproveIndicator(autoApproveIndicator);
AwardExtendedAttribute attribute = new AwardExtendedAttribute();
attribute.setAutoApproveReason(autoApproveReason);
award.setExtension(attribute);
InvoiceGeneralDetail invoiceGeneralDetail = Mockito.mock(InvoiceGeneralDetail.class);
Mockito.when(invoiceGeneralDetail.getAward()).thenReturn(award);
contractsGrantsInvoiceDocument.setInvoiceGeneralDetail(invoiceGeneralDetail);
}
Aggregations