[Enhancement] Added billing hours for account user in timesheet

This commit is contained in:
Rohit Waghchaure 2016-08-22 18:42:02 +05:30 committed by Nabin Hait
parent e334813daf
commit 0cb171feb2
7 changed files with 125 additions and 23 deletions

View File

@ -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",

View File

@ -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")

View File

@ -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
}

View File

@ -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<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;
}

View File

@ -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",
@ -728,6 +728,46 @@
"submit": 1,
"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,

View File

@ -32,7 +32,7 @@ class Timesheet(Document):
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 @@ class Timesheet(Document):
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 @@ def make_sales_invoice(source_name, target=None):
"doctype": "Sales Invoice Timesheet",
"field_map": {
"total_billing_amount": "billing_amount",
"total_hours": "billing_hours",
"name": "time_sheet"
},
}

View File

@ -11,7 +11,7 @@
"editable_grid": 1,
"fields": [
{
"allow_on_submit": 0,
"allow_on_submit": 1,
"bold": 0,
"collapsible": 0,
"depends_on": "",
@ -184,6 +184,31 @@
"set_only_once": 0,
"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,
@ -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",