use of org.kuali.kfs.core.api.util.type.KualiDecimal in project cu-kfs by CU-CommunityApps.
the class PaymentApplicationAction method adjustBothQuickApplyToInvoiceAndApplyToInvoiceDetailDueToDeleteInvoicePaidApplied.
protected void adjustBothQuickApplyToInvoiceAndApplyToInvoiceDetailDueToDeleteInvoicePaidApplied(PaymentApplicationForm paymentApplicationForm, int deletedAppliedFundsIndex) {
PaymentApplicationDocument paymentApplicationDocument = paymentApplicationForm.getPaymentApplicationDocument();
InvoicePaidApplied appliedFundBeingDeleted = paymentApplicationDocument.getInvoicePaidApplieds().get(deletedAppliedFundsIndex);
String summaryOfAppliedFundsDocumentNumberBeingDeleted = appliedFundBeingDeleted.getFinancialDocumentReferenceInvoiceNumber();
KualiDecimal summaryOfAppliedFundsAmountBeingDeleted = appliedFundBeingDeleted.getInvoiceItemAppliedAmount();
if (StringUtils.isNotBlank(summaryOfAppliedFundsDocumentNumberBeingDeleted)) {
for (PaymentApplicationInvoiceApply invoiceListItem : paymentApplicationForm.getInvoiceApplications()) {
for (PaymentApplicationInvoiceDetailApply invoiceListItemDetail : invoiceListItem.getDetailApplications()) {
deleteCleanupOfApplyToInvoiceDetailData(invoiceListItemDetail, summaryOfAppliedFundsDocumentNumberBeingDeleted, summaryOfAppliedFundsAmountBeingDeleted);
deleteCleanupOfQuickApplyToInvoiceData(invoiceListItem, invoiceListItemDetail, summaryOfAppliedFundsDocumentNumberBeingDeleted);
}
}
}
}
use of org.kuali.kfs.core.api.util.type.KualiDecimal in project cu-kfs by CU-CommunityApps.
the class ContractsGrantsInvoiceCreateDocumentServiceImpl method writeErrorEntryByAward.
protected void writeErrorEntryByAward(ContractsAndGrantsBillingAward award, List<String> validationCategory, PrintStream printStream) throws IOException {
// %15s %18s %20s %19s %15s %18s %23s %18s
if (ObjectUtils.isNotNull(award)) {
KualiDecimal cumulativeExpenses = KualiDecimal.ZERO;
String awardBeginningDate;
String awardEndingDate;
String awardTotalAmount;
String proposalNumber = award.getProposalNumber();
Date beginningDate = award.getAwardBeginningDate();
Date endingDate = award.getAwardEndingDate();
KualiDecimal totalAmount = award.getAwardTotalAmount();
if (ObjectUtils.isNotNull(beginningDate)) {
awardBeginningDate = beginningDate.toString();
} else {
awardBeginningDate = "null award beginning date";
}
if (ObjectUtils.isNotNull(endingDate)) {
awardEndingDate = endingDate.toString();
} else {
awardEndingDate = "null award ending date";
}
if (ObjectUtils.isNotNull(totalAmount) && ObjectUtils.isNotNull(totalAmount.bigDecimalValue())) {
awardTotalAmount = totalAmount.toString();
} else {
awardTotalAmount = "null award total amount";
}
if (CollectionUtils.isEmpty(award.getActiveAwardAccounts())) {
writeToReport(proposalNumber, "", awardBeginningDate, awardEndingDate, awardTotalAmount, cumulativeExpenses.toString(), printStream);
} else {
final SystemOptions systemOptions = optionsService.getCurrentYearOptions();
// calculate cumulativeExpenses
for (ContractsAndGrantsBillingAwardAccount awardAccount : award.getActiveAwardAccounts()) {
cumulativeExpenses = cumulativeExpenses.add(contractsGrantsInvoiceDocumentService.getBudgetAndActualsForAwardAccount(awardAccount, systemOptions.getActualFinancialBalanceTypeCd()));
}
boolean firstLineFlag = true;
for (ContractsAndGrantsBillingAwardAccount awardAccount : award.getActiveAwardAccounts()) {
if (firstLineFlag) {
writeToReport(proposalNumber, awardAccount.getAccountNumber(), awardBeginningDate, awardEndingDate, awardTotalAmount, cumulativeExpenses.toString(), printStream);
firstLineFlag = false;
} else {
writeToReport("", awardAccount.getAccountNumber(), "", "", "", "", printStream);
}
}
}
}
// To print all the errors from the validation category.
for (String vCat : validationCategory) {
printStream.printf("%s", " " + vCat);
printStream.print("\r\n");
}
printStream.print(REPORT_LINE_DIVIDER);
printStream.print("\r\n");
}
use of org.kuali.kfs.core.api.util.type.KualiDecimal in project cu-kfs by CU-CommunityApps.
the class ContractsGrantsInvoiceCreateDocumentServiceImpl method takeAPennyLeaveAPennyCGBStyle.
/**
* If the total of current expenditures within the list of InvoiceDetailAccountObjectCode business objects does
* not meet the amount to target, steal or give a penny from one of those business objects so that it does
*
* @param invoiceDetailAccountObjectCodes a List of InvoiceDetailAccountObjectCode business objects
* @param amountToTarget the amount which the sum of those objects should equal
*/
protected void takeAPennyLeaveAPennyCGBStyle(List<InvoiceDetailAccountObjectCode> invoiceDetailAccountObjectCodes, KualiDecimal amountToTarget) {
if (!CollectionUtils.isEmpty(invoiceDetailAccountObjectCodes)) {
final KualiDecimal currentExpenditureTotal = sumInvoiceDetailAccountObjectCodes(invoiceDetailAccountObjectCodes).getCurrentExpenditures();
if (!currentExpenditureTotal.equals(amountToTarget)) {
final KualiDecimal difference = currentExpenditureTotal.subtract(amountToTarget);
InvoiceDetailAccountObjectCode invoiceDetailAccountObjectCode = findFirstPositiveCurrentExpenditureInvoiceDetailAccountObjectCode(invoiceDetailAccountObjectCodes);
if (invoiceDetailAccountObjectCode != null) {
invoiceDetailAccountObjectCode.setCurrentExpenditures(invoiceDetailAccountObjectCode.getCurrentExpenditures().subtract(difference));
}
}
}
}
use of org.kuali.kfs.core.api.util.type.KualiDecimal in project cu-kfs by CU-CommunityApps.
the class ContractsGrantsInvoiceCreateDocumentServiceImpl method calculateBalanceAmountWithoutLastBilledPeriod.
/**
* This method would make sure the amounts of the current period are not included. So it calculates the cumulative
* and subtracts the current period values. This would be done for Billing Frequencies - Monthly, Quarterly,
* Semi-Annual and Annual.
*
* @param glBalance
* @return balanceAmount
*/
protected KualiDecimal calculateBalanceAmountWithoutLastBilledPeriod(java.sql.Date lastBilledDate, Balance glBalance) {
Timestamp ts = new Timestamp(new java.util.Date().getTime());
java.sql.Date today = new java.sql.Date(ts.getTime());
AccountingPeriod currPeriod = accountingPeriodService.getByDate(today);
String currentPeriodCode = currPeriod.getUniversityFiscalPeriodCode();
KualiDecimal currentBalanceAmount = KualiDecimal.ZERO;
switch(currentPeriodCode) {
case KFSConstants.MONTH13:
currentBalanceAmount = currentBalanceAmount.add(cleanAmount(glBalance.getMonth12Amount()));
// notice - no break!!!! we want to fall through to pick up all the prior months amounts
case KFSConstants.MONTH12:
currentBalanceAmount = currentBalanceAmount.add(cleanAmount(glBalance.getMonth11Amount()));
// fall through
case KFSConstants.MONTH11:
currentBalanceAmount = currentBalanceAmount.add(cleanAmount(glBalance.getMonth10Amount()));
// fall through
case KFSConstants.MONTH10:
currentBalanceAmount = currentBalanceAmount.add(cleanAmount(glBalance.getMonth9Amount()));
// fall through
case KFSConstants.MONTH9:
currentBalanceAmount = currentBalanceAmount.add(cleanAmount(glBalance.getMonth8Amount()));
// fall through
case KFSConstants.MONTH8:
currentBalanceAmount = currentBalanceAmount.add(cleanAmount(glBalance.getMonth7Amount()));
// fall through
case KFSConstants.MONTH7:
currentBalanceAmount = currentBalanceAmount.add(cleanAmount(glBalance.getMonth6Amount()));
// fall through
case KFSConstants.MONTH6:
currentBalanceAmount = currentBalanceAmount.add(cleanAmount(glBalance.getMonth5Amount()));
// fall through
case KFSConstants.MONTH5:
currentBalanceAmount = currentBalanceAmount.add(cleanAmount(glBalance.getMonth4Amount()));
// fall through
case KFSConstants.MONTH4:
currentBalanceAmount = currentBalanceAmount.add(cleanAmount(glBalance.getMonth3Amount()));
// fall through
case KFSConstants.MONTH3:
currentBalanceAmount = currentBalanceAmount.add(cleanAmount(glBalance.getMonth2Amount()));
// fall through
case KFSConstants.MONTH2:
currentBalanceAmount = currentBalanceAmount.add(cleanAmount(glBalance.getMonth1Amount()));
break;
default:
break;
}
return glBalance.getContractsGrantsBeginningBalanceAmount().add(currentBalanceAmount);
}
use of org.kuali.kfs.core.api.util.type.KualiDecimal 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