From 53e8c15267cb275b36f7532db67d2a252df8e1f4 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sat, 23 Sep 2023 11:14:43 -0500 Subject: [PATCH] Add basic views for POS batches --- tailbone/views/batch/pos.py | 148 ++++++++++++++++++++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 tailbone/views/batch/pos.py diff --git a/tailbone/views/batch/pos.py b/tailbone/views/batch/pos.py new file mode 100644 index 00000000..402a70b4 --- /dev/null +++ b/tailbone/views/batch/pos.py @@ -0,0 +1,148 @@ +# -*- 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 POS batches +""" + +from rattail.db.model import POSBatch, POSBatchRow + +from tailbone.views.batch import BatchMasterView + + +class POSBatchView(BatchMasterView): + """ + Master view for POS batches + """ + model_class = POSBatch + model_row_class = POSBatchRow + default_handler_spec = 'rattail.batch.pos:POSBatchHandler' + route_prefix = 'batch.pos' + url_prefix = '/batch/pos' + creatable = False + + grid_columns = [ + 'id', + 'created', + 'created_by', + 'rowcount', + 'sales_total', + 'void', + 'status_code', + 'executed', + 'executed_by', + ] + + form_fields = [ + 'id', + 'description', + 'notes', + 'params', + 'rowcount', + 'sales_total', + 'tax1_total', + 'tax2_total', + 'status_code', + 'created', + 'created_by', + 'executed', + 'executed_by', + ] + + row_grid_columns = [ + 'sequence', + 'row_type', + 'product', + 'description', + 'reg_price', + 'txn_price', + 'quantity', + 'sales_total', + 'status_code', + ] + + row_form_fields = [ + 'sequence', + 'row_type', + 'item_entry', + 'product', + 'description', + 'reg_price', + 'txn_price', + 'quantity', + 'sales_total', + 'tax1_total', + 'tax2_total', + 'status_code', + ] + + def configure_grid(self, g): + super().configure_grid(g) + + g.set_type('sales_total', 'currency') + g.set_type('tax1_total', 'currency') + g.set_type('tax2_total', 'currency') + + g.set_link('created') + g.set_link('created_by') + + def grid_extra_class(self, batch, i): + if batch.void: + return 'warning' + + def configure_form(self, f): + super().configure_form(f) + + f.set_type('sales_total', 'currency') + f.set_type('tax1_total', 'currency') + f.set_type('tax2_total', 'currency') + + def configure_row_grid(self, g): + super().configure_row_grid(g) + + g.set_type('quantity', 'quantity') + g.set_type('reg_price', 'currency') + g.set_type('txn_price', 'currency') + g.set_type('sales_total', 'currency') + + g.set_link('product') + g.set_link('description') + + def configure_row_form(self, f): + super().configure_row_form(f) + + 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) + + +def defaults(config, **kwargs): + base = globals() + + POSBatchView = kwargs.get('POSBatchView', base['POSBatchView']) + POSBatchView.defaults(config) + + +def includeme(config): + defaults(config)