fix gitlab tests

This commit is contained in:
root
2026-06-09 02:32:58 -04:00
parent 20a0b6c4e5
commit 6def9993da
1489 changed files with 10449 additions and 11356 deletions
@@ -15,7 +15,8 @@ class RefundOverpaymentService
public function __construct(
private RefundNotificationService $notifications,
private ApplicationUrlService $urls,
) {}
) {
}
public function recalculate(bool $triggerEvents = false, ?string $invoiceNumber = null, ?int $actorId = null): array
{
@@ -76,7 +77,7 @@ class RefundOverpaymentService
private function recalculateForInvoice(string $invoiceNumber, bool $triggerEvents, ?int $actorId): array
{
$invoice = Invoice::query()->where('invoice_number', $invoiceNumber)->first();
if (! $invoice) {
if (!$invoice) {
return ['ok' => false, 'message' => 'Invoice not found.'];
}
@@ -120,7 +121,6 @@ class RefundOverpaymentService
'updated_at' => utc_now(),
'updated_by' => $actorId,
]);
return ['ok' => true, 'message' => 'Overpayment updated for invoice.'];
}
@@ -164,22 +164,27 @@ class RefundOverpaymentService
->select('id', 'parent_id', 'total_amount', 'school_year')
->where('school_year', $schoolYear)
->get()
->map(fn ($row) => (array) $row)
->map(fn ($row) => method_exists($row, 'toArray') ? $row->toArray() : (array) $row)
->filter(fn (array $row) => isset($row['id'], $row['parent_id']))
->values()
->all();
if (empty($invRows)) {
return ['created_ids' => [], 'updated_ids' => []];
}
$invoiceIds = array_map(static fn ($row) => (int) $row['id'], $invRows);
$invoiceIds = array_values(array_filter(array_map(static fn ($row) => (int) ($row['id'] ?? 0), $invRows)));
$paidByInv = $this->sumPaymentsByInvoice($invoiceIds);
$discByInv = $this->sumDiscountsByInvoice($invoiceIds);
$refByInv = $this->sumRefundsByInvoice($invoiceIds);
foreach ($invRows as $inv) {
$iid = (int) $inv['id'];
$pid = (int) $inv['parent_id'];
$iid = (int) ($inv['id'] ?? 0);
$pid = (int) ($inv['parent_id'] ?? 0);
if ($iid <= 0 || $pid <= 0) {
continue;
}
$total = (float) ($inv['total_amount'] ?? 0);
$paid = (float) ($paidByInv[$iid] ?? 0);
$disc = (float) ($discByInv[$iid] ?? 0);
@@ -204,7 +209,6 @@ class RefundOverpaymentService
'updated_by' => $actorId,
]);
$updated[] = (int) $openRow->id;
continue;
}
@@ -225,7 +229,6 @@ class RefundOverpaymentService
'updated_by' => $actorId,
]);
$updated[] = (int) $parentLevelOpen->id;
continue;
}
@@ -236,7 +239,7 @@ class RefundOverpaymentService
->orderByDesc('id')
->first();
if (! $existing || $existing->status === Refund::STATUS_PAID) {
if (!$existing || $existing->status === Refund::STATUS_PAID) {
$refund = Refund::query()->create([
'parent_id' => $pid,
'school_year' => $schoolYear,