@Test public void depreciateAssetTest() { final DepreciationRequest depreciationRequest = getDepreciationRequest(); final List<CalculationAssetDetails> calculationAssetDetailList = getCalculationAssetDetailList(); final List<AssetCurrentValue> assetCurrentValues = getAssetCurrentValues(); final Map<Long, CalculationCurrentValue> calculationCurrentValues = getCalculationCurrentValueMap(); final Map<Long, BigDecimal> depreciationSumMap = getDepreciationSumMap(); final Map<Long, DepreciationDetail> depreciationDetailsMap = getDepreciationDetailsMap(); final String depreciationMinimumValue = "5000"; final String depreciationCapiatalizedValue = "1"; final String depreciationCFactor = "0.5"; when(assetConfigurationService.getAssetConfigValueByKeyAndTenantId(AssetConfigurationKeys.ASSETMINIMUMVALUE, "ap.kurnool")).thenReturn(depreciationMinimumValue); when(assetConfigurationService .getAssetConfigValueByKeyAndTenantId(AssetConfigurationKeys.ASSETDEFAULTCAPITALIZEDVALUE, "ap.kurnool")) .thenReturn(depreciationCapiatalizedValue); when(assetConfigurationService.getAssetConfigValueByKeyAndTenantId(AssetConfigurationKeys.DEPRECIATIONCFACTOR, "ap.kurnool")).thenReturn(depreciationCFactor); assetDepreciatorImpl.depreciateAsset(depreciationRequest, calculationAssetDetailList, calculationCurrentValues, depreciationSumMap, assetCurrentValues, depreciationDetailsMap); }
@Override public void depreciateAsset(final DepreciationRequest depreciationRequest, final List<CalculationAssetDetails> calculationAssetDetailList, final Map<Long, CalculationCurrentValue> calculationCurrentValues, final Map<Long, BigDecimal> depreciationSumMap, final List<AssetCurrentValue> assetCurrentValues, final Map<Long, DepreciationDetail> depreciationDetailsMap) { final BigDecimal depreciationSum = BigDecimal.ZERO; for (final CalculationAssetDetails calculationAssetDetail : calculationAssetDetailList) { log.info("inside the loop for calculation asset details"); final Long assetId = calculationAssetDetail.getAssetId(); final Double depreciationRate = getDepreciationRate(calculationAssetDetail); if (depreciationRate == null) { depreciationDetailsMap.put(assetId, DepreciationDetail.builder().assetId(assetId).status(DepreciationStatus.FAIL) .reasonForFailure(ReasonForFailure.DEPRECIATION_RATE_NOT_FOUND).build()); continue; } final CalculationCurrentValue calculationCurrentValue = calculationCurrentValues.get(assetId); final DepreciationDetail depreciationDetail = computeDepreciationDetail(calculationAssetDetail, calculationCurrentValue, depreciationRate, depreciationSum); depreciationDetail.setAssetId(assetId); if (depreciationDetail.getStatus().equals(DepreciationStatus.SUCCESS)) { depreciationDetail.setDepreciationRate(depreciationRate); depreciationDetail.setStatus(DepreciationStatus.SUCCESS); assetCurrentValues .add(AssetCurrentValue.builder().assetId(assetId).assetTranType(TransactionType.DEPRECIATION) .currentAmount(depreciationDetail.getValueAfterDepreciation()).build()); } depreciationDetailsMap.put(assetId, depreciationDetail); } }
AssetDepreciatorImpl implements AssetDepreciator { @Override public void depreciateAsset(final DepreciationRequest depreciationRequest, final List<CalculationAssetDetails> calculationAssetDetailList, final Map<Long, CalculationCurrentValue> calculationCurrentValues, final Map<Long, BigDecimal> depreciationSumMap, final List<AssetCurrentValue> assetCurrentValues, final Map<Long, DepreciationDetail> depreciationDetailsMap) { final BigDecimal depreciationSum = BigDecimal.ZERO; for (final CalculationAssetDetails calculationAssetDetail : calculationAssetDetailList) { log.info("inside the loop for calculation asset details"); final Long assetId = calculationAssetDetail.getAssetId(); final Double depreciationRate = getDepreciationRate(calculationAssetDetail); if (depreciationRate == null) { depreciationDetailsMap.put(assetId, DepreciationDetail.builder().assetId(assetId).status(DepreciationStatus.FAIL) .reasonForFailure(ReasonForFailure.DEPRECIATION_RATE_NOT_FOUND).build()); continue; } final CalculationCurrentValue calculationCurrentValue = calculationCurrentValues.get(assetId); final DepreciationDetail depreciationDetail = computeDepreciationDetail(calculationAssetDetail, calculationCurrentValue, depreciationRate, depreciationSum); depreciationDetail.setAssetId(assetId); if (depreciationDetail.getStatus().equals(DepreciationStatus.SUCCESS)) { depreciationDetail.setDepreciationRate(depreciationRate); depreciationDetail.setStatus(DepreciationStatus.SUCCESS); assetCurrentValues .add(AssetCurrentValue.builder().assetId(assetId).assetTranType(TransactionType.DEPRECIATION) .currentAmount(depreciationDetail.getValueAfterDepreciation()).build()); } depreciationDetailsMap.put(assetId, depreciationDetail); } } }
AssetDepreciatorImpl implements AssetDepreciator { @Override public void depreciateAsset(final DepreciationRequest depreciationRequest, final List<CalculationAssetDetails> calculationAssetDetailList, final Map<Long, CalculationCurrentValue> calculationCurrentValues, final Map<Long, BigDecimal> depreciationSumMap, final List<AssetCurrentValue> assetCurrentValues, final Map<Long, DepreciationDetail> depreciationDetailsMap) { final BigDecimal depreciationSum = BigDecimal.ZERO; for (final CalculationAssetDetails calculationAssetDetail : calculationAssetDetailList) { log.info("inside the loop for calculation asset details"); final Long assetId = calculationAssetDetail.getAssetId(); final Double depreciationRate = getDepreciationRate(calculationAssetDetail); if (depreciationRate == null) { depreciationDetailsMap.put(assetId, DepreciationDetail.builder().assetId(assetId).status(DepreciationStatus.FAIL) .reasonForFailure(ReasonForFailure.DEPRECIATION_RATE_NOT_FOUND).build()); continue; } final CalculationCurrentValue calculationCurrentValue = calculationCurrentValues.get(assetId); final DepreciationDetail depreciationDetail = computeDepreciationDetail(calculationAssetDetail, calculationCurrentValue, depreciationRate, depreciationSum); depreciationDetail.setAssetId(assetId); if (depreciationDetail.getStatus().equals(DepreciationStatus.SUCCESS)) { depreciationDetail.setDepreciationRate(depreciationRate); depreciationDetail.setStatus(DepreciationStatus.SUCCESS); assetCurrentValues .add(AssetCurrentValue.builder().assetId(assetId).assetTranType(TransactionType.DEPRECIATION) .currentAmount(depreciationDetail.getValueAfterDepreciation()).build()); } depreciationDetailsMap.put(assetId, depreciationDetail); } }  }
AssetDepreciatorImpl implements AssetDepreciator { @Override public void depreciateAsset(final DepreciationRequest depreciationRequest, final List<CalculationAssetDetails> calculationAssetDetailList, final Map<Long, CalculationCurrentValue> calculationCurrentValues, final Map<Long, BigDecimal> depreciationSumMap, final List<AssetCurrentValue> assetCurrentValues, final Map<Long, DepreciationDetail> depreciationDetailsMap) { final BigDecimal depreciationSum = BigDecimal.ZERO; for (final CalculationAssetDetails calculationAssetDetail : calculationAssetDetailList) { log.info("inside the loop for calculation asset details"); final Long assetId = calculationAssetDetail.getAssetId(); final Double depreciationRate = getDepreciationRate(calculationAssetDetail); if (depreciationRate == null) { depreciationDetailsMap.put(assetId, DepreciationDetail.builder().assetId(assetId).status(DepreciationStatus.FAIL) .reasonForFailure(ReasonForFailure.DEPRECIATION_RATE_NOT_FOUND).build()); continue; } final CalculationCurrentValue calculationCurrentValue = calculationCurrentValues.get(assetId); final DepreciationDetail depreciationDetail = computeDepreciationDetail(calculationAssetDetail, calculationCurrentValue, depreciationRate, depreciationSum); depreciationDetail.setAssetId(assetId); if (depreciationDetail.getStatus().equals(DepreciationStatus.SUCCESS)) { depreciationDetail.setDepreciationRate(depreciationRate); depreciationDetail.setStatus(DepreciationStatus.SUCCESS); assetCurrentValues .add(AssetCurrentValue.builder().assetId(assetId).assetTranType(TransactionType.DEPRECIATION) .currentAmount(depreciationDetail.getValueAfterDepreciation()).build()); } depreciationDetailsMap.put(assetId, depreciationDetail); } }  @Override void depreciateAsset(final DepreciationRequest depreciationRequest,
            final List<CalculationAssetDetails> calculationAssetDetailList,
            final Map<Long, CalculationCurrentValue> calculationCurrentValues,
            final Map<Long, BigDecimal> depreciationSumMap, final List<AssetCurrentValue> assetCurrentValues,
            final Map<Long, DepreciationDetail> depreciationDetailsMap); DepreciationDetail computeDepreciationDetail(final CalculationAssetDetails calculationAssetDetail,
            final CalculationCurrentValue calculationCurrentValue, final Double depreciationRate,
            final BigDecimal depreciationSum); Double getDepreciationRate(final CalculationAssetDetails calculationAssetDetail); }
AssetDepreciatorImpl implements AssetDepreciator { @Override public void depreciateAsset(final DepreciationRequest depreciationRequest, final List<CalculationAssetDetails> calculationAssetDetailList, final Map<Long, CalculationCurrentValue> calculationCurrentValues, final Map<Long, BigDecimal> depreciationSumMap, final List<AssetCurrentValue> assetCurrentValues, final Map<Long, DepreciationDetail> depreciationDetailsMap) { final BigDecimal depreciationSum = BigDecimal.ZERO; for (final CalculationAssetDetails calculationAssetDetail : calculationAssetDetailList) { log.info("inside the loop for calculation asset details"); final Long assetId = calculationAssetDetail.getAssetId(); final Double depreciationRate = getDepreciationRate(calculationAssetDetail); if (depreciationRate == null) { depreciationDetailsMap.put(assetId, DepreciationDetail.builder().assetId(assetId).status(DepreciationStatus.FAIL) .reasonForFailure(ReasonForFailure.DEPRECIATION_RATE_NOT_FOUND).build()); continue; } final CalculationCurrentValue calculationCurrentValue = calculationCurrentValues.get(assetId); final DepreciationDetail depreciationDetail = computeDepreciationDetail(calculationAssetDetail, calculationCurrentValue, depreciationRate, depreciationSum); depreciationDetail.setAssetId(assetId); if (depreciationDetail.getStatus().equals(DepreciationStatus.SUCCESS)) { depreciationDetail.setDepreciationRate(depreciationRate); depreciationDetail.setStatus(DepreciationStatus.SUCCESS); assetCurrentValues .add(AssetCurrentValue.builder().assetId(assetId).assetTranType(TransactionType.DEPRECIATION) .currentAmount(depreciationDetail.getValueAfterDepreciation()).build()); } depreciationDetailsMap.put(assetId, depreciationDetail); } }  @Override void depreciateAsset(final DepreciationRequest depreciationRequest,
            final List<CalculationAssetDetails> calculationAssetDetailList,
            final Map<Long, CalculationCurrentValue> calculationCurrentValues,
            final Map<Long, BigDecimal> depreciationSumMap, final List<AssetCurrentValue> assetCurrentValues,
            final Map<Long, DepreciationDetail> depreciationDetailsMap); DepreciationDetail computeDepreciationDetail(final CalculationAssetDetails calculationAssetDetail,
            final CalculationCurrentValue calculationCurrentValue, final Double depreciationRate,
            final BigDecimal depreciationSum); Double getDepreciationRate(final CalculationAssetDetails calculationAssetDetail);  }