fixes test cases, added patch
This commit is contained in:
parent
0cb171feb2
commit
69aebf4db5
@ -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
|
||||
|
1
erpnext/patches/v7_1/__init__.py
Normal file
1
erpnext/patches/v7_1/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
14
erpnext/patches/v7_1/update_total_billing_hours.py
Normal file
14
erpnext/patches/v7_1/update_total_billing_hours.py
Normal file
@ -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""")
|
@ -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')
|
||||
|
@ -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<tl.length; i++) {
|
||||
if (tl[i].hours) {
|
||||
total_hr += tl[i].billing_hours;
|
||||
total_working_hr += tl[i].hours;
|
||||
total_billing_hr += tl[i].billing_hours;
|
||||
total_billing_amount += tl[i].billing_amount;
|
||||
total_costing_amount += tl[i].costing_amount;
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.set_value("total_hours", total_hr);
|
||||
cur_frm.set_value("total_billing_hours", total_billing_hr);
|
||||
cur_frm.set_value("total_hours", total_working_hr);
|
||||
cur_frm.set_value("total_billing_amount", total_billing_amount);
|
||||
cur_frm.set_value("total_costing_amount", total_costing_amount);
|
||||
}
|
@ -453,7 +453,7 @@
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"fieldname": "section_break_8",
|
||||
"fieldname": "working_hours",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
@ -462,7 +462,7 @@
|
||||
"in_list_view": 0,
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 1,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
@ -486,7 +486,7 @@
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_list_view": 1,
|
||||
"label": "Total Billing Hours",
|
||||
"label": "Total Working Hours",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
@ -499,6 +499,56 @@
|
||||
"set_only_once": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 1,
|
||||
"fieldname": "billing_details",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_list_view": 0,
|
||||
"label": "Billing Details",
|
||||
"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,
|
||||
"fieldname": "total_billing_hours",
|
||||
"fieldtype": "Float",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_list_view": 0,
|
||||
"label": "Total Billing Hours",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"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,
|
||||
@ -662,7 +712,7 @@
|
||||
"issingle": 0,
|
||||
"istable": 0,
|
||||
"max_attachments": 0,
|
||||
"modified": "2016-08-22 21:31:22.226215",
|
||||
"modified": "2016-08-23 00:38:14.550753",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Projects",
|
||||
"name": "Timesheet",
|
||||
|
@ -28,15 +28,23 @@ class Timesheet(Document):
|
||||
|
||||
def calculate_total_amounts(self):
|
||||
self.total_hours = 0.0
|
||||
self.total_billing_hours = 0.0
|
||||
self.total_billing_amount = 0.0
|
||||
self.total_costing_amount = 0.0
|
||||
|
||||
for d in self.get("time_logs"):
|
||||
self.total_hours += flt(d.billing_hours)
|
||||
self.update_billing_hours(d)
|
||||
|
||||
self.total_hours += flt(d.hours)
|
||||
self.total_billing_hours += flt(d.billing_hours)
|
||||
if d.billable:
|
||||
self.total_billing_amount += flt(d.billing_amount)
|
||||
self.total_costing_amount += flt(d.costing_amount)
|
||||
|
||||
def update_billing_hours(self, args):
|
||||
if cint(args.billing_hours) == 0:
|
||||
args.billing_hours = args.hours
|
||||
|
||||
def set_status(self):
|
||||
self.status = {
|
||||
"0": "Draft",
|
||||
@ -246,7 +254,7 @@ def make_sales_invoice(source_name, target=None):
|
||||
"doctype": "Sales Invoice Timesheet",
|
||||
"field_map": {
|
||||
"total_billing_amount": "billing_amount",
|
||||
"total_hours": "billing_hours",
|
||||
"total_billing_hours": "billing_hours",
|
||||
"name": "time_sheet"
|
||||
},
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user