From b8b19c60efde973ff4b382e4b38f63434531fd02 Mon Sep 17 00:00:00 2001 From: Oliver Date: Sat, 25 Mar 2023 00:35:22 +1100 Subject: [PATCH] Adds footer formatter to stock table (#4528) Closes https://github.com/inventree/InvenTree/issues/4525 --- InvenTree/templates/js/translated/stock.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/InvenTree/templates/js/translated/stock.js b/InvenTree/templates/js/translated/stock.js index f25efdee43..cc6bdaf4fb 100644 --- a/InvenTree/templates/js/translated/stock.js +++ b/InvenTree/templates/js/translated/stock.js @@ -1896,6 +1896,18 @@ function loadStockTable(table, options) { } return html; + }, + footerFormatter: function(data) { + // Display "total" stock quantity of all rendered rows + let total = 0; + + data.forEach(function(row) { + if (row.quantity != null) { + total += row.quantity; + } + }); + + return total; } };