LaravelDaily/laravel-invoices

Possibility to recalculate values

LWlook opened this issue · 2 comments

Is your feature request related to a problem? Please describe.
In the newer versions you deleted the beforeRender() from the toHtml()- method. So before calling the toHtml()- method i need a way to recalculate all the total-fields.
Additional: Sometimes I want to use the library to calculate all total-fields without rendering it to the screen (only save all values to the database). So a calculate method would help.

Describe the solution you'd like
A simple method like this in the Invoice.php-file would help:

    public function calculateAndValidate(): void {
        $this->beforeRender();
    }

Or you can make the calculate() and validate() - methods public.

Describe alternatives you've considered
You could always call "render()" before taking the values, but

  1. This method caches the values after calling it once.
  2. Is much slower than just recalculating all values.
mc0de commented

@LWlook made calculate and validate methods public

@mc0de Thank you very much! 😄