use of org.kuali.kfs.module.cam.businessobject.AssetPayment 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.AssetPayment in project cu-kfs by CU-CommunityApps.
the class AssetSeparatePaymentDistributor method prepareSourcePaymentsForSplit.
/**
* Split the amount to be assigned from the source payments
*/
private void prepareSourcePaymentsForSplit() {
// Call the allocate with ratio for each payments
for (AssetPayment assetPayment : this.sourcePayments) {
// KFSUPGRADE-929. some payment has 0 charge amount but with depr amount
if (assetPayment.getAccountChargeAmount() != null) {
// Separate amount
AssetPayment separatePayment = new AssetPayment();
ObjectValueUtils.copySimpleProperties(assetPayment, separatePayment);
this.separatedPayments.add(separatePayment);
// Remaining amount
AssetPayment remainingPayment = new AssetPayment();
ObjectValueUtils.copySimpleProperties(assetPayment, remainingPayment);
this.remainingPayments.add(remainingPayment);
applyRatioToPaymentAmounts(assetPayment, new AssetPayment[] { separatePayment, remainingPayment }, new double[] { separateRatio, retainRatio });
}
}
}
use of org.kuali.kfs.module.cam.businessobject.AssetPayment in project cu-kfs by CU-CommunityApps.
the class AssetSeparatePaymentDistributor method createOffsetPayments.
/**
* Creates offset payment by copying and negating the separated payments
*/
private void createOffsetPayments() {
// create offset payment by negating the amount fields
for (AssetPayment separatePayment : this.separatedPayments) {
AssetPayment offsetPayment = new AssetPayment();
ObjectValueUtils.copySimpleProperties(separatePayment, offsetPayment);
try {
negatePaymentAmounts(offsetPayment);
} catch (Exception e) {
throw new RuntimeException();
}
offsetPayment.setDocumentNumber(assetGlobal.getDocumentNumber());
offsetPayment.setFinancialDocumentTypeCode(CamsConstants.PaymentDocumentTypeCodes.ASSET_GLOBAL_SEPARATE);
offsetPayment.setVersionNumber(null);
offsetPayment.setObjectId(null);
offsetPayment.setPaymentSequenceNumber(++maxPaymentSeqNo);
this.offsetPayments.add(offsetPayment);
}
this.sourceAsset.getAssetPayments().addAll(this.offsetPayments);
}
use of org.kuali.kfs.module.cam.businessobject.AssetPayment 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.AssetPayment 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);
}
}
}
Aggregations