FIX: Исправлена автоподстановка суммы при смешанной оплате + убраны версии JS

1. Убран параметр версии ?v=4 из подключения terminal.js (для разработки не нужен)

2. Исправлена логика автоподстановки суммы в PaymentWidget:
   - Теперь при выборе способа оплаты подставляется ОСТАТОЧНАЯ сумма
   - Остаток = amount_due - уже добавленные платежи
   - Добавлена подсказка "Осталось оплатить: X руб."

Пример:
- Заказ на 30 руб.
- Добавили платеж 10 руб. наличными
- Выбираем картой → автоматически подставится 20 руб. (а не 30!)

Это предотвращает ошибки и переплаты при смешанной оплате.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-12-03 21:31:45 +03:00
parent 0ed60954c4
commit 12282a8ce4
2 changed files with 8 additions and 5 deletions

View File

@@ -164,15 +164,18 @@ export class PaymentWidget {
const amountInput = document.getElementById(`${this.containerId}-amount`); const amountInput = document.getElementById(`${this.containerId}-amount`);
const hint = document.getElementById(`${this.containerId}-hint`); const hint = document.getElementById(`${this.containerId}-hint`);
// Вычисляем остаток с учетом уже добавленных платежей
const remaining = this.order.amount_due - this.getTotalPayments();
if (this.selectedMethod.code === 'account_balance' && this.customer) { if (this.selectedMethod.code === 'account_balance' && this.customer) {
const maxAmount = Math.min(this.order.amount_due, this.customer.wallet_balance); const maxAmount = Math.min(remaining, this.customer.wallet_balance);
amountInput.max = maxAmount; amountInput.max = maxAmount;
amountInput.value = maxAmount.toFixed(2); amountInput.value = maxAmount.toFixed(2);
hint.textContent = `Макс: ${maxAmount.toFixed(2)} руб.`; hint.textContent = `Макс: ${maxAmount.toFixed(2)} руб. | Осталось: ${remaining.toFixed(2)} руб.`;
} else { } else {
amountInput.removeAttribute('max'); amountInput.removeAttribute('max');
amountInput.value = this.order.amount_due.toFixed(2); amountInput.value = remaining.toFixed(2);
hint.textContent = ''; hint.textContent = `Осталось оплатить: ${remaining.toFixed(2)} руб.`;
} }
} }

View File

@@ -504,5 +504,5 @@
} }
</script> </script>
<script src="{% static 'pos/js/terminal.js' %}?v=4"></script> <script src="{% static 'pos/js/terminal.js' %}"></script>
{% endblock %} {% endblock %}