use of org.broadleafcommerce.core.pricing.service.exception.TaxException in project BroadleafCommerce by BroadleafCommerce.
the class CommitTaxRollbackHandler method rollbackState.
@Override
public void rollbackState(Activity<ProcessContext<CheckoutSeed>> activity, ProcessContext<CheckoutSeed> processContext, Map<String, Object> stateConfiguration) throws RollbackFailureException {
ProcessContext<CheckoutSeed> ctx = processContext;
Order order = ctx.getSeedData().getOrder();
try {
taxService.cancelTax(order);
} catch (TaxException e) {
throw new RollbackFailureException("An exception occured cancelling taxes for order id: " + order.getId(), e);
}
}
use of org.broadleafcommerce.core.pricing.service.exception.TaxException in project BroadleafCommerce by BroadleafCommerce.
the class TaxServiceImpl method calculateTaxForOrder.
@Override
public Order calculateTaxForOrder(Order order) throws TaxException {
List<ModuleConfiguration> configurations = moduleConfigService.findActiveConfigurationsByType(ModuleConfigurationType.TAX_CALCULATION);
// Try to find a default configuration
ModuleConfiguration config = null;
if (configurations != null) {
for (ModuleConfiguration configuration : configurations) {
if (configuration.getIsDefault()) {
config = configuration;
break;
}
}
if (config == null && CollectionUtils.isNotEmpty(configurations)) {
// if there wasn't a default one, use the first active one...
config = configurations.get(0);
}
}
if (CollectionUtils.isNotEmpty(providers)) {
for (TaxProvider provider : providers) {
if (provider.canRespond(config)) {
return provider.calculateTaxForOrder(order, config);
}
}
}
// haven't returned anything, nothing must have run
if (!mustCalculate) {
return order;
}
throw new TaxException("No eligible tax providers were configured.");
}
Aggregations