Skip to Content
author's profile photo Former Member
Former Member

Writing Custom Tax Logic

I wrote some custom tax logic (using .cs include file linked from verify.aspx) and I can calculate the new tax but how to I set the shopping cart tax to my new value so it shows on the screen (and into the database)? I have looked at the nptax class and nporderexpensetax class help files but I am not sure how exactly which command to use? Thanks,

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jul 07, 2008 at 04:20 PM

    How does this work? Does webtools store a taxcode for each line item of the cart and then synch the taxcode to b1?

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Actually it's very dependant on the situation.

      Example 1: Not creating a BP for B2C accounts created in B1

      Customer A places an order and wants it shipped to Nebraska

      Customer A creates an account in Web tools

      The Item is warehoused in Alabama, so anyone shipping to Alabama has to pay Alabama sales tax

      The tax is not applied to Customer A's order in Web tools

      The tax is also not applied to Customer A's order in B1

      Example 2: Not creating a BP for B2C accounts created in B1

      Shopper places an order and wants it shipped to Alabama

      Shopper creates an account in Web tools

      The Item is warehoused in Alabama, so anyone shipping to Alabama has to pay Alabama sales tax

      Shopper pays tax in Wt

      The merchant adds Alabama to list of shipping addresses in B1 on the "B2C Website" BP and tax assigned to the address, during implementation

      Tax is applied in B1 with the same amount charged in Wt

      Example 3: Creating a BP for B2C accounts created in B1, Setting in Synchmanager for Default Website Tax Code set to Alabama

      Shopper places an order and wants it shipped to Alabama

      Shopper creates an account in Web tools

      The Item is warehoused in Alabama, so anyone shipping to Alabama has to pay Alabama sales tax

      Shopper pays tax in Wt

      Sync creates BP for B2C account with the address, but the tax field on the address is blank

      Order is correct in B1 as the correct tax code is set on the order(based on the Default Website Tax code selection)

      Example 4: Creating a BP for B2C accounts created in B1, Setting in Synchmanager for Default Website Tax Code set to Alabama

      Shopper places an order and wants it shipped to Nebraska

      Shopper creates an account in Web tools

      The Item is warehoused in Nebraska, so anyone shipping to Nebraska will pay state sales tax

      Shopper pays tax in Wt

      Sync creates BP for B2C account with the address, but the tax field on the address is blank

      Negative percentage discount shows on order as the Default Website Tax Code is set to Alabama but Nebraska tax was calculated in Wt

      So Wt is doing things correctly, and within B1 the adjustment needs to be made.

      This is a limitation of the solution that has a simple workaround(manually add correct tax), and it is a best practice to monitor all orders coming from the web for fraud detection, errors made by shopper, etc anyways.

  • author's profile photo Former Member
    Former Member
    Posted on Jul 03, 2008 at 02:56 PM

    Hi Stephen,

    It is not possible to modify the tax calculations.

    NPOrder.Calculate() is run on every page of the check out process and will recalculate taxes based on data from the tax tables.

    The only way to change the values displayed is to change the data in the tax tables.

    Given that, the taxes are fairly flexible and there is a good chance you can get the calculations you are looking for.

    We might be able to help you get the values you need if you give us more information.

    You should also know that it is possible to create taxes in Webtools that can not be created in B1. If you are doing this, there is a high probability that you will get incorrect data in B1 from the synch.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 03, 2008 at 03:45 PM

    The tax logic for NY is too complex to be supported by standard webtools and B1. In addition, we have very custom pricing logic, so the tax needs to run off this price instead of the price in the database. We have an add-on on b1 which will calculate the tax so it matches webtools. Here is pseduo code of how the tax works:

    From destination shipto zipccode, lookup taxcode & taxrate:

    If zip not found,

    taxcode = <out of state tax code> (tax=0)

    If zip found:

    For each line,

    If part is not table (tax liable is no) then

    Tax code = non-taxable code (tax amount = 0)

    End else

    If customer is non-taxable then

    Tax code = OS0 (non-taxable code) (tax amount=0 )

    End else

    If part mintax = u2018nu2019 and zip mintax = u2018nu2019 then

    Line_tax = line_amount * tax_rate

    Else

    If unit_total < $110 tax = non-taxable code,

    else line_tax = line_amount * tax_rate.

    End

    End

    End

    End

    Can I just update the tax on the screen after NPOrder.Calculate() has been called?

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Stephan,

      Here is my super-quick response--all a bit hypothetical.

      You should be able to update the tax values after Calculate(), but it will be a lot of work.

      There are a number of calculated values on OrderMaster, OrderDetail, OrderExepense and and OrderExpenseTax that may also require an update (I would need to research this to give you the exact fields--but it should be a little obvious).

      I THINK (not 100%) you should be able to do this in the onPreRender event on cart.ascx.

      You may also need a custom page to amend the values after verify.aspx (ie, Webflow).

      The bigger problem, to me, is getting them back to B1. If B1 can not support this tax structure, you will end up with negative discounts on the order.

      I will need to spend more time with your code to see if there is another way to do this.

      Edited by: Shane Hart on Jul 3, 2008 11:20 AM

  • author's profile photo Former Member
    Former Member
    Posted on Jul 03, 2008 at 04:30 PM

    Ok, thanks. I will take that approach.

    As for the negative discount, don't all weborders have this issue. No line item taxrate nor taxcode is synched from webtools to b1, so I get a neg discount when I synch any order on a fresh webtools install. Correct?

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.