Creation and editing of events
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Resources;
|
||||
|
||||
use App\Enumerations\InvoiceStatus;
|
||||
use App\Enumerations\InvoiceType;
|
||||
use App\Models\CostUnit;
|
||||
use App\Repositories\CostUnitRepository;
|
||||
use App\ValueObjects\Amount;
|
||||
@@ -28,6 +29,14 @@ class CostUnitResource {
|
||||
$countDonatedInvoices = $countInvoices[InvoiceStatus::INVOICE_META_STATUS_DONATED];
|
||||
$countDeniedInvoices = $countInvoices[InvoiceStatus::INVOICE_STATUS_DENIED];
|
||||
|
||||
$amounts = [];
|
||||
$overAllAmount = new Amount(0, 'Euro');
|
||||
foreach (InvoiceType::all() as $invoiceType) {
|
||||
$overAllAmount->addAmount($costUnitRepository->sumupByInvoiceType($this->costUnit, $invoiceType));
|
||||
$amounts[$invoiceType->slug]['string'] = $costUnitRepository->sumupByInvoiceType($this->costUnit, $invoiceType)->toString();
|
||||
$amounts[$invoiceType->slug]['name'] = $invoiceType->name;
|
||||
}
|
||||
|
||||
|
||||
$data = array_merge(
|
||||
$this->costUnit->toArray(),
|
||||
@@ -41,6 +50,8 @@ class CostUnitResource {
|
||||
'countDonatedInvoices' => $countDonatedInvoices,
|
||||
'countDeniedInvoices' => $countDeniedInvoices,
|
||||
'treasurers' => $this->costUnit->treasurers()->get()->map(fn($user) => new UserResource($user))->toArray(),
|
||||
'amounts' => $amounts,
|
||||
'overAllAmount' => ['text' => $overAllAmount->toString(), 'value' => $overAllAmount],
|
||||
]);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user