@SuppressWarnings("unchecked") @Test public void createVoucherForDisposalTest() throws Exception { final DisposalRequest disposalRequest = getDisposalRequest(); final HttpHeaders headers = getHttpHeaders(); final Asset asset = getAsset(); final List<Asset> assets = new ArrayList<>(); assets.add(asset); getFunctionResponse(); getFundResponse(); final VoucherRequest voucherRequest = getVoucherRequest(); when(assetRepository.findForCriteria(any(AssetCriteria.class))).thenReturn(assets); when(voucherService.createDisposalVoucherRequest(any(Disposal.class), any(Long.class), any(Long.class), any(List.class), any(String.class), any(HttpHeaders.class))).thenReturn(voucherRequest); disposalService.createVoucherForDisposal(disposalRequest, headers); }
public String createVoucherForDisposal(final DisposalRequest disposalRequest, final HttpHeaders headers) { final Disposal disposal = disposalRequest.getDisposal(); final RequestInfo requestInfo = disposalRequest.getRequestInfo(); final List<Long> assetIds = new ArrayList<>(); final String tenantId = disposal.getTenantId(); assetIds.add(disposal.getAssetId()); final Asset asset = assetRepository .findForCriteria(AssetCriteria.builder().tenantId(tenantId).id(assetIds).build()).get(0); final AssetCategory assetCategory = asset.getAssetCategory(); final List<ChartOfAccountDetailContract> subledgerDetailsForAssetAccount = voucherService .getSubledgerDetails(requestInfo, tenantId, assetCategory.getAssetAccount()); final List<ChartOfAccountDetailContract> subledgerDetailsForAssetSaleAccount = voucherService .getSubledgerDetails(requestInfo, tenantId, disposal.getAssetSaleAccount()); voucherService.validateSubLedgerDetails(subledgerDetailsForAssetAccount, subledgerDetailsForAssetSaleAccount); final List<VoucherAccountCodeDetails> accountCodeDetails = getAccountDetails(disposal, assetCategory, requestInfo); log.debug("Voucher Create Account Code Details :: " + accountCodeDetails); final VoucherRequest voucherRequest = voucherService.createDisposalVoucherRequest(disposal, asset.getId(), asset.getDepartment().getId(), accountCodeDetails, asset.getFunction(), headers); log.debug("Voucher Request for Disposal :: " + voucherRequest); return voucherService.createVoucher(voucherRequest, tenantId, headers); }
DisposalService { public String createVoucherForDisposal(final DisposalRequest disposalRequest, final HttpHeaders headers) { final Disposal disposal = disposalRequest.getDisposal(); final RequestInfo requestInfo = disposalRequest.getRequestInfo(); final List<Long> assetIds = new ArrayList<>(); final String tenantId = disposal.getTenantId(); assetIds.add(disposal.getAssetId()); final Asset asset = assetRepository .findForCriteria(AssetCriteria.builder().tenantId(tenantId).id(assetIds).build()).get(0); final AssetCategory assetCategory = asset.getAssetCategory(); final List<ChartOfAccountDetailContract> subledgerDetailsForAssetAccount = voucherService .getSubledgerDetails(requestInfo, tenantId, assetCategory.getAssetAccount()); final List<ChartOfAccountDetailContract> subledgerDetailsForAssetSaleAccount = voucherService .getSubledgerDetails(requestInfo, tenantId, disposal.getAssetSaleAccount()); voucherService.validateSubLedgerDetails(subledgerDetailsForAssetAccount, subledgerDetailsForAssetSaleAccount); final List<VoucherAccountCodeDetails> accountCodeDetails = getAccountDetails(disposal, assetCategory, requestInfo); log.debug("Voucher Create Account Code Details :: " + accountCodeDetails); final VoucherRequest voucherRequest = voucherService.createDisposalVoucherRequest(disposal, asset.getId(), asset.getDepartment().getId(), accountCodeDetails, asset.getFunction(), headers); log.debug("Voucher Request for Disposal :: " + voucherRequest); return voucherService.createVoucher(voucherRequest, tenantId, headers); } }
DisposalService { public String createVoucherForDisposal(final DisposalRequest disposalRequest, final HttpHeaders headers) { final Disposal disposal = disposalRequest.getDisposal(); final RequestInfo requestInfo = disposalRequest.getRequestInfo(); final List<Long> assetIds = new ArrayList<>(); final String tenantId = disposal.getTenantId(); assetIds.add(disposal.getAssetId()); final Asset asset = assetRepository .findForCriteria(AssetCriteria.builder().tenantId(tenantId).id(assetIds).build()).get(0); final AssetCategory assetCategory = asset.getAssetCategory(); final List<ChartOfAccountDetailContract> subledgerDetailsForAssetAccount = voucherService .getSubledgerDetails(requestInfo, tenantId, assetCategory.getAssetAccount()); final List<ChartOfAccountDetailContract> subledgerDetailsForAssetSaleAccount = voucherService .getSubledgerDetails(requestInfo, tenantId, disposal.getAssetSaleAccount()); voucherService.validateSubLedgerDetails(subledgerDetailsForAssetAccount, subledgerDetailsForAssetSaleAccount); final List<VoucherAccountCodeDetails> accountCodeDetails = getAccountDetails(disposal, assetCategory, requestInfo); log.debug("Voucher Create Account Code Details :: " + accountCodeDetails); final VoucherRequest voucherRequest = voucherService.createDisposalVoucherRequest(disposal, asset.getId(), asset.getDepartment().getId(), accountCodeDetails, asset.getFunction(), headers); log.debug("Voucher Request for Disposal :: " + voucherRequest); return voucherService.createVoucher(voucherRequest, tenantId, headers); }  }
DisposalService { public String createVoucherForDisposal(final DisposalRequest disposalRequest, final HttpHeaders headers) { final Disposal disposal = disposalRequest.getDisposal(); final RequestInfo requestInfo = disposalRequest.getRequestInfo(); final List<Long> assetIds = new ArrayList<>(); final String tenantId = disposal.getTenantId(); assetIds.add(disposal.getAssetId()); final Asset asset = assetRepository .findForCriteria(AssetCriteria.builder().tenantId(tenantId).id(assetIds).build()).get(0); final AssetCategory assetCategory = asset.getAssetCategory(); final List<ChartOfAccountDetailContract> subledgerDetailsForAssetAccount = voucherService .getSubledgerDetails(requestInfo, tenantId, assetCategory.getAssetAccount()); final List<ChartOfAccountDetailContract> subledgerDetailsForAssetSaleAccount = voucherService .getSubledgerDetails(requestInfo, tenantId, disposal.getAssetSaleAccount()); voucherService.validateSubLedgerDetails(subledgerDetailsForAssetAccount, subledgerDetailsForAssetSaleAccount); final List<VoucherAccountCodeDetails> accountCodeDetails = getAccountDetails(disposal, assetCategory, requestInfo); log.debug("Voucher Create Account Code Details :: " + accountCodeDetails); final VoucherRequest voucherRequest = voucherService.createDisposalVoucherRequest(disposal, asset.getId(), asset.getDepartment().getId(), accountCodeDetails, asset.getFunction(), headers); log.debug("Voucher Request for Disposal :: " + voucherRequest); return voucherService.createVoucher(voucherRequest, tenantId, headers); }  List<Disposal> search(final DisposalCriteria disposalCriteria, final RequestInfo requestInfo); void create(final DisposalRequest disposalRequest); void setStatusOfAssetToDisposed(final DisposalRequest disposalRequest); Disposal saveDisposal(final DisposalRequest disposalRequest, final HttpHeaders headers); String createVoucherForDisposal(final DisposalRequest disposalRequest, final HttpHeaders headers); }
DisposalService { public String createVoucherForDisposal(final DisposalRequest disposalRequest, final HttpHeaders headers) { final Disposal disposal = disposalRequest.getDisposal(); final RequestInfo requestInfo = disposalRequest.getRequestInfo(); final List<Long> assetIds = new ArrayList<>(); final String tenantId = disposal.getTenantId(); assetIds.add(disposal.getAssetId()); final Asset asset = assetRepository .findForCriteria(AssetCriteria.builder().tenantId(tenantId).id(assetIds).build()).get(0); final AssetCategory assetCategory = asset.getAssetCategory(); final List<ChartOfAccountDetailContract> subledgerDetailsForAssetAccount = voucherService .getSubledgerDetails(requestInfo, tenantId, assetCategory.getAssetAccount()); final List<ChartOfAccountDetailContract> subledgerDetailsForAssetSaleAccount = voucherService .getSubledgerDetails(requestInfo, tenantId, disposal.getAssetSaleAccount()); voucherService.validateSubLedgerDetails(subledgerDetailsForAssetAccount, subledgerDetailsForAssetSaleAccount); final List<VoucherAccountCodeDetails> accountCodeDetails = getAccountDetails(disposal, assetCategory, requestInfo); log.debug("Voucher Create Account Code Details :: " + accountCodeDetails); final VoucherRequest voucherRequest = voucherService.createDisposalVoucherRequest(disposal, asset.getId(), asset.getDepartment().getId(), accountCodeDetails, asset.getFunction(), headers); log.debug("Voucher Request for Disposal :: " + voucherRequest); return voucherService.createVoucher(voucherRequest, tenantId, headers); }  List<Disposal> search(final DisposalCriteria disposalCriteria, final RequestInfo requestInfo); void create(final DisposalRequest disposalRequest); void setStatusOfAssetToDisposed(final DisposalRequest disposalRequest); Disposal saveDisposal(final DisposalRequest disposalRequest, final HttpHeaders headers); String createVoucherForDisposal(final DisposalRequest disposalRequest, final HttpHeaders headers);  }