From dfc73c7ff0dd47b19f610840129ecdca404e48d9 Mon Sep 17 00:00:00 2001 From: Jesus Guerrero Date: Fri, 24 Nov 2023 00:16:36 -0400 Subject: [PATCH] feat: add account filters --- .../Services/TransactionService.php | 14 ++-- package-lock.json | 71 +++++++++++-------- .../Finance/Partials/FinanceTemplate.vue | 12 ++-- resources/js/Pages/Finance/Transactions.vue | 16 +++-- .../transactions/components/AccountFilter.vue | 41 +++++++++++ .../components}/AccountFilters.vue | 0 6 files changed, 107 insertions(+), 47 deletions(-) create mode 100644 resources/js/domains/transactions/components/AccountFilter.vue rename resources/js/{Pages/Trends => domains/transactions/components}/AccountFilters.vue (100%) diff --git a/app/Domains/Transaction/Services/TransactionService.php b/app/Domains/Transaction/Services/TransactionService.php index 8a341790..7e0cd347 100644 --- a/app/Domains/Transaction/Services/TransactionService.php +++ b/app/Domains/Transaction/Services/TransactionService.php @@ -223,8 +223,8 @@ public function getNetWorthMonth($teamId, $endDate) public static function getNetWorth($teamId, $startDate, $endDate) { return DB::select(" - with data (month_date, total, type, balance_type, detail_type) AS ( - SELECT LAST_DAY(tl.date) as month_date, tl.amount * tl.type, tl.type, accounts.balance_type, adt.name + with data (date_unit, total, type, balance_type, detail_type) AS ( + SELECT LAST_DAY(tl.date) as date_unit, tl.amount * tl.type, tl.type, accounts.balance_type, adt.name FROM transaction_lines tl INNER JOIN transactions t on tl.transaction_id = t.id INNER JOIN accounts on tl.account_id = accounts.id @@ -234,12 +234,12 @@ public static function getNetWorth($teamId, $startDate, $endDate) AND tl.team_id = :teamId AND balance_type IS NOT null ) - SELECT month_date, - SUM(SUM(CASE WHEN balance_type = 'debit' THEN total ELSE 0 END)) over (ORDER BY month_date) as assets, - SUM(SUM(CASE WHEN balance_type = 'credit' THEN total ELSE 0 END)) over (ORDER BY month_date) as debts + SELECT date_unit, + SUM(SUM(CASE WHEN balance_type = 'debit' THEN total ELSE 0 END)) over (ORDER BY date_unit) as assets, + SUM(SUM(CASE WHEN balance_type = 'credit' THEN total ELSE 0 END)) over (ORDER BY date_unit) as debts FROM DATA - GROUP BY month_date - ORDER BY month_date DESC + GROUP BY date_unit + ORDER BY date_unit DESC LIMIT 12; ", [ 'teamId' => $teamId, diff --git a/package-lock.json b/package-lock.json index 23e5fd34..0bc82c40 100644 --- a/package-lock.json +++ b/package-lock.json @@ -35,7 +35,7 @@ "@vitejs/plugin-vue": "^4.5.0", "@vue/server-renderer": "^3.3.8", "@vueuse/core": "^10.6.1", - "atmosphere-ui": "^1.3.2", + "atmosphere-ui": "^1.3.3", "autoprefixer": "^10.4.15", "axios": "^1.4.0", "date-fns": "^2.30.0", @@ -53,13 +53,13 @@ "sass": "^1.69.5", "slug": "^8.2.3", "tailwindcss": "^3.3.5", - "typescript": "^5.2.2", - "unplugin-icons": "^0.16.6", + "typescript": "^5.3.2", + "unplugin-icons": "^0.17.4", "unplugin-vue-components": "^0.25.2", "uuid": "^9.0.1", "vite": "^4.5.0", - "vite-plugin-pwa": "^0.16.7", - "vue": "^3.3.4", + "vite-plugin-pwa": "^0.17.0", + "vue": "^3.3.8", "vue-multiselect": "^3.0.0-beta.3", "vue3-apexcharts": "^1.4.4", "vueuse-temporals": "^1.6.0" @@ -4017,9 +4017,9 @@ } }, "node_modules/atmosphere-ui": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/atmosphere-ui/-/atmosphere-ui-1.3.2.tgz", - "integrity": "sha512-wQW3o+UaWxzeWXwrB2ziDU/BJyHtuwGKXOIJMDlpE6rp24925wmryO0LKIV0dhMemSeCo7ZMoIMo6AVGahT3lg==", + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/atmosphere-ui/-/atmosphere-ui-1.3.3.tgz", + "integrity": "sha512-AjIGfvf/QeS41CqJ13kn++cLBcgFHDUvrSsREDX54QGnYGyFGuceEvsTJ6EZh+JKsOU4mtDEFSNlm1aJiaMShw==", "dev": true, "dependencies": { "@popperjs/core": "^2.11.8", @@ -6931,8 +6931,7 @@ "version": "3.2.0", "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.2.0.tgz", "integrity": "sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==", - "devOptional": true, - "peer": true + "devOptional": true }, "node_modules/jsonfile": { "version": "6.1.0", @@ -7380,7 +7379,6 @@ "resolved": "https://registry.npmjs.org/mlly/-/mlly-1.4.2.tgz", "integrity": "sha512-i/Ykufi2t1EZ6NaPLdfnZk2AX8cs0d+mTzVKuPfqPKPatxLApaBoxJQ9x1/uckXtrS/U5oisPMDkNs0yQTaBRg==", "devOptional": true, - "peer": true, "dependencies": { "acorn": "^8.10.0", "pathe": "^1.1.1", @@ -7771,8 +7769,7 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/pathe/-/pathe-1.1.1.tgz", "integrity": "sha512-d+RQGp0MAYTIaDBIMmOfMwz3E+LOZnxx1HZd5R18mmCZY0QBlK0LDZfPc8FW8Ed2DlvsuE6PRjroDY+wg4+j/Q==", - "devOptional": true, - "peer": true + "devOptional": true }, "node_modules/pathval": { "version": "1.1.1", @@ -7874,7 +7871,6 @@ "resolved": "https://registry.npmjs.org/pkg-types/-/pkg-types-1.0.3.tgz", "integrity": "sha512-nN7pYi0AQqJnoLPC9eHFQ8AcyaixBUOwvqc5TDnIKCMEE6I0y8P7OKA7fPexsXGCGxQDl/cmrLAp26LhcwxZ4A==", "devOptional": true, - "peer": true, "dependencies": { "jsonc-parser": "^3.2.0", "mlly": "^1.2.0", @@ -9449,9 +9445,9 @@ } }, "node_modules/typescript": { - "version": "5.2.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz", - "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==", + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.2.tgz", + "integrity": "sha512-6l+RyNy7oAHDfxC4FzSJcz9vnjTKxrLpDG5M2Vu4SHRVNg6xzqZp6LYSR9zjqQTu8DU/f5xwxUdADOkbrIX2gQ==", "devOptional": true, "bin": { "tsc": "bin/tsc", @@ -9465,8 +9461,7 @@ "version": "1.3.2", "resolved": "https://registry.npmjs.org/ufo/-/ufo-1.3.2.tgz", "integrity": "sha512-o+ORpgGwaYQXgqGDwd+hkS4PuZ3QnmqMMxRuajK/a38L6fTpcE5GPIfrf+L/KemFzfUpeUQc1rRS1iDBozvnFA==", - "devOptional": true, - "peer": true + "devOptional": true }, "node_modules/unbox-primitive": { "version": "1.0.2", @@ -9639,18 +9634,18 @@ } }, "node_modules/unplugin-icons": { - "version": "0.16.6", - "resolved": "https://registry.npmjs.org/unplugin-icons/-/unplugin-icons-0.16.6.tgz", - "integrity": "sha512-jL70sAC7twp4hI/MTfm+vyvTRtHqiEIzf3XOjJz7yzhMEEQnk5Ey5YIXRAU03Mc4BF99ITvvnBzfyRZee86OeA==", + "version": "0.17.4", + "resolved": "https://registry.npmjs.org/unplugin-icons/-/unplugin-icons-0.17.4.tgz", + "integrity": "sha512-PHLxjBx3ZV8RUBvfMafFl8uWH88jHeZgOijcRpkwgne7y2Ovx7WI0Ltzzw3fjZQ7dGaDhB8udyKVdm9N2S6BIw==", "dev": true, "dependencies": { "@antfu/install-pkg": "^0.1.1", "@antfu/utils": "^0.7.6", - "@iconify/utils": "^2.1.9", + "@iconify/utils": "^2.1.11", "debug": "^4.3.4", "kolorist": "^1.8.0", - "local-pkg": "^0.4.3", - "unplugin": "^1.4.0" + "local-pkg": "^0.5.0", + "unplugin": "^1.5.0" }, "funding": { "url": "https://github.com/sponsors/antfu" @@ -9680,6 +9675,22 @@ } } }, + "node_modules/unplugin-icons/node_modules/local-pkg": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/local-pkg/-/local-pkg-0.5.0.tgz", + "integrity": "sha512-ok6z3qlYyCDS4ZEU27HaU6x/xZa9Whf8jD4ptH5UZTQYZVYeb9bnZ3ojVhiJNLiXK1Hfc0GNbLXcmZ5plLDDBg==", + "dev": true, + "dependencies": { + "mlly": "^1.4.2", + "pkg-types": "^1.0.3" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + } + }, "node_modules/unplugin-vue-components": { "version": "0.25.2", "resolved": "https://registry.npmjs.org/unplugin-vue-components/-/unplugin-vue-components-0.25.2.tgz", @@ -9979,13 +9990,13 @@ } }, "node_modules/vite-plugin-pwa": { - "version": "0.16.7", - "resolved": "https://registry.npmjs.org/vite-plugin-pwa/-/vite-plugin-pwa-0.16.7.tgz", - "integrity": "sha512-4WMA5unuKlHs+koNoykeuCfTcqEGbiTRr8sVYUQMhc6tWxZpSRnv9Ojk4LKmqVhoPGHfBVCdGaMo8t9Qidkc1Q==", + "version": "0.17.0", + "resolved": "https://registry.npmjs.org/vite-plugin-pwa/-/vite-plugin-pwa-0.17.0.tgz", + "integrity": "sha512-cOyEG8EEc7JHmyMapTnjK2j0g2BIC3ErlmOHyGzVu8hqjyF9Jt6yWMmVNFtpA6v/NNyzP28ARf3vwzIAzR1kaw==", "dev": true, "dependencies": { "debug": "^4.3.4", - "fast-glob": "^3.3.1", + "fast-glob": "^3.3.2", "pretty-bytes": "^6.1.1", "workbox-build": "^7.0.0", "workbox-window": "^7.0.0" @@ -9997,7 +10008,7 @@ "url": "https://github.com/sponsors/antfu" }, "peerDependencies": { - "vite": "^3.1.0 || ^4.0.0 || ^5.0.0-0", + "vite": "^3.1.0 || ^4.0.0 || ^5.0.0", "workbox-build": "^7.0.0", "workbox-window": "^7.0.0" } diff --git a/resources/js/Pages/Finance/Partials/FinanceTemplate.vue b/resources/js/Pages/Finance/Partials/FinanceTemplate.vue index edbd0d05..5f3b3162 100644 --- a/resources/js/Pages/Finance/Partials/FinanceTemplate.vue +++ b/resources/js/Pages/Finance/Partials/FinanceTemplate.vue @@ -6,8 +6,6 @@ import { useImportModal } from '@/domains/transactions/useImportModal'; import { PANEL_SIZES } from '@/utils/constants'; - const { toggleModal: toggleImportModal } = useImportModal(); - const props = defineProps({ title: { type: String @@ -32,6 +30,9 @@ }, forceShowPanel: { type: Boolean, + }, + hidePanel: { + type: Boolean } }); @@ -53,11 +54,14 @@