mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-09-24 02:11:34 +02:00
ac0d63b0b2
* Skip preview tests * Fixes for product test * Fixes for tests * Update README.md * Update README.md * Update README.md * Update README.md * Fixes for incorrect payment types * Refactor class nameS * Entity Notification refactor * Entity Notifications * Add oauth_provider to User transformer * Invoices can only be deleted in the balance in zero
45 lines
1.2 KiB
PHP
45 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\Utils\Traits\Invoice;
|
|
|
|
use App\Models\Invoice;
|
|
|
|
trait ActionsInvoice
|
|
{
|
|
public function invoiceDeletable($invoice) :bool
|
|
{
|
|
if ($invoice->status_id <= Invoice::STATUS_SENT && $invoice->is_deleted == false && $invoice->deleted_at == null && $invoice->balance == 0) {
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public function invoiceCancellable($invoice) :bool
|
|
{
|
|
if (($invoice->status_id == Invoice::STATUS_SENT || $invoice->status_id == Invoice::STATUS_PARTIAL) && $invoice->is_deleted == false && $invoice->deleted_at == null) {
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public function invoiceReversable($invoice) :bool
|
|
{
|
|
if (($invoice->status_id == Invoice::STATUS_SENT || $invoice->status_id == Invoice::STATUS_PARTIAL || $invoice->status_id == Invoice::STATUS_PAID) && $invoice->is_deleted == false && $invoice->deleted_at == null) {
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|