Fix critical wallet balance validation bug after balance updates

- Replace static template value with dynamic DOM-based balance reading
- Use parseFloat(walletBalanceElement.textContent) for current balance
- Ensures validation uses the actual displayed balance, not stale template value
- Fixes false "insufficient balance" errors after successful transactions
- Maintains consistency between display and validation logic
- Prevents user confusion with inconsistent balance states

This was a critical bug where users would see updated balance but still get
insufficient balance errors due to static template rendering.

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Claude 2025-07-18 20:05:26 +05:30
parent 64c2d98de9
commit c81bdfbfe0

View File

@ -1560,9 +1560,10 @@ document.addEventListener('keydown', function(e) {
return; return;
{% endif %} {% endif %}
// Check wallet balance // Check wallet balance dynamically from DOM
const balance = {{ user.wallet_balance|default:0 }}; const walletBalanceElement = document.getElementById('walletBalance');
if (balance < 4.00) { const currentBalance = walletBalanceElement ? parseFloat(walletBalanceElement.textContent) : 0;
if (currentBalance < 4.00) {
AgentUtils.showToast('Insufficient balance! You need 4.00 AED.', 'error'); AgentUtils.showToast('Insufficient balance! You need 4.00 AED.', 'error');
setTimeout(() => { setTimeout(() => {
window.location.href = "{% url 'core:wallet' %}"; window.location.href = "{% url 'core:wallet' %}";