[ic] Re: Negative Tax - bug?

Dan Bergan danb at berganconsulting.com
Tue Oct 30 09:56:00 EST 2007


On 10/16/07, Dan Bergan <danb at berganconsulting.com> wrote:
> I'm having an issue where negative sales tax amounts are computed.
> The issue arises when there is a discount on the entire order, and the
> products in the cart are nontaxable.
>
> A detailed description and potential solution is here:
> http://www.icdevgroup.org/pipermail/interchange-users/2007-May/047410.html
>
> This issue was also found here (with no resolutions):
> http://www.icdevgroup.org/pipermail/interchange-users/2005-September/043923.html
>
> Is this a bug?  It doesn't seem like a negative sales tax should be valid.
>

Back in May, Carl had what looks to be a good solution for this
problem, which I am going to implement for my installation (see
below).

I tried to log into the bug tracker to submit this as bug, but it
looks like "guest" does not have access to submit bugs.  If someone
can let me know how to submit a bug, or submit this for me, I would
appreciate it.

Carl's description and potential solution:
IC (ver 5.4) allowed several customers to check out with a negative
sales-tax value and a positive grand total.  Investigation showed
that this situation occurred when:
    (a) All the merchandise in the cart was non-taxable, and
    (b) an entire-order discount was in place.

We fixed the immediate problem by adjusting sub taxable_amount in
Interpolate.pm.  We changed only the last line of the routine as
follows:
    --- return $taxable;
    +++ return ($taxable > 0) ? $taxable : 0;

But ours was an edge case.  Imagine instead a cart with a mix of
taxable and non-taxable merchandise, where the discount exceeds the
value of the taxable merchandise.  The current code will return a
negative value, and our patch above would return a value of zero as
the taxable subototal. But should the discount discount wipe out _all_
the tax in this case?  Should we perhaps compute the reduction of the
taxable subtotal proportionally as per the lines below?

    # $taxable contains taxable amount summed from item loop as per
current code
    return $taxable unless $::Discounts->{ENTIRE_ORDER};

    # this can be computed more efficiently by accumulating the
item-subtotal's in the item loop earlier in the code
    my $grand = subtotal() + $::Discounts->{ENTIRE_ORDER};
    return 0 unless $grand;

    $taxable -= $discount * ($taxable / $grand);
    return sprintf("%0.2f",$taxable);


More information about the interchange-users mailing list