Search in sources :

Example 71 with KualiDecimal

use of org.kuali.kfs.core.api.util.type.KualiDecimal in project cu-kfs by CU-CommunityApps.

the class CapitalAssetInformationActionBase method accountingLinesAmountDistributed.

/**
 * @param capitalAccountingLines
 * @param existingCapitalAsset
 * @return true if accounting line amount equals to capital asset amount, else false.
 */
protected boolean accountingLinesAmountDistributed(List<CapitalAccountingLines> capitalAccountingLines, CapitalAssetInformation existingCapitalAsset) {
    KualiDecimal accountingLineAmount = KualiDecimal.ZERO;
    for (CapitalAccountingLines capitalAccountingLine : capitalAccountingLines) {
        accountingLineAmount = accountingLineAmount.add(capitalAccountingLine.getAmount().abs());
    }
    KualiDecimal capitalAssetsAmount = existingCapitalAsset.getCapitalAssetLineAmount();
    return accountingLineAmount.equals(capitalAssetsAmount);
}
Also used : CapitalAccountingLines(org.kuali.kfs.fp.businessobject.CapitalAccountingLines) KualiDecimal(org.kuali.kfs.core.api.util.type.KualiDecimal)

Example 72 with KualiDecimal

use of org.kuali.kfs.core.api.util.type.KualiDecimal in project cu-kfs by CU-CommunityApps.

the class BalanceInquiryLookupAction method getSelectedObjectIds.

/**
 * put all entities into select object map. This implementation only deals with the money amount objects.
 *
 * @param multipleValueLookupForm the given struts form
 * @param resultTable             the given result table that holds all data being presented
 * @return the map containing all entries available for selection
 */
private Map<String, String> getSelectedObjectIds(MultipleValueLookupForm multipleValueLookupForm, List<ResultRow> resultTable) {
    String businessObjectClassName = multipleValueLookupForm.getBusinessObjectClassName();
    SegmentedBusinessObject segmentedBusinessObject;
    try {
        segmentedBusinessObject = (SegmentedBusinessObject) Class.forName(multipleValueLookupForm.getBusinessObjectClassName()).newInstance();
    } catch (Exception e) {
        throw new RuntimeException("Fail to create an object of " + businessObjectClassName + e);
    }
    Map<String, String> selectedObjectIds = new HashMap<>();
    Collection<String> segmentedPropertyNames = segmentedBusinessObject.getSegmentedPropertyNames();
    for (ResultRow row : resultTable) {
        for (Column column : row.getColumns()) {
            String propertyName = column.getPropertyName();
            if (segmentedPropertyNames.contains(propertyName)) {
                String propertyValue = StringUtils.replace(column.getPropertyValue(), ",", "");
                // Cornell Customization If there is a negative value, we need to convert it from (##.##) to -##.##
                if (StringUtils.contains(propertyValue, "(")) {
                    propertyValue = StringUtils.replace(propertyValue, "(", "-");
                    propertyValue = StringUtils.replace(propertyValue, ")", "");
                }
                KualiDecimal amount = new KualiDecimal(propertyValue);
                if (amount.isNonZero()) {
                    String objectId = row.getObjectId() + "." + propertyName + "." + KRADUtils.convertDecimalIntoInteger(amount);
                    selectedObjectIds.put(objectId, objectId);
                }
            }
        }
    }
    return selectedObjectIds;
}
Also used : ResultRow(org.kuali.kfs.kns.web.ui.ResultRow) HashMap(java.util.HashMap) Column(org.kuali.kfs.kns.web.ui.Column) KualiDecimal(org.kuali.kfs.core.api.util.type.KualiDecimal) SegmentedBusinessObject(org.kuali.kfs.integration.ld.SegmentedBusinessObject)

Example 73 with KualiDecimal

use of org.kuali.kfs.core.api.util.type.KualiDecimal in project cu-kfs by CU-CommunityApps.

the class CustomerInvoiceDetail method getAmountOpen.

// ---- BEGIN OPEN AMOUNTS
public KualiDecimal getAmountOpen() {
    // if the parent isn't saved, or if its saved but not approved, we
    // need to include the discounts.  If its both saved AND approved, we do not include the discounts.
    boolean includeDiscounts = !(isParentSaved() && isParentApproved());
    KualiDecimal amount = getAmount();
    KualiDecimal applied = getAmountApplied();
    KualiDecimal a = amount.subtract(applied);
    if (includeDiscounts) {
        CustomerInvoiceDetail discount = getDiscountCustomerInvoiceDetail();
        if (ObjectUtils.isNotNull(discount)) {
            a = a.add(discount.getAmount());
        }
    }
    return a;
}
Also used : KualiDecimal(org.kuali.kfs.core.api.util.type.KualiDecimal) AccountsReceivableCustomerInvoiceDetail(org.kuali.kfs.integration.ar.AccountsReceivableCustomerInvoiceDetail)

Example 74 with KualiDecimal

use of org.kuali.kfs.core.api.util.type.KualiDecimal in project cu-kfs by CU-CommunityApps.

the class CustomerInvoiceDetail method getAmountDiscounted.

/**
 * Retrieves the discounted amount.  This is the amount minutes any discounts that might exist.  If no discount
 * exists, then it just returns the amount.
 * <p>
 * NOTE this does not subtract PaidApplieds, only discounts.
 *
 * @return
 */
// PAYAPP
public KualiDecimal getAmountDiscounted() {
    KualiDecimal a = getAmount();
    CustomerInvoiceDetail discount = getDiscountCustomerInvoiceDetail();
    if (ObjectUtils.isNotNull(discount)) {
        KualiDecimal d = discount.getAmount();
        a = a.add(d);
    }
    return a;
}
Also used : KualiDecimal(org.kuali.kfs.core.api.util.type.KualiDecimal) AccountsReceivableCustomerInvoiceDetail(org.kuali.kfs.integration.ar.AccountsReceivableCustomerInvoiceDetail)

Example 75 with KualiDecimal

use of org.kuali.kfs.core.api.util.type.KualiDecimal in project cu-kfs by CU-CommunityApps.

the class PaymentApplicationAdjustmentDocument method getTotalDollarAmount.

/**
 * @return The total available to be applied on this document.
 * back-port FINP 7310
 */
@Override
public KualiDecimal getTotalDollarAmount() {
    PaymentApplicationAdjustableDocument adjusteeDocument = (PaymentApplicationAdjustableDocument) getAdjusteeDocument();
    KualiDecimal cumulativeAdjusteeNonArTotal = KualiDecimal.ZERO;
    if (anAppaIsBeingAdjusted(adjusteeDocument)) {
        while (adjusteeDocument instanceof PaymentApplicationAdjustmentDocument) {
            cumulativeAdjusteeNonArTotal = cumulativeAdjusteeNonArTotal.add(adjusteeDocument.getNonArTotal());
            adjusteeDocument = (PaymentApplicationAdjustableDocument) ((PaymentApplicationAdjustmentDocument) adjusteeDocument).getAdjusteeDocument();
        }
    } else {
        // An APP is being adjusted
        cumulativeAdjusteeNonArTotal = cumulativeAdjusteeNonArTotal.add(adjusteeDocument.getNonArTotal());
    }
    final PaymentApplicationDocument rootAdjusteeDocument = getRootAdjusteeDocument();
    final KualiDecimal rootAdjusteeTotalFromControl = rootAdjusteeDocument.getTotalFromControl();
    final KualiDecimal totalDollarAmount = rootAdjusteeTotalFromControl.subtract(cumulativeAdjusteeNonArTotal);
    LOG.debug("getTotalDollarAmount() - Exit : totalDollarAmount={}", totalDollarAmount);
    return totalDollarAmount;
}
Also used : AbstractKualiDecimal(org.kuali.kfs.core.api.util.type.AbstractKualiDecimal) KualiDecimal(org.kuali.kfs.core.api.util.type.KualiDecimal)

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