fix school year for all tables
Tests / PHPUnit (push) Failing after 1m20s

This commit is contained in:
root
2026-07-18 14:45:38 -04:00
parent 4db8334a3c
commit 716cc8b8d3
125 changed files with 2315 additions and 81 deletions
+1 -1
View File
@@ -160,7 +160,7 @@
<h4 class="fw-bold">Payment</h4>
<small>$<?= number_format($paymentBalance, 2) ?></small>
<div class="hover-popup">
<p class="mb-0">Latest outstanding balance from the most recent invoice.</p>
<p class="mb-0">Current account balance for this school year, including any previous-year carry-over.</p>
</div>
</div>
</div>
+2
View File
@@ -97,6 +97,7 @@ $deadline = parseDbDateTime($dueDate, 'UTC', $displayTz); // format either DATE
<th>Invoice Number</th>
<th>Issue Date</th>
<th>Due Date</th>
<th>Description</th>
<th>Balance</th>
<th>Last Payment Amount</th>
<th>Last Payment Date</th>
@@ -117,6 +118,7 @@ $deadline = parseDbDateTime($dueDate, 'UTC', $displayTz); // format either DATE
<td><?= esc($invoice['invoice_number']) ?></td>
<td><?= $issueDt ? esc($issueDt->format('m-d-Y h:i A')) : '—' ?></td>
<td><?= $dueDt ? esc($dueDt->format('m-d-Y')) : '—' ?></td>
<td><?= esc($invoice['description'] ?? '') ?: '—' ?></td>
<td>$<?= number_format((float)($invoice['balance'] ?? 0), 2) ?></td>
<td>$<?= number_format((float)($invoice['last_paid_amount'] ?? 0), 2) ?></td>
<td><?= $lastPay ? esc($lastPay->format('m-d-Y h:i A')) : '—' ?></td>
+52 -2
View File
@@ -182,6 +182,12 @@
</form>
<?php if ($parent): ?>
<?php if (!empty($carryForwardPaymentRequired)): ?>
<div class="alert alert-warning">
<?= esc($carryForwardPaymentMessage ?? 'This parent has a balance carried over from a previous school year. Payment must be made in full; installments are not allowed.') ?>
</div>
<?php endif; ?>
<!-- Parent + Student info -->
<div class="row mb-4">
<div class="col-md-6">
@@ -406,7 +412,8 @@
id="invoice_id"
class="form-select"
required
data-end-date="<?= esc($installmentEndYmd ?? '') ?>">
data-end-date="<?= esc($installmentEndYmd ?? '') ?>"
data-carry-forward-full-required="<?= !empty($carryForwardPaymentRequired) ? '1' : '0' ?>">
<?php if (!empty($invoices)): ?>
<?php foreach ($invoices as $invoice): ?>
<option
@@ -464,8 +471,13 @@
<label for="payment_type" class="form-label">Payment Type</label>
<select name="payment_type" id="payment_type" class="form-select" required>
<option value="full">Full Payment</option>
<option value="installment">Installment Payment</option>
<option value="installment" <?= !empty($carryForwardPaymentRequired) ? 'disabled' : '' ?>>Installment Payment</option>
</select>
<?php if (!empty($carryForwardPaymentRequired)): ?>
<div class="form-text text-warning">
Installments are disabled because this parent has a previous-year carry-over balance.
</div>
<?php endif; ?>
</div>
<!-- Installment section (non-card only) -->
@@ -573,6 +585,8 @@
const $instSeq = () => _el('installment_seq');
const $maxInstLab = () => _el('max-installments');
const $form = () => _el('addPaymentForm');
const carryForwardFullRequired = <?= !empty($carryForwardPaymentRequired) ? 'true' : 'false' ?>;
const carryForwardFullMessage = <?= json_encode($carryForwardPaymentMessage ?? 'This parent has a balance carried over from a previous school year. Payment must be made in full; installments are not allowed.') ?>;
// Confirm overlay elements
const $overlay = () => _el('payConfirmOverlay');
@@ -699,6 +713,25 @@
$amountHint().textContent = 'Card payments must cover the remaining balance in full.';
}
function forceCarryForwardFullRules() {
const type = $type();
if (type) {
type.value = 'full';
type.removeAttribute('disabled');
const installmentOption = type.querySelector('option[value="installment"]');
if (installmentOption) installmentOption.disabled = true;
}
$instSec().style.display = 'none';
$instSeqRow().style.display = 'none';
const bal = getBalance();
$amount().value = bal.toFixed(2);
$amount().setAttribute('readonly', 'readonly');
if ($instAmt()) $instAmt().value = '';
$amountHint().textContent = carryForwardFullMessage;
}
function setupInstallments() {
const endDate = $invoice().getAttribute('data-end-date') || '';
const months = monthsUntil(endDate);
@@ -767,6 +800,8 @@
if (m === 'card') {
forceCardRules();
} else if (carryForwardFullRequired) {
forceCarryForwardFullRules();
} else {
// enable full/installment select
$type().removeAttribute('disabled');
@@ -787,6 +822,10 @@
forceCardRules();
return;
}
if (carryForwardFullRequired) {
forceCarryForwardFullRules();
return;
}
if (t === 'installment') {
$instSec().style.display = '';
setupInstallments();
@@ -807,6 +846,8 @@
if (($method().value || '').toLowerCase() === 'card') {
forceCardRules();
} else if (carryForwardFullRequired) {
forceCarryForwardFullRules();
} else {
updateAmountHint();
if ($type().value === 'installment') {
@@ -879,6 +920,10 @@
alert('Please enter a valid amount > 0.');
return;
}
if (carryForwardFullRequired && type === 'installment') {
alert(carryForwardFullMessage);
return;
}
const invoiceText = invOpt.text || ('Invoice #' + invOpt.value);
// Derive balance: prefer total - paid - discount - refunds, else fallback to data-balance
@@ -909,6 +954,11 @@
const newBal = (isFinite(balance) && isFinite(amount)) ? (balance - amount) : NaN;
const overpay = (isFinite(newBal) && newBal < -0.005);
if (carryForwardFullRequired && isFinite(balance) && Math.abs(amount - balance) > 0.005) {
alert(carryForwardFullMessage);
$amount().value = Math.max(0, balance).toFixed(2);
return;
}
$pcAmount().textContent = fmtUSD(amount);
$pcInvoice().innerHTML = '<strong>Invoice:</strong> ' + esc(invoiceText);
@@ -24,6 +24,7 @@
$carryForward = $preview['carry_forward'] ?? [];
$status = (string) ($source['status'] ?? '');
$batchStatus = (string) ($latestBatch['status'] ?? '');
$missingCarryForwardInvoices = (int) ($missingCarryForwardInvoices ?? 0);
$money = static fn ($value): string => '$' . number_format((float) $value, 2);
$score = static fn ($value): string => is_numeric($value) ? number_format((float) $value, 2) : '-';
$promotionUrl = static function (array $overrides = []) use ($source, $target, $promotionSort, $promotionOrder, $promotionPage, $promotionPerPage): string {
@@ -429,6 +430,17 @@
</form>
<?php endif; ?>
<?php if (in_array($batchStatus, ['executed', 'completed'], true)): ?>
<form action="<?= site_url('administrator/school-years/' . (int) $source['id'] . '/closing/execute') ?>" method="post">
<?= csrf_field() ?>
<button class="btn btn-primary" type="submit">
<?= $missingCarryForwardInvoices > 0
? 'Repair Carry-Forward Invoices (' . $missingCarryForwardInvoices . ')'
: 'Re-run Carry-Forward Sync' ?>
</button>
</form>
<?php endif; ?>
<?php if ($status === 'closing' && ! in_array($batchStatus, ['executed', 'completed'], true)): ?>
<form action="<?= site_url('administrator/school-years/' . (int) $source['id'] . '/closing/cancel') ?>" method="post">
<?= csrf_field() ?>