Merge pull request #22400 from AfshanKhan/FR_ISS_204290
fix: removed condition that considered "Standard working hours" while…
diff --git a/erpnext/projects/doctype/timesheet/test_timesheet.py b/erpnext/projects/doctype/timesheet/test_timesheet.py
index 03b67b1..a5ce44d 100644
--- a/erpnext/projects/doctype/timesheet/test_timesheet.py
+++ b/erpnext/projects/doctype/timesheet/test_timesheet.py
@@ -140,52 +140,6 @@
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"
diff --git a/erpnext/projects/doctype/timesheet/timesheet.js b/erpnext/projects/doctype/timesheet/timesheet.js
index defc18b..5de2930 100644
--- a/erpnext/projects/doctype/timesheet/timesheet.js
+++ b/erpnext/projects/doctype/timesheet/timesheet.js
@@ -162,19 +162,11 @@
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 @@
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;
+ });
}
};
diff --git a/erpnext/projects/doctype/timesheet/timesheet.py b/erpnext/projects/doctype/timesheet/timesheet.py
index e908216..7fe22be 100644
--- a/erpnext/projects/doctype/timesheet/timesheet.py
+++ b/erpnext/projects/doctype/timesheet/timesheet.py
@@ -24,7 +24,6 @@
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 @@
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()
diff --git a/erpnext/setup/doctype/company/company.json b/erpnext/setup/doctype/company/company.json
index c25edc5..221044d 100644
--- a/erpnext/setup/doctype/company/company.json
+++ b/erpnext/setup/doctype/company/company.json
@@ -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",
@@ -241,11 +240,6 @@
"options": "Holiday List"
},
{
- "fieldname": "standard_working_hours",
- "fieldtype": "Float",
- "label": "Standard Working Hours"
- },
- {
"fieldname": "default_warehouse_for_sales_return",
"fieldtype": "Link",
"label": "Default warehouse for Sales Return",
@@ -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",