diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 2e38927c7d..99c869d809 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -464,8 +464,8 @@ class SalesInvoice(SellingController): if not timesheet.billing_hours and ts_doc.total_billing_hours: timesheet.billing_hours = ts_doc.total_billing_hours - if not timesheet.billing_amount and ts_doc.total_billing_amount: - timesheet.billing_amount = ts_doc.total_billing_amount + if not timesheet.billing_amount and ts_doc.total_billable_amount: + timesheet.billing_amount = ts_doc.total_billable_amount def update_timesheet_billing_for_project(self): if not self.timesheets and self.project: diff --git a/erpnext/demo/user/projects.py b/erpnext/demo/user/projects.py index 505ccfd077..9802447679 100644 --- a/erpnext/demo/user/projects.py +++ b/erpnext/demo/user/projects.py @@ -22,7 +22,7 @@ def make_timesheet_for_projects(current_date ): ts = make_timesheet(employee, simulate = True, billable = 1, activity_type=get_random("Activity Type"), project=data.project, task =data.name) - if flt(ts.total_billing_amount) > 0.0: + if flt(ts.total_billable_amount) > 0.0: make_sales_invoice_for_timesheet(ts.name) frappe.db.commit() diff --git a/erpnext/patches.txt b/erpnext/patches.txt index d38ed3476a..802e045d65 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -295,7 +295,8 @@ 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') #2016-09-09 +execute:frappe.reload_doc('projects', 'doctype', 'timesheet') #2016-09-12 +erpnext.patches.v7_1.rename_field_timesheet 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/patches/v7_0/move_timelogbatch_from_salesinvoiceitem_to_salesinvoicetimesheet.py b/erpnext/patches/v7_0/move_timelogbatch_from_salesinvoiceitem_to_salesinvoicetimesheet.py index 695c552f06..a365f65605 100644 --- a/erpnext/patches/v7_0/move_timelogbatch_from_salesinvoiceitem_to_salesinvoicetimesheet.py +++ b/erpnext/patches/v7_0/move_timelogbatch_from_salesinvoiceitem_to_salesinvoicetimesheet.py @@ -3,12 +3,12 @@ import frappe def execute(): frappe.reload_doc('accounts', 'doctype', 'sales_invoice') frappe.reload_doc('accounts', 'doctype', 'sales_invoice_payment') - for time_sheet in frappe.db.sql(""" select sales_invoice, name, total_billing_amount from `tabTimesheet` + for time_sheet in frappe.db.sql(""" select sales_invoice, name, total_billable_amount from `tabTimesheet` where sales_invoice is not null and docstatus < 2""", as_dict=True): si_doc = frappe.get_doc('Sales Invoice', time_sheet.sales_invoice) ts = si_doc.append('timesheets',{}) ts.time_sheet = time_sheet.name - ts.billing_amount = time_sheet.total_billing_amount + ts.billing_amount = time_sheet.total_billable_amount si_doc.update_time_sheet(time_sheet.sales_invoice) si_doc.flags.ignore_validate_update_after_submit = True si_doc.save() \ No newline at end of file diff --git a/erpnext/patches/v7_1/move_sales_invoice_from_parent_to_child_timesheet.py b/erpnext/patches/v7_1/move_sales_invoice_from_parent_to_child_timesheet.py index 67e88e60ab..d1ec7c697e 100644 --- a/erpnext/patches/v7_1/move_sales_invoice_from_parent_to_child_timesheet.py +++ b/erpnext/patches/v7_1/move_sales_invoice_from_parent_to_child_timesheet.py @@ -13,7 +13,7 @@ def execute(): ) as sit set ts.total_billed_amount = sit.billing_amount, ts.total_billed_hours = sit.billing_hours, - ts.per_billed = ((sit.billing_amount * 100)/ts.total_billing_amount) + ts.per_billed = ((sit.billing_amount * 100)/ts.total_billable_amount) where ts.name = sit.time_sheet and ts.docstatus = 1""") frappe.db.sql(""" update `tabTimesheet Detail` tsd, `tabTimesheet` ts set tsd.sales_invoice = ts.sales_invoice diff --git a/erpnext/patches/v7_1/rename_field_timesheet.py b/erpnext/patches/v7_1/rename_field_timesheet.py new file mode 100644 index 0000000000..1957545cd3 --- /dev/null +++ b/erpnext/patches/v7_1/rename_field_timesheet.py @@ -0,0 +1,8 @@ +from __future__ import unicode_literals +import frappe +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 diff --git a/erpnext/patches/v7_1/update_total_billing_hours.py b/erpnext/patches/v7_1/update_total_billing_hours.py index a38b88d594..68222c4274 100644 --- a/erpnext/patches/v7_1/update_total_billing_hours.py +++ b/erpnext/patches/v7_1/update_total_billing_hours.py @@ -6,7 +6,7 @@ def execute(): 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""") + where total_billable_amount>0 and docstatus = 1""") frappe.db.sql("""update `tabTimesheet Detail` set billing_hours=hours where docstatus < 2""") diff --git a/erpnext/projects/doctype/timesheet/test_timesheet.py b/erpnext/projects/doctype/timesheet/test_timesheet.py index 1e7be41d59..22bb2761b0 100644 --- a/erpnext/projects/doctype/timesheet/test_timesheet.py +++ b/erpnext/projects/doctype/timesheet/test_timesheet.py @@ -20,6 +20,7 @@ class TestTimesheet(unittest.TestCase): 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) + self.assertEquals(timesheet.total_billable_amount, 100) def test_salary_slip_from_timesheet(self): salary_structure = make_salary_structure("_T-Employee-0001") diff --git a/erpnext/projects/doctype/timesheet/timesheet.js b/erpnext/projects/doctype/timesheet/timesheet.js index c591ccb54b..1b6f95678d 100644 --- a/erpnext/projects/doctype/timesheet/timesheet.js +++ b/erpnext/projects/doctype/timesheet/timesheet.js @@ -25,7 +25,7 @@ frappe.ui.form.on("Timesheet", { frm.fields_dict['time_logs'].grid.get_field('project').get_query = function() { return{ filters: { - 'status': frm.doc.company + 'company': frm.doc.company } } } @@ -159,12 +159,12 @@ var calculate_time_and_amount = function(frm) { var tl = frm.doc.time_logs || []; total_working_hr = 0; total_billing_hr = 0; - total_billing_amount = 0; + total_billable_amount = 0; total_costing_amount = 0; for(var i=0; i 0 and self.total_billing_amount > 0: - self.per_billed = (self.total_billed_amount * 100) / self.total_billing_amount + if self.total_billed_amount > 0 and self.total_billable_amount > 0: + self.per_billed = (self.total_billed_amount * 100) / self.total_billable_amount def update_billing_hours(self, args): if cint(args.billing_hours) == 0: @@ -276,7 +276,7 @@ def get_timesheet(doctype, txt, searchfield, start, page_len, filters): return frappe.db.sql("""select distinct tsd.parent from `tabTimesheet Detail` tsd, `tabTimesheet` ts where ts.status in ('Submitted', 'Payslip') and tsd.parent = ts.name and - tsd.docstatus = 1 and ts.total_billing_amount > 0 + tsd.docstatus = 1 and ts.total_billable_amount > 0 and tsd.parent LIKE %(txt)s {condition} order by tsd.parent limit %(start)s, %(page_len)s""" .format(condition=condition), { @@ -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_billing_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_billing_hours as billing_hours"], filters = {'name': name}) return { 'billing_hours': data[0].billing_hours, @@ -306,10 +306,10 @@ 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_amount': flt(timesheet.total_billing_amount) - flt(timesheet.total_billed_amount) + 'billing_amount': flt(timesheet.total_billable_amount) - flt(timesheet.total_billed_amount) }) - target.run_method("calculate_billing_amount_from_timesheet") + target.run_method("calculate_billing_amount_for_timesheet") return target