Search in sources :

Example 6 with Asset

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

the class CuAssetServiceImpl method findActiveAssetsMatchingTagNumber.

public List<Asset> findActiveAssetsMatchingTagNumber(String campusTagNumber) {
    List<Asset> activeMatches = new ArrayList<Asset>();
    // find all assets matching this tag number
    Map<String, String> params = new HashMap<String, String>();
    params.put(CamsPropertyConstants.Asset.CAMPUS_TAG_NUMBER, campusTagNumber);
    Collection<Asset> tagMatches = businessObjectService.findMatching(Asset.class, params);
    if (tagMatches != null && !tagMatches.isEmpty()) {
        for (Asset asset : tagMatches) {
            // if found matching, check if status is not retired
            if (!isAssetRetired(asset) || parameterService.getParameterValueAsBoolean(CamsConstants.CAM_MODULE_CODE, "Asset", CuCamsConstants.Parameters.RE_USE_RETIRED_ASSET_TAG_NUMBER, Boolean.FALSE)) {
                activeMatches.add(asset);
            }
        }
    }
    return activeMatches;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Asset(org.kuali.kfs.module.cam.businessobject.Asset)

Example 7 with Asset

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

the class CuAssetRule method validateTagNumber.

protected boolean validateTagNumber() {
    boolean valid = true;
    boolean anyFound = false;
    if (!assetService.isTagNumberCheckExclude(newAsset)) {
        Map<String, Object> fieldValues = new HashMap<String, Object>();
        if (ObjectUtils.isNotNull(newAsset.getCampusTagNumber())) {
            fieldValues.put(CamsPropertyConstants.Asset.CAMPUS_TAG_NUMBER, newAsset.getCampusTagNumber().toUpperCase());
            Collection<Asset> results = getBoService().findMatching(Asset.class, fieldValues);
            for (Asset asset : results) {
                if (!asset.getCapitalAssetNumber().equals(newAsset.getCapitalAssetNumber())) {
                    // KFSMI-6149 - do not invalidate if the asset from the database is retired
                    if (StringUtils.isBlank(asset.getRetirementReasonCode()) || !parameterService.getParameterValueAsBoolean(CamsConstants.CAM_MODULE_CODE, "Asset", CuCamsConstants.Parameters.RE_USE_RETIRED_ASSET_TAG_NUMBER, Boolean.FALSE)) {
                        putFieldError(CamsPropertyConstants.Asset.CAMPUS_TAG_NUMBER, CamsKeyConstants.AssetLocationGlobal.ERROR_DUPLICATE_TAG_NUMBER_FOUND, new String[] { newAsset.getCampusTagNumber(), asset.getCapitalAssetNumber().toString(), newAsset.getCapitalAssetNumber().toString() });
                        valid &= false;
                        LOG.info("The asset tag number [" + newAsset.getCampusTagNumber().toUpperCase() + "] is a duplicate of asset number [" + asset.getCapitalAssetNumber().toString() + "]'s tag number");
                    } else {
                        LOG.info("Although the asset tag number [" + newAsset.getCampusTagNumber().toUpperCase() + "] is a duplicate of asset number [" + asset.getCapitalAssetNumber().toString() + "]'s tag number, the old asset has already been retired");
                    }
                }
            }
        }
    }
    return valid;
}
Also used : HashMap(java.util.HashMap) Asset(org.kuali.kfs.module.cam.businessobject.Asset)

Example 8 with Asset

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

the class CuAssetServiceImplTest method createAssetWithGivenInventoryStatusCode.

protected List<Asset> createAssetWithGivenInventoryStatusCode(String inventoryStatusCode) {
    List<Asset> assetsList = new ArrayList<Asset>();
    Asset asset = new Asset();
    asset.setInventoryStatusCode(inventoryStatusCode);
    assetsList.add(asset);
    return assetsList;
}
Also used : ArrayList(java.util.ArrayList) Asset(org.kuali.kfs.module.cam.businessobject.Asset)

Example 9 with Asset

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

the class GlLineServiceImpl method updatePreTagInformation.

/**
 * Updates pre tag information received from FP document
 *
 * @param entry GeneralLedgerEntry
 * @param document AssetPaymentDocument
 */
protected void updatePreTagInformation(GeneralLedgerEntry entry, AssetPaymentDocument document, Integer capitalAssetLineNumber) {
    CapitalAssetInformation capitalAssetInformation = findCapitalAssetInformation(entry.getDocumentNumber(), capitalAssetLineNumber);
    if (ObjectUtils.isNotNull(capitalAssetInformation)) {
        // if it is modify asset...
        if (KFSConstants.CapitalAssets.CAPITAL_ASSET_MODIFY_ACTION_INDICATOR.equals(capitalAssetInformation.getCapitalAssetActionIndicator())) {
            AssetPaymentAssetDetail assetPaymentAssetDetail = new AssetPaymentAssetDetail();
            assetPaymentAssetDetail.setDocumentNumber(document.getDocumentNumber());
            // get the allocated amount for the capital asset....
            assetPaymentAssetDetail.setCapitalAssetNumber(capitalAssetInformation.getCapitalAssetNumber());
            assetPaymentAssetDetail.setAllocatedAmount(KualiDecimal.ZERO);
            assetPaymentAssetDetail.setAllocatedUserValue(assetPaymentAssetDetail.getAllocatedAmount());
            assetPaymentAssetDetail.refreshReferenceObject(CamsPropertyConstants.AssetPaymentAssetDetail.ASSET);
            Asset asset = assetPaymentAssetDetail.getAsset();
            if (ObjectUtils.isNotNull(asset)) {
                assetPaymentAssetDetail.setPreviousTotalCostAmount(asset.getTotalCostAmount() != null ? asset.getTotalCostAmount() : KualiDecimal.ZERO);
                document.getAssetPaymentAssetDetail().add(assetPaymentAssetDetail);
            }
        }
    }
}
Also used : CapitalAssetInformation(org.kuali.kfs.fp.businessobject.CapitalAssetInformation) AssetPaymentAssetDetail(org.kuali.kfs.module.cam.businessobject.AssetPaymentAssetDetail) GeneralLedgerEntryAsset(org.kuali.kfs.module.cam.businessobject.GeneralLedgerEntryAsset) Asset(org.kuali.kfs.module.cam.businessobject.Asset)

Example 10 with Asset

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

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