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);
}
}
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);
}
}
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);
}
}
Aggregations