Skip to content

Commit

Permalink
fix(Fixed Asset Register): error when selecting more than one fiscal …
Browse files Browse the repository at this point in the history
…year
  • Loading branch information
barredterra committed Jan 30, 2023
1 parent 3e5f832 commit 11d165c
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,18 @@ 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(
result = frappe.get_all(
doctype="Asset Finance Book",
filters=[["parent", "=", asset.asset_id], finance_book_filter],
fieldname="value_after_depreciation",
filters={
"parent": asset.asset_id,
"finance_book": finance_book or ("is", "not set"),
},
pluck="value_after_depreciation",
limit=1,
)

return result[0] if result else 0.0


def prepare_chart_data(data, filters):
labels_values_map = {}
Expand Down

0 comments on commit 11d165c

Please sign in to comment.