While customizing tax integration with third party, it is important to understand the end points provided by commerce to customize.
Please find below out of box commerce tables and commands that needs to be customized.
INSERT INTO CALMETHOD (CALMETHOD_ID, STOREENT_ID, CALUSAGE_ID, TASKNAME,
DESCRIPTION, SUBCLASS, NAME) VALUES ((select coalesce((min(calmethod_id)-1),1)
from calmethod), 10701 , -3,'com.custom.commerce.order.calculation.ApplyCalculationUsageCmd', 'custommethod for calculation sales taxes', 12, 'ApplyCalculationUsageSalesTax')
update stencalusg SET CALMETHOD_ID_APP =
(SELECT CALMETHOD_ID FROM CALMETHOD WHERE TASKNAME = 'com. custom .commerce.order.calculation.ApplyCalculationUsageCmd'
AND STOREENT_ID = 10701 AND CALUSAGE_ID = -3) and calusage_id=-3
insert into CMDREG (STOREENT_ID, INTERFACENAME, DESCRIPTION, CLASSNAME, PROPERTIES, LASTUPDATE, TARGET) values
(0,'com.custom.commerce.order.calculation.ApplyCalculationUsageCmd','Sales Tax calculation usage for third-party tax
providers','com.custom.commerce.order.calculation.ApplyCalculationUsageSalesTaxCmdImpl',null,null,'Local')
//out of the box command required to be extended.
public class ApplyCalculationUsageSalesTaxCmdImpl extends ApplyCalculationUsageCmdImpl implements com.custom.commerce.order.calculation.ApplyCalculationUsageCmd{
public static final String CLASSNAME = ApplyCalculationUsageSalesTaxCmdImpl.class.getName();
private static Logger LOGGER = Logger.getLogger(CLASSNAME);
public void performExecute()
throws ECException
{
String methodName = "performExecute";
if (LoggingHelper.isEntryExitTraceEnabled(LOGGER)) {
LOGGER.entering(CLASSNAME, methodName);
}
//get tax from Third party
BigDecimal orderTax = new BigDecimal(100.00);
Item[] items = super.getItems();
// set on first order item
for (int i = 0; i < 1; i++) {
items[i].setSalesTaxTotal(orderTax);
items[i].commit();
}
if (LoggingHelper.isEntryExitTraceEnabled(LOGGER)) {
LOGGER.exiting(CLASSNAME, methodName);
}
}
Please find below out of box commerce tables and commands that needs to be customized.
INSERT INTO CALMETHOD (CALMETHOD_ID, STOREENT_ID, CALUSAGE_ID, TASKNAME,
DESCRIPTION, SUBCLASS, NAME) VALUES ((select coalesce((min(calmethod_id)-1),1)
from calmethod), 10701 , -3,'com.custom.commerce.order.calculation.ApplyCalculationUsageCmd', 'custommethod for calculation sales taxes', 12, 'ApplyCalculationUsageSalesTax')
update stencalusg SET CALMETHOD_ID_APP =
(SELECT CALMETHOD_ID FROM CALMETHOD WHERE TASKNAME = 'com. custom .commerce.order.calculation.ApplyCalculationUsageCmd'
AND STOREENT_ID = 10701 AND CALUSAGE_ID = -3) and calusage_id=-3
insert into CMDREG (STOREENT_ID, INTERFACENAME, DESCRIPTION, CLASSNAME, PROPERTIES, LASTUPDATE, TARGET) values
(0,'com.custom.commerce.order.calculation.ApplyCalculationUsageCmd','Sales Tax calculation usage for third-party tax
providers','com.custom.commerce.order.calculation.ApplyCalculationUsageSalesTaxCmdImpl',null,null,'Local')
//out of the box command required to be extended.
public class ApplyCalculationUsageSalesTaxCmdImpl extends ApplyCalculationUsageCmdImpl implements com.custom.commerce.order.calculation.ApplyCalculationUsageCmd{
public static final String CLASSNAME = ApplyCalculationUsageSalesTaxCmdImpl.class.getName();
private static Logger LOGGER = Logger.getLogger(CLASSNAME);
public void performExecute()
throws ECException
{
String methodName = "performExecute";
if (LoggingHelper.isEntryExitTraceEnabled(LOGGER)) {
LOGGER.entering(CLASSNAME, methodName);
}
//get tax from Third party
BigDecimal orderTax = new BigDecimal(100.00);
Item[] items = super.getItems();
// set on first order item
for (int i = 0; i < 1; i++) {
items[i].setSalesTaxTotal(orderTax);
items[i].commit();
}
if (LoggingHelper.isEntryExitTraceEnabled(LOGGER)) {
LOGGER.exiting(CLASSNAME, methodName);
}
}