@SuppressWarnings("unchecked") @Test public void createVoucherForRevaluationTest() throws Exception { final RevaluationRequest revaluationRequest = getRevaluationRequest(); final HttpHeaders headers = getHttpHeaders(); final Asset asset = getAsset(); final VoucherRequest voucherRequest = getVoucherRequest(); when(assetService.getAsset(any(String.class), any(Long.class), any(RequestInfo.class))).thenReturn(asset); when(voucherService.createRevaluationVoucherRequest(any(Revaluation.class), any(List.class), any(Long.class), any(Long.class), any(HttpHeaders.class))).thenReturn(voucherRequest); revaluationService.createVoucherForRevaluation(revaluationRequest, headers); }
public String createVoucherForRevaluation(final RevaluationRequest revaluationRequest, final HttpHeaders headers) { final Revaluation revaluation = revaluationRequest.getRevaluation(); final RequestInfo requestInfo = revaluationRequest.getRequestInfo(); final String tenantId = revaluation.getTenantId(); final Asset asset = assetService.getAsset(tenantId, revaluation.getAssetId(), requestInfo); log.debug("asset for revaluation :: " + asset); final AssetCategory assetCategory = asset.getAssetCategory(); if (revaluation.getTypeOfChange().equals(TypeOfChangeEnum.INCREASED)) { log.info("subledger details check for Type of change INCREASED"); final List<ChartOfAccountDetailContract> subledgerDetailsForAssetAccount = voucherService .getSubledgerDetails(requestInfo, tenantId, assetCategory.getAssetAccount()); final List<ChartOfAccountDetailContract> subledgerDetailsForRevaluationReserverAccount = voucherService .getSubledgerDetails(requestInfo, tenantId, assetCategory.getRevaluationReserveAccount()); voucherService.validateSubLedgerDetails(subledgerDetailsForAssetAccount, subledgerDetailsForRevaluationReserverAccount); } else if (revaluation.getTypeOfChange().equals(TypeOfChangeEnum.DECREASED)) { log.info("subledger details check for Type of change DECREASED"); final List<ChartOfAccountDetailContract> subledgerDetailsForAssetAccount = voucherService .getSubledgerDetails(requestInfo, tenantId, assetCategory.getAssetAccount()); final List<ChartOfAccountDetailContract> subledgerDetailsForFixedAssetWrittenOffAccount = voucherService .getSubledgerDetails(requestInfo, tenantId, revaluation.getFixedAssetsWrittenOffAccount()); voucherService.validateSubLedgerDetails(subledgerDetailsForAssetAccount, subledgerDetailsForFixedAssetWrittenOffAccount); } final List<VoucherAccountCodeDetails> accountCodeDetails = getAccountDetails(revaluation, assetCategory, requestInfo); log.debug("Voucher Create Account Code Details :: " + accountCodeDetails); final VoucherRequest voucherRequest = voucherService.createRevaluationVoucherRequest(revaluation, accountCodeDetails, asset.getId(), asset.getDepartment().getId(), headers); log.debug("Voucher Request for Revaluation :: " + voucherRequest); return voucherService.createVoucher(voucherRequest, tenantId, headers); }
RevaluationService { public String createVoucherForRevaluation(final RevaluationRequest revaluationRequest, final HttpHeaders headers) { final Revaluation revaluation = revaluationRequest.getRevaluation(); final RequestInfo requestInfo = revaluationRequest.getRequestInfo(); final String tenantId = revaluation.getTenantId(); final Asset asset = assetService.getAsset(tenantId, revaluation.getAssetId(), requestInfo); log.debug("asset for revaluation :: " + asset); final AssetCategory assetCategory = asset.getAssetCategory(); if (revaluation.getTypeOfChange().equals(TypeOfChangeEnum.INCREASED)) { log.info("subledger details check for Type of change INCREASED"); final List<ChartOfAccountDetailContract> subledgerDetailsForAssetAccount = voucherService .getSubledgerDetails(requestInfo, tenantId, assetCategory.getAssetAccount()); final List<ChartOfAccountDetailContract> subledgerDetailsForRevaluationReserverAccount = voucherService .getSubledgerDetails(requestInfo, tenantId, assetCategory.getRevaluationReserveAccount()); voucherService.validateSubLedgerDetails(subledgerDetailsForAssetAccount, subledgerDetailsForRevaluationReserverAccount); } else if (revaluation.getTypeOfChange().equals(TypeOfChangeEnum.DECREASED)) { log.info("subledger details check for Type of change DECREASED"); final List<ChartOfAccountDetailContract> subledgerDetailsForAssetAccount = voucherService .getSubledgerDetails(requestInfo, tenantId, assetCategory.getAssetAccount()); final List<ChartOfAccountDetailContract> subledgerDetailsForFixedAssetWrittenOffAccount = voucherService .getSubledgerDetails(requestInfo, tenantId, revaluation.getFixedAssetsWrittenOffAccount()); voucherService.validateSubLedgerDetails(subledgerDetailsForAssetAccount, subledgerDetailsForFixedAssetWrittenOffAccount); } final List<VoucherAccountCodeDetails> accountCodeDetails = getAccountDetails(revaluation, assetCategory, requestInfo); log.debug("Voucher Create Account Code Details :: " + accountCodeDetails); final VoucherRequest voucherRequest = voucherService.createRevaluationVoucherRequest(revaluation, accountCodeDetails, asset.getId(), asset.getDepartment().getId(), headers); log.debug("Voucher Request for Revaluation :: " + voucherRequest); return voucherService.createVoucher(voucherRequest, tenantId, headers); } }
RevaluationService { public String createVoucherForRevaluation(final RevaluationRequest revaluationRequest, final HttpHeaders headers) { final Revaluation revaluation = revaluationRequest.getRevaluation(); final RequestInfo requestInfo = revaluationRequest.getRequestInfo(); final String tenantId = revaluation.getTenantId(); final Asset asset = assetService.getAsset(tenantId, revaluation.getAssetId(), requestInfo); log.debug("asset for revaluation :: " + asset); final AssetCategory assetCategory = asset.getAssetCategory(); if (revaluation.getTypeOfChange().equals(TypeOfChangeEnum.INCREASED)) { log.info("subledger details check for Type of change INCREASED"); final List<ChartOfAccountDetailContract> subledgerDetailsForAssetAccount = voucherService .getSubledgerDetails(requestInfo, tenantId, assetCategory.getAssetAccount()); final List<ChartOfAccountDetailContract> subledgerDetailsForRevaluationReserverAccount = voucherService .getSubledgerDetails(requestInfo, tenantId, assetCategory.getRevaluationReserveAccount()); voucherService.validateSubLedgerDetails(subledgerDetailsForAssetAccount, subledgerDetailsForRevaluationReserverAccount); } else if (revaluation.getTypeOfChange().equals(TypeOfChangeEnum.DECREASED)) { log.info("subledger details check for Type of change DECREASED"); final List<ChartOfAccountDetailContract> subledgerDetailsForAssetAccount = voucherService .getSubledgerDetails(requestInfo, tenantId, assetCategory.getAssetAccount()); final List<ChartOfAccountDetailContract> subledgerDetailsForFixedAssetWrittenOffAccount = voucherService .getSubledgerDetails(requestInfo, tenantId, revaluation.getFixedAssetsWrittenOffAccount()); voucherService.validateSubLedgerDetails(subledgerDetailsForAssetAccount, subledgerDetailsForFixedAssetWrittenOffAccount); } final List<VoucherAccountCodeDetails> accountCodeDetails = getAccountDetails(revaluation, assetCategory, requestInfo); log.debug("Voucher Create Account Code Details :: " + accountCodeDetails); final VoucherRequest voucherRequest = voucherService.createRevaluationVoucherRequest(revaluation, accountCodeDetails, asset.getId(), asset.getDepartment().getId(), headers); log.debug("Voucher Request for Revaluation :: " + voucherRequest); return voucherService.createVoucher(voucherRequest, tenantId, headers); }  }
RevaluationService { public String createVoucherForRevaluation(final RevaluationRequest revaluationRequest, final HttpHeaders headers) { final Revaluation revaluation = revaluationRequest.getRevaluation(); final RequestInfo requestInfo = revaluationRequest.getRequestInfo(); final String tenantId = revaluation.getTenantId(); final Asset asset = assetService.getAsset(tenantId, revaluation.getAssetId(), requestInfo); log.debug("asset for revaluation :: " + asset); final AssetCategory assetCategory = asset.getAssetCategory(); if (revaluation.getTypeOfChange().equals(TypeOfChangeEnum.INCREASED)) { log.info("subledger details check for Type of change INCREASED"); final List<ChartOfAccountDetailContract> subledgerDetailsForAssetAccount = voucherService .getSubledgerDetails(requestInfo, tenantId, assetCategory.getAssetAccount()); final List<ChartOfAccountDetailContract> subledgerDetailsForRevaluationReserverAccount = voucherService .getSubledgerDetails(requestInfo, tenantId, assetCategory.getRevaluationReserveAccount()); voucherService.validateSubLedgerDetails(subledgerDetailsForAssetAccount, subledgerDetailsForRevaluationReserverAccount); } else if (revaluation.getTypeOfChange().equals(TypeOfChangeEnum.DECREASED)) { log.info("subledger details check for Type of change DECREASED"); final List<ChartOfAccountDetailContract> subledgerDetailsForAssetAccount = voucherService .getSubledgerDetails(requestInfo, tenantId, assetCategory.getAssetAccount()); final List<ChartOfAccountDetailContract> subledgerDetailsForFixedAssetWrittenOffAccount = voucherService .getSubledgerDetails(requestInfo, tenantId, revaluation.getFixedAssetsWrittenOffAccount()); voucherService.validateSubLedgerDetails(subledgerDetailsForAssetAccount, subledgerDetailsForFixedAssetWrittenOffAccount); } final List<VoucherAccountCodeDetails> accountCodeDetails = getAccountDetails(revaluation, assetCategory, requestInfo); log.debug("Voucher Create Account Code Details :: " + accountCodeDetails); final VoucherRequest voucherRequest = voucherService.createRevaluationVoucherRequest(revaluation, accountCodeDetails, asset.getId(), asset.getDepartment().getId(), headers); log.debug("Voucher Request for Revaluation :: " + voucherRequest); return voucherService.createVoucher(voucherRequest, tenantId, headers); }  Revaluation saveRevaluation(final RevaluationRequest revaluationRequest, final HttpHeaders headers); void create(final RevaluationRequest revaluationRequest); void saveRevaluationAmountToCurrentAmount(final RevaluationRequest revaluationRequest); List<Revaluation> search(final RevaluationCriteria revaluationCriteria, final RequestInfo requestInfo); List<Revaluation> getRevaluation(final String tenantId, final Long assetId, final RequestInfo requestInfo); String createVoucherForRevaluation(final RevaluationRequest revaluationRequest, final HttpHeaders headers); List<VoucherAccountCodeDetails> getAccountDetails(final Revaluation revaluation,
            final AssetCategory assetCategory, final RequestInfo requestInfo); }
RevaluationService { public String createVoucherForRevaluation(final RevaluationRequest revaluationRequest, final HttpHeaders headers) { final Revaluation revaluation = revaluationRequest.getRevaluation(); final RequestInfo requestInfo = revaluationRequest.getRequestInfo(); final String tenantId = revaluation.getTenantId(); final Asset asset = assetService.getAsset(tenantId, revaluation.getAssetId(), requestInfo); log.debug("asset for revaluation :: " + asset); final AssetCategory assetCategory = asset.getAssetCategory(); if (revaluation.getTypeOfChange().equals(TypeOfChangeEnum.INCREASED)) { log.info("subledger details check for Type of change INCREASED"); final List<ChartOfAccountDetailContract> subledgerDetailsForAssetAccount = voucherService .getSubledgerDetails(requestInfo, tenantId, assetCategory.getAssetAccount()); final List<ChartOfAccountDetailContract> subledgerDetailsForRevaluationReserverAccount = voucherService .getSubledgerDetails(requestInfo, tenantId, assetCategory.getRevaluationReserveAccount()); voucherService.validateSubLedgerDetails(subledgerDetailsForAssetAccount, subledgerDetailsForRevaluationReserverAccount); } else if (revaluation.getTypeOfChange().equals(TypeOfChangeEnum.DECREASED)) { log.info("subledger details check for Type of change DECREASED"); final List<ChartOfAccountDetailContract> subledgerDetailsForAssetAccount = voucherService .getSubledgerDetails(requestInfo, tenantId, assetCategory.getAssetAccount()); final List<ChartOfAccountDetailContract> subledgerDetailsForFixedAssetWrittenOffAccount = voucherService .getSubledgerDetails(requestInfo, tenantId, revaluation.getFixedAssetsWrittenOffAccount()); voucherService.validateSubLedgerDetails(subledgerDetailsForAssetAccount, subledgerDetailsForFixedAssetWrittenOffAccount); } final List<VoucherAccountCodeDetails> accountCodeDetails = getAccountDetails(revaluation, assetCategory, requestInfo); log.debug("Voucher Create Account Code Details :: " + accountCodeDetails); final VoucherRequest voucherRequest = voucherService.createRevaluationVoucherRequest(revaluation, accountCodeDetails, asset.getId(), asset.getDepartment().getId(), headers); log.debug("Voucher Request for Revaluation :: " + voucherRequest); return voucherService.createVoucher(voucherRequest, tenantId, headers); }  Revaluation saveRevaluation(final RevaluationRequest revaluationRequest, final HttpHeaders headers); void create(final RevaluationRequest revaluationRequest); void saveRevaluationAmountToCurrentAmount(final RevaluationRequest revaluationRequest); List<Revaluation> search(final RevaluationCriteria revaluationCriteria, final RequestInfo requestInfo); List<Revaluation> getRevaluation(final String tenantId, final Long assetId, final RequestInfo requestInfo); String createVoucherForRevaluation(final RevaluationRequest revaluationRequest, final HttpHeaders headers); List<VoucherAccountCodeDetails> getAccountDetails(final Revaluation revaluation,
            final AssetCategory assetCategory, final RequestInfo requestInfo);  }