From 74fc1e4cc3180ced102b1d746a544c297b6335fd Mon Sep 17 00:00:00 2001 From: Sugesh393 Date: Fri, 20 Dec 2024 16:27:00 +0530 Subject: [PATCH] chore: update company in department accounting dimension --- .../sales_invoice/test_sales_invoice.py | 19 ++++++++++++++++--- .../tests/test_accounts_controller.py | 10 ++++++++++ .../doctype/timesheet/test_timesheet.py | 12 +++++++++--- 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py index 6ec1df5d7121..8b31da6863e0 100644 --- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py @@ -77,7 +77,7 @@ def make(self): @classmethod def setUpClass(cls): super().setUpClass() - cls.enterClassContext(cls.change_settings("Selling Settings", validate_selling_price=0)) + # cls.enterClassContext(cls.change_settings("Selling Settings", validate_selling_price=0)) unlink_payment_on_cancel_of_invoice() @classmethod @@ -3115,6 +3115,15 @@ def test_sales_invoice_against_supplier_usd_with_dimensions(self): # enable common party accounting frappe.db.set_single_value("Accounts Settings", "enable_common_party_accounting", 1) + department = frappe.new_doc("Department") + department.department_name = "Test Department" + department.company = "_Test Company" + department.save() + + location = frappe.get_doc("Accounting Dimension", "Location") + location.dimension_defaults[0].mandatory_for_bs = 0 + location.save() + # create a dimension and make it mandatory if not frappe.get_all("Accounting Dimension", filters={"document_type": "Department"}): dim = frappe.get_doc( @@ -3139,7 +3148,7 @@ def test_sales_invoice_against_supplier_usd_with_dimensions(self): si = create_sales_invoice( customer=customer, parent_cost_center="_Test Cost Center - _TC", do_not_submit=True ) - si.department = "All Departments" + si.department = "Test Department - _TC" si.save().submit() # check outstanding of sales invoice @@ -3156,7 +3165,7 @@ def test_sales_invoice_against_supplier_usd_with_dimensions(self): "party": si.customer, "reference_type": si.doctype, "reference_name": si.name, - "department": "All Departments", + "department": "Test Department - _TC", }, pluck="credit_in_account_currency", ) @@ -4281,8 +4290,12 @@ def test_total_billed_amount(self): project = frappe.new_doc("Project") project.project_name = "Test Total Billed Amount" + project.company = "_Test Company" project.save() + location = frappe.get_doc("Accounting Dimension", "Location") + location.dimension_defaults[0].mandatory_for_bs = 0 + location.save() si.project = project.name si.save() si.submit() diff --git a/erpnext/controllers/tests/test_accounts_controller.py b/erpnext/controllers/tests/test_accounts_controller.py index f54bf29863fb..3f3f1b4f1069 100644 --- a/erpnext/controllers/tests/test_accounts_controller.py +++ b/erpnext/controllers/tests/test_accounts_controller.py @@ -1467,6 +1467,13 @@ def test_90_dimensions_filter(self): """ self.setup_dimensions() rate_in_account_currency = 1 + department = frappe.get_all( + "Department", + {"name": ["in", ["Management", "Operations", "Legal", "Research & Development"]]}, + ["name", "company"], + ) + for dept in department: + frappe.db.set_value("Department", dept.name, "company", "_Test Company") # Invoices si1 = self.create_sales_invoice(qty=1, rate=rate_in_account_currency, do_not_submit=True) @@ -1535,6 +1542,7 @@ def test_90_dimensions_filter(self): def test_91_cr_note_should_inherit_dimension(self): self.setup_dimensions() rate_in_account_currency = 1 + frappe.db.set_value("Department", "Management", "company", "_Test Company") # Invoice si = self.create_sales_invoice(qty=1, rate=rate_in_account_currency, do_not_submit=True) @@ -1581,6 +1589,7 @@ def test_92_dimension_inhertiance_exc_gain_loss(self): self.setup_dimensions() rate_in_account_currency = 1 dpt = "Research & Development" + frappe.db.set_value("Department", dpt, "company", "_Test Company") si = self.create_sales_invoice(qty=1, rate=rate_in_account_currency, do_not_save=True) si.department = dpt @@ -1616,6 +1625,7 @@ def test_92_dimension_inhertiance_exc_gain_loss(self): def test_93_dimension_inheritance_on_advance(self): self.setup_dimensions() dpt = "Research & Development" + frappe.db.set_value("Department", dpt, "company", "_Test Company") adv = self.create_payment_entry(amount=1, source_exc_rate=85) adv.department = dpt diff --git a/erpnext/projects/doctype/timesheet/test_timesheet.py b/erpnext/projects/doctype/timesheet/test_timesheet.py index ba2f95ba59b0..5902b377ceed 100644 --- a/erpnext/projects/doctype/timesheet/test_timesheet.py +++ b/erpnext/projects/doctype/timesheet/test_timesheet.py @@ -55,13 +55,19 @@ def test_sales_invoice_from_timesheet(self): def test_timesheet_billing_based_on_project(self): emp = make_employee("test_employee_6@salary.com") - project = frappe.get_value("Project", {"project_name": "_Test Project"}) + project = frappe.get_doc("Project", "_T-Project-00001") + project.company = "_Test Company" + project.save() + + location = frappe.get_doc("Accounting Dimension", "Location") + location.dimension_defaults[0].mandatory_for_bs = 0 + location.save() timesheet = make_timesheet( - emp, simulate=True, is_billable=1, project=project, company="_Test Company" + emp, simulate=True, is_billable=1, project=project.name, company="_Test Company" ) sales_invoice = create_sales_invoice(do_not_save=True) - sales_invoice.project = project + sales_invoice.project = project.name sales_invoice.submit() ts = frappe.get_doc("Timesheet", timesheet.name)