Exemplo n.º 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")
Exemplo n.º 2
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()
Exemplo n.º 3
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")
Exemplo n.º 4
0
    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")
Exemplo n.º 5
0
def work():
	frappe.set_user(frappe.db.get_global("demo_accounts_user"))

	# 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()
Exemplo n.º 6
0
	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 = '2020-06-06'
		asset.purchase_date = '2020-06-06'
		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": "2020-06-06"
		})
		asset.insert()
		asset.submit()
		post_depreciation_entries(date="2021-01-01")

		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", 100000.0, 0.0),
			("_Test Fixed Asset - _TC", 0.0, 100000.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")
Exemplo n.º 7
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()