Search in sources :

Example 6 with ContractsGrantsInvoiceDocument

use of org.kuali.kfs.module.ar.document.ContractsGrantsInvoiceDocument in project cu-kfs by CU-CommunityApps.

the class ContractsGrantsInvoiceCreateDocumentServiceImpl method generateAndSaveContractsAndGrantsInvoiceDocument.

/**
 * FINP-5295 This method was modified for the backport.
 *
 * Generates and then saves a Contracts & Grants Invoice Document
 *
 * @param awd                the award for the document
 * @param validAwardAccounts the award accounts which should appear on the document
 * @param errorMessages      a List of error messages, to be appended to if there are errors in document generation
 * @param accountDetails     letter of credit details if we're creating via loc
 * @param locCreationType    letter of credit creation type if we're creating via loc
 */
protected void generateAndSaveContractsAndGrantsInvoiceDocument(ContractsAndGrantsBillingAward awd, List<ContractsAndGrantsBillingAwardAccount> validAwardAccounts, List<ErrorMessage> errorMessages, ContractsAndGrantsInvoiceDocumentCreationProcessType creationProcessType, List<ContractsGrantsLetterOfCreditReviewDetail> accountDetails, String locCreationType) {
    ChartOrgHolder chartOrgHolder = financialSystemUserService.getPrimaryOrganization(awd.getAwardPrimaryFundManager().getFundManager().getPrincipalId(), KFSConstants.OptionalModuleNamespaces.ACCOUNTS_RECEIVABLE);
    /*
         * CU Customization (KFSPTS-23675):
         * Include creationProcessType in the method call.
         */
    ContractsGrantsInvoiceDocument cgInvoiceDocument = createCGInvoiceDocumentByAwardInfo(awd, validAwardAccounts, chartOrgHolder.getChartOfAccountsCode(), chartOrgHolder.getOrganizationCode(), errorMessages, accountDetails, locCreationType, creationProcessType);
    if (ObjectUtils.isNotNull(cgInvoiceDocument)) {
        if (cgInvoiceDocument.getTotalInvoiceAmount().isPositive() || getContractsGrantsInvoiceDocumentService().getInvoiceMilestoneTotal(cgInvoiceDocument).isPositive() || getContractsGrantsInvoiceDocumentService().getBillAmountTotal(cgInvoiceDocument).isPositive() || (ArConstants.BillingFrequencyValues.isTimeBased(awd) && ContractsAndGrantsInvoiceDocumentCreationProcessType.MANUAL.equals(creationProcessType))) {
            try {
                documentService.saveDocument(cgInvoiceDocument, DocumentSystemSaveEvent.class);
            } catch (WorkflowException ex) {
                LOG.error("Error creating cgin documents: " + ex.getMessage(), ex);
                throw new RuntimeException("Error creating cgin documents: " + ex.getMessage(), ex);
            }
        } else {
            ErrorMessage errorMessage;
            List<InvoiceAccountDetail> invoiceAccounts = cgInvoiceDocument.getAccountDetails();
            if (!invoiceAccounts.isEmpty()) {
                errorMessage = new ErrorMessage(ArKeyConstants.ContractsGrantsInvoiceCreateDocumentConstants.NON_BILLABLE, invoiceAccounts.get(0).getAccountNumber(), awd.getProposalNumber());
            } else {
                errorMessage = new ErrorMessage(ArKeyConstants.ContractsGrantsInvoiceCreateDocumentConstants.NON_BILLABLE, null, awd.getProposalNumber());
            }
            errorMessages.add(errorMessage);
        }
    }
}
Also used : ChartOrgHolder(org.kuali.kfs.sys.businessobject.ChartOrgHolder) WorkflowException(org.kuali.kfs.kew.api.exception.WorkflowException) InvoiceAccountDetail(org.kuali.kfs.module.ar.businessobject.InvoiceAccountDetail) ContractsGrantsInvoiceDocument(org.kuali.kfs.module.ar.document.ContractsGrantsInvoiceDocument) ErrorMessage(org.kuali.kfs.krad.util.ErrorMessage) ContractsGrantsInvoiceDocumentErrorMessage(org.kuali.kfs.module.ar.businessobject.ContractsGrantsInvoiceDocumentErrorMessage)

Example 7 with ContractsGrantsInvoiceDocument

use of org.kuali.kfs.module.ar.document.ContractsGrantsInvoiceDocument 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 8 with ContractsGrantsInvoiceDocument

use of org.kuali.kfs.module.ar.document.ContractsGrantsInvoiceDocument 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)

Example 9 with ContractsGrantsInvoiceDocument

use of org.kuali.kfs.module.ar.document.ContractsGrantsInvoiceDocument in project cu-kfs by CU-CommunityApps.

the class CuContractsGrantsInvoiceDocumentServiceImpl method getInstitutionTemplateParameters.

protected Map<String, String> getInstitutionTemplateParameters(ContractsGrantsInvoiceDocument document) {
    Map<String, Object> localParameterMap = new HashMap<String, Object>();
    if (document.getInvoiceGeneralDetail().isFinalBillIndicator()) {
        localParameterMap.put(CuArPropertyConstants.ContractsAndGrantsBillingAwardFields.FINAL_BILL, CUKFSConstants.CAPITAL_X);
        localParameterMap.put(CuArPropertyConstants.ContractsAndGrantsBillingAwardFields.PARTIAL_BILL, StringUtils.EMPTY);
    } else {
        localParameterMap.put(CuArPropertyConstants.ContractsAndGrantsBillingAwardFields.FINAL_BILL, StringUtils.EMPTY);
        localParameterMap.put(CuArPropertyConstants.ContractsAndGrantsBillingAwardFields.PARTIAL_BILL, CUKFSConstants.CAPITAL_X);
    }
    ContractsGrantsInvoiceDetail totalCostInvoiceDetail = document.getTotalCostInvoiceDetail();
    if (ObjectUtils.isNotNull(totalCostInvoiceDetail)) {
        localParameterMap.put(CuArPropertyConstants.ContractsAndGrantsBillingAwardFields.TOTAL_PROGRAM_OUTLAYS_TO_DATE, totalCostInvoiceDetail.getTotalAmountBilledToDate().add(document.getInvoiceGeneralDetail().getCostShareAmount()));
    }
    setAwardExtendedAttributeValuesInParameterMap(document, localParameterMap);
    setPurchaseOrderNumberFieldInParameterMap(document, localParameterMap);
    if (!localParameterMap.isEmpty()) {
        LOG.debug("getInstitutionTemplateParameters, there were local parameters, these will be in the returned map.");
    }
    return localParameterMap.keySet().stream().collect(Collectors.toMap(key -> key, key -> stringifyValue(localParameterMap.get(key)), (a, b) -> b));
}
Also used : Customer(org.kuali.kfs.module.ar.businessobject.Customer) CuContractsGrantsInvoiceDocumentService(edu.cornell.kfs.module.ar.document.service.CuContractsGrantsInvoiceDocumentService) SubFundGroup(org.kuali.kfs.coa.businessobject.SubFundGroup) HashMap(java.util.HashMap) Award(org.kuali.kfs.module.cg.businessobject.Award) StringUtils(org.apache.commons.lang3.StringUtils) ContractsGrantsInvoiceDetail(org.kuali.kfs.module.ar.businessobject.ContractsGrantsInvoiceDetail) CollectionUtils(org.apache.commons.collections4.CollectionUtils) InvoiceDetailAccountObjectCode(org.kuali.kfs.module.ar.businessobject.InvoiceDetailAccountObjectCode) CUKFSConstants(edu.cornell.kfs.sys.CUKFSConstants) BigDecimal(java.math.BigDecimal) ContractsAndGrantsBillingAward(org.kuali.kfs.integration.cg.ContractsAndGrantsBillingAward) ArKeyConstants(org.kuali.kfs.module.ar.ArKeyConstants) Calendar(java.util.Calendar) Map(java.util.Map) InvoiceAccountDetail(org.kuali.kfs.module.ar.businessobject.InvoiceAccountDetail) CustomerExtendedAttribute(edu.cornell.kfs.module.ar.businessobject.CustomerExtendedAttribute) AwardAccountExtendedAttribute(edu.cornell.kfs.module.cg.businessobject.AwardAccountExtendedAttribute) ContractsGrantsInvoiceDocumentServiceImpl(org.kuali.kfs.module.ar.document.service.impl.ContractsGrantsInvoiceDocumentServiceImpl) Account(org.kuali.kfs.coa.businessobject.Account) RoundingMode(java.math.RoundingMode) CGIntegrationConstants(org.kuali.kfs.integration.cg.CGIntegrationConstants) AccountsReceivableDocumentHeader(org.kuali.kfs.module.ar.businessobject.AccountsReceivableDocumentHeader) CuArPropertyConstants(edu.cornell.kfs.module.ar.CuArPropertyConstants) KualiDecimal(org.kuali.kfs.core.api.util.type.KualiDecimal) CuArParameterKeyConstants(edu.cornell.kfs.module.ar.CuArParameterKeyConstants) KFSPropertyConstants(org.kuali.kfs.sys.KFSPropertyConstants) Collectors(java.util.stream.Collectors) ObjectUtils(org.kuali.kfs.krad.util.ObjectUtils) Date(java.sql.Date) List(java.util.List) AwardExtendedAttribute(edu.cornell.kfs.module.cg.businessobject.AwardExtendedAttribute) Logger(org.apache.logging.log4j.Logger) OrganizationAccountingDefault(org.kuali.kfs.module.ar.businessobject.OrganizationAccountingDefault) SystemInformation(org.kuali.kfs.module.ar.businessobject.SystemInformation) ArPropertyConstants(org.kuali.kfs.module.ar.ArPropertyConstants) Optional(java.util.Optional) ArConstants(org.kuali.kfs.module.ar.ArConstants) LogManager(org.apache.logging.log4j.LogManager) CustomerInvoiceDetail(org.kuali.kfs.module.ar.businessobject.CustomerInvoiceDetail) ContractsGrantsInvoiceDocument(org.kuali.kfs.module.ar.document.ContractsGrantsInvoiceDocument) ContractsGrantsInvoiceDetail(org.kuali.kfs.module.ar.businessobject.ContractsGrantsInvoiceDetail) HashMap(java.util.HashMap)

Example 10 with ContractsGrantsInvoiceDocument

use of org.kuali.kfs.module.ar.document.ContractsGrantsInvoiceDocument in project cu-kfs by CU-CommunityApps.

the class CuContractsGrantsInvoiceDocumentAction method findAwardBudgetTotal.

private KualiDecimal findAwardBudgetTotal(ContractsGrantsInvoiceDocumentForm contractsGrantsInvoiceDocumentForm) {
    ContractsGrantsInvoiceDocument contractsGrantsInvoiceDocument = contractsGrantsInvoiceDocumentForm.getContractsGrantsInvoiceDocument();
    Award award = (Award) contractsGrantsInvoiceDocument.getInvoiceGeneralDetail().getAward();
    AwardExtendedAttribute awardExtension = (AwardExtendedAttribute) award.getExtension();
    KualiDecimal budgetTotalAmount = null;
    if (ObjectUtils.isNotNull(awardExtension)) {
        budgetTotalAmount = awardExtension.getBudgetTotalAmount();
    } else {
        LOG.error("findAwardBudgetTotal, there is no award extension object on award " + award.getProposalNumber());
    }
    return budgetTotalAmount;
}
Also used : Award(org.kuali.kfs.module.cg.businessobject.Award) KualiDecimal(org.kuali.kfs.core.api.util.type.KualiDecimal) ContractsGrantsInvoiceDocument(org.kuali.kfs.module.ar.document.ContractsGrantsInvoiceDocument) AwardExtendedAttribute(edu.cornell.kfs.module.cg.businessobject.AwardExtendedAttribute)

Aggregations

ContractsGrantsInvoiceDocument (org.kuali.kfs.module.ar.document.ContractsGrantsInvoiceDocument)18 HashMap (java.util.HashMap)8 KualiDecimal (org.kuali.kfs.core.api.util.type.KualiDecimal)7 AwardExtendedAttribute (edu.cornell.kfs.module.cg.businessobject.AwardExtendedAttribute)5 Award (org.kuali.kfs.module.cg.businessobject.Award)5 AbstractKualiDecimal (org.kuali.kfs.core.api.util.type.AbstractKualiDecimal)4 WorkflowException (org.kuali.kfs.kew.api.exception.WorkflowException)4 DocumentBase (org.kuali.kfs.krad.document.DocumentBase)3 InvoiceAccountDetail (org.kuali.kfs.module.ar.businessobject.InvoiceAccountDetail)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 ContractsAndGrantsBillingAward (org.kuali.kfs.integration.cg.ContractsAndGrantsBillingAward)2 ErrorMessage (org.kuali.kfs.krad.util.ErrorMessage)2 AccountsReceivableDocumentHeader (org.kuali.kfs.module.ar.businessobject.AccountsReceivableDocumentHeader)2 ContractsGrantsInvoiceDetail (org.kuali.kfs.module.ar.businessobject.ContractsGrantsInvoiceDetail)2 InvoiceGeneralDetail (org.kuali.kfs.module.ar.businessobject.InvoiceGeneralDetail)2 CuArParameterKeyConstants (edu.cornell.kfs.module.ar.CuArParameterKeyConstants)1 CuArPropertyConstants (edu.cornell.kfs.module.ar.CuArPropertyConstants)1 CustomerExtendedAttribute (edu.cornell.kfs.module.ar.businessobject.CustomerExtendedAttribute)1 CuContractsGrantsInvoiceDocumentService (edu.cornell.kfs.module.ar.document.service.CuContractsGrantsInvoiceDocumentService)1