fix installment for carry over balance parent account
This commit is contained in:
@@ -423,6 +423,7 @@
|
||||
data-display-total="<?= esc($invoice['display_total'] ?? $invoice['total_amount'] ?? '') ?>"
|
||||
data-balance-due-cents="<?= (int)($invoice['balance_due_cents'] ?? 0) ?>"
|
||||
data-customer-credit-cents="<?= (int)($invoice['customer_credit_cents'] ?? 0) ?>"
|
||||
data-carry-forward-invoice="<?= !empty($invoice['is_carry_forward_invoice']) ? '1' : '0' ?>"
|
||||
data-next-installment="<?= (int)($invoice['next_installment'] ?? 1) ?>">
|
||||
<?php
|
||||
$uiPaid = (float)($invoice['paid_amount'] ?? 0);
|
||||
@@ -634,6 +635,11 @@
|
||||
return isFinite(v) ? v : 1;
|
||||
}
|
||||
|
||||
function selectedInvoiceRequiresCarryForwardFull() {
|
||||
const opt = currentOpt();
|
||||
return carryForwardFullRequired || (opt && opt.getAttribute('data-carry-forward-invoice') === '1');
|
||||
}
|
||||
|
||||
function monthsUntil(endYmd) {
|
||||
if (!endYmd) return 0;
|
||||
const today = new Date();
|
||||
@@ -788,12 +794,15 @@
|
||||
|
||||
if (m === 'card') {
|
||||
forceCardRules();
|
||||
} else if (carryForwardFullRequired) {
|
||||
} else if (selectedInvoiceRequiresCarryForwardFull()) {
|
||||
forceCarryForwardFullRules();
|
||||
} else {
|
||||
// enable full/installment select
|
||||
$type().removeAttribute('disabled');
|
||||
$type().value = 'full';
|
||||
const type = $type();
|
||||
type.removeAttribute('disabled');
|
||||
const installmentOption = type.querySelector('option[value="installment"]');
|
||||
if (installmentOption) installmentOption.disabled = false;
|
||||
type.value = 'full';
|
||||
$instSec().style.display = 'none';
|
||||
$instSeqRow().style.display = 'none';
|
||||
$amount().removeAttribute('readonly');
|
||||
@@ -810,7 +819,7 @@
|
||||
forceCardRules();
|
||||
return;
|
||||
}
|
||||
if (carryForwardFullRequired) {
|
||||
if (selectedInvoiceRequiresCarryForwardFull()) {
|
||||
forceCarryForwardFullRules();
|
||||
return;
|
||||
}
|
||||
@@ -834,7 +843,7 @@
|
||||
|
||||
if (($method().value || '').toLowerCase() === 'card') {
|
||||
forceCardRules();
|
||||
} else if (carryForwardFullRequired) {
|
||||
} else if (selectedInvoiceRequiresCarryForwardFull()) {
|
||||
forceCarryForwardFullRules();
|
||||
} else {
|
||||
updateAmountHint();
|
||||
@@ -908,7 +917,7 @@
|
||||
alert('Please enter a valid amount > 0.');
|
||||
return;
|
||||
}
|
||||
if (carryForwardFullRequired && type === 'installment') {
|
||||
if (selectedInvoiceRequiresCarryForwardFull() && type === 'installment') {
|
||||
alert(carryForwardFullMessage);
|
||||
return;
|
||||
}
|
||||
@@ -924,7 +933,7 @@
|
||||
|
||||
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) {
|
||||
if (selectedInvoiceRequiresCarryForwardFull() && isFinite(balance) && Math.abs(amount - balance) > 0.005) {
|
||||
alert(carryForwardFullMessage);
|
||||
$amount().value = Math.max(0, balance).toFixed(2);
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user