use of org.kuali.kfs.core.api.util.type.KualiDecimal in project cu-kfs by CU-CommunityApps.
the class AssetSeparatePaymentDistributor method roundAccountChargeAmount.
/**
* Rounds the last payment by adjusting the amount compared against separate source amount and copies account charge amount to
* primary depreciation base amount if not zero
*/
private void roundAccountChargeAmount() {
for (int j = 0; j < this.newAssets.size(); j++) {
Asset currentAsset = this.newAssets.get(j);
AssetGlobalDetail detail = this.assetGlobal.getAssetGlobalDetails().get(j);
AssetPayment lastPayment = currentAsset.getAssetPayments().get(currentAsset.getAssetPayments().size() - 1);
KualiDecimal totalForAsset = this.totalByAsset.get(currentAsset.getCapitalAssetNumber());
KualiDecimal diff = detail.getSeparateSourceAmount().subtract(totalForAsset);
lastPayment.setAccountChargeAmount(lastPayment.getAccountChargeAmount().add(diff));
currentAsset.setTotalCostAmount(totalForAsset.add(diff));
AssetPayment lastSource = this.separatedPayments.get(this.separatedPayments.size() - 1);
lastSource.setAccountChargeAmount(lastSource.getAccountChargeAmount().add(diff));
// TODO : need more testing
if (lastPayment.getPrimaryDepreciationBaseAmount() != null && lastPayment.getPrimaryDepreciationBaseAmount().isNonZero()) {
if (lastPayment.getAccountChargeAmount().isNonZero() || lastPayment.getAccumulatedPrimaryDepreciationAmount() == null || lastPayment.getAccumulatedPrimaryDepreciationAmount().isZero()) {
lastPayment.setPrimaryDepreciationBaseAmount(lastPayment.getAccountChargeAmount());
lastSource.setPrimaryDepreciationBaseAmount(lastSource.getAccountChargeAmount());
}
}
}
}
use of org.kuali.kfs.core.api.util.type.KualiDecimal in project cu-kfs by CU-CommunityApps.
the class Award method getAwardTotalAmount.
@Override
public KualiDecimal getAwardTotalAmount() {
KualiDecimal direct = getAwardDirectCostAmount();
KualiDecimal indirect = getAwardIndirectCostAmount();
return ObjectUtils.isNull(direct) || ObjectUtils.isNull(indirect) ? null : direct.add(indirect);
}
use of org.kuali.kfs.core.api.util.type.KualiDecimal in project cu-kfs by CU-CommunityApps.
the class ContractsGrantsInvoiceDocumentServiceImpl method createSourceAccountingLinesByAward.
/**
* Generates the source accounting lines for a Contracts & Grants Invoice from the award accounts associated with
* an award (in the form of the pre-generated invoice account details)
*
* @param contractsGrantsInvoiceDocument the Contracts & Grants Invoice to create invoice details for
* @return a List of generated accounting lines
*/
protected List<CustomerInvoiceDetail> createSourceAccountingLinesByAward(ContractsGrantsInvoiceDocument contractsGrantsInvoiceDocument) {
List<CustomerInvoiceDetail> awardAccountingLines = new ArrayList<>();
if (!CollectionUtils.isEmpty(contractsGrantsInvoiceDocument.getAccountDetails())) {
final Map<String, KualiDecimal> accountExpenditureAmounts = getCategoryExpenditureAmountsForInvoiceAccountDetail(contractsGrantsInvoiceDocument);
final Map<String, KualiDecimal> accountTotalBilledAmounts = getCategoryTotalBilledAmountsForInvoiceAccountDetail(contractsGrantsInvoiceDocument);
for (InvoiceAccountDetail invAcctD : contractsGrantsInvoiceDocument.getAccountDetails()) {
final String proposalNumber = invAcctD.getProposalNumber();
final String chartOfAccountsCode = invAcctD.getChartOfAccountsCode();
final String accountNumber = invAcctD.getAccountNumber();
if (invAcctD.getAccount() == null) {
invAcctD.refreshReferenceObject(KFSPropertyConstants.ACCOUNT);
}
final SubFundGroup subFundGroup = invAcctD.getAccount().getSubFundGroup();
final Integer sequenceNumber = contractsGrantsInvoiceDocument.getAccountDetails().indexOf(invAcctD) + 1;
final String accountKey = StringUtils.join(new String[] { chartOfAccountsCode, accountNumber }, "-");
KualiDecimal totalAmount = accountExpenditureAmounts.getOrDefault(accountKey, KualiDecimal.ZERO);
if (invAcctD.getTotalPreviouslyBilled().isZero()) {
KualiDecimal previouslyBilledAmount = getPredeterminedBillingBilledToDateAmount(proposalNumber, chartOfAccountsCode, accountNumber);
previouslyBilledAmount = previouslyBilledAmount.add(getMilestonesBilledToDateAmount(proposalNumber, chartOfAccountsCode, accountNumber));
KualiDecimal totalBilledAmount = accountTotalBilledAmounts.getOrDefault(accountKey, KualiDecimal.ZERO);
previouslyBilledAmount = previouslyBilledAmount.subtract(totalBilledAmount);
if (previouslyBilledAmount.isGreaterThan(KualiDecimal.ZERO)) {
totalAmount = totalAmount.subtract(previouslyBilledAmount);
}
}
CustomerInvoiceDetail cide = createSourceAccountingLine(contractsGrantsInvoiceDocument.getDocumentNumber(), chartOfAccountsCode, accountNumber, subFundGroup, totalAmount, sequenceNumber);
awardAccountingLines.add(cide);
}
}
return awardAccountingLines;
}
use of org.kuali.kfs.core.api.util.type.KualiDecimal in project cu-kfs by CU-CommunityApps.
the class CustomerInvoiceDetailServiceImpl method recalculateCustomerInvoiceDetail.
@Override
public void recalculateCustomerInvoiceDetail(CustomerInvoiceDocument customerInvoiceDocument, CustomerInvoiceDetail customerInvoiceDetail) {
// make sure amounts are negative when they are supposed to be
if (!customerInvoiceDocument.isInvoiceReversal() && customerInvoiceDetail.isDiscountLine()) {
customerInvoiceDetail.setInvoiceItemUnitPriceToNegative();
} else if (customerInvoiceDocument.isInvoiceReversal() && !customerInvoiceDetail.isDiscountLine()) {
customerInvoiceDetail.setInvoiceItemUnitPriceToNegative();
}
KualiDecimal pretaxAmount = customerInvoiceDetail.getInvoiceItemPreTaxAmount();
KualiDecimal taxAmount = KualiDecimal.ZERO;
if (accountsReceivableTaxService.isCustomerInvoiceDetailTaxable(customerInvoiceDocument, customerInvoiceDetail)) {
String postalCode = accountsReceivableTaxService.getPostalCodeForTaxation(customerInvoiceDocument);
taxAmount = taxService.getTotalSalesTaxAmount(dateTimeService.getCurrentSqlDate(), postalCode, pretaxAmount);
}
customerInvoiceDetail.setInvoiceItemTaxAmount(taxAmount);
customerInvoiceDetail.setAmount(taxAmount.add(pretaxAmount));
}
use of org.kuali.kfs.core.api.util.type.KualiDecimal in project cu-kfs by CU-CommunityApps.
the class CustomerInvoiceDetailServiceImpl method getCustomerInvoiceDetailFromOrganizationAccountingDefault.
@Override
public CustomerInvoiceDetail getCustomerInvoiceDetailFromOrganizationAccountingDefault(Integer universityFiscalYear, String chartOfAccountsCode, String organizationCode) {
CustomerInvoiceDetail customerInvoiceDetail = new CustomerInvoiceDetail();
Map<String, Object> criteria = new HashMap<>();
criteria.put("universityFiscalYear", universityFiscalYear);
criteria.put("chartOfAccountsCode", chartOfAccountsCode);
criteria.put("organizationCode", organizationCode);
OrganizationAccountingDefault organizationAccountingDefault = businessObjectService.findByPrimaryKey(OrganizationAccountingDefault.class, criteria);
if (ObjectUtils.isNotNull(organizationAccountingDefault)) {
customerInvoiceDetail.setChartOfAccountsCode(organizationAccountingDefault.getDefaultInvoiceChartOfAccountsCode());
customerInvoiceDetail.setAccountNumber(organizationAccountingDefault.getDefaultInvoiceAccountNumber());
customerInvoiceDetail.setSubAccountNumber(organizationAccountingDefault.getDefaultInvoiceSubAccountNumber());
customerInvoiceDetail.setFinancialObjectCode(organizationAccountingDefault.getDefaultInvoiceFinancialObjectCode());
customerInvoiceDetail.setFinancialSubObjectCode(organizationAccountingDefault.getDefaultInvoiceFinancialSubObjectCode());
customerInvoiceDetail.setProjectCode(organizationAccountingDefault.getDefaultInvoiceProjectCode());
customerInvoiceDetail.setOrganizationReferenceId(organizationAccountingDefault.getDefaultInvoiceOrganizationReferenceIdentifier());
}
customerInvoiceDetail.setInvoiceItemTaxAmount(new KualiDecimal(0.00));
customerInvoiceDetail.setInvoiceItemQuantity(new BigDecimal(1));
customerInvoiceDetail.setInvoiceItemUnitOfMeasureCode(ArConstants.CUSTOMER_INVOICE_DETAIL_UOM_DEFAULT);
customerInvoiceDetail.setTaxableIndicator(false);
return customerInvoiceDetail;
}
Aggregations