-
app/Enums/InvoiceStatus.php
Open in GitHubclass InvoiceStatus { private const DRAFT = 'draft'; private const CLOSED = 'closed'; private const SENT = 'sent'; private const UNPAID = 'unpaid'; private const PARTIAL_PAID = 'partial_paid'; private const PAID = 'paid'; private const OVERPAID = 'overpaid'; // }
-
app/Services/Invoice/GenerateInvoiceStatus.php
Open in GitHubuse App\Enums\InvoiceStatus; use App\Models\Invoice; use App\Repositories\Money\Money; class GenerateInvoiceStatus { // public function getStatus() { if ($this->isDraft()) { return InvoiceStatus::draft()->getStatus(); } if ($this->isUnPaid()) { return InvoiceStatus::unpaid()->getStatus(); } if ($this->isPaid()) { return InvoiceStatus::paid()->getStatus(); } if ($this->isPartialPaid()) { return InvoiceStatus::partialPaid()->getStatus(); } if ($this->isOverPaid()) { return InvoiceStatus::overpaid()->getStatus(); } throw new \Exception("Can't generate invoice status for invoice: " . $this->invoice->id); } // }