After setting subTotalPrice the tax is not calculated correctly
LWlook opened this issue · comments
Describe the bug
After setting subTotalPrice the taxByPercent is not calculated correctly.
To Reproduce
Steps to reproduce the behavior:
- Set quantity to 8.53
- Set pricePerUnit to 5.57
- Set taxByPercentage to 13
- Set subTotalPrice to 53.65
- Calculate the result
- Display the taxes.
Expected behavior
The taxes should be 53.65 - (8.53 * 5.57) or 13% form the net value. But now only the percent-value is copied to the taxes.
Additional context
Addition why it is necessary to set the subTotalPrice, the pricePerUnit and the taxByPercent: If somebody wants an invoice with the gross values on display, I need to set all three values to display the correct values on the invoice.
@LWlook it is NOT necessary to specify subTotalPrice. if you do that, it will override anything pre-calculated.
(new InvoiceItem())->title('Service 1')
->description('Your product or service description')
->pricePerUnit(5.57)
->quantity(8.53)
->taxByPercent(13),
and (8.53 * 5.57) * 1.13 = 53.69
, not 53.65
, and if you want to manually override values it is your option, then you should also provide your own calculated taxes as ->tax($amount)
@mc0de Thank you for answering that, but I still have a problem.
- If a calculate tax on my own and set it with ->tax($amount) than I lose the information how much taxes in percent are on the item.
- The calculation is also a bit trickier than it seams: If you calculate from the net side, than your math is correct. But I have a GUI where I can set the gross values, for example:
Amount: 8.53
GrossPrice: 6,29
And this values aren't possible with the package, because now the subTotal is 8,53*6,29 = 53,65. But pricePerUnit is still 5,57 as 6,29 / 1,13 is 5,57.
@LWlook thanks for clarifying.
package wasn't designed specifically for your specified requirements.
Optionally what can I suggest is to use setCustomData
on the invoice providing values with your own calculations or whatever data you need and make a custom template to reflect that data.