diff --git a/default_thai_company/public/js/payment_entry.js b/default_thai_company/public/js/payment_entry.js index 5f4a827..5c9a9d3 100644 --- a/default_thai_company/public/js/payment_entry.js +++ b/default_thai_company/public/js/payment_entry.js @@ -1,4 +1,18 @@ frappe.ui.form.on("Payment Entry", { + onload(frm) { + if (frm.is_new() && frm.doc.posting_date && !frm.doc.reference_date) { + frm.set_value("reference_date", frm.doc.posting_date); + } + }, + + // Cheque/Reference Date follows Posting Date; the field stays editable for the + // cases where the cheque is dated differently. + posting_date(frm) { + if (frm.doc.posting_date) { + frm.set_value("reference_date", frm.doc.posting_date); + } + }, + apply_tax_withholding_amount(frm) { if (frm.doc.party_type !== "Customer" || frm.doc.payment_type !== "Receive") return; if (!frm.doc.apply_tax_withholding_amount) {