From 11e78adaab63086819156a8b9bd2a35634b5e854 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Wed, 14 Dec 2016 12:32:41 -0600 Subject: [PATCH] Add "print receiving worksheet" feature, for 'ordered' purchases --- tailbone/helpers.py | 2 + .../purchases/batches/receive_form.mako | 2 +- tailbone/templates/purchases/index.mako | 2 +- .../purchases/receiving_worksheet.mako | 93 +++++++++++++++++++ tailbone/templates/purchases/view.mako | 7 ++ tailbone/views/purchases/core.py | 24 +++++ 6 files changed, 128 insertions(+), 2 deletions(-) create mode 100644 tailbone/templates/purchases/receiving_worksheet.mako diff --git a/tailbone/helpers.py b/tailbone/helpers.py index 0c85c522..c6ffa51b 100644 --- a/tailbone/helpers.py +++ b/tailbone/helpers.py @@ -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 * diff --git a/tailbone/templates/purchases/batches/receive_form.mako b/tailbone/templates/purchases/batches/receive_form.mako index 7bb6a60f..63d953a2 100644 --- a/tailbone/templates/purchases/batches/receive_form.mako +++ b/tailbone/templates/purchases/batches/receive_form.mako @@ -331,7 +331,7 @@ ${h.hidden('ordered_product')}
- +
${h.hidden('product')}
${h.text('upc', autocomplete='off')}
diff --git a/tailbone/templates/purchases/index.mako b/tailbone/templates/purchases/index.mako index d9d44c2b..e953e23d 100644 --- a/tailbone/templates/purchases/index.mako +++ b/tailbone/templates/purchases/index.mako @@ -4,7 +4,7 @@ <%def name="context_menu_items()"> ${parent.context_menu_items()} % if request.has_perm('purchases.batch.list'): -
  • ${h.link_to("Go to Purchase Batches", url('purchases.batch'))}
  • +
  • ${h.link_to("Go to Purchasing Batches", url('purchases.batch'))}
  • % endif diff --git a/tailbone/templates/purchases/receiving_worksheet.mako b/tailbone/templates/purchases/receiving_worksheet.mako new file mode 100644 index 00000000..31be83f9 --- /dev/null +++ b/tailbone/templates/purchases/receiving_worksheet.mako @@ -0,0 +1,93 @@ +## -*- coding: utf-8 -*- + + + Receiving Worksheet + + + + +

    Receiving Worksheet

    + +

    Notes:

    + +

    + Vendor:  (${purchase.vendor.id}) ${purchase.vendor} + + Phone:  ${purchase.vendor.phone} +

    +

    + Contact:  ${purchase.vendor.contact} + + Fax:  ${purchase.vendor.fax_number} +

    +

    + Store ID:  ${purchase.store.id} + + Buyer:  ${purchase.buyer} + + Order Date:  ${purchase.date_ordered} +

    +

    + Received by (name):  ____________________ + + Received on (date):  ____________________ +

    + + + + + + + + + + + + + + + + % for item in purchase.items: + + + + + + + + + + + % endfor + +
    UPCVend CodeBrandDescriptionCasesUnitsUnit CostTotal Cost
    ${item.upc.pretty()}${item.vendor_code or ''}${(item.brand_name or '')[:15]}${item.description or ''}${h.pretty_quantity(item.cases_ordered or 0)}${h.pretty_quantity(item.units_ordered or 0)}${'${:0,.2f}'.format(item.po_unit_cost) if item.po_unit_cost is not None else ''}${'${:0,.2f}'.format(item.po_total) if item.po_total is not None else ''}
    + + + diff --git a/tailbone/templates/purchases/view.mako b/tailbone/templates/purchases/view.mako index 9a985470..74871427 100644 --- a/tailbone/templates/purchases/view.mako +++ b/tailbone/templates/purchases/view.mako @@ -6,4 +6,11 @@ ${h.stylesheet_link(request.static_url('tailbone:static/css/purchases.css'))} +<%def name="context_menu_items()"> + ${parent.context_menu_items()} + % if instance.status < enum.PURCHASE_STATUS_RECEIVED and request.has_perm('purchases.receiving_worksheet'): +
  • ${h.link_to("Print Receiving Worksheet", url('purchases.receiving_worksheet', uuid=instance.uuid), target='_blank')}
  • + % endif + + ${parent.body()} diff --git a/tailbone/views/purchases/core.py b/tailbone/views/purchases/core.py index bf431724..ca942846 100644 --- a/tailbone/views/purchases/core.py +++ b/tailbone/views/purchases/core.py @@ -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)