[ic] Negative Sales Tax Problem

Carl Bailey carl at triangleresearch.com
Mon May 7 09:17:04 EDT 2007

Last week we encountered a problem where 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 
    --- 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);

Or is there a better way still?


More information about the interchange-users mailing list