diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 99c869d809..ecc9a6026a 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -461,8 +461,8 @@ class SalesInvoice(SellingController): def set_billing_hours_and_amount(self): for timesheet in self.timesheets: ts_doc = frappe.get_doc('Timesheet', timesheet.time_sheet) - if not timesheet.billing_hours and ts_doc.total_billing_hours: - timesheet.billing_hours = ts_doc.total_billing_hours + if not timesheet.billing_hours and ts_doc.total_billable_hours: + timesheet.billing_hours = ts_doc.total_billable_hours if not timesheet.billing_amount and ts_doc.total_billable_amount: timesheet.billing_amount = ts_doc.total_billable_amount diff --git a/erpnext/patches/v7_1/rename_field_timesheet.py b/erpnext/patches/v7_1/rename_field_timesheet.py index 1957545cd3..3690a2e79d 100644 --- a/erpnext/patches/v7_1/rename_field_timesheet.py +++ b/erpnext/patches/v7_1/rename_field_timesheet.py @@ -4,5 +4,8 @@ from frappe.model.utils.rename_field import rename_field def execute(): doctype = 'Timesheet' - if "total_billing_amount" in frappe.db.get_table_columns(doctype): - rename_field(doctype, 'total_billing_amount', 'total_billable_amount') \ No newline at end of file + fields_dict = {'total_billing_amount': 'total_billable_amount', 'total_billing_hours': 'total_billable_hours'} + + for old_fieldname, new_fieldname in fields_dict.items(): + if old_fieldname in frappe.db.get_table_columns(doctype): + rename_field(doctype, old_fieldname, new_fieldname) diff --git a/erpnext/patches/v7_1/update_total_billing_hours.py b/erpnext/patches/v7_1/update_total_billing_hours.py index 68222c4274..b9c96028f5 100644 --- a/erpnext/patches/v7_1/update_total_billing_hours.py +++ b/erpnext/patches/v7_1/update_total_billing_hours.py @@ -5,10 +5,10 @@ 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 + frappe.db.sql("""update tabTimesheet set total_billable_hours=total_hours where total_billable_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` + frappe.db.sql(""" update `tabSales Invoice Timesheet` set billing_hours = (select total_billable_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 22bb2761b0..369be6da3c 100644 --- a/erpnext/projects/doctype/timesheet/test_timesheet.py +++ b/erpnext/projects/doctype/timesheet/test_timesheet.py @@ -17,7 +17,7 @@ class TestTimesheet(unittest.TestCase): timesheet = make_timesheet("_T-Employee-0001", simulate = True, billable=1) self.assertEquals(timesheet.total_hours, 2) - self.assertEquals(timesheet.total_billing_hours, 2) + self.assertEquals(timesheet.total_billable_hours, 2) self.assertEquals(timesheet.time_logs[0].billing_rate, 50) self.assertEquals(timesheet.time_logs[0].billing_amount, 100) self.assertEquals(timesheet.total_billable_amount, 100) diff --git a/erpnext/projects/doctype/timesheet/timesheet.js b/erpnext/projects/doctype/timesheet/timesheet.js index 1b6f95678d..7d0e71ae99 100644 --- a/erpnext/projects/doctype/timesheet/timesheet.js +++ b/erpnext/projects/doctype/timesheet/timesheet.js @@ -173,7 +173,7 @@ var calculate_time_and_amount = function(frm) { } } - cur_frm.set_value("total_billing_hours", total_billing_hr); + cur_frm.set_value("total_billable_hours", total_billing_hr); cur_frm.set_value("total_hours", total_working_hr); cur_frm.set_value("total_billable_amount", total_billable_amount); cur_frm.set_value("total_costing_amount", total_costing_amount); diff --git a/erpnext/projects/doctype/timesheet/timesheet.json b/erpnext/projects/doctype/timesheet/timesheet.json index fd99e9a5af..168bc63142 100644 --- a/erpnext/projects/doctype/timesheet/timesheet.json +++ b/erpnext/projects/doctype/timesheet/timesheet.json @@ -549,14 +549,14 @@ "bold": 0, "collapsible": 0, "columns": 0, - "fieldname": "total_billing_hours", + "fieldname": "total_billable_hours", "fieldtype": "Float", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, - "label": "Total Billing Hours", + "label": "Total Billable Hours", "length": 0, "no_copy": 0, "permlevel": 0, @@ -817,7 +817,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2016-09-12 18:35:01.578750", + "modified": "2016-09-12 13:19:22.298036", "modified_by": "Administrator", "module": "Projects", "name": "Timesheet", diff --git a/erpnext/projects/doctype/timesheet/timesheet.py b/erpnext/projects/doctype/timesheet/timesheet.py index ba5210dc69..6fbe3f0fc5 100644 --- a/erpnext/projects/doctype/timesheet/timesheet.py +++ b/erpnext/projects/doctype/timesheet/timesheet.py @@ -29,7 +29,7 @@ class Timesheet(Document): def calculate_total_amounts(self): self.total_hours = 0.0 - self.total_billing_hours = 0.0 + self.total_billable_hours = 0.0 self.total_billed_hours = 0.0 self.total_billable_amount = 0.0 self.total_costing_amount = 0.0 @@ -40,7 +40,7 @@ class Timesheet(Document): self.total_hours += flt(d.hours) if d.billable: - self.total_billing_hours += flt(d.billing_hours) + self.total_billable_hours += flt(d.billing_hours) self.total_billable_amount += flt(d.billing_amount) self.total_costing_amount += flt(d.costing_amount) self.total_billed_amount += flt(d.billing_amount) if d.sales_invoice else 0.0 @@ -290,7 +290,7 @@ def get_timesheet_data(name, project): data = get_projectwise_timesheet_data(project, name) else: data = frappe.get_all('Timesheet', - fields = ["(total_billable_amount - total_billed_amount) as billing_amt", "total_billing_hours as billing_hours"], filters = {'name': name}) + fields = ["(total_billable_amount - total_billed_amount) as billing_amt", "total_billable_hours as billing_hours"], filters = {'name': name}) return { 'billing_hours': data[0].billing_hours, @@ -305,7 +305,7 @@ def make_sales_invoice(source_name, target=None): target.append('timesheets', { 'time_sheet': timesheet.name, - 'billing_hours': flt(timesheet.total_billing_hours) - flt(timesheet.total_billed_hours), + 'billing_hours': flt(timesheet.total_billable_hours) - flt(timesheet.total_billed_hours), 'billing_amount': flt(timesheet.total_billable_amount) - flt(timesheet.total_billed_amount) })