Search in sources :

Example 1 with AssetGlobalDetail

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

the class AssetSeparatePaymentDistributor method distribute.

public void distribute() {
    KualiDecimal totalSourceAmount = this.assetGlobal.getTotalCostAmount();
    KualiDecimal totalSeparateAmount = this.assetGlobal.getSeparateSourceTotalAmount();
    KualiDecimal remainingAmount = totalSourceAmount.subtract(totalSeparateAmount);
    // Compute separate ratio
    separateRatio = totalSeparateAmount.doubleValue() / totalSourceAmount.doubleValue();
    // Compute the retained ratio
    retainRatio = remainingAmount.doubleValue() / totalSourceAmount.doubleValue();
    List<AssetGlobalDetail> assetGlobalDetails = this.assetGlobal.getAssetGlobalDetails();
    int size = assetGlobalDetails.size();
    assetAllocateRatios = new double[size];
    AssetGlobalDetail assetGlobalDetail = null;
    // Compute ratio by each asset
    for (int i = 0; i < size; i++) {
        assetGlobalDetail = assetGlobalDetails.get(i);
        Long capitalAssetNumber = assetGlobalDetail.getCapitalAssetNumber();
        totalByAsset.put(capitalAssetNumber, KualiDecimal.ZERO);
        assetAllocateRatios[i] = assetGlobalDetail.getSeparateSourceAmount().doubleValue() / totalSeparateAmount.doubleValue();
    }
    // Prepare the source and offset payments for split
    prepareSourcePaymentsForSplit();
    // Distribute payments by ratio
    allocatePaymentAmountsByRatio();
    // Round and balance by each payment line
    roundPaymentAmounts();
    // Round and balance by separate source amount
    roundAccountChargeAmount();
    // create offset payments
    createOffsetPayments();
}
Also used : AssetGlobalDetail(org.kuali.kfs.module.cam.businessobject.AssetGlobalDetail) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal)

Example 2 with AssetGlobalDetail

use of org.kuali.kfs.module.cam.businessobject.AssetGlobalDetail 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 AssetGlobalDetail

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

the class GlLineServiceImpl method updatePreTagInformation.

/**
 * This method reads the pre-tag information and creates objects for asset global document
 *
 * @param entry GL Line
 * @param document Asset Global Maintenance Document
 * @param assetGlobal Asset Global Object
 */
protected void updatePreTagInformation(GeneralLedgerEntry entry, MaintenanceDocument document, AssetGlobal assetGlobal, Integer capitalAssetLineNumber) {
    CapitalAssetInformation capitalAssetInformation = findCapitalAssetInformation(entry.getDocumentNumber(), capitalAssetLineNumber);
    // if it is create asset...
    if (ObjectUtils.isNotNull(capitalAssetInformation)) {
        if (KFSConstants.CapitalAssets.CAPITAL_ASSET_CREATE_ACTION_INDICATOR.equals(capitalAssetInformation.getCapitalAssetActionIndicator())) {
            List<CapitalAssetInformationDetail> capitalAssetInformationDetails = capitalAssetInformation.getCapitalAssetInformationDetails();
            for (CapitalAssetInformationDetail capitalAssetInformationDetail : capitalAssetInformationDetails) {
                // This is not added to constructor in CAMS to provide module isolation from CAMS
                AssetGlobalDetail assetGlobalDetail = new AssetGlobalDetail();
                assetGlobalDetail.setDocumentNumber(document.getDocumentNumber());
                assetGlobalDetail.setCampusCode(capitalAssetInformationDetail.getCampusCode());
                assetGlobalDetail.setBuildingCode(capitalAssetInformationDetail.getBuildingCode());
                assetGlobalDetail.setBuildingRoomNumber(capitalAssetInformationDetail.getBuildingRoomNumber());
                assetGlobalDetail.setBuildingSubRoomNumber(capitalAssetInformationDetail.getBuildingSubRoomNumber());
                assetGlobalDetail.setSerialNumber(capitalAssetInformationDetail.getCapitalAssetSerialNumber());
                assetGlobalDetail.setCapitalAssetNumber(NextAssetNumberFinder.getLongValue());
                assetGlobalDetail.setCampusTagNumber(capitalAssetInformationDetail.getCapitalAssetTagNumber());
                // KFSPTS-3597 add off campus information
                CapitalAssetInformationDetailExtendedAttribute extendedAttribute = (CapitalAssetInformationDetailExtendedAttribute) capitalAssetInformationDetail.getExtension();
                assetGlobalDetail.setOffCampusAddress(extendedAttribute.getAssetLocationStreetAddress());
                assetGlobalDetail.setOffCampusCityName(extendedAttribute.getAssetLocationCityName());
                assetGlobalDetail.setOffCampusCountryCode(extendedAttribute.getAssetLocationCountryCode());
                assetGlobalDetail.setOffCampusStateCode(extendedAttribute.getAssetLocationStateCode());
                assetGlobalDetail.setOffCampusZipCode(extendedAttribute.getAssetLocationZipCode());
                AssetGlobalDetail uniqueAsset = new AssetGlobalDetail();
                ObjectValueUtils.copySimpleProperties(assetGlobalDetail, uniqueAsset);
                assetGlobalDetail.getAssetGlobalUniqueDetails().add(uniqueAsset);
                assetGlobal.getAssetSharedDetails().add(assetGlobalDetail);
            }
            assetGlobal.setVendorName(capitalAssetInformation.getVendorName());
            assetGlobal.setInventoryStatusCode(CamsConstants.InventoryStatusCode.CAPITAL_ASSET_ACTIVE_IDENTIFIABLE);
            assetGlobal.setCapitalAssetTypeCode(capitalAssetInformation.getCapitalAssetTypeCode());
            assetGlobal.setManufacturerName(capitalAssetInformation.getCapitalAssetManufacturerName());
            assetGlobal.setManufacturerModelNumber(capitalAssetInformation.getCapitalAssetManufacturerModelNumber());
            assetGlobal.setCapitalAssetDescription(capitalAssetInformation.getCapitalAssetDescription());
        }
    }
}
Also used : CapitalAssetInformation(org.kuali.kfs.fp.businessobject.CapitalAssetInformation) AssetGlobalDetail(org.kuali.kfs.module.cam.businessobject.AssetGlobalDetail) CapitalAssetInformationDetailExtendedAttribute(edu.cornell.kfs.fp.businessobject.CapitalAssetInformationDetailExtendedAttribute) CapitalAssetInformationDetail(org.kuali.kfs.fp.businessobject.CapitalAssetInformationDetail)

Example 4 with AssetGlobalDetail

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

the class CuAssetGlobalServiceImplTest method testSetupAsset.

public void testSetupAsset() {
    AssetGlobal assetGlobal = AssetGlobalFixture.ONE.createAssetGlobal();
    AssetGlobalDetail assetGlobalDetail = AssetGlobalDetailFixture.ONE.createAssetGlobalDetail();
    Asset asset = assetGlobalService.setupAsset(assetGlobal, assetGlobalDetail, false);
    assertTrue("Asset was not null", null != asset);
    LOG.info("Asset created was not null");
}
Also used : AssetGlobalDetail(org.kuali.kfs.module.cam.businessobject.AssetGlobalDetail) AssetGlobal(org.kuali.kfs.module.cam.businessobject.AssetGlobal) Asset(org.kuali.kfs.module.cam.businessobject.Asset)

Aggregations

AssetGlobalDetail (org.kuali.kfs.module.cam.businessobject.AssetGlobalDetail)4 Asset (org.kuali.kfs.module.cam.businessobject.Asset)2 KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)2 CapitalAssetInformationDetailExtendedAttribute (edu.cornell.kfs.fp.businessobject.CapitalAssetInformationDetailExtendedAttribute)1 CapitalAssetInformation (org.kuali.kfs.fp.businessobject.CapitalAssetInformation)1 CapitalAssetInformationDetail (org.kuali.kfs.fp.businessobject.CapitalAssetInformationDetail)1 AssetGlobal (org.kuali.kfs.module.cam.businessobject.AssetGlobal)1 AssetPayment (org.kuali.kfs.module.cam.businessobject.AssetPayment)1