Search in sources :

Example 36 with KualiDecimal

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());
            }
        }
    }
}
Also used : AssetGlobalDetail(org.kuali.kfs.module.cam.businessobject.AssetGlobalDetail) AssetPayment(org.kuali.kfs.module.cam.businessobject.AssetPayment) Asset(org.kuali.kfs.module.cam.businessobject.Asset) KualiDecimal(org.kuali.kfs.core.api.util.type.KualiDecimal)

Example 37 with KualiDecimal

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);
}
Also used : KualiDecimal(org.kuali.kfs.core.api.util.type.KualiDecimal)

Example 38 with KualiDecimal

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;
}
Also used : SubFundGroup(org.kuali.kfs.coa.businessobject.SubFundGroup) ArrayList(java.util.ArrayList) CustomerInvoiceDetail(org.kuali.kfs.module.ar.businessobject.CustomerInvoiceDetail) AbstractKualiDecimal(org.kuali.kfs.core.api.util.type.AbstractKualiDecimal) KualiDecimal(org.kuali.kfs.core.api.util.type.KualiDecimal) InvoiceAccountDetail(org.kuali.kfs.module.ar.businessobject.InvoiceAccountDetail)

Example 39 with KualiDecimal

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));
}
Also used : KualiDecimal(org.kuali.kfs.core.api.util.type.KualiDecimal)

Example 40 with KualiDecimal

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;
}
Also used : OrganizationAccountingDefault(org.kuali.kfs.module.ar.businessobject.OrganizationAccountingDefault) HashMap(java.util.HashMap) AccountsReceivableCustomerInvoiceDetail(org.kuali.kfs.integration.ar.AccountsReceivableCustomerInvoiceDetail) CustomerInvoiceDetail(org.kuali.kfs.module.ar.businessobject.CustomerInvoiceDetail) KualiDecimal(org.kuali.kfs.core.api.util.type.KualiDecimal) BigDecimal(java.math.BigDecimal)

Aggregations

KualiDecimal (org.kuali.kfs.core.api.util.type.KualiDecimal)280 ArrayList (java.util.ArrayList)46 HashMap (java.util.HashMap)36 Test (org.junit.Test)28 AbstractKualiDecimal (org.kuali.kfs.core.api.util.type.AbstractKualiDecimal)21 BigDecimal (java.math.BigDecimal)18 List (java.util.List)18 SourceAccountingLine (org.kuali.kfs.sys.businessobject.SourceAccountingLine)15 Date (java.sql.Date)14 CapitalAssetInformation (org.kuali.kfs.fp.businessobject.CapitalAssetInformation)14 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)14 ConcurStandardAccountingExtractDetailLine (edu.cornell.kfs.concur.batch.businessobject.ConcurStandardAccountingExtractDetailLine)11 KualiInteger (org.kuali.kfs.core.api.util.type.KualiInteger)11 ParameterService (org.kuali.kfs.coreservice.framework.parameter.ParameterService)11 IOException (java.io.IOException)10 InvoiceDetailAccountObjectCode (org.kuali.kfs.module.ar.businessobject.InvoiceDetailAccountObjectCode)10 Map (java.util.Map)9 ParameterEvaluator (org.kuali.kfs.core.api.parameter.ParameterEvaluator)9 CapitalAccountingLines (org.kuali.kfs.fp.businessobject.CapitalAccountingLines)9 PurchaseOrderItem (org.kuali.kfs.module.purap.businessobject.PurchaseOrderItem)8