The series added for Asset Depreciation Entry (#10268)
This commit is contained in:
parent
1ac6bcba23
commit
7f476b4528
@ -36,12 +36,15 @@ def make_depreciation_entry(asset_name, date=None):
|
|||||||
fixed_asset_account, accumulated_depreciation_account, depreciation_expense_account = \
|
fixed_asset_account, accumulated_depreciation_account, depreciation_expense_account = \
|
||||||
get_depreciation_accounts(asset)
|
get_depreciation_accounts(asset)
|
||||||
|
|
||||||
depreciation_cost_center = frappe.db.get_value("Company", asset.company, "depreciation_cost_center")
|
depreciation_cost_center, depreciation_series = frappe.db.get_value("Company", asset.company,
|
||||||
|
["depreciation_cost_center", "series_for_depreciation_entry"])
|
||||||
|
|
||||||
|
|
||||||
for d in asset.get("schedules"):
|
for d in asset.get("schedules"):
|
||||||
if not d.journal_entry and getdate(d.schedule_date) <= getdate(date):
|
if not d.journal_entry and getdate(d.schedule_date) <= getdate(date):
|
||||||
je = frappe.new_doc("Journal Entry")
|
je = frappe.new_doc("Journal Entry")
|
||||||
je.voucher_type = "Depreciation Entry"
|
je.voucher_type = "Depreciation Entry"
|
||||||
|
je.naming_series = depreciation_series
|
||||||
je.posting_date = d.schedule_date
|
je.posting_date = d.schedule_date
|
||||||
je.company = asset.company
|
je.company = asset.company
|
||||||
je.remark = "Depreciation Entry against {0} worth {1}".format(asset_name, d.depreciation_amount)
|
je.remark = "Depreciation Entry against {0} worth {1}".format(asset_name, d.depreciation_amount)
|
||||||
@ -109,8 +112,11 @@ def scrap_asset(asset_name):
|
|||||||
elif asset.status in ("Cancelled", "Sold", "Scrapped"):
|
elif asset.status in ("Cancelled", "Sold", "Scrapped"):
|
||||||
frappe.throw(_("Asset {0} cannot be scrapped, as it is already {1}").format(asset.name, asset.status))
|
frappe.throw(_("Asset {0} cannot be scrapped, as it is already {1}").format(asset.name, asset.status))
|
||||||
|
|
||||||
|
depreciation_series = frappe.db.get_value("Company", asset.company, "series_for_depreciation_entry")
|
||||||
|
|
||||||
je = frappe.new_doc("Journal Entry")
|
je = frappe.new_doc("Journal Entry")
|
||||||
je.voucher_type = "Journal Entry"
|
je.voucher_type = "Journal Entry"
|
||||||
|
je.naming_series = depreciation_series
|
||||||
je.posting_date = today()
|
je.posting_date = today()
|
||||||
je.company = asset.company
|
je.company = asset.company
|
||||||
je.remark = "Scrap Entry for asset {0}".format(asset_name)
|
je.remark = "Scrap Entry for asset {0}".format(asset_name)
|
||||||
|
@ -150,11 +150,16 @@ class TestAsset(unittest.TestCase):
|
|||||||
asset.load_from_db()
|
asset.load_from_db()
|
||||||
self.assertEqual(asset.status, "Submitted")
|
self.assertEqual(asset.status, "Submitted")
|
||||||
|
|
||||||
|
frappe.db.set_value("Company", "_Test Company", "series_for_depreciation_entry", "DEPR-")
|
||||||
|
|
||||||
post_depreciation_entries(date="2021-01-01")
|
post_depreciation_entries(date="2021-01-01")
|
||||||
asset.load_from_db()
|
asset.load_from_db()
|
||||||
|
|
||||||
self.assertEqual(asset.status, "Partially Depreciated")
|
self.assertEqual(asset.status, "Partially Depreciated")
|
||||||
|
|
||||||
|
# check depreciation entry series
|
||||||
|
self.assertEqual(asset.get("schedules")[0].journal_entry[:4], "DEPR")
|
||||||
|
|
||||||
expected_gle = (
|
expected_gle = (
|
||||||
("_Test Accumulated Depreciations - _TC", 0.0, 30000.0),
|
("_Test Accumulated Depreciations - _TC", 0.0, 30000.0),
|
||||||
("_Test Depreciations - _TC", 30000.0, 0.0)
|
("_Test Depreciations - _TC", 30000.0, 0.0)
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user