From d99b4e29b95db9c3ae9a2852a9757977e4912096 Mon Sep 17 00:00:00 2001 From: Govind S Menokee Date: Wed, 2 Mar 2022 22:29:19 +0530 Subject: [PATCH 1/4] fix: HSN-wise-summary of outward supplies Updated Report Report changes done in order to meet the specification as per govt guideline - [GUIDELINE](https://taxguru.in/goods-and-service-tax/12-points-note-filing-gstr-1-01st-2021-onwards.html) (cherry picked from commit 363752510ead7d3b86693d3659b2157753f2762d) # Conflicts: # erpnext/regional/report/hsn_wise_summary_of_outward_supplies/hsn_wise_summary_of_outward_supplies.py --- .../hsn_wise_summary_of_outward_supplies.py | 81 ++++++++++++++++--- 1 file changed, 72 insertions(+), 9 deletions(-) diff --git a/erpnext/regional/report/hsn_wise_summary_of_outward_supplies/hsn_wise_summary_of_outward_supplies.py b/erpnext/regional/report/hsn_wise_summary_of_outward_supplies/hsn_wise_summary_of_outward_supplies.py index 09f2df1226..bc1e479c46 100644 --- a/erpnext/regional/report/hsn_wise_summary_of_outward_supplies/hsn_wise_summary_of_outward_supplies.py +++ b/erpnext/regional/report/hsn_wise_summary_of_outward_supplies/hsn_wise_summary_of_outward_supplies.py @@ -32,7 +32,7 @@ def _execute(filters=None): added_item = [] for d in item_list: if (d.parent, d.item_code) not in added_item: - row = [d.gst_hsn_code, d.description, d.stock_uom, d.stock_qty] + row = [d.gst_hsn_code, d.description, d.stock_uom, d.stock_qty, d.tax_rate] total_tax = 0 for tax in tax_columns: item_tax = itemised_tax.get((d.parent, d.item_code), {}).get(tax, {}) @@ -40,11 +40,9 @@ def _execute(filters=None): row += [d.base_net_amount + total_tax] row += [d.base_net_amount] - for tax in tax_columns: item_tax = itemised_tax.get((d.parent, d.item_code), {}).get(tax, {}) row += [item_tax.get("tax_amount", 0)] - data.append(row) added_item.append((d.parent, d.item_code)) if data: @@ -59,7 +57,41 @@ def get_columns(): "label": _("HSN/SAC"), "fieldtype": "Link", "options": "GST HSN Code", +<<<<<<< HEAD "width": 100, +======= + "width": 100 + }, + { + "fieldname": "description", + "label": _("Description"), + "fieldtype": "Data", + "width": 300 + }, + { + "fieldname": "stock_uom", + "label": _("Stock UOM"), + "fieldtype": "Data", + "width": 100 + }, + { + "fieldname": "stock_qty", + "label": _("Stock Qty"), + "fieldtype": "Float", + "width": 90 + }, + { + "fieldname": "tax_rate", + "label": _("Tax Rate"), + "fieldtype": "Data", + "width": 90 + }, + { + "fieldname": "total_amount", + "label": _("Total Amount"), + "fieldtype": "Currency", + "width": 120 +>>>>>>> 363752510e (fix: HSN-wise-summary of outward supplies Updated Report) }, {"fieldname": "description", "label": _("Description"), "fieldtype": "Data", "width": 300}, {"fieldname": "stock_uom", "label": _("Stock UOM"), "fieldtype": "Data", "width": 100}, @@ -106,14 +138,24 @@ def get_items(filters): sum(`tabSales Invoice Item`.stock_qty) as stock_qty, sum(`tabSales Invoice Item`.base_net_amount) as base_net_amount, sum(`tabSales Invoice Item`.base_price_list_rate) as base_price_list_rate, - `tabSales Invoice Item`.parent, `tabSales Invoice Item`.item_code, - `tabGST HSN Code`.description - from `tabSales Invoice`, `tabSales Invoice Item`, `tabGST HSN Code` - where `tabSales Invoice`.name = `tabSales Invoice Item`.parent + `tabSales Invoice Item`.parent, + `tabSales Invoice Item`.item_code, + `tabGST HSN Code`.description, + json_extract(`tabSales Taxes and Charges`.item_wise_tax_detail, + concat('$."' , `tabSales Invoice Item`.item_code, '"[0]')) * count(distinct `tabSales Taxes and Charges`.name) as tax_rate + from + `tabSales Invoice`, + `tabSales Invoice Item`, + `tabGST HSN Code`, + `tabSales Taxes and Charges` + where + `tabSales Invoice`.name = `tabSales Invoice Item`.parent + and `tabSales Taxes and Charges`.parent = `tabSales Invoice`.name and `tabSales Invoice`.docstatus = 1 and `tabSales Invoice Item`.gst_hsn_code is not NULL and `tabSales Invoice Item`.gst_hsn_code = `tabGST HSN Code`.name %s %s group by +<<<<<<< HEAD `tabSales Invoice Item`.parent, `tabSales Invoice Item`.item_code """ @@ -121,6 +163,11 @@ def get_items(filters): filters, as_dict=1, ) +======= + `tabSales Invoice Item`.parent, + `tabSales Invoice Item`.item_code + """ % (conditions, match_conditions), filters, as_dict=1) +>>>>>>> 363752510e (fix: HSN-wise-summary of outward supplies Updated Report) return items @@ -213,8 +260,10 @@ def get_merged_data(columns, data): result = [] for row in data: - merged_hsn_dict.setdefault(row[0], {}) + key = row[0] + '-' + str(row[4]) + merged_hsn_dict.setdefault(key, {}) for i, d in enumerate(columns): +<<<<<<< HEAD if d["fieldtype"] not in ("Int", "Float", "Currency"): merged_hsn_dict[row[0]][d["fieldname"]] = row[i] else: @@ -222,6 +271,15 @@ def get_merged_data(columns, data): merged_hsn_dict[row[0]][d["fieldname"]] += row[i] else: merged_hsn_dict[row[0]][d["fieldname"]] = row[i] +======= + if d['fieldtype'] not in ('Int', 'Float', 'Currency'): + merged_hsn_dict[key][d['fieldname']] = row[i] + else: + if merged_hsn_dict.get(key, {}).get(d['fieldname'], ''): + merged_hsn_dict[key][d['fieldname']] += row[i] + else: + merged_hsn_dict[key][d['fieldname']] = row[i] +>>>>>>> 363752510e (fix: HSN-wise-summary of outward supplies Updated Report) for key, value in merged_hsn_dict.items(): result.append(value) @@ -240,9 +298,14 @@ def get_json(filters, report_name, data): fp = "%02d%s" % (getdate(filters["to_date"]).month, getdate(filters["to_date"]).year) +<<<<<<< HEAD gst_json = {"version": "GST2.3.4", "hash": "hash", "gstin": gstin, "fp": fp} gst_json["hsn"] = {"data": get_hsn_wise_json_data(filters, report_data)} +======= + gst_json = {"version": "GST3.0.3", + "hash": "hash", "gstin": gstin, "fp": fp} +>>>>>>> 363752510e (fix: HSN-wise-summary of outward supplies Updated Report) return {"report_name": report_name, "data": gst_json} @@ -271,7 +334,7 @@ def get_hsn_wise_json_data(filters, report_data): "desc": hsn.get("description"), "uqc": hsn.get("stock_uom").upper(), "qty": hsn.get("stock_qty"), - "val": flt(hsn.get("total_amount"), 2), + "rt": flt(hsn.get("tax_rate"), 2), "txval": flt(hsn.get("taxable_amount", 2)), "iamt": 0.0, "camt": 0.0, From 3ae4b9033fc14c6fa10bc32297760fcc351cde1e Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Sat, 7 May 2022 22:44:53 +0530 Subject: [PATCH 2/4] chore: Remove extra columns (cherry picked from commit b0e929b8ae8780ada76ea6b699a2b4d840b31487) # Conflicts: # erpnext/regional/report/hsn_wise_summary_of_outward_supplies/hsn_wise_summary_of_outward_supplies.py --- .../hsn_wise_summary_of_outward_supplies.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/erpnext/regional/report/hsn_wise_summary_of_outward_supplies/hsn_wise_summary_of_outward_supplies.py b/erpnext/regional/report/hsn_wise_summary_of_outward_supplies/hsn_wise_summary_of_outward_supplies.py index bc1e479c46..057474782d 100644 --- a/erpnext/regional/report/hsn_wise_summary_of_outward_supplies/hsn_wise_summary_of_outward_supplies.py +++ b/erpnext/regional/report/hsn_wise_summary_of_outward_supplies/hsn_wise_summary_of_outward_supplies.py @@ -96,6 +96,10 @@ def get_columns(): {"fieldname": "description", "label": _("Description"), "fieldtype": "Data", "width": 300}, {"fieldname": "stock_uom", "label": _("Stock UOM"), "fieldtype": "Data", "width": 100}, {"fieldname": "stock_qty", "label": _("Stock Qty"), "fieldtype": "Float", "width": 90}, +<<<<<<< HEAD +======= + {"fieldname": "tax_rate", "label": _("Tax Rate"), "fieldtype": "Data", "width": 90}, +>>>>>>> b0e929b8ae (chore: Remove extra columns) {"fieldname": "total_amount", "label": _("Total Amount"), "fieldtype": "Currency", "width": 120}, { "fieldname": "taxable_amount", @@ -256,6 +260,7 @@ def get_tax_accounts( def get_merged_data(columns, data): + print(data) merged_hsn_dict = {} # to group same hsn under one key and perform row addition result = [] From 85c137b3aa55750005901799a005a0f69d9dc27a Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Sat, 7 May 2022 22:53:59 +0530 Subject: [PATCH 3/4] chore: Remove print statement (cherry picked from commit a8fbd2451b498ad49356cf0e6a710616ab802465) --- .../hsn_wise_summary_of_outward_supplies.py | 1 - 1 file changed, 1 deletion(-) diff --git a/erpnext/regional/report/hsn_wise_summary_of_outward_supplies/hsn_wise_summary_of_outward_supplies.py b/erpnext/regional/report/hsn_wise_summary_of_outward_supplies/hsn_wise_summary_of_outward_supplies.py index 057474782d..7323def2a4 100644 --- a/erpnext/regional/report/hsn_wise_summary_of_outward_supplies/hsn_wise_summary_of_outward_supplies.py +++ b/erpnext/regional/report/hsn_wise_summary_of_outward_supplies/hsn_wise_summary_of_outward_supplies.py @@ -260,7 +260,6 @@ def get_tax_accounts( def get_merged_data(columns, data): - print(data) merged_hsn_dict = {} # to group same hsn under one key and perform row addition result = [] From c9f6405b2a30fd4eefd0fa90f1101f1247cdf584 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Mon, 9 May 2022 10:33:03 +0530 Subject: [PATCH 4/4] chore: Resolve conflicts --- .../hsn_wise_summary_of_outward_supplies.py | 74 ++----------------- 1 file changed, 8 insertions(+), 66 deletions(-) diff --git a/erpnext/regional/report/hsn_wise_summary_of_outward_supplies/hsn_wise_summary_of_outward_supplies.py b/erpnext/regional/report/hsn_wise_summary_of_outward_supplies/hsn_wise_summary_of_outward_supplies.py index 7323def2a4..3f42668862 100644 --- a/erpnext/regional/report/hsn_wise_summary_of_outward_supplies/hsn_wise_summary_of_outward_supplies.py +++ b/erpnext/regional/report/hsn_wise_summary_of_outward_supplies/hsn_wise_summary_of_outward_supplies.py @@ -57,49 +57,12 @@ def get_columns(): "label": _("HSN/SAC"), "fieldtype": "Link", "options": "GST HSN Code", -<<<<<<< HEAD "width": 100, -======= - "width": 100 - }, - { - "fieldname": "description", - "label": _("Description"), - "fieldtype": "Data", - "width": 300 - }, - { - "fieldname": "stock_uom", - "label": _("Stock UOM"), - "fieldtype": "Data", - "width": 100 - }, - { - "fieldname": "stock_qty", - "label": _("Stock Qty"), - "fieldtype": "Float", - "width": 90 - }, - { - "fieldname": "tax_rate", - "label": _("Tax Rate"), - "fieldtype": "Data", - "width": 90 - }, - { - "fieldname": "total_amount", - "label": _("Total Amount"), - "fieldtype": "Currency", - "width": 120 ->>>>>>> 363752510e (fix: HSN-wise-summary of outward supplies Updated Report) }, {"fieldname": "description", "label": _("Description"), "fieldtype": "Data", "width": 300}, {"fieldname": "stock_uom", "label": _("Stock UOM"), "fieldtype": "Data", "width": 100}, {"fieldname": "stock_qty", "label": _("Stock Qty"), "fieldtype": "Float", "width": 90}, -<<<<<<< HEAD -======= {"fieldname": "tax_rate", "label": _("Tax Rate"), "fieldtype": "Data", "width": 90}, ->>>>>>> b0e929b8ae (chore: Remove extra columns) {"fieldname": "total_amount", "label": _("Total Amount"), "fieldtype": "Currency", "width": 120}, { "fieldname": "taxable_amount", @@ -159,19 +122,13 @@ def get_items(filters): and `tabSales Invoice Item`.gst_hsn_code is not NULL and `tabSales Invoice Item`.gst_hsn_code = `tabGST HSN Code`.name %s %s group by -<<<<<<< HEAD - `tabSales Invoice Item`.parent, `tabSales Invoice Item`.item_code - + `tabSales Invoice Item`.parent, + `tabSales Invoice Item`.item_code """ % (conditions, match_conditions), filters, as_dict=1, ) -======= - `tabSales Invoice Item`.parent, - `tabSales Invoice Item`.item_code - """ % (conditions, match_conditions), filters, as_dict=1) ->>>>>>> 363752510e (fix: HSN-wise-summary of outward supplies Updated Report) return items @@ -264,26 +221,16 @@ def get_merged_data(columns, data): result = [] for row in data: - key = row[0] + '-' + str(row[4]) + key = row[0] + "-" + str(row[4]) merged_hsn_dict.setdefault(key, {}) for i, d in enumerate(columns): -<<<<<<< HEAD if d["fieldtype"] not in ("Int", "Float", "Currency"): - merged_hsn_dict[row[0]][d["fieldname"]] = row[i] + merged_hsn_dict[key][d["fieldname"]] = row[i] else: - if merged_hsn_dict.get(row[0], {}).get(d["fieldname"], ""): - merged_hsn_dict[row[0]][d["fieldname"]] += row[i] + if merged_hsn_dict.get(key, {}).get(d["fieldname"], ""): + merged_hsn_dict[key][d["fieldname"]] += row[i] else: - merged_hsn_dict[row[0]][d["fieldname"]] = row[i] -======= - if d['fieldtype'] not in ('Int', 'Float', 'Currency'): - merged_hsn_dict[key][d['fieldname']] = row[i] - else: - if merged_hsn_dict.get(key, {}).get(d['fieldname'], ''): - merged_hsn_dict[key][d['fieldname']] += row[i] - else: - merged_hsn_dict[key][d['fieldname']] = row[i] ->>>>>>> 363752510e (fix: HSN-wise-summary of outward supplies Updated Report) + merged_hsn_dict[key][d["fieldname"]] = row[i] for key, value in merged_hsn_dict.items(): result.append(value) @@ -302,14 +249,9 @@ def get_json(filters, report_name, data): fp = "%02d%s" % (getdate(filters["to_date"]).month, getdate(filters["to_date"]).year) -<<<<<<< HEAD - gst_json = {"version": "GST2.3.4", "hash": "hash", "gstin": gstin, "fp": fp} + gst_json = {"version": "GST3.0.3", "hash": "hash", "gstin": gstin, "fp": fp} gst_json["hsn"] = {"data": get_hsn_wise_json_data(filters, report_data)} -======= - gst_json = {"version": "GST3.0.3", - "hash": "hash", "gstin": gstin, "fp": fp} ->>>>>>> 363752510e (fix: HSN-wise-summary of outward supplies Updated Report) return {"report_name": report_name, "data": gst_json}