fix: wrong calculation of depreciation eliminated for a period (#20502)
This commit is contained in:
parent
d20e36f3fd
commit
8cf841ce60
@ -29,7 +29,7 @@ def get_data(filters):
|
|||||||
|
|
||||||
row.update(next(asset for asset in assets if asset["asset_category"] == asset_category.get("asset_category", "")))
|
row.update(next(asset for asset in assets if asset["asset_category"] == asset_category.get("asset_category", "")))
|
||||||
row.accumulated_depreciation_as_on_to_date = (flt(row.accumulated_depreciation_as_on_from_date) +
|
row.accumulated_depreciation_as_on_to_date = (flt(row.accumulated_depreciation_as_on_from_date) +
|
||||||
flt(row.depreciation_amount_during_the_period) - flt(row.depreciation_eliminated))
|
flt(row.depreciation_amount_during_the_period) - flt(row.depreciation_eliminated_during_the_period))
|
||||||
|
|
||||||
row.net_asset_value_as_on_from_date = (flt(row.cost_as_on_from_date) -
|
row.net_asset_value_as_on_from_date = (flt(row.cost_as_on_from_date) -
|
||||||
flt(row.accumulated_depreciation_as_on_from_date))
|
flt(row.accumulated_depreciation_as_on_from_date))
|
||||||
@ -86,7 +86,6 @@ def get_asset_categories(filters):
|
|||||||
group by asset_category
|
group by asset_category
|
||||||
""", {"to_date": filters.to_date, "from_date": filters.from_date, "company": filters.company}, as_dict=1)
|
""", {"to_date": filters.to_date, "from_date": filters.from_date, "company": filters.company}, as_dict=1)
|
||||||
|
|
||||||
|
|
||||||
def get_assets(filters):
|
def get_assets(filters):
|
||||||
return frappe.db.sql("""
|
return frappe.db.sql("""
|
||||||
SELECT results.asset_category,
|
SELECT results.asset_category,
|
||||||
@ -94,9 +93,7 @@ def get_assets(filters):
|
|||||||
sum(results.depreciation_eliminated_during_the_period) as depreciation_eliminated_during_the_period,
|
sum(results.depreciation_eliminated_during_the_period) as depreciation_eliminated_during_the_period,
|
||||||
sum(results.depreciation_amount_during_the_period) as depreciation_amount_during_the_period
|
sum(results.depreciation_amount_during_the_period) as depreciation_amount_during_the_period
|
||||||
from (SELECT a.asset_category,
|
from (SELECT a.asset_category,
|
||||||
ifnull(sum(a.opening_accumulated_depreciation +
|
ifnull(sum(case when ds.schedule_date < %(from_date)s then
|
||||||
case when ds.schedule_date < %(from_date)s and
|
|
||||||
(ifnull(a.disposal_date, 0) = 0 or a.disposal_date >= %(from_date)s) then
|
|
||||||
ds.depreciation_amount
|
ds.depreciation_amount
|
||||||
else
|
else
|
||||||
0
|
0
|
||||||
@ -107,7 +104,6 @@ def get_assets(filters):
|
|||||||
else
|
else
|
||||||
0
|
0
|
||||||
end), 0) as depreciation_eliminated_during_the_period,
|
end), 0) as depreciation_eliminated_during_the_period,
|
||||||
|
|
||||||
ifnull(sum(case when ds.schedule_date >= %(from_date)s and ds.schedule_date <= %(to_date)s
|
ifnull(sum(case when ds.schedule_date >= %(from_date)s and ds.schedule_date <= %(to_date)s
|
||||||
and (ifnull(a.disposal_date, 0) = 0 or ds.schedule_date <= a.disposal_date) then
|
and (ifnull(a.disposal_date, 0) = 0 or ds.schedule_date <= a.disposal_date) then
|
||||||
ds.depreciation_amount
|
ds.depreciation_amount
|
||||||
@ -120,7 +116,8 @@ def get_assets(filters):
|
|||||||
union
|
union
|
||||||
SELECT a.asset_category,
|
SELECT a.asset_category,
|
||||||
ifnull(sum(case when ifnull(a.disposal_date, 0) != 0
|
ifnull(sum(case when ifnull(a.disposal_date, 0) != 0
|
||||||
and (a.disposal_date < %(from_date)s or a.disposal_date > %(to_date)s) then
|
and (a.disposal_date < %(from_date)s or a.disposal_date > %(to_date)s)
|
||||||
|
then
|
||||||
0
|
0
|
||||||
else
|
else
|
||||||
a.opening_accumulated_depreciation
|
a.opening_accumulated_depreciation
|
||||||
@ -133,7 +130,6 @@ def get_assets(filters):
|
|||||||
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
|
||||||
and not exists(select * from `tabDepreciation Schedule` ds where a.name = ds.parent)
|
|
||||||
group by a.asset_category) as results
|
group by a.asset_category) as results
|
||||||
group by results.asset_category
|
group by results.asset_category
|
||||||
""", {"to_date": filters.to_date, "from_date": filters.from_date, "company": filters.company}, as_dict=1)
|
""", {"to_date": filters.to_date, "from_date": filters.from_date, "company": filters.company}, as_dict=1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user