fix: removed condition that considered "Standard working hours" while creating "timesheet" as it was setting wrong time #20848
This commit is contained in:
parent
5e16ca0326
commit
4e37d25374
@ -162,19 +162,11 @@ frappe.ui.form.on("Timesheet Detail", {
|
|||||||
|
|
||||||
to_time: function(frm, cdt, cdn) {
|
to_time: function(frm, cdt, cdn) {
|
||||||
var child = locals[cdt][cdn];
|
var child = locals[cdt][cdn];
|
||||||
var time_diff = (moment(child.to_time).diff(moment(child.from_time),"seconds")) / ( 60 * 60 * 24);
|
|
||||||
var std_working_hours = 0;
|
|
||||||
|
|
||||||
if(frm._setting_hours) return;
|
if(frm._setting_hours) return;
|
||||||
|
|
||||||
var hours = moment(child.to_time).diff(moment(child.from_time), "seconds") / 3600;
|
var hours = moment(child.to_time).diff(moment(child.from_time), "seconds") / 3600;
|
||||||
std_working_hours = time_diff * frappe.working_hours;
|
frappe.model.set_value(cdt, cdn, "hours", hours);
|
||||||
|
|
||||||
if (std_working_hours < hours && std_working_hours > 0) {
|
|
||||||
frappe.model.set_value(cdt, cdn, "hours", std_working_hours);
|
|
||||||
} else {
|
|
||||||
frappe.model.set_value(cdt, cdn, "hours", hours);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
time_logs_add: function(frm) {
|
time_logs_add: function(frm) {
|
||||||
@ -236,23 +228,12 @@ var calculate_end_time = function(frm, cdt, cdn) {
|
|||||||
|
|
||||||
let d = moment(child.from_time);
|
let d = moment(child.from_time);
|
||||||
if(child.hours) {
|
if(child.hours) {
|
||||||
var time_diff = (moment(child.to_time).diff(moment(child.from_time),"seconds")) / (60 * 60 * 24);
|
d.add(child.hours, "hours");
|
||||||
var std_working_hours = 0;
|
frm._setting_hours = true;
|
||||||
var hours = moment(child.to_time).diff(moment(child.from_time), "seconds") / 3600;
|
frappe.model.set_value(cdt, cdn, "to_time",
|
||||||
|
d.format(frappe.defaultDatetimeFormat)).then(() => {
|
||||||
std_working_hours = time_diff * frappe.working_hours;
|
frm._setting_hours = false;
|
||||||
|
});
|
||||||
if (std_working_hours < hours && std_working_hours > 0) {
|
|
||||||
frappe.model.set_value(cdt, cdn, "hours", std_working_hours);
|
|
||||||
frappe.model.set_value(cdt, cdn, "to_time", d.add(hours, "hours").format(frappe.defaultDatetimeFormat));
|
|
||||||
} else {
|
|
||||||
d.add(child.hours, "hours");
|
|
||||||
frm._setting_hours = true;
|
|
||||||
frappe.model.set_value(cdt, cdn, "to_time",
|
|
||||||
d.format(frappe.defaultDatetimeFormat)).then(() => {
|
|
||||||
frm._setting_hours = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user