Expose views for tenders, more columns for POS batch/rows

This commit is contained in:
Lance Edgar 2023-09-27 17:13:49 -05:00
parent abcf1e1895
commit f572757f00
4 changed files with 120 additions and 10 deletions

View file

@ -625,15 +625,30 @@ class MenuHandler(GenericHandler):
""" """
items = [] items = []
if kwargs.get('include_stores', True): include_stores = kwargs.get('include_stores', True)
items.extend([ include_tenders = kwargs.get('include_tenders', True)
{
'title': "Stores", if include_stores or include_tenders:
'route': 'stores',
'perm': 'stores.list', if include_stores:
}, items.extend([
{'type': 'sep'}, {
]) 'title': "Stores",
'route': 'stores',
'perm': 'stores.list',
},
])
if include_tenders:
items.extend([
{
'title': "Tenders",
'route': 'tenders',
'perm': 'tenders.list',
},
])
items.append({'type': 'sep'})
items.extend([ items.extend([
{ {

View file

@ -68,6 +68,10 @@ class POSBatchView(BatchMasterView):
'sales_total', 'sales_total',
'tax1_total', 'tax1_total',
'tax2_total', 'tax2_total',
'tender_total',
'balance',
'void',
'training_mode',
'status_code', 'status_code',
'created', 'created',
'created_by', 'created_by',
@ -84,6 +88,7 @@ class POSBatchView(BatchMasterView):
'txn_price', 'txn_price',
'quantity', 'quantity',
'sales_total', 'sales_total',
'tender_total',
'status_code', 'status_code',
] ]
@ -99,7 +104,10 @@ class POSBatchView(BatchMasterView):
'sales_total', 'sales_total',
'tax1_total', 'tax1_total',
'tax2_total', 'tax2_total',
'tender_total',
'status_code', 'status_code',
'timestamp',
'user',
] ]
def configure_grid(self, g): def configure_grid(self, g):
@ -118,19 +126,33 @@ class POSBatchView(BatchMasterView):
g.set_type('sales_total', 'currency') g.set_type('sales_total', 'currency')
g.set_type('tax1_total', 'currency') g.set_type('tax1_total', 'currency')
g.set_type('tax2_total', 'currency') g.set_type('tax2_total', 'currency')
g.set_type('tender_total', 'currency')
# executed
# nb. default view should show "all recent" batches regardless
# of execution (i think..)
if 'executed' in g.filters:
g.filters['executed'].default_active = False
def grid_extra_class(self, batch, i): def grid_extra_class(self, batch, i):
if batch.void: if batch.void:
return 'warning' return 'warning'
if batch.training_mode:
return 'notice'
def configure_form(self, f): def configure_form(self, f):
super().configure_form(f) super().configure_form(f)
app = self.get_rattail_app()
f.set_renderer('customer', self.render_customer) f.set_renderer('customer', self.render_customer)
f.set_type('sales_total', 'currency') f.set_type('sales_total', 'currency')
f.set_type('tax1_total', 'currency') f.set_type('tax1_total', 'currency')
f.set_type('tax2_total', 'currency') f.set_type('tax2_total', 'currency')
f.set_type('tender_total', 'currency')
f.set_type('tender_total', 'currency')
f.set_renderer('balance', lambda batch, field: app.render_currency(batch.get_balance()))
def configure_row_grid(self, g): def configure_row_grid(self, g):
super().configure_row_grid(g) super().configure_row_grid(g)
@ -139,6 +161,7 @@ class POSBatchView(BatchMasterView):
g.set_type('reg_price', 'currency') g.set_type('reg_price', 'currency')
g.set_type('txn_price', 'currency') g.set_type('txn_price', 'currency')
g.set_type('sales_total', 'currency') g.set_type('sales_total', 'currency')
g.set_type('tender_total', 'currency')
g.set_link('product') g.set_link('product')
g.set_link('description') g.set_link('description')
@ -146,11 +169,15 @@ class POSBatchView(BatchMasterView):
def configure_row_form(self, f): def configure_row_form(self, f):
super().configure_row_form(f) super().configure_row_form(f)
f.set_renderer('product', self.render_product)
f.set_type('quantity', 'quantity') f.set_type('quantity', 'quantity')
f.set_type('reg_price', 'currency') f.set_type('reg_price', 'currency')
f.set_type('txn_price', 'currency') f.set_type('txn_price', 'currency')
f.set_type('sales_total', 'currency') f.set_type('sales_total', 'currency')
f.set_renderer('product', self.render_product) f.set_type('tender_total', 'currency')
f.set_renderer('user', self.render_user)
def defaults(config, **kwargs): def defaults(config, **kwargs):

67
tailbone/views/tenders.py Normal file
View file

@ -0,0 +1,67 @@
# -*- coding: utf-8; -*-
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2023 Lance Edgar
#
# This file is part of Rattail.
#
# Rattail is free software: you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# Rattail is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# Rattail. If not, see <http://www.gnu.org/licenses/>.
#
################################################################################
"""
Views for tenders
"""
from rattail.db.model import Tender
from tailbone.views import MasterView
class TenderView(MasterView):
"""
Master view for the Tender class.
"""
model_class = Tender
has_versions = True
grid_columns = [
'code',
'name',
]
form_fields = [
'code',
'name',
'notes',
]
def configure_grid(self, g):
super().configure_grid(g)
g.set_link('code')
g.set_link('name')
g.set_sort_defaults('name')
def defaults(config, **kwargs):
base = globals()
TenderView = kwargs.get('TenderView', base['TenderView'])
TenderView.defaults(config)
def includeme(config):
defaults(config)

View file

@ -43,6 +43,7 @@ def defaults(config, **kwargs):
config.include(mod('tailbone.views.reportcodes')) config.include(mod('tailbone.views.reportcodes'))
config.include(mod('tailbone.views.stores')) config.include(mod('tailbone.views.stores'))
config.include(mod('tailbone.views.subdepartments')) config.include(mod('tailbone.views.subdepartments'))
config.include(mod('tailbone.views.tenders'))
config.include(mod('tailbone.views.uoms')) config.include(mod('tailbone.views.uoms'))
config.include(mod('tailbone.views.vendors')) config.include(mod('tailbone.views.vendors'))