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