mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Ensure freshness of models
This commit is contained in:
parent
43031fd9ce
commit
e071c3aae7
@ -220,8 +220,6 @@ class InvoiceController extends BaseController
|
||||
public function store(StoreInvoiceRequest $request)
|
||||
{
|
||||
|
||||
// $client = Client::find($request->input('client_id'));
|
||||
|
||||
$invoice = $this->invoice_repo->save($request->all(), InvoiceFactory::create(auth()->user()->company()->id, auth()->user()->id));
|
||||
|
||||
$invoice = $invoice->service()
|
||||
|
@ -62,7 +62,7 @@ class ValidInvoicesRules implements Rule
|
||||
return false;
|
||||
}
|
||||
|
||||
$inv = Invoice::whereId($invoice['invoice_id'])->first();
|
||||
$inv = Invoice::withTrashed()->whereId($invoice['invoice_id'])->first();
|
||||
|
||||
if (! $inv) {
|
||||
|
||||
|
@ -51,6 +51,7 @@ class HandleCancellation extends AbstractService
|
||||
|
||||
//adjust client balance
|
||||
$this->invoice->client->service()->updateBalance($adjustment)->save();
|
||||
$this->invoice->fresh();
|
||||
|
||||
$this->invoice->service()->workFlow()->save();
|
||||
|
||||
@ -78,7 +79,8 @@ class HandleCancellation extends AbstractService
|
||||
$adjustment = $cancellation->adjustment * -1;
|
||||
|
||||
$this->invoice->ledger()->updateInvoiceBalance($adjustment, "Invoice {$this->invoice->number} reversal");
|
||||
|
||||
$this->invoice->fresh();
|
||||
|
||||
/* Reverse the invoice status and balance */
|
||||
$this->invoice->balance += $adjustment;
|
||||
$this->invoice->status_id = $cancellation->status_id;
|
||||
@ -90,7 +92,8 @@ class HandleCancellation extends AbstractService
|
||||
unset($backup->cancellation);
|
||||
$this->invoice->backup = $backup;
|
||||
$this->invoice->saveQuietly();
|
||||
|
||||
$this->invoice->fresh();
|
||||
|
||||
return $this->invoice;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user