LaravelDaily / laravel-invoices

Laravel package to generate PDF invoices from various customizable parameters

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Precalculation

alexcinergy opened this issue · comments

Hello!

Is it possible to make a precalculation of the invoice before send it to the browser?

I want to use your calculation() method, but once I've use it then when I sending it to the browser I got:

Exception: Invoice: you must have taxes only on items or only on invoice in file "/vendor/laraveldaily/laravel-invoices/src/Traits/InvoiceHelpers.php on line 356"

Because there is a check for:

if ($item->hasTax() && $this->hasTax()) {
    throw new Exception('Invoice: you must have taxes only on items or only on invoice.');
}

Please assist.

I have extend your class with 2 extra methods like

Get calculation:
public function prepare()

    {
        parent::validate();
        parent::calculate();
    }

Reset before stream

    public function reset()
    {
        $this->hasItemTax = $this->total_taxes = $this->total_discount = $this->taxable_amount = 0;
    }

But not sure am I right

@alexcinergy it is not clear for me what you're trying to do.

What is the real problem are you trying to solve?

Tax exception is for a reason, usually you should be doing one of this:

  • Tax all items at once with same rate on the invoice
  • Tax every line item seperately

Closing as there is no further explanation provided.

See https://xyproblem.info/