From 69aebf4db53d9d8a5c35c25bb6632bb608bee564 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Tue, 23 Aug 2016 10:41:15 +0530 Subject: [PATCH] fixes test cases, added patch --- erpnext/patches.txt | 1 + erpnext/patches/v7_1/__init__.py | 1 + .../v7_1/update_total_billing_hours.py | 14 +++++ .../doctype/timesheet/test_timesheet.py | 2 +- .../projects/doctype/timesheet/timesheet.js | 9 ++- .../projects/doctype/timesheet/timesheet.json | 58 +++++++++++++++++-- .../projects/doctype/timesheet/timesheet.py | 12 +++- 7 files changed, 87 insertions(+), 10 deletions(-) create mode 100644 erpnext/patches/v7_1/__init__.py create mode 100644 erpnext/patches/v7_1/update_total_billing_hours.py diff --git a/erpnext/patches.txt b/erpnext/patches.txt index e9f2ce11b6a..ba82a2367aa 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -315,3 +315,4 @@ erpnext.patches.v7_0.repost_future_gle_for_purchase_invoice 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 00000000000..519ff49eac1 --- /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 00000000000..a38b88d594d --- /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 e443435d58e..8e7e562442c 100644 --- a/erpnext/projects/doctype/timesheet/test_timesheet.py +++ b/erpnext/projects/doctype/timesheet/test_timesheet.py @@ -16,6 +16,7 @@ class TestTimesheet(unittest.TestCase): 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 @@ class TestTimesheet(unittest.TestCase): 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 7828f2b9868..907d20db5e5 100644 --- a/erpnext/projects/doctype/timesheet/timesheet.js +++ b/erpnext/projects/doctype/timesheet/timesheet.js @@ -156,18 +156,21 @@ var calculate_billing_costing_amount = function(frm, cdt, cdn){ 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