From 0cb171feb2c345fbf4491373195ea4f631006c40 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Mon, 22 Aug 2016 18:42:02 +0530 Subject: [PATCH] [Enhancement] Added billing hours for account user in timesheet --- .../sales_invoice_timesheet.json | 27 +++++++++- erpnext/patches.txt | 2 +- .../doctype/activity_type/activity_type.json | 3 +- .../projects/doctype/timesheet/timesheet.js | 20 ++++++-- .../projects/doctype/timesheet/timesheet.json | 50 +++++++++++++++++-- .../projects/doctype/timesheet/timesheet.py | 5 +- .../timesheet_detail/timesheet_detail.json | 41 ++++++++++++--- 7 files changed, 125 insertions(+), 23 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice_timesheet/sales_invoice_timesheet.json b/erpnext/accounts/doctype/sales_invoice_timesheet/sales_invoice_timesheet.json index 8ab95f4485..25dd3cb845 100644 --- a/erpnext/accounts/doctype/sales_invoice_timesheet/sales_invoice_timesheet.json +++ b/erpnext/accounts/doctype/sales_invoice_timesheet/sales_invoice_timesheet.json @@ -36,6 +36,31 @@ "set_only_once": 0, "unique": 0 }, + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "fieldname": "billing_hours", + "fieldtype": "Float", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_list_view": 1, + "label": "Billing Hours", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 1, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, { "allow_on_submit": 0, "bold": 0, @@ -72,7 +97,7 @@ "issingle": 0, "istable": 1, "max_attachments": 0, - "modified": "2016-07-11 03:28:07.876168", + "modified": "2016-08-22 21:32:55.504103", "modified_by": "Administrator", "module": "Accounts", "name": "Sales Invoice Timesheet", diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 91498e3298..e9f2ce11b6 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -294,7 +294,7 @@ erpnext.patches.v7_0.rename_prevdoc_fields erpnext.patches.v7_0.rename_time_sheet_doctype execute:frappe.delete_doc_if_exists("Report", "Customers Not Buying Since Long Time") erpnext.patches.v7_0.make_is_group_fieldtype_as_check -execute:frappe.reload_doc('projects', 'doctype', 'timesheet', force=True) +execute:frappe.reload_doc('projects', 'doctype', 'timesheet', force=True) #2016-08-23 execute:frappe.delete_doc_if_exists("Report", "Employee Holiday Attendance") execute:frappe.delete_doc_if_exists("DocType", "Payment Tool") execute:frappe.delete_doc_if_exists("DocType", "Payment Tool Detail") diff --git a/erpnext/projects/doctype/activity_type/activity_type.json b/erpnext/projects/doctype/activity_type/activity_type.json index dc1a57c6c4..628f993eb1 100644 --- a/erpnext/projects/doctype/activity_type/activity_type.json +++ b/erpnext/projects/doctype/activity_type/activity_type.json @@ -121,7 +121,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2016-07-25 05:24:26.717981", + "modified": "2016-08-22 08:53:43.680463", "modified_by": "Administrator", "module": "Projects", "name": "Activity Type", @@ -171,5 +171,6 @@ "quick_entry": 1, "read_only": 0, "read_only_onload": 0, + "sort_order": "ASC", "track_seen": 0 } \ No newline at end of file diff --git a/erpnext/projects/doctype/timesheet/timesheet.js b/erpnext/projects/doctype/timesheet/timesheet.js index a780ab4f47..7828f2b986 100644 --- a/erpnext/projects/doctype/timesheet/timesheet.js +++ b/erpnext/projects/doctype/timesheet/timesheet.js @@ -49,6 +49,10 @@ frappe.ui.form.on("Timesheet", { "icon-file-alt"); } } + + if(frm.doc.sales_invoice) { + cur_frm.fields_dict["time_logs"].grid.toggle_enable("billing_hours", false); + } }, make_invoice: function(frm) { @@ -87,6 +91,10 @@ frappe.ui.form.on("Timesheet Detail", { calculate_end_time(frm, cdt, cdn) }, + billing_hours: function(frm, cdt, cdn) { + calculate_billing_costing_amount(frm, cdt, cdn) + }, + billing_rate: function(frm, cdt, cdn) { calculate_billing_costing_amount(frm, cdt, cdn) }, @@ -127,16 +135,18 @@ calculate_end_time = function(frm, cdt, cdn){ frappe.model.set_value(cdt, cdn, "to_time", d.format(moment.defaultDatetimeFormat)); frm._setting_hours = false; - calculate_billing_costing_amount(frm, cdt, cdn) + if(frm.doc.__islocal && !child.billing_hours && child.hours){ + frappe.model.set_value(cdt, cdn, "billing_hours", child.hours); + } } var calculate_billing_costing_amount = function(frm, cdt, cdn){ child = locals[cdt][cdn] billing_amount = costing_amount = 0.0; - if(child.hours && child.billable){ - billing_amount = (child.hours * child.billing_rate); - costing_amount = flt(child.costing_rate * child.hours); + if(child.billing_hours && child.billable){ + billing_amount = (child.billing_hours * child.billing_rate); + costing_amount = flt(child.costing_rate * child.billing_hours); } frappe.model.set_value(cdt, cdn, 'billing_amount', billing_amount); @@ -151,7 +161,7 @@ var calculate_time_and_amount = function(frm) { total_costing_amount = 0; for(var i=0; i