fix: GST Itemised Sales Register GSTIN filter (#32367)
fix: GST Itemised Sales Register GSTIN filte
This commit is contained in:
@@ -19,14 +19,19 @@ def execute(filters=None):
|
||||
return _execute(filters)
|
||||
|
||||
|
||||
def _execute(filters=None, additional_table_columns=None, additional_query_columns=None):
|
||||
def _execute(
|
||||
filters=None,
|
||||
additional_table_columns=None,
|
||||
additional_query_columns=None,
|
||||
additional_conditions=None,
|
||||
):
|
||||
if not filters:
|
||||
filters = {}
|
||||
columns = get_columns(additional_table_columns, filters)
|
||||
|
||||
company_currency = frappe.get_cached_value("Company", filters.get("company"), "default_currency")
|
||||
|
||||
item_list = get_items(filters, additional_query_columns)
|
||||
item_list = get_items(filters, additional_query_columns, additional_conditions)
|
||||
if item_list:
|
||||
itemised_tax, tax_columns = get_tax_accounts(item_list, columns, company_currency)
|
||||
|
||||
@@ -328,7 +333,7 @@ def get_columns(additional_table_columns, filters):
|
||||
return columns
|
||||
|
||||
|
||||
def get_conditions(filters):
|
||||
def get_conditions(filters, additional_conditions=None):
|
||||
conditions = ""
|
||||
|
||||
for opts in (
|
||||
@@ -341,6 +346,9 @@ def get_conditions(filters):
|
||||
if filters.get(opts[0]):
|
||||
conditions += opts[1]
|
||||
|
||||
if additional_conditions:
|
||||
conditions += additional_conditions
|
||||
|
||||
if filters.get("mode_of_payment"):
|
||||
conditions += """ and exists(select name from `tabSales Invoice Payment`
|
||||
where parent=`tabSales Invoice`.name
|
||||
@@ -376,8 +384,8 @@ def get_group_by_conditions(filters, doctype):
|
||||
return "ORDER BY `tab{0}`.{1}".format(doctype, frappe.scrub(filters.get("group_by")))
|
||||
|
||||
|
||||
def get_items(filters, additional_query_columns):
|
||||
conditions = get_conditions(filters)
|
||||
def get_items(filters, additional_query_columns, additional_conditions=None):
|
||||
conditions = get_conditions(filters, additional_conditions)
|
||||
|
||||
if additional_query_columns:
|
||||
additional_query_columns = ", " + ", ".join(additional_query_columns)
|
||||
|
||||
@@ -15,12 +15,6 @@ filters = filters.concat({
|
||||
"placeholder":"Company GSTIN",
|
||||
"options": [""],
|
||||
"width": "80"
|
||||
}, {
|
||||
"fieldname":"invoice_type",
|
||||
"label": __("Invoice Type"),
|
||||
"fieldtype": "Select",
|
||||
"placeholder":"Invoice Type",
|
||||
"options": ["", "Regular", "SEZ", "Export", "Deemed Export"]
|
||||
});
|
||||
|
||||
// Handle company on change
|
||||
|
||||
@@ -5,31 +5,48 @@
|
||||
from erpnext.accounts.report.item_wise_sales_register.item_wise_sales_register import _execute
|
||||
|
||||
|
||||
def get_conditions(filters, additional_query_columns):
|
||||
conditions = ""
|
||||
|
||||
for opts in additional_query_columns:
|
||||
if filters.get(opts):
|
||||
conditions += f" and {opts}=%({opts})s"
|
||||
|
||||
return conditions
|
||||
|
||||
|
||||
def execute(filters=None):
|
||||
additional_table_columns = [
|
||||
dict(fieldtype="Data", label="Customer GSTIN", fieldname="customer_gstin", width=120),
|
||||
dict(
|
||||
fieldtype="Data", label="Billing Address GSTIN", fieldname="billing_address_gstin", width=140
|
||||
),
|
||||
dict(fieldtype="Data", label="Company GSTIN", fieldname="company_gstin", width=120),
|
||||
dict(fieldtype="Data", label="Place of Supply", fieldname="place_of_supply", width=120),
|
||||
dict(fieldtype="Data", label="Reverse Charge", fieldname="reverse_charge", width=120),
|
||||
dict(fieldtype="Data", label="GST Category", fieldname="gst_category", width=120),
|
||||
dict(fieldtype="Data", label="Export Type", fieldname="export_type", width=120),
|
||||
dict(fieldtype="Data", label="E-Commerce GSTIN", fieldname="ecommerce_gstin", width=130),
|
||||
dict(fieldtype="Data", label="HSN Code", fieldname="gst_hsn_code", width=120),
|
||||
]
|
||||
|
||||
additional_query_columns = [
|
||||
"customer_gstin",
|
||||
"billing_address_gstin",
|
||||
"company_gstin",
|
||||
"place_of_supply",
|
||||
"reverse_charge",
|
||||
"gst_category",
|
||||
"export_type",
|
||||
"ecommerce_gstin",
|
||||
"gst_hsn_code",
|
||||
]
|
||||
|
||||
additional_conditions = get_conditions(filters, additional_query_columns)
|
||||
|
||||
return _execute(
|
||||
filters,
|
||||
additional_table_columns=[
|
||||
dict(fieldtype="Data", label="Customer GSTIN", fieldname="customer_gstin", width=120),
|
||||
dict(
|
||||
fieldtype="Data", label="Billing Address GSTIN", fieldname="billing_address_gstin", width=140
|
||||
),
|
||||
dict(fieldtype="Data", label="Company GSTIN", fieldname="company_gstin", width=120),
|
||||
dict(fieldtype="Data", label="Place of Supply", fieldname="place_of_supply", width=120),
|
||||
dict(fieldtype="Data", label="Reverse Charge", fieldname="reverse_charge", width=120),
|
||||
dict(fieldtype="Data", label="GST Category", fieldname="gst_category", width=120),
|
||||
dict(fieldtype="Data", label="Export Type", fieldname="export_type", width=120),
|
||||
dict(fieldtype="Data", label="E-Commerce GSTIN", fieldname="ecommerce_gstin", width=130),
|
||||
dict(fieldtype="Data", label="HSN Code", fieldname="gst_hsn_code", width=120),
|
||||
],
|
||||
additional_query_columns=[
|
||||
"customer_gstin",
|
||||
"billing_address_gstin",
|
||||
"company_gstin",
|
||||
"place_of_supply",
|
||||
"reverse_charge",
|
||||
"gst_category",
|
||||
"export_type",
|
||||
"ecommerce_gstin",
|
||||
"gst_hsn_code",
|
||||
],
|
||||
additional_table_columns=additional_table_columns,
|
||||
additional_query_columns=additional_query_columns,
|
||||
additional_conditions=additional_conditions,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user