Skip to content

Commit

Permalink
fix: asset value in fixed asset register (frappe#33608)
Browse files Browse the repository at this point in the history
fix: asset value in fixed asset register

(cherry picked from commit aa1f2a7)

Co-authored-by: anandbaburajan <anandbaburajan@gmail.com>
  • Loading branch information
mergify[bot] and anandbaburajan authored Jan 15, 2023
1 parent e23d7aa commit 42fe63d
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions erpnext/assets/report/fixed_asset_register/fixed_asset_register.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def get_data(filters):
"status",
"department",
"cost_center",
"calculate_depreciation",
"purchase_receipt",
"asset_category",
"purchase_date",
Expand All @@ -98,11 +99,7 @@ def get_data(filters):
assets_record = frappe.db.get_all("Asset", filters=conditions, fields=fields)

for asset in assets_record:
asset_value = (
asset.gross_purchase_amount
- flt(asset.opening_accumulated_depreciation)
- flt(depreciation_amount_map.get(asset.name))
)
asset_value = get_asset_value(asset, filters.finance_book)
row = {
"asset_id": asset.asset_id,
"asset_name": asset.asset_name,
Expand All @@ -125,6 +122,21 @@ def get_data(filters):
return data


def get_asset_value(asset, finance_book=None):
if not asset.calculate_depreciation:
return flt(asset.gross_purchase_amount) - flt(asset.opening_accumulated_depreciation)

finance_book_filter = ["finance_book", "is", "not set"]
if finance_book:
finance_book_filter = ["finance_book", "=", finance_book]

return frappe.db.get_value(
doctype="Asset Finance Book",
filters=[["parent", "=", asset.asset_id], finance_book_filter],
fieldname="value_after_depreciation",
)


def prepare_chart_data(data, filters):
labels_values_map = {}
date_field = frappe.scrub(filters.date_based_on)
Expand Down

0 comments on commit 42fe63d

Please sign in to comment.