Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Fix all lint issues.
James Cole375ea31a62ff
diff --git a/resources/assets/v3/js/api/model/currency/get.js b/resources/assets/v3/js/api/model/currency/get.jsindex 87e953f8c2..b65d35e0be 100644--- a/resources/assets/v3/js/api/model/currency/get.js+++ b/resources/assets/v3/js/api/model/currency/get.js@@ -30,5 +30,8 @@ export default class Get {list(params) {return api.get('/api/v1/currencies', {params: params});}+ get(code) {+ return api.get('/api/v1/currencies/' + code);+ }}diff --git a/resources/assets/v3/js/api/model/exchange-rate/delete.js b/resources/assets/v3/js/api/model/exchange-rate/delete.jsnew file mode 100644index 0000000000..138e071c2b--- /dev/null+++ b/resources/assets/v3/js/api/model/exchange-rate/delete.js@@ -0,0 +1,28 @@+/*+ * post.js+ * Copyright (c) 2023 [email protected]+ *+ * This file is part of Firefly III (https://github.com/firefly-iii).+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ */++import {api} from "../../../boot/axios";++export default class Delete {+ delete(id) {+ let url = '/api/v1/exchange-rates/' + parseInt(id);+ return api.delete(url);+ }+}diff --git a/resources/assets/v3/js/api/model/exchange-rate/get.js b/resources/assets/v3/js/api/model/exchange-rate/get.jsnew file mode 100644index 0000000000..5d4dddab26--- /dev/null+++ b/resources/assets/v3/js/api/model/exchange-rate/get.js@@ -0,0 +1,29 @@+/*+ * list.js+ * Copyright (c) 2022 [email protected]+ *+ * This file is part of Firefly III (https://github.com/firefly-iii).+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ */++import {api} from "../../../boot/axios";++export default class Get {++ get(from, to, params) {+ return api.get('/api/v1/exchange-rates/' + from + '/' + to , {params: params});+ }++}diff --git a/resources/assets/v3/js/api/model/exchange-rate/post.js b/resources/assets/v3/js/api/model/exchange-rate/post.jsnew file mode 100644index 0000000000..869dc56044--- /dev/null+++ b/resources/assets/v3/js/api/model/exchange-rate/post.js@@ -0,0 +1,28 @@+/*+ * post.js+ * Copyright (c) 2023 [email protected]+ *+ * This file is part of Firefly III (https://github.com/firefly-iii).+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ */++import {api} from "../../../boot/axios";++export default class Post {+ post(submission) {+ let url = '/api/v1/exchange-rates';+ return api.post(url, submission);+ }+}diff --git a/resources/assets/v3/js/api/model/exchange-rate/put.js b/resources/assets/v3/js/api/model/exchange-rate/put.jsnew file mode 100644index 0000000000..ffce80a13d--- /dev/null+++ b/resources/assets/v3/js/api/model/exchange-rate/put.js@@ -0,0 +1,28 @@+/*+ * post.js+ * Copyright (c) 2023 [email protected]+ *+ * This file is part of Firefly III (https://github.com/firefly-iii).+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ */++import {api} from "../../../boot/axios";++export default class Put {+ put(submission, params) {+ let url = '/api/v1/exchange-rates/' + parseInt(params.id);+ return api.put(url, submission);+ }+}diff --git a/resources/assets/v3/js/api/model/webhook/post.js b/resources/assets/v3/js/api/model/webhook/post.jsindex f8394b41a3..6147215b63 100644--- a/resources/assets/v3/js/api/model/webhook/post.js+++ b/resources/assets/v3/js/api/model/webhook/post.js@@ -22,7 +22,6 @@ import {api} from "../../../boot/axios";export default class Post {triggerTransaction(webhook, transaction) {- let url = '/api/v1/webhooks';return api.post('./api/v1/webhooks/' + webhook + '/trigger-transaction/' + transaction, {});}diff --git a/resources/assets/v3/js/api/user-group/get.js b/resources/assets/v3/js/api/user-group/get.jsnew file mode 100644index 0000000000..9646c52895--- /dev/null+++ b/resources/assets/v3/js/api/user-group/get.js@@ -0,0 +1,32 @@+/*+ * get.js+ * Copyright (c) 2023 [email protected]+ *+ * This file is part of Firefly III (https://github.com/firefly-iii).+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ */+++import {api} from "../../boot/axios";++export default class Get {++ list(params) {+ return api.get('/api/v1/user-groups', {params: params});+ }+ get(id, params) {+ return api.get('/api/v1/user-groups/' + parseInt(id), {params: params});+ }+}diff --git a/resources/assets/v3/js/api/user-group/put.js b/resources/assets/v3/js/api/user-group/put.jsnew file mode 100644index 0000000000..7b2c249a64--- /dev/null+++ b/resources/assets/v3/js/api/user-group/put.js@@ -0,0 +1,28 @@+/*+ * post.js+ * Copyright (c) 2023 [email protected]+ *+ * This file is part of Firefly III (https://github.com/firefly-iii).+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ */++import {api} from "../../boot/axios";++export default class Put {+ put(submission, params) {+ let url = '/api/v1/user-groups/' + parseInt(params.id);+ return api.put(url, submission);+ }+}diff --git a/resources/assets/v3/js/boot/bootstrap.js b/resources/assets/v3/js/boot/bootstrap.jsindex 29da20f12d..1abccd71c5 100644--- a/resources/assets/v3/js/boot/bootstrap.js+++ b/resources/assets/v3/js/boot/bootstrap.js@@ -99,10 +99,10 @@ getFreshVariable('lastActivity').then((serverValue) => {}});// cancel or complete- tour.on('cancel', (eventOptions) => {+ tour.on('cancel', () => {site.post(window.routeForFinishedTour);});- tour.on('complete', (eventOptions) => {+ tour.on('complete', () => {site.post(window.routeForFinishedTour);});diff --git a/resources/assets/v3/js/pages/accounts/create.js b/resources/assets/v3/js/pages/accounts/create.jsindex 5952d23554..a4de558593 100644--- a/resources/assets/v3/js/pages/accounts/create.js+++ b/resources/assets/v3/js/pages/accounts/create.js@@ -22,6 +22,7 @@ import '../../boot/bootstrap.js';import sidebar from '../../pages/shared/sidebar.js';import dates from '../shared/dates.js';import i18next from "i18next";+import Alpine from "alpinejs";let create = function () {return {diff --git a/resources/assets/v3/js/pages/accounts/edit.js b/resources/assets/v3/js/pages/accounts/edit.jsindex 5c1087f7c1..fd107db713 100644--- a/resources/assets/v3/js/pages/accounts/edit.js+++ b/resources/assets/v3/js/pages/accounts/edit.js@@ -22,6 +22,7 @@ import '../../boot/bootstrap.js';import sidebar from '../../pages/shared/sidebar.js';import dates from '../shared/dates.js';import i18next from "i18next";+import Alpine from "alpinejs";let edit = function () {return {diff --git a/resources/assets/v3/js/pages/administrations/edit.js b/resources/assets/v3/js/pages/administrations/edit.jsindex 84601acba0..98b55d0ccd 100644--- a/resources/assets/v3/js/pages/administrations/edit.js+++ b/resources/assets/v3/js/pages/administrations/edit.js@@ -23,6 +23,9 @@ import sidebar from '../../pages/shared/sidebar.js';import dates from '../shared/dates.js';import i18next from "i18next";import Get from '../../api/model/currency/get.js';+import GetUserGroup from '../../api/user-group/get.js';+import Put from '../../api/user-group/put.js';+import Alpine from "alpinejs";let edit = function () {return {@@ -47,8 +50,7 @@ let edit = function () {this.downloadAdministration(administrationId);},downloadAdministration: function (id) {- // TODO use API code.- axios.get("./api/v1/user-groups/" + id).then((response) => {+ (new GetUserGroup).get(id, {}).then((response) => {let current = response.data.data;this.administration = {id: current.id,@@ -79,8 +81,7 @@ let edit = function () {currency_id: [],};- // disable button- $('#submitButton').prop("disabled", true);+ document.getElementById('submitButton').disabled = true;// collect datalet data = {@@ -89,8 +90,7 @@ let edit = function () {};// post!- // TODO use API code.- axios.put('./api/v1/user-groups/' + this.administration.id, data).then((response) => {+ (new Put).put(data, {id: this.administration.id}).then((response) => {let administrationId = parseInt(response.data.data.id);window.location.href = './administrations?user_group_id=' + administrationId + '&message=updated';}).catch((error) => {@@ -100,7 +100,7 @@ let edit = function () {this.errors.primary_currency_id = error.response.data.errors.primary_currency_id;// enable button again- $('#submitButton').prop("disabled", false);+ document.getElementById('submitButton').disabled = false;});if (e) {diff --git a/resources/assets/v3/js/pages/administrations/index.js b/resources/assets/v3/js/pages/administrations/index.jsindex 6956e8da08..f4452ef8ea 100644--- a/resources/assets/v3/js/pages/administrations/index.js+++ b/resources/assets/v3/js/pages/administrations/index.js@@ -22,6 +22,8 @@import '../../boot/bootstrap.js';import sidebar from '../../pages/shared/sidebar.js';import dates from '../shared/dates.js';+import Get from '../../api/user-group/get.js';+import Alpine from "alpinejs";let index = function () {return {@@ -35,8 +37,7 @@ let index = function () {},downloadAdministrations: function (page) {- // TODO use API endpoint.- axios.get("./api/v1/user-groups?page=" + page).then((response) => {+ (new Get).list({page: page}).then((response) => {for (let i in response.data.data) {if (Object.hasOwn(response.data.data, i)) {let current = response.data.data[i];@@ -51,7 +52,7 @@ let index = function () {}if (response.data.meta.pagination.current_page < response.data.meta.pagination.total_pages) {- this.downloadAdministrations(response.data.meta.pagination.current_page + 1);+ this.downloadAdministrations(parseInt(response.data.meta.pagination.current_page) + 1);}});},diff --git a/resources/assets/v3/js/pages/dashboard/boxes.js b/resources/assets/v3/js/pages/dashboard/boxes.jsindex a1a7d17c73..ffb9eddbe0 100644--- a/resources/assets/v3/js/pages/dashboard/boxes.js+++ b/resources/assets/v3/js/pages/dashboard/boxes.js@@ -21,7 +21,7 @@import Summary from "../../api/summary/index.js";import {format} from "date-fns";-import {getVariable} from "../../store/get-variable.js";+import {getVariables} from "../../store/get-variables.js";import formatMoney from "../../util/format-money.js";import {getCacheKey} from "../../support/get-cache-key.js";import {cleanupCache} from "../../support/cleanup-cache.js";@@ -70,7 +70,7 @@ export default () => ({this.boxData = response.data;window.store.set(boxesCacheKey, response.data);this.generateOptions(this.boxData);- }).catch((error) => {+ }).catch(() => {console.error('Request gave error.');});},@@ -83,9 +83,9 @@ export default () => ({// process new content:for (const i in data) {- if (data.hasOwnProperty(i)) {+ if (Object.hasOwn(data, i)) {const current = data[i];- if (!current.hasOwnProperty('key')) {+ if (!Object.hasOwn(current,'key')) {continue;}let key = current.key;@@ -97,7 +97,7 @@ export default () => ({// spent info is used in subtitle:if (key.startsWith('spent-in-')) {// prep subtitles (for later)- if (!subtitles.hasOwnProperty(current.currency_code)) {+ if (!Object.hasOwn(subtitles, current.currency_code)) {subtitles[current.currency_code] = '';}// append the amount spent.@@ -109,7 +109,7 @@ export default () => ({// earned info is used in subtitle:if (key.startsWith('earned-in-')) {// prep subtitles (for later)- if (!subtitles.hasOwnProperty(current.currency_code)) {+ if (!Object.hasOwn(subtitles, current.currency_code)) {subtitles[current.currency_code] = '';}// prepend the amount earned.@@ -143,7 +143,7 @@ export default () => ({}}for (let i in subtitles) {- if (subtitles.hasOwnProperty(i)) {+ if (Object.hasOwn(subtitles, i)) {this.balanceBox.subtitles.push(subtitles[i]);}}@@ -166,10 +166,10 @@ export default () => ({init() {// console.log('boxes init');// TODO can be replaced by "getVariables"- Promise.all([getVariable('viewRange'), getVariable('convert_to_primary', false)]).then((values) => {+ getVariables(['convert_to_primary']).then((values) => {// console.log('boxes after promises');afterPromises = true;- this.convertToPrimary = values[1];+ this.convertToPrimary = values[0];this.loadBoxes();});window.store.observe('end', () => {diff --git a/resources/assets/v3/js/pages/dashboard/dashboard.js b/resources/assets/v3/js/pages/dashboard/dashboard.jsindex 4d2f8262ae..cb9963911c 100644--- a/resources/assets/v3/js/pages/dashboard/dashboard.js+++ b/resources/assets/v3/js/pages/dashboard/dashboard.js@@ -21,9 +21,8 @@import '../../boot/bootstrap.js';import sidebar from '../../pages/shared/sidebar.js';import dates from '../shared/dates.js';--import boxes from './boxes.js';+import Alpine from "alpinejs";let index = function () {return {diff --git a/resources/assets/v3/js/pages/exchange-rates/index.js b/resources/assets/v3/js/pages/exchange-rates/index.jsindex 2a41ec5c65..98f9552e20 100644--- a/resources/assets/v3/js/pages/exchange-rates/index.js+++ b/resources/assets/v3/js/pages/exchange-rates/index.js@@ -23,6 +23,8 @@ import '../../boot/bootstrap.js';import sidebar from '../../pages/shared/sidebar.js';import dates from '../shared/dates.js';import i18next from "i18next";+import Alpine from 'alpinejs';+import Get from '../../api/model/currency/get.js';let index = function () {return {@@ -39,9 +41,9 @@ let index = function () {this.downloadCurrencies(1);},downloadCurrencies: function (page) {- axios.get("./api/v1/currencies?enabled=1&page=" + page).then((response) => {+ (new Get).list({enabled: 1, page: page}).then((response) => {for (let i in response.data.data) {- if (response.data.data.hasOwnProperty(i)) {+ if (Object.hasOwn(response.data.data, i)) {let current = response.data.data[i];if (current.attributes.enabled) {let currency = {diff --git a/resources/assets/v3/js/pages/exchange-rates/rates.js b/resources/assets/v3/js/pages/exchange-rates/rates.jsindex 8d04b84d51..6cc81aa41f 100644--- a/resources/assets/v3/js/pages/exchange-rates/rates.js+++ b/resources/assets/v3/js/pages/exchange-rates/rates.js@@ -24,6 +24,12 @@ import sidebar from '../../pages/shared/sidebar.js';import dates from '../shared/dates.js';import format from "date-fns/format";import i18next from "i18next";+import Post from '../../api/model/exchange-rate/post.js';+import Put from '../../api/model/exchange-rate/put.js';+import Delete from '../../api/model/exchange-rate/delete.js';+import Get from '../../api/model/currency/get.js';+import GetRate from '../../api/model/exchange-rate/get.js';+import Alpine from 'alpinejs';let rates = function () {return {@@ -66,8 +72,7 @@ let rates = function () {submitRate: function (e) {if (e) e.preventDefault();this.posting = true;-- axios.post("./api/v1/exchange-rates", {+ (new Post).post({from: this.from_code,to: this.to_code,rate: this.newRate,@@ -97,7 +102,7 @@ let rates = function () {this.updating = true;if (0 === parseInt(this.rates[index].rate_id)) {console.log('[a] POST, not PUT.');- axios.post('./api/v1/exchange-rates',+ (new Post).post({from: this.from_code,to: this.to_code,@@ -110,7 +115,7 @@ let rates = function () {}if (0 !== parseInt(this.rates[index].rate_id)) {console.log('[a] PUT, not POST.');- axios.put('./api/v1/exchange-rates/' + this.rates[index].rate_id, {rate: this.rates[index].rate})+ (new Put).put({rate: this.rates[index].rate}, {id: this.rates[index].rate_id}).then(() => {this.updating = false;});@@ -122,7 +127,7 @@ let rates = function () {if (0 === parseInt(this.rates[index].inverse_id)) {console.log('[b] POST, not PUT.');// post, not put- axios.post('./api/v1/exchange-rates',+ (new Post).post({// remember, this is in reverse.from: this.to_code,@@ -136,7 +141,7 @@ let rates = function () {}if (0 !== parseInt(this.rates[index].inverse_id)) {console.log('[b] PUT, not POST.');- axios.put('./api/v1/exchange-rates/' + this.rates[index].inverse_id, {rate: this.rates[index].inverse})+ (new Put).put({rate: this.rates[index].inverse}, {id: this.rates[index].inverse_id}).then(() => {this.updating = false;});@@ -154,10 +159,10 @@ let rates = function () {let inverseId = parseInt(this.rates[index].inverse_id);// delete A to Bif (rateId > 0) {- axios.delete('./api/v1/exchange-rates/' + rateId);+ (new Delete).delete(rateId);}if (inverseId > 0) {- axios.delete('./api/v1/exchange-rates/' + inverseId);+ (new Delete).delete(inverseId);}this.rates.splice(index, 1);@@ -181,14 +186,14 @@ let rates = function () {downloadCurrencies: function () {console.log('Now downloading currencies.');this.loading = true;- axios.get("./api/v1/currencies/" + this.from_code).then((response) => {+ (new Get).get(this.from_code).then((response) => {this.from = {id: response.data.data.id,code: response.data.data.attributes.code,name: response.data.data.attributes.name,}});- axios.get("./api/v1/currencies/" + this.to_code).then((response) => {+ (new Get).get(this.to_code).then((response) => {// console.log(response.data.data);this.to = {id: response.data.data.id,@@ -201,9 +206,9 @@ let rates = function () {this.tempRates = {};this.loading = true;console.log('Now downloading rates.', page);- axios.get('./api/v1/exchange-rates/' + this.from_code + '/' + this.to_code + '?page=' + page).then((response) => {+ (new GetRate).get(this.from_code, this.to_code, {page:page}).then((response) => {for (let i in response.data.data) {- if (response.data.data.hasOwnProperty(i)) {+ if (Object.hasOwn(response.data.data, i)) {console.log('Downloaded entry #' + i);let current = response.data.data[i];let date = new Date(current.attributes.date);@@ -228,7 +233,7 @@ let rates = function () {console.log('Key updated to "' + key + '"');}- if (!this.tempRates.hasOwnProperty(key)) {+ if (!Object.hasOwn(this.tempRates, key)) {console.log('New entry stored');this.tempRates[key] = {key: key,@@ -243,12 +248,12 @@ let rates = function () {}// inverse is not "" and existing inverse is ""?- if (this.tempRates.hasOwnProperty(key) && inverse !== '' && this.tempRates[key].inverse === '') {+ if (Object.hasOwn(this.tempRates, key) && inverse !== '' && this.tempRates[key].inverse === '') {this.tempRates[key].inverse = inverse;this.tempRates[key].inverse_id = inverse_id;}// rate is not "" and existing rate is ""?- if (this.tempRates.hasOwnProperty(key) && rate !== '' && this.tempRates[key].rate === '') {+ if (Object.hasOwn(this.tempRates, key) && rate !== '' && this.tempRates[key].rate === '') {this.tempRates[key].rate = rate;this.tempRates[key].rate_id = rate_id;}