2020-02-15 10:01:15 +01:00
|
|
|
<?php
|
2020-05-09 00:35:49 +02:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2020-02-15 10:01:15 +01:00
|
|
|
namespace App\Services\Credit;
|
|
|
|
|
2020-02-26 22:21:12 +01:00
|
|
|
use App\Models\Credit;
|
2020-03-03 10:44:26 +01:00
|
|
|
use App\Services\Credit\CreateInvitations;
|
|
|
|
use App\Services\Credit\MarkSent;
|
2020-02-15 10:01:15 +01:00
|
|
|
|
|
|
|
class CreditService
|
|
|
|
{
|
|
|
|
protected $credit;
|
|
|
|
|
|
|
|
public function __construct($credit)
|
|
|
|
{
|
|
|
|
$this->credit = $credit;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCreditPdf($contact)
|
|
|
|
{
|
2020-02-18 21:56:21 +01:00
|
|
|
return (new GetCreditPdf($this->credit, $contact))->run();
|
2020-02-15 10:01:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Applies the invoice number
|
|
|
|
* @return $this InvoiceService object
|
|
|
|
*/
|
|
|
|
public function applyNumber()
|
|
|
|
{
|
2020-02-18 21:56:21 +01:00
|
|
|
$this->credit = (new ApplyNumber($this->credit->client, $this->credit))->run();
|
2020-02-15 10:01:15 +01:00
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function createInvitations()
|
|
|
|
{
|
2020-02-18 21:56:21 +01:00
|
|
|
$this->credit = (new CreateInvitations($this->credit))->run();
|
2020-02-15 10:01:15 +01:00
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2020-03-03 10:44:26 +01:00
|
|
|
public function setStatus($status)
|
|
|
|
{
|
|
|
|
$this->credit->status_id = $status;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function markSent()
|
|
|
|
{
|
2020-03-04 00:51:50 +01:00
|
|
|
$this->credit = (new MarkSent($this->credit->client, $this->credit))->run();
|
2020-03-03 10:44:26 +01:00
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2020-02-15 10:01:15 +01:00
|
|
|
/**
|
|
|
|
* Saves the credit
|
|
|
|
* @return Credit object
|
|
|
|
*/
|
|
|
|
public function save() : ?Credit
|
|
|
|
{
|
|
|
|
$this->credit->save();
|
2020-02-22 03:25:49 +01:00
|
|
|
|
2020-02-15 10:01:15 +01:00
|
|
|
return $this->credit;
|
|
|
|
}
|
|
|
|
}
|