Search in sources :

Example 1 with ReadableTaxRate

use of com.salesmanager.shop.model.tax.ReadableTaxRate in project shopizer by shopizer-ecommerce.

the class TaxFacadeImpl method taxRates.

@Override
public ReadableEntityList<ReadableTaxRate> taxRates(MerchantStore store, Language language) {
    Validate.notNull(store, "MerchantStore cannot be null");
    Validate.notNull(store.getCode(), "MerchantStore code cannot be null");
    try {
        List<TaxRate> rates = taxRateService.listByStore(store, language);
        List<ReadableTaxRate> readableRates = rates.stream().map(r -> readableTaxRateMapper.convert(r, store, language)).collect(Collectors.toList());
        ReadableEntityList<ReadableTaxRate> returnRates = new ReadableEntityList<ReadableTaxRate>();
        returnRates.setItems(readableRates);
        returnRates.setTotalPages(1);
        returnRates.setNumber(readableRates.size());
        returnRates.setRecordsTotal(readableRates.size());
        return returnRates;
    } catch (ServiceException e) {
        LOGGER.error("Error while getting taxRates for store [" + store.getCode() + "]", e);
        throw new ServiceRuntimeException("Error while getting taxRates for store [" + store.getCode() + "]", e);
    }
}
Also used : PersistableTaxClassMapper(com.salesmanager.shop.mapper.tax.PersistableTaxClassMapper) Entity(com.salesmanager.shop.model.entity.Entity) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) TaxRateService(com.salesmanager.core.business.services.tax.TaxRateService) PersistableTaxRateMapper(com.salesmanager.shop.mapper.tax.PersistableTaxRateMapper) TaxClassService(com.salesmanager.core.business.services.tax.TaxClassService) ServiceException(com.salesmanager.core.business.exception.ServiceException) TaxRate(com.salesmanager.core.model.tax.taxrate.TaxRate) Language(com.salesmanager.core.model.reference.language.Language) MerchantStore(com.salesmanager.core.model.merchant.MerchantStore) ReadableTaxRate(com.salesmanager.shop.model.tax.ReadableTaxRate) ResourceNotFoundException(com.salesmanager.shop.store.api.exception.ResourceNotFoundException) Service(org.springframework.stereotype.Service) PersistableTaxRate(com.salesmanager.shop.model.tax.PersistableTaxRate) OperationNotAllowedException(com.salesmanager.shop.store.api.exception.OperationNotAllowedException) Logger(org.slf4j.Logger) TaxFacade(com.salesmanager.shop.store.controller.tax.facade.TaxFacade) TaxClass(com.salesmanager.core.model.tax.taxclass.TaxClass) ReadableTaxClassMapper(com.salesmanager.shop.mapper.tax.ReadableTaxClassMapper) Collectors(java.util.stream.Collectors) UnauthorizedException(com.salesmanager.shop.store.api.exception.UnauthorizedException) List(java.util.List) ReadableTaxClass(com.salesmanager.shop.model.tax.ReadableTaxClass) Validate(org.apache.commons.lang3.Validate) ReadableTaxRateMapper(com.salesmanager.shop.mapper.tax.ReadableTaxRateMapper) ServiceRuntimeException(com.salesmanager.shop.store.api.exception.ServiceRuntimeException) PersistableTaxClass(com.salesmanager.shop.model.tax.PersistableTaxClass) ReadableEntityList(com.salesmanager.shop.model.entity.ReadableEntityList) ReadableEntityList(com.salesmanager.shop.model.entity.ReadableEntityList) ServiceException(com.salesmanager.core.business.exception.ServiceException) TaxRate(com.salesmanager.core.model.tax.taxrate.TaxRate) ReadableTaxRate(com.salesmanager.shop.model.tax.ReadableTaxRate) PersistableTaxRate(com.salesmanager.shop.model.tax.PersistableTaxRate) ReadableTaxRate(com.salesmanager.shop.model.tax.ReadableTaxRate) ServiceRuntimeException(com.salesmanager.shop.store.api.exception.ServiceRuntimeException)

Aggregations

ServiceException (com.salesmanager.core.business.exception.ServiceException)1 TaxClassService (com.salesmanager.core.business.services.tax.TaxClassService)1 TaxRateService (com.salesmanager.core.business.services.tax.TaxRateService)1 MerchantStore (com.salesmanager.core.model.merchant.MerchantStore)1 Language (com.salesmanager.core.model.reference.language.Language)1 TaxClass (com.salesmanager.core.model.tax.taxclass.TaxClass)1 TaxRate (com.salesmanager.core.model.tax.taxrate.TaxRate)1 PersistableTaxClassMapper (com.salesmanager.shop.mapper.tax.PersistableTaxClassMapper)1 PersistableTaxRateMapper (com.salesmanager.shop.mapper.tax.PersistableTaxRateMapper)1 ReadableTaxClassMapper (com.salesmanager.shop.mapper.tax.ReadableTaxClassMapper)1 ReadableTaxRateMapper (com.salesmanager.shop.mapper.tax.ReadableTaxRateMapper)1 Entity (com.salesmanager.shop.model.entity.Entity)1 ReadableEntityList (com.salesmanager.shop.model.entity.ReadableEntityList)1 PersistableTaxClass (com.salesmanager.shop.model.tax.PersistableTaxClass)1 PersistableTaxRate (com.salesmanager.shop.model.tax.PersistableTaxRate)1 ReadableTaxClass (com.salesmanager.shop.model.tax.ReadableTaxClass)1 ReadableTaxRate (com.salesmanager.shop.model.tax.ReadableTaxRate)1 OperationNotAllowedException (com.salesmanager.shop.store.api.exception.OperationNotAllowedException)1 ResourceNotFoundException (com.salesmanager.shop.store.api.exception.ResourceNotFoundException)1 ServiceRuntimeException (com.salesmanager.shop.store.api.exception.ServiceRuntimeException)1