Skip to content

Commit

Permalink
fix: port option for additional_conditions in item wise sales register
Browse files Browse the repository at this point in the history
  • Loading branch information
vorasmit committed May 6, 2023
1 parent 934e1b4 commit cb8bddb
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ 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)

Expand Down Expand Up @@ -328,7 +328,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 (
Expand All @@ -340,6 +340,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`
Expand Down Expand Up @@ -376,8 +379,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)
Expand Down

0 comments on commit cb8bddb

Please sign in to comment.