fix: Get last day of the monthif depr posting date is the last day of its month

This commit is contained in:
GangaManoj 2022-06-22 21:39:39 +05:30 committed by Nabin Hait
parent b07aae4da5
commit 154e258ad0

View File

@ -252,6 +252,7 @@ class Asset(AccountsController):
number_of_pending_depreciations += 1
skip_row = False
should_get_last_day = is_last_day_of_the_month(finance_book.depreciation_start_date)
for n in range(start[finance_book.idx - 1], number_of_pending_depreciations):
# If depreciation is already completed (for double declining balance)
@ -265,6 +266,9 @@ class Asset(AccountsController):
finance_book.depreciation_start_date, n * cint(finance_book.frequency_of_depreciation)
)
if should_get_last_day:
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)
@ -860,14 +864,6 @@ class Asset(AccountsController):
months = month_diff(to_date, from_date)
total_days = get_total_days(to_date, row.frequency_of_depreciation)
print("\n"*10)
print("from_date: ", from_date)
print("to_date: ", to_date)
print("\n")
print("days: ", days)
print("total_days: ", total_days)
print("\n"*10)
return (depreciation_amount * flt(days)) / flt(total_days), days, months