Spaces:
Running
Running
Fix paid invoice form validation
Browse files
main.js
CHANGED
|
@@ -341,10 +341,15 @@ function syncDocumentTypeControls() {
|
|
| 341 |
const isPersonalPaid = selectedType === "personal_paid";
|
| 342 |
setVisibility(paymentTermField, !isPersonalPaid);
|
| 343 |
setVisibility(paidDocumentHint, isPersonalPaid);
|
| 344 |
-
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 348 |
}
|
| 349 |
}
|
| 350 |
|
|
@@ -859,7 +864,7 @@ function startInvoiceEdit(invoiceId) {
|
|
| 859 |
syncDocumentTypeControls();
|
| 860 |
}
|
| 861 |
invoiceForm.elements.saleDate.value = invoice.sale_date || "";
|
| 862 |
-
invoiceForm.elements.paymentTerm.value = isPaidInvoice(invoice) ?
|
| 863 |
|
| 864 |
if (invoice.client) {
|
| 865 |
setClientFormValues(invoice.client);
|
|
|
|
| 341 |
const isPersonalPaid = selectedType === "personal_paid";
|
| 342 |
setVisibility(paymentTermField, !isPersonalPaid);
|
| 343 |
setVisibility(paidDocumentHint, isPersonalPaid);
|
| 344 |
+
const paymentTermInput = invoiceForm?.elements.paymentTerm;
|
| 345 |
+
if (!paymentTermInput) {
|
| 346 |
+
return;
|
| 347 |
+
}
|
| 348 |
+
paymentTermInput.disabled = isPersonalPaid;
|
| 349 |
+
if (isPersonalPaid) {
|
| 350 |
+
paymentTermInput.value = "";
|
| 351 |
+
} else if (!paymentTermInput.value) {
|
| 352 |
+
paymentTermInput.value = "14";
|
| 353 |
}
|
| 354 |
}
|
| 355 |
|
|
|
|
| 864 |
syncDocumentTypeControls();
|
| 865 |
}
|
| 866 |
invoiceForm.elements.saleDate.value = invoice.sale_date || "";
|
| 867 |
+
invoiceForm.elements.paymentTerm.value = isPaidInvoice(invoice) ? "" : (invoice.payment_term || 14);
|
| 868 |
|
| 869 |
if (invoice.client) {
|
| 870 |
setClientFormValues(invoice.client);
|