1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00
invoiceninja/app/Services/Invoice/MarkSent.php
David Bomba 3ec996ee5d
Invoice Designer (#3283)
* Working self-updater package

* Fixes for travis

* Working on invoice designs

* Working on invoice builder

* Tests for invoice design

* Working on invoice designs

* Minor fixes

* Minor fixes for randomdataseeder
2020-02-05 15:06:03 +11:00

52 lines
1.2 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\Jobs\Company\UpdateCompanyLedgerWithInvoice;
use App\Models\Invoice;
class MarkSent
{
private $client;
public function __construct($client)
{
$this->client = $client;
}
public function __invoke($invoice)
{
/* Return immediately if status is not draft */
if ($invoice->status_id != Invoice::STATUS_DRAFT) {
return $invoice;
}
$invoice->markInvitationsSent();
$invoice->setReminder();
event(new InvoiceWasMarkedSent($invoice, $invoice->company));
$this->client->service()->updateBalance($invoice->balance)->save();
$invoice->service()->setStatus(Invoice::STATUS_SENT)->applyNumber()->save();
UpdateCompanyLedgerWithInvoice::dispatchNow($invoice, $invoice->balance, $invoice->company);
return $invoice;
}
}