diff --git a/myproject/orders/templates/orders/order_form.html b/myproject/orders/templates/orders/order_form.html index 8fb01c3..1d0f2ae 100644 --- a/myproject/orders/templates/orders/order_form.html +++ b/myproject/orders/templates/orders/order_form.html @@ -695,6 +695,10 @@ + +
@@ -884,6 +888,7 @@ document.addEventListener('DOMContentLoaded', function() { const amountInput = document.getElementById('unified-amount'); const amountHint = document.getElementById('amount-hint'); const amountMaxSpan = document.getElementById('amount-max'); + const walletEmptyHint = document.getElementById('wallet-empty-hint'); const refundReasonWrap = document.getElementById('refund-reason-wrap'); const refundReasonInput = document.getElementById('refund-reason'); @@ -974,12 +979,28 @@ document.addEventListener('DOMContentLoaded', function() { // Выбор способа (не активируем по умолчанию) methodButtons.forEach(btn => { btn.addEventListener('click', () => { + const methodCode = btn.dataset.code; + + // Скрываем подсказку перед проверкой + if (walletEmptyHint) walletEmptyHint.style.display = 'none'; + + // Проверяем баланс кошелька для платежа + if (currentMode === 'payment' && methodCode === 'account_balance' && walletBalance === 0) { + if (walletEmptyHint) walletEmptyHint.style.display = 'block'; + return; + } + methodButtons.forEach(b => b.classList.remove('active')); btn.classList.add('active'); methodHidden.value = btn.dataset.id; - currentMethodCode = btn.dataset.code; + currentMethodCode = methodCode; if (currentMode === 'payment') { + // Для кошелька: подставляем максимум из (остаток к оплате, баланс) + if (methodCode === 'account_balance') { + const max = Math.min(amountDue, walletBalance); + amountInput.value = max.toFixed(2); + } updateLimitsForPayment(); } else { updateLimitsForRefund();