1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00
invoiceninja/app/Services/Invoice/UpdateBalance.php
Benjamin Beganović 7dd6f814ac
Change 'Quote' & 'Invoice' service implementation (#3327)
* Change '__invoke' to 'run' for Invoice services

*  Change '__invoke' to 'run' for Quote services
2020-02-14 14:32:22 +11:00

48 lines
946 B
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\Models\Invoice;
class UpdateBalance
{
private $invoice;
public function __construct($invoice)
{
$this->invoice = $invoice;
}
public function run($balance_adjustment)
{
if ($this->invoice->is_deleted) {
return;
}
$balance_adjustment = floatval($balance_adjustment);
$this->invoice->balance += $balance_adjustment;
if ($this->invoice->balance == 0) {
$this->status_id = Invoice::STATUS_PAID;
// $this->save();
// event(new InvoiceWasPaid($this, $this->company));
}
return $this->invoice;
}
}