@@ -405,6 +405,14 @@
function buildForm(){
const fd = new FormData(document.getElementById('formFinalPayment'));
+ // Ensure raw numeric amount is sent
+ (function ensureRawAmount(){
+ const amountInput = document.getElementById('id_amount');
+ if (amountInput){
+ const raw = (amountInput.getAttribute('data-raw-value') || amountInput.value.replace(/\D/g, ''));
+ if (raw) fd.set('amount', raw);
+ }
+ })();
// تبدیل تاریخ شمسی به میلادی برای ارسال
const persianDateValue = $('#id_payment_date').val();
@@ -465,6 +473,24 @@
}
// Legacy approve button removed; using modal forms below
+
+ // Handle AJAX form submission with number formatting
+ $(document).ready(function() {
+ // Override buildForm function for AJAX submission
+ const originalBuildForm = window.buildForm;
+ window.buildForm = function() {
+ // Set raw values before creating FormData
+ if (window.setRawValuesForSubmission) {
+ window.setRawValuesForSubmission();
+ }
+ const result = originalBuildForm ? originalBuildForm() : new FormData(document.querySelector('form'));
+ // Restore formatted values for display
+ if (window.restoreFormattedValues) {
+ window.restoreFormattedValues();
+ }
+ return result;
+ };
+ });
{% endblock %}
diff --git a/invoices/templates/invoices/quote_payment_step.html b/invoices/templates/invoices/quote_payment_step.html
index e9bc07f..4a071f8 100644
--- a/invoices/templates/invoices/quote_payment_step.html
+++ b/invoices/templates/invoices/quote_payment_step.html
@@ -72,7 +72,7 @@
-
+
@@ -366,6 +366,12 @@
}
const form = document.getElementById('formAddPayment');
const fd = buildFormData(form);
+ // Ensure raw numeric amount is sent
+ (function ensureRawAmount(){
+ const amountInput = document.getElementById('id_amount');
+ const raw = (amountInput.getAttribute('data-raw-value') || amountInput.value.replace(/\D/g, ''));
+ if (raw) fd.set('amount', raw);
+ })();
// تبدیل تاریخ شمسی به میلادی برای ارسال
const persianDateValue = $('#id_payment_date').val();
@@ -383,7 +389,7 @@
setTimeout(() => { window.location.href = resp.redirect; }, 700);
}
} else {
- showToast(resp.message + ':' + resp.error || 'خطا در ثبت فیش', 'danger');
+ showToast((resp.message || resp.error || 'خطا در ثبت فیش'), 'danger');
}
}).catch(() => showToast('خطا در ارتباط با سرور', 'danger'));
});
@@ -460,6 +466,7 @@
} catch (e) { console.error('Error initializing Persian Date Picker:', e); }
}
})();
+
{% endblock %}