mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-27 08:54:45 +00:00
fix: remove duplicate method
This commit is contained in:
@@ -161,83 +161,6 @@ def get_conditions(filters):
|
|||||||
return conditions
|
return conditions
|
||||||
|
|
||||||
|
|
||||||
def get_data(filters):
|
|
||||||
data = []
|
|
||||||
|
|
||||||
conditions = get_conditions(filters)
|
|
||||||
pr_supplier_map = get_purchase_receipt_supplier_map()
|
|
||||||
pi_supplier_map = get_purchase_invoice_supplier_map()
|
|
||||||
|
|
||||||
assets_linked_to_fb = get_assets_linked_to_fb(filters)
|
|
||||||
|
|
||||||
company_fb = frappe.get_cached_value("Company", filters.company, "default_finance_book")
|
|
||||||
|
|
||||||
if filters.include_default_book_assets and company_fb:
|
|
||||||
finance_book = company_fb
|
|
||||||
elif filters.finance_book:
|
|
||||||
finance_book = filters.finance_book
|
|
||||||
else:
|
|
||||||
finance_book = None
|
|
||||||
|
|
||||||
depreciation_amount_map = get_asset_depreciation_amount_map(filters, finance_book)
|
|
||||||
|
|
||||||
group_by = frappe.scrub(filters.get("group_by"))
|
|
||||||
|
|
||||||
if group_by in ("asset_category", "location"):
|
|
||||||
data = get_group_by_data(group_by, conditions, assets_linked_to_fb, depreciation_amount_map)
|
|
||||||
return data
|
|
||||||
|
|
||||||
fields = [
|
|
||||||
"name as asset_id",
|
|
||||||
"asset_name",
|
|
||||||
"status",
|
|
||||||
"department",
|
|
||||||
"company",
|
|
||||||
"cost_center",
|
|
||||||
"calculate_depreciation",
|
|
||||||
"purchase_receipt",
|
|
||||||
"asset_category",
|
|
||||||
"purchase_date",
|
|
||||||
"gross_purchase_amount",
|
|
||||||
"location",
|
|
||||||
"available_for_use_date",
|
|
||||||
"purchase_invoice",
|
|
||||||
"opening_accumulated_depreciation",
|
|
||||||
]
|
|
||||||
assets_record = frappe.db.get_all("Asset", filters=conditions, fields=fields)
|
|
||||||
|
|
||||||
for asset in assets_record:
|
|
||||||
if assets_linked_to_fb and asset.calculate_depreciation and asset.asset_id not in assets_linked_to_fb:
|
|
||||||
continue
|
|
||||||
|
|
||||||
depreciation_amount = depreciation_amount_map.get(asset.asset_id) or 0.0
|
|
||||||
asset_value = (
|
|
||||||
asset.gross_purchase_amount - asset.opening_accumulated_depreciation - depreciation_amount
|
|
||||||
)
|
|
||||||
|
|
||||||
row = {
|
|
||||||
"asset_id": asset.asset_id,
|
|
||||||
"asset_name": asset.asset_name,
|
|
||||||
"status": asset.status,
|
|
||||||
"department": asset.department,
|
|
||||||
"cost_center": asset.cost_center,
|
|
||||||
"vendor_name": pr_supplier_map.get(asset.purchase_receipt)
|
|
||||||
or pi_supplier_map.get(asset.purchase_invoice),
|
|
||||||
"gross_purchase_amount": asset.gross_purchase_amount,
|
|
||||||
"opening_accumulated_depreciation": asset.opening_accumulated_depreciation,
|
|
||||||
"depreciated_amount": depreciation_amount,
|
|
||||||
"available_for_use_date": asset.available_for_use_date,
|
|
||||||
"location": asset.location,
|
|
||||||
"asset_category": asset.asset_category,
|
|
||||||
"purchase_date": asset.purchase_date,
|
|
||||||
"asset_value": asset_value,
|
|
||||||
"company": asset.company,
|
|
||||||
}
|
|
||||||
data.append(row)
|
|
||||||
|
|
||||||
return data
|
|
||||||
|
|
||||||
|
|
||||||
def prepare_chart_data(data, filters):
|
def prepare_chart_data(data, filters):
|
||||||
if not data:
|
if not data:
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user