Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Sales Invoice): allow linking to project without adding timesheets #44295

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions erpnext/accounts/doctype/sales_invoice/sales_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -1092,13 +1092,16 @@ def set_billing_hours_and_amount(self):
timesheet.billing_amount = ts_doc.total_billable_amount

def update_timesheet_billing_for_project(self):
if not self.timesheets and self.project:
self.add_timesheet_data()
else:
if self.timesheets:
self.calculate_billing_amount_for_timesheet()

@frappe.whitelist()
@frappe.whitelist(methods=["PUT"])
def add_timesheet_data(self):
if not self.timesheets and self.project:
self._add_timesheet_data()
self.save()

def _add_timesheet_data(self):
self.set("timesheets", [])
if self.project:
for data in get_projectwise_timesheet_data(self.project):
Expand Down
1 change: 1 addition & 0 deletions erpnext/projects/doctype/timesheet/test_timesheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def test_timesheet_billing_based_on_project(self):
)
sales_invoice = create_sales_invoice(do_not_save=True)
sales_invoice.project = project
sales_invoice._add_timesheet_data()
sales_invoice.submit()

ts = frappe.get_doc("Timesheet", timesheet.name)
Expand Down
Loading