mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-01 11:19:09 +00:00
fix: Hooks method to update availed ITC field
This commit is contained in:
@@ -261,6 +261,7 @@ doc_events = {
|
|||||||
"Purchase Invoice": {
|
"Purchase Invoice": {
|
||||||
"validate": [
|
"validate": [
|
||||||
"erpnext.regional.india.utils.validate_reverse_charge_transaction",
|
"erpnext.regional.india.utils.validate_reverse_charge_transaction",
|
||||||
|
"erpnext.regional.india.utils.update_itc_availed_fields",
|
||||||
"erpnext.regional.united_arab_emirates.utils.update_grand_total_for_rcm",
|
"erpnext.regional.united_arab_emirates.utils.update_grand_total_for_rcm",
|
||||||
"erpnext.regional.united_arab_emirates.utils.validate_returns"
|
"erpnext.regional.united_arab_emirates.utils.validate_returns"
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -674,9 +674,11 @@ def validate_state_code(state_code, address):
|
|||||||
return int(state_code)
|
return int(state_code)
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_gst_accounts(company, account_wise=False, only_reverse_charge=0, only_non_reverse_charge=0):
|
def get_gst_accounts(company=None, account_wise=False, only_reverse_charge=0, only_non_reverse_charge=0):
|
||||||
filters={"parent": "GST Settings", "company": company}
|
filters={"parent": "GST Settings"}
|
||||||
|
|
||||||
|
if company:
|
||||||
|
filters.update({'company': company})
|
||||||
if only_reverse_charge:
|
if only_reverse_charge:
|
||||||
filters.update({'is_reverse_charge_account': 1})
|
filters.update({'is_reverse_charge_account': 1})
|
||||||
elif only_non_reverse_charge:
|
elif only_non_reverse_charge:
|
||||||
@@ -718,10 +720,16 @@ def validate_reverse_charge_transaction(doc, method):
|
|||||||
+ gst_accounts.get('igst_account')
|
+ gst_accounts.get('igst_account')
|
||||||
|
|
||||||
for tax in doc.get('taxes'):
|
for tax in doc.get('taxes'):
|
||||||
if tax.account_head in non_reverse_charge_accounts and tax.add_deduct_tax == 'Add':
|
if tax.account_head in non_reverse_charge_accounts:
|
||||||
base_gst_tax += tax.base_tax_amount_after_discount_amount
|
if tax.add_deduct_tax == 'Add':
|
||||||
elif tax.account_head in reverse_charge_accounts and tax.add_deduct_tax == 'Deduct':
|
base_gst_tax += tax.base_tax_amount_after_discount_amount
|
||||||
base_reverse_charge_booked += tax.base_tax_amount_after_discount_amount
|
else:
|
||||||
|
base_gst_tax += tax.base_tax_amount_after_discount_amount
|
||||||
|
elif tax.account_head in reverse_charge_accounts:
|
||||||
|
if tax.add_deduct_tax == 'Add':
|
||||||
|
base_reverse_charge_booked += tax.base_tax_amount_after_discount_amount
|
||||||
|
else:
|
||||||
|
base_reverse_charge_booked += tax.base_tax_amount_after_discount_amount
|
||||||
|
|
||||||
if base_gst_tax != base_reverse_charge_booked:
|
if base_gst_tax != base_reverse_charge_booked:
|
||||||
msg = _("Booked reverse charge is not equal to applied tax amount")
|
msg = _("Booked reverse charge is not equal to applied tax amount")
|
||||||
@@ -731,6 +739,23 @@ def validate_reverse_charge_transaction(doc, method):
|
|||||||
|
|
||||||
frappe.throw(msg)
|
frappe.throw(msg)
|
||||||
|
|
||||||
|
def update_itc_availed_fields(doc, method):
|
||||||
|
country = frappe.get_cached_value('Company', doc.company, 'country')
|
||||||
|
|
||||||
|
if country != 'India':
|
||||||
|
return
|
||||||
|
|
||||||
|
gst_accounts = get_gst_accounts(doc.company, only_non_reverse_charge=1)
|
||||||
|
for tax in doc.get('taxes'):
|
||||||
|
if tax.account_head in gst_accounts.get('igst_account'):
|
||||||
|
doc.itc_integrated_tax += tax.base_tax_amount_after_discount_amount
|
||||||
|
if tax.account_head in gst_accounts.get('sgst_account'):
|
||||||
|
doc.itc_state_tax += tax.base_tax_amount_after_discount_amount
|
||||||
|
if tax.account_head in gst_accounts.get('cgst_account'):
|
||||||
|
doc.itc_central_tax += tax.base_tax_amount_after_discount_amount
|
||||||
|
if tax.account_head in gst_accounts.get('cess_account'):
|
||||||
|
doc.itc_cess_amount += tax.base_tax_amount_after_discount_amount
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_regional_round_off_accounts(company, account_list):
|
def get_regional_round_off_accounts(company, account_list):
|
||||||
country = frappe.get_cached_value('Company', company, 'country')
|
country = frappe.get_cached_value('Company', company, 'country')
|
||||||
|
|||||||
Reference in New Issue
Block a user