Add "print receiving worksheet" feature, for 'ordered' purchases

This commit is contained in:
Lance Edgar 2016-12-14 12:32:41 -06:00
parent 86c667e1f1
commit 11e78adaab
6 changed files with 128 additions and 2 deletions

View file

@ -29,6 +29,8 @@ from __future__ import unicode_literals
import datetime
from decimal import Decimal
from rattail.util import pretty_quantity
from webhelpers.html import *
from webhelpers.html.tags import *

View file

@ -331,7 +331,7 @@
${h.hidden('ordered_product')}
<div class="field-wrapper">
<label for="upc">Product UPC</label>
<label for="upc">Receiving UPC</label>
<div class="field">
${h.hidden('product')}
<div>${h.text('upc', autocomplete='off')}</div>

View file

@ -4,7 +4,7 @@
<%def name="context_menu_items()">
${parent.context_menu_items()}
% if request.has_perm('purchases.batch.list'):
<li>${h.link_to("Go to Purchase Batches", url('purchases.batch'))}</li>
<li>${h.link_to("Go to Purchasing Batches", url('purchases.batch'))}</li>
% endif
</%def>

View file

@ -0,0 +1,93 @@
## -*- coding: utf-8 -*-
<html>
<head>
<title>Receiving Worksheet</title>
<style type="text/css">
.notes {
margin-bottom: 2em;
}
.spacer {
display: inline-block;
width: 1em;
}
.receiving-info {
padding-top: 1em;
}
table {
font-size: 0.8em;
white-space: nowrap;
}
th, td {
padding: 1em 0.4em 0 0;
}
th {
text-align: left;
}
.quantity {
text-align: center;
}
.currency {
text-align: right;
}
</style>
</head>
<body>
<h1>Receiving Worksheet</h1>
<p class="notes">Notes:</p>
<p class="info">
Vendor:&nbsp; <strong>(${purchase.vendor.id}) ${purchase.vendor}</strong>
<span class="spacer"></span>
Phone:&nbsp; <strong>${purchase.vendor.phone}</strong>
</p>
<p class="info">
Contact:&nbsp; <strong>${purchase.vendor.contact}</strong>
<span class="spacer"></span>
Fax:&nbsp; <strong>${purchase.vendor.fax_number}</strong>
</p>
<p class="info">
Store ID:&nbsp; <strong>${purchase.store.id}</strong>
<span class="spacer"></span>
Buyer:&nbsp; <strong>${purchase.buyer}</strong>
<span class="spacer"></span>
Order Date:&nbsp; <strong>${purchase.date_ordered}</strong>
</p>
<p class="receiving-info">
Received by (name):&nbsp; ____________________
<span class="spacer"></span>
Received on (date):&nbsp; ____________________
</p>
<table>
<thead>
<tr>
<th>UPC</th>
<th>Vend Code</th>
<th>Brand</th>
<th>Description</th>
<th>Cases</th>
<th>Units</th>
<th>Unit Cost</th>
<th>Total Cost</th>
</tr>
</thead>
<tbody>
% for item in purchase.items:
<tr>
<td>${item.upc.pretty()}</td>
<td>${item.vendor_code or ''}</td>
<td>${(item.brand_name or '')[:15]}</td>
<td>${item.description or ''}</td>
<td class="quantity">${h.pretty_quantity(item.cases_ordered or 0)}</td>
<td class="quantity">${h.pretty_quantity(item.units_ordered or 0)}</td>
<td class="currency">${'${:0,.2f}'.format(item.po_unit_cost) if item.po_unit_cost is not None else ''}</td>
<td class="currency">${'${:0,.2f}'.format(item.po_total) if item.po_total is not None else ''}</td>
</tr>
% endfor
</tbody>
</table>
</body>
</html>

View file

@ -6,4 +6,11 @@
${h.stylesheet_link(request.static_url('tailbone:static/css/purchases.css'))}
</%def>
<%def name="context_menu_items()">
${parent.context_menu_items()}
% if instance.status < enum.PURCHASE_STATUS_RECEIVED and request.has_perm('purchases.receiving_worksheet'):
<li>${h.link_to("Print Receiving Worksheet", url('purchases.receiving_worksheet', uuid=instance.uuid), target='_blank')}</li>
% endif
</%def>
${parent.body()}

View file

@ -258,6 +258,30 @@ class PurchaseView(MasterView):
fs.invoice_total,
])
def receiving_worksheet(self):
purchase = self.get_instance()
return self.render_to_response('receiving_worksheet', {
'purchase': purchase,
})
@classmethod
def defaults(cls, config):
route_prefix = cls.get_route_prefix()
url_prefix = cls.get_url_prefix()
permission_prefix = cls.get_permission_prefix()
model_key = cls.get_model_key()
model_title = cls.get_model_title()
cls._defaults(config)
# receiving worksheet
config.add_tailbone_permission(permission_prefix, '{}.receiving_worksheet'.format(permission_prefix),
"Print receiving worksheet for {}".format(model_title))
config.add_route('{}.receiving_worksheet'.format(route_prefix), '{}/{{{}}}/receiving-worksheet'.format(url_prefix, model_key))
config.add_view(cls, attr='receiving_worksheet', route_name='{}.receiving_worksheet'.format(route_prefix),
permission='{}.receiving_worksheet'.format(permission_prefix))
def includeme(config):
PurchaseView.defaults(config)