Add grid totals support for CORE stock purchases

This commit is contained in:
Lance Edgar 2023-09-16 13:09:09 -05:00
parent f540dfce43
commit b70c47f821

View file

@ -37,6 +37,7 @@ class StockPurchaseView(CoreTransMasterView):
model_title = "CORE-POS Stock Purchase"
url_prefix = '/core-pos/stock-purchases'
route_prefix = 'corepos.stock_purchases'
supports_grid_totals = True
labels = {
'transaction_id': "Transaction ID",
@ -53,6 +54,12 @@ class StockPurchaseView(CoreTransMasterView):
g.set_link('transaction_number')
g.set_link('datetime')
def fetch_grid_totals(self):
app = self.get_rattail_app()
results = self.get_effective_data()
total = sum([purchase.amount for purchase in results])
return {'totals_display': app.render_currency(total)}
def configure_form(self, f):
super().configure_form(f)