LaravelDaily / laravel-invoices

Laravel package to generate PDF invoices from various customizable parameters

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

After setting subTotalPrice the tax is not calculated correctly

LWlook opened this issue · comments

commented

Describe the bug
After setting subTotalPrice the taxByPercent is not calculated correctly.

To Reproduce
Steps to reproduce the behavior:

  1. Set quantity to 8.53
  2. Set pricePerUnit to 5.57
  3. Set taxByPercentage to 13
  4. Set subTotalPrice to 53.65
  5. Calculate the result
  6. 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.

Screenshots
image

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),

image

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)

commented

@mc0de Thank you for answering that, but I still have a problem.

  1. 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.
  2. 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.