mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-01 11:19:09 +00:00
refactor: move code for unlinking sales invoice to Timesheet
This commit is contained in:
@@ -652,13 +652,8 @@ class SalesInvoice(SellingController):
|
|||||||
def unlink_sales_invoice_from_timesheets(self):
|
def unlink_sales_invoice_from_timesheets(self):
|
||||||
for row in self.timesheets:
|
for row in self.timesheets:
|
||||||
timesheet = frappe.get_doc("Timesheet", row.time_sheet)
|
timesheet = frappe.get_doc("Timesheet", row.time_sheet)
|
||||||
for time_log in timesheet.time_logs:
|
timesheet.unlink_sales_invoice(self.name)
|
||||||
if time_log.sales_invoice == self.name:
|
|
||||||
time_log.sales_invoice = None
|
|
||||||
timesheet.calculate_total_amounts()
|
|
||||||
timesheet.calculate_percentage_billed()
|
|
||||||
timesheet.flags.ignore_validate_update_after_submit = True
|
timesheet.flags.ignore_validate_update_after_submit = True
|
||||||
timesheet.set_status()
|
|
||||||
timesheet.db_update_all()
|
timesheet.db_update_all()
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
|
|||||||
@@ -256,6 +256,16 @@ class Timesheet(Document):
|
|||||||
if not ts_detail.is_billable:
|
if not ts_detail.is_billable:
|
||||||
ts_detail.billing_rate = 0.0
|
ts_detail.billing_rate = 0.0
|
||||||
|
|
||||||
|
def unlink_sales_invoice(self, sales_invoice: str):
|
||||||
|
"""Remove link to Sales Invoice from all time logs."""
|
||||||
|
for time_log in self.time_logs:
|
||||||
|
if time_log.sales_invoice == sales_invoice:
|
||||||
|
time_log.sales_invoice = None
|
||||||
|
|
||||||
|
self.calculate_total_amounts()
|
||||||
|
self.calculate_percentage_billed()
|
||||||
|
self.set_status()
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_projectwise_timesheet_data(project=None, parent=None, from_time=None, to_time=None):
|
def get_projectwise_timesheet_data(project=None, parent=None, from_time=None, to_time=None):
|
||||||
|
|||||||
Reference in New Issue
Block a user