fix: Asset Category filter is not working in asset depreciation and b… (#36806)
fix: Asset Category filter is not working in asset depreciation and balances Co-authored-by: ubuntu <viralkansodiya167@gmail.com>
This commit is contained in:
parent
1449e38b39
commit
388a42ec7e
@ -58,6 +58,9 @@ def get_data(filters):
|
|||||||
|
|
||||||
|
|
||||||
def get_asset_categories(filters):
|
def get_asset_categories(filters):
|
||||||
|
condition = ""
|
||||||
|
if filters.get("asset_category"):
|
||||||
|
condition += " and asset_category = %(asset_category)s"
|
||||||
return frappe.db.sql(
|
return frappe.db.sql(
|
||||||
"""
|
"""
|
||||||
SELECT asset_category,
|
SELECT asset_category,
|
||||||
@ -98,15 +101,25 @@ def get_asset_categories(filters):
|
|||||||
0
|
0
|
||||||
end), 0) as cost_of_scrapped_asset
|
end), 0) as cost_of_scrapped_asset
|
||||||
from `tabAsset`
|
from `tabAsset`
|
||||||
where docstatus=1 and company=%(company)s and purchase_date <= %(to_date)s
|
where docstatus=1 and company=%(company)s and purchase_date <= %(to_date)s {}
|
||||||
group by asset_category
|
group by asset_category
|
||||||
""",
|
""".format(
|
||||||
{"to_date": filters.to_date, "from_date": filters.from_date, "company": filters.company},
|
condition
|
||||||
|
),
|
||||||
|
{
|
||||||
|
"to_date": filters.to_date,
|
||||||
|
"from_date": filters.from_date,
|
||||||
|
"company": filters.company,
|
||||||
|
"asset_category": filters.get("asset_category"),
|
||||||
|
},
|
||||||
as_dict=1,
|
as_dict=1,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_assets(filters):
|
def get_assets(filters):
|
||||||
|
condition = ""
|
||||||
|
if filters.get("asset_category"):
|
||||||
|
condition = " and a.asset_category = '{}'".format(filters.get("asset_category"))
|
||||||
return frappe.db.sql(
|
return frappe.db.sql(
|
||||||
"""
|
"""
|
||||||
SELECT results.asset_category,
|
SELECT results.asset_category,
|
||||||
@ -138,7 +151,7 @@ def get_assets(filters):
|
|||||||
aca.parent = a.asset_category and aca.company_name = %(company)s
|
aca.parent = a.asset_category and aca.company_name = %(company)s
|
||||||
join `tabCompany` company on
|
join `tabCompany` company on
|
||||||
company.name = %(company)s
|
company.name = %(company)s
|
||||||
where a.docstatus=1 and a.company=%(company)s and a.purchase_date <= %(to_date)s and gle.debit != 0 and gle.is_cancelled = 0 and gle.account = ifnull(aca.depreciation_expense_account, company.depreciation_expense_account)
|
where a.docstatus=1 and a.company=%(company)s and a.purchase_date <= %(to_date)s and gle.debit != 0 and gle.is_cancelled = 0 and gle.account = ifnull(aca.depreciation_expense_account, company.depreciation_expense_account) {0}
|
||||||
group by a.asset_category
|
group by a.asset_category
|
||||||
union
|
union
|
||||||
SELECT a.asset_category,
|
SELECT a.asset_category,
|
||||||
@ -154,10 +167,12 @@ def get_assets(filters):
|
|||||||
end), 0) as depreciation_eliminated_during_the_period,
|
end), 0) as depreciation_eliminated_during_the_period,
|
||||||
0 as depreciation_amount_during_the_period
|
0 as depreciation_amount_during_the_period
|
||||||
from `tabAsset` a
|
from `tabAsset` a
|
||||||
where a.docstatus=1 and a.company=%(company)s and a.purchase_date <= %(to_date)s
|
where a.docstatus=1 and a.company=%(company)s and a.purchase_date <= %(to_date)s {0}
|
||||||
group by a.asset_category) as results
|
group by a.asset_category) as results
|
||||||
group by results.asset_category
|
group by results.asset_category
|
||||||
""",
|
""".format(
|
||||||
|
condition
|
||||||
|
),
|
||||||
{"to_date": filters.to_date, "from_date": filters.from_date, "company": filters.company},
|
{"to_date": filters.to_date, "from_date": filters.from_date, "company": filters.company},
|
||||||
as_dict=1,
|
as_dict=1,
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user