Added "preferred only" option to Ordering Worksheet.
This commit is contained in:
parent
80eb558783
commit
cd7f7ee444
|
@ -34,6 +34,10 @@ ${h.hidden('departments', value='')}
|
||||||
<div class="grid"></div>
|
<div class="grid"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="field-wrapper">
|
||||||
|
${h.checkbox('preferred_only', label="Include only those products for which this vendor is preferred.", checked=True)}
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="buttons">
|
<div class="buttons">
|
||||||
${h.submit('submit', "Generate Report")}
|
${h.submit('submit', "Generate Report")}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -34,7 +34,8 @@ def ordering_report(request):
|
||||||
dept = Session.query(rattail.Department).get(uuid)
|
dept = Session.query(rattail.Department).get(uuid)
|
||||||
if dept:
|
if dept:
|
||||||
departments.append(dept)
|
departments.append(dept)
|
||||||
body = write_ordering_worksheet(vendor, departments)
|
preferred_only = request.params.get('preferred_only') == '1'
|
||||||
|
body = write_ordering_worksheet(vendor, departments, preferred_only)
|
||||||
response = Response(content_type='text/html')
|
response = Response(content_type='text/html')
|
||||||
response.headers['Content-Length'] = len(body)
|
response.headers['Content-Length'] = len(body)
|
||||||
response.headers['Content-Disposition'] = 'attachment; filename=ordering.html'
|
response.headers['Content-Disposition'] = 'attachment; filename=ordering.html'
|
||||||
|
@ -43,7 +44,7 @@ def ordering_report(request):
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
|
||||||
def write_ordering_worksheet(vendor, departments):
|
def write_ordering_worksheet(vendor, departments, preferred_only):
|
||||||
"""
|
"""
|
||||||
Rendering engine for the ordering worksheet report.
|
Rendering engine for the ordering worksheet report.
|
||||||
"""
|
"""
|
||||||
|
@ -52,6 +53,8 @@ def write_ordering_worksheet(vendor, departments):
|
||||||
q = q.join(rattail.Product)
|
q = q.join(rattail.Product)
|
||||||
q = q.filter(rattail.ProductCost.vendor == vendor)
|
q = q.filter(rattail.ProductCost.vendor == vendor)
|
||||||
q = q.filter(rattail.Product.department_uuid.in_([x.uuid for x in departments]))
|
q = q.filter(rattail.Product.department_uuid.in_([x.uuid for x in departments]))
|
||||||
|
if preferred_only:
|
||||||
|
q = q.filter(rattail.ProductCost.preference == 1)
|
||||||
|
|
||||||
costs = {}
|
costs = {}
|
||||||
for cost in q:
|
for cost in q:
|
||||||
|
|
Loading…
Reference in a new issue