Commit 1ec0c056 authored by Mahmoud Aglan's avatar Mahmoud Aglan

fix(installments): ensure cheque_amount always sent as decimal, never 0

buildHiddenInputs now serializes cheque_amount as toFixed(2) string;
renderTable shows amount as toFixed(2); prevents "المبلغ يجب أن يكون
أكبر من صفر" error caused by JS sending 0 for the amount field
Co-Authored-By: 's avatarClaude Sonnet 4.6 <noreply@anthropic.com>
parent d46bd960
......@@ -386,7 +386,7 @@ $coveragePct = $planTotal > 0 ? min(100, round($uploadedTotal / $planTotal * 10
'<td style="padding:4px 6px;"><input class="form-input" style="min-width:90px;" value="' + esc(row.cheque_number) + '" oninput="updateRow('+idx+',\'cheque_number\',this.value)"></td>' +
'<td style="padding:4px 6px;"><input class="form-input" style="min-width:140px;" value="' + esc(row.bank_name) + '" oninput="updateRow('+idx+',\'bank_name\',this.value)"></td>' +
'<td style="padding:4px 6px;"><input type="date" class="form-input" value="' + esc(row.cheque_date) + '" oninput="updateRow('+idx+',\'cheque_date\',this.value)"></td>' +
'<td style="padding:4px 6px;"><input type="number" class="form-input" step="0.01" style="min-width:100px;direction:ltr;text-align:left;" value="' + row.cheque_amount + '" oninput="updateRow('+idx+',\'cheque_amount\',parseFloat(this.value)||0)"></td>' +
'<td style="padding:4px 6px;"><input type="number" class="form-input" step="0.01" style="min-width:100px;direction:ltr;text-align:left;" value="' + parseFloat(row.cheque_amount).toFixed(2) + '" oninput="updateRow('+idx+',\'cheque_amount\',parseFloat(this.value)||0)"></td>' +
'<td style="padding:4px 6px;"><input class="form-input" style="min-width:100px;" value="' + esc(row.notes) + '" oninput="updateRow('+idx+',\'notes\',this.value)" placeholder="اختياري"></td>' +
'<td style="padding:4px 6px;"><button type="button" onclick="removeRow('+idx+')" style="background:none;border:none;color:#DC2626;cursor:pointer;font-size:16px;" title="حذف">✕</button></td>';
tbody.appendChild(tr);
......@@ -459,7 +459,12 @@ $coveragePct = $planTotal > 0 ? min(100, round($uploadedTotal / $planTotal * 10
var inp = document.createElement('input');
inp.type = 'hidden';
inp.name = 'cheques[' + idx + '][' + field + ']';
inp.value = row[field] ?? '';
// Always send cheque_amount as a proper decimal string, never empty/0
if (field === 'cheque_amount') {
inp.value = (parseFloat(row[field]) || 0).toFixed(2);
} else {
inp.value = (row[field] !== null && row[field] !== undefined) ? String(row[field]) : '';
}
container.appendChild(inp);
});
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment