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)
|
||||||
|
@ -1547,6 +1547,36 @@
|
|||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"collapsible": 0,
|
||||||
|
"columns": 0,
|
||||||
|
"fieldname": "series_for_depreciation_entry",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"hidden": 0,
|
||||||
|
"ignore_user_permissions": 0,
|
||||||
|
"ignore_xss_filter": 0,
|
||||||
|
"in_filter": 0,
|
||||||
|
"in_global_search": 0,
|
||||||
|
"in_list_view": 0,
|
||||||
|
"in_standard_filter": 0,
|
||||||
|
"label": "Series for Asset Depreciation Entry (Journal Entry)",
|
||||||
|
"length": 0,
|
||||||
|
"no_copy": 0,
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"remember_last_selected_value": 0,
|
||||||
|
"report_hide": 0,
|
||||||
|
"reqd": 0,
|
||||||
|
"search_index": 0,
|
||||||
|
"set_only_once": 0,
|
||||||
|
"unique": 0
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"allow_bulk_edit": 0,
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
@ -1961,7 +1991,7 @@
|
|||||||
"istable": 0,
|
"istable": 0,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"menu_index": 0,
|
"menu_index": 0,
|
||||||
"modified": "2017-07-19 03:16:27.171189",
|
"modified": "2017-08-03 16:17:31.206886",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Setup",
|
"module": "Setup",
|
||||||
"name": "Company",
|
"name": "Company",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user