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

fix: incorrect Gross Margin on project (backport #44461) #44468

Merged
Merged
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
3 changes: 3 additions & 0 deletions erpnext/accounts/doctype/sales_invoice/sales_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -1755,6 +1755,9 @@ def validate_serial_against_delivery_note(self):

def update_project(self):
unique_projects = list(set([d.project for d in self.get("items") if d.project]))
if self.project and self.project not in unique_projects:
unique_projects.append(self.project)

for p in unique_projects:
project = frappe.get_doc("Project", p)
project.update_billed_amount()
Expand Down
14 changes: 14 additions & 0 deletions erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -4217,6 +4217,20 @@ def test_common_party_with_different_currency_in_debtor_and_creditor(self):
self.assertTrue(jv)
self.assertEqual(jv[0], si.grand_total)

def test_total_billed_amount(self):
si = create_sales_invoice(do_not_submit=True)

project = frappe.new_doc("Project")
project.project_name = "Test Total Billed Amount"
project.save()

si.project = project.name
si.save()
si.submit()

doc = frappe.get_doc("Project", project.name)
self.assertEqual(doc.total_billed_amount, si.grand_total)


def set_advance_flag(company, flag, default_account):
frappe.db.set_value(
Expand Down
Loading