fix: Paging and Discount filter

- Convert incoming api args to frappe dict
- Change discount filter condition due to reversal of behaviour
This commit is contained in:
marination 2021-09-03 17:50:14 +05:30
parent 78b791cd1d
commit 942dedddb4
2 changed files with 2 additions and 1 deletions

View File

@ -27,6 +27,7 @@ def get_product_filter_data(query_args=None):
if isinstance(query_args, str):
query_args = json.loads(query_args)
query_args = frappe._dict(query_args)
if query_args:
search = query_args.get("search")
field_filters = query_args.get("field_filters", {})

View File

@ -289,7 +289,7 @@ class ProductQuery:
def filter_results_by_discount(self, fields, result):
if fields and fields.get("discount"):
discount_percent = frappe.utils.flt(fields["discount"][0])
result = [row for row in result if row.get("discount_percent") and row.discount_percent >= discount_percent]
result = [row for row in result if row.get("discount_percent") and row.discount_percent <= discount_percent]
if self.filter_with_discount:
# no limit was added to results while querying