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++;
}
}
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());
}
}
}
}
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);
}
}
}
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;
}
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;
}
Aggregations