[ic] Issue with taxable_amount / total_cost calculating incorrect totals when Discount ENTIRE_ORDER is used

Dan Bergan danbergan at gmail.com
Wed Feb 3 01:43:07 UTC 2010

On Tue, Feb 2, 2010 at 6:19 PM, Ron Phipps <ron at endpoint.com> wrote:
> I found this issue while working with a build of 5.5.0 from 2007, and in reviewing Interpolate.pm from git HEAD it appears to be the same.
> This is more to ask if there is a scenario where taxable_amount should be returning negative amounts and what that scenario might look like. If we cannot come up with the scenario it might make sense to fix the issue.
> Here is the situation, we have a $6 discount in use on a $100 subtotal order.  There is $6.00 in shipping and the tax is %9.
> If the items in the cart are marked nontaxable the results are as follows:
> Subtotal:       100
> Ship:           6
> SalesTax:       -0.54
> Discount:       -6
> Total:          $99.46
> The problem is that when total_cost calls salestax which in turn calls taxable_amount $cost is calculated as -6.00 (the amount of the discount since no items are taxed), and this -6.00 is returned to salestax which then calculates the tax as -0.54 and is figured into the total cost.
> I patched my local copy by adding:
>        if ($cost < 0) {
>            $cost = 0;
>        }
> prior to:
>        $taxable = $cost;

I had a similar issue a while back:


I ended up doing a custom discount where the "entire order" discount
was split proportionally  to all items on the order.  But, it still
never made sense to me why negative tax was being calculated when all
the items on the order were non-taxable.

I do understand that a negative tax can be valid for returns, but when
an item isn't taxable, then no tax should be calculated.


More information about the interchange-users mailing list