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
+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);