From cbf973d90ff877f67087f5e87b83318a32c9bf71 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 14 Sep 2022 12:55:49 +0530 Subject: [PATCH 1/3] fix: always set default expense account in company --- erpnext/setup/doctype/company/company.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/setup/doctype/company/company.py b/erpnext/setup/doctype/company/company.py index dc698886a0..490504a7c9 100644 --- a/erpnext/setup/doctype/company/company.py +++ b/erpnext/setup/doctype/company/company.py @@ -389,6 +389,7 @@ class Company(NestedSet): "capital_work_in_progress_account": "Capital Work in Progress", "asset_received_but_not_billed": "Asset Received But Not Billed", "expenses_included_in_asset_valuation": "Expenses Included In Asset Valuation", + "default_expense_account": "Cost of Goods Sold", } if self.enable_perpetual_inventory: @@ -398,7 +399,6 @@ class Company(NestedSet): "default_inventory_account": "Stock", "stock_adjustment_account": "Stock Adjustment", "expenses_included_in_valuation": "Expenses Included In Valuation", - "default_expense_account": "Cost of Goods Sold", } ) From a5b58859334218dde1876a42fbceda870152f046 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 14 Sep 2022 17:20:19 +0530 Subject: [PATCH 2/3] fix: test cases --- .../stock_reconciliation/test_stock_reconciliation.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py b/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py index 4e76ae781f..7b984d3847 100644 --- a/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py +++ b/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py @@ -729,15 +729,19 @@ def create_stock_reconciliation(**args): sr.expense_account = args.expense_account or ( ( frappe.get_cached_value("Company", sr.company, "stock_adjustment_account") - or "Stock Adjustment - _TC" + or frappe.get_cached_value( + "Account", {"account_type": "Stock Adjustment", "company": sr.company}, "name" + ) ) if frappe.get_all("Stock Ledger Entry", {"company": sr.company}) - else "Temporary Opening - _TC" + else frappe.get_cached_value( + "Account", {"account_type": "Temporary", "company": sr.company}, "name" + ) ) sr.cost_center = ( args.cost_center or frappe.get_cached_value("Company", sr.company, "cost_center") - or "_Test Cost Center - _TC" + or frappe.get_cached_value("Cost Center", filters={"is_group": 0, "company": sr.company}) ) sr.append( From 34571055048839a6c1a53dc6cd690ebde55fbbcd Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 14 Sep 2022 18:31:15 +0530 Subject: [PATCH 3/3] fix: test cases --- .../assets/doctype/asset_repair/test_asset_repair.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/erpnext/assets/doctype/asset_repair/test_asset_repair.py b/erpnext/assets/doctype/asset_repair/test_asset_repair.py index 2786349f7b..6e06f52ac6 100644 --- a/erpnext/assets/doctype/asset_repair/test_asset_repair.py +++ b/erpnext/assets/doctype/asset_repair/test_asset_repair.py @@ -129,6 +129,18 @@ class TestAssetRepair(unittest.TestCase): def test_gl_entries_with_perpetual_inventory(self): set_depreciation_settings_in_company(company="_Test Company with perpetual inventory") + asset_category = frappe.get_doc("Asset Category", "Computers") + asset_category.append( + "accounts", + { + "company_name": "_Test Company with perpetual inventory", + "fixed_asset_account": "_Test Fixed Asset - TCP1", + "accumulated_depreciation_account": "_Test Accumulated Depreciations - TCP1", + "depreciation_expense_account": "_Test Depreciations - TCP1", + }, + ) + asset_category.save() + asset_repair = create_asset_repair( capitalize_repair_cost=1, stock_consumption=1,