Improve display of purchase credit data

esp. within a receiving batch row
This commit is contained in:
Lance Edgar 2019-03-07 12:21:50 -06:00
parent 4a9b528c47
commit 3760c3239f
2 changed files with 76 additions and 7 deletions

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2018 Lance Edgar # Copyright © 2010-2019 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -47,6 +47,11 @@ class PurchaseCreditView(MasterView):
editable = False editable = False
checkboxes = True checkboxes = True
labels = {
'upc': "UPC",
'mispick_upc': "Mispick UPC",
}
grid_columns = [ grid_columns = [
'vendor', 'vendor',
'invoice_number', 'invoice_number',
@ -65,6 +70,35 @@ class PurchaseCreditView(MasterView):
'status', 'status',
] ]
form_fields = [
'store',
'vendor',
'invoice_number',
'invoice_date',
'date_ordered',
'date_shipped',
'date_received',
'department_number',
'department_name',
'vendor_item_code',
'upc',
'product',
'case_quantity',
'credit_type',
'cases_shorted',
'units_shorted',
'invoice_line_number',
'invoice_case_cost',
'invoice_unit_cost',
'invoice_total',
'credit_total',
'mispick_upc',
'mispick_product',
'product_discarded',
'expiration_date',
'status',
]
def configure_grid(self, g): def configure_grid(self, g):
super(PurchaseCreditView, self).configure_grid(g) super(PurchaseCreditView, self).configure_grid(g)
@ -86,15 +120,24 @@ class PurchaseCreditView(MasterView):
g.set_type('credit_total', 'currency') g.set_type('credit_total', 'currency')
g.set_label('invoice_number', "Invoice No.") g.set_label('invoice_number', "Invoice No.")
g.set_label('upc', "UPC")
g.set_label('vendor_item_code', "Item Code") g.set_label('vendor_item_code', "Item Code")
g.set_label('brand_name', "Brand") g.set_label('brand_name', "Brand")
g.set_label('cases_shorted', "Cases") g.set_label('cases_shorted', "Cases")
g.set_label('units_shorted', "Units") g.set_label('units_shorted', "Units")
g.set_label('credit_type', "Type") g.set_label('credit_type', "Type")
g.set_label('mispick_upc', "Mispick UPC")
g.set_label('date_received', "Date") g.set_label('date_received', "Date")
g.set_link('upc')
g.set_link('vendor_item_code')
g.set_link('brand_name')
g.set_link('description')
def configure_form(self, f):
super(PurchaseCreditView, self).configure_form(f)
# status
f.set_enum('status', self.enum.PURCHASE_CREDIT_STATUS)
def change_status(self): def change_status(self):
if self.request.method != 'POST': if self.request.method != 'POST':
self.request.session.flash("Sorry, you must POST to change credit status", 'error') self.request.session.flash("Sorry, you must POST to change credit status", 'error')

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2018 Lance Edgar # Copyright © 2010-2019 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -34,9 +34,9 @@ from rattail.time import localtime
import colander import colander
from deform import widget as dfwidget from deform import widget as dfwidget
from pyramid import httpexceptions from pyramid import httpexceptions
from webhelpers2.html import tags from webhelpers2.html import tags, HTML
from tailbone import forms from tailbone import forms, grids
from tailbone.views.batch import BatchMasterView from tailbone.views.batch import BatchMasterView
@ -646,7 +646,6 @@ class PurchasingBatchView(BatchMasterView):
# readonly fields # readonly fields
f.set_readonly('case_quantity') f.set_readonly('case_quantity')
f.set_readonly('credits')
# quantity fields # quantity fields
f.set_type('case_quantity', 'quantity') f.set_type('case_quantity', 'quantity')
@ -670,6 +669,10 @@ class PurchasingBatchView(BatchMasterView):
# upc # upc
f.set_type('upc', 'gpc') f.set_type('upc', 'gpc')
# credits
f.set_readonly('credits')
f.set_renderer('credits', self.render_row_credits)
if self.creating: if self.creating:
f.remove_fields( f.remove_fields(
'upc', 'upc',
@ -704,6 +707,29 @@ class PurchasingBatchView(BatchMasterView):
else: else:
f.remove_field('product') f.remove_field('product')
def render_row_credits(self, row, field):
if not row.credits:
return ""
route_prefix = self.get_route_prefix()
columns = [
'credit_type',
'cases_shorted',
'units_shorted',
'credit_total',
]
g = grids.Grid(
key='{}.row_credits'.format(route_prefix),
data=row.credits,
columns=columns,
labels={'credit_type': "Type",
'cases_shorted': "Cases",
'units_shorted': "Units"})
g.set_type('cases_shorted', 'quantity')
g.set_type('units_shorted', 'quantity')
g.set_type('credit_total', 'currency')
return HTML.literal(g.render_grid())
def configure_mobile_row_form(self, f): def configure_mobile_row_form(self, f):
super(PurchasingBatchView, self).configure_mobile_row_form(f) super(PurchasingBatchView, self).configure_mobile_row_form(f)
# row = f.model_instance # row = f.model_instance