mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-16 11:39:18 +00:00
refactor: use read_only_depends_on instead of code (#27008)
(cherry picked from commit 332ac105b5)
# Conflicts:
# erpnext/accounts/doctype/pos_invoice/pos_invoice.js
# erpnext/accounts/doctype/sales_invoice/sales_invoice.js
This commit is contained in:
committed by
frappe-pr-bot
parent
352157c9fc
commit
f08d7410be
@@ -110,17 +110,18 @@ erpnext.selling.POSInvoiceController = erpnext.selling.SellingController.extend(
|
|||||||
this.frm.refresh_field("base_paid_amount");
|
this.frm.refresh_field("base_paid_amount");
|
||||||
},
|
},
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
write_off_outstanding_amount_automatically: function() {
|
write_off_outstanding_amount_automatically: function() {
|
||||||
if(cint(this.frm.doc.write_off_outstanding_amount_automatically)) {
|
if(cint(this.frm.doc.write_off_outstanding_amount_automatically)) {
|
||||||
|
=======
|
||||||
|
write_off_outstanding_amount_automatically() {
|
||||||
|
if (cint(this.frm.doc.write_off_outstanding_amount_automatically)) {
|
||||||
|
>>>>>>> 332ac105b5 (refactor: use `read_only_depends_on` instead of code (#27008))
|
||||||
frappe.model.round_floats_in(this.frm.doc, ["grand_total", "paid_amount"]);
|
frappe.model.round_floats_in(this.frm.doc, ["grand_total", "paid_amount"]);
|
||||||
// this will make outstanding amount 0
|
// this will make outstanding amount 0
|
||||||
this.frm.set_value("write_off_amount",
|
this.frm.set_value("write_off_amount",
|
||||||
flt(this.frm.doc.grand_total - this.frm.doc.paid_amount - this.frm.doc.total_advance, precision("write_off_amount"))
|
flt(this.frm.doc.grand_total - this.frm.doc.paid_amount - this.frm.doc.total_advance, precision("write_off_amount"))
|
||||||
);
|
);
|
||||||
this.frm.toggle_enable("write_off_amount", false);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
this.frm.toggle_enable("write_off_amount", true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.calculate_outstanding_amount(false);
|
this.calculate_outstanding_amount(false);
|
||||||
|
|||||||
@@ -1183,7 +1183,8 @@
|
|||||||
"label": "Write Off Amount",
|
"label": "Write Off Amount",
|
||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"options": "currency",
|
"options": "currency",
|
||||||
"print_hide": 1
|
"print_hide": 1,
|
||||||
|
"read_only_depends_on": "eval: doc.write_off_outstanding_amount_automatically"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "base_write_off_amount",
|
"fieldname": "base_write_off_amount",
|
||||||
@@ -1554,7 +1555,7 @@
|
|||||||
"icon": "fa fa-file-text",
|
"icon": "fa fa-file-text",
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2021-08-17 20:13:44.255437",
|
"modified": "2021-08-18 16:13:52.080543",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "POS Invoice",
|
"name": "POS Invoice",
|
||||||
|
|||||||
@@ -323,17 +323,18 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
|
|||||||
this.frm.refresh_fields();
|
this.frm.refresh_fields();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
write_off_outstanding_amount_automatically: function() {
|
write_off_outstanding_amount_automatically: function() {
|
||||||
if(cint(this.frm.doc.write_off_outstanding_amount_automatically)) {
|
if(cint(this.frm.doc.write_off_outstanding_amount_automatically)) {
|
||||||
|
=======
|
||||||
|
write_off_outstanding_amount_automatically() {
|
||||||
|
if (cint(this.frm.doc.write_off_outstanding_amount_automatically)) {
|
||||||
|
>>>>>>> 332ac105b5 (refactor: use `read_only_depends_on` instead of code (#27008))
|
||||||
frappe.model.round_floats_in(this.frm.doc, ["grand_total", "paid_amount"]);
|
frappe.model.round_floats_in(this.frm.doc, ["grand_total", "paid_amount"]);
|
||||||
// this will make outstanding amount 0
|
// this will make outstanding amount 0
|
||||||
this.frm.set_value("write_off_amount",
|
this.frm.set_value("write_off_amount",
|
||||||
flt(this.frm.doc.grand_total - this.frm.doc.paid_amount - this.frm.doc.total_advance, precision("write_off_amount"))
|
flt(this.frm.doc.grand_total - this.frm.doc.paid_amount - this.frm.doc.total_advance, precision("write_off_amount"))
|
||||||
);
|
);
|
||||||
this.frm.toggle_enable("write_off_amount", false);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
this.frm.toggle_enable("write_off_amount", true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.calculate_outstanding_amount(false);
|
this.calculate_outstanding_amount(false);
|
||||||
@@ -787,8 +788,6 @@ frappe.ui.form.on('Sales Invoice', {
|
|||||||
if (frappe.boot.sysdefaults.country == 'India') unhide_field(['c_form_applicable', 'c_form_no']);
|
if (frappe.boot.sysdefaults.country == 'India') unhide_field(['c_form_applicable', 'c_form_no']);
|
||||||
else hide_field(['c_form_applicable', 'c_form_no']);
|
else hide_field(['c_form_applicable', 'c_form_no']);
|
||||||
|
|
||||||
frm.toggle_enable("write_off_amount", !!!cint(doc.write_off_outstanding_amount_automatically));
|
|
||||||
|
|
||||||
frm.refresh_fields();
|
frm.refresh_fields();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -1444,7 +1444,8 @@
|
|||||||
"label": "Write Off Amount",
|
"label": "Write Off Amount",
|
||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"options": "currency",
|
"options": "currency",
|
||||||
"print_hide": 1
|
"print_hide": 1,
|
||||||
|
"read_only_depends_on": "eval:doc.write_off_outstanding_amount_automatically"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "base_write_off_amount",
|
"fieldname": "base_write_off_amount",
|
||||||
@@ -2016,7 +2017,7 @@
|
|||||||
"link_fieldname": "consolidated_invoice"
|
"link_fieldname": "consolidated_invoice"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"modified": "2021-08-17 20:16:12.737743",
|
"modified": "2021-08-18 16:07:45.122570",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Sales Invoice",
|
"name": "Sales Invoice",
|
||||||
|
|||||||
Reference in New Issue
Block a user