[Enhancement] Added billing hours for account user in timesheet
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 8ab95f4..25dd3cb 100644
--- a/erpnext/accounts/doctype/sales_invoice_timesheet/sales_invoice_timesheet.json
+++ b/erpnext/accounts/doctype/sales_invoice_timesheet/sales_invoice_timesheet.json
@@ -40,6 +40,31 @@
"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,
+ "collapsible": 0,
"fieldname": "billing_amount",
"fieldtype": "Currency",
"hidden": 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 91498e3..e9f2ce1 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -294,7 +294,7 @@
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 dc1a57c..628f993 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 a780ab4..7828f2b 100644
--- a/erpnext/projects/doctype/timesheet/timesheet.js
+++ b/erpnext/projects/doctype/timesheet/timesheet.js
@@ -49,6 +49,10 @@
"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 @@
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 @@
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 @@
total_costing_amount = 0;
for(var i=0; i<tl.length; i++) {
if (tl[i].hours) {
- total_hr += tl[i].hours;
+ total_hr += tl[i].billing_hours;
total_billing_amount += tl[i].billing_amount;
total_costing_amount += tl[i].costing_amount;
}
diff --git a/erpnext/projects/doctype/timesheet/timesheet.json b/erpnext/projects/doctype/timesheet/timesheet.json
index 16d71d8..74c4add 100644
--- a/erpnext/projects/doctype/timesheet/timesheet.json
+++ b/erpnext/projects/doctype/timesheet/timesheet.json
@@ -462,7 +462,7 @@
"in_list_view": 0,
"length": 0,
"no_copy": 0,
- "permlevel": 0,
+ "permlevel": 1,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
@@ -474,7 +474,7 @@
"unique": 0
},
{
- "allow_on_submit": 0,
+ "allow_on_submit": 1,
"bold": 0,
"collapsible": 0,
"default": "0",
@@ -486,7 +486,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 1,
- "label": "Total Hours",
+ "label": "Total Billing Hours",
"length": 0,
"no_copy": 0,
"permlevel": 0,
@@ -524,7 +524,7 @@
"unique": 0
},
{
- "allow_on_submit": 0,
+ "allow_on_submit": 1,
"bold": 0,
"collapsible": 0,
"default": "0",
@@ -662,7 +662,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
- "modified": "2016-08-01 08:54:31.840829",
+ "modified": "2016-08-22 21:31:22.226215",
"modified_by": "Administrator",
"module": "Projects",
"name": "Timesheet",
@@ -729,6 +729,46 @@
"write": 1
},
{
+ "amend": 1,
+ "apply_user_permissions": 0,
+ "cancel": 1,
+ "create": 1,
+ "delete": 1,
+ "email": 1,
+ "export": 1,
+ "if_owner": 0,
+ "import": 0,
+ "permlevel": 0,
+ "print": 1,
+ "read": 1,
+ "report": 1,
+ "role": "Accounts User",
+ "set_user_permissions": 0,
+ "share": 1,
+ "submit": 1,
+ "write": 1
+ },
+ {
+ "amend": 0,
+ "apply_user_permissions": 0,
+ "cancel": 0,
+ "create": 0,
+ "delete": 0,
+ "email": 1,
+ "export": 1,
+ "if_owner": 0,
+ "import": 0,
+ "permlevel": 1,
+ "print": 1,
+ "read": 1,
+ "report": 1,
+ "role": "Accounts User",
+ "set_user_permissions": 0,
+ "share": 1,
+ "submit": 0,
+ "write": 1
+ },
+ {
"amend": 0,
"apply_user_permissions": 0,
"cancel": 0,
diff --git a/erpnext/projects/doctype/timesheet/timesheet.py b/erpnext/projects/doctype/timesheet/timesheet.py
index 0379f90..a895c8d 100644
--- a/erpnext/projects/doctype/timesheet/timesheet.py
+++ b/erpnext/projects/doctype/timesheet/timesheet.py
@@ -32,7 +32,7 @@
self.total_costing_amount = 0.0
for d in self.get("time_logs"):
- self.total_hours += flt(d.hours)
+ self.total_hours += flt(d.billing_hours)
if d.billable:
self.total_billing_amount += flt(d.billing_amount)
self.total_costing_amount += flt(d.costing_amount)
@@ -230,7 +230,7 @@
for data in self.time_logs:
if data.activity_type and (not data.billing_amount or not data.costing_amount):
rate = get_activity_cost(self.employee, data.activity_type)
- hours = data.hours or 0
+ hours = data.billing_hours or 0
if rate:
data.billing_rate = flt(rate.get('billing_rate'))
data.costing_rate = flt(rate.get('costing_rate'))
@@ -246,6 +246,7 @@
"doctype": "Sales Invoice Timesheet",
"field_map": {
"total_billing_amount": "billing_amount",
+ "total_hours": "billing_hours",
"name": "time_sheet"
},
}
diff --git a/erpnext/projects/doctype/timesheet_detail/timesheet_detail.json b/erpnext/projects/doctype/timesheet_detail/timesheet_detail.json
index f847e64..e122b6c 100644
--- a/erpnext/projects/doctype/timesheet_detail/timesheet_detail.json
+++ b/erpnext/projects/doctype/timesheet_detail/timesheet_detail.json
@@ -11,7 +11,7 @@
"editable_grid": 1,
"fields": [
{
- "allow_on_submit": 0,
+ "allow_on_submit": 1,
"bold": 0,
"collapsible": 0,
"depends_on": "",
@@ -185,6 +185,31 @@
"unique": 0
},
{
+ "allow_on_submit": 1,
+ "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": 0,
+ "label": "Billing Hours",
+ "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,
@@ -199,7 +224,7 @@
"label": "Billing Rate",
"length": 0,
"no_copy": 0,
- "permlevel": 0,
+ "permlevel": 1,
"precision": "2",
"print_hide": 0,
"print_hide_if_no_value": 0,
@@ -224,7 +249,7 @@
"label": "Costing Rate",
"length": 0,
"no_copy": 0,
- "permlevel": 0,
+ "permlevel": 1,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
@@ -260,7 +285,7 @@
"unique": 0
},
{
- "allow_on_submit": 0,
+ "allow_on_submit": 1,
"bold": 0,
"collapsible": 0,
"default": "0",
@@ -276,7 +301,7 @@
"label": "Billing Amount",
"length": 0,
"no_copy": 0,
- "permlevel": 0,
+ "permlevel": 1,
"precision": "2",
"print_hide": 0,
"print_hide_if_no_value": 0,
@@ -288,7 +313,7 @@
"unique": 0
},
{
- "allow_on_submit": 0,
+ "allow_on_submit": 1,
"bold": 0,
"collapsible": 0,
"default": "0",
@@ -303,7 +328,7 @@
"label": "Costing Amount",
"length": 0,
"no_copy": 0,
- "permlevel": 0,
+ "permlevel": 1,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
@@ -532,7 +557,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
- "modified": "2016-08-06 03:14:31.691605",
+ "modified": "2016-08-22 21:20:31.726779",
"modified_by": "Administrator",
"module": "Projects",
"name": "Timesheet Detail",