/** * Utility functions that concern about retrieving and storing data in a project file. * this file also includes a default project in case a user want to start anew. */ const VERSION = "0.1"; let projectData = { version: VERSION, expenses: [], accounts: [ { name: "Current", entries: [ { date: 1704067200000, subject: '(Savings) Initial Deposit', amount: -500, targetAccount: "Savings" }, { date: 1704067200000, subject: 'Salary', amount: 2182.15 }, { date: 1704153600000, subject: 'Rent', amount: -800 }, { date: 1704240000000, subject: 'Groceries', amount: -24.19 } ], }, { name: "Savings", entries: [ { date: 1704067200000, subject: 'Initial Deposit', amount: 500 } ], } ] }; class Project { #projectData; addAccount(accountName) { } closeAccount(accountName, transferToOtherAccount) { } getSummation(accountName) { const acc = this.#projectData.accounts.find(p => p.name === accountName); return acc.entries.reduce((sum, e) => sum + parseFloat(e.amount), 0); } getAccounts() { } getAccountEntries(accountName) { } save(to) { } constructor(projectData) { } static open(from) { return new Project() } }