mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-07 15:25:19 +00:00
fix: incorrect Gross Margin on project (#44461)
(cherry picked from commit 7de9c14a2c)
# Conflicts:
# erpnext/accounts/doctype/sales_invoice/sales_invoice.py
# erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
This commit is contained in:
@@ -1556,8 +1556,17 @@ class SalesInvoice(SellingController):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def update_project(self):
|
def update_project(self):
|
||||||
|
<<<<<<< HEAD
|
||||||
if self.project:
|
if self.project:
|
||||||
project = frappe.get_doc("Project", self.project)
|
project = frappe.get_doc("Project", self.project)
|
||||||
|
=======
|
||||||
|
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)
|
||||||
|
>>>>>>> 7de9c14a2c (fix: incorrect Gross Margin on project (#44461))
|
||||||
project.update_billed_amount()
|
project.update_billed_amount()
|
||||||
project.db_update()
|
project.db_update()
|
||||||
|
|
||||||
|
|||||||
@@ -3843,6 +3843,7 @@ class TestSalesInvoice(FrappeTestCase):
|
|||||||
self.assertEqual(jv[0], si.grand_total)
|
self.assertEqual(jv[0], si.grand_total)
|
||||||
|
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
def check_gl_entries(doc, voucher_no, expected_gle, posting_date):
|
def check_gl_entries(doc, voucher_no, expected_gle, posting_date):
|
||||||
gl_entries = frappe.db.sql(
|
gl_entries = frappe.db.sql(
|
||||||
"""select account, debit, credit, posting_date
|
"""select account, debit, credit, posting_date
|
||||||
@@ -3852,6 +3853,50 @@ def check_gl_entries(doc, voucher_no, expected_gle, posting_date):
|
|||||||
order by posting_date asc, account asc""",
|
order by posting_date asc, account asc""",
|
||||||
(voucher_no, posting_date),
|
(voucher_no, posting_date),
|
||||||
as_dict=1,
|
as_dict=1,
|
||||||
|
=======
|
||||||
|
def test_gl_voucher_subtype(self):
|
||||||
|
si = create_sales_invoice()
|
||||||
|
gl_entries = frappe.get_all(
|
||||||
|
"GL Entry",
|
||||||
|
filters={"voucher_type": "Sales Invoice", "voucher_no": si.name},
|
||||||
|
pluck="voucher_subtype",
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertTrue(all([x == "Sales Invoice" for x in gl_entries]))
|
||||||
|
|
||||||
|
si = create_sales_invoice(is_return=1, qty=-1)
|
||||||
|
gl_entries = frappe.get_all(
|
||||||
|
"GL Entry",
|
||||||
|
filters={"voucher_type": "Sales Invoice", "voucher_no": si.name},
|
||||||
|
pluck="voucher_subtype",
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertTrue(all([x == "Credit Note" for x in gl_entries]))
|
||||||
|
|
||||||
|
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(
|
||||||
|
"Company",
|
||||||
|
company,
|
||||||
|
{
|
||||||
|
"book_advance_payments_in_separate_party_account": flag,
|
||||||
|
"default_advance_received_account": default_account,
|
||||||
|
},
|
||||||
|
>>>>>>> 7de9c14a2c (fix: incorrect Gross Margin on project (#44461))
|
||||||
)
|
)
|
||||||
|
|
||||||
for i, gle in enumerate(gl_entries):
|
for i, gle in enumerate(gl_entries):
|
||||||
|
|||||||
Reference in New Issue
Block a user