refactor: DRY for disable due date logic
This commit is contained in:
parent
9e32387aa7
commit
e7da1c5500
@ -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");
|
||||
},
|
||||
|
||||
});
|
@ -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");
|
||||
},
|
||||
|
||||
});
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user