fix: asset value in fixed asset register
This commit is contained in:
parent
e0f5ecdad6
commit
aa1f2a7297
@ -86,6 +86,7 @@ def get_data(filters):
|
||||
"status",
|
||||
"department",
|
||||
"cost_center",
|
||||
"calculate_depreciation",
|
||||
"purchase_receipt",
|
||||
"asset_category",
|
||||
"purchase_date",
|
||||
@ -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,
|
||||
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user