Beispiel #1
0
	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")
Beispiel #2
0
    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")
Beispiel #3
0
def work():
    frappe.set_user(frappe.db.get_global('demo_accounts_user'))

    asset_list = make_asset_purchase_entry()

    if not asset_list:
        # fixed_asset.work() already run
        return

    # Enable booking asset depreciation entry automatically
    frappe.db.set_value("Accounts Settings", None,
                        "book_asset_depreciation_entry_automatically", 1)

    # post depreciation entries as on today
    post_depreciation_entries()

    # scrap a random asset
    frappe.db.set_value("Company", "Wind Power LLC", "disposal_account",
                        "Gain/Loss on Asset Disposal - WPL")

    asset = get_random_asset()
    scrap_asset(asset.name)

    # Sell a random asset
    sell_an_asset()
Beispiel #4
0
def work():
	frappe.set_user(frappe.db.get_global('demo_accounts_user'))

	asset_list = make_asset_purchase_entry()

	if not asset_list:
		# fixed_asset.work() already run
		return
		
	# post depreciation entries as on today
	post_depreciation_entries()
	
	# scrap a random asset
	frappe.db.set_value("Company", "Wind Power LLC", "disposal_account", "Gain/Loss on Asset Disposal - WPL")
	
	asset = get_random_asset()
	scrap_asset(asset.name)
	
	# Sell a random asset
	sell_an_asset()