Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Paging and Discount filter #27332

Merged
merged 3 commits into from Sep 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions erpnext/e_commerce/api.py
Expand Up @@ -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", {})
Expand Down
2 changes: 1 addition & 1 deletion erpnext/e_commerce/product_data_engine/query.py
Expand Up @@ -287,7 +287,7 @@ def combine_web_item_group_results(self, item_group, result, website_item_groups
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
Expand Down
Expand Up @@ -265,10 +265,9 @@ def test_product_list_with_discount_filters(self):
)
items = result.get("items")

# check if only product with 10% and below discount are fetched in the right order
self.assertEqual(len(items), 2)
self.assertEqual(items[0].get("item_code"), "Test 13I Laptop")
self.assertEqual(items[1].get("item_code"), "Test 12I Laptop")
# check if only product with 10% and below discount are fetched
self.assertEqual(len(items), 1)
self.assertEqual(items[0].get("item_code"), "Test 12I Laptop")

def test_product_list_with_api(self):
"Test products listing using API."
Expand Down
4 changes: 2 additions & 2 deletions erpnext/regional/report/gstr_1/gstr_1.py
Expand Up @@ -50,7 +50,7 @@ def run(self):
self.get_invoice_items()
self.get_items_based_on_tax_rate()
self.invoice_fields = [d["fieldname"] for d in self.invoice_columns]

self.get_data()

return self.columns, self.data
Expand Down Expand Up @@ -709,7 +709,7 @@ def get_columns(self):
"width": 100
}
]

self.columns = self.invoice_columns + self.tax_columns + self.other_columns

@frappe.whitelist()
Expand Down