Merge pull request #39453 from nabinhait/asset-depr-income-tax-act

fix: Asset Depreciation WDV as per Income Tax Act
This commit is contained in:
Nabin Hait
2024-01-25 16:06:22 +05:30
committed by GitHub
4 changed files with 25 additions and 6 deletions

View File

@@ -41,7 +41,7 @@ def test_record_generator():
] ]
start = 2012 start = 2012
end = now_datetime().year + 5 end = now_datetime().year + 25
for year in range(start, end): for year in range(start, end):
test_records.append( test_records.append(
{ {

View File

@@ -10,6 +10,7 @@ from frappe import _
from frappe.utils import ( from frappe.utils import (
add_days, add_days,
add_months, add_months,
add_years,
cint, cint,
date_diff, date_diff,
flt, flt,
@@ -23,6 +24,7 @@ from frappe.utils import (
import erpnext import erpnext
from erpnext.accounts.general_ledger import make_reverse_gl_entries 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 ( from erpnext.assets.doctype.asset.depreciation import (
get_depreciation_accounts, get_depreciation_accounts,
get_disposal_account_and_cost_center, get_disposal_account_and_cost_center,
@@ -381,14 +383,24 @@ class Asset(AccountsController):
should_get_last_day = is_last_day_of_the_month(finance_book.depreciation_start_date) should_get_last_day = is_last_day_of_the_month(finance_book.depreciation_start_date)
depreciation_amount = 0 depreciation_amount = 0
number_of_pending_depreciations = final_number_of_depreciations - start[finance_book.idx - 1] 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): for n in range(start[finance_book.idx - 1], final_number_of_depreciations):
# If depreciation is already completed (for double declining balance) # If depreciation is already completed (for double declining balance)
if skip_row: if skip_row:
continue 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: if n > 0 and len(self.get("schedules")) > n - 1:
prev_depreciation_amount = self.get("schedules")[n - 1].depreciation_amount prev_depreciation_amount = self.get("schedules")[n - 1].depreciation_amount
else: else:
@@ -397,6 +409,7 @@ class Asset(AccountsController):
depreciation_amount = get_depreciation_amount( depreciation_amount = get_depreciation_amount(
self, self,
value_after_depreciation, value_after_depreciation,
yearly_opening_wdv,
finance_book, finance_book,
n, n,
prev_depreciation_amount, prev_depreciation_amount,
@@ -494,7 +507,10 @@ class Asset(AccountsController):
if not depreciation_amount: if not depreciation_amount:
continue 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 # Adjust depreciation amount in the last period based on the expected value after useful life
if finance_book.expected_value_after_useful_life and ( if finance_book.expected_value_after_useful_life and (
@@ -1380,6 +1396,7 @@ def get_total_days(date, frequency):
def get_depreciation_amount( def get_depreciation_amount(
asset, asset,
depreciable_value, depreciable_value,
yearly_opening_wdv,
fb_row, fb_row,
schedule_idx=0, schedule_idx=0,
prev_depreciation_amount=0, prev_depreciation_amount=0,
@@ -1397,6 +1414,7 @@ def get_depreciation_amount(
asset, asset,
fb_row, fb_row,
depreciable_value, depreciable_value,
yearly_opening_wdv,
schedule_idx, schedule_idx,
prev_depreciation_amount, prev_depreciation_amount,
has_wdv_or_dd_non_yearly_pro_rata, has_wdv_or_dd_non_yearly_pro_rata,
@@ -1542,6 +1560,7 @@ def get_wdv_or_dd_depr_amount(
asset, asset,
fb_row, fb_row,
depreciable_value, depreciable_value,
yearly_opening_wdv,
schedule_idx, schedule_idx,
prev_depreciation_amount, prev_depreciation_amount,
has_wdv_or_dd_non_yearly_pro_rata, has_wdv_or_dd_non_yearly_pro_rata,

View File

@@ -845,7 +845,7 @@ class TestDepreciationMethods(AssetSetup):
["2030-12-31", 28630.14, 28630.14], ["2030-12-31", 28630.14, 28630.14],
["2031-12-31", 35684.93, 64315.07], ["2031-12-31", 35684.93, 64315.07],
["2032-12-31", 17842.47, 82157.54], ["2032-12-31", 17842.47, 82157.54],
["2033-06-06", 5342.46, 87500.0], ["2033-06-06", 5342.47, 87500.01],
] ]
schedules = [ schedules = [
@@ -957,7 +957,7 @@ class TestDepreciationBasics(AssetSetup):
}, },
) )
depreciation_amount = get_depreciation_amount(asset, 100000, asset.finance_books[0]) depreciation_amount = get_depreciation_amount(asset, 100000, 100000, asset.finance_books[0])
self.assertEqual(depreciation_amount, 30000) self.assertEqual(depreciation_amount, 30000)
def test_make_depreciation_schedule(self): def test_make_depreciation_schedule(self):

View File

@@ -14,7 +14,7 @@ def execute():
"label": "For Income Tax", "label": "For Income Tax",
"fieldtype": "Check", "fieldtype": "Check",
"insert_after": "finance_book_name", "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%.",
} }
] ]
} }