fix: monthly wdv depr schedule for existing assets [dev] (#35460)
fix: monthly wdv depr schedule for existing assets
This commit is contained in:
parent
d84c8de46c
commit
ae26d72f7f
@ -246,10 +246,6 @@ class AssetDepreciationSchedule(Document):
|
|||||||
if should_get_last_day:
|
if should_get_last_day:
|
||||||
schedule_date = get_last_day(schedule_date)
|
schedule_date = get_last_day(schedule_date)
|
||||||
|
|
||||||
# schedule date will be a year later from start date
|
|
||||||
# so monthly schedule date is calculated by removing 11 months from it
|
|
||||||
monthly_schedule_date = add_months(schedule_date, -row.frequency_of_depreciation + 1)
|
|
||||||
|
|
||||||
# if asset is being sold or scrapped
|
# if asset is being sold or scrapped
|
||||||
if date_of_disposal:
|
if date_of_disposal:
|
||||||
from_date = add_months(
|
from_date = add_months(
|
||||||
@ -275,14 +271,20 @@ class AssetDepreciationSchedule(Document):
|
|||||||
break
|
break
|
||||||
|
|
||||||
# For first row
|
# For first row
|
||||||
if (
|
if n == 0 and has_pro_rata and not self.opening_accumulated_depreciation:
|
||||||
(has_pro_rata or has_wdv_or_dd_non_yearly_pro_rata)
|
from_date = add_days(asset_doc.available_for_use_date, -1)
|
||||||
and not self.opening_accumulated_depreciation
|
depreciation_amount, days, months = _get_pro_rata_amt(
|
||||||
and n == 0
|
row,
|
||||||
):
|
depreciation_amount,
|
||||||
from_date = add_days(
|
from_date,
|
||||||
asset_doc.available_for_use_date, -1
|
row.depreciation_start_date,
|
||||||
) # needed to calc depr amount for available_for_use_date too
|
has_wdv_or_dd_non_yearly_pro_rata,
|
||||||
|
)
|
||||||
|
elif n == 0 and has_wdv_or_dd_non_yearly_pro_rata and self.opening_accumulated_depreciation:
|
||||||
|
from_date = add_months(
|
||||||
|
getdate(asset_doc.available_for_use_date),
|
||||||
|
(self.number_of_depreciations_booked * row.frequency_of_depreciation),
|
||||||
|
)
|
||||||
depreciation_amount, days, months = _get_pro_rata_amt(
|
depreciation_amount, days, months = _get_pro_rata_amt(
|
||||||
row,
|
row,
|
||||||
depreciation_amount,
|
depreciation_amount,
|
||||||
@ -290,11 +292,6 @@ class AssetDepreciationSchedule(Document):
|
|||||||
row.depreciation_start_date,
|
row.depreciation_start_date,
|
||||||
has_wdv_or_dd_non_yearly_pro_rata,
|
has_wdv_or_dd_non_yearly_pro_rata,
|
||||||
)
|
)
|
||||||
|
|
||||||
# For first depr schedule date will be the start date
|
|
||||||
# so monthly schedule date is calculated by removing
|
|
||||||
# month difference between use date and start date
|
|
||||||
monthly_schedule_date = add_months(row.depreciation_start_date, -months + 1)
|
|
||||||
|
|
||||||
# For last row
|
# For last row
|
||||||
elif has_pro_rata and n == cint(number_of_pending_depreciations) - 1:
|
elif has_pro_rata and n == cint(number_of_pending_depreciations) - 1:
|
||||||
@ -319,9 +316,7 @@ class AssetDepreciationSchedule(Document):
|
|||||||
depreciation_amount_without_pro_rata, depreciation_amount
|
depreciation_amount_without_pro_rata, depreciation_amount
|
||||||
)
|
)
|
||||||
|
|
||||||
monthly_schedule_date = add_months(schedule_date, 1)
|
|
||||||
schedule_date = add_days(schedule_date, days)
|
schedule_date = add_days(schedule_date, days)
|
||||||
last_schedule_date = schedule_date
|
|
||||||
|
|
||||||
if not depreciation_amount:
|
if not depreciation_amount:
|
||||||
continue
|
continue
|
||||||
|
Loading…
x
Reference in New Issue
Block a user