mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-19 18:25:32 +00:00
fix: monthly WDV depr schedule for existing assets [v14] (#35458)
* fix: monthly wdv depr schedule for existing assets * fix: monthly wdv depr schedule for existing assets properly
This commit is contained in:
@@ -337,10 +337,6 @@ class Asset(AccountsController):
|
|||||||
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, -finance_book.frequency_of_depreciation + 1)
|
|
||||||
|
|
||||||
# if asset is being sold
|
# if asset is being sold
|
||||||
if date_of_disposal:
|
if date_of_disposal:
|
||||||
from_date = self.get_from_date_for_disposal(finance_book)
|
from_date = self.get_from_date_for_disposal(finance_book)
|
||||||
@@ -363,14 +359,20 @@ class Asset(AccountsController):
|
|||||||
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(self.available_for_use_date, -1)
|
||||||
and not self.opening_accumulated_depreciation
|
depreciation_amount, days, months = self.get_pro_rata_amt(
|
||||||
and n == 0
|
finance_book,
|
||||||
):
|
depreciation_amount,
|
||||||
from_date = add_days(
|
from_date,
|
||||||
self.available_for_use_date, -1
|
finance_book.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(self.available_for_use_date),
|
||||||
|
(self.number_of_depreciations_booked * finance_book.frequency_of_depreciation),
|
||||||
|
)
|
||||||
depreciation_amount, days, months = self.get_pro_rata_amt(
|
depreciation_amount, days, months = self.get_pro_rata_amt(
|
||||||
finance_book,
|
finance_book,
|
||||||
depreciation_amount,
|
depreciation_amount,
|
||||||
@@ -378,10 +380,6 @@ class Asset(AccountsController):
|
|||||||
finance_book.depreciation_start_date,
|
finance_book.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(finance_book.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:
|
||||||
@@ -406,9 +404,7 @@ class Asset(AccountsController):
|
|||||||
depreciation_amount_without_pro_rata, depreciation_amount, finance_book.finance_book
|
depreciation_amount_without_pro_rata, depreciation_amount, finance_book.finance_book
|
||||||
)
|
)
|
||||||
|
|
||||||
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
|
||||||
|
|||||||
Reference in New Issue
Block a user