Percentage discount is calculated without taxes [has-pr]
dennisoderwald opened this issue · 10 comments
A percentage discount that is unrelated to an item is calculated incorrectly, as it seems the percentage value is calculated from the net and not from the gross, so without taxes. With the variant "Fixed" it seems to be correct.
If a coupon is attached to the item itself, it seems to be true.
You can change how you need your taxes to work with:
https://github.com/lukepolo/laracart/blob/master/src/config/laracart.php#L96
If this is still incorrect, can you write a quick test and we can fix it?
I'm not quite sure myself right now if I might get this solved with the configuration. Here is an example:
LaraCart::add(2, 'Product Name', 1, 0.84, [
'tax' => 0.19
]);
$coupon = new \LukePOLO\LaraCart\Coupons\Fixed('CODE', 1.00, [
'description' => 'DESCRIPTION'
]);
LaraCart::addCoupon($coupon);
For my understanding, this should correctly come out:
Sub Total: 0.84
Tax Total: 0.16
Total Discount: 1.00
Total: 0.00
I have tried to interfere with the configuration (for taxes/discounts) but have not found a solution. With me always comes out the following:
Sub Total: 0.84
Tax Total: 0.16
Total Discount: 0.84
Total: 0.16
However, the discount is 1€ (taxed) and not only 0.84€.
I am now quite confused myself whether there is an error in the code or I am simply doing something wrong.
The following configuration should be correct in my opinion:
/*
|--------------------------------------------------------------------------
| Calculate tax per item, rather than subtotal
| https://github.com/lukepolo/laracart/issues/180
|
| This will vary , please investigate to follow the rules of your local laws
| https://money.stackexchange.com/questions/15051/sales-tax-rounded-then-totaled-or-totaled-then-rounded
|--------------------------------------------------------------------------
|
*/
'tax_by_item' => true,
/*
|--------------------------------------------------------------------------
| If you need to tax items before discount you can turn it on
|--------------------------------------------------------------------------
|
*/
'tax_item_before_discount' => true,
/*
|--------------------------------------------------------------------------
| Allows you to choose if the discounts applied are taxable
|--------------------------------------------------------------------------
|
*/
'discountTaxable' => false,
/*
|--------------------------------------------------------------------------
| If your discounts are already pre taxes but items are not,
| you can set this here to get the correct values
|--------------------------------------------------------------------------
|
*/
'discountsAlreadyTaxed' => true,
/*
|--------------------------------------------------------------------------
| Allows you to choose if the discounts applied to fees
|--------------------------------------------------------------------------
|
*/
'discountOnFees' => false,
In Germany, we have to deduct the discount from the gross.
Are you saying your discount is already pre-taxed?
yes, its a gross discount already including taxes
Yes this certainly looks like a bug, it should come out to 0 as you stated. Let me see if I can find a quick fix.
Okay, reassured to hear it's a bug. :) I'm just checking again if the problem also occurs with percentage discounts....
The percentage discount also seems to be calculated from the net.
Percentage discount was also incorrect. This has been fixed in the PR as well.
I am going to have to go think about how to fix all of this properly. May be a couple more days.
Sorry, I have not had the time to complete this. Over the next couple of weeks I plan on going through knocking out bugs where I can.
i have fixed this in the newer branch 2.1