From 4d26d5e07af8bdbeae6fcff3d479721c082e26b0 Mon Sep 17 00:00:00 2001 From: Ninad1306 Date: Wed, 7 Aug 2024 17:03:31 +0530 Subject: [PATCH] fix: ITC-04 beta report --- .../gst_india/report/itc_04_beta/__init__.py | 0 .../report/itc_04_beta/itc_04_beta.js | 35 ++++ .../report/itc_04_beta/itc_04_beta.json | 50 +++++ .../report/itc_04_beta/itc_04_beta.py | 175 ++++++++++++++++++ .../gst_india/utils/itc_04/itc_04_data.py | 4 +- 5 files changed, 262 insertions(+), 2 deletions(-) create mode 100644 india_compliance/gst_india/report/itc_04_beta/__init__.py create mode 100644 india_compliance/gst_india/report/itc_04_beta/itc_04_beta.js create mode 100644 india_compliance/gst_india/report/itc_04_beta/itc_04_beta.json create mode 100644 india_compliance/gst_india/report/itc_04_beta/itc_04_beta.py diff --git a/india_compliance/gst_india/report/itc_04_beta/__init__.py b/india_compliance/gst_india/report/itc_04_beta/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/india_compliance/gst_india/report/itc_04_beta/itc_04_beta.js b/india_compliance/gst_india/report/itc_04_beta/itc_04_beta.js new file mode 100644 index 000000000..af6c7b6cc --- /dev/null +++ b/india_compliance/gst_india/report/itc_04_beta/itc_04_beta.js @@ -0,0 +1,35 @@ +// Copyright (c) 2024, Resilient Tech and contributors +// For license information, please see license.txt + +frappe.query_reports["ITC-04 Beta"] = { + filters: [ + { + fieldname: "company", + label: "Company", + fieldtype: "Link", + options: "Company", + }, + { + fieldname: "company_gstin", + label: "Company GSTIN", + fieldtype: "Data", + }, + { + fieldname: "from_date", + label: "From Date", + fieldtype: "Date", + }, + { + fieldname: "to_date", + label: "To Date", + fieldtype: "Date", + }, + { + fieldname: "category", + label: "Invoice Category", + fieldtype: "Select", + options: ["", "Table 4", "Table 5A"], + reqd: 1 + }, + ], + }; diff --git a/india_compliance/gst_india/report/itc_04_beta/itc_04_beta.json b/india_compliance/gst_india/report/itc_04_beta/itc_04_beta.json new file mode 100644 index 000000000..e1a610f7a --- /dev/null +++ b/india_compliance/gst_india/report/itc_04_beta/itc_04_beta.json @@ -0,0 +1,50 @@ +{ + "add_total_row": 0, + "columns": [], + "creation": "2024-08-07 16:20:53.275110", + "disabled": 0, + "docstatus": 0, + "doctype": "Report", + "filters": [], + "idx": 0, + "is_standard": "Yes", + "letterhead": null, + "modified": "2024-08-07 16:20:53.275110", + "modified_by": "Administrator", + "module": "GST India", + "name": "ITC-04 Beta", + "owner": "Administrator", + "prepared_report": 0, + "ref_doctype": "Item", + "report_name": "ITC-04 Beta", + "report_type": "Script Report", + "roles": [ + { + "role": "Item Manager" + }, + { + "role": "Stock Manager" + }, + { + "role": "Stock User" + }, + { + "role": "Sales User" + }, + { + "role": "Purchase User" + }, + { + "role": "Maintenance User" + }, + { + "role": "Accounts User" + }, + { + "role": "Manufacturing User" + }, + { + "role": "Desk User" + } + ] +} \ No newline at end of file diff --git a/india_compliance/gst_india/report/itc_04_beta/itc_04_beta.py b/india_compliance/gst_india/report/itc_04_beta/itc_04_beta.py new file mode 100644 index 000000000..54233f12c --- /dev/null +++ b/india_compliance/gst_india/report/itc_04_beta/itc_04_beta.py @@ -0,0 +1,175 @@ +# Copyright (c) 2024, Resilient Tech and contributors +# For license information, please see license.txt +from india_compliance.gst_india.utils.itc_04.itc_04_data import ITC04Query + + +def execute(filters=None): + if not filters: + filters = {} + + _class = ITC04Query(filters) + data = [] + + if filters.category == "Table 4": + columns = get_columns_table_4() + data = _class.get_query_table_4_se().run(as_dict=True) + data.extend(_class.get_query_table_4_sr().run(as_dict=True)) + else: + columns = get_columns_table_5A() + data = _class.get_query_table_5A_se().run(as_dict=True) + data.extend(_class.get_query_table_5A_sr().run(as_dict=True)) + + return columns, data + + +def get_common_columns(): + return [ + { + "fieldname": "company_gstin", + "label": "Company GSTIN", + "fieldtype": "Data", + "width": 180, + }, + { + "fieldname": "posting_date", + "label": "Posting Date", + "fieldtype": "Date", + "width": 180, + }, + { + "fieldname": "invoice_no", + "label": "Invoice No (Challan No)", + "fieldtype": "Data", + "width": 180, + }, + { + "fieldname": "supplier", + "label": "Supplier", + "fieldtype": "Data", + "width": 180, + }, + { + "fieldname": "gst_category", + "label": "GST Category", + "fieldtype": "Data", + "width": 180, + }, + { + "fieldname": "supplier_gstin", + "label": "Supplier GSTIN", + "fieldtype": "Data", + "width": 180, + }, + { + "fieldname": "place_of_supply", + "label": "Destination of Supply", + "fieldtype": "Data", + "width": 180, + }, + { + "fieldname": "is_return", + "label": "Is Return", + "fieldtype": "Check", + "width": 180, + }, + { + "fieldname": "item_code", + "label": "Item Code", + "fieldtype": "Data", + "width": 180, + }, + { + "fieldname": "gst_hsn_code", + "label": "HSN Code", + "fieldtype": "Data", + "width": 180, + }, + { + "fieldname": "uom", + "label": "UOM", + "fieldtype": "Data", + "width": 180, + }, + { + "fieldname": "gst_treatment", + "label": "GST Treatment", + "fieldtype": "Data", + "width": 180, + }, + { + "fieldname": "qty", + "label": "Qty", + "fieldtype": "Float", + "width": 180, + }, + { + "fieldname": "item_type", + "label": "Item Type (Input/Capital Goods)", + "fieldtype": "Data", + "width": 180, + }, + ] + + +def get_columns_table_4(): + return get_common_columns() + [ + { + "fieldname": "taxable_value", + "label": "Taxable Value", + "fieldtype": "Currency", + "width": 180, + }, + { + "fieldname": "gst_rate", + "label": "GST Rate", + "fieldtype": "Percent", + "width": 180, + }, + { + "fieldname": "cgst_amount", + "label": "CGST Amount", + "fieldtype": "Currency", + "width": 180, + }, + { + "fieldname": "sgst_amount", + "label": "SGST Amount", + "fieldtype": "Currency", + "width": 180, + }, + { + "fieldname": "igst_amount", + "label": "IGST Amount", + "fieldtype": "Currency", + "width": 180, + }, + { + "fieldname": "total_cess_amount", + "label": "Total Cess Amount", + "fieldtype": "Currency", + "width": 180, + }, + { + "fieldname": "total_tax", + "label": "Total Tax", + "fieldtype": "Currency", + "width": 180, + }, + { + "fieldname": "total_amount", + "label": "Total Amount", + "fieldtype": "Currency", + "width": 180, + }, + ] + + +def get_columns_table_5A(): + return [ + { + "fieldname": "original_challan_no", + "label": "Original Challan No", + "fieldtype": "Data", + "width": 180, + }, + ] + get_common_columns() diff --git a/india_compliance/gst_india/utils/itc_04/itc_04_data.py b/india_compliance/gst_india/utils/itc_04/itc_04_data.py index d406c58a7..7115f7b65 100644 --- a/india_compliance/gst_india/utils/itc_04/itc_04_data.py +++ b/india_compliance/gst_india/utils/itc_04/itc_04_data.py @@ -88,7 +88,7 @@ def get_query_table_4_se(self): self.se.bill_to_gst_category.as_("gst_category"), ) .where(IfNull(self.se.bill_to_gstin, "") != self.se.bill_from_gstin) - .where(self.se.subcontracting != "") + .where(self.se.subcontracting_order != "") .where(self.se.purpose == "Send to Subcontractor") ) @@ -160,7 +160,7 @@ def get_query_table_5A_se(self): self.se.bill_from_gstin.as_("company_gstin"), ) .where(IfNull(self.se.bill_to_gstin, "") != self.se.bill_from_gstin) - .where(self.se.subcontracting != "") + .where(self.se.subcontracting_order != "") .where(self.se.purpose == "Material Transfer") )