From 56e4346eadcfd31463ce3f281eb96367704eb6cb Mon Sep 17 00:00:00 2001 From: mnaim-cloude8 <38936916+mnaim-cloude8@users.noreply.github.com> Date: Mon, 25 Jun 2018 17:35:26 +0800 Subject: [PATCH] To fixed if if no schedule and disposal is NOT within the period. (#14637) * To fixed if if no schedule and disposal is NOT within the period, then opening accumulated depreciation not included. If no schedule, and disposal is within period, accumulated dep is the amount eliminated. * Update asset_depreciations_and_balances.py --- .../asset_depreciations_and_balances.py | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/erpnext/accounts/report/asset_depreciations_and_balances/asset_depreciations_and_balances.py b/erpnext/accounts/report/asset_depreciations_and_balances/asset_depreciations_and_balances.py index 67112b669f6..0c99f1424cf 100644 --- a/erpnext/accounts/report/asset_depreciations_and_balances/asset_depreciations_and_balances.py +++ b/erpnext/accounts/report/asset_depreciations_and_balances/asset_depreciations_and_balances.py @@ -94,17 +94,32 @@ def get_accumulated_depreciations(assets, filters): "depreciation_amount_during_the_period": 0, "depreciation_eliminated_during_the_period": 0 })) - + depr = asset_depreciations[d.asset_category] + + if not asset.schedules: # if no schedule, + if asset.disposal_date: + # and disposal is NOT within the period, then opening accumulated depreciation not included + if getdate(asset.disposal_date) < getdate(filters.from_date) or getdate(asset.disposal_date) > getdate(filters.to_date): + asset_depreciations[d.asset_category]['accumulated_depreciation_as_on_from_date'] = 0 + + # if no schedule, and disposal is within period, accumulated dep is the amount eliminated + if getdate(asset.disposal_date) >= getdate(filters.from_date) and getdate(asset.disposal_date) <= getdate(filters.to_date): + depr.depreciation_eliminated_during_the_period += asset.opening_accumulated_depreciation for schedule in asset.get("schedules"): if getdate(schedule.schedule_date) < getdate(filters.from_date): if not asset.disposal_date or getdate(asset.disposal_date) >= getdate(filters.from_date): depr.accumulated_depreciation_as_on_from_date += flt(schedule.depreciation_amount) elif getdate(schedule.schedule_date) <= getdate(filters.to_date): - depr.depreciation_amount_during_the_period += flt(schedule.depreciation_amount) - - if asset.disposal_date and getdate(schedule.schedule_date) > getdate(asset.disposal_date): + if not asset.disposal_date: + depr.depreciation_amount_during_the_period += flt(schedule.depreciation_amount) + else: + if getdate(schedule.schedule_date) <= getdate(asset.disposal_date): + depr.depreciation_amount_during_the_period += flt(schedule.depreciation_amount) + + if asset.disposal_date and getdate(asset.disposal_date) >= getdate(filters.from_date) and getdate(asset.disposal_date) <= getdate(filters.to_date): + if getdate(schedule.schedule_date) <= getdate(asset.disposal_date): depr.depreciation_eliminated_during_the_period += flt(schedule.depreciation_amount) return asset_depreciations