@Test public void test_should_create_VoucherRequest_For_Disposal() throws JsonParseException, JsonMappingException, IOException { final DisposalRequest disposalRequest = getDisposalRequest(); disposalRequest.getRequestInfo(); final Disposal disposal = disposalRequest.getDisposal(); final Asset asset = get_Asset(); final List<VoucherAccountCodeDetails> accountCodeDetails = getLedgers(); final String tenantId = disposal.getTenantId(); final Map<String, String> voucherParams = getAssetFinancialParamsMap(); when(mapper.readValue(any(String.class), any(TypeReference.class))).thenReturn(voucherParams); when(assetConfigurationService.getAssetConfigValueByKeyAndTenantId(AssetConfigurationKeys.DISPOSALVOUCHERNAME, tenantId)).thenReturn("Asset Disposal"); when(assetConfigurationService .getAssetConfigValueByKeyAndTenantId(AssetConfigurationKeys.DISPOSALVOUCHERDESCRIPTION, tenantId)) .thenReturn("Asset Disposal Journal Voucher"); final VoucherRequest generatedVoucherRequest = voucherService.createDisposalVoucherRequest(disposal, asset.getId(), asset.getDepartment().getId(), accountCodeDetails,asset.getFunction(), getHttpHeaders()); final Fund fund = getFund(); final Voucher voucher = getVoucher(asset.getDepartment().getId(), fund); voucher.setName(assetConfigurationService .getAssetConfigValueByKeyAndTenantId(AssetConfigurationKeys.DISPOSALVOUCHERNAME, tenantId)); voucher.setDescription(assetConfigurationService .getAssetConfigValueByKeyAndTenantId(AssetConfigurationKeys.DISPOSALVOUCHERDESCRIPTION, tenantId)); voucher.setSource(null + "/asset-web/app/asset/create-asset-sale.html?id=" + asset.getId() + "&type=view"); final List<Voucher> vouchers = new ArrayList<>(); vouchers.add(voucher); final VoucherRequest expectedVoucherRequest = new VoucherRequest(); expectedVoucherRequest.setRequestInfo(new org.egov.asset.model.RequestInfo()); expectedVoucherRequest.setVouchers(vouchers); System.out.println(generatedVoucherRequest + "\n"); System.err.println(expectedVoucherRequest); assertEquals(expectedVoucherRequest.getVouchers().toString(), generatedVoucherRequest.getVouchers().toString()); }
public VoucherRequest createDisposalVoucherRequest(final Disposal disposal, final Long assetId, final Long departmentId, final List<VoucherAccountCodeDetails> accountCodeDetails,final String functionCode, final HttpHeaders header) { final VoucherRequest voucherRequest = new VoucherRequest(); final List<Voucher> vouchers = new ArrayList<>(); final String tenantId = disposal.getTenantId(); final Voucher voucher = generateVoucher(departmentId); voucher.setName(assetConfigurationService .getAssetConfigValueByKeyAndTenantId(AssetConfigurationKeys.DISPOSALVOUCHERNAME, tenantId)); voucher.setDescription(assetConfigurationService .getAssetConfigValueByKeyAndTenantId(AssetConfigurationKeys.DISPOSALVOUCHERDESCRIPTION, tenantId)); final String source = header.getOrigin() + "/asset-web/app/asset/create-asset-sale.html?id=" + assetId + "&type=view"; log.debug("Disposal source :: " + source); voucher.setSource(source); setFinancialParameters(voucher, accountCodeDetails, tenantId,functionCode); voucher.setLedgers(accountCodeDetails); log.debug("Disposal Voucher :: " + voucher); vouchers.add(voucher); generateVoucherRequest(voucherRequest, vouchers); return voucherRequest; }
VoucherService { public VoucherRequest createDisposalVoucherRequest(final Disposal disposal, final Long assetId, final Long departmentId, final List<VoucherAccountCodeDetails> accountCodeDetails,final String functionCode, final HttpHeaders header) { final VoucherRequest voucherRequest = new VoucherRequest(); final List<Voucher> vouchers = new ArrayList<>(); final String tenantId = disposal.getTenantId(); final Voucher voucher = generateVoucher(departmentId); voucher.setName(assetConfigurationService .getAssetConfigValueByKeyAndTenantId(AssetConfigurationKeys.DISPOSALVOUCHERNAME, tenantId)); voucher.setDescription(assetConfigurationService .getAssetConfigValueByKeyAndTenantId(AssetConfigurationKeys.DISPOSALVOUCHERDESCRIPTION, tenantId)); final String source = header.getOrigin() + "/asset-web/app/asset/create-asset-sale.html?id=" + assetId + "&type=view"; log.debug("Disposal source :: " + source); voucher.setSource(source); setFinancialParameters(voucher, accountCodeDetails, tenantId,functionCode); voucher.setLedgers(accountCodeDetails); log.debug("Disposal Voucher :: " + voucher); vouchers.add(voucher); generateVoucherRequest(voucherRequest, vouchers); return voucherRequest; } }
VoucherService { public VoucherRequest createDisposalVoucherRequest(final Disposal disposal, final Long assetId, final Long departmentId, final List<VoucherAccountCodeDetails> accountCodeDetails,final String functionCode, final HttpHeaders header) { final VoucherRequest voucherRequest = new VoucherRequest(); final List<Voucher> vouchers = new ArrayList<>(); final String tenantId = disposal.getTenantId(); final Voucher voucher = generateVoucher(departmentId); voucher.setName(assetConfigurationService .getAssetConfigValueByKeyAndTenantId(AssetConfigurationKeys.DISPOSALVOUCHERNAME, tenantId)); voucher.setDescription(assetConfigurationService .getAssetConfigValueByKeyAndTenantId(AssetConfigurationKeys.DISPOSALVOUCHERDESCRIPTION, tenantId)); final String source = header.getOrigin() + "/asset-web/app/asset/create-asset-sale.html?id=" + assetId + "&type=view"; log.debug("Disposal source :: " + source); voucher.setSource(source); setFinancialParameters(voucher, accountCodeDetails, tenantId,functionCode); voucher.setLedgers(accountCodeDetails); log.debug("Disposal Voucher :: " + voucher); vouchers.add(voucher); generateVoucherRequest(voucherRequest, vouchers); return voucherRequest; }  }
VoucherService { public VoucherRequest createDisposalVoucherRequest(final Disposal disposal, final Long assetId, final Long departmentId, final List<VoucherAccountCodeDetails> accountCodeDetails,final String functionCode, final HttpHeaders header) { final VoucherRequest voucherRequest = new VoucherRequest(); final List<Voucher> vouchers = new ArrayList<>(); final String tenantId = disposal.getTenantId(); final Voucher voucher = generateVoucher(departmentId); voucher.setName(assetConfigurationService .getAssetConfigValueByKeyAndTenantId(AssetConfigurationKeys.DISPOSALVOUCHERNAME, tenantId)); voucher.setDescription(assetConfigurationService .getAssetConfigValueByKeyAndTenantId(AssetConfigurationKeys.DISPOSALVOUCHERDESCRIPTION, tenantId)); final String source = header.getOrigin() + "/asset-web/app/asset/create-asset-sale.html?id=" + assetId + "&type=view"; log.debug("Disposal source :: " + source); voucher.setSource(source); setFinancialParameters(voucher, accountCodeDetails, tenantId,functionCode); voucher.setLedgers(accountCodeDetails); log.debug("Disposal Voucher :: " + voucher); vouchers.add(voucher); generateVoucherRequest(voucherRequest, vouchers); return voucherRequest; }  @SuppressWarnings({ "rawtypes", "unchecked" }) String createVoucher(final VoucherRequest voucherRequest, final String tenantId, final HttpHeaders headers); VoucherAccountCodeDetails getGlCodes(final RequestInfo requestInfo, final String tenantId,
            final Long accountId, final BigDecimal amount, final Boolean iscredit, final Boolean isDebit); List<ChartOfAccountContract> getChartOfAccounts(final RequestInfo requestInfo, final String tenantId,
            final Long accountId); List<ChartOfAccountDetailContract> getSubledgerDetails(final RequestInfo requestInfo, final String tenantId,
            final Long accountId); void validateSubLedgerDetails(final List<ChartOfAccountDetailContract> creditableCOA,
            final List<ChartOfAccountDetailContract> debitableCOA); VoucherRequest createRevaluationVoucherRequest(final Revaluation revaluation,
            final List<VoucherAccountCodeDetails> accountCodeDetails, final Long assetId, final Long departmentId,
            final HttpHeaders header); VoucherRequest createDisposalVoucherRequest(final Disposal disposal, final Long assetId,
            final Long departmentId, final List<VoucherAccountCodeDetails> accountCodeDetails,final String functionCode,
            final HttpHeaders header); VoucherRequest createDepreciationVoucherRequest(
            final List<DepreciationInputs> depreciationInputsList, final Long departmentId,final String functionCode,final Long assetId,
           final Long depreciationId,  final List<VoucherAccountCodeDetails> accountCodeDetails, final String tenantId, final HttpHeaders header); void setFinancialParameters(final Voucher voucher, final List<VoucherAccountCodeDetails> accountCodeDetails,
            final String tenantId,final String functionCode); }
VoucherService { public VoucherRequest createDisposalVoucherRequest(final Disposal disposal, final Long assetId, final Long departmentId, final List<VoucherAccountCodeDetails> accountCodeDetails,final String functionCode, final HttpHeaders header) { final VoucherRequest voucherRequest = new VoucherRequest(); final List<Voucher> vouchers = new ArrayList<>(); final String tenantId = disposal.getTenantId(); final Voucher voucher = generateVoucher(departmentId); voucher.setName(assetConfigurationService .getAssetConfigValueByKeyAndTenantId(AssetConfigurationKeys.DISPOSALVOUCHERNAME, tenantId)); voucher.setDescription(assetConfigurationService .getAssetConfigValueByKeyAndTenantId(AssetConfigurationKeys.DISPOSALVOUCHERDESCRIPTION, tenantId)); final String source = header.getOrigin() + "/asset-web/app/asset/create-asset-sale.html?id=" + assetId + "&type=view"; log.debug("Disposal source :: " + source); voucher.setSource(source); setFinancialParameters(voucher, accountCodeDetails, tenantId,functionCode); voucher.setLedgers(accountCodeDetails); log.debug("Disposal Voucher :: " + voucher); vouchers.add(voucher); generateVoucherRequest(voucherRequest, vouchers); return voucherRequest; }  @SuppressWarnings({ "rawtypes", "unchecked" }) String createVoucher(final VoucherRequest voucherRequest, final String tenantId, final HttpHeaders headers); VoucherAccountCodeDetails getGlCodes(final RequestInfo requestInfo, final String tenantId,
            final Long accountId, final BigDecimal amount, final Boolean iscredit, final Boolean isDebit); List<ChartOfAccountContract> getChartOfAccounts(final RequestInfo requestInfo, final String tenantId,
            final Long accountId); List<ChartOfAccountDetailContract> getSubledgerDetails(final RequestInfo requestInfo, final String tenantId,
            final Long accountId); void validateSubLedgerDetails(final List<ChartOfAccountDetailContract> creditableCOA,
            final List<ChartOfAccountDetailContract> debitableCOA); VoucherRequest createRevaluationVoucherRequest(final Revaluation revaluation,
            final List<VoucherAccountCodeDetails> accountCodeDetails, final Long assetId, final Long departmentId,
            final HttpHeaders header); VoucherRequest createDisposalVoucherRequest(final Disposal disposal, final Long assetId,
            final Long departmentId, final List<VoucherAccountCodeDetails> accountCodeDetails,final String functionCode,
            final HttpHeaders header); VoucherRequest createDepreciationVoucherRequest(
            final List<DepreciationInputs> depreciationInputsList, final Long departmentId,final String functionCode,final Long assetId,
           final Long depreciationId,  final List<VoucherAccountCodeDetails> accountCodeDetails, final String tenantId, final HttpHeaders header); void setFinancialParameters(final Voucher voucher, final List<VoucherAccountCodeDetails> accountCodeDetails,
            final String tenantId,final String functionCode);  }