1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-21 08:51:34 +02:00
invoiceninja/app/Services/Invoice/MarkSent.php
David Bomba 43e57d0117
Fixes for self-update (#3514)
* minor fix for payment notifications

* styleci

* Limit Self updating to self hosters only
:

* Fixes for designs

* Minor fixes for self-update
2020-03-21 16:37:30 +11:00

55 lines
1.4 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);
//UpdateCompanyLedgerWithInvoice::dispatchNow($this->invoice, $this->invoice->balance, $this->invoice->company);
return $this->invoice;
}
}