rename total_billing_amount to total_billable_amount in timesheet doctype

This commit is contained in:
Rohit Waghchaure
2016-09-12 19:06:41 +05:30
parent 4eb908fc76
commit 7b6fdb77d0
11 changed files with 33 additions and 23 deletions

View File

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

View File

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

View File

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

View File

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