Merge pull request #22086 from deepeshgarg007/rcm_develop
fix(India): Reverse charge mechanism for GST
This commit is contained in:
commit
f1cbe89496
@ -238,6 +238,9 @@ doc_events = {
|
||||
"on_cancel": "erpnext.regional.italy.utils.sales_invoice_on_cancel",
|
||||
"on_trash": "erpnext.regional.check_deletion_permission"
|
||||
},
|
||||
"Purchase Invoice": {
|
||||
"on_submit": "erpnext.regional.india.utils.make_reverse_charge_entries"
|
||||
},
|
||||
"Payment Entry": {
|
||||
"on_submit": ["erpnext.regional.create_transaction_log", "erpnext.accounts.doctype.payment_request.payment_request.update_payment_req_status"],
|
||||
"on_trash": "erpnext.regional.check_deletion_permission"
|
||||
|
@ -52,7 +52,7 @@
|
||||
<td class="disabled"></td>
|
||||
<td class="disabled"></td>
|
||||
<tr>
|
||||
<td>(d) {{__("Inward Supplies(liable to reverse charge")}}</td>
|
||||
<td>(d) {{__("Inward Supplies(liable to reverse charge)")}}</td>
|
||||
<td class="right">{{ flt(data.sup_details.isup_rev.txval, 2) }}</td>
|
||||
<td class="right">{{ flt(data.sup_details.isup_rev.iamt, 2) }}</td>
|
||||
<td class="right">{{ flt(data.sup_details.isup_rev.camt, 2) }}</td>
|
||||
|
@ -158,7 +158,7 @@ class GSTR3BReport(Document):
|
||||
|
||||
self.prepare_data("Sales Invoice", outward_supply_tax_amounts, "sup_details", "osup_det", ["Registered Regular"])
|
||||
self.prepare_data("Sales Invoice", outward_supply_tax_amounts, "sup_details", "osup_zero", ["SEZ", "Deemed Export", "Overseas"])
|
||||
self.prepare_data("Purchase Invoice", inward_supply_tax_amounts, "sup_details", "isup_rev", ["Registered Regular"], reverse_charge="Y")
|
||||
self.prepare_data("Purchase Invoice", inward_supply_tax_amounts, "sup_details", "isup_rev", ["Unregistered", "Overseas"], reverse_charge="Y")
|
||||
self.report_dict["sup_details"]["osup_nil_exmp"]["txval"] = flt(self.get_nil_rated_supply_value(), 2)
|
||||
self.set_itc_details(itc_details)
|
||||
|
||||
@ -192,31 +192,27 @@ class GSTR3BReport(Document):
|
||||
for d in self.report_dict["itc_elg"]["itc_avl"]:
|
||||
|
||||
itc_type = itc_type_map.get(d["ty"])
|
||||
gst_category = "Registered Regular"
|
||||
gst_category = ["Registered Regular"]
|
||||
|
||||
if d["ty"] == 'ISRC':
|
||||
reverse_charge = "Y"
|
||||
itc_type = 'All Other ITC'
|
||||
gst_category = ['Unregistered', 'Overseas']
|
||||
else:
|
||||
reverse_charge = "N"
|
||||
|
||||
for account_head in self.account_heads:
|
||||
for category in gst_category:
|
||||
for key in [['iamt', 'igst_account'], ['camt', 'cgst_account'], ['samt', 'sgst_account'], ['csamt', 'cess_account']]:
|
||||
d[key[0]] += flt(itc_details.get((category, itc_type, reverse_charge, account_head.get(key[1])), {}).get("amount"), 2)
|
||||
|
||||
d["iamt"] += flt(itc_details.get((gst_category, itc_type, reverse_charge, account_head.get('igst_account')), {}).get("amount"), 2)
|
||||
d["camt"] += flt(itc_details.get((gst_category, itc_type, reverse_charge, account_head.get('cgst_account')), {}).get("amount"), 2)
|
||||
d["samt"] += flt(itc_details.get((gst_category, itc_type, reverse_charge, account_head.get('sgst_account')), {}).get("amount"), 2)
|
||||
d["csamt"] += flt(itc_details.get((gst_category, itc_type, reverse_charge, account_head.get('cess_account')), {}).get("amount"), 2)
|
||||
|
||||
net_itc["iamt"] += flt(d["iamt"], 2)
|
||||
net_itc["camt"] += flt(d["camt"], 2)
|
||||
net_itc["samt"] += flt(d["samt"], 2)
|
||||
net_itc["csamt"] += flt(d["csamt"], 2)
|
||||
for key in ['iamt', 'camt', 'samt', 'csamt']:
|
||||
net_itc[key] += flt(d[key], 2)
|
||||
|
||||
for account_head in self.account_heads:
|
||||
itc_inelg = self.report_dict["itc_elg"]["itc_inelg"][1]
|
||||
itc_inelg["iamt"] = flt(itc_details.get(("Ineligible", "N", account_head.get("igst_account")), {}).get("amount"), 2)
|
||||
itc_inelg["camt"] = flt(itc_details.get(("Ineligible", "N", account_head.get("cgst_account")), {}).get("amount"), 2)
|
||||
itc_inelg["samt"] = flt(itc_details.get(("Ineligible", "N", account_head.get("sgst_account")), {}).get("amount"), 2)
|
||||
itc_inelg["csamt"] = flt(itc_details.get(("Ineligible", "N", account_head.get("cess_account")), {}).get("amount"), 2)
|
||||
for key in [['iamt', 'igst_account'], ['camt', 'cgst_account'], ['samt', 'sgst_account'], ['csamt', 'cess_account']]:
|
||||
itc_inelg[key[0]] = flt(itc_details.get(("Ineligible", "N", account_head.get(key[1])), {}).get("amount"), 2)
|
||||
|
||||
def prepare_data(self, doctype, tax_details, supply_type, supply_category, gst_category_list, reverse_charge="N"):
|
||||
|
||||
@ -274,17 +270,16 @@ class GSTR3BReport(Document):
|
||||
""" #nosec
|
||||
.format(doctype = doctype), (self.month_no, self.year, reverse_charge, self.company, self.gst_details.get("gstin"))))
|
||||
|
||||
def get_itc_details(self, reverse_charge='N'):
|
||||
|
||||
def get_itc_details(self):
|
||||
itc_amount = frappe.db.sql("""
|
||||
select s.gst_category, sum(t.tax_amount_after_discount_amount) as tax_amount, t.account_head, s.eligibility_for_itc, s.reverse_charge
|
||||
from `tabPurchase Invoice` s , `tabPurchase Taxes and Charges` t
|
||||
where s.docstatus = 1 and t.parent = s.name and s.reverse_charge = %s
|
||||
where s.docstatus = 1 and t.parent = s.name
|
||||
and month(s.posting_date) = %s and year(s.posting_date) = %s and s.company = %s
|
||||
and s.company_gstin = %s
|
||||
group by t.account_head, s.gst_category, s.eligibility_for_itc
|
||||
""",
|
||||
(reverse_charge, self.month_no, self.year, self.company, self.gst_details.get("gstin")), as_dict=1)
|
||||
(self.month_no, self.year, self.company, self.gst_details.get("gstin")), as_dict=1)
|
||||
|
||||
itc_details = {}
|
||||
|
||||
|
@ -9,6 +9,8 @@ from erpnext.hr.utils import get_salary_assignment
|
||||
from erpnext.hr.doctype.salary_structure.salary_structure import make_salary_slip
|
||||
from erpnext.regional.india import number_state_mapping
|
||||
from six import string_types
|
||||
from erpnext.accounts.general_ledger import make_gl_entries
|
||||
from erpnext.accounts.utils import get_account_currency
|
||||
|
||||
def validate_gstin_for_india(doc, method):
|
||||
if hasattr(doc, 'gst_state') and doc.gst_state:
|
||||
@ -658,5 +660,53 @@ def get_gst_accounts(company, account_wise=False):
|
||||
elif val:
|
||||
gst_accounts[val] = acc
|
||||
|
||||
|
||||
return gst_accounts
|
||||
|
||||
def make_reverse_charge_entries(doc, method):
|
||||
country = frappe.get_cached_value('Company', doc.company, 'country')
|
||||
|
||||
if country != 'India':
|
||||
return
|
||||
|
||||
if doc.reverse_charge == 'Y':
|
||||
gl_entries = []
|
||||
gst_accounts = get_gst_accounts(doc.company)
|
||||
gst_account_list = gst_accounts.get('cgst_account') + gst_accounts.get('sgst_account') \
|
||||
+ gst_accounts.get('igst_account')
|
||||
|
||||
for tax in doc.get('taxes'):
|
||||
if tax.category not in ("Total", "Valuation and Total"):
|
||||
continue
|
||||
|
||||
if flt(tax.base_tax_amount_after_discount_amount) and tax.account_head in gst_account_list:
|
||||
account_currency = get_account_currency(tax.account_head)
|
||||
|
||||
gl_entries.append(doc.get_gl_dict(
|
||||
{
|
||||
"account": tax.account_head,
|
||||
"cost_center": tax.cost_center,
|
||||
"posting_date": doc.posting_date,
|
||||
"against": doc.supplier,
|
||||
"credit": tax.base_tax_amount_after_discount_amount,
|
||||
"credits_in_account_currency": tax.base_tax_amount_after_discount_amount \
|
||||
if account_currency==doc.company_currency \
|
||||
else tax.tax_amount_after_discount_amount
|
||||
}, account_currency, item=tax)
|
||||
)
|
||||
|
||||
gl_entries.append(doc.get_gl_dict(
|
||||
{
|
||||
"account": doc.credit_to if doc.doctype == 'Purchase Invoice' else doc.debit_to,
|
||||
"cost_center": doc.cost_center,
|
||||
"posting_date": doc.posting_date,
|
||||
"party_type": 'Supplier',
|
||||
"party": doc.supplier,
|
||||
"against": tax.account_head,
|
||||
"debit": tax.base_tax_amount_after_discount_amount,
|
||||
"debit_in_account_currency": tax.base_tax_amount_after_discount_amount \
|
||||
if account_currency==doc.company_currency \
|
||||
else tax.tax_amount_after_discount_amount
|
||||
}, account_currency, item=doc)
|
||||
)
|
||||
|
||||
make_gl_entries(gl_entries)
|
Loading…
x
Reference in New Issue
Block a user