Postby ktisdell » Mon Dec 02, 2013 2:05 pm
We have refactored the way that we handle tax modules, to allow for multiple tax (or other modules) to be used. We have an Avalara Tax Module available if you are willing to pay the fees to Avalara for tax calculations. If you wish to implement your own tax module, you must do the following:
1. Implement TaxProvider (org.broadleafcommerce.core.pricing.service.tax.provider.TaxProvider). The methods commitTaxForOrder and cancelTax can be empty implementations. They are for situations where you need to send tax information to another system, or cancel tax in another system.
2. Extend AbstractModuleConfiguration (org.broadleafcommerce.common.config.domain.AbstractModuleConfiguration). This is an entity and must have an associated DB table. This is used for things like integrations with external tax systems. As such, you can provide any additional properties such as username, password, URL, etc... Or, you can provide additional information such as tax rate. If you don't have any additional properties, then you can simply create a blank implementation, which will require a table with a primary key that is a foreign key to the BLC_MODULE_CONFIGURATION table. Your entry in the BLC_MODULE_CONFIGURATION must have a corresponding entry in your new module config table. You must provide:
- MODULE_NAME
- ACTIVE_START_DATE (date in the past)
- IS_DEFAULT to true (especially if this is your only tax module)
- CONFIG_TYPE to 'TAX_CALCULATION'
- MODULE_PRIORITY to some number (this can be any number, but if you have multiple tax modules, this will be the order that they are evaluated. It's best to set this number to 1 if you only have one tax module.)
When you implement the "canRespond(ModuleConfiguration config)" method as part of the implementation of TaxProvider, you should do the following:
public boolean canRespond(ModuleConfiguration config) {
if (config instanceof MyTaxModuleConfig) {
return true;
}
return false;
}
The rest is up to you to provide the implementation. Please remember that taxes are calculated and stored at the FulfillmentGroup and FulfillemntGroupItem level.