diff --git a/app/Domains/Event/Views/Partials/Overview.vue b/app/Domains/Event/Views/Partials/Overview.vue index 0e28bda..920e544 100644 --- a/app/Domains/Event/Views/Partials/Overview.vue +++ b/app/Domains/Event/Views/Partials/Overview.vue @@ -112,8 +112,8 @@
-
-
+
+

@@ -186,6 +186,7 @@     + Budget bearbeiten Ausgabenübersicht Archivieren
@@ -248,13 +249,13 @@ gap: 10px; /* Abstand zwischen den Spalten */ } -.event-flexbox-row.top .left { +.event-flexbox-row.top .actions-left { flex: 0 0 calc(100% - 300px); padding: 10px; } -.event-flexbox-row.top .right { - flex: 0 0 250px; +.event-flexbox-row.top .actions-right { + flex: 0 0 200px; padding: 10px; } @@ -263,7 +264,7 @@ padding: 10px; } -.event-flexbox-row.top .right input[type="button"] { +.event-flexbox-row.top .actions-right input[type="button"] { width: 100% !important; margin-bottom: 10px; } diff --git a/app/Domains/Event/Views/Partials/ParticipationSummary.vue b/app/Domains/Event/Views/Partials/ParticipationSummary.vue index 3394bd6..3c605bd 100644 --- a/app/Domains/Event/Views/Partials/ParticipationSummary.vue +++ b/app/Domains/Event/Views/Partials/ParticipationSummary.vue @@ -96,19 +96,31 @@ const props = defineProps({ + + Budget + + {{ props.event.totalBalance.estimated.readable }} + + + {{props.event.totalBalance.estimated.readable}} + + +

Ausgaben

- +
+ - + +
{{amount.name}} {{amount.string}}({{ amount.estimatedString }})
Gesamt{{props.event.costUnit.overAllAmount.text}}{{props.event.costUnit.overAllAmount.text}}({{props.event.costUnit.overAllEstimatedAmount.text}}))
@@ -121,7 +133,7 @@ const props = defineProps({ .participant-flexbox { display: flex; flex-direction: column; - gap: 10px; + gap: 20px; width: 95%; margin: 20px auto 0; } @@ -135,7 +147,7 @@ const props = defineProps({ .participant-flexbox-row.top .left, .participant-flexbox-row.top .right { - padding: 10px; + padding: 20px; min-width: 0; } diff --git a/app/Models/CostUnit.php b/app/Models/CostUnit.php index afb66e3..8f82621 100644 --- a/app/Models/CostUnit.php +++ b/app/Models/CostUnit.php @@ -6,6 +6,7 @@ use App\Scopes\InstancedModel; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Database\Eloquent\Relations\HasMany; +use Illuminate\Database\Eloquent\Relations\HasOne; /** * @property string $name @@ -44,7 +45,15 @@ class CostUnit extends InstancedModel return $this->hasMany(Invoice::class); } + public function estimates() : hasMany { + return $this->hasMany(CostUnitEstimate::class); + } + public function tenant() : BelongsTo { return $this->belongsTo(Tenant::class, 'tenant', 'slug'); } + + public function event() : HasOne { + return $this->hasOne(Event::class); + } } diff --git a/app/Repositories/CostUnitRepository.php b/app/Repositories/CostUnitRepository.php index 75df613..a976501 100644 --- a/app/Repositories/CostUnitRepository.php +++ b/app/Repositories/CostUnitRepository.php @@ -178,6 +178,18 @@ class CostUnitRepository { return $amount; } + public function sumupEstimatedByInvoiceType(CostUnit $costUnit, InvoiceType $invoiceType) : Amount { + $amount = new Amount(0, 'Euro'); + foreach ($costUnit->estimates()->get() as $estimate) { + if ($estimate->type !== $invoiceType->slug) { + continue; + } + + $amount->addAmount($estimate->calculateAmount()); + } + return $amount; + } + public function sumupUnhandledAmounts(CostUnit $costUnit, bool $donatedAmount = false) : Amount { $amount = new Amount(0, ''); diff --git a/app/Resources/CostUnitResource.php b/app/Resources/CostUnitResource.php index 1799798..15d156c 100644 --- a/app/Resources/CostUnitResource.php +++ b/app/Resources/CostUnitResource.php @@ -31,10 +31,15 @@ class CostUnitResource { $amounts = []; $overAllAmount = new Amount(0, 'Euro'); + $overAllEstimatedAmount = new Amount(0, 'Euro'); foreach (InvoiceType::orderBy('sort_order')->get() as $invoiceType) { $overAllAmount->addAmount($costUnitRepository->sumupByInvoiceType($this->costUnit, $invoiceType)); + $overAllEstimatedAmount->addAmount($costUnitRepository->sumupEstimatedByInvoiceType($this->costUnit, $invoiceType)); $amounts[$invoiceType->slug]['string'] = $costUnitRepository->sumupByInvoiceType($this->costUnit, $invoiceType)->toString(); $amounts[$invoiceType->slug]['name'] = $invoiceType->name; + $amounts[$invoiceType->slug]['estimated'] = $costUnitRepository->sumupEstimatedByInvoiceType($this->costUnit, $invoiceType); + $amounts[$invoiceType->slug]['estimatedString'] = $costUnitRepository->sumupEstimatedByInvoiceType($this->costUnit, $invoiceType)->toString(); + } @@ -52,6 +57,7 @@ class CostUnitResource { 'treasurers' => $this->costUnit->treasurers()->get()->map(fn($user) => new UserResource($user))->toArray(), 'amounts' => $amounts, 'overAllAmount' => ['text' => $overAllAmount->toString(), 'value' => $overAllAmount], + 'overAllEstimatedAmount' => ['text' => $overAllEstimatedAmount->toString(), 'value' => $overAllEstimatedAmount], ]); diff --git a/app/Resources/EventResource.php b/app/Resources/EventResource.php index 14bb4cf..ca7428a 100644 --- a/app/Resources/EventResource.php +++ b/app/Resources/EventResource.php @@ -86,6 +86,7 @@ class EventResource extends JsonResource{ $returnArray['eventEnd'] = $this->event->end_date->format('d.m.Y'); $returnArray['eventEndInternal'] = $this->event->end_date; $returnArray['duration'] = $duration; + $returnArray['totalParticipantCount'] = $this->event->participants()->count(); $returnArray['supportPersonIndex'] = $this->event->support_per_person->toString(); $returnArray['supportPerson'] = $this->calculateSupportPerPerson($returnArray['participants']); @@ -95,12 +96,15 @@ class EventResource extends JsonResource{ $totalBalanceReal = new Amount(0, 'Euro'); $totalBalanceExpected = new Amount(0, 'Euro'); + $totalBalanceEstimated = new Amount(0, 'Euro'); $totalBalanceReal->addAmount($returnArray['income']['real']['amount']); $totalBalanceExpected->addAmount($returnArray['income']['expected']['amount']); + $totalBalanceEstimated->addAmount($returnArray['income']['expected']['amount']); $totalBalanceReal->subtractAmount($returnArray['costUnit']['overAllAmount']['value']); $totalBalanceExpected->subtractAmount($returnArray['costUnit']['overAllAmount']['value']); + $totalBalanceEstimated->subtractAmount($returnArray['costUnit']['overAllEstimatedAmount']['value']); $returnArray['totalBalance'] = [ 'real' => [ 'value' => $totalBalanceReal->getAmount(), @@ -108,7 +112,11 @@ class EventResource extends JsonResource{ ], 'expected' => [ 'value' => $totalBalanceExpected->getAmount(), 'readable' => $totalBalanceExpected->toString(), - ] + ], + 'estimated' => [ + 'value' => $totalBalanceEstimated->getAmount(), + 'readable' => $totalBalanceEstimated->toString(), + ] ]; $returnArray['flatSupport'] = $this->event->support_flat->toString(); diff --git a/app/Scopes/CommonController.php b/app/Scopes/CommonController.php index a1bb05d..dd0efae 100644 --- a/app/Scopes/CommonController.php +++ b/app/Scopes/CommonController.php @@ -5,6 +5,7 @@ namespace App\Scopes; use App\Models\Tenant; use App\Providers\AuthCheckProvider; use App\Repositories\CostUnitRepository; +use App\Repositories\EstimatesRepository; use App\Repositories\EventParticipantRepository; use App\Repositories\EventRepository; use App\Repositories\InvoiceRepository; @@ -21,6 +22,7 @@ abstract class CommonController { protected InvoiceRepository $invoices; protected EventRepository $events; protected EventParticipantRepository $eventParticipants; + protected EstimatesRepository $estimates; public function __construct() { $this->tenant = app('tenant'); @@ -30,6 +32,7 @@ abstract class CommonController { $this->invoices = new InvoiceRepository(); $this->events = new EventRepository(); $this->eventParticipants = new EventParticipantRepository(); + $this->estimates = new EstimatesRepository(); } protected function checkAuth() { diff --git a/routes/web.php b/routes/web.php index bbbd546..e521279 100644 --- a/routes/web.php +++ b/routes/web.php @@ -21,6 +21,8 @@ require_once __DIR__ . '/../app/Domains/Invoice/Routes/web.php'; require_once __DIR__ . '/../app/Domains/Invoice/Routes/api.php'; require_once __DIR__ . '/../app/Domains/Event/Routes/web.php'; require_once __DIR__ . '/../app/Domains/Event/Routes/api.php'; +require_once __DIR__ . '/../app/Domains/Budget/Routes/web.php'; +require_once __DIR__ . '/../app/Domains/Budget/Routes/api.php'; Route::get('/LKvDUqWl', function () {