Example #1
0
	def test_asset_sale(self):
		frappe.get_doc("Asset", "Macbook Pro 1").submit()
		post_depreciation_entries(date="2021-01-01")

		si = make_sales_invoice(asset="Macbook Pro 1", item_code="Macbook Pro", company="_Test Company")
		si.customer = "_Test Customer"
		si.due_date = nowdate()
		si.get("items")[0].rate = 25000
		si.insert()
		si.submit()

		self.assertEqual(frappe.db.get_value("Asset", "Macbook Pro 1", "status"), "Sold")

		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", 45000.0, 0.0),
			("Debtors - _TC", 25000.0, 0.0)
		)

		gle = frappe.db.sql("""select account, debit, credit from `tabGL Entry`
			where voucher_type='Sales Invoice' and voucher_no = %s
			order by account""", si.name)

		self.assertEqual(gle, expected_gle)

		si.cancel()

		self.assertEqual(frappe.db.get_value("Asset", "Macbook Pro 1", "status"), "Partially Depreciated")
Example #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")
Example #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")
Example #4
0
    def test_asset_sale(self):
        frappe.get_doc("Asset", "Macbook Pro 1").submit()
        post_depreciation_entries(date="2021-01-01")

        si = make_sales_invoice(asset="Macbook Pro 1",
                                item_code="Macbook Pro",
                                company="_Test Company")
        si.customer = "_Test Customer"
        si.due_date = nowdate()
        si.get("items")[0].rate = 25000
        si.insert()
        si.submit()

        self.assertEqual(
            frappe.db.get_value("Asset", "Macbook Pro 1", "status"), "Sold")

        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", 45000.0,
                         0.0), ("Debtors - _TC", 25000.0, 0.0))

        gle = frappe.db.sql(
            """select account, debit, credit from `tabGL Entry`
			where voucher_type='Sales Invoice' and voucher_no = %s
			order by account""", si.name)

        self.assertEqual(gle, expected_gle)

        si.cancel()

        self.assertEqual(
            frappe.db.get_value("Asset", "Macbook Pro 1", "status"),
            "Partially Depreciated")
Example #5
0
    def test_depreciation(self):
        asset = frappe.get_doc("Asset", "Macbook Pro 1")
        asset.submit()
        asset.load_from_db()
        self.assertEqual(asset.status, "Submitted")

        frappe.db.set_value("Company", "_Test Company",
                            "series_for_depreciation_entry", "DEPR-")

        post_depreciation_entries(date="2021-01-01")
        asset.load_from_db()

        self.assertEqual(asset.status, "Partially Depreciated")

        # check depreciation entry series
        self.assertEqual(asset.get("schedules")[0].journal_entry[:4], "DEPR")

        expected_gle = (("_Test Accumulated Depreciations - _TC", 0.0,
                         30000.0), ("_Test Depreciations - _TC", 30000.0, 0.0))

        gle = frappe.db.sql(
            """select account, debit, credit from `tabGL Entry`
			where against_voucher_type='Asset' and against_voucher = %s
			order by account""", asset.name)

        self.assertEqual(gle, expected_gle)
        self.assertEqual(asset.get("value_after_depreciation"), 70000)
Example #6
0
	def test_depreciation(self):
		asset = frappe.get_doc("Asset", "Macbook Pro 1")
		asset.submit()
		asset.load_from_db()
		self.assertEqual(asset.status, "Submitted")

		frappe.db.set_value("Company", "_Test Company", "series_for_depreciation_entry", "DEPR-")

		post_depreciation_entries(date="2021-01-01")
		asset.load_from_db()

		self.assertEqual(asset.status, "Partially Depreciated")

		# check depreciation entry series
		self.assertEqual(asset.get("schedules")[0].journal_entry[:4], "DEPR")

		expected_gle = (
			("_Test Accumulated Depreciations - _TC", 0.0, 30000.0),
			("_Test Depreciations - _TC", 30000.0, 0.0)
		)

		gle = frappe.db.sql("""select account, debit, credit from `tabGL Entry`
			where against_voucher_type='Asset' and against_voucher = %s
			order by account""", asset.name)

		self.assertEqual(gle, expected_gle)
		self.assertEqual(asset.get("value_after_depreciation"), 70000)
Example #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()
Example #8
0
	def test_depreciation_entry_cancellation(self):
		asset = frappe.get_doc("Asset", "Macbook Pro 1")
		asset.submit()
		post_depreciation_entries(date="2021-01-01")
		
		asset.load_from_db()
		
		# cancel depreciation entry
		depr_entry = asset.get("schedules")[0].journal_entry
		self.assertTrue(depr_entry)
		frappe.get_doc("Journal Entry", depr_entry).cancel()
		
		asset.load_from_db()
		depr_entry = asset.get("schedules")[0].journal_entry
		self.assertFalse(depr_entry)
Example #9
0
    def test_depreciation_entry_cancellation(self):
        asset = frappe.get_doc("Asset", "Macbook Pro 1")
        asset.submit()
        post_depreciation_entries(date="2021-01-01")

        asset.load_from_db()

        # cancel depreciation entry
        depr_entry = asset.get("schedules")[0].journal_entry
        self.assertTrue(depr_entry)
        frappe.get_doc("Journal Entry", depr_entry).cancel()

        asset.load_from_db()
        depr_entry = asset.get("schedules")[0].journal_entry
        self.assertFalse(depr_entry)
Example #10
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()