* fix: allow fully depreciated existing assets (cherry picked from commit 9489cba275525a93d92c00f62569888a219a8912) # Conflicts: # erpnext/assets/doctype/asset/asset.json # erpnext/assets/doctype/asset/depreciation.py * chore: fix conflicts in asset.json * chore: fix conflicts in depreciation.py --------- Co-authored-by: anandbaburajan <anandbaburajan@gmail.com>
This commit is contained in:
parent
a93ae9c826
commit
3f09f811bf
@ -43,6 +43,7 @@
|
|||||||
"column_break_33",
|
"column_break_33",
|
||||||
"opening_accumulated_depreciation",
|
"opening_accumulated_depreciation",
|
||||||
"number_of_depreciations_booked",
|
"number_of_depreciations_booked",
|
||||||
|
"is_fully_depreciated",
|
||||||
"section_break_36",
|
"section_break_36",
|
||||||
"finance_books",
|
"finance_books",
|
||||||
"section_break_33",
|
"section_break_33",
|
||||||
@ -205,6 +206,7 @@
|
|||||||
"fieldname": "disposal_date",
|
"fieldname": "disposal_date",
|
||||||
"fieldtype": "Date",
|
"fieldtype": "Date",
|
||||||
"label": "Disposal Date",
|
"label": "Disposal Date",
|
||||||
|
"no_copy": 1,
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -244,19 +246,17 @@
|
|||||||
"label": "Is Existing Asset"
|
"label": "Is Existing Asset"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"depends_on": "is_existing_asset",
|
"depends_on": "eval:(doc.is_existing_asset)",
|
||||||
"fieldname": "opening_accumulated_depreciation",
|
"fieldname": "opening_accumulated_depreciation",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
"label": "Opening Accumulated Depreciation",
|
"label": "Opening Accumulated Depreciation",
|
||||||
"no_copy": 1,
|
|
||||||
"options": "Company:company:default_currency"
|
"options": "Company:company:default_currency"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"depends_on": "eval:(doc.is_existing_asset && doc.opening_accumulated_depreciation)",
|
"depends_on": "eval:(doc.is_existing_asset)",
|
||||||
"fieldname": "number_of_depreciations_booked",
|
"fieldname": "number_of_depreciations_booked",
|
||||||
"fieldtype": "Int",
|
"fieldtype": "Int",
|
||||||
"label": "Number of Depreciations Booked",
|
"label": "Number of Depreciations Booked"
|
||||||
"no_copy": 1
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"collapsible": 1,
|
"collapsible": 1,
|
||||||
@ -500,6 +500,13 @@
|
|||||||
"fieldtype": "HTML",
|
"fieldtype": "HTML",
|
||||||
"hidden": 1,
|
"hidden": 1,
|
||||||
"label": "Depreciation Schedule View"
|
"label": "Depreciation Schedule View"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "0",
|
||||||
|
"depends_on": "eval:(doc.is_existing_asset)",
|
||||||
|
"fieldname": "is_fully_depreciated",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Is Fully Depreciated"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"idx": 72,
|
"idx": 72,
|
||||||
@ -533,7 +540,7 @@
|
|||||||
"table_fieldname": "accounts"
|
"table_fieldname": "accounts"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"modified": "2023-07-26 13:33:36.821534",
|
"modified": "2023-07-28 15:47:01.137996",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Assets",
|
"module": "Assets",
|
||||||
"name": "Asset",
|
"name": "Asset",
|
||||||
@ -577,4 +584,4 @@
|
|||||||
"states": [],
|
"states": [],
|
||||||
"title_field": "asset_name",
|
"title_field": "asset_name",
|
||||||
"track_changes": 1
|
"track_changes": 1
|
||||||
}
|
}
|
||||||
|
|||||||
@ -194,8 +194,11 @@ class Asset(AccountsController):
|
|||||||
|
|
||||||
if not self.calculate_depreciation:
|
if not self.calculate_depreciation:
|
||||||
return
|
return
|
||||||
elif not self.finance_books:
|
else:
|
||||||
frappe.throw(_("Enter depreciation details"))
|
if not self.finance_books:
|
||||||
|
frappe.throw(_("Enter depreciation details"))
|
||||||
|
if self.is_fully_depreciated:
|
||||||
|
frappe.throw(_("Depreciation cannot be calculated for fully depreciated assets"))
|
||||||
|
|
||||||
if self.is_existing_asset:
|
if self.is_existing_asset:
|
||||||
return
|
return
|
||||||
@ -276,7 +279,7 @@ class Asset(AccountsController):
|
|||||||
depreciable_amount = flt(self.gross_purchase_amount) - flt(row.expected_value_after_useful_life)
|
depreciable_amount = flt(self.gross_purchase_amount) - flt(row.expected_value_after_useful_life)
|
||||||
if flt(self.opening_accumulated_depreciation) > depreciable_amount:
|
if flt(self.opening_accumulated_depreciation) > depreciable_amount:
|
||||||
frappe.throw(
|
frappe.throw(
|
||||||
_("Opening Accumulated Depreciation must be less than equal to {0}").format(
|
_("Opening Accumulated Depreciation must be less than or equal to {0}").format(
|
||||||
depreciable_amount
|
depreciable_amount
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -412,7 +415,9 @@ class Asset(AccountsController):
|
|||||||
expected_value_after_useful_life = self.finance_books[idx].expected_value_after_useful_life
|
expected_value_after_useful_life = self.finance_books[idx].expected_value_after_useful_life
|
||||||
value_after_depreciation = self.finance_books[idx].value_after_depreciation
|
value_after_depreciation = self.finance_books[idx].value_after_depreciation
|
||||||
|
|
||||||
if flt(value_after_depreciation) <= expected_value_after_useful_life:
|
if (
|
||||||
|
flt(value_after_depreciation) <= expected_value_after_useful_life or self.is_fully_depreciated
|
||||||
|
):
|
||||||
status = "Fully Depreciated"
|
status = "Fully Depreciated"
|
||||||
elif flt(value_after_depreciation) < flt(self.gross_purchase_amount):
|
elif flt(value_after_depreciation) < flt(self.gross_purchase_amount):
|
||||||
status = "Partially Depreciated"
|
status = "Partially Depreciated"
|
||||||
|
|||||||
@ -398,6 +398,15 @@ def reverse_depreciation_entry_made_after_disposal(asset, date):
|
|||||||
|
|
||||||
reverse_journal_entry = make_reverse_journal_entry(schedule.journal_entry)
|
reverse_journal_entry = make_reverse_journal_entry(schedule.journal_entry)
|
||||||
reverse_journal_entry.posting_date = nowdate()
|
reverse_journal_entry.posting_date = nowdate()
|
||||||
|
|
||||||
|
for account in reverse_journal_entry.accounts:
|
||||||
|
account.update(
|
||||||
|
{
|
||||||
|
"reference_type": "Asset",
|
||||||
|
"reference_name": asset.name,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
frappe.flags.is_reverse_depr_entry = True
|
frappe.flags.is_reverse_depr_entry = True
|
||||||
reverse_journal_entry.submit()
|
reverse_journal_entry.submit()
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user