From 8a4c9d1238198d8951440534710a1b2a9ff32e84 Mon Sep 17 00:00:00 2001 From: Saqib Ansari Date: Wed, 8 Jun 2022 14:12:59 +0530 Subject: [PATCH 1/2] fix(asset): failing test case (#31277) --- erpnext/assets/doctype/asset/test_asset.py | 23 ++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/erpnext/assets/doctype/asset/test_asset.py b/erpnext/assets/doctype/asset/test_asset.py index 25929a744af..226a38a5849 100644 --- a/erpnext/assets/doctype/asset/test_asset.py +++ b/erpnext/assets/doctype/asset/test_asset.py @@ -193,30 +193,30 @@ class TestAsset(AssetSetup): def test_gle_made_by_asset_sale(self): asset = create_asset( calculate_depreciation=1, - available_for_use_date="2021-06-06", - purchase_date="2021-01-01", + available_for_use_date="2020-06-06", + purchase_date="2020-01-01", expected_value_after_useful_life=10000, total_number_of_depreciations=3, frequency_of_depreciation=10, - depreciation_start_date="2021-12-31", + depreciation_start_date="2020-12-31", submit=1, ) - - post_depreciation_entries(date="2022-01-01") + post_depreciation_entries(date="2021-01-01") si = make_sales_invoice(asset=asset.name, item_code="Macbook Pro", company="_Test Company") si.customer = "_Test Customer" - si.posting_date = getdate("2022-04-22") - si.due_date = getdate("2022-04-22") + si.set_posting_time = 1 + si.posting_date = "2021-10-31" + si.due_date = "2021-10-31" si.get("items")[0].rate = 75000 si.submit() self.assertEqual(frappe.db.get_value("Asset", asset.name, "status"), "Sold") expected_gle = ( - ("_Test Accumulated Depreciations - _TC", 36082.31, 0.0), + ("_Test Accumulated Depreciations - _TC", 50490.2, 0.0), ("_Test Fixed Asset - _TC", 0.0, 100000.0), - ("_Test Gain/Loss on Asset Disposal - _TC", 0.0, 11082.31), + ("_Test Gain/Loss on Asset Disposal - _TC", 0.0, 25490.2), ("Debtors - _TC", 75000.0, 0.0), ) @@ -227,7 +227,10 @@ class TestAsset(AssetSetup): si.name, ) - self.assertEqual(gle, expected_gle) + for i, gle_entry in enumerate(gle): + self.assertEqual(gle_entry[0], expected_gle[i][0]) + self.assertEqual(flt(gle_entry[1], 1), flt(expected_gle[i][1], 1)) + self.assertEqual(flt(gle_entry[2], 1), flt(expected_gle[i][2], 1)) si.load_from_db() si.cancel() From 633a4521e496446dc3ae87752a412d94dddd563c Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Wed, 8 Jun 2022 18:12:02 +0530 Subject: [PATCH 2/2] fix: Use `frappe.as_unicode` to decode output of redis module list (backport #31282) (#31283) fix: Use `frappe.as_unicode` to decode output of redis module list (#31282) - As of redis 7, a list is added to the result of fetching the module list - This list cannot be "decoded",so use `frappe.as_unicode` that handles bytes as well as other types (cherry picked from commit 2832731601920b07c7083a20c49868e866640add) Co-authored-by: Marica --- erpnext/e_commerce/redisearch_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/e_commerce/redisearch_utils.py b/erpnext/e_commerce/redisearch_utils.py index f2dd796f2c5..97da02688ef 100644 --- a/erpnext/e_commerce/redisearch_utils.py +++ b/erpnext/e_commerce/redisearch_utils.py @@ -38,7 +38,7 @@ def is_search_module_loaded(): out = cache.execute_command("MODULE LIST") parsed_output = " ".join( - (" ".join([s.decode() for s in o if not isinstance(s, int)]) for o in out) + (" ".join([frappe.as_unicode(s) for s in o if not isinstance(s, int)]) for o in out) ) return "search" in parsed_output except Exception: