Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(regional): toggle for reduced depreciation rate as per IT Act (backport #27600) #27688

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions erpnext/assets/doctype/asset/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,10 +394,6 @@ def validate_asset_finance_books(self, row):
if cint(self.number_of_depreciations_booked) > cint(row.total_number_of_depreciations):
frappe.throw(_("Number of Depreciations Booked cannot be greater than Total Number of Depreciations"))

if row.depreciation_start_date and getdate(row.depreciation_start_date) < getdate(nowdate()):
frappe.msgprint(_("Depreciation Row {0}: Depreciation Start Date is entered as past date")
.format(row.idx), title=_('Warning'), indicator='red')

if row.depreciation_start_date and getdate(row.depreciation_start_date) < getdate(self.purchase_date):
frappe.throw(_("Depreciation Row {0}: Next Depreciation Date cannot be before Purchase Date")
.format(row.idx))
Expand Down
6 changes: 6 additions & 0 deletions erpnext/assets/doctype/asset/test_asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,12 +645,18 @@ def test_discounted_wdv_depreciation_rate_for_indian_region(self):
pr = make_purchase_receipt(item_code="Macbook Pro",
qty=1, rate=8000.0, location="Test Location")

finance_book = frappe.new_doc('Finance Book')
finance_book.finance_book_name = 'Income Tax'
finance_book.for_income_tax = 1
finance_book.insert(ignore_if_duplicate=1)

asset_name = frappe.db.get_value("Asset", {"purchase_receipt": pr.name}, 'name')
asset = frappe.get_doc('Asset', asset_name)
asset.calculate_depreciation = 1
asset.available_for_use_date = '2030-07-12'
asset.purchase_date = '2030-01-01'
asset.append("finance_books", {
"finance_book": finance_book.name,
"expected_value_after_useful_life": 1000,
"depreciation_method": "Written Down Value",
"total_number_of_depreciations": 3,
Expand Down
3 changes: 2 additions & 1 deletion erpnext/patches.txt
Original file line number Diff line number Diff line change
Expand Up @@ -315,4 +315,5 @@ erpnext.patches.v13_0.make_homepage_products_website_items
erpnext.patches.v13_0.update_dates_in_tax_withholding_category
erpnext.patches.v13_0.replace_supplier_item_group_with_party_specific_item
erpnext.patches.v13_0.create_accounting_dimensions_in_pos_doctypes
erpnext.patches.v13_0.modify_invalid_gain_loss_gl_entries
erpnext.patches.v13_0.create_custom_field_for_finance_book
erpnext.patches.v13_0.modify_invalid_gain_loss_gl_entries
21 changes: 21 additions & 0 deletions erpnext/patches/v13_0/create_custom_field_for_finance_book.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import frappe
from frappe.custom.doctype.custom_field.custom_field import create_custom_fields


def execute():
company = frappe.get_all('Company', filters = {'country': 'India'})
if not company:
return

custom_field = {
'Finance Book': [
{
'fieldname': 'for_income_tax',
'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%.'
}
]
}
create_custom_fields(custom_field, update=1)
9 changes: 9 additions & 0 deletions erpnext/regional/india/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,15 @@ def make_custom_fields(update=True):
'fieldtype': 'Data',
'insert_after': 'email'
}
],
'Finance Book': [
{
'fieldname': 'for_income_tax',
'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%.'
}
]
}
create_custom_fields(custom_fields, update=update)
Expand Down
13 changes: 7 additions & 6 deletions erpnext/regional/india/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -856,12 +856,13 @@ def get_depreciation_amount(asset, depreciable_value, row):
rate_of_depreciation = row.rate_of_depreciation
# if its the first depreciation
if depreciable_value == asset.gross_purchase_amount:
# as per IT act, if the asset is purchased in the 2nd half of fiscal year, then rate is divided by 2
diff = date_diff(row.depreciation_start_date, asset.available_for_use_date)
if diff <= 180:
rate_of_depreciation = rate_of_depreciation / 2
frappe.msgprint(
_('As per IT Act, the rate of depreciation for the first depreciation entry is reduced by 50%.'))
if row.finance_book and frappe.db.get_value('Finance Book', row.finance_book, 'for_income_tax'):
# as per IT act, if the asset is purchased in the 2nd half of fiscal year, then rate is divided by 2
diff = date_diff(row.depreciation_start_date, asset.available_for_use_date)
if diff <= 180:
rate_of_depreciation = rate_of_depreciation / 2
frappe.msgprint(
_('As per IT Act, the rate of depreciation for the first depreciation entry is reduced by 50%.'))

depreciation_amount = flt(depreciable_value * (flt(rate_of_depreciation) / 100))

Expand Down