mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 21:22:58 +01:00
74a6c4f2ee
* Performance improvements moving from str_replace to strtr * Remove legacy docs * Clean up credit transformer * Working on invoice emails * Clean up for invoice designs * Tests for light and dark theme emails * Working on reminder scheduling * Reminder Job Class * Fixes for github actions * PHP CS * Test for reminders * Test for reminders
57 lines
1.3 KiB
PHP
57 lines
1.3 KiB
PHP
<?php
|
|
/**
|
|
* Invoice Ninja (https://invoiceninja.com)
|
|
*
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
*
|
|
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
|
*
|
|
* @license https://opensource.org/licenses/AAL
|
|
*/
|
|
|
|
namespace App\Services\Invoice;
|
|
|
|
use App\Events\Invoice\InvoiceWasMarkedSent;
|
|
use App\Models\Invoice;
|
|
use App\Services\AbstractService;
|
|
|
|
class MarkSent extends AbstractService
|
|
{
|
|
private $client;
|
|
|
|
private $invoice;
|
|
|
|
public function __construct($client, $invoice)
|
|
{
|
|
$this->client = $client;
|
|
$this->invoice = $invoice;
|
|
}
|
|
|
|
public function run()
|
|
{
|
|
|
|
/* Return immediately if status is not draft */
|
|
if ($this->invoice->status_id != Invoice::STATUS_DRAFT) {
|
|
return $this->invoice;
|
|
}
|
|
|
|
$this->invoice->markInvitationsSent();
|
|
|
|
$this->invoice->setReminder();
|
|
|
|
event(new InvoiceWasMarkedSent($this->invoice, $this->invoice->company));
|
|
|
|
$this->invoice
|
|
->service()
|
|
->setStatus(Invoice::STATUS_SENT)
|
|
->applyNumber()
|
|
->save();
|
|
|
|
$this->client->service()->updateBalance($this->invoice->balance)->save();
|
|
|
|
$this->invoice->ledger()->updateInvoiceBalance($this->invoice->balance);
|
|
|
|
return $this->invoice;
|
|
}
|
|
}
|