diff --git a/js/003-data/gameVariableData.js b/js/003-data/gameVariableData.js index b70c19617a1e8f6634778ca8cc6c8dcc4c89813e..70c9dcb22e3831e659e6038e8010be8cc557b5fc 100644 --- a/js/003-data/gameVariableData.js +++ b/js/003-data/gameVariableData.js @@ -495,7 +495,6 @@ App.Data.resetOnNGPlus = { lastWeeksCashExpenses: {}, lastWeeksRepIncome: {}, lastWeeksRepExpenses: {}, - lastWeeksGatheredTotals: {}, currentRule: {}, costs: 0, seeBuilding: 0, diff --git a/src/data/backwardsCompatibility/backwardsCompatibility.js b/src/data/backwardsCompatibility/backwardsCompatibility.js index f33df391adde60a45971ba0095bede45a4ea13d1..4a2b6f872cdbf8ed90efd5492a4c8c1d2129cfd2 100644 --- a/src/data/backwardsCompatibility/backwardsCompatibility.js +++ b/src/data/backwardsCompatibility/backwardsCompatibility.js @@ -119,17 +119,6 @@ App.Update.backwardsCompatibility = function() { }; App.Update.globalVariables = function(node) { - for (const key of Object.keys(CategoryAssociatedGroup)) { - if(!V.lastWeeksGatheredTotals[key]) { - V.lastWeeksGatheredTotals[key] = {income: 0, expenses: 0}; - } - for (const subKey of Object.keys(new App.Data.Records.LastWeeksCash())) { - if(!V.lastWeeksGatheredTotals[key][subKey]) { - V.lastWeeksGatheredTotals[key][subKey] = {income: 0, expenses: 0}; - } - } - } - if (Array.isArray(V.nationalities)) { V.nationalities = weightedArray2HashMap(V.nationalities); } diff --git a/src/js/economyJS.js b/src/js/economyJS.js index df410187683ebb5072328af98dd0bde1e642d1ed..2f791dedcd56a3ffb668bc158eec356c0e475233 100644 --- a/src/js/economyJS.js +++ b/src/js/economyJS.js @@ -2308,14 +2308,6 @@ globalThis.cashX = function(cost, what, who) { who.lastWeeksCashIncome += cost; who.lifetimeCashIncome += cost; } - - // gather totals - for (const key of Object.keys(CategoryAssociatedGroup)) { - if (CategoryAssociatedGroup[key].contains(what)) { - V.lastWeeksGatheredTotals[key][what].income += cost; - V.lastWeeksGatheredTotals[key].income += cost; - } - } } else if (cost < 0) { // EXPENSES // record the action if (typeof V.lastWeeksCashExpenses[what] !== 'undefined') { @@ -2333,14 +2325,6 @@ globalThis.cashX = function(cost, what, who) { who.lifetimeCashExpenses += cost; } } - - // gather totals - for (const key of Object.keys(CategoryAssociatedGroup)) { - if (CategoryAssociatedGroup[key].contains(what)) { - V.lastWeeksGatheredTotals[key][what].expenses += cost; - V.lastWeeksGatheredTotals[key].expenses += cost; - } - } } App.Utils.scheduleSidebarRefresh(); @@ -2600,15 +2584,6 @@ globalThis.setupLastWeeksCash = function() { V.lastWeeksCashIncome = new App.Data.Records.LastWeeksCash(); V.lastWeeksCashExpenses = new App.Data.Records.LastWeeksCash(); V.lastWeeksCashErrors = "Errors: "; - - // Here we reset our tracked totals on week end, and add the default categories to all objects - V.lastWeeksGatheredTotals = {}; - for (const key of Object.keys(CategoryAssociatedGroup)){ - V.lastWeeksGatheredTotals[key] = {income: 0, expenses: 0}; - for (const subKey of Object.keys(new App.Data.Records.LastWeeksCash())) { - V.lastWeeksGatheredTotals[key][subKey] = {income: 0, expenses: 0}; - } - } }; globalThis.setupLastWeeksRep = function() { diff --git a/src/uncategorized/costsBudget.js b/src/uncategorized/costsBudget.js index 6fbad7e4d0aff229edac61f8a90171a5e83658fb..7d4b53daaa94041583a0a097a8b3d703c5528e0e 100644 --- a/src/uncategorized/costsBudget.js +++ b/src/uncategorized/costsBudget.js @@ -4,7 +4,6 @@ App.UI.Budget.Cost = function() { // Set up object to track calculated displays const income = "lastWeeksCashIncome"; const expenses = "lastWeeksCashExpenses"; - const F = V.lastWeeksGatheredTotals; const table = document.createElement("table"); table.classList.add("budget"); @@ -367,19 +366,24 @@ App.UI.Budget.Cost = function() { } } - function generateRowGroup(title, group) { - if (F[group].income || F[group].expenses || V.showAllEntries.costsBudget) { + function generateRowGroup(title, name) { + /** @type {string[]} */ + const members = CategoryAssociatedGroup[name]; + const groupIn = members.map((k) => V[income][k]).reduce((acc, cur) => acc + cur); + const groupEx = members.map((k) => V[expenses][k]).reduce((acc, cur) => acc + cur); + + if (groupIn || groupEx || V.showAllEntries.costsBudget) { const row = table.insertRow(); let cell = row.insertCell(); const headline = document.createElement('h3'); headline.textContent = title; cell.append(headline); cell = row.insertCell(); - cell.append(cashFormatColorDOM(F[group].income, null)); + cell.append(cashFormatColorDOM(groupIn)); cell = row.insertCell(); - cell.append(cashFormatColorDOM(F[group].expenses, null)); + cell.append(cashFormatColorDOM(groupEx)); cell = row.insertCell(); - cell.append(cashFormatColorDOM(F[group].income + F[group].expenses, null)); + cell.append(cashFormatColorDOM(groupIn + groupEx)); return row; } }