fixes test cases, added patch
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index e9f2ce1..ba82a23 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -315,3 +315,4 @@
erpnext.patches.v7_0.fix_duplicate_icons
erpnext.patches.v7_0.move_employee_parent_to_child_in_salary_structure
erpnext.patches.v7_0.repost_gle_for_pos_sales_return
+erpnext.patches.v7_1.update_total_billing_hours
diff --git a/erpnext/patches/v7_1/__init__.py b/erpnext/patches/v7_1/__init__.py
new file mode 100644
index 0000000..519ff49
--- /dev/null
+++ b/erpnext/patches/v7_1/__init__.py
@@ -0,0 +1 @@
+from __future__ import unicode_literals
\ No newline at end of file
diff --git a/erpnext/patches/v7_1/update_total_billing_hours.py b/erpnext/patches/v7_1/update_total_billing_hours.py
new file mode 100644
index 0000000..a38b88d
--- /dev/null
+++ b/erpnext/patches/v7_1/update_total_billing_hours.py
@@ -0,0 +1,14 @@
+from __future__ import unicode_literals
+import frappe
+
+def execute():
+ frappe.reload_doc('projects', 'doctype', 'timesheet_detail')
+ frappe.reload_doc('accounts', 'doctype', 'sales_invoice_timesheet')
+
+ frappe.db.sql("""update tabTimesheet set total_billing_hours=total_hours
+ where total_billing_amount>0 and docstatus = 1""")
+
+ frappe.db.sql("""update `tabTimesheet Detail` set billing_hours=hours where docstatus < 2""")
+
+ frappe.db.sql(""" update `tabSales Invoice Timesheet` set billing_hours = (select total_billing_hours from `tabTimesheet`
+ where name = time_sheet) where time_sheet is not null""")
\ No newline at end of file
diff --git a/erpnext/projects/doctype/timesheet/test_timesheet.py b/erpnext/projects/doctype/timesheet/test_timesheet.py
index e443435..8e7e562 100644
--- a/erpnext/projects/doctype/timesheet/test_timesheet.py
+++ b/erpnext/projects/doctype/timesheet/test_timesheet.py
@@ -16,6 +16,7 @@
timesheet = make_timesheet("_T-Employee-0001", True)
self.assertEquals(timesheet.total_hours, 2)
+ self.assertEquals(timesheet.total_billing_hours, 2)
self.assertEquals(timesheet.time_logs[0].billing_rate, 50)
self.assertEquals(timesheet.time_logs[0].billing_amount, 100)
@@ -54,7 +55,6 @@
timesheet = frappe.get_doc('Timesheet', timesheet.name)
self.assertEquals(sales_invoice.total_billing_amount, 100)
self.assertEquals(timesheet.status, 'Billed')
-
def make_salary_structure(employee):
name = frappe.db.get_value('Salary Structure Employee', {'employee': employee}, 'parent')
diff --git a/erpnext/projects/doctype/timesheet/timesheet.js b/erpnext/projects/doctype/timesheet/timesheet.js
index 7828f2b..907d20d 100644
--- a/erpnext/projects/doctype/timesheet/timesheet.js
+++ b/erpnext/projects/doctype/timesheet/timesheet.js
@@ -156,18 +156,21 @@
var calculate_time_and_amount = function(frm) {
var tl = frm.doc.time_logs || [];
- total_hr = 0;
+ total_working_hr = 0;
+ total_billing_hr = 0;
total_billing_amount = 0;
total_costing_amount = 0;
for(var i=0; i<tl.length; i++) {
if (tl[i].hours) {
- total_hr += tl[i].billing_hours;
+ total_working_hr += tl[i].hours;
+ total_billing_hr += tl[i].billing_hours;
total_billing_amount += tl[i].billing_amount;
total_costing_amount += tl[i].costing_amount;
}
}
- cur_frm.set_value("total_hours", total_hr);
+ cur_frm.set_value("total_billing_hours", total_billing_hr);
+ cur_frm.set_value("total_hours", total_working_hr);
cur_frm.set_value("total_billing_amount", total_billing_amount);
cur_frm.set_value("total_costing_amount", total_costing_amount);
}
\ No newline at end of file
diff --git a/erpnext/projects/doctype/timesheet/timesheet.json b/erpnext/projects/doctype/timesheet/timesheet.json
index 74c4add..a5debd0 100644
--- a/erpnext/projects/doctype/timesheet/timesheet.json
+++ b/erpnext/projects/doctype/timesheet/timesheet.json
@@ -453,7 +453,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
- "fieldname": "section_break_8",
+ "fieldname": "working_hours",
"fieldtype": "Section Break",
"hidden": 0,
"ignore_user_permissions": 0,
@@ -462,7 +462,7 @@
"in_list_view": 0,
"length": 0,
"no_copy": 0,
- "permlevel": 1,
+ "permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
@@ -486,7 +486,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 1,
- "label": "Total Billing Hours",
+ "label": "Total Working Hours",
"length": 0,
"no_copy": 0,
"permlevel": 0,
@@ -502,6 +502,56 @@
{
"allow_on_submit": 0,
"bold": 0,
+ "collapsible": 1,
+ "fieldname": "billing_details",
+ "fieldtype": "Section Break",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_list_view": 0,
+ "label": "Billing Details",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 1,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "unique": 0
+ },
+ {
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "fieldname": "total_billing_hours",
+ "fieldtype": "Float",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_list_view": 0,
+ "label": "Total Billing Hours",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "unique": 0
+ },
+ {
+ "allow_on_submit": 0,
+ "bold": 0,
"collapsible": 0,
"fieldname": "column_break_10",
"fieldtype": "Column Break",
@@ -662,7 +712,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
- "modified": "2016-08-22 21:31:22.226215",
+ "modified": "2016-08-23 00:38:14.550753",
"modified_by": "Administrator",
"module": "Projects",
"name": "Timesheet",
diff --git a/erpnext/projects/doctype/timesheet/timesheet.py b/erpnext/projects/doctype/timesheet/timesheet.py
index a895c8d..c2a2d3e 100644
--- a/erpnext/projects/doctype/timesheet/timesheet.py
+++ b/erpnext/projects/doctype/timesheet/timesheet.py
@@ -28,15 +28,23 @@
def calculate_total_amounts(self):
self.total_hours = 0.0
+ self.total_billing_hours = 0.0
self.total_billing_amount = 0.0
self.total_costing_amount = 0.0
for d in self.get("time_logs"):
- self.total_hours += flt(d.billing_hours)
+ self.update_billing_hours(d)
+
+ self.total_hours += flt(d.hours)
+ self.total_billing_hours += flt(d.billing_hours)
if d.billable:
self.total_billing_amount += flt(d.billing_amount)
self.total_costing_amount += flt(d.costing_amount)
+ def update_billing_hours(self, args):
+ if cint(args.billing_hours) == 0:
+ args.billing_hours = args.hours
+
def set_status(self):
self.status = {
"0": "Draft",
@@ -246,7 +254,7 @@
"doctype": "Sales Invoice Timesheet",
"field_map": {
"total_billing_amount": "billing_amount",
- "total_hours": "billing_hours",
+ "total_billing_hours": "billing_hours",
"name": "time_sheet"
},
}