Skip to content

Commit 0604787

Browse files
committed
Add offline payment support to the check in tool + Add invoicing support
1 parent c6acd75 commit 0604787

File tree

84 files changed

+11041
-416
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+11041
-416
lines changed

backend/app/DomainObjects/AttendeeDomainObject.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public static function getAllowedSorts(): AllowedSorts
2929
[
3030
self::CREATED_AT => [
3131
'asc' => __('Older First'),
32-
'desc' => __('Newer First'),
32+
'desc' => __('Newest First'),
3333
],
3434
self::UPDATED_AT => [
3535
'desc' => __('Recently Updated First'),
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace HiEvents\DomainObjects\Enums;
4+
5+
enum AttendeeCheckInActionType: string
6+
{
7+
use BaseEnum;
8+
9+
case CHECK_IN = 'check-in';
10+
case CHECK_IN_AND_MARK_ORDER_AS_PAID = 'check-in-and-mark-order-as-paid';
11+
}

backend/app/DomainObjects/Generated/EventSettingDomainObjectAbstract.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ abstract class EventSettingDomainObjectAbstract extends \HiEvents\DomainObjects\
5555
final public const TAX_DETAILS = 'tax_details';
5656
final public const PAYMENT_PROVIDERS = 'payment_providers';
5757
final public const OFFLINE_PAYMENT_INSTRUCTIONS = 'offline_payment_instructions';
58+
final public const ALLOW_ORDERS_AWAITING_OFFLINE_PAYMENT_TO_CHECK_IN = 'allow_orders_awaiting_offline_payment_to_check_in';
5859

5960
protected int $id;
6061
protected int $event_id;
@@ -101,6 +102,7 @@ abstract class EventSettingDomainObjectAbstract extends \HiEvents\DomainObjects\
101102
protected ?string $tax_details = null;
102103
protected array|string|null $payment_providers = null;
103104
protected ?string $offline_payment_instructions = null;
105+
protected bool $allow_orders_awaiting_offline_payment_to_check_in = false;
104106

105107
public function toArray(): array
106108
{
@@ -150,6 +152,7 @@ public function toArray(): array
150152
'tax_details' => $this->tax_details ?? null,
151153
'payment_providers' => $this->payment_providers ?? null,
152154
'offline_payment_instructions' => $this->offline_payment_instructions ?? null,
155+
'allow_orders_awaiting_offline_payment_to_check_in' => $this->allow_orders_awaiting_offline_payment_to_check_in ?? null,
153156
];
154157
}
155158

@@ -647,4 +650,16 @@ public function getOfflinePaymentInstructions(): ?string
647650
{
648651
return $this->offline_payment_instructions;
649652
}
653+
654+
public function setAllowOrdersAwaitingOfflinePaymentToCheckIn(
655+
bool $allow_orders_awaiting_offline_payment_to_check_in,
656+
): self {
657+
$this->allow_orders_awaiting_offline_payment_to_check_in = $allow_orders_awaiting_offline_payment_to_check_in;
658+
return $this;
659+
}
660+
661+
public function getAllowOrdersAwaitingOfflinePaymentToCheckIn(): bool
662+
{
663+
return $this->allow_orders_awaiting_offline_payment_to_check_in;
664+
}
650665
}

backend/app/DomainObjects/Generated/InvoiceDomainObjectAbstract.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ abstract class InvoiceDomainObjectAbstract extends \HiEvents\DomainObjects\Abstr
1313
final public const ID = 'id';
1414
final public const ORDER_ID = 'order_id';
1515
final public const ACCOUNT_ID = 'account_id';
16-
final public const USER_ID = 'user_id';
1716
final public const INVOICE_NUMBER = 'invoice_number';
1817
final public const ISSUE_DATE = 'issue_date';
1918
final public const DUE_DATE = 'due_date';
@@ -29,7 +28,6 @@ abstract class InvoiceDomainObjectAbstract extends \HiEvents\DomainObjects\Abstr
2928
protected int $id;
3029
protected int $order_id;
3130
protected int $account_id;
32-
protected int $user_id;
3331
protected string $invoice_number;
3432
protected string $issue_date = 'CURRENT_TIMESTAMP';
3533
protected ?string $due_date = null;
@@ -48,7 +46,6 @@ public function toArray(): array
4846
'id' => $this->id ?? null,
4947
'order_id' => $this->order_id ?? null,
5048
'account_id' => $this->account_id ?? null,
51-
'user_id' => $this->user_id ?? null,
5249
'invoice_number' => $this->invoice_number ?? null,
5350
'issue_date' => $this->issue_date ?? null,
5451
'due_date' => $this->due_date ?? null,
@@ -96,17 +93,6 @@ public function getAccountId(): int
9693
return $this->account_id;
9794
}
9895

99-
public function setUserId(int $user_id): self
100-
{
101-
$this->user_id = $user_id;
102-
return $this;
103-
}
104-
105-
public function getUserId(): int
106-
{
107-
return $this->user_id;
108-
}
109-
11096
public function setInvoiceNumber(string $invoice_number): self
11197
{
11298
$this->invoice_number = $invoice_number;

backend/app/DomainObjects/InvoiceDomainObject.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,31 @@
44

55
class InvoiceDomainObject extends Generated\InvoiceDomainObjectAbstract
66
{
7+
public ?OrderDomainObject $order = null;
8+
9+
public ?EventDomainObject $event = null;
10+
11+
public function getOrder(): ?OrderDomainObject
12+
{
13+
return $this->order;
14+
}
15+
16+
public function setOrder(?OrderDomainObject $order): self
17+
{
18+
$this->order = $order;
19+
20+
return $this;
21+
}
22+
23+
public function getEvent(): ?EventDomainObject
24+
{
25+
return $this->event;
26+
}
27+
28+
public function setEvent(?EventDomainObject $event): self
29+
{
30+
$this->event = $event;
31+
32+
return $this;
33+
}
734
}

backend/app/DomainObjects/OrderDomainObject.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use HiEvents\DomainObjects\Status\OrderPaymentStatus;
1010
use HiEvents\DomainObjects\Status\OrderStatus;
1111
use HiEvents\Helper\AddressHelper;
12+
use Illuminate\Support\Carbon;
1213
use Illuminate\Support\Collection;
1314

1415
class OrderDomainObject extends Generated\OrderDomainObjectAbstract implements IsSortable, IsFilterable
@@ -24,6 +25,8 @@ class OrderDomainObject extends Generated\OrderDomainObjectAbstract implements I
2425
/** @var Collection<QuestionAndAnswerViewDomainObject>|null */
2526
public ?Collection $questionAndAnswerViews = null;
2627

28+
public ?Collection $invoices = null;
29+
2730
public ?EventDomainObject $event = null;
2831

2932
public static function getAllowedFilterFields(): array
@@ -152,6 +155,16 @@ public function isOrderCancelled(): bool
152155
return $this->getStatus() === OrderStatus::CANCELLED->name;
153156
}
154157

158+
public function isOrderReserved(): bool
159+
{
160+
return $this->getStatus() === OrderStatus::RESERVED->name;
161+
}
162+
163+
public function isReservedOrderExpired(): bool
164+
{
165+
return (new Carbon($this->getReservedUntil()))->isPast();
166+
}
167+
155168
public function isOrderFailed(): bool
156169
{
157170
return $this->getPaymentStatus() === OrderPaymentStatus::PAYMENT_FAILED->name;
@@ -183,6 +196,21 @@ public function getBillingAddressString(): string
183196
return AddressHelper::formatAddress($this->getAddress());
184197
}
185198

199+
public function getHasTaxes(): bool
200+
{
201+
return $this->getTotalTax() > 0;
202+
}
203+
204+
public function getHasFees(): bool
205+
{
206+
return $this->getTotalFee() > 0;
207+
}
208+
209+
public function getLatestInvoice(): ?InvoiceDomainObject
210+
{
211+
return $this->getInvoices()?->sortByDesc(fn(InvoiceDomainObject $invoice) => $invoice->getId())->first();
212+
}
213+
186214
public function getStripePayment(): ?StripePaymentDomainObject
187215
{
188216
return $this->stripePayment;
@@ -214,4 +242,15 @@ public function getEvent(): ?EventDomainObject
214242
{
215243
return $this->event;
216244
}
245+
246+
public function setInvoices(?Collection $invoices): OrderDomainObject
247+
{
248+
$this->invoices = $invoices;
249+
return $this;
250+
}
251+
252+
public function getInvoices(): ?Collection
253+
{
254+
return $this->invoices;
255+
}
217256
}

backend/app/DomainObjects/Status/AttendeeStatus.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ enum AttendeeStatus
99
use BaseEnum;
1010

1111
case ACTIVE;
12+
case AWAITING_PAYMENT;
1213
case CANCELLED;
1314
}

backend/app/Events/OrderStatusChangedEvent.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class OrderStatusChangedEvent
1212
public function __construct(
1313
public OrderDomainObject $order,
1414
public bool $sendEmails = true,
15+
public bool $createInvoice = false,
1516
)
1617
{
1718
}

backend/app/Helper/Url.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ public static function getFrontEndUrlFromConfig(string $key, array $queryParams
2222
return self::addQueryParamsToUrl($queryParams, $url);
2323
}
2424

25+
public static function getApiUrl(string $path, array $queryParams = []): string
26+
{
27+
$url = rtrim(config('app.api_url'), '/') . '/' . ltrim($path, '/');
28+
29+
return self::addQueryParamsToUrl($queryParams, $url);
30+
}
31+
2532
public static function getCdnUrl(string $path): string
2633
{
2734
return config('app.cnd_url') . '/' . $path;

backend/app/Http/Actions/CheckInLists/Public/CreateAttendeeCheckInPublicAction.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ public function __invoke(
2525
): JsonResponse
2626
{
2727
try {
28-
$checkIns = $this->createAttendeeCheckInPublicHandler->handle(new CreateAttendeeCheckInPublicDTO(
29-
checkInListUuid: $checkInListUuid,
30-
checkInUserIpAddress: $request->ip(),
31-
attendeePublicIds: $request->validated('attendee_public_ids'),
32-
));
28+
$checkIns = $this->createAttendeeCheckInPublicHandler->handle(CreateAttendeeCheckInPublicDTO::from([
29+
'checkInListUuid' => $checkInListUuid,
30+
'checkInUserIpAddress' => $request->ip(),
31+
'attendeesAndActions' => $request->validated('attendees'),
32+
]));
3333
} catch (CannotCheckInException $e) {
3434
return $this->errorResponse(
3535
message: $e->getMessage(),

0 commit comments

Comments
 (0)