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:
commit
1f97744083
@ -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();
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user