From f572757f0091fe09ecd5409e06eb44c94016d434 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Wed, 27 Sep 2023 17:13:49 -0500 Subject: [PATCH] Expose views for tenders, more columns for POS batch/rows --- tailbone/menus.py | 33 +++++++++++++----- tailbone/views/batch/pos.py | 29 +++++++++++++++- tailbone/views/tenders.py | 67 +++++++++++++++++++++++++++++++++++++ tailbone/views/typical.py | 1 + 4 files changed, 120 insertions(+), 10 deletions(-) create mode 100644 tailbone/views/tenders.py diff --git a/tailbone/menus.py b/tailbone/menus.py index b50233f8..36189b88 100644 --- a/tailbone/menus.py +++ b/tailbone/menus.py @@ -625,15 +625,30 @@ class MenuHandler(GenericHandler): """ items = [] - if kwargs.get('include_stores', True): - items.extend([ - { - 'title': "Stores", - 'route': 'stores', - 'perm': 'stores.list', - }, - {'type': 'sep'}, - ]) + include_stores = kwargs.get('include_stores', True) + include_tenders = kwargs.get('include_tenders', True) + + if include_stores or include_tenders: + + if include_stores: + items.extend([ + { + '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([ { diff --git a/tailbone/views/batch/pos.py b/tailbone/views/batch/pos.py index 7c9d5586..d2a38314 100644 --- a/tailbone/views/batch/pos.py +++ b/tailbone/views/batch/pos.py @@ -68,6 +68,10 @@ class POSBatchView(BatchMasterView): 'sales_total', 'tax1_total', 'tax2_total', + 'tender_total', + 'balance', + 'void', + 'training_mode', 'status_code', 'created', 'created_by', @@ -84,6 +88,7 @@ class POSBatchView(BatchMasterView): 'txn_price', 'quantity', 'sales_total', + 'tender_total', 'status_code', ] @@ -99,7 +104,10 @@ class POSBatchView(BatchMasterView): 'sales_total', 'tax1_total', 'tax2_total', + 'tender_total', 'status_code', + 'timestamp', + 'user', ] def configure_grid(self, g): @@ -118,19 +126,33 @@ class POSBatchView(BatchMasterView): g.set_type('sales_total', 'currency') g.set_type('tax1_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): if batch.void: return 'warning' + if batch.training_mode: + return 'notice' def configure_form(self, f): super().configure_form(f) + app = self.get_rattail_app() f.set_renderer('customer', self.render_customer) f.set_type('sales_total', 'currency') f.set_type('tax1_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): super().configure_row_grid(g) @@ -139,6 +161,7 @@ class POSBatchView(BatchMasterView): g.set_type('reg_price', 'currency') g.set_type('txn_price', 'currency') g.set_type('sales_total', 'currency') + g.set_type('tender_total', 'currency') g.set_link('product') g.set_link('description') @@ -146,11 +169,15 @@ class POSBatchView(BatchMasterView): def configure_row_form(self, f): super().configure_row_form(f) + f.set_renderer('product', self.render_product) + f.set_type('quantity', 'quantity') f.set_type('reg_price', 'currency') f.set_type('txn_price', '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): diff --git a/tailbone/views/tenders.py b/tailbone/views/tenders.py new file mode 100644 index 00000000..a95773e3 --- /dev/null +++ b/tailbone/views/tenders.py @@ -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 . +# +################################################################################ +""" +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) diff --git a/tailbone/views/typical.py b/tailbone/views/typical.py index d3450fbd..ed94d552 100644 --- a/tailbone/views/typical.py +++ b/tailbone/views/typical.py @@ -43,6 +43,7 @@ def defaults(config, **kwargs): config.include(mod('tailbone.views.reportcodes')) config.include(mod('tailbone.views.stores')) config.include(mod('tailbone.views.subdepartments')) + config.include(mod('tailbone.views.tenders')) config.include(mod('tailbone.views.uoms')) config.include(mod('tailbone.views.vendors'))