From b5e5d3b3af9116d29b65e1edcebea3b2fb895344 Mon Sep 17 00:00:00 2001 From: anandbaburajan Date: Thu, 17 Nov 2022 12:13:06 +0530 Subject: [PATCH 1/2] fix: precision in asset tests --- erpnext/assets/doctype/asset/test_asset.py | 43 ++++++++++++++++++---- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/erpnext/assets/doctype/asset/test_asset.py b/erpnext/assets/doctype/asset/test_asset.py index 5c1311d68a..417d62f7ec 100644 --- a/erpnext/assets/doctype/asset/test_asset.py +++ b/erpnext/assets/doctype/asset/test_asset.py @@ -230,9 +230,22 @@ class TestAsset(AssetSetup): self.assertTrue(asset.journal_entry_for_scrap) expected_gle = ( - ("_Test Accumulated Depreciations - _TC", 18000.0 + pro_rata_amount, 0.0), - ("_Test Fixed Asset - _TC", 0.0, 100000.0), - ("_Test Gain/Loss on Asset Disposal - _TC", 82000.0 - pro_rata_amount, 0.0), + ( + "_Test Accumulated Depreciations - _TC", + flt(18000.0 + pro_rata_amount, asset.precision("gross_purchase_amount")), + 0.0 + ), + ( + "_Test Fixed Asset - _TC", + 0.0, + 100000.0 + ), + ( + "_Test Gain/Loss on Asset Disposal - _TC", + flt(82000.0 - pro_rata_amount, asset.precision("gross_purchase_amount")), + 0.0 + ), + ) gle = frappe.db.sql( @@ -288,10 +301,26 @@ class TestAsset(AssetSetup): pro_rata_amount = flt(pro_rata_amount, asset.precision("gross_purchase_amount")) expected_gle = ( - ("_Test Accumulated Depreciations - _TC", 18000.0 + pro_rata_amount, 0.0), - ("_Test Fixed Asset - _TC", 0.0, 100000.0), - ("_Test Gain/Loss on Asset Disposal - _TC", 57000.0 - pro_rata_amount, 0.0), - ("Debtors - _TC", 25000.0, 0.0), + ( + "_Test Accumulated Depreciations - _TC", + flt(18000.0 + pro_rata_amount, asset.precision("gross_purchase_amount")) + 0.0 + ), + ( + "_Test Fixed Asset - _TC", + 0.0, + 100000.0 + ), + ( + "_Test Gain/Loss on Asset Disposal - _TC", + flt(57000.0 - pro_rata_amount, asset.precision("gross_purchase_amount")) + 0.0 + ), + ( + "Debtors - _TC", + 25000.0, + 0.0 + ), ) gle = frappe.db.sql( From 218da1217a27d759fc853ace4c372c1f82b2cbf2 Mon Sep 17 00:00:00 2001 From: anandbaburajan Date: Thu, 17 Nov 2022 12:22:05 +0530 Subject: [PATCH 2/2] fix: add missing commas and brackets --- erpnext/assets/doctype/asset/test_asset.py | 27 ++++++---------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/erpnext/assets/doctype/asset/test_asset.py b/erpnext/assets/doctype/asset/test_asset.py index 417d62f7ec..19c913ae91 100644 --- a/erpnext/assets/doctype/asset/test_asset.py +++ b/erpnext/assets/doctype/asset/test_asset.py @@ -233,19 +233,14 @@ class TestAsset(AssetSetup): ( "_Test Accumulated Depreciations - _TC", flt(18000.0 + pro_rata_amount, asset.precision("gross_purchase_amount")), - 0.0 - ), - ( - "_Test Fixed Asset - _TC", 0.0, - 100000.0 ), + ("_Test Fixed Asset - _TC", 0.0, 100000.0), ( "_Test Gain/Loss on Asset Disposal - _TC", flt(82000.0 - pro_rata_amount, asset.precision("gross_purchase_amount")), - 0.0 + 0.0, ), - ) gle = frappe.db.sql( @@ -303,24 +298,16 @@ class TestAsset(AssetSetup): expected_gle = ( ( "_Test Accumulated Depreciations - _TC", - flt(18000.0 + pro_rata_amount, asset.precision("gross_purchase_amount")) - 0.0 - ), - ( - "_Test Fixed Asset - _TC", + flt(18000.0 + pro_rata_amount, asset.precision("gross_purchase_amount")), 0.0, - 100000.0 ), + ("_Test Fixed Asset - _TC", 0.0, 100000.0), ( "_Test Gain/Loss on Asset Disposal - _TC", - flt(57000.0 - pro_rata_amount, asset.precision("gross_purchase_amount")) - 0.0 - ), - ( - "Debtors - _TC", - 25000.0, - 0.0 + flt(57000.0 - pro_rata_amount, asset.precision("gross_purchase_amount")), + 0.0, ), + ("Debtors - _TC", 25000.0, 0.0), ) gle = frappe.db.sql(