Skip to content

Commit

Permalink
fix: Asset Depreciation WDV as per Income Tax Act
Browse files Browse the repository at this point in the history
  • Loading branch information
nabinhait committed Jan 18, 2024
1 parent 05a2fb3 commit b840eb9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
21 changes: 19 additions & 2 deletions erpnext/assets/doctype/asset/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from frappe.utils import (
add_days,
add_months,
add_years,
cint,
date_diff,
flt,
Expand All @@ -23,6 +24,7 @@

import erpnext
from erpnext.accounts.general_ledger import make_reverse_gl_entries
from erpnext.accounts.utils import get_fiscal_year
from erpnext.assets.doctype.asset.depreciation import (
get_depreciation_accounts,
get_disposal_account_and_cost_center,
Expand Down Expand Up @@ -381,14 +383,22 @@ def _make_depreciation_schedule(
should_get_last_day = is_last_day_of_the_month(finance_book.depreciation_start_date)

depreciation_amount = 0

number_of_pending_depreciations = final_number_of_depreciations - start[finance_book.idx - 1]
yearly_opening_wdv = value_after_depreciation
current_fiscal_year_end_date = None

for n in range(start[finance_book.idx - 1], final_number_of_depreciations):
# If depreciation is already completed (for double declining balance)
if skip_row:
continue

schedule_date = add_months(finance_book.depreciation_start_date, n * cint(finance_book.frequency_of_depreciation))
if not current_fiscal_year_end_date:
current_fiscal_year_end_date = get_fiscal_year(finance_book.depreciation_start_date)[2]
elif getdate(schedule_date) > getdate(current_fiscal_year_end_date):
current_fiscal_year_end_date = add_years(current_fiscal_year_end_date, 1)
yearly_opening_wdv = value_after_depreciation

if n > 0 and len(self.get("schedules")) > n - 1:
prev_depreciation_amount = self.get("schedules")[n - 1].depreciation_amount
else:
Expand All @@ -397,6 +407,7 @@ def _make_depreciation_schedule(
depreciation_amount = get_depreciation_amount(
self,
value_after_depreciation,
yearly_opening_wdv,
finance_book,
n,
prev_depreciation_amount,
Expand Down Expand Up @@ -494,7 +505,10 @@ def _make_depreciation_schedule(

if not depreciation_amount:
continue
value_after_depreciation -= flt(depreciation_amount, self.precision("gross_purchase_amount"))
value_after_depreciation = flt(
value_after_depreciation - flt(depreciation_amount),
self.precision("gross_purchase_amount"),
)

# Adjust depreciation amount in the last period based on the expected value after useful life
if finance_book.expected_value_after_useful_life and (
Expand Down Expand Up @@ -1380,6 +1394,7 @@ def get_total_days(date, frequency):
def get_depreciation_amount(
asset,
depreciable_value,
yearly_opening_wdv,
fb_row,
schedule_idx=0,
prev_depreciation_amount=0,
Expand All @@ -1397,6 +1412,7 @@ def get_depreciation_amount(
asset,
fb_row,
depreciable_value,
yearly_opening_wdv,
schedule_idx,
prev_depreciation_amount,
has_wdv_or_dd_non_yearly_pro_rata,
Expand Down Expand Up @@ -1542,6 +1558,7 @@ def get_wdv_or_dd_depr_amount(
asset,
fb_row,
depreciable_value,
yearly_opening_wdv,
schedule_idx,
prev_depreciation_amount,
has_wdv_or_dd_non_yearly_pro_rata,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def execute():
"label": "For Income Tax",
"fieldtype": "Check",
"insert_after": "finance_book_name",
"description": "If the asset is put to use for less than 180 days, the first Depreciation Rate will be reduced by 50%.",
"description": "If the asset is put to use for less than 180 days in the first year, the first year's depreciation rate will be reduced by 50%.",
}
]
}
Expand Down

0 comments on commit b840eb9

Please sign in to comment.