1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00

Merge pull request #4695 from turbo124/v5-develop

Fix for recurring invoice tax calculations.
This commit is contained in:
David Bomba 2021-01-15 09:58:44 +11:00 committed by GitHub
commit 1f97744083
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 9 deletions

View File

@ -18,6 +18,7 @@ use App\Models\Company;
use App\Models\Credit;
use App\Models\Invoice;
use App\Models\Quote;
use App\Models\RecurringInvoice;
use App\Utils\Ninja;
use App\Utils\Traits\MakesHash;
use App\Utils\Traits\SavesDocuments;
@ -162,7 +163,10 @@ class BaseRepository
$state = [];
$resource = explode('\\', $class->name)[2]; /** This will extract 'Invoice' from App\Models\Invoice */
$lcfirst_resource_id = lcfirst($resource).'_id';
$lcfirst_resource_id = lcfirst($resource).'_id'; //doesn't work for recurring.
if($class->name == RecurringInvoice::class)
$lcfirst_resource_id = 'recurring_invoice_id';
$state['starting_amount'] = $model->amount;
@ -292,6 +296,10 @@ class BaseRepository
$model = $model->calc()->getQuote();
}
if($class->name == RecurringInvoice::class) {
$model = $model->calc()->getRecurringInvoice();
}
$model->save();
return $model->fresh();

View File

@ -21,18 +21,20 @@ class RecurringInvoiceRepository extends BaseRepository
{
public function save($data, RecurringInvoice $invoice) : ?RecurringInvoice
{
$invoice->fill($data);
$invoice->save();
$invoice = $this->alternativeSave($data, $invoice);
// $invoice->fill($data);
$invoice_calc = new InvoiceSum($invoice);
// $invoice->save();
$invoice->service()
->applyNumber()
->createInvitations()
->save();
// $invoice_calc = new InvoiceSum($invoice);
// $invoice->service()
// ->applyNumber()
// ->createInvitations()
// ->save();
$invoice = $invoice_calc->build()->getRecurringInvoice();
// $invoice = $invoice_calc->build()->getRecurringInvoice();
return $invoice;
}