Search in sources :

Example 1 with InvoiceGeneralDetail

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;
}
Also used : HashMap(java.util.HashMap) ContractsAndGrantsBillingAward(org.kuali.kfs.integration.cg.ContractsAndGrantsBillingAward) InvoiceGeneralDetail(org.kuali.kfs.module.ar.businessobject.InvoiceGeneralDetail)

Example 2 with InvoiceGeneralDetail

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);
    }
}
Also used : ModuleConfiguration(org.kuali.kfs.krad.bo.ModuleConfiguration) FinancialSystemModuleConfiguration(org.kuali.kfs.sys.FinancialSystemModuleConfiguration) InvoiceTemplate(org.kuali.kfs.module.ar.businessobject.InvoiceTemplate) InvoiceGeneralDetail(org.kuali.kfs.module.ar.businessobject.InvoiceGeneralDetail) IOException(java.io.IOException) File(java.io.File) CustomerAddress(org.kuali.kfs.module.ar.businessobject.CustomerAddress)

Example 3 with InvoiceGeneralDetail

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;
}
Also used : ContractsAndGrantsBillingAwardAccount(org.kuali.kfs.integration.cg.ContractsAndGrantsBillingAwardAccount) Account(org.kuali.kfs.coa.businessobject.Account) ContractsAndGrantsBillingAward(org.kuali.kfs.integration.cg.ContractsAndGrantsBillingAward) InvoiceGeneralDetail(org.kuali.kfs.module.ar.businessobject.InvoiceGeneralDetail) InvoiceAccountDetail(org.kuali.kfs.module.ar.businessobject.InvoiceAccountDetail)

Example 4 with InvoiceGeneralDetail

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);
}
Also used : Award(org.kuali.kfs.module.cg.businessobject.Award) InvoiceGeneralDetail(org.kuali.kfs.module.ar.businessobject.InvoiceGeneralDetail) ContractsGrantsInvoiceDocument(org.kuali.kfs.module.ar.document.ContractsGrantsInvoiceDocument) AwardExtendedAttribute(edu.cornell.kfs.module.cg.businessobject.AwardExtendedAttribute) DocumentBase(org.kuali.kfs.krad.document.DocumentBase)

Example 5 with 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);
}
Also used : Award(org.kuali.kfs.module.cg.businessobject.Award) InvoiceGeneralDetail(org.kuali.kfs.module.ar.businessobject.InvoiceGeneralDetail) ContractsGrantsInvoiceDocument(org.kuali.kfs.module.ar.document.ContractsGrantsInvoiceDocument) AwardExtendedAttribute(edu.cornell.kfs.module.cg.businessobject.AwardExtendedAttribute) DocumentBase(org.kuali.kfs.krad.document.DocumentBase)

Aggregations

InvoiceGeneralDetail (org.kuali.kfs.module.ar.businessobject.InvoiceGeneralDetail)8 AwardExtendedAttribute (edu.cornell.kfs.module.cg.businessobject.AwardExtendedAttribute)3 DocumentBase (org.kuali.kfs.krad.document.DocumentBase)3 ContractsGrantsInvoiceDocument (org.kuali.kfs.module.ar.document.ContractsGrantsInvoiceDocument)3 Award (org.kuali.kfs.module.cg.businessobject.Award)3 HashMap (java.util.HashMap)2 KualiDecimal (org.kuali.kfs.core.api.util.type.KualiDecimal)2 ContractsAndGrantsBillingAward (org.kuali.kfs.integration.cg.ContractsAndGrantsBillingAward)2 ContractsAndGrantsBillingAwardAccount (org.kuali.kfs.integration.cg.ContractsAndGrantsBillingAwardAccount)2 ContractsGrantsInvoiceDetail (org.kuali.kfs.module.ar.businessobject.ContractsGrantsInvoiceDetail)2 InvoiceAccountDetail (org.kuali.kfs.module.ar.businessobject.InvoiceAccountDetail)2 File (java.io.File)1 IOException (java.io.IOException)1 Date (java.sql.Date)1 Timestamp (java.sql.Timestamp)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Account (org.kuali.kfs.coa.businessobject.Account)1 AccountingPeriod (org.kuali.kfs.coa.businessobject.AccountingPeriod)1