mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-16 16:08:39 +00:00
feat: add status filter to Supplier Quotation Comparison report
This commit is contained in:
@@ -85,6 +85,17 @@ frappe.query_reports["Supplier Quotation Comparison"] = {
|
||||
],
|
||||
default: __("Categorize by Supplier"),
|
||||
},
|
||||
{
|
||||
fieldname: "status",
|
||||
label: __("Status"),
|
||||
fieldtype: "Select",
|
||||
options: [
|
||||
{ label: "", value: "" },
|
||||
{ label: __("Draft"), value: "Draft" },
|
||||
{ label: __("Submitted"), value: "Submitted" },
|
||||
],
|
||||
default: "Submitted",
|
||||
},
|
||||
{
|
||||
fieldtype: "Check",
|
||||
label: __("Include Expired"),
|
||||
|
||||
@@ -56,13 +56,20 @@ def get_data(filters):
|
||||
)
|
||||
.where(
|
||||
(sq_item.parent == sq.name)
|
||||
& (sq_item.docstatus < 2)
|
||||
& (sq.company == filters.get("company"))
|
||||
& (sq.transaction_date.between(filters.get("from_date"), filters.get("to_date")))
|
||||
)
|
||||
.orderby(sq.transaction_date, sq_item.item_code)
|
||||
)
|
||||
|
||||
# blank -> Draft + Submitted, else filter to the chosen docstatus
|
||||
if filters.get("status") == "Draft":
|
||||
query = query.where(sq_item.docstatus == 0)
|
||||
elif filters.get("status") == "Submitted":
|
||||
query = query.where(sq_item.docstatus == 1)
|
||||
else:
|
||||
query = query.where(sq_item.docstatus < 2)
|
||||
|
||||
if filters.get("item_code"):
|
||||
query = query.where(sq_item.item_code == filters.get("item_code"))
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ class TestSupplierQuotationComparison(ERPNextTestSuite):
|
||||
"""The report lists Supplier Quotation item lines so quotes for the same item can
|
||||
be compared across suppliers."""
|
||||
|
||||
def make_quotation(self, supplier, qty, rate, uom=None):
|
||||
def make_quotation(self, supplier, qty, rate, uom=None, submit=True):
|
||||
item = {"item_code": ITEM, "qty": qty, "rate": rate, "warehouse": "_Test Warehouse - _TC"}
|
||||
if uom:
|
||||
item["uom"] = uom
|
||||
@@ -29,7 +29,8 @@ class TestSupplierQuotationComparison(ERPNextTestSuite):
|
||||
}
|
||||
)
|
||||
sq.insert()
|
||||
sq.submit()
|
||||
if submit:
|
||||
sq.submit()
|
||||
return sq
|
||||
|
||||
def run_report(self, **extra):
|
||||
@@ -64,3 +65,21 @@ class TestSupplierQuotationComparison(ERPNextTestSuite):
|
||||
self.assertIn(sq2.name, quotes)
|
||||
self.assertEqual(quotes[sq1.name]["base_rate"], 100)
|
||||
self.assertEqual(quotes[sq2.name]["base_rate"], 120)
|
||||
|
||||
def test_status_filter(self):
|
||||
draft = self.make_quotation("_Test Supplier", qty=10, rate=100, submit=False)
|
||||
submitted = self.make_quotation("_Test Supplier 1", qty=10, rate=120)
|
||||
|
||||
def names(**extra):
|
||||
return {r["quotation"] for r in self.run_report(item_code=ITEM, **extra)}
|
||||
|
||||
# default (Submitted) hides drafts
|
||||
self.assertNotIn(draft.name, names(status="Submitted"))
|
||||
self.assertIn(submitted.name, names(status="Submitted"))
|
||||
# Draft shows only drafts
|
||||
self.assertIn(draft.name, names(status="Draft"))
|
||||
self.assertNotIn(submitted.name, names(status="Draft"))
|
||||
# blank shows both
|
||||
both = names(status="")
|
||||
self.assertIn(draft.name, both)
|
||||
self.assertIn(submitted.name, both)
|
||||
|
||||
Reference in New Issue
Block a user