refac: filters and columns of fixed asset register report (#20332)
This commit is contained in:
parent
011c13b3cc
commit
e009187e02
@ -20,6 +20,16 @@ frappe.query_reports["Fixed Asset Register"] = {
|
|||||||
default: 'In Location',
|
default: 'In Location',
|
||||||
reqd: 1
|
reqd: 1
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
fieldname:"purchase_date",
|
||||||
|
label: __("Purchase Date"),
|
||||||
|
fieldtype: "Date"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldname:"available_for_use_date",
|
||||||
|
label: __("Available For Use Date"),
|
||||||
|
fieldtype: "Date"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
fieldname:"finance_book",
|
fieldname:"finance_book",
|
||||||
label: __("Finance Book"),
|
label: __("Finance Book"),
|
||||||
@ -27,10 +37,15 @@ frappe.query_reports["Fixed Asset Register"] = {
|
|||||||
options: "Finance Book"
|
options: "Finance Book"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname:"date",
|
fieldname:"asset_category",
|
||||||
label: __("Date"),
|
label: __("Asset Category"),
|
||||||
fieldtype: "Date",
|
fieldtype: "Link",
|
||||||
default: frappe.datetime.get_today()
|
options: "Asset Category"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldname:"is_existing_asset",
|
||||||
|
label: __("Is Existing Asset"),
|
||||||
|
fieldtype: "Check"
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|||||||
@ -40,6 +40,42 @@ def get_columns(filters):
|
|||||||
"fieldname": "status",
|
"fieldname": "status",
|
||||||
"width": 90
|
"width": 90
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"label": _("Purchase Date"),
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"fieldname": "purchase_date",
|
||||||
|
"width": 90
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": _("Available For Use Date"),
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"fieldname": "available_for_use_date",
|
||||||
|
"width": 90
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": _("Gross Purchase Amount"),
|
||||||
|
"fieldname": "gross_purchase_amount",
|
||||||
|
"options": "Currency",
|
||||||
|
"width": 90
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": _("Asset Value"),
|
||||||
|
"fieldname": "asset_value",
|
||||||
|
"options": "Currency",
|
||||||
|
"width": 90
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": _("Opening Accumulated Depreciation"),
|
||||||
|
"fieldname": "opening_accumulated_depreciation",
|
||||||
|
"options": "Currency",
|
||||||
|
"width": 90
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": _("Depreciated Amount"),
|
||||||
|
"fieldname": "depreciated_amount",
|
||||||
|
"options": "Currency",
|
||||||
|
"width": 90
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"label": _("Cost Center"),
|
"label": _("Cost Center"),
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
@ -54,25 +90,6 @@ def get_columns(filters):
|
|||||||
"options": "Department",
|
"options": "Department",
|
||||||
"width": 100
|
"width": 100
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"label": _("Location"),
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"fieldname": "location",
|
|
||||||
"options": "Location",
|
|
||||||
"width": 100
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": _("Purchase Date"),
|
|
||||||
"fieldtype": "Date",
|
|
||||||
"fieldname": "purchase_date",
|
|
||||||
"width": 90
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": _("Gross Purchase Amount"),
|
|
||||||
"fieldname": "gross_purchase_amount",
|
|
||||||
"options": "Currency",
|
|
||||||
"width": 90
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"label": _("Vendor Name"),
|
"label": _("Vendor Name"),
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
@ -80,25 +97,29 @@ def get_columns(filters):
|
|||||||
"width": 100
|
"width": 100
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": _("Available For Use Date"),
|
"label": _("Location"),
|
||||||
"fieldtype": "Date",
|
"fieldtype": "Link",
|
||||||
"fieldname": "available_for_use_date",
|
"fieldname": "location",
|
||||||
"width": 90
|
"options": "Location",
|
||||||
},
|
"width": 100
|
||||||
{
|
|
||||||
"label": _("Asset Value"),
|
|
||||||
"fieldname": "asset_value",
|
|
||||||
"options": "Currency",
|
|
||||||
"width": 90
|
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
def get_conditions(filters):
|
def get_conditions(filters):
|
||||||
conditions = {'docstatus': 1}
|
conditions = { 'docstatus': 1 }
|
||||||
status = filters.status
|
status = filters.status
|
||||||
|
date = filters.date
|
||||||
|
|
||||||
if filters.company:
|
if filters.get('company'):
|
||||||
conditions["company"] = filters.company
|
conditions["company"] = filters.company
|
||||||
|
if filters.get('purchase_date'):
|
||||||
|
conditions["purchase_date"] = ('<=', filters.get('purchase_date'))
|
||||||
|
if filters.get('available_for_use_date'):
|
||||||
|
conditions["available_for_use_date"] = ('<=', filters.get('available_for_use_date'))
|
||||||
|
if filters.get('is_existing_asset'):
|
||||||
|
conditions["is_existing_asset"] = filters.get('is_existing_asset')
|
||||||
|
if filters.get('asset_category'):
|
||||||
|
conditions["asset_category"] = filters.get('asset_category')
|
||||||
|
|
||||||
# In Store assets are those that are not sold or scrapped
|
# In Store assets are those that are not sold or scrapped
|
||||||
operand = 'not in'
|
operand = 'not in'
|
||||||
@ -114,7 +135,7 @@ def get_data(filters):
|
|||||||
data = []
|
data = []
|
||||||
|
|
||||||
conditions = get_conditions(filters)
|
conditions = get_conditions(filters)
|
||||||
depreciation_amount_map = get_finance_book_value_map(filters.date, filters.finance_book)
|
depreciation_amount_map = get_finance_book_value_map(filters)
|
||||||
pr_supplier_map = get_purchase_receipt_supplier_map()
|
pr_supplier_map = get_purchase_receipt_supplier_map()
|
||||||
pi_supplier_map = get_purchase_invoice_supplier_map()
|
pi_supplier_map = get_purchase_invoice_supplier_map()
|
||||||
|
|
||||||
@ -136,6 +157,8 @@ def get_data(filters):
|
|||||||
"cost_center": asset.cost_center,
|
"cost_center": asset.cost_center,
|
||||||
"vendor_name": pr_supplier_map.get(asset.purchase_receipt) or pi_supplier_map.get(asset.purchase_invoice),
|
"vendor_name": pr_supplier_map.get(asset.purchase_receipt) or pi_supplier_map.get(asset.purchase_invoice),
|
||||||
"gross_purchase_amount": asset.gross_purchase_amount,
|
"gross_purchase_amount": asset.gross_purchase_amount,
|
||||||
|
"opening_accumulated_depreciation": asset.opening_accumulated_depreciation,
|
||||||
|
"depreciated_amount": depreciation_amount_map.get(asset.name) or 0.0,
|
||||||
"available_for_use_date": asset.available_for_use_date,
|
"available_for_use_date": asset.available_for_use_date,
|
||||||
"location": asset.location,
|
"location": asset.location,
|
||||||
"asset_category": asset.asset_category,
|
"asset_category": asset.asset_category,
|
||||||
@ -146,9 +169,9 @@ def get_data(filters):
|
|||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def get_finance_book_value_map(date, finance_book=''):
|
def get_finance_book_value_map(filters):
|
||||||
if not date:
|
date = filters.get('purchase_date') or filters.get('available_for_use_date') or today()
|
||||||
date = today()
|
|
||||||
return frappe._dict(frappe.db.sql(''' Select
|
return frappe._dict(frappe.db.sql(''' Select
|
||||||
parent, SUM(depreciation_amount)
|
parent, SUM(depreciation_amount)
|
||||||
FROM `tabDepreciation Schedule`
|
FROM `tabDepreciation Schedule`
|
||||||
@ -157,7 +180,7 @@ def get_finance_book_value_map(date, finance_book=''):
|
|||||||
AND schedule_date<=%s
|
AND schedule_date<=%s
|
||||||
AND journal_entry IS NOT NULL
|
AND journal_entry IS NOT NULL
|
||||||
AND ifnull(finance_book, '')=%s
|
AND ifnull(finance_book, '')=%s
|
||||||
GROUP BY parent''', (date, cstr(finance_book))))
|
GROUP BY parent''', (date, cstr(filters.finance_book or ''))))
|
||||||
|
|
||||||
def get_purchase_receipt_supplier_map():
|
def get_purchase_receipt_supplier_map():
|
||||||
return frappe._dict(frappe.db.sql(''' Select
|
return frappe._dict(frappe.db.sql(''' Select
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user