Skip to content

Commit 714b66f

Browse files
committed
refactor(Business Trip): use frm trigger
1 parent 85610f2 commit 714b66f

1 file changed

Lines changed: 16 additions & 15 deletions

File tree

erpnext_germany/erpnext_germany/doctype/business_trip/business_trip.js

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ frappe.ui.form.on("Business Trip", {
1212
},
1313

1414
refresh(frm) {
15-
set_date_constraints(frm);
15+
frm.trigger("set_date_constraints");
1616

1717
if (frm.doc.docstatus === 1) {
1818
frm.add_custom_button(__("Show Processing Details"), function () {
@@ -26,26 +26,27 @@ frappe.ui.form.on("Business Trip", {
2626
frm.set_value("to_date", frm.doc.from_date);
2727
}
2828

29-
set_date_constraints(frm);
29+
frm.trigger("set_date_constraints");
3030
},
3131

3232
to_date(frm) {
33-
set_date_constraints(frm);
33+
frm.trigger("set_date_constraints");
3434
},
35-
});
3635

37-
function set_date_constraints(frm) {
38-
if (frm.fields_dict.from_date?.datepicker) {
39-
frm.fields_dict.from_date.datepicker.update({
40-
maxDate: frm.doc.to_date ? new Date(frm.doc.to_date) : null,
41-
});
42-
}
43-
if (frm.fields_dict.to_date?.datepicker) {
44-
frm.fields_dict.to_date.datepicker.update({
45-
minDate: frm.doc.from_date ? new Date(frm.doc.from_date) : null,
46-
});
36+
set_date_constraints(frm) {
37+
if (frm.fields_dict.from_date?.datepicker) {
38+
frm.fields_dict.from_date.datepicker.update({
39+
maxDate: frm.doc.to_date ? new Date(frm.doc.to_date) : null,
40+
});
41+
}
42+
if (frm.fields_dict.to_date?.datepicker) {
43+
frm.fields_dict.to_date.datepicker.update({
44+
minDate: frm.doc.from_date ? new Date(frm.doc.from_date) : null,
45+
});
46+
}
4747
}
48-
}
48+
});
49+
4950

5051
frappe.ui.form.on("Business Trip Journey", {
5152
journeys_add(frm, cdt, cdn) {

0 commit comments

Comments
 (0)