From e3f4e75561dbb4efcf1a21769d534d15fa478be3 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 6 Aug 2023 11:21:20 +0200 Subject: [PATCH] Fix boxes api --- package-lock.json | 182 +++++++++---------- resources/assets/v2/pages/dashboard/boxes.js | 147 ++++++++++++--- 2 files changed, 213 insertions(+), 116 deletions(-) diff --git a/package-lock.json b/package-lock.json index cc4dd94c0c..653e4e0fae 100644 --- a/package-lock.json +++ b/package-lock.json @@ -32,9 +32,9 @@ } }, "node_modules/@esbuild/android-arm": { - "version": "0.18.17", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.18.17.tgz", - "integrity": "sha512-wHsmJG/dnL3OkpAcwbgoBTTMHVi4Uyou3F5mf58ZtmUyIKfcdA7TROav/6tCzET4A3QW2Q2FC+eFneMU+iyOxg==", + "version": "0.18.18", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.18.18.tgz", + "integrity": "sha512-oBymf7ZwplAawSxmiSlBCf+FMcY0f4bs5QP2jn43JKUf0M9DnrUTjqa5RvFPl1elw+sMfcpfBRPK+rb+E1q7zg==", "cpu": [ "arm" ], @@ -48,9 +48,9 @@ } }, "node_modules/@esbuild/android-arm64": { - "version": "0.18.17", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.18.17.tgz", - "integrity": "sha512-9np+YYdNDed5+Jgr1TdWBsozZ85U1Oa3xW0c7TWqH0y2aGghXtZsuT8nYRbzOMcl0bXZXjOGbksoTtVOlWrRZg==", + "version": "0.18.18", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.18.18.tgz", + "integrity": "sha512-dkAPYzRHq3dNXIzOyAknYOzsx8o3KWaNiuu56B2rP9IFPmFWMS58WQcTlUQi6iloku8ZyHHMluCe5sTWhKq/Yw==", "cpu": [ "arm64" ], @@ -64,9 +64,9 @@ } }, "node_modules/@esbuild/android-x64": { - "version": "0.18.17", - "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.18.17.tgz", - "integrity": "sha512-O+FeWB/+xya0aLg23hHEM2E3hbfwZzjqumKMSIqcHbNvDa+dza2D0yLuymRBQQnC34CWrsJUXyH2MG5VnLd6uw==", + "version": "0.18.18", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.18.18.tgz", + "integrity": "sha512-r7/pVcrUQMYkjvtE/1/n6BxhWM+/9tvLxDG1ev1ce4z3YsqoxMK9bbOM6bFcj0BowMeGQvOZWcBV182lFFKmrw==", "cpu": [ "x64" ], @@ -80,9 +80,9 @@ } }, "node_modules/@esbuild/darwin-arm64": { - "version": "0.18.17", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.18.17.tgz", - "integrity": "sha512-M9uJ9VSB1oli2BE/dJs3zVr9kcCBBsE883prage1NWz6pBS++1oNn/7soPNS3+1DGj0FrkSvnED4Bmlu1VAE9g==", + "version": "0.18.18", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.18.18.tgz", + "integrity": "sha512-MSe2iV9MAH3wfP0g+vzN9bp36rtPPuCSk+bT5E2vv/d8krvW5uB/Pi/Q5+txUZuxsG3GcO8dhygjnFq0wJU9hQ==", "cpu": [ "arm64" ], @@ -96,9 +96,9 @@ } }, "node_modules/@esbuild/darwin-x64": { - "version": "0.18.17", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.18.17.tgz", - "integrity": "sha512-XDre+J5YeIJDMfp3n0279DFNrGCXlxOuGsWIkRb1NThMZ0BsrWXoTg23Jer7fEXQ9Ye5QjrvXpxnhzl3bHtk0g==", + "version": "0.18.18", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.18.18.tgz", + "integrity": "sha512-ARFYISOWkaifjcr48YtO70gcDNeOf1H2RnmOj6ip3xHIj66f3dAbhcd5Nph5np6oHI7DhHIcr9MWO18RvUL1bw==", "cpu": [ "x64" ], @@ -112,9 +112,9 @@ } }, "node_modules/@esbuild/freebsd-arm64": { - "version": "0.18.17", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.18.17.tgz", - "integrity": "sha512-cjTzGa3QlNfERa0+ptykyxs5A6FEUQQF0MuilYXYBGdBxD3vxJcKnzDlhDCa1VAJCmAxed6mYhA2KaJIbtiNuQ==", + "version": "0.18.18", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.18.18.tgz", + "integrity": "sha512-BHnXmexzEWRU2ZySJosU0Ts0NRnJnNrMB6t4EiIaOSel73I8iLsNiTPLH0rJulAh19cYZutsB5XHK6N8fi5eMg==", "cpu": [ "arm64" ], @@ -128,9 +128,9 @@ } }, "node_modules/@esbuild/freebsd-x64": { - "version": "0.18.17", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.18.17.tgz", - "integrity": "sha512-sOxEvR8d7V7Kw8QqzxWc7bFfnWnGdaFBut1dRUYtu+EIRXefBc/eIsiUiShnW0hM3FmQ5Zf27suDuHsKgZ5QrA==", + "version": "0.18.18", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.18.18.tgz", + "integrity": "sha512-n823w35wm0ZOobbuE//0sJjuz1Qj619+AwjgOcAJMN2pomZhH9BONCtn+KlfrmM/NWZ+27yB/eGVFzUIWLeh3w==", "cpu": [ "x64" ], @@ -144,9 +144,9 @@ } }, "node_modules/@esbuild/linux-arm": { - "version": "0.18.17", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.18.17.tgz", - "integrity": "sha512-2d3Lw6wkwgSLC2fIvXKoMNGVaeY8qdN0IC3rfuVxJp89CRfA3e3VqWifGDfuakPmp90+ZirmTfye1n4ncjv2lg==", + "version": "0.18.18", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.18.18.tgz", + "integrity": "sha512-Kck3jxPLQU4VeAGwe8Q4NU+IWIx+suULYOFUI9T0C2J1+UQlOHJ08ITN+MaJJ+2youzJOmKmcphH/t3SJxQ1Tw==", "cpu": [ "arm" ], @@ -160,9 +160,9 @@ } }, "node_modules/@esbuild/linux-arm64": { - "version": "0.18.17", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.18.17.tgz", - "integrity": "sha512-c9w3tE7qA3CYWjT+M3BMbwMt+0JYOp3vCMKgVBrCl1nwjAlOMYzEo+gG7QaZ9AtqZFj5MbUc885wuBBmu6aADQ==", + "version": "0.18.18", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.18.18.tgz", + "integrity": "sha512-zANxnwF0sCinDcAqoMohGoWBK9QaFJ65Vgh0ZE+RXtURaMwx+RfmfLElqtnn7X8OYNckMoIXSg7u+tZ3tqTlrA==", "cpu": [ "arm64" ], @@ -176,9 +176,9 @@ } }, "node_modules/@esbuild/linux-ia32": { - "version": "0.18.17", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.18.17.tgz", - "integrity": "sha512-1DS9F966pn5pPnqXYz16dQqWIB0dmDfAQZd6jSSpiT9eX1NzKh07J6VKR3AoXXXEk6CqZMojiVDSZi1SlmKVdg==", + "version": "0.18.18", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.18.18.tgz", + "integrity": "sha512-+VHz2sIRlY5u8IlaLJpdf5TL2kM76yx186pW7bpTB+vLWpzcFQVP04L842ZB2Ty13A1VXUvy3DbU1jV65P2skg==", "cpu": [ "ia32" ], @@ -192,9 +192,9 @@ } }, "node_modules/@esbuild/linux-loong64": { - "version": "0.18.17", - "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.18.17.tgz", - "integrity": "sha512-EvLsxCk6ZF0fpCB6w6eOI2Fc8KW5N6sHlIovNe8uOFObL2O+Mr0bflPHyHwLT6rwMg9r77WOAWb2FqCQrVnwFg==", + "version": "0.18.18", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.18.18.tgz", + "integrity": "sha512-fXPEPdeGBvguo/1+Na8OIWz3667BN1cwbGtTEZWTd0qdyTsk5gGf9jVX8MblElbDb/Cpw6y5JiaQuL96YmvBwQ==", "cpu": [ "loong64" ], @@ -208,9 +208,9 @@ } }, "node_modules/@esbuild/linux-mips64el": { - "version": "0.18.17", - "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.18.17.tgz", - "integrity": "sha512-e0bIdHA5p6l+lwqTE36NAW5hHtw2tNRmHlGBygZC14QObsA3bD4C6sXLJjvnDIjSKhW1/0S3eDy+QmX/uZWEYQ==", + "version": "0.18.18", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.18.18.tgz", + "integrity": "sha512-dLvRB87pIBIRnEIC32LIcgwK1JzlIuADIRjLKdUIpxauKwMuS/xMpN+cFl+0nN4RHNYOZ57DmXFFmQAcdlFOmw==", "cpu": [ "mips64el" ], @@ -224,9 +224,9 @@ } }, "node_modules/@esbuild/linux-ppc64": { - "version": "0.18.17", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.18.17.tgz", - "integrity": "sha512-BAAilJ0M5O2uMxHYGjFKn4nJKF6fNCdP1E0o5t5fvMYYzeIqy2JdAP88Az5LHt9qBoUa4tDaRpfWt21ep5/WqQ==", + "version": "0.18.18", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.18.18.tgz", + "integrity": "sha512-fRChqIJZ7hLkXSKfBLYgsX9Ssb5OGCjk3dzCETF5QSS1qjTgayLv0ALUdJDB9QOh/nbWwp+qfLZU6md4XcjL7w==", "cpu": [ "ppc64" ], @@ -240,9 +240,9 @@ } }, "node_modules/@esbuild/linux-riscv64": { - "version": "0.18.17", - "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.18.17.tgz", - "integrity": "sha512-Wh/HW2MPnC3b8BqRSIme/9Zhab36PPH+3zam5pqGRH4pE+4xTrVLx2+XdGp6fVS3L2x+DrsIcsbMleex8fbE6g==", + "version": "0.18.18", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.18.18.tgz", + "integrity": "sha512-ALK/BT3u7Hoa/vHjow6W6+MKF0ohYcVcVA1EpskI4bkBPVuDLrUDqt2YFifg5UcZc8qup0CwQqWmFUd6VMNgaA==", "cpu": [ "riscv64" ], @@ -256,9 +256,9 @@ } }, "node_modules/@esbuild/linux-s390x": { - "version": "0.18.17", - "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.18.17.tgz", - "integrity": "sha512-j/34jAl3ul3PNcK3pfI0NSlBANduT2UO5kZ7FCaK33XFv3chDhICLY8wJJWIhiQ+YNdQ9dxqQctRg2bvrMlYgg==", + "version": "0.18.18", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.18.18.tgz", + "integrity": "sha512-crT7jtOXd9iirY65B+mJQ6W0HWdNy8dtkZqKGWNcBnunpLcTCfne5y5bKic9bhyYzKpQEsO+C/VBPD8iF0RhRw==", "cpu": [ "s390x" ], @@ -272,9 +272,9 @@ } }, "node_modules/@esbuild/linux-x64": { - "version": "0.18.17", - "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.18.17.tgz", - "integrity": "sha512-QM50vJ/y+8I60qEmFxMoxIx4de03pGo2HwxdBeFd4nMh364X6TIBZ6VQ5UQmPbQWUVWHWws5MmJXlHAXvJEmpQ==", + "version": "0.18.18", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.18.18.tgz", + "integrity": "sha512-/NSgghjBOW9ELqjXDYxOCCIsvQUZpvua1/6NdnA9Vnrp9UzEydyDdFXljUjMMS9p5KxMzbMO9frjHYGVHBfCHg==", "cpu": [ "x64" ], @@ -288,9 +288,9 @@ } }, "node_modules/@esbuild/netbsd-x64": { - "version": "0.18.17", - "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.18.17.tgz", - "integrity": "sha512-/jGlhWR7Sj9JPZHzXyyMZ1RFMkNPjC6QIAan0sDOtIo2TYk3tZn5UDrkE0XgsTQCxWTTOcMPf9p6Rh2hXtl5TQ==", + "version": "0.18.18", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.18.18.tgz", + "integrity": "sha512-8Otf05Vx5sZjLLDulgr5QS5lsWXMplKZEyHMArH9/S4olLlhzmdhQBPhzhJTNwaL2FJNdWcUPNGAcoD5zDTfUA==", "cpu": [ "x64" ], @@ -304,9 +304,9 @@ } }, "node_modules/@esbuild/openbsd-x64": { - "version": "0.18.17", - "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.18.17.tgz", - "integrity": "sha512-rSEeYaGgyGGf4qZM2NonMhMOP/5EHp4u9ehFiBrg7stH6BYEEjlkVREuDEcQ0LfIl53OXLxNbfuIj7mr5m29TA==", + "version": "0.18.18", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.18.18.tgz", + "integrity": "sha512-tFiFF4kT5L5qhVrWJUNxEXWvvX8nK/UX9ZrB7apuTwY3f6+Xy4aFMBPwAVrBYtBd5MOUuyOVHK6HBZCAHkwUlw==", "cpu": [ "x64" ], @@ -320,9 +320,9 @@ } }, "node_modules/@esbuild/sunos-x64": { - "version": "0.18.17", - "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.18.17.tgz", - "integrity": "sha512-Y7ZBbkLqlSgn4+zot4KUNYst0bFoO68tRgI6mY2FIM+b7ZbyNVtNbDP5y8qlu4/knZZ73fgJDlXID+ohY5zt5g==", + "version": "0.18.18", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.18.18.tgz", + "integrity": "sha512-MPogVV8Bzh8os4OM+YDGGsSzCzmNRiyKGtHoJyZLtI4BMmd6EcxmGlcEGK1uM46h1BiOyi7Z7teUtzzQhvkC+w==", "cpu": [ "x64" ], @@ -336,9 +336,9 @@ } }, "node_modules/@esbuild/win32-arm64": { - "version": "0.18.17", - "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.18.17.tgz", - "integrity": "sha512-bwPmTJsEQcbZk26oYpc4c/8PvTY3J5/QK8jM19DVlEsAB41M39aWovWoHtNm78sd6ip6prilxeHosPADXtEJFw==", + "version": "0.18.18", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.18.18.tgz", + "integrity": "sha512-YKD6LF/XXY9REu+ZL5RAsusiG48n602qxsMVh/E8FFD9hp4OyTQaL9fpE1ovxwQXqFio+tT0ITUGjDSSSPN13w==", "cpu": [ "arm64" ], @@ -352,9 +352,9 @@ } }, "node_modules/@esbuild/win32-ia32": { - "version": "0.18.17", - "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.18.17.tgz", - "integrity": "sha512-H/XaPtPKli2MhW+3CQueo6Ni3Avggi6hP/YvgkEe1aSaxw+AeO8MFjq8DlgfTd9Iz4Yih3QCZI6YLMoyccnPRg==", + "version": "0.18.18", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.18.18.tgz", + "integrity": "sha512-NjSBmBsyZBTsZB6ga6rA6PfG/RHnwruUz/9YEVXcm4STGauFWvhYhOMhEyw1yU5NVgYYm8CH5AltCm77TS21/Q==", "cpu": [ "ia32" ], @@ -368,9 +368,9 @@ } }, "node_modules/@esbuild/win32-x64": { - "version": "0.18.17", - "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.18.17.tgz", - "integrity": "sha512-fGEb8f2BSA3CW7riJVurug65ACLuQAzKq0SSqkY2b2yHHH0MzDfbLyKIGzHwOI/gkHcxM/leuSW6D5w/LMNitA==", + "version": "0.18.18", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.18.18.tgz", + "integrity": "sha512-eTSg/gC3p3tdjj4roDhe5xu94l1s2jMazP8u2FsYO8SEKvSpPOO71EucprDn/IuErDPvTFUhV9lTw5z5WJCRKQ==", "cpu": [ "x64" ], @@ -568,9 +568,9 @@ } }, "node_modules/esbuild": { - "version": "0.18.17", - "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.18.17.tgz", - "integrity": "sha512-1GJtYnUxsJreHYA0Y+iQz2UEykonY66HNWOb0yXYZi9/kNrORUEHVg87eQsCtqh59PEJ5YVZJO98JHznMJSWjg==", + "version": "0.18.18", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.18.18.tgz", + "integrity": "sha512-UckDPWvdVJLNT0npk5AMTpVwGRQhS76rWFLmHwEtgNvWlR9sgVV1eyc/oeBtM86q9s8ABBLMmm0CwNxhVemOiw==", "dev": true, "hasInstallScript": true, "bin": { @@ -580,28 +580,28 @@ "node": ">=12" }, "optionalDependencies": { - "@esbuild/android-arm": "0.18.17", - "@esbuild/android-arm64": "0.18.17", - "@esbuild/android-x64": "0.18.17", - "@esbuild/darwin-arm64": "0.18.17", - "@esbuild/darwin-x64": "0.18.17", - "@esbuild/freebsd-arm64": "0.18.17", - "@esbuild/freebsd-x64": "0.18.17", - "@esbuild/linux-arm": "0.18.17", - "@esbuild/linux-arm64": "0.18.17", - "@esbuild/linux-ia32": "0.18.17", - "@esbuild/linux-loong64": "0.18.17", - "@esbuild/linux-mips64el": "0.18.17", - "@esbuild/linux-ppc64": "0.18.17", - "@esbuild/linux-riscv64": "0.18.17", - "@esbuild/linux-s390x": "0.18.17", - "@esbuild/linux-x64": "0.18.17", - "@esbuild/netbsd-x64": "0.18.17", - "@esbuild/openbsd-x64": "0.18.17", - "@esbuild/sunos-x64": "0.18.17", - "@esbuild/win32-arm64": "0.18.17", - "@esbuild/win32-ia32": "0.18.17", - "@esbuild/win32-x64": "0.18.17" + "@esbuild/android-arm": "0.18.18", + "@esbuild/android-arm64": "0.18.18", + "@esbuild/android-x64": "0.18.18", + "@esbuild/darwin-arm64": "0.18.18", + "@esbuild/darwin-x64": "0.18.18", + "@esbuild/freebsd-arm64": "0.18.18", + "@esbuild/freebsd-x64": "0.18.18", + "@esbuild/linux-arm": "0.18.18", + "@esbuild/linux-arm64": "0.18.18", + "@esbuild/linux-ia32": "0.18.18", + "@esbuild/linux-loong64": "0.18.18", + "@esbuild/linux-mips64el": "0.18.18", + "@esbuild/linux-ppc64": "0.18.18", + "@esbuild/linux-riscv64": "0.18.18", + "@esbuild/linux-s390x": "0.18.18", + "@esbuild/linux-x64": "0.18.18", + "@esbuild/netbsd-x64": "0.18.18", + "@esbuild/openbsd-x64": "0.18.18", + "@esbuild/sunos-x64": "0.18.18", + "@esbuild/win32-arm64": "0.18.18", + "@esbuild/win32-ia32": "0.18.18", + "@esbuild/win32-x64": "0.18.18" } }, "node_modules/fill-range": { diff --git a/resources/assets/v2/pages/dashboard/boxes.js b/resources/assets/v2/pages/dashboard/boxes.js index 0f9123f0d0..4aa31543e9 100644 --- a/resources/assets/v2/pages/dashboard/boxes.js +++ b/resources/assets/v2/pages/dashboard/boxes.js @@ -21,6 +21,7 @@ import Summary from "../../api/v2/summary/index.js"; import {format} from "date-fns"; import {getVariable} from "../../store/get-variable.js"; +import formatMoney from "../../util/format-money.js"; export default () => ({ @@ -28,6 +29,7 @@ export default () => ({ billBox: {paid: [], unpaid: []}, leftBox: {left: [], perDay: []}, netBox: {net: []}, + autoConversion: false, loading: false, loadBoxes() { if (this.loading) { @@ -46,37 +48,127 @@ export default () => ({ this.billBox = {paid: [], unpaid: []}; this.leftBox = {left: [], perDay: []}; this.netBox = {net: []}; + let subtitles = {}; // process new content: for (const i in response.data) { if (response.data.hasOwnProperty(i)) { const current = response.data[i]; - if (i.startsWith('balance-in-')) { - this.balanceBox.amounts.push(current.value_parsed); - this.balanceBox.subtitles.push(current.sub_title); - continue; - } - if (i.startsWith('bills-unpaid-in-')) { - this.billBox.unpaid.push(current.value_parsed); - continue; - } - if (i.startsWith('bills-paid-in-')) { - this.billBox.paid.push(current.value_parsed); - continue; - } - if (i.startsWith('spent-in-')) { - this.leftBox.left.push(current.value_parsed); - continue; - } - if (i.startsWith('left-to-spend-in-')) { // per day - this.leftBox.perDay.push(current.sub_title); - continue; - } - if (i.startsWith('net-worth-in-')) { - this.netBox.net.push(current.value_parsed); + let key = current.key; + // native (auto conversion): + if (this.autoConversion) { + if (key.startsWith('balance-in-native')) { + this.balanceBox.amounts.push(formatMoney(current.value, current.currency_code)); + // prep subtitles (for later) + if (!subtitles.hasOwnProperty(current.currency_code)) { + subtitles[current.currency_code] = ''; + } + continue; + } + // spent info is used in subtitle: + if (key.startsWith('spent-in-native')) { + // prep subtitles (for later) + if (!subtitles.hasOwnProperty(current.currency_code)) { + subtitles[current.currency_code] = ''; + } + // append the amount spent. + subtitles[current.currency_code] = + subtitles[current.currency_code] + + formatMoney(current.value, current.currency_code); + continue; + } + // earned info is used in subtitle: + if (key.startsWith('earned-in-native')) { + // prep subtitles (for later) + if (!subtitles.hasOwnProperty(current.currency_code)) { + subtitles[current.currency_code] = ''; + } + // prepend the amount earned. + subtitles[current.currency_code] = + formatMoney(current.value, current.currency_code) + ' + ' + + subtitles[current.currency_code]; + continue; + } + if (key.startsWith('bills-unpaid-in-native')) { + this.billBox.unpaid.push(formatMoney(current.value, current.currency_code)); + continue; + } + if (key.startsWith('bills-paid-in-native')) { + this.billBox.paid.push(formatMoney(current.value, current.currency_code)); + continue; + } + if (key.startsWith('left-to-spend-in-native')) { + this.leftBox.left.push(formatMoney(current.value, current.currency_code)); + continue; + } + if (key.startsWith('left-per-day-to-spend-in-native')) { // per day + this.leftBox.perDay.push(formatMoney(current.value, current.currency_code)); + continue; + } + if (key.startsWith('net-worth-in-native')) { + this.netBox.net.push(formatMoney(current.value, current.currency_code)); + continue; + } } - //console.log('Next up: ', current); + // not native + if (!this.autoConversion && !key.endsWith('native')) { + if (key.startsWith('balance-in-')) { + this.balanceBox.amounts.push(formatMoney(current.value, current.currency_code)); + continue; + } + // spent info is used in subtitle: + if (key.startsWith('spent-in-')) { + // prep subtitles (for later) + if (!subtitles.hasOwnProperty(current.currency_code)) { + subtitles[current.currency_code] = ''; + } + // append the amount spent. + subtitles[current.currency_code] = + subtitles[current.currency_code] + + formatMoney(current.value, current.currency_code); + continue; + } + // earned info is used in subtitle: + if (key.startsWith('earned-in-')) { + // prep subtitles (for later) + if (!subtitles.hasOwnProperty(current.currency_code)) { + subtitles[current.currency_code] = ''; + } + // prepend the amount earned. + subtitles[current.currency_code] = + formatMoney(current.value, current.currency_code) + ' + ' + + subtitles[current.currency_code]; + continue; + } + + + if (key.startsWith('bills-unpaid-in-')) { + this.billBox.unpaid.push(formatMoney(current.value, current.currency_code)); + continue; + } + if (key.startsWith('bills-paid-in-')) { + this.billBox.paid.push(formatMoney(current.value, current.currency_code)); + continue; + } + if (key.startsWith('left-to-spend-in-')) { + this.leftBox.left.push(formatMoney(current.value, current.currency_code)); + continue; + } + if (key.startsWith('left-per-day-to-spend-in-')) { + this.leftBox.perDay.push(formatMoney(current.value, current.currency_code)); + continue; + } + if (key.startsWith('net-worth-in-')) { + this.netBox.net.push(formatMoney(current.value, current.currency_code)); + + } + } + } + } + for (let i in subtitles) { + if (subtitles.hasOwnProperty(i)) { + this.balanceBox.subtitles.push(subtitles[i]); } } this.loading = false; @@ -86,11 +178,16 @@ export default () => ({ // Getter init() { - Promise.all([getVariable('viewRange'),]).then((values) => { + Promise.all([getVariable('viewRange'), getVariable('autoConversion', false)]).then((values) => { + this.autoConversion = values[1]; this.loadBoxes(); }); window.store.observe('end', () => { this.loadBoxes(); }); + window.store.observe('autoConversion', (newValue) => { + this.autoConversion = newValue; + this.loadBoxes(); + }); }, });