diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js index 36ca5287e9..0850b3dded 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -373,22 +373,4 @@ frappe.ui.form.on("Purchase Invoice", { } }) -frappe.ui.form.on("Purchase Invoice", { - payment_terms_template: function() { - cur_frm.trigger("disable_due_date"); - }, - disable_due_date: function() { - const disable = cur_frm.doc.payment_terms_template || ( - cur_frm.doc.payment_schedule && cur_frm.doc.payment_schedule.length == 0); - cur_frm.set_df_property("due_date", "read_only", disable ? 1 : 0); - }, - -}); - -frappe.ui.form.on("Payment Schedule", { - payment_schedule_remove: function() { - cur_frm.trigger("disable_due_date"); - }, - -}); \ No newline at end of file diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js index 5432b4c450..4b917ce27b 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js @@ -565,22 +565,3 @@ var calculate_total_billing_amount = function(frm) { refresh_field('total_billing_amount') } -frappe.ui.form.on("Sales Invoice", { - payment_terms_template: function() { - cur_frm.trigger("disable_due_date"); - }, - - disable_due_date: function() { - const disable = cur_frm.doc.payment_terms_template || ( - cur_frm.doc.payment_schedule && cur_frm.doc.payment_schedule.length == 0); - cur_frm.set_df_property("due_date", "read_only", disable ? 1 : 0); - }, - -}); - -frappe.ui.form.on("Payment Schedule", { - payment_schedule_remove: function() { - cur_frm.trigger("disable_due_date"); - }, - -}); \ No newline at end of file diff --git a/erpnext/public/js/controllers/accounts.js b/erpnext/public/js/controllers/accounts.js index abd5566243..4650345648 100644 --- a/erpnext/public/js/controllers/accounts.js +++ b/erpnext/public/js/controllers/accounts.js @@ -52,7 +52,14 @@ frappe.ui.form.on(cur_frm.doctype, { }, taxes_on_form_rendered: function(frm) { erpnext.taxes.set_conditional_mandatory_rate_or_amount(frm.open_grid_row()); - } + }, + + disable_due_date: function() { + const disable = cur_frm.doc.payment_terms_template || ( + cur_frm.doc.payment_schedule && cur_frm.doc.payment_schedule.length != 0); + cur_frm.set_df_property("due_date", "read_only", disable ? 1 : 0); + }, + }); frappe.ui.form.on('Sales Invoice Payment', { @@ -62,15 +69,32 @@ frappe.ui.form.on('Sales Invoice Payment', { frappe.model.set_value(cdt, cdn, 'account', account) }) } -}) +}); + +frappe.ui.form.on("Sales Invoice", { + payment_terms_template: function() { + cur_frm.trigger("disable_due_date"); + } +}); frappe.ui.form.on('Purchase Invoice', { mode_of_payment: function(frm) { get_payment_mode_account(frm, frm.doc.mode_of_payment, function(account){ frm.set_value('cash_bank_account', account); }) + }, + + payment_terms_template: function() { + cur_frm.trigger("disable_due_date"); } -}) +}); + +frappe.ui.form.on("Payment Schedule", { + payment_schedule_remove: function() { + cur_frm.trigger("disable_due_date"); + }, + +}); frappe.ui.form.on('Payment Entry', { mode_of_payment: function(frm) {