mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-01 12:38:27 +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):
|
||||
for row in self.timesheets:
|
||||
timesheet = frappe.get_doc("Timesheet", row.time_sheet)
|
||||
for time_log in timesheet.time_logs:
|
||||
if time_log.sales_invoice == self.name:
|
||||
time_log.sales_invoice = None
|
||||
timesheet.calculate_total_amounts()
|
||||
timesheet.calculate_percentage_billed()
|
||||
timesheet.unlink_sales_invoice(self.name)
|
||||
timesheet.flags.ignore_validate_update_after_submit = True
|
||||
timesheet.set_status()
|
||||
timesheet.db_update_all()
|
||||
|
||||
@frappe.whitelist()
|
||||
|
||||
@@ -256,6 +256,16 @@ class Timesheet(Document):
|
||||
if not ts_detail.is_billable:
|
||||
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()
|
||||
def get_projectwise_timesheet_data(project=None, parent=None, from_time=None, to_time=None):
|
||||
|
||||
Reference in New Issue
Block a user