1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 16:31:33 +02: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->each(function ($invoice) {
$invoice->service()->removeUnpaidGatewayFees();
$invoice->service()->removeUnpaidGatewayFees()->save();
});
}

View File

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

View File

@ -86,8 +86,8 @@ class MarkPaid extends AbstractService
->deletePdf()
->save();
if ($this->invoice->client->getSetting('client_manual_payment_notification'))
$payment->service()->sendEmail();
// if ($this->invoice->client->getSetting('client_manual_payment_notification'))
// $payment->service()->sendEmail();
/* Update Invoice balance */
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 */
if ($this->invoice->status_id != Invoice::STATUS_DRAFT) {
if ($this->invoice->fresh()->status_id != Invoice::STATUS_DRAFT) {
return $this->invoice;
}
$this->invoice->markInvitationsSent();
/*Set status*/
$this->invoice
->service()
->setStatus(Invoice::STATUS_SENT)
->save();
$this->invoice
->service()
->applyNumber()
->setDueDate()
->updateBalance($this->invoice->amount)
@ -49,9 +52,18 @@ class MarkSent extends AbstractService
->setReminder()
->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)));