Managing own invoices
This commit is contained in:
@@ -13,9 +13,9 @@ use Illuminate\Database\Eloquent\Collection;
|
||||
class InvoiceRepository {
|
||||
public function getMyInvoicesWidget() : array {
|
||||
$invoices = [
|
||||
InvoiceStatus::INVOICE_STATUS_NEW => ['slug' => 'new', 'title' => 'Neue Abrechnungen', 'count' => 0, 'amount' => Amount::fromString('0')->toString()],
|
||||
InvoiceStatus::INVOICE_STATUS_APPROVED => ['slug' => 'approved', 'title' => 'Freigegebene Abrechnungen', 'count' => 0, 'amount' => Amount::fromString('0')->toString()],
|
||||
InvoiceStatus::INVOICE_STATUS_DENIED => ['slug' => 'declined', 'title' => 'Abgelehnte Abrechnungen', 'count' => 0, 'amount' => Amount::fromString('0')->toString()]
|
||||
InvoiceStatus::INVOICE_STATUS_NEW => ['slug' => InvoiceStatus::INVOICE_STATUS_NEW, 'title' => 'Neue Abrechnungen', 'count' => 0, 'amount' => Amount::fromString('0')->toString()],
|
||||
InvoiceStatus::INVOICE_STATUS_APPROVED => ['slug' => InvoiceStatus::INVOICE_STATUS_APPROVED, 'title' => 'Freigegebene Abrechnungen', 'count' => 0, 'amount' => Amount::fromString('0')->toString()],
|
||||
InvoiceStatus::INVOICE_STATUS_DENIED => ['slug' => InvoiceStatus::INVOICE_STATUS_DENIED, 'title' => 'Abgelehnte Abrechnungen', 'count' => 0, 'amount' => Amount::fromString('0')->toString()]
|
||||
];
|
||||
|
||||
|
||||
@@ -48,6 +48,21 @@ class InvoiceRepository {
|
||||
return $returnData;
|
||||
}
|
||||
|
||||
public function getMyInvoicesByStatus(string $status) : array {
|
||||
$returnData = [];
|
||||
foreach (Invoice::where(
|
||||
[
|
||||
'status' => $status,
|
||||
'user_id' => auth()->user()->id,
|
||||
'tenant' => app('tenant')->slug,
|
||||
|
||||
]
|
||||
)->get() as $invoice) {
|
||||
$returnData[] = new InvoiceResource($invoice)->toArray();
|
||||
};
|
||||
return $returnData;
|
||||
}
|
||||
|
||||
public function getAsTreasurer(int $invoiceId) : ?Invoice {
|
||||
$invoice = Invoice::where('id', $invoiceId)->first();
|
||||
if ($invoice === null) {
|
||||
|
||||
Reference in New Issue
Block a user