Merge pull request #22400 from AfshanKhan/FR_ISS_204290
fix: removed condition that considered "Standard working hours" while…
This commit is contained in:
commit
cc7e1b0ec5
@ -140,52 +140,6 @@ class TestTimesheet(unittest.TestCase):
|
||||
settings.ignore_employee_time_overlap = initial_setting
|
||||
settings.save()
|
||||
|
||||
def test_timesheet_std_working_hours(self):
|
||||
emp = make_employee("test_employee_6@salary.com")
|
||||
|
||||
company = frappe.get_doc('Company', "_Test Company")
|
||||
company.standard_working_hours = 8
|
||||
company.save()
|
||||
|
||||
timesheet = frappe.new_doc("Timesheet")
|
||||
timesheet.employee = emp
|
||||
timesheet.company = '_Test Company'
|
||||
timesheet.append(
|
||||
'time_logs',
|
||||
{
|
||||
"activity_type": "_Test Activity Type",
|
||||
"from_time": now_datetime(),
|
||||
"to_time": now_datetime() + datetime.timedelta(days= 4)
|
||||
}
|
||||
)
|
||||
timesheet.save()
|
||||
|
||||
ts = frappe.get_doc('Timesheet', timesheet.name)
|
||||
self.assertEqual(ts.total_hours, 32)
|
||||
ts.submit()
|
||||
ts.cancel()
|
||||
|
||||
company = frappe.get_doc('Company', "_Test Company")
|
||||
company.standard_working_hours = 0
|
||||
company.save()
|
||||
|
||||
timesheet = frappe.new_doc("Timesheet")
|
||||
timesheet.employee = emp
|
||||
timesheet.company = '_Test Company'
|
||||
timesheet.append(
|
||||
'time_logs',
|
||||
{
|
||||
"activity_type": "_Test Activity Type",
|
||||
"from_time": now_datetime(),
|
||||
"to_time": now_datetime() + datetime.timedelta(days= 4)
|
||||
}
|
||||
)
|
||||
timesheet.save()
|
||||
|
||||
ts = frappe.get_doc('Timesheet', timesheet.name)
|
||||
self.assertEqual(ts.total_hours, 96)
|
||||
ts.submit()
|
||||
ts.cancel()
|
||||
|
||||
def make_salary_structure_for_timesheet(employee):
|
||||
salary_structure_name = "Timesheet Salary Structure Test"
|
||||
|
@ -162,19 +162,11 @@ frappe.ui.form.on("Timesheet Detail", {
|
||||
|
||||
to_time: function(frm, 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;
|
||||
|
||||
var hours = moment(child.to_time).diff(moment(child.from_time), "seconds") / 3600;
|
||||
std_working_hours = time_diff * frappe.working_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);
|
||||
}
|
||||
frappe.model.set_value(cdt, cdn, "hours", hours);
|
||||
},
|
||||
|
||||
time_logs_add: function(frm) {
|
||||
@ -236,23 +228,12 @@ var calculate_end_time = function(frm, cdt, cdn) {
|
||||
|
||||
let d = moment(child.from_time);
|
||||
if(child.hours) {
|
||||
var time_diff = (moment(child.to_time).diff(moment(child.from_time),"seconds")) / (60 * 60 * 24);
|
||||
var std_working_hours = 0;
|
||||
var hours = moment(child.to_time).diff(moment(child.from_time), "seconds") / 3600;
|
||||
|
||||
std_working_hours = time_diff * frappe.working_hours;
|
||||
|
||||
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;
|
||||
});
|
||||
}
|
||||
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;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -24,7 +24,6 @@ class Timesheet(Document):
|
||||
self.set_status()
|
||||
self.validate_dates()
|
||||
self.validate_time_logs()
|
||||
self.calculate_std_hours()
|
||||
self.update_cost()
|
||||
self.calculate_total_amounts()
|
||||
self.calculate_percentage_billed()
|
||||
@ -91,17 +90,6 @@ class Timesheet(Document):
|
||||
self.start_date = getdate(start_date)
|
||||
self.end_date = getdate(end_date)
|
||||
|
||||
def calculate_std_hours(self):
|
||||
std_working_hours = frappe.get_value("Company", self.company, 'standard_working_hours')
|
||||
|
||||
for time in self.time_logs:
|
||||
if time.from_time and time.to_time:
|
||||
if flt(std_working_hours) and date_diff(time.to_time, time.from_time):
|
||||
time.hours = flt(std_working_hours) * date_diff(time.to_time, time.from_time)
|
||||
else:
|
||||
if not time.hours:
|
||||
time.hours = time_diff_in_hours(time.to_time, time.from_time)
|
||||
|
||||
def before_cancel(self):
|
||||
self.set_status()
|
||||
|
||||
|
@ -22,7 +22,6 @@
|
||||
"default_letter_head",
|
||||
"default_holiday_list",
|
||||
"default_finance_book",
|
||||
"standard_working_hours",
|
||||
"default_selling_terms",
|
||||
"default_buying_terms",
|
||||
"default_warehouse_for_sales_return",
|
||||
@ -240,11 +239,6 @@
|
||||
"label": "Default Holiday List",
|
||||
"options": "Holiday List"
|
||||
},
|
||||
{
|
||||
"fieldname": "standard_working_hours",
|
||||
"fieldtype": "Float",
|
||||
"label": "Standard Working Hours"
|
||||
},
|
||||
{
|
||||
"fieldname": "default_warehouse_for_sales_return",
|
||||
"fieldtype": "Link",
|
||||
@ -746,7 +740,7 @@
|
||||
"image_field": "company_logo",
|
||||
"is_tree": 1,
|
||||
"links": [],
|
||||
"modified": "2020-06-20 11:38:43.178970",
|
||||
"modified": "2020-06-24 12:45:31.462195",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Setup",
|
||||
"name": "Company",
|
||||
|
Loading…
Reference in New Issue
Block a user