-
+
+
+
+
+
+
+ | Beginn |
+ {{ dynamicProps.event.eventBegin }} |
+
+
+
+ | Ende |
+ {{ dynamicProps.event.eventEnd }} |
+
+
+
+ | Anmeldeschluss |
+ {{dynamicProps.event.earlyBirdEnd.formatted}} |
+
+
+
+ | Nachmeldeschluss |
+ {{dynamicProps.event.registrationFinalEnd.formatted}} |
+
+
+
+ | Anmelde-URL |
+
+ {{dynamicProps.event.url}}
+
+ |
+
+
+
+
diff --git a/app/Http/Controllers/EventCodeGetController.php b/app/Http/Controllers/EventCodeGetController.php
new file mode 100644
index 0000000..b5fe6b4
--- /dev/null
+++ b/app/Http/Controllers/EventCodeGetController.php
@@ -0,0 +1,19 @@
+createQrCode($request), 200,
+ ['Content-Type' => 'image/png']
+ );
+ }
+}
diff --git a/app/Providers/QrCodeUrlProvider.php b/app/Providers/QrCodeUrlProvider.php
new file mode 100644
index 0000000..e467a1c
--- /dev/null
+++ b/app/Providers/QrCodeUrlProvider.php
@@ -0,0 +1,18 @@
+getByIdentifier($this->url, false)->toResource()->toArray($request);
+ return
+ QrCode::format('png')->size(300)->generate($event['url']);
+ }
+}
diff --git a/app/Resources/EventParticipantResource.php b/app/Resources/EventParticipantResource.php
index 13106e5..526f290 100644
--- a/app/Resources/EventParticipantResource.php
+++ b/app/Resources/EventParticipantResource.php
@@ -22,9 +22,19 @@ class EventParticipantResource extends JsonResource
$amountLeft->subtractAmount($this->resource->amount_paid);
}
+ $presenceDays = $this->resource->arrival_date->diff($this->resource->departure_date)->days;
+ $presenceDaysSupport = $presenceDays;
+
+ if ($presenceDaysSupport === 0) {
+ $presenceDaysSupport = 1;
+ } else {
+ $presenceDaysSupport = $presenceDaysSupport - 1;
+ }
+
return array_merge(
$this->resource->toArray(),
[
+ 'presenceDays' => ['real' => $presenceDays, 'support' => $presenceDaysSupport],
'participationType' => ParticipationType::where(['slug' => $this->resource->participation_type])->first()->name,
'needs_payment' => $this->resource->amount->getAmount() > 0 && $event->pay_direct,
'nicename' => $this->resource->getNicename(),
diff --git a/app/Resources/EventResource.php b/app/Resources/EventResource.php
index 4f3748e..cb9210c 100644
--- a/app/Resources/EventResource.php
+++ b/app/Resources/EventResource.php
@@ -3,6 +3,7 @@
namespace App\Resources;
use App\Enumerations\ParticipationFeeType;
+use App\Enumerations\ParticipationType;
use App\Models\Event;
use App\ValueObjects\Amount;
use DateTime;
@@ -24,6 +25,7 @@ class EventResource extends JsonResource{
'id' => $this->event->id,
'name' => $this->event->name,
'identifier' => $this->event->identifier,
+ 'url' => 'https://' . app('tenant')->url . '/event/' . $this->event->identifier . '/signup',
'location' => $this->event->location,
'postalCode' => $this->event->postal_code,
'email' => $this->event->email,
@@ -56,6 +58,18 @@ class EventResource extends JsonResource{
->toArray();
+ foreach ([
+ ParticipationType::PARTICIPATION_TYPE_PARTICIPANT,
+ ParticipationType::PARTICIPATION_TYPE_TEAM,
+ ParticipationType::PARTICIPATION_TYPE_VOLUNTEER,
+ ParticipationType::PARTICIPATION_TYPE_OTHER,
+ ] as $participationType) {
+ $returnArray['participants'][$participationType] = $this->getParticipants($participationType);
+ }
+
+
+
+
$returnArray['costUnit'] = new CostUnitResource($this->event->costUnit()->first())->toArray(true);
$returnArray['solidarityPayment'] = $this->event->participation_fee_type === ParticipationFeeType::PARTICIPATION_FEE_TYPE_SOLIDARITY;
$returnArray['payPerDay'] = $this->event->pay_per_day;
@@ -65,15 +79,33 @@ class EventResource extends JsonResource{
$returnArray['eventEnd'] = $this->event->end_date->format('d.m.Y');
$returnArray['eventEndInternal'] = $this->event->end_date;
$returnArray['duration'] = $duration;
-#
- $totalBalance = new Amount(0, 'Euro');
- $totalBalance->addAmount($this->calculateIncomes());
- $totalBalance->subtractAmount($returnArray['costUnit']['overAllAmount']['value']);
- $returnArray['totalIncome'] = $this->calculateIncomes()->toString();
- $returnArray['totalBalance'] = ['text' => $totalBalance->toString(), 'value' => $totalBalance->getAmount()];
+ $returnArray['supportPersonIndex'] = $this->event->support_per_person->toString();
+ $returnArray['supportPerson'] = $this->calculateSupportPerPerson($returnArray['participants']);
+
+ $returnArray['income'] = $this->calculateIncomes($returnArray['participants'], $returnArray['supportPerson']['amount']);
+
+
+ $totalBalanceReal = new Amount(0, 'Euro');
+ $totalBalanceExpected = new Amount(0, 'Euro');
+
+ $totalBalanceReal->addAmount($returnArray['income']['real']['amount']);
+ $totalBalanceExpected->addAmount($returnArray['income']['expected']['amount']);
+
+ $totalBalanceReal->subtractAmount($returnArray['costUnit']['overAllAmount']['value']);
+ $totalBalanceExpected->subtractAmount($returnArray['costUnit']['overAllAmount']['value']);
+
+ $returnArray['totalBalance'] = [
+ 'real' => [
+ 'value' => $totalBalanceReal->getAmount(),
+ 'readable' => $totalBalanceReal->toString(),
+ ], 'expected' => [
+ 'value' => $totalBalanceExpected->getAmount(),
+ 'readable' => $totalBalanceExpected->toString(),
+ ]
+ ];
+
$returnArray['flatSupport'] = $this->event->support_flat->toString();
- $returnArray['supportPerson'] = $this->event->support_per_person->toString();
$returnArray['flatSupportEdit'] = $this->event->support_flat->getFormattedAmount();
$returnArray['supportPersonEdit'] = $this->event->support_per_person->getFormattedAmount();
@@ -161,12 +193,106 @@ class EventResource extends JsonResource{
return 1 + $this->event->early_bird_end_amount_increase / 100;
}
- public function calculateIncomes() : Amount {
- $amount = new Amount(0, 'Euro');
- $amount->addAmount($this->event->support_flat);
- return $amount;
+ public function calculateSupportPerPerson(array $participants) : array {
+ if ($this->event->support_per_person === null) {
+ return [
+ 'amount' => new Amount(0, 'Euro'),
+ 'readable' => '0,00'
+ ];
+ }
+
+ $amount = $this->event->support_per_person;
+ $multiplier = 0;
+
+
+
+ foreach ($participants as $participationType => $participantData) {
+ if (isset($participantData['participants']) && count($participantData['participants']) > 0) {
+ foreach ($participantData['participants'] as $participant) {
+ $multiplier += $participant->toResource()->toArray(new Request())['presenceDays']['support'];
+ }
+ }
+ }
+
+ $amount->multiply($multiplier);
+
+ return [
+ 'amount' => $amount,
+ 'readable' => $amount->toString()
+ ];
+
+
}
+ public function calculateIncomes(array $participants, Amount $supportPerPerson) : array {
+ $expectedAmount = $supportPerPerson;
+ $expectedAmount->addAmount($this->event->support_flat);
+
+ $realAmount = $supportPerPerson;
+ $realAmount->addAmount($this->event->support_flat);
+
+
+ foreach ($participants as $participationType => $participantData) {
+ $expectedAmount->addAmount(new Amount($participantData['amount']['expected']['value'], 'Euro'));
+ $realAmount->addAmount(new Amount($participantData['amount']['paid']['value'], 'Euro'));
+ }
+
+
+
+ return ['real' => [
+ 'amount' => $realAmount,
+ 'readable' => $realAmount->toString()
+ ],
+ 'expected' => [
+ 'amount' => $expectedAmount,
+ 'readable' => $expectedAmount->toString(),
+ ]
+ ];
+ }
+
+ public function getParticipants(string $participationType) : array {
+ $returnData = [];
+ $returnData['amount'] = ['expected' => new Amount(0, 'Euro'), 'paid' => new Amount(0, 'Euro')];
+ $returnData['count'] = 0;
+
+ foreach ($this->event->participants()->where(
+ [
+ 'participation_type' => $participationType,
+ 'unregistered_at' => null
+ ]
+
+ )->get() as $participant)
+ {
+ $returnData['count']++;
+ $returnData['participants'][] = $participant;
+
+ if ($participant->amount !== null) {
+ $returnData['amount']['expected'] = $returnData['amount']['expected']->addAmount($participant->amount);
+ }
+
+ if ($participant->amount_paid !== null) {
+ $returnData['amount']['paid'] = $returnData['amount']['paid']->addAmount($participant->amount_paid);
+ }
+
+ };
+
+ $returnData['amount']['expected'] =
+ [
+ 'value' => $returnData['amount']['expected']->getAmount(),
+ 'readable' => $returnData['amount']['expected']->toString()
+ ];
+
+ $returnData['amount']['paid'] =
+ [
+ 'value' => $returnData['amount']['paid']->getAmount(),
+ 'readable' => $returnData['amount']['paid']->toString()
+ ];
+
+
+ return $returnData;
+ }
+
+
public function calculateAmount(
string $participationType,
string $feeType,
diff --git a/app/ValueObjects/Amount.php b/app/ValueObjects/Amount.php
index 97e154e..747fab4 100644
--- a/app/ValueObjects/Amount.php
+++ b/app/ValueObjects/Amount.php
@@ -37,8 +37,9 @@ class Amount {
|> function (string $value) : string { return str_replace('.', ',', $value); };
}
- public function addAmount(Amount $amount) : void {
+ public function addAmount(Amount $amount) : Amount {
$this->amount += $amount->getAmount();
+ return $this;
}
public function subtractAmount(Amount $amount) : void {
diff --git a/routes/web.php b/routes/web.php
index cdbd393..e73d547 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -1,6 +1,7 @@
group(function () {
Route::get('/', DashboardController::class);