def test_scrap_asset(self): asset = frappe.get_doc("Asset", "Macbook Pro 1") asset.submit() post_depreciation_entries(date="2021-01-01") scrap_asset("Macbook Pro 1") asset.load_from_db() self.assertEqual(asset.status, "Scrapped") self.assertTrue(asset.journal_entry_for_scrap) expected_gle = ( ("_Test Accumulated Depreciations - _TC", 30000.0, 0.0), ("_Test Fixed Asset - _TC", 0.0, 100000.0), ("_Test Gain/Loss on Asset Disposal - _TC", 70000.0, 0.0) ) gle = frappe.db.sql("""select account, debit, credit from `tabGL Entry` where voucher_type='Journal Entry' and voucher_no = %s order by account""", asset.journal_entry_for_scrap) self.assertEqual(gle, expected_gle) restore_asset("Macbook Pro 1") asset.load_from_db() self.assertFalse(asset.journal_entry_for_scrap) self.assertEqual(asset.status, "Partially Depreciated")
def test_scrap_asset(self): asset = frappe.get_doc("Asset", "Macbook Pro 1") asset.submit() post_depreciation_entries(date="2021-01-01") scrap_asset("Macbook Pro 1") asset.load_from_db() self.assertEqual(asset.status, "Scrapped") self.assertTrue(asset.journal_entry_for_scrap) expected_gle = (("_Test Accumulated Depreciations - _TC", 30000.0, 0.0), ("_Test Fixed Asset - _TC", 0.0, 100000.0), ("_Test Gain/Loss on Asset Disposal - _TC", 70000.0, 0.0)) gle = frappe.db.sql( """select account, debit, credit from `tabGL Entry` where voucher_type='Journal Entry' and voucher_no = %s order by account""", asset.journal_entry_for_scrap) self.assertEqual(gle, expected_gle) restore_asset("Macbook Pro 1") asset.load_from_db() self.assertFalse(asset.journal_entry_for_scrap) self.assertEqual(asset.status, "Partially Depreciated")
def test_scrap_asset(self): pr = make_purchase_receipt(item_code="Macbook Pro", qty=1, rate=100000.0, location="Test Location") asset_name = frappe.db.get_value("Asset", {"purchase_receipt": pr.name}, 'name') asset = frappe.get_doc('Asset', asset_name) asset.calculate_depreciation = 1 asset.available_for_use_date = nowdate() asset.purchase_date = nowdate() asset.append( "finance_books", { "expected_value_after_useful_life": 10000, "depreciation_method": "Straight Line", "total_number_of_depreciations": 3, "frequency_of_depreciation": 10, "depreciation_start_date": nowdate() }) asset.insert() asset.submit() post_depreciation_entries(date=add_months(nowdate(), 10)) scrap_asset(asset.name) asset.load_from_db() self.assertEqual(asset.status, "Scrapped") self.assertTrue(asset.journal_entry_for_scrap) expected_gle = (("_Test Accumulated Depreciations - _TC", 30000.0, 0.0), ("_Test Fixed Asset - _TC", 0.0, 100000.0), ("_Test Gain/Loss on Asset Disposal - _TC", 70000.0, 0.0)) gle = frappe.db.sql( """select account, debit, credit from `tabGL Entry` where voucher_type='Journal Entry' and voucher_no = %s order by account""", asset.journal_entry_for_scrap) self.assertEqual(gle, expected_gle) restore_asset(asset.name) asset.load_from_db() self.assertFalse(asset.journal_entry_for_scrap) self.assertEqual(asset.status, "Partially Depreciated")