From 419a64b5ecab26b6852cb16e91de6c5c19596a6b Mon Sep 17 00:00:00 2001 From: Ninad1306 Date: Tue, 24 Sep 2024 12:24:00 +0530 Subject: [PATCH 1/4] fix: items table removed from gstr_2b api --- india_compliance/gst_india/utils/gstr_2/gstr.py | 2 +- india_compliance/gst_india/utils/gstr_2/gstr_2b.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/india_compliance/gst_india/utils/gstr_2/gstr.py b/india_compliance/gst_india/utils/gstr_2/gstr.py index f9979cc59..a5a4384bb 100644 --- a/india_compliance/gst_india/utils/gstr_2/gstr.py +++ b/india_compliance/gst_india/utils/gstr_2/gstr.py @@ -128,7 +128,7 @@ def get_invoice_details(self, invoice): def get_transaction_items(self, invoice): return [ self.get_transaction_item(frappe._dict(item)) - for item in invoice.get(self.get_key("items_key")) + for item in invoice.get(self.get_key("items_key"), []) ] def get_transaction_item(self, item): diff --git a/india_compliance/gst_india/utils/gstr_2/gstr_2b.py b/india_compliance/gst_india/utils/gstr_2/gstr_2b.py index 1e9b348b1..54915b046 100644 --- a/india_compliance/gst_india/utils/gstr_2/gstr_2b.py +++ b/india_compliance/gst_india/utils/gstr_2/gstr_2b.py @@ -35,7 +35,6 @@ class GSTR2bB2B(GSTR2b): def setup(self): super().setup() self.set_key("invoice_key", "inv") - self.set_key("items_key", "items") def get_invoice_details(self, invoice): return { From bd442f68c19b20f33e3588417b901639e2b41e88 Mon Sep 17 00:00:00 2001 From: Ninad1306 Date: Tue, 24 Sep 2024 13:37:25 +0530 Subject: [PATCH 2/4] fix: update test cases --- .../gst_india/data/test_gstr_2b.json | 493 ++++++++++++++++-- .../gst_india/utils/gstr_2/test_gstr_2b.py | 44 -- 2 files changed, 445 insertions(+), 92 deletions(-) diff --git a/india_compliance/gst_india/data/test_gstr_2b.json b/india_compliance/gst_india/data/test_gstr_2b.json index d84202a6e..c8b741a93 100644 --- a/india_compliance/gst_india/data/test_gstr_2b.json +++ b/india_compliance/gst_india/data/test_gstr_2b.json @@ -35,6 +35,18 @@ "cgst": 200, "sgst": 200, "cess": 100 + }, + "ecom": { + "igst": 400, + "cgst": 200, + "sgst": 200, + "cess": 100 + }, + "ecoma": { + "igst": 400, + "cgst": 200, + "sgst": 200, + "cess": 100 } }, "isdsup": { @@ -187,6 +199,18 @@ "cgst": 200, "sgst": 200, "cess": 100 + }, + "ecom": { + "igst": 400, + "cgst": 200, + "sgst": 200, + "cess": 100 + }, + "ecoma": { + "igst": 400, + "cgst": 200, + "sgst": 200, + "cess": 100 } }, "isdsup": { @@ -309,6 +333,128 @@ "cess": 100 } } + }, + "itcrev": { + "nonrevsup": { + "igst": 1600, + "cgst": 800, + "sgst": 800, + "cess": 400, + "b2b": { + "igst": 400, + "cgst": 200, + "sgst": 200, + "cess": 100 + }, + "b2ba": { + "igst": 400, + "cgst": 200, + "sgst": 200, + "cess": 100 + }, + "cdnr": { + "igst": 400, + "cgst": 200, + "sgst": 200, + "cess": 100 + }, + "cdnra": { + "igst": 400, + "cgst": 200, + "sgst": 200, + "cess": 100 + } + }, + "isdsup": { + "igst": 0, + "cgst": 0, + "sgst": 0, + "cess": 0, + "isd": { + "igst": 0, + "cgst": 0, + "sgst": 0, + "cess": 0 + }, + "isda": { + "igst": 0, + "cgst": 0, + "sgst": 0, + "cess": 0 + } + }, + "imports": { + "igst": 0, + "cgst": 0, + "sgst": 0, + "cess": 0, + "impg": { + "igst": 0, + "cgst": 0, + "sgst": 0, + "cess": 0 + }, + "impgsez": { + "igst": 0, + "cgst": 0, + "sgst": 0, + "cess": 0 + }, + "impga": { + "igst": 0, + "cgst": 0, + "sgst": 0, + "cess": 0 + }, + "impgasez": { + "igst": 0, + "cgst": 0, + "sgst": 0, + "cess": 0 + } + }, + "othersup": { + "igst": 1600, + "cgst": 800, + "sgst": 800, + "cess": 400, + "cdnr": { + "igst": 400, + "cgst": 200, + "sgst": 200, + "cess": 100 + }, + "cdnra": { + "igst": 400, + "cgst": 200, + "sgst": 200, + "cess": 100 + }, + "cdnrrev": { + "igst": 400, + "cgst": 200, + "sgst": 200, + "cess": 100 + }, + "cdnrarev": { + "igst": 400, + "cgst": 200, + "sgst": 200, + "cess": 100 + }, + "isd": { + "igst": 400, + "cgst": 200, + "sgst": 200, + "cess": 100 + }, + "isda": { + "igst": 400, + "cgst": 200, + "sgst": 200, + "cess": 100 + } + } } }, "cpsumm": { @@ -408,6 +554,112 @@ "igst": 400, "cess": 100 } + ], + "ecom": [ + { + "sgst": 0, + "ttldocs": 1, + "trdnm": "GSTN", + "supprd": "012023", + "supfildt": "26-08-2023", + "txval": 12324, + "ctin": "07USERR0205A1ZS", + "cgst": 0, + "cess": 0, + "igst": 123.24 + }, + { + "sgst": 0, + "ttldocs": 1, + "trdnm": "GSTN", + "supprd": "052023", + "supfildt": "26-08-2023", + "txval": 443, + "ctin": "07USERR0205A1ZS", + "cgst": 0, + "cess": 0, + "igst": 4.43 + } + ], + "ecoma": [ + { + "sgst": 0, + "ttldocs": 1, + "trdnm": "GSTN", + "supprd": "012023", + "supfildt": "26-08-2023", + "txval": 12324, + "ctin": "07USERR0205A1ZS", + "cgst": 0, + "cess": 0, + "igst": 123.24 + }, + { + "sgst": 0, + "ttldocs": 1, + "trdnm": "GSTN", + "supprd": "052023", + "supfildt": "26-08-2023", + "txval": 443, + "ctin": "07USERR0205A1ZS", + "cgst": 0, + "cess": 0, + "igst": 4.43 + } + ], + "itcrev": [ + { + "b2b": { + "ctin": "00AABCE2207R1Z5", + "trdnm": "GSTN", + "supprd": "022020", + "supfildt": "02-03-2020", + "ttldocs": 3, + "txval": 500, + "igst": 400, + "cgst": 0, + "sgst": 0, + "cess": 100 + }, + "b2ba": { + "ctin": "00AABCE2207R1Z5", + "trdnm": "GSTN", + "supprd": "022020", + "supfildt": "02-03-2020", + "ttldocs": 3, + "txval": 500, + "igst": 400, + "cgst": 0, + "sgst": 0, + "cess": 100 + }, + "cdnr": { + "ctin": "00AABCE2207R1Z5", + "trdnm": "GSTN", + "supprd": "022020", + "supfildt": "02-03-2020", + "nttyp": "D", + "ttldocs": 3, + "txval": 400, + "igst": 0, + "cgst": 200, + "sgst": 200, + "cess": 0 + }, + "cdnra": { + "ctin": "00AABCE2207R1Z5", + "trdnm": "GSTN", + "supprd": "022020", + "supfildt": "02-03-2020", + "nttyp": "D", + "ttldocs": 3, + "txval": 400, + "igst": 0, + "cgst": 200, + "sgst": 200, + "cess": 0 + } + } ] }, "docdata": { @@ -430,18 +682,7 @@ "diffprcnt": 1, "srctyp": "e-Invoice", "irn": "897ADG56RTY78956HYUG90BNHHIJK453GFTD99845672FDHHHSHGFH4567FG56TR", - "irngendate": "24-12-2019", - "items": [ - { - "num": 1, - "rt": 5, - "txval": 400, - "igst": 0, - "cgst": 200, - "sgst": 200, - "cess": 0 - } - ] + "irngendate": "24-12-2019" } ] } @@ -464,18 +705,7 @@ "rev": "N", "itcavl": "N", "rsn": "P", - "diffprcnt": 1, - "items": [ - { - "num": 1, - "rt": 5, - "txval": 400, - "igst": 0, - "cgst": 200, - "sgst": 200, - "cess": 0 - } - ] + "diffprcnt": 1 } ] } @@ -500,18 +730,7 @@ "diffprcnt": 1, "srctyp": "e-Invoice", "irn": "897ADG56RTY78956HYUG90BNHHIJK453GFTD99845672FDHHHSHGFH4567FG56TR", - "irngendate": "24-12-2019", - "items": [ - { - "num": 1, - "rt": 5, - "txval": 400, - "igst": 400, - "cgst": 0, - "sgst": 0, - "cess": 0 - } - ] + "irngendate": "24-12-2019" } ] } @@ -536,18 +755,7 @@ "rev": "N", "itcavl": "N", "rsn": "C", - "diffprcnt": 1, - "items": [ - { - "num": 1, - "rt": 5, - "txval": 400, - "igst": 0, - "cgst": 200, - "sgst": 200, - "cess": 0 - } - ] + "diffprcnt": 1 } ] } @@ -630,6 +838,195 @@ } ] } + ], + "ecom": [ + { + "inv": [ + { + "dt": "01-01-2023", + "val": 343242, + "rev": "N", + "itcavl": "Y", + "pos": "23", + "typ": "R", + "inum": "doc1", + "rsn": "", + "srctyp": "e-Invoice", + "irn": "897ADG56RTY78956HYUG90BNHHIJK453GFTD99845672FDHHHSHGFH4567FG56TR", + "irngendate": "24-12-2019" + } + ], + "trdnm": "GSTN", + "supfildt": "26-08-2023", + "supprd": "012023", + "ctin": "07USERR0205A1ZS" + }, + { + "inv": [ + { + "dt": "01-05-2023", + "val": 234324234, + "rev": "N", + "itcavl": "Y", + "pos": "23", + "typ": "R", + "inum": "E123", + "rsn": "", + "srctyp": "e-Invoice", + "irn": "897ADG56RTY78956HYUG90BNHHIJK453GFTD99845672FDHHHSHGFH4567FG56TR", + "irngendate": "24-12-2019" + } + ], + "trdnm": "GSTN", + "supfildt": "26-08-2023", + "supprd": "052023", + "ctin": "07USERR0205A1ZS" + } + ], + "ecoma": [ + { + "inv": [ + { + "dt": "01-01-2023", + "val": 343242, + "rev": "N", + "itcavl": "Y", + "pos": "23", + "typ": "R", + "inum": "doc1", + "rsn": "", + "srctyp": "e-Invoice", + "irn": "897ADG56RTY78956HYUG90BNHHIJK453GFTD99845672FDHHHSHGFH4567FG56TR", + "irngendate": "24-12-2019" + } + ], + "trdnm": "GSTN", + "supfildt": "26-08-2023", + "supprd": "012023", + "ctin": "07USERR0205A1ZS" + }, + { + "inv": [ + { + "dt": "01-05-2023", + "val": 234324234, + "rev": "N", + "itcavl": "Y", + "pos": "23", + "typ": "R", + "inum": "E123", + "rsn": "", + "srctyp": "e-Invoice", + "irn": "897ADG56RTY78956HYUG90BNHHIJK453GFTD99845672FDHHHSHGFH4567FG56TR", + "irngendate": "24-12-2019" + } + ], + "trdnm": "GSTN", + "supfildt": "26-08-2023", + "supprd": "052023", + "ctin": "07USERR0205A1ZS" + } + ], + "itcrev": [ + { + "b2b": [ + { + "ctin": "01AABCE2207R1Z5", + "trdnm": "GSTN", + "supfildt": "18-11-2019", + "supprd": "112019", + "inv": [ + { + "inum": "S008400", + "typ": "R", + "dt": "24-11-2016", + "val": 729248.16, + "pos": "06", + "rev": "N", + "itcavl": "N", + "rsn": "P", + "diffprcnt": 1, + "srctyp": "e-Invoice", + "irn": "897ADG56RTY78956HYUG90BNHHIJK453GFTD99845672FDHHHSHGFH4567FG56TR", + "irngendate": "24-12-2019" + } + ] + } + ], + "b2ba": [ + { + "ctin": "01AABCE2207R1Z5", + "trdnm": "GSTN", + "supfildt": "18-11-2019", + "supprd": "112019", + "inv": [ + { + "oinum": "S008400", + "oidt": "24-11-2016", + "inum": "S008400", + "typ": "R", + "dt": "24-11-2016", + "val": 729248.16, + "pos": "06", + "rev": "N", + "itcavl": "N", + "rsn": "P", + "diffprcnt": 1 + } + ] + } + ], + "cdnr": [ + { + "ctin": "01AAAAP1208Q1ZS", + "trdnm": "GSTN", + "supfildt": "18-11-2019", + "supprd": "112019", + "nt": [ + { + "ntnum": "533515", + "typ": "D", + "suptyp": "R", + "dt": "23-09-2016", + "val": 729248.16, + "pos": "01", + "rev": "N", + "itcavl": "N", + "rsn": "C", + "diffprcnt": 1, + "srctyp": "e-Invoice", + "irn": "897ADG56RTY78956HYUG90BNHHIJK453GFTD99845672FDHHHSHGFH4567FG56TR", + "irngendate": "24-12-2019" + } + ] + } + ], + "cdnra": [ + { + "ctin": "01AAAAP1208Q1ZS", + "trdnm": "GSTN", + "supfildt": "18-11-2019", + "supprd": "112019", + "nt": [ + { + "onttyp": "D", + "ontnum": "533515", + "ontdt": "23-09-2016", + "ntnum": "533515", + "typ": "D", + "suptyp": "R", + "dt": "23-09-2016", + "val": 729248.16, + "pos": "01", + "rev": "N", + "itcavl": "N", + "rsn": "C", + "diffprcnt": 1 + } + ] + } + ] + } ] } } diff --git a/india_compliance/gst_india/utils/gstr_2/test_gstr_2b.py b/india_compliance/gst_india/utils/gstr_2/test_gstr_2b.py index 47f2a14cb..fead11d7c 100644 --- a/india_compliance/gst_india/utils/gstr_2/test_gstr_2b.py +++ b/india_compliance/gst_india/utils/gstr_2/test_gstr_2b.py @@ -58,17 +58,6 @@ def test_gstr2b_b2b(self): ), "irn_gen_date": date(2019, 12, 24), "doc_type": "Invoice", - "items": [ - { - "item_number": 1, - "rate": 5, - "taxable_value": 400, - "igst": 0, - "cgst": 200, - "sgst": 200, - "cess": 0, - } - ], }, doc, ) @@ -98,17 +87,6 @@ def test_gstr2b_b2ba(self): "original_bill_no": "S008400", "original_bill_date": date(2016, 11, 24), "doc_type": "Invoice", - "items": [ - { - "item_number": 1, - "rate": 5, - "taxable_value": 400, - "igst": 0, - "cgst": 200, - "sgst": 200, - "cess": 0, - } - ], }, doc, ) @@ -138,17 +116,6 @@ def test_gstr2b_cdnr(self): ), "irn_gen_date": date(2019, 12, 24), "doc_type": "Credit Note", - "items": [ - { - "item_number": 1, - "rate": 5, - "taxable_value": 400, - "igst": 400, - "cgst": 0, - "sgst": 0, - "cess": 0, - } - ], }, doc, ) @@ -176,17 +143,6 @@ def test_gstr2b_cdnra(self): "reason_itc_unavailability": "Return filed post annual cut-off", "diffprcnt": "1", "doc_type": "Credit Note", - "items": [ - { - "item_number": 1, - "rate": 5, - "taxable_value": 400, - "igst": 0, - "cgst": 200, - "sgst": 200, - "cess": 0, - } - ], }, doc, ) From b911cc90976ab9cc507b19a9900d571978132012 Mon Sep 17 00:00:00 2001 From: Ninad1306 Date: Thu, 14 Nov 2024 18:22:58 +0530 Subject: [PATCH 3/4] fix: item values available in invoice only --- .../gst_india/utils/gstr_2/gstr_2b.py | 28 +++++++------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/india_compliance/gst_india/utils/gstr_2/gstr_2b.py b/india_compliance/gst_india/utils/gstr_2/gstr_2b.py index 54915b046..47f166745 100644 --- a/india_compliance/gst_india/utils/gstr_2/gstr_2b.py +++ b/india_compliance/gst_india/utils/gstr_2/gstr_2b.py @@ -19,16 +19,16 @@ def get_supplier_details(self, supplier): "sup_return_period": supplier.supprd, } - def get_transaction_item(self, item): - return { - "item_number": item.num, - "rate": item.rt, - "taxable_value": item.txval, - "igst": item.igst, - "cgst": item.cgst, - "sgst": item.sgst, - "cess": item.cess, - } + def get_transaction_items(self, invoice): + return [ + { + "taxable_value": invoice.txval, + "igst": invoice.igst, + "cgst": invoice.cgst, + "sgst": invoice.sgst, + "cess": invoice.cess, + } + ] class GSTR2bB2B(GSTR2b): @@ -131,10 +131,6 @@ def get_invoice_details(self, invoice): "document_value": invoice.igst + invoice.cgst + invoice.sgst + invoice.cess, } - # item details are included in invoice details - def get_transaction_items(self, invoice): - return [self.get_transaction_item(invoice)] - class GSTR2bISDA(GSTR2bISD): def get_invoice_details(self, invoice): @@ -167,10 +163,6 @@ def get_invoice_details(self, invoice): "itc_availability": "Yes", # always available } - # item details are included in invoice details - def get_transaction_items(self, invoice): - return [self.get_transaction_item(invoice)] - class GSTR2bIMPG(GSTR2bIMPGSEZ): def get_supplier_details(self, supplier): From 6053872b988ed1d94e53463a1b4f39cf87041eaf Mon Sep 17 00:00:00 2001 From: Ninad1306 Date: Thu, 14 Nov 2024 18:39:45 +0530 Subject: [PATCH 4/4] fix: updated test cases --- .../gst_india/data/test_gstr_2b.json | 42 +++++++++++++++++++ .../gst_india/utils/gstr_2/test_gstr_2b.py | 36 ++++++++++++++++ 2 files changed, 78 insertions(+) diff --git a/india_compliance/gst_india/data/test_gstr_2b.json b/india_compliance/gst_india/data/test_gstr_2b.json index c8b741a93..74fac8dee 100644 --- a/india_compliance/gst_india/data/test_gstr_2b.json +++ b/india_compliance/gst_india/data/test_gstr_2b.json @@ -673,6 +673,11 @@ { "inum": "S008400", "typ": "R", + "txval": 12200, + "sgst": 0, + "cgst": 0, + "cess": 0, + "igst": 183, "dt": "24-11-2016", "val": 729248.16, "pos": "06", @@ -699,6 +704,11 @@ "oidt": "24-11-2016", "inum": "S008400", "typ": "R", + "txval": 12200, + "sgst": 0, + "cgst": 0, + "cess": 0, + "igst": 183, "dt": "24-11-2016", "val": 729248.16, "pos": "06", @@ -723,6 +733,11 @@ "suptyp": "R", "dt": "23-09-2016", "val": 729248.16, + "txval": 12200, + "sgst": 0, + "cgst": 0, + "cess": 0, + "igst": 183, "pos": "01", "rev": "N", "itcavl": "N", @@ -748,7 +763,12 @@ "ontdt": "23-09-2016", "ntnum": "533515", "typ": "C", + "txval": 12200, "suptyp": "R", + "sgst": 0, + "cgst": 0, + "cess": 0, + "igst": 183, "dt": "23-09-2016", "val": 729248.16, "pos": "01", @@ -845,6 +865,11 @@ { "dt": "01-01-2023", "val": 343242, + "sgst": 0, + "cgst": 0, + "cess": 0, + "igst": 183, + "txval": 12200, "rev": "N", "itcavl": "Y", "pos": "23", @@ -866,6 +891,11 @@ { "dt": "01-05-2023", "val": 234324234, + "sgst": 0, + "cgst": 0, + "cess": 0, + "igst": 183, + "txval": 12200, "rev": "N", "itcavl": "Y", "pos": "23", @@ -888,7 +918,14 @@ "inv": [ { "dt": "01-01-2023", + "oinum": "S008400", + "oidt": "24-11-2016", "val": 343242, + "sgst": 0, + "cgst": 0, + "cess": 0, + "igst": 183, + "txval": 12200, "rev": "N", "itcavl": "Y", "pos": "23", @@ -910,6 +947,11 @@ { "dt": "01-05-2023", "val": 234324234, + "sgst": 0, + "cgst": 0, + "cess": 0, + "igst": 183, + "txval": 12200, "rev": "N", "itcavl": "Y", "pos": "23", diff --git a/india_compliance/gst_india/utils/gstr_2/test_gstr_2b.py b/india_compliance/gst_india/utils/gstr_2/test_gstr_2b.py index fead11d7c..6d2f69720 100644 --- a/india_compliance/gst_india/utils/gstr_2/test_gstr_2b.py +++ b/india_compliance/gst_india/utils/gstr_2/test_gstr_2b.py @@ -58,6 +58,15 @@ def test_gstr2b_b2b(self): ), "irn_gen_date": date(2019, 12, 24), "doc_type": "Invoice", + "items": [ + { + "taxable_value": 12200, + "igst": 183, + "cgst": 0, + "sgst": 0, + "cess": 0, + } + ], }, doc, ) @@ -87,6 +96,15 @@ def test_gstr2b_b2ba(self): "original_bill_no": "S008400", "original_bill_date": date(2016, 11, 24), "doc_type": "Invoice", + "items": [ + { + "taxable_value": 12200, + "igst": 183, + "cgst": 0, + "sgst": 0, + "cess": 0, + } + ], }, doc, ) @@ -116,6 +134,15 @@ def test_gstr2b_cdnr(self): ), "irn_gen_date": date(2019, 12, 24), "doc_type": "Credit Note", + "items": [ + { + "taxable_value": 12200, + "igst": 183, + "cgst": 0, + "sgst": 0, + "cess": 0, + } + ], }, doc, ) @@ -143,6 +170,15 @@ def test_gstr2b_cdnra(self): "reason_itc_unavailability": "Return filed post annual cut-off", "diffprcnt": "1", "doc_type": "Credit Note", + "items": [ + { + "taxable_value": 12200, + "igst": 183, + "cgst": 0, + "sgst": 0, + "cess": 0, + } + ], }, doc, )