Search in sources :

Example 1 with Asset

use of org.kuali.kfs.module.cam.businessobject.Asset in project cu-kfs by CU-CommunityApps.

the class AssetSeparatePaymentDistributor method allocatePaymentAmountsByRatio.

/**
 * Applies the asset allocate ratio for each payment line to be created and adds to the new asset. In addition it keeps track of
 * how amount is consumed by each asset and how each payment is being split
 */
private void allocatePaymentAmountsByRatio() {
    int index = 0;
    for (AssetPayment source : this.separatedPayments) {
        // for each source payment, create target payments by ratio
        AssetPayment[] targets = new AssetPayment[assetAllocateRatios.length];
        for (int j = 0; j < assetAllocateRatios.length; j++) {
            AssetPayment newPayment = new AssetPayment();
            ObjectValueUtils.copySimpleProperties(source, newPayment);
            Asset currentAsset = this.newAssets.get(j);
            Long capitalAssetNumber = currentAsset.getCapitalAssetNumber();
            newPayment.setCapitalAssetNumber(capitalAssetNumber);
            newPayment.setDocumentNumber(assetGlobal.getDocumentNumber());
            newPayment.setFinancialDocumentTypeCode(CamsConstants.PaymentDocumentTypeCodes.ASSET_GLOBAL_SEPARATE);
            targets[j] = newPayment;
            newPayment.setVersionNumber(null);
            newPayment.setObjectId(null);
            currentAsset.getAssetPayments().add(index, newPayment);
        }
        applyRatioToPaymentAmounts(source, targets, assetAllocateRatios);
        // keep track of split happened for the source
        this.paymentSplitMap.put(source.getPaymentSequenceNumber(), Arrays.asList(targets));
        // keep track of total amount by asset
        for (int j = 0; j < targets.length; j++) {
            Asset currentAsset = this.newAssets.get(j);
            Long capitalAssetNumber = currentAsset.getCapitalAssetNumber();
            this.totalByAsset.put(capitalAssetNumber, this.totalByAsset.get(capitalAssetNumber).add(targets[j].getAccountChargeAmount()));
        }
        index++;
    }
}
Also used : AssetPayment(org.kuali.kfs.module.cam.businessobject.AssetPayment) Asset(org.kuali.kfs.module.cam.businessobject.Asset)

Example 2 with Asset

use of org.kuali.kfs.module.cam.businessobject.Asset 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.rice.core.api.util.type.KualiDecimal)

Example 3 with Asset

use of org.kuali.kfs.module.cam.businessobject.Asset in project cu-kfs by CU-CommunityApps.

the class AssetSeparatePaymentDistributor method computeAccumulatedDepreciationAmount.

/**
 * Sums up YTD values and Previous Year value to decide accumulated depreciation amount
 */
private void computeAccumulatedDepreciationAmount() {
    KualiDecimal previousYearAmount = null;
    for (Asset asset : this.newAssets) {
        List<AssetPayment> assetPayments = asset.getAssetPayments();
        for (AssetPayment currPayment : assetPayments) {
            previousYearAmount = currPayment.getPreviousYearPrimaryDepreciationAmount();
            previousYearAmount = previousYearAmount == null ? KualiDecimal.ZERO : previousYearAmount;
            KualiDecimal computedAmount = previousYearAmount.add(sumPeriodicDepreciationAmounts(currPayment));
            if (computedAmount.isNonZero()) {
                currPayment.setAccumulatedPrimaryDepreciationAmount(computedAmount);
            }
        }
    }
    for (AssetPayment currPayment : this.offsetPayments) {
        previousYearAmount = currPayment.getPreviousYearPrimaryDepreciationAmount();
        previousYearAmount = previousYearAmount == null ? KualiDecimal.ZERO : previousYearAmount;
        KualiDecimal computedAmount = previousYearAmount.add(sumPeriodicDepreciationAmounts(currPayment));
        if (computedAmount.isNonZero()) {
            currPayment.setAccumulatedPrimaryDepreciationAmount(computedAmount);
        }
    }
}
Also used : AssetPayment(org.kuali.kfs.module.cam.businessobject.AssetPayment) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) Asset(org.kuali.kfs.module.cam.businessobject.Asset)

Example 4 with Asset

use of org.kuali.kfs.module.cam.businessobject.Asset in project cu-kfs by CU-CommunityApps.

the class CuAssetLookupableHelperServiceImpl method excludeBlankOffCampusLocations.

protected List<? extends BusinessObject> excludeBlankOffCampusLocations(List<? extends BusinessObject> results) {
    List<Asset> resultsModified = new ArrayList<Asset>();
    int count = 0;
    LOG.info("Asset count: " + results.size());
    for (BusinessObject boAsset : results) {
        Asset asset;
        if (boAsset instanceof Asset) {
            count++;
            boolean remove = false;
            asset = (Asset) boAsset;
            List<AssetLocation> locs = asset.getAssetLocations();
            if (locs.isEmpty()) {
                resultsModified.add(asset);
            }
            LOG.info("Asset location counts: " + locs.size());
            for (AssetLocation assetLoc : locs) {
                if (StringUtils.equalsIgnoreCase(assetLoc.getAssetLocationTypeCode(), "O")) {
                    remove |= StringUtils.isBlank(assetLoc.getAssetLocationStreetAddress());
                }
            }
            if (!remove) {
                resultsModified.add(asset);
            } else {
                LOG.info("Removing asset: " + asset.getCapitalAssetNumber());
            }
        } else {
            break;
        }
    }
    LOG.info("Assets reviewed: " + count);
    LOG.info("Results returned: " + resultsModified.size());
    return resultsModified;
}
Also used : AssetLocation(org.kuali.kfs.module.cam.businessobject.AssetLocation) ArrayList(java.util.ArrayList) Asset(org.kuali.kfs.module.cam.businessobject.Asset) BusinessObject(org.kuali.rice.krad.bo.BusinessObject)

Example 5 with Asset

use of org.kuali.kfs.module.cam.businessobject.Asset in project cu-kfs by CU-CommunityApps.

the class CuAssetGlobalServiceImpl method setupAsset.

// KFSUPGRADE-535
// if we need to implement service rate ind, then it can be populated from detail to assetext too.
@Override
protected Asset setupAsset(AssetGlobal assetGlobal, AssetGlobalDetail assetGlobalDetail, boolean separate) {
    Asset asset = super.setupAsset(assetGlobal, assetGlobalDetail, separate);
    AssetExtension ae = (AssetExtension) asset.getExtension();
    ae.setCapitalAssetNumber(asset.getCapitalAssetNumber());
    return asset;
}
Also used : AssetExtension(edu.cornell.kfs.module.cam.businessobject.AssetExtension) Asset(org.kuali.kfs.module.cam.businessobject.Asset)

Aggregations

Asset (org.kuali.kfs.module.cam.businessobject.Asset)10 ArrayList (java.util.ArrayList)3 AssetPayment (org.kuali.kfs.module.cam.businessobject.AssetPayment)3 HashMap (java.util.HashMap)2 AssetGlobalDetail (org.kuali.kfs.module.cam.businessobject.AssetGlobalDetail)2 KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)2 AssetExtension (edu.cornell.kfs.module.cam.businessobject.AssetExtension)1 CapitalAssetInformation (org.kuali.kfs.fp.businessobject.CapitalAssetInformation)1 AssetGlobal (org.kuali.kfs.module.cam.businessobject.AssetGlobal)1 AssetLocation (org.kuali.kfs.module.cam.businessobject.AssetLocation)1 AssetPaymentAssetDetail (org.kuali.kfs.module.cam.businessobject.AssetPaymentAssetDetail)1 GeneralLedgerEntryAsset (org.kuali.kfs.module.cam.businessobject.GeneralLedgerEntryAsset)1 BusinessObject (org.kuali.rice.krad.bo.BusinessObject)1