Skip to content

Commit 96c766a

Browse files
committed
Add notes to invoices
1 parent 195acba commit 96c766a

38 files changed

+622
-302
lines changed

backend/app/DomainObjects/Generated/EventSettingDomainObjectAbstract.php

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,12 @@ abstract class EventSettingDomainObjectAbstract extends \HiEvents\DomainObjects\
5252
final public const REQUIRE_BILLING_ADDRESS = 'require_billing_address';
5353
final public const ORGANIZATION_NAME = 'organization_name';
5454
final public const ORGANIZATION_ADDRESS = 'organization_address';
55-
final public const TAX_DETAILS = 'tax_details';
55+
final public const INVOICE_TAX_DETAILS = 'invoice_tax_details';
5656
final public const PAYMENT_PROVIDERS = 'payment_providers';
5757
final public const OFFLINE_PAYMENT_INSTRUCTIONS = 'offline_payment_instructions';
5858
final public const ALLOW_ORDERS_AWAITING_OFFLINE_PAYMENT_TO_CHECK_IN = 'allow_orders_awaiting_offline_payment_to_check_in';
59+
final public const INVOICE_PAYMENT_TERMS_DAYS = 'invoice_payment_terms_days';
60+
final public const INVOICE_NOTES = 'invoice_notes';
5961

6062
protected int $id;
6163
protected int $event_id;
@@ -99,10 +101,12 @@ abstract class EventSettingDomainObjectAbstract extends \HiEvents\DomainObjects\
99101
protected bool $require_billing_address = true;
100102
protected ?string $organization_name = null;
101103
protected ?string $organization_address = null;
102-
protected ?string $tax_details = null;
104+
protected ?string $invoice_tax_details = null;
103105
protected array|string|null $payment_providers = null;
104106
protected ?string $offline_payment_instructions = null;
105107
protected bool $allow_orders_awaiting_offline_payment_to_check_in = false;
108+
protected ?int $invoice_payment_terms_days = null;
109+
protected ?string $invoice_notes = null;
106110

107111
public function toArray(): array
108112
{
@@ -149,10 +153,12 @@ public function toArray(): array
149153
'require_billing_address' => $this->require_billing_address ?? null,
150154
'organization_name' => $this->organization_name ?? null,
151155
'organization_address' => $this->organization_address ?? null,
152-
'tax_details' => $this->tax_details ?? null,
156+
'invoice_tax_details' => $this->invoice_tax_details ?? null,
153157
'payment_providers' => $this->payment_providers ?? null,
154158
'offline_payment_instructions' => $this->offline_payment_instructions ?? null,
155159
'allow_orders_awaiting_offline_payment_to_check_in' => $this->allow_orders_awaiting_offline_payment_to_check_in ?? null,
160+
'invoice_payment_terms_days' => $this->invoice_payment_terms_days ?? null,
161+
'invoice_notes' => $this->invoice_notes ?? null,
156162
];
157163
}
158164

@@ -618,15 +624,15 @@ public function getOrganizationAddress(): ?string
618624
return $this->organization_address;
619625
}
620626

621-
public function setTaxDetails(?string $tax_details): self
627+
public function setInvoiceTaxDetails(?string $invoice_tax_details): self
622628
{
623-
$this->tax_details = $tax_details;
629+
$this->invoice_tax_details = $invoice_tax_details;
624630
return $this;
625631
}
626632

627-
public function getTaxDetails(): ?string
633+
public function getInvoiceTaxDetails(): ?string
628634
{
629-
return $this->tax_details;
635+
return $this->invoice_tax_details;
630636
}
631637

632638
public function setPaymentProviders(array|string|null $payment_providers): self
@@ -662,4 +668,26 @@ public function getAllowOrdersAwaitingOfflinePaymentToCheckIn(): bool
662668
{
663669
return $this->allow_orders_awaiting_offline_payment_to_check_in;
664670
}
671+
672+
public function setInvoicePaymentTermsDays(?int $invoice_payment_terms_days): self
673+
{
674+
$this->invoice_payment_terms_days = $invoice_payment_terms_days;
675+
return $this;
676+
}
677+
678+
public function getInvoicePaymentTermsDays(): ?int
679+
{
680+
return $this->invoice_payment_terms_days;
681+
}
682+
683+
public function setInvoiceNotes(?string $invoice_notes): self
684+
{
685+
$this->invoice_notes = $invoice_notes;
686+
return $this;
687+
}
688+
689+
public function getInvoiceNotes(): ?string
690+
{
691+
return $this->invoice_notes;
692+
}
665693
}

backend/app/Http/Actions/Orders/DownloadOrderInvoiceSignedAction.php renamed to backend/app/Http/Actions/Orders/DownloadOrderInvoiceAction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use Illuminate\Http\Request;
1010
use Illuminate\Http\Response;
1111

12-
class DownloadOrderInvoiceSignedAction extends BaseAction
12+
class DownloadOrderInvoiceAction extends BaseAction
1313
{
1414
public function __construct(
1515
private readonly GetOrderInvoiceHandler $orderInvoiceHandler,

backend/app/Http/Actions/Orders/CompleteOrderActionPublic.php renamed to backend/app/Http/Actions/Orders/Public/CompleteOrderActionPublic.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace HiEvents\Http\Actions\Orders;
5+
namespace HiEvents\Http\Actions\Orders\Public;
66

77
use HiEvents\Exceptions\ResourceConflictException;
88
use HiEvents\Http\Actions\BaseAction;

backend/app/Http/Actions/Orders/CreateOrderActionPublic.php renamed to backend/app/Http/Actions/Orders/Public/CreateOrderActionPublic.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace HiEvents\Http\Actions\Orders;
5+
namespace HiEvents\Http\Actions\Orders\Public;
66

77
use HiEvents\Http\Actions\BaseAction;
88
use HiEvents\Http\Request\Order\CreateOrderRequest;
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace HiEvents\Http\Actions\Orders\Public;
4+
5+
use HiEvents\Http\Actions\BaseAction;
6+
use HiEvents\Services\Application\Handlers\Order\Public\DownloadOrderInvoicePublicHandler;
7+
use Illuminate\Http\Response;
8+
9+
class DownloadOrderInvoicePublicAction extends BaseAction
10+
{
11+
public function __construct(
12+
private readonly DownloadOrderInvoicePublicHandler $downloadOrderInvoicePublicHandler,
13+
)
14+
{
15+
}
16+
17+
public function __invoke(int $eventId, string $orderShortId): Response
18+
{
19+
$invoice = $this->downloadOrderInvoicePublicHandler->handle(
20+
eventId: $eventId,
21+
orderShortId: $orderShortId,
22+
);
23+
24+
return $invoice->pdf->stream($invoice->filename);
25+
}
26+
}

backend/app/Http/Actions/Orders/GetOrderActionPublic.php renamed to backend/app/Http/Actions/Orders/Public/GetOrderActionPublic.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace HiEvents\Http\Actions\Orders;
3+
namespace HiEvents\Http\Actions\Orders\Public;
44

55
use HiEvents\Http\Actions\BaseAction;
66
use HiEvents\Resources\Order\OrderResourcePublic;

backend/app/Http/Actions/Orders/TransitionOrderToOfflinePaymentPublicAction.php renamed to backend/app/Http/Actions/Orders/Public/TransitionOrderToOfflinePaymentPublicAction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace HiEvents\Http\Actions\Orders;
3+
namespace HiEvents\Http\Actions\Orders\Public;
44

55
use HiEvents\Http\Actions\BaseAction;
66
use HiEvents\Resources\Order\OrderResourcePublic;

backend/app/Http/Request/EventSettings/UpdateEventSettingsRequest.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function rules(): array
6161
// Payment settings
6262
'payment_providers' => ['array'],
6363
'payment_providers.*' => ['string', Rule::in(PaymentProviders::valuesArray())],
64-
'offline_payment_instructions' => ['required_if:payment_providers,offline', 'string', 'nullable'],
64+
'offline_payment_instructions' => ['string', 'nullable', Rule::requiredIf(fn() => in_array(PaymentProviders::OFFLINE->name, $this->input('payment_providers', []), true))],
6565
'allow_orders_awaiting_offline_payment_to_check_in' => ['boolean'],
6666

6767
// Invoice settings
@@ -70,9 +70,11 @@ public function rules(): array
7070
'invoice_prefix' => ['nullable', 'string', 'max:10', 'regex:/^[A-Za-z0-9\-]*$/'],
7171
'invoice_start_number' => ['nullable', 'integer', 'min:1'],
7272
'require_billing_address' => ['boolean'],
73-
'organization_name' => ['required_if:enable_invoicing,true', 'string', 'max:255'],
74-
'organization_address' => ['required_if:enable_invoicing,true', 'string'],
75-
'tax_details' => ['nullable', 'string'],
73+
'organization_name' => ['required_if:enable_invoicing,true', 'string', 'max:255', 'nullable'],
74+
'organization_address' => ['required_if:enable_invoicing,true', 'string', 'max:255', 'nullable'],
75+
'invoice_tax_details' => ['nullable', 'string'],
76+
'invoice_notes' => ['nullable', 'string'],
77+
'invoice_payment_terms_days' => ['nullable', 'integer', 'gte:0', 'lte:1000'],
7678
];
7779
}
7880

@@ -97,7 +99,7 @@ public function messages(): array
9799

98100
// Payment messages
99101
'payment_providers.*.in' => __('Invalid payment provider selected.'),
100-
'offline_payment_instructions.required_if' => __('Payment instructions are required when offline payments are enabled.'),
102+
'offline_payment_instructions.required' => __('Payment instructions are required when offline payments are enabled.'),
101103

102104
// Invoice messages
103105
'invoice_prefix.regex' => __('The invoice prefix may only contain letters, numbers, and hyphens.'),

backend/app/Models/Invoice.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ protected function getCastMap(): array
1212
'taxes_and_fees' => 'array',
1313
'items' => 'array',
1414
'total_amount' => 'float',
15+
'due_date' => 'datetime',
1516
];
1617
}
1718

backend/app/Resources/Event/EventSettingsResource.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ public function toArray($request): array
6060
'require_billing_address' => $this->getRequireBillingAddress(),
6161
'organization_name' => $this->getOrganizationName(),
6262
'organization_address' => $this->getOrganizationAddress(),
63-
'tax_details' => $this->getTaxDetails(),
63+
'invoice_tax_details' => $this->getInvoiceTaxDetails(),
64+
'invoice_notes' => $this->getInvoiceNotes(),
65+
'invoice_payment_terms_days' => $this->getInvoicePaymentTermsDays(),
6466
];
6567
}
6668
}

0 commit comments

Comments
 (0)