From 25e4af5b03e9d4fee2ee6d387718d734ab5c8169 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Wed, 5 May 2021 11:38:44 +0530 Subject: [PATCH] fix: Inward supplies liable to reverse charge --- .../doctype/gstr_3b_report/gstr_3b_report.py | 21 +++++++++++++++---- erpnext/regional/india/utils.py | 11 ++++++---- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.py b/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.py index 662e4d3c431..eea083bf81e 100644 --- a/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.py +++ b/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.py @@ -28,6 +28,9 @@ class GSTR3BReport(Document): self.get_outward_supply_details("Sales Invoice") self.set_outward_taxable_supplies() + self.get_outward_supply_details("Purchase Invoice", reverse_charge=True) + self.set_supplies_liable_to_reverse_charge() + itc_details = self.get_itc_details() self.set_itc_details(itc_details) self.get_itc_reversal_entries() @@ -129,7 +132,7 @@ class GSTR3BReport(Document): WHERE p.docstatus = 1 and p.name = i.parent and p.is_opening = 'No' and p.gst_category != 'Registered Composition' - and (i.is_nil_exempt = 1 or i.is_non_gst = 1 or p.gst_catgory = 'Registered Composition') and + and (i.is_nil_exempt = 1 or i.is_non_gst = 1 or p.gst_category = 'Registered Composition') and month(p.posting_date) = %s and year(p.posting_date) = %s and p.company = %s and p.company_gstin = %s GROUP BY p.place_of_supply, i.is_nil_exempt, i.is_non_gst""", @@ -170,7 +173,7 @@ class GSTR3BReport(Document): condition = '' if reverse_charge: - condition += 'AND reverse_charge = Y' + condition += "AND reverse_charge = 'Y'" invoice_details = frappe.db.sql(""" SELECT @@ -318,8 +321,18 @@ class GSTR3BReport(Document): self.set_inter_state_supply(inter_state_supply_details) def set_supplies_liable_to_reverse_charge(self): - # ToDo: - pass + for inv, items_based_on_rate in self.items_based_on_tax_rate.items(): + for rate, items in items_based_on_rate.items(): + for item_code, taxable_value in self.invoice_items.get(inv).items(): + if item_code in items: + if inv in self.cgst_sgst_invoices: + tax_rate = rate/2 + self.report_dict['sup_details']['isup_rev']['camt'] += (taxable_value * tax_rate /100) + self.report_dict['sup_details']['isup_rev']['samt'] += (taxable_value * tax_rate /100) + self.report_dict['sup_details']['isup_rev']['txval'] += taxable_value + else: + self.report_dict['sup_details']['isup_rev']['iamt'] += (taxable_value * rate /100) + self.report_dict['sup_details']['isup_rev']['txval'] += taxable_value def set_inter_state_supply(self, inter_state_supply): for key, value in iteritems(inter_state_supply): diff --git a/erpnext/regional/india/utils.py b/erpnext/regional/india/utils.py index b474b04bad1..4dc92ff90f8 100644 --- a/erpnext/regional/india/utils.py +++ b/erpnext/regional/india/utils.py @@ -728,16 +728,19 @@ def update_itc_availed_fields(doc, method): if country != 'India': return + # Initialize values + doc.itc_integrated_tax = doc.itc_state_tax = doc.itc_central_tax = doc.itc_cess_amount = 0 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 + doc.itc_integrated_tax += flt(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 + doc.itc_state_tax += flt(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 + doc.itc_central_tax += flt(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 + doc.itc_cess_amount += flt(tax.base_tax_amount_after_discount_amount) @frappe.whitelist() def get_regional_round_off_accounts(company, account_list):