Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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.

...

  1. 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 lower

    Code Block
    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 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
    [cce lang="sql"]INSERT INTO taxvendor
    (ownerid,name,chargescript,InvoiceChargeScript) VALUES (1,'VAT','

    Code Block
    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;'
    )

  2. In the AdminPortal load the Setup tab > page / Tax Codes and apply this add the appropriate tax vendor script above to tax codes that you need this applied onneed to apply inclusive taxing

  3. Ensure there is a Tax Rate assigned to the Tax Codes

  4. Test by going to a user who has that Tax Code assigned and add 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