@Test public void testGetTaxIdBy() throws Exception { final TaxService taxService = ctx().getBean("taxService", TaxService.class); final TaxConfigService taxConfigService = ctx().getBean("taxConfigService", TaxConfigService.class); final List<Tax> startTaxes = taxService.getTaxesByShopCode("SHOIP1", "EUR"); assertFalse(startTaxes.isEmpty()); assertEquals(7, startTaxes.size()); final Long shopDefaultEURTax = taxConfigService.getTaxIdBy("SHOIP1", "EUR", null, null, null); assertEquals(Long.valueOf(1010L), shopDefaultEURTax); final Long shopCountryGBTax = taxConfigService.getTaxIdBy("SHOIP1", "EUR", "GB", null, null); assertEquals(Long.valueOf(1010L), shopCountryGBTax); final Long shopSateGBCAMTax = taxConfigService.getTaxIdBy("SHOIP1", "EUR", "GB", "GB-CAM", null); assertEquals(Long.valueOf(1010L), shopSateGBCAMTax); final Long shopProductGBCAMTax = taxConfigService.getTaxIdBy("SHOIP1", "EUR", "GB", "GB-CAM", "CC_TEST1"); assertEquals(Long.valueOf(1015L), shopProductGBCAMTax); final Long shopCountryUATax = taxConfigService.getTaxIdBy("SHOIP1", "EUR", "UA", null, null); assertEquals(Long.valueOf(1011L), shopCountryUATax); final Long shopProductUATax = taxConfigService.getTaxIdBy("SHOIP1", "EUR", "UA", null, "CC_TEST2"); assertEquals(Long.valueOf(1011L), shopProductUATax); final Long shopStateUSUSTax = taxConfigService.getTaxIdBy("SHOIP1", "EUR", "US", "US-US", null); assertEquals(Long.valueOf(1012L), shopStateUSUSTax); final Long shopStateUSUSTax2 = taxConfigService.getTaxIdBy("SHOIP1", "EUR", "US", "US-US", "CC_TEST2"); assertEquals(Long.valueOf(1012L), shopStateUSUSTax2); final Long shopCountryUAProductTax = taxConfigService.getTaxIdBy("SHOIP1", "EUR", "UA", null, "CC_TEST1"); assertEquals(Long.valueOf(1013L), shopCountryUAProductTax); final Long shopProductUSUSTax = taxConfigService.getTaxIdBy("SHOIP1", "EUR", "US", "US-US", "CC_TEST1"); assertEquals(Long.valueOf(1014L), shopProductUSUSTax); final Long shopProductTax = taxConfigService.getTaxIdBy("SHOIP1", "EUR", null, null, "CC_TEST1"); assertEquals(Long.valueOf(1015L), shopProductTax); }
@Override public Long getTaxIdBy(final String shopCode, final String currency, final String countryCode, final String stateCode, final String productCode) { final List<Tax> shopTaxes = taxService.getTaxesByShopCode(shopCode, currency); if (shopTaxes.isEmpty()) { return null; } final List<TaxConfig> taxConfigs = getGenericDao().findByNamedQuery("TAXCONFIG.BY.COUNTRYCODE.STATECODE.PRODUCTCODE.IN.TAXES", shopTaxes, countryCode, stateCode, productCode); if (taxConfigs.isEmpty()) { return null; } taxConfigs.sort(PRIORITY); return taxConfigs.get(0).getTax().getTaxId(); }
TaxConfigServiceImpl extends BaseGenericServiceImpl<TaxConfig> implements TaxConfigService { @Override public Long getTaxIdBy(final String shopCode, final String currency, final String countryCode, final String stateCode, final String productCode) { final List<Tax> shopTaxes = taxService.getTaxesByShopCode(shopCode, currency); if (shopTaxes.isEmpty()) { return null; } final List<TaxConfig> taxConfigs = getGenericDao().findByNamedQuery("TAXCONFIG.BY.COUNTRYCODE.STATECODE.PRODUCTCODE.IN.TAXES", shopTaxes, countryCode, stateCode, productCode); if (taxConfigs.isEmpty()) { return null; } taxConfigs.sort(PRIORITY); return taxConfigs.get(0).getTax().getTaxId(); } }
TaxConfigServiceImpl extends BaseGenericServiceImpl<TaxConfig> implements TaxConfigService { @Override public Long getTaxIdBy(final String shopCode, final String currency, final String countryCode, final String stateCode, final String productCode) { final List<Tax> shopTaxes = taxService.getTaxesByShopCode(shopCode, currency); if (shopTaxes.isEmpty()) { return null; } final List<TaxConfig> taxConfigs = getGenericDao().findByNamedQuery("TAXCONFIG.BY.COUNTRYCODE.STATECODE.PRODUCTCODE.IN.TAXES", shopTaxes, countryCode, stateCode, productCode); if (taxConfigs.isEmpty()) { return null; } taxConfigs.sort(PRIORITY); return taxConfigs.get(0).getTax().getTaxId(); } TaxConfigServiceImpl(final GenericDAO<TaxConfig, Long> genericDao,
                                final TaxService taxService); }
TaxConfigServiceImpl extends BaseGenericServiceImpl<TaxConfig> implements TaxConfigService { @Override public Long getTaxIdBy(final String shopCode, final String currency, final String countryCode, final String stateCode, final String productCode) { final List<Tax> shopTaxes = taxService.getTaxesByShopCode(shopCode, currency); if (shopTaxes.isEmpty()) { return null; } final List<TaxConfig> taxConfigs = getGenericDao().findByNamedQuery("TAXCONFIG.BY.COUNTRYCODE.STATECODE.PRODUCTCODE.IN.TAXES", shopTaxes, countryCode, stateCode, productCode); if (taxConfigs.isEmpty()) { return null; } taxConfigs.sort(PRIORITY); return taxConfigs.get(0).getTax().getTaxId(); } TaxConfigServiceImpl(final GenericDAO<TaxConfig, Long> genericDao,
                                final TaxService taxService); @Override Long getTaxIdBy(final String shopCode, final String currency, final String countryCode, final String stateCode, final String productCode); @Override List<TaxConfig> findTaxConfigs(final int start, final int offset, final String sort, final boolean sortDescending, final Map<String, List> filter); @Override int findTaxConfigCount(final Map<String, List> filter); @Override TaxConfig create(final TaxConfig instance); @Override TaxConfig update(final TaxConfig instance); @Override void delete(final TaxConfig instance); }
TaxConfigServiceImpl extends BaseGenericServiceImpl<TaxConfig> implements TaxConfigService { @Override public Long getTaxIdBy(final String shopCode, final String currency, final String countryCode, final String stateCode, final String productCode) { final List<Tax> shopTaxes = taxService.getTaxesByShopCode(shopCode, currency); if (shopTaxes.isEmpty()) { return null; } final List<TaxConfig> taxConfigs = getGenericDao().findByNamedQuery("TAXCONFIG.BY.COUNTRYCODE.STATECODE.PRODUCTCODE.IN.TAXES", shopTaxes, countryCode, stateCode, productCode); if (taxConfigs.isEmpty()) { return null; } taxConfigs.sort(PRIORITY); return taxConfigs.get(0).getTax().getTaxId(); } TaxConfigServiceImpl(final GenericDAO<TaxConfig, Long> genericDao,
                                final TaxService taxService); @Override Long getTaxIdBy(final String shopCode, final String currency, final String countryCode, final String stateCode, final String productCode); @Override List<TaxConfig> findTaxConfigs(final int start, final int offset, final String sort, final boolean sortDescending, final Map<String, List> filter); @Override int findTaxConfigCount(final Map<String, List> filter); @Override TaxConfig create(final TaxConfig instance); @Override TaxConfig update(final TaxConfig instance); @Override void delete(final TaxConfig instance);  }