1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

Minor fixes for marking an invoice as sent

This commit is contained in:
David Bomba 2021-10-19 20:04:19 +11:00
parent 51d6efb5ca
commit a09666fb96
4 changed files with 21 additions and 9 deletions

View File

@ -308,7 +308,7 @@ class BaseDriver extends AbstractPaymentDriver
$invoices = Invoice::whereIn('id', $this->transformKeys(array_column($payment_hash->invoices(), 'invoice_id')))->withTrashed()->get(); $invoices = Invoice::whereIn('id', $this->transformKeys(array_column($payment_hash->invoices(), 'invoice_id')))->withTrashed()->get();
$invoices->each(function ($invoice) { $invoices->each(function ($invoice) {
$invoice->service()->removeUnpaidGatewayFees(); $invoice->service()->removeUnpaidGatewayFees()->save();
}); });
} }

View File

@ -494,6 +494,6 @@ class InvoiceService
{ {
$this->invoice->saveQuietly(); $this->invoice->saveQuietly();
return $this->invoice; return $this->invoice->fresh();
} }
} }

View File

@ -86,8 +86,8 @@ class MarkPaid extends AbstractService
->deletePdf() ->deletePdf()
->save(); ->save();
if ($this->invoice->client->getSetting('client_manual_payment_notification')) // if ($this->invoice->client->getSetting('client_manual_payment_notification'))
$payment->service()->sendEmail(); // $payment->service()->sendEmail();
/* Update Invoice balance */ /* Update Invoice balance */
event(new PaymentWasCreated($payment, $payment->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null))); event(new PaymentWasCreated($payment, $payment->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));

View File

@ -33,15 +33,18 @@ class MarkSent extends AbstractService
{ {
/* Return immediately if status is not draft */ /* Return immediately if status is not draft */
if ($this->invoice->status_id != Invoice::STATUS_DRAFT) { if ($this->invoice->fresh()->status_id != Invoice::STATUS_DRAFT) {
return $this->invoice; return $this->invoice;
} }
$this->invoice->markInvitationsSent(); /*Set status*/
$this->invoice $this->invoice
->service() ->service()
->setStatus(Invoice::STATUS_SENT) ->setStatus(Invoice::STATUS_SENT)
->save();
$this->invoice
->service()
->applyNumber() ->applyNumber()
->setDueDate() ->setDueDate()
->updateBalance($this->invoice->amount) ->updateBalance($this->invoice->amount)
@ -49,9 +52,18 @@ class MarkSent extends AbstractService
->setReminder() ->setReminder()
->save(); ->save();
$this->client->service()->updateBalance($this->invoice->balance)->save(); $this->invoice->markInvitationsSent();
$this->invoice->ledger()->updateInvoiceBalance($this->invoice->balance, "Invoice {$this->invoice->number} marked as sent."); /*Adjust client balance*/
$this->client
->service()
->updateBalance($this->invoice->balance)
->save();
/*Update ledger*/
$this->invoice
->ledger()
->updateInvoiceBalance($this->invoice->balance, "Invoice {$this->invoice->number} marked as sent.");
event(new InvoiceWasUpdated($this->invoice, $this->invoice->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null))); event(new InvoiceWasUpdated($this->invoice, $this->invoice->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));