Applying Tax Inclusive Taxes to Tax Codes
Summary
This article describes how to configure inclusive taxing via a SQL script. If you have an AvaTax integrated EngageIP environment running EngageIP 8.5.25.0 or later you can enable inclusive taxing on services without the requirement to apply the script below, see the Configuring Inclusive Taxes section of the AvaTax configuration article for details.
Inclusive Tax Pricing
This allows you to apply a tax that is calculated within the price of the product. So if the base fee of the product is £10 and the tax rate is 2%, the system would calculate that the tax would be £0.20 and the new base fee of the service would be charged at £9.80
Configuration
Copy and paste the appropriate SQL below in query analyzer on the BOSS database. This will add the taxing script to the system:
Script for EngageIP 8.5.22.9 or lowerTaxCode taxCode = (TaxCode)context["taxCode"]; StatementDetails sd = (StatementDetails)context["statementdetails"]; DOUBLE taxableamount = (DOUBLE)context["taxableamount"]; Logisense.Boss.Logic.Billing.Taxes taxes = NEW Logisense.Boss.Logic.Billing.Taxes(); DOUBLE totalTaxes = 0.00; DOUBLE vattax = 0.00; DOUBLE originalamount = 0.0; DOUBLE totaltaxrate = 0.00; INT counttax=0;//Find ALL taxes foreach (TaxRate my_tr IN taxCode.GetTaxRateByConnectorCollection()) { IF (my_tr.TaxOnTax == FALSE) { totaltaxrate += my_tr.Rate; counttax++; } } //Amount = $107.00 including VAT (7%) //Original Price = (Amount / ( 1.0 + TaxRate) //Original Price = (107/1.07) = 100.00 //VAT = Amount Original Price = 107- 100 = $7.00 //Calculate Tax originalamount = (taxableamount) / (1.00 + totaltaxrate); originalamount = Logisense.Boss.Logic.Billing.Rounding.Round(originalamount, 2); vattax = taxableamount - originalamount; //Adjust statementdetails WITHOUT tax //we need TO consider Discount IF EXISTS, the Discount IS subtracted FROM Original Amount DOUBLE discount = 0.00; foreach (StatementDetailsDiscount my_sdd IN sd.GetStatementDetailsDiscountCollection()) { discount += my_sdd.Amount; } sd.Amount = originalamount + discount; sd.Update(); IF (counttax==1) { foreach (TaxRate my_tr IN taxCode.GetTaxRateByConnectorCollection()) { IF (my_tr.TaxOnTax == FALSE) { Logisense.Boss.Logic.Billing.TaxInformation newTaxInfo = NEW Logisense.Boss.Logic.Billing.TaxInformation(); newTaxInfo.AmountTaxed = taxableamount; newTaxInfo.Rate = my_tr.Rate; newTaxInfo.TaxAmount = Logisense.Boss.Logic.Billing.Rounding.Round(vattax, 2 ); newTaxInfo.TaxName = my_tr.Name; taxes.AddTax(newTaxInfo); totalTaxes += newTaxInfo.TaxAmount; } } } ELSE { foreach (TaxRate my_tr IN taxCode.GetTaxRateByConnectorCollection()) { IF (my_tr.TaxOnTax == FALSE) { Logisense.Boss.Logic.Billing.TaxInformation newTaxInfo = NEW Logisense.Boss.Logic.Billing.TaxInformation(); newTaxInfo.AmountTaxed = taxableamount; newTaxInfo.Rate = my_tr.Rate; newTaxInfo.TaxAmount = Logisense.Boss.Logic.Billing.Rounding.Round(originalamount * my_tr.Rate,2 ); newTaxInfo.TaxName = my_tr.Name; taxes.AddTax(newTaxInfo); totalTaxes += newTaxInfo.TaxAmount; } } } //Tax ON Tax. foreach (TaxRate my_tr IN taxCode.GetTaxRateByConnectorCollection()) { IF (my_tr.TaxOnTax == TRUE) { try { Logisense.Boss.Logic.Billing.TaxInformation newTaxInfo = NEW Logisense.Boss.Logic.Billing.TaxInformation(); newTaxInfo.AmountTaxed = taxableamount; newTaxInfo.Rate = my_tr.Rate; newTaxInfo.TaxAmount = Logisense.Boss.Logic.Billing.Rounding.Round(my_tr.Rate * (vattax), 2); newTaxInfo.TaxName = my_tr.Name; taxes.AddTax(newTaxInfo); } catch { } } } RETURN taxes;
Â
Script for EngageIP 8.5.24.x or higher
INSERT INTO taxvendor (ownerid,name,chargescript,InvoiceChargeScript) VALUES (1,'VAT',' TaxCode taxCode = (TaxCode)context["taxCode"]; StatementDetails sd = (StatementDetails)context["statementdetails"]; double taxableamount = (double)context["taxableamount"]; Logisense.Boss.Logic.Billing.Taxes taxes = new Logisense.Boss.Logic.Billing.Taxes(); double totalTaxes = 0.00; double vattax = 0.00; double originalamount = 0.0; double totaltaxrate = 0.00; int counttax=0; //Find all taxes foreach (TaxRate my_tr in taxCode.GetTaxRateByConnectorCollection()) { if (my_tr.TaxOnTax == false) { totaltaxrate += my_tr.Rate; counttax++; } } //Amount = $107.00 including VAT (7%) //Original Price = (Amount / ( 1.0 + TaxRate) //Original Price = (107/1.07) = 100.00 //VAT = Amount Original Price = 107- 100 = $7.00 //Calculate VAT originalamount = (taxableamount) / (1.00 + totaltaxrate); originalamount = Logisense.Boss.Logic.Billing.Rounding.Round(originalamount, 2); vattax = taxableamount - originalamount; //Adjust statementdetails without tax //we need to consider Discount if exists, the Discount is subtracted from Original Amount double discount = 0.00; foreach (StatementDetailsDiscount my_sdd in sd.GetStatementDetailsDiscountCollection()) { discount += my_sdd.Amount; } sd.Amount = originalamount + discount; sd.Update(); if (counttax==1) { foreach (TaxRate my_tr in taxCode.GetTaxRateByConnectorCollection()) { if (my_tr.TaxOnTax == false) { Logisense.Boss.Logic.Billing.TaxInformation newTaxInfo = new Logisense.Boss.Logic.Billing.TaxInformation(); newTaxInfo.AmountTaxed = taxableamount; newTaxInfo.Rate = my_tr.Rate; newTaxInfo.TaxAmount = Logisense.Boss.Logic.Billing.Rounding.Round(vattax, 2 ); newTaxInfo.TaxName = my_tr.Name; taxes.AddTax(newTaxInfo); totalTaxes += newTaxInfo.TaxAmount; } } } else { foreach (TaxRate my_tr in taxCode.GetTaxRateByConnectorCollection()) { if (my_tr.TaxOnTax == false) { Logisense.Boss.Logic.Billing.TaxInformation newTaxInfo = new Logisense.Boss.Logic.Billing.TaxInformation(); newTaxInfo.AmountTaxed = taxableamount; newTaxInfo.Rate = my_tr.Rate; newTaxInfo.TaxAmount = Logisense.Boss.Logic.Billing.Rounding.Round(originalamount * my_tr.Rate,2 ); newTaxInfo.TaxName = my_tr.Name; taxes.AddTax(newTaxInfo); totalTaxes += newTaxInfo.TaxAmount; } } } //Tax On Tax. foreach (TaxRate my_tr in taxCode.GetTaxRateByConnectorCollection()) { if (my_tr.TaxOnTax == true) { try { Logisense.Boss.Logic.Billing.TaxInformation newTaxInfo = new Logisense.Boss.Logic.Billing.TaxInformation(); newTaxInfo.AmountTaxed = taxableamount; newTaxInfo.Rate = my_tr.Rate; newTaxInfo.TaxAmount = Logisense.Boss.Logic.Billing.Rounding.Round(my_tr.Rate * (vattax), 2); newTaxInfo.TaxName = my_tr.Name; taxes.AddTax(newTaxInfo); } catch { } } } return taxes; ','var pending = (List)context["StatementDetailsPendingTaxes"]; Logisense.Boss.Logic.Billing.Tax.ChargeTaxesPerStatementDetails(pending); return true;' )
Â
In the AdminPortal load the Setup page / Tax Codes and add the appropriate tax vendor script above to tax codes that need to apply inclusive taxing
Ensure there is a Tax Rate assigned to the Tax Codes
Test inclusive taxing by loading an account which has a Tax Code assigned to it which is using the inclusive taxing script. Add a transaction for $10. The system will calculate the base fee according to the % rate you entered so that the total price is no greater then the original base fee