Search in sources :

Example 1 with ContractsGrantsInvoiceDocumentErrorLog

use of org.kuali.kfs.module.ar.businessobject.ContractsGrantsInvoiceDocumentErrorLog in project cu-kfs by CU-CommunityApps.

the class CuContractsGrantsInvoiceCreateDocumentServiceImpl method storeValidationErrors.

/**
 * Fixes NullPointerException that can occur when getting the award total amount.
 * award.getAwardTotalAmount().bigDecimalValue() causes the NullPointerException if the total amount returned null.
 */
@Override
protected void storeValidationErrors(Map<ContractsAndGrantsBillingAward, List<String>> invalidGroup, Collection<ContractsGrantsInvoiceDocumentErrorLog> contractsGrantsInvoiceDocumentErrorLogs, String creationProcessTypeCode) {
    for (ContractsAndGrantsBillingAward award : invalidGroup.keySet()) {
        KualiDecimal cumulativeExpenses = KualiDecimal.ZERO;
        ContractsGrantsInvoiceDocumentErrorLog contractsGrantsInvoiceDocumentErrorLog = new ContractsGrantsInvoiceDocumentErrorLog();
        if (ObjectUtils.isNotNull(award)) {
            Date beginningDate = award.getAwardBeginningDate();
            Date endingDate = award.getAwardEndingDate();
            final SystemOptions systemOptions = optionsService.getCurrentYearOptions();
            contractsGrantsInvoiceDocumentErrorLog.setProposalNumber(award.getProposalNumber());
            contractsGrantsInvoiceDocumentErrorLog.setAwardBeginningDate(beginningDate);
            contractsGrantsInvoiceDocumentErrorLog.setAwardEndingDate(endingDate);
            KualiDecimal awardTotalAmount = award.getAwardTotalAmount() == null ? KualiDecimal.ZERO : award.getAwardTotalAmount();
            contractsGrantsInvoiceDocumentErrorLog.setAwardTotalAmount(awardTotalAmount.bigDecimalValue());
            if (ObjectUtils.isNotNull(award.getAwardPrimaryFundManager())) {
                contractsGrantsInvoiceDocumentErrorLog.setPrimaryFundManagerPrincipalId(award.getAwardPrimaryFundManager().getPrincipalId());
            }
            if (!CollectionUtils.isEmpty(award.getActiveAwardAccounts())) {
                boolean firstLineFlag = true;
                for (ContractsAndGrantsBillingAwardAccount awardAccount : award.getActiveAwardAccounts()) {
                    cumulativeExpenses = cumulativeExpenses.add(contractsGrantsInvoiceDocumentService.getBudgetAndActualsForAwardAccount(awardAccount, systemOptions.getActualFinancialBalanceTypeCd()));
                    if (firstLineFlag) {
                        firstLineFlag = false;
                        contractsGrantsInvoiceDocumentErrorLog.setAccounts(awardAccount.getAccountNumber());
                    } else {
                        contractsGrantsInvoiceDocumentErrorLog.setAccounts(contractsGrantsInvoiceDocumentErrorLog.getAccounts() + ";" + awardAccount.getAccountNumber());
                    }
                }
            }
            contractsGrantsInvoiceDocumentErrorLog.setCumulativeExpensesAmount(cumulativeExpenses.bigDecimalValue());
        }
        for (String vCat : invalidGroup.get(award)) {
            ContractsGrantsInvoiceDocumentErrorMessage contractsGrantsInvoiceDocumentErrorCategory = new ContractsGrantsInvoiceDocumentErrorMessage();
            contractsGrantsInvoiceDocumentErrorCategory.setErrorMessageText(vCat);
            contractsGrantsInvoiceDocumentErrorLog.getErrorMessages().add(contractsGrantsInvoiceDocumentErrorCategory);
        }
        int errorAccountsMax = dataDictionaryService.getAttributeMaxLength(ContractsGrantsInvoiceDocumentErrorLog.class, ContractsGrantsInvoiceDocumentErrorLogLookupFields.ACCOUNTS);
        contractsGrantsInvoiceDocumentErrorLog.setAccounts(StringUtils.left(contractsGrantsInvoiceDocumentErrorLog.getAccounts(), errorAccountsMax));
        contractsGrantsInvoiceDocumentErrorLog.setErrorDate(dateTimeService.getCurrentTimestamp());
        contractsGrantsInvoiceDocumentErrorLog.setCreationProcessTypeCode(creationProcessTypeCode);
        businessObjectService.save(contractsGrantsInvoiceDocumentErrorLog);
        contractsGrantsInvoiceDocumentErrorLogs.add(contractsGrantsInvoiceDocumentErrorLog);
    }
}
Also used : ContractsGrantsInvoiceDocumentErrorMessage(org.kuali.kfs.module.ar.businessobject.ContractsGrantsInvoiceDocumentErrorMessage) ContractsAndGrantsBillingAward(org.kuali.kfs.integration.cg.ContractsAndGrantsBillingAward) ContractsGrantsInvoiceDocumentErrorLog(org.kuali.kfs.module.ar.businessobject.ContractsGrantsInvoiceDocumentErrorLog) KualiDecimal(org.kuali.kfs.core.api.util.type.KualiDecimal) ContractsAndGrantsBillingAwardAccount(org.kuali.kfs.integration.cg.ContractsAndGrantsBillingAwardAccount) SystemOptions(org.kuali.kfs.sys.businessobject.SystemOptions) Date(java.sql.Date)

Example 2 with ContractsGrantsInvoiceDocumentErrorLog

use of org.kuali.kfs.module.ar.businessobject.ContractsGrantsInvoiceDocumentErrorLog in project cu-kfs by CU-CommunityApps.

the class ContractsGrantsInvoiceCreateDocumentServiceImpl method storeCreationErrors.

protected void storeCreationErrors(List<ErrorMessage> errorMessages, String creationProcessTypeCode) {
    for (ErrorMessage errorMessage : errorMessages) {
        ContractsGrantsInvoiceDocumentErrorLog contractsGrantsInvoiceDocumentErrorLog = new ContractsGrantsInvoiceDocumentErrorLog();
        ContractsGrantsInvoiceDocumentErrorMessage contractsGrantsInvoiceDocumentErrorCategory = new ContractsGrantsInvoiceDocumentErrorMessage();
        contractsGrantsInvoiceDocumentErrorCategory.setErrorMessageText(MessageFormat.format(configurationService.getPropertyValueAsString(errorMessage.getErrorKey()), errorMessage.getMessageParameters()));
        contractsGrantsInvoiceDocumentErrorLog.getErrorMessages().add(contractsGrantsInvoiceDocumentErrorCategory);
        contractsGrantsInvoiceDocumentErrorLog.setErrorDate(dateTimeService.getCurrentTimestamp());
        contractsGrantsInvoiceDocumentErrorLog.setCreationProcessTypeCode(creationProcessTypeCode);
        businessObjectService.save(contractsGrantsInvoiceDocumentErrorLog);
    }
}
Also used : ContractsGrantsInvoiceDocumentErrorMessage(org.kuali.kfs.module.ar.businessobject.ContractsGrantsInvoiceDocumentErrorMessage) ContractsGrantsInvoiceDocumentErrorLog(org.kuali.kfs.module.ar.businessobject.ContractsGrantsInvoiceDocumentErrorLog) ErrorMessage(org.kuali.kfs.krad.util.ErrorMessage) ContractsGrantsInvoiceDocumentErrorMessage(org.kuali.kfs.module.ar.businessobject.ContractsGrantsInvoiceDocumentErrorMessage)

Example 3 with ContractsGrantsInvoiceDocumentErrorLog

use of org.kuali.kfs.module.ar.businessobject.ContractsGrantsInvoiceDocumentErrorLog in project cu-kfs by CU-CommunityApps.

the class ContractsGrantsInvoiceCreateDocumentServiceImpl method storeValidationErrors.

protected void storeValidationErrors(Map<ContractsAndGrantsBillingAward, List<String>> invalidGroup, Collection<ContractsGrantsInvoiceDocumentErrorLog> contractsGrantsInvoiceDocumentErrorLogs, String creationProcessTypeCode) {
    for (ContractsAndGrantsBillingAward award : invalidGroup.keySet()) {
        KualiDecimal cumulativeExpenses = KualiDecimal.ZERO;
        ContractsGrantsInvoiceDocumentErrorLog contractsGrantsInvoiceDocumentErrorLog = new ContractsGrantsInvoiceDocumentErrorLog();
        if (ObjectUtils.isNotNull(award)) {
            Date beginningDate = award.getAwardBeginningDate();
            Date endingDate = award.getAwardEndingDate();
            final SystemOptions systemOptions = optionsService.getCurrentYearOptions();
            contractsGrantsInvoiceDocumentErrorLog.setProposalNumber(award.getProposalNumber());
            contractsGrantsInvoiceDocumentErrorLog.setAwardBeginningDate(beginningDate);
            contractsGrantsInvoiceDocumentErrorLog.setAwardEndingDate(endingDate);
            contractsGrantsInvoiceDocumentErrorLog.setAwardTotalAmount(award.getAwardTotalAmount().bigDecimalValue());
            if (ObjectUtils.isNotNull(award.getAwardPrimaryFundManager())) {
                contractsGrantsInvoiceDocumentErrorLog.setPrimaryFundManagerPrincipalId(award.getAwardPrimaryFundManager().getPrincipalId());
            }
            if (!CollectionUtils.isEmpty(award.getActiveAwardAccounts())) {
                boolean firstLineFlag = true;
                for (ContractsAndGrantsBillingAwardAccount awardAccount : award.getActiveAwardAccounts()) {
                    cumulativeExpenses = cumulativeExpenses.add(contractsGrantsInvoiceDocumentService.getBudgetAndActualsForAwardAccount(awardAccount, systemOptions.getActualFinancialBalanceTypeCd()));
                    if (firstLineFlag) {
                        firstLineFlag = false;
                        contractsGrantsInvoiceDocumentErrorLog.setAccounts(awardAccount.getAccountNumber());
                    } else {
                        contractsGrantsInvoiceDocumentErrorLog.setAccounts(contractsGrantsInvoiceDocumentErrorLog.getAccounts() + ";" + awardAccount.getAccountNumber());
                    }
                }
            }
            contractsGrantsInvoiceDocumentErrorLog.setCumulativeExpensesAmount(cumulativeExpenses.bigDecimalValue());
        }
        for (String vCat : invalidGroup.get(award)) {
            ContractsGrantsInvoiceDocumentErrorMessage contractsGrantsInvoiceDocumentErrorCategory = new ContractsGrantsInvoiceDocumentErrorMessage();
            contractsGrantsInvoiceDocumentErrorCategory.setErrorMessageText(vCat);
            contractsGrantsInvoiceDocumentErrorLog.getErrorMessages().add(contractsGrantsInvoiceDocumentErrorCategory);
        }
        int errorAccountsMax = dataDictionaryService.getAttributeMaxLength(ContractsGrantsInvoiceDocumentErrorLog.class, ContractsGrantsInvoiceDocumentErrorLogLookupFields.ACCOUNTS);
        contractsGrantsInvoiceDocumentErrorLog.setAccounts(StringUtils.left(contractsGrantsInvoiceDocumentErrorLog.getAccounts(), errorAccountsMax));
        contractsGrantsInvoiceDocumentErrorLog.setErrorDate(dateTimeService.getCurrentTimestamp());
        contractsGrantsInvoiceDocumentErrorLog.setCreationProcessTypeCode(creationProcessTypeCode);
        businessObjectService.save(contractsGrantsInvoiceDocumentErrorLog);
        contractsGrantsInvoiceDocumentErrorLogs.add(contractsGrantsInvoiceDocumentErrorLog);
    }
}
Also used : ContractsGrantsInvoiceDocumentErrorMessage(org.kuali.kfs.module.ar.businessobject.ContractsGrantsInvoiceDocumentErrorMessage) ContractsAndGrantsBillingAward(org.kuali.kfs.integration.cg.ContractsAndGrantsBillingAward) ContractsGrantsInvoiceDocumentErrorLog(org.kuali.kfs.module.ar.businessobject.ContractsGrantsInvoiceDocumentErrorLog) KualiDecimal(org.kuali.kfs.core.api.util.type.KualiDecimal) ContractsAndGrantsBillingAwardAccount(org.kuali.kfs.integration.cg.ContractsAndGrantsBillingAwardAccount) SystemOptions(org.kuali.kfs.sys.businessobject.SystemOptions) Date(java.sql.Date)

Aggregations

ContractsGrantsInvoiceDocumentErrorLog (org.kuali.kfs.module.ar.businessobject.ContractsGrantsInvoiceDocumentErrorLog)3 ContractsGrantsInvoiceDocumentErrorMessage (org.kuali.kfs.module.ar.businessobject.ContractsGrantsInvoiceDocumentErrorMessage)3 Date (java.sql.Date)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 SystemOptions (org.kuali.kfs.sys.businessobject.SystemOptions)2 ErrorMessage (org.kuali.kfs.krad.util.ErrorMessage)1