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

* fix: incorrect Gross Margin on project (#44461)

(cherry picked from commit 7de9c14a2c)

# Conflicts:
#	erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py

* chore: resolve conflict

---------

Co-authored-by: rohitwaghchaure <rohitw1991@gmail.com>
Co-authored-by: ruthra kumar <ruthra@erpnext.com>
This commit is contained in:
mergify[bot]
2024-12-03 15:09:09 +05:30
committed by GitHub
parent 0c28726ce2
commit 0a9c92fce9
2 changed files with 17 additions and 0 deletions

View File

@@ -1755,6 +1755,9 @@ class SalesInvoice(SellingController):
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()

View File

@@ -4217,6 +4217,20 @@ class TestSalesInvoice(FrappeTestCase):
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(