fix tests

This commit is contained in:
root
2026-06-11 11:46:12 -04:00
parent c91fa2ce4d
commit 5ead80fdc7
1489 changed files with 11349 additions and 10305 deletions
+12 -13
View File
@@ -26,8 +26,7 @@ class ChargeService
private ExtraChargesInvoiceService $invoices,
private ExtraChargesContextService $context,
private InvoiceGenerationService $invoiceGeneration
) {
}
) {}
public function createExtraCharge(array $payload): array
{
@@ -60,7 +59,7 @@ class ChargeService
'semester' => $payload['semester'] ?? $this->context->getSemester(),
]));
if (!($result['ok'] ?? false)) {
if (! ($result['ok'] ?? false)) {
return $result;
}
@@ -70,14 +69,14 @@ class ChargeService
'id' => (int) ($result['id'] ?? 0),
'parent_id' => $parentId,
'invoice_id' => $result['invoice_id'] ?? null,
'status' => !empty($payload['invoice_id']) ? 'applied' : 'pending',
'status' => ! empty($payload['invoice_id']) ? 'applied' : 'pending',
];
}
public function cancelExtraCharge(int $chargeId): array
{
$charge = AdditionalCharge::query()->find($chargeId);
if (!$charge) {
if (! $charge) {
return ['ok' => false, 'message' => 'Extra charge not found.'];
}
@@ -99,7 +98,7 @@ class ChargeService
public function applyExtraCharge(int $chargeId, int $invoiceId): array
{
$charge = AdditionalCharge::query()->find($chargeId);
if (!$charge) {
if (! $charge) {
return ['ok' => false, 'message' => 'Extra charge not found.'];
}
@@ -165,7 +164,7 @@ class ChargeService
$amount = isset($payload['amount']) ? (float) $payload['amount'] : null;
if ($eventId > 0) {
$event = Event::getEvent($eventId, $schoolYear);
if (!$event) {
if (! $event) {
return ['ok' => false, 'message' => 'Event not found.'];
}
$eventName = (string) ($event->event_name ?? $eventName);
@@ -225,7 +224,7 @@ class ChargeService
public function cancelEventCharge(int $chargeId, bool $issueCredit = true): array
{
$charge = EventCharges::query()->find($chargeId);
if (!$charge) {
if (! $charge) {
return ['ok' => false, 'message' => 'Event charge not found.'];
}
@@ -252,8 +251,8 @@ class ChargeService
if ($issueCredit && $amount > 0 && $parentId > 0) {
$credit = $this->createExtraCharge([
'parent_id' => $parentId,
'title' => 'Event credit: ' . $eventName,
'description' => 'Account credit for canceled event charge #' . $chargeId,
'title' => 'Event credit: '.$eventName,
'description' => 'Account credit for canceled event charge #'.$chargeId,
'amount' => $amount,
'charge_type' => 'deduct',
'school_year' => $schoolYear,
@@ -287,7 +286,7 @@ class ChargeService
public function markEventChargePaid(int $chargeId, bool $paid, ?int $paymentId = null): array
{
$charge = EventCharges::query()->find($chargeId);
if (!$charge) {
if (! $charge) {
return ['ok' => false, 'message' => 'Event charge not found.'];
}
@@ -389,7 +388,7 @@ class ChargeService
private function resolveEventName(EventCharges $charge): string
{
if (!empty($charge->event_name)) {
if (! empty($charge->event_name)) {
return (string) $charge->event_name;
}
@@ -426,7 +425,7 @@ class ChargeService
}
/**
* @param array<string, mixed> $row
* @param array<string, mixed> $row
*/
private function formatEventCharge(array $row): array
{