From c81bdfbfe0a03f1e1a387c016f9618d688b63628 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 18 Jul 2025 20:05:26 +0530 Subject: [PATCH] Fix critical wallet balance validation bug after balance updates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- .../templates/job_posting_generator/detail.html | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/job_posting_generator/templates/job_posting_generator/detail.html b/job_posting_generator/templates/job_posting_generator/detail.html index 46a2e07..f8ee9f0 100644 --- a/job_posting_generator/templates/job_posting_generator/detail.html +++ b/job_posting_generator/templates/job_posting_generator/detail.html @@ -1560,9 +1560,10 @@ document.addEventListener('keydown', function(e) { return; {% endif %} - // Check wallet balance - const balance = {{ user.wallet_balance|default:0 }}; - if (balance < 4.00) { + // Check wallet balance dynamically from DOM + const walletBalanceElement = document.getElementById('walletBalance'); + const currentBalance = walletBalanceElement ? parseFloat(walletBalanceElement.textContent) : 0; + if (currentBalance < 4.00) { AgentUtils.showToast('Insufficient balance! You need 4.00 AED.', 'error'); setTimeout(() => { window.location.href = "{% url 'core:wallet' %}";