Rename to Tally; add Beauty category, Housing -> Household
This commit is contained in:
16
app.js
16
app.js
@@ -1,4 +1,4 @@
|
||||
/* Pin & Penny: daily / weekly / monthly views + repeating expenses.
|
||||
/* Tally: daily / weekly / monthly views + repeating expenses.
|
||||
Stored privately in localStorage; no network calls. */
|
||||
|
||||
"use strict";
|
||||
@@ -7,10 +7,11 @@
|
||||
var CATS = {
|
||||
Food: "#9ed6a4",
|
||||
Transport: "#a9c8f0",
|
||||
Housing: "#eab88f",
|
||||
Household: "#eab88f",
|
||||
Utilities: "#8fd8c4",
|
||||
Shopping: "#f5b98a",
|
||||
Health: "#f2a3a3",
|
||||
Beauty: "#dba9e8",
|
||||
Entertainment: "#f2cd88",
|
||||
Other: "#c9c9c9"
|
||||
};
|
||||
@@ -110,7 +111,14 @@ function load() {
|
||||
return seed;
|
||||
}
|
||||
var arr = JSON.parse(raw);
|
||||
return Array.isArray(arr) ? arr : [];
|
||||
if (!Array.isArray(arr)) return [];
|
||||
/* Migrate the Housing -> Household rename in stored entries. */
|
||||
var changed = false;
|
||||
arr.forEach(function (e) {
|
||||
if (e && e.category === "Housing") { e.category = "Household"; changed = true; }
|
||||
});
|
||||
if (changed) { try { save(arr); } catch (err) { /* keep the in-memory list */ } }
|
||||
return arr;
|
||||
} catch (e) {
|
||||
return [];
|
||||
}
|
||||
@@ -138,7 +146,7 @@ function seedSamples() {
|
||||
mk("New shoes", 79.99, "Shopping", addDaysStr(t, -8)),
|
||||
mk("Team lunch", 13.4, "Food", addDaysStr(t, -9), "weekly"),
|
||||
mk("Internet", 59.99, "Utilities", addDaysStr(t, -12), "monthly"),
|
||||
mk("Rent", 1200.0, "Housing", first, "monthly"),
|
||||
mk("Rent", 1200.0, "Household", first, "monthly"),
|
||||
mk("Concert ticket", 45.0, "Entertainment", addDaysStr(t, -20)),
|
||||
mk("Groceries", 62.1, "Food", addDaysStr(t, -33))
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user