use of com.salesmanager.core.model.tax.taxclass.TaxClass in project shopizer by shopizer-ecommerce.
the class TaxFacadeImpl method taxClasses.
@Override
public ReadableEntityList<ReadableTaxClass> taxClasses(MerchantStore store, Language language) {
Validate.notNull(store, "MerchantStore cannot be null");
Validate.notNull(store.getCode(), "MerchantStore code cannot be null");
try {
List<TaxClass> models = taxClassService.listByStore(store);
List<ReadableTaxClass> taxClasses = models.stream().map(t -> convertToReadableTaxClass(t, store, language)).collect(Collectors.toList());
ReadableEntityList<ReadableTaxClass> list = new ReadableEntityList<ReadableTaxClass>();
list.setItems(taxClasses);
list.setNumber(taxClasses.size());
list.setTotalPages(1);
list.setRecordsTotal(taxClasses.size());
return list;
} catch (ServiceException e) {
LOGGER.error("Error while getting taxClasses for store [" + store.getCode() + "]", e);
throw new ServiceRuntimeException("Error while getting taxClasses for store [" + store.getCode() + "]", e);
}
}
use of com.salesmanager.core.model.tax.taxclass.TaxClass in project shopizer by shopizer-ecommerce.
the class TaxFacadeImpl method createTaxClass.
@Override
public Entity createTaxClass(PersistableTaxClass taxClass, MerchantStore store, Language language) {
Validate.notNull(taxClass, "TaxClass cannot be null");
Validate.notNull(store, "MerchantStore cannot be null");
Validate.notNull(store.getCode(), "MerchantStore code cannot be null");
try {
if (this.existsTaxClass(taxClass.getCode(), store, language)) {
throw new OperationNotAllowedException("Tax class [" + taxClass.getCode() + "] already exist for store [" + store.getCode() + "]");
}
taxClass.setStore(store.getCode());
TaxClass model = persistableTaxClassMapper.convert(taxClass, store, language);
model = taxClassService.saveOrUpdate(model);
;
Entity id = new Entity();
id.setId(model.getId());
return id;
} catch (ServiceException e) {
LOGGER.error("Error while saving taxClass [" + taxClass.getCode() + "] for store [" + store.getCode() + "]", e);
throw new ServiceRuntimeException("Error while saving taxClass [" + taxClass.getCode() + "] for store [" + store.getCode() + "]", e);
}
}
use of com.salesmanager.core.model.tax.taxclass.TaxClass in project shopizer by shopizer-ecommerce.
the class InitializationDatabaseImpl method createMerchant.
private void createMerchant() throws ServiceException {
LOGGER.info(String.format("%s : Creating merchant ", name));
Date date = new Date(System.currentTimeMillis());
Language en = languageService.getByCode("en");
Country ca = countryService.getByCode("CA");
Currency currency = currencyService.getByCode("CAD");
Zone qc = zoneService.getByCode("QC");
List<Language> supportedLanguages = new ArrayList<Language>();
supportedLanguages.add(en);
// create a merchant
MerchantStore store = new MerchantStore();
store.setCountry(ca);
store.setCurrency(currency);
store.setDefaultLanguage(en);
store.setInBusinessSince(date);
store.setZone(qc);
store.setStorename("Default store");
store.setStorephone("888-888-8888");
store.setCode(MerchantStore.DEFAULT_STORE);
store.setStorecity("My city");
store.setStoreaddress("1234 Street address");
store.setStorepostalcode("H2H-2H2");
store.setStoreEmailAddress("john@test.com");
store.setDomainName("localhost:8080");
store.setStoreTemplate("december");
store.setRetailer(true);
store.setLanguages(supportedLanguages);
merchantService.create(store);
TaxClass taxclass = new TaxClass(TaxClass.DEFAULT_TAX_CLASS);
taxclass.setMerchantStore(store);
taxClassService.create(taxclass);
// create default manufacturer
Manufacturer defaultManufacturer = new Manufacturer();
defaultManufacturer.setCode("DEFAULT");
defaultManufacturer.setMerchantStore(store);
ManufacturerDescription manufacturerDescription = new ManufacturerDescription();
manufacturerDescription.setLanguage(en);
manufacturerDescription.setName("DEFAULT");
manufacturerDescription.setManufacturer(defaultManufacturer);
manufacturerDescription.setDescription("DEFAULT");
defaultManufacturer.getDescriptions().add(manufacturerDescription);
manufacturerService.create(defaultManufacturer);
Optin newsletter = new Optin();
newsletter.setCode(OptinType.NEWSLETTER.name());
newsletter.setMerchant(store);
newsletter.setOptinType(OptinType.NEWSLETTER);
optinService.create(newsletter);
}
use of com.salesmanager.core.model.tax.taxclass.TaxClass in project shopizer by shopizer-ecommerce.
the class TaxClassServiceImpl method delete.
@Override
public void delete(TaxClass taxClass) throws ServiceException {
TaxClass t = getById(taxClass.getId());
super.delete(t);
}
use of com.salesmanager.core.model.tax.taxclass.TaxClass in project shopizer by shopizer-ecommerce.
the class PersistableTaxClassMapper method convert.
@Override
public TaxClass convert(PersistableTaxClass source, MerchantStore store, Language language) {
Validate.notNull(source, "PersistableTaxClass cannot be null");
Validate.notNull(store, "MerchantStore cannot be null");
TaxClass taxClass = new TaxClass();
taxClass.setMerchantStore(store);
taxClass.setTitle(source.getName());
taxClass.setId(source.getId());
return this.merge(source, taxClass, store, language);
}
Aggregations