From 3a83c7bd7d5340ef960e71b8535f868e1ef6f715 Mon Sep 17 00:00:00 2001 From: deepeshgarg007 Date: Tue, 2 Jul 2019 19:56:33 +0530 Subject: [PATCH] fix: Multiple fixes in GSTR-3b Report --- .../gstr_3b_report/gstr_3b_report.html | 16 ++-- .../doctype/gstr_3b_report/gstr_3b_report.py | 79 ++++++++++++------- 2 files changed, 58 insertions(+), 37 deletions(-) diff --git a/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.html b/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.html index 77a9b63dfe..2da79a6364 100644 --- a/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.html +++ b/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.html @@ -222,17 +222,17 @@   (1) {{__("As per rules 42 & 43 of CGST Rules")}} - - - - + {{ flt(data.itc_elg.itc_rev[0].iamt, 2) }} + {{ flt(data.itc_elg.itc_rev[0].camt, 2) }} + {{ flt(data.itc_elg.itc_rev[0].samt, 2) }} + {{ flt(data.itc_elg.itc_rev[0].csamt, 2) }}   (2) {{__("Others")}} - - - - + {{ flt(data.itc_elg.itc_rev[1].iamt, 2) }} + {{ flt(data.itc_elg.itc_rev[1].camt, 2) }} + {{ flt(data.itc_elg.itc_rev[1].samt, 2) }} + {{ flt(data.itc_elg.itc_rev[1].csamt, 2) }} (C) {{__("Net ITC Available(A) - (B)")}} 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 6569833659..448abe8f28 100644 --- a/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.py +++ b/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.py @@ -91,10 +91,10 @@ class GSTR3BReport(Document): }, { "ty": "ISD", - "iamt": 1, - "camt": 1, - "samt": 1, - "csamt": 1 + "iamt": 0, + "camt": 0, + "samt": 0, + "csamt": 0 }, { "samt": 0, @@ -104,6 +104,22 @@ class GSTR3BReport(Document): "iamt": 0 } ], + "itc_rev": [ + { + "ty": "RUL", + "iamt": 0, + "camt": 0, + "samt": 0, + "csamt": 0 + }, + { + "ty": "OTH", + "iamt": 0, + "camt": 0, + "samt": 0, + "csamt": 0 + } + ], "itc_net": { "samt": 0, "csamt": 0, @@ -173,6 +189,10 @@ class GSTR3BReport(Document): net_itc = self.report_dict["itc_elg"]["itc_net"] for d in self.report_dict["itc_elg"]["itc_avl"]: + + itc_type = itc_type_map.get(d["ty"]) + gst_category = "Registered Regular" + if d["ty"] == 'ISRC': reverse_charge = "Y" else: @@ -180,24 +200,22 @@ class GSTR3BReport(Document): for account_head in self.account_heads: - d["iamt"] = flt(itc_details.get((itc_type_map.get(d["ty"]), reverse_charge, account_head.get('igst_account')), {}).get("amount"), 2) - net_itc["iamt"] += flt(d["iamt"], 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) - d["camt"] = flt(itc_details.get((itc_type_map.get(d["ty"]), reverse_charge, account_head.get('cgst_account')), {}).get("amount"), 2) - net_itc["camt"] += flt(d["camt"], 2) - - d["samt"] = flt(itc_details.get((itc_type_map.get(d["ty"]), reverse_charge, account_head.get('sgst_account')), {}).get("amount"), 2) - net_itc["samt"] += flt(d["samt"], 2) - - d["csamt"] = flt(itc_details.get((itc_type_map.get(d["ty"]), reverse_charge, account_head.get('cess_account')), {}).get("amount"), 2) - net_itc["csamt"] += flt(d["csamt"], 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 account_head in self.account_heads: - - self.report_dict["itc_elg"]["itc_inelg"][1]["iamt"] = flt(itc_details.get(("Ineligible", "N", account_head.get("igst_account")), {}).get("amount"), 2) - self.report_dict["itc_elg"]["itc_inelg"][1]["camt"] = flt(itc_details.get(("Ineligible", "N", account_head.get("cgst_account")), {}).get("amount"), 2) - self.report_dict["itc_elg"]["itc_inelg"][1]["samt"] = flt(itc_details.get(("Ineligible", "N", account_head.get("sgst_account")), {}).get("amount"), 2) - self.report_dict["itc_elg"]["itc_inelg"][1]["csamt"] = flt(itc_details.get(("Ineligible", "N", account_head.get("cess_account")), {}).get("amount"), 2) + 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) def prepare_data(self, doctype, tax_details, supply_type, supply_category, gst_category_list, reverse_charge="N"): @@ -226,20 +244,22 @@ class GSTR3BReport(Document): def set_inter_state_supply(self, inter_state_supply): + osup_det = self.report_dict["sup_details"]["osup_det"] + for d in inter_state_supply.get("Unregistered", []): self.report_dict["inter_sup"]["unreg_details"].append(d) - self.report_dict["sup_details"]["osup_det"]["txval"] += flt(d["txval"], 2) - self.report_dict["sup_details"]["osup_det"]["iamt"] += flt(d["iamt"], 2) + osup_det["txval"] = flt(osup_det["txval"] + d["txval"], 2) + osup_det["iamt"] = flt(osup_det["iamt"] + d["iamt"], 2) for d in inter_state_supply.get("Registered Composition", []): self.report_dict["inter_sup"]["comp_details"].append(d) - self.report_dict["sup_details"]["osup_det"]["txval"] += flt(d["txval"], 2) - self.report_dict["sup_details"]["osup_det"]["iamt"] += flt(d["iamt"], 2) + osup_det["txval"] = flt(osup_det["txval"] + d["txval"], 2) + osup_det["iamt"] = flt(osup_det["iamt"] + d["iamt"], 2) for d in inter_state_supply.get("UIN Holders", []): self.report_dict["inter_sup"]["uin_details"].append(d) - self.report_dict["sup_details"]["osup_det"]["txval"] += flt(d["txval"], 2) - self.report_dict["sup_details"]["osup_det"]["iamt"] += flt(d["iamt"], 2) + osup_det["txval"] = flt(osup_det["txval"] + d["txval"], 2) + osup_det["iamt"] = flt(osup_det["iamt"] + d["iamt"], 2) def get_total_taxable_value(self, doctype, reverse_charge): @@ -268,7 +288,7 @@ class GSTR3BReport(Document): itc_details = {} for d in itc_amount: - itc_details.setdefault((d.eligibility_for_itc, d.reverse_charge, d.account_head),{ + itc_details.setdefault((d.gst_category, d.eligibility_for_itc, d.reverse_charge, d.account_head),{ "amount": d.tax_amount }) @@ -315,9 +335,10 @@ class GSTR3BReport(Document): "iamt": flt(inter_state_supply_tax_mapping.get(d.place_of_supply), 2) }) else: - self.report_dict["sup_details"]["osup_det"]["txval"] += flt(d.total, 2) - self.report_dict["sup_details"]["osup_det"]["camt"] += flt(inter_state_supply_tax_mapping.get(d.place_of_supply)/2, 2) - self.report_dict["sup_details"]["osup_det"]["samt"] += flt(inter_state_supply_tax_mapping.get(d.place_of_supply)/2, 2) + osup_det = self.report_dict["sup_details"]["osup_det"] + osup_det["txval"] = flt(osup_det["txval"] + d.total, 2) + osup_det["camt"] = flt(osup_det["camt"] + inter_state_supply_tax_mapping.get(d.place_of_supply)/2, 2) + osup_det["samt"] = flt(osup_det["samt"] + inter_state_supply_tax_mapping.get(d.place_of_supply)/2, 2) return inter_state_supply_details