From ea1eb7b7bced66e8a49cbaf46a083604b3622154 Mon Sep 17 00:00:00 2001 From: isKonstantin Date: Fri, 22 Dec 2023 20:06:48 +0300 Subject: [PATCH] Accumulation support --- components/accounts/entry.vue | 15 +- components/accounts/tagGroup.vue | 26 +++- components/buttons/walletButton.vue | 16 ++ components/modal/account/edit.vue | 9 +- components/modal/accumulation/set.vue | 138 ++++++++++++++++++ components/modal/accumulation/stepEntry.vue | 51 +++++++ components/modal/transaction/edit/edit.vue | 2 +- .../modal/transaction/edit/internal.vue | 4 +- components/select/account.vue | 10 +- components/transactions/table/tableEntry.vue | 38 ++++- composables/useApiLoader.ts | 5 + lang/en-US.json | 24 ++- lang/ru-RU.json | 27 +++- libs/api/accumulations/AccumulationsApi.ts | 61 ++++++++ package-lock.json | 4 +- package.json | 2 +- pages/transactions.vue | 1 + 17 files changed, 406 insertions(+), 27 deletions(-) create mode 100644 components/buttons/walletButton.vue create mode 100644 components/modal/accumulation/set.vue create mode 100644 components/modal/accumulation/stepEntry.vue create mode 100644 libs/api/accumulations/AccumulationsApi.ts diff --git a/components/accounts/entry.vue b/components/accounts/entry.vue index c3664dd..29a2aa1 100644 --- a/components/accounts/entry.vue +++ b/components/accounts/entry.vue @@ -14,7 +14,7 @@ {{account.name}}

-
+
@@ -36,16 +36,23 @@ import HideButton from "~/components/buttons/hideButton.vue"; import EditButton from "~/components/buttons/editButton.vue"; import DeleteButton from "~/components/buttons/deleteButton.vue"; +import WalletButton from "~/components/buttons/walletButton.vue"; -const emit = defineEmits(['edit-modal']); +const emit = defineEmits(['edit-modal', 'accumulation-modal']); const props = defineProps({ - account: {} + account: { + required: true + }, + hideButtons: { + default: false, + required: false + } }) const { t, locale } = useI18n(); const { $currenciesApi, $accountsApi, $toastsManager } = useNuxtApp(); -const currency = (await $currenciesApi.getCurrencies()).value.find(c => c.currencyId === props.account.currencyId) +const currency = $currenciesApi.getCurrencies().value.find(c => c.currencyId === props.account.currencyId) const formatAmount = (delta) => { const formatter = Intl.NumberFormat(locale.value, { diff --git a/components/accounts/tagGroup.vue b/components/accounts/tagGroup.vue index 6f17c04..d6e75f4 100644 --- a/components/accounts/tagGroup.vue +++ b/components/accounts/tagGroup.vue @@ -22,9 +22,17 @@
- - - + + +
@@ -49,7 +57,8 @@ - + +
@@ -87,11 +96,11 @@ const hiddenAccounts = computed(() => props.accounts.filter((a) => a.hidden)); const createAccountModal = ref(false); const tagDeleteModal = ref(false); const tagEditModal = ref(false); +const accumulationSetModal = ref(false); const accountEditModal = ref(false); - const accountToEdit = ref(null); - +const accountToAccumulation = ref(null); const setHide = () => { emit('hide'); } @@ -109,6 +118,11 @@ const openEditAccountModal = (account) => { accountEditModal.value = true; } +const openAccumulationModal = (account) => { + accountToAccumulation.value = account; + accumulationSetModal.value = true; +} + const confirmDelete = () => { tagDeleteModal.value = false; diff --git a/components/buttons/walletButton.vue b/components/buttons/walletButton.vue new file mode 100644 index 0000000..b49cd75 --- /dev/null +++ b/components/buttons/walletButton.vue @@ -0,0 +1,16 @@ + + + + + \ No newline at end of file diff --git a/components/modal/account/edit.vue b/components/modal/account/edit.vue index 5825dc6..6d62a3e 100644 --- a/components/modal/account/edit.vue +++ b/components/modal/account/edit.vue @@ -24,7 +24,7 @@ v-model="tag" @change="syncTag"> - +
@@ -36,7 +36,9 @@ :maxlength="configs.maxDescriptionLength"> - @@ -75,6 +77,7 @@ import Default from "~/components/modal/transaction/create/default.vue"; import Internal from "~/components/modal/transaction/create/internal.vue"; +import WalletButton from "~/components/buttons/walletButton.vue"; const props = defineProps({ opened: { @@ -87,7 +90,7 @@ const props = defineProps({ } }) -const emit = defineEmits(['close']) +const emit = defineEmits(['close', 'openAccumulation']) const tab = ref(0); const { t } = useI18n(); diff --git a/components/modal/accumulation/set.vue b/components/modal/accumulation/set.vue new file mode 100644 index 0000000..9d6f32f --- /dev/null +++ b/components/modal/accumulation/set.vue @@ -0,0 +1,138 @@ + + + + + \ No newline at end of file diff --git a/components/modal/accumulation/stepEntry.vue b/components/modal/accumulation/stepEntry.vue new file mode 100644 index 0000000..b7a69d4 --- /dev/null +++ b/components/modal/accumulation/stepEntry.vue @@ -0,0 +1,51 @@ + + + + + \ No newline at end of file diff --git a/components/modal/transaction/edit/edit.vue b/components/modal/transaction/edit/edit.vue index b4d0db0..50d70fa 100644 --- a/components/modal/transaction/edit/edit.vue +++ b/components/modal/transaction/edit/edit.vue @@ -1,6 +1,6 @@ diff --git a/components/modal/transaction/edit/internal.vue b/components/modal/transaction/edit/internal.vue index b9844d1..a93a76d 100644 --- a/components/modal/transaction/edit/internal.vue +++ b/components/modal/transaction/edit/internal.vue @@ -123,7 +123,7 @@ const tagsTree = $transactionsTagsApi.getTagsTree(); const tagsMap = $transactionsTagsApi.getTagsTreeMap(); const excludeAccount = computed(() => { - if (!props.transaction) + if (!props.transaction || !props.opened) return null; return tab.value === 1 ? props.transaction.accountId : (props.transaction.metadata ? props.transaction.metadata.linkedTransaction.accountId : -1); @@ -147,7 +147,7 @@ watch(() => props.opened, (newV, oldV) => { }) const transactionToEdit = computed(() => { - if (!props.transaction) + if (!props.transaction || !props.opened) return null; return tab.value === 0 ? props.transaction : (props.transaction.metadata ? props.transaction.metadata.linkedTransaction : null); diff --git a/components/select/account.vue b/components/select/account.vue index 8d3d9ba..7ce3a29 100644 --- a/components/select/account.vue +++ b/components/select/account.vue @@ -20,6 +20,10 @@ const props = defineProps({ excludeAccount: { type: Number + }, + + currencyFilter: { + type: Number } }) @@ -27,13 +31,13 @@ const emit = defineEmits(['update:modelValue', 'selected']) const { t } = useI18n(); const {$accountsApi, $accountsTagsApi} = useNuxtApp(); -const tags = await $accountsTagsApi.getTags(); -const accounts = await $accountsApi.getAccounts(); +const tags = $accountsTagsApi.getTags(); +const accounts = $accountsApi.getAccounts(); const value = ref(props.modelValue || null); const getTagAccounts = (t) => { - return useArrayFilter(accounts, a => a.tagId === t.tagId).value + return useArrayFilter(accounts, a => a.tagId === t.tagId && (!props.currencyFilter || a.currencyId === props.currencyFilter)).value } const options = computed(() => { diff --git a/components/transactions/table/tableEntry.vue b/components/transactions/table/tableEntry.vue index e4ba4f0..532ad25 100644 --- a/components/transactions/table/tableEntry.vue +++ b/components/transactions/table/tableEntry.vue @@ -6,6 +6,8 @@ {{ formatDelta(transaction.delta, transaction.currencyId) }} + + {{ tagsMap.get(transaction.tagId).tag.name }} {{ new Date(transaction.createdAt).toLocaleString(locale, {year: 'numeric', month: 'numeric', day: 'numeric', hour: '2-digit', minute: '2-digit'}) }} {{ accountsMap.get(transaction.accountId).name }} @@ -25,7 +27,11 @@ {{ formatDelta(transaction.metadata.linkedTransaction.delta, transaction.metadata.linkedTransaction.currencyId) }}

+ + + +
@@ -59,15 +65,43 @@

+ {{ formatDelta(transaction.delta, transaction.currencyId) }} +

+ + + +
+
+ + + +
+
+ + + {{ tagsMap.get(transaction.tagId).tag.name }} + {{ new Date(transaction.createdAt).toLocaleString(locale, {year: 'numeric', month: 'numeric', day: 'numeric', hour: '2-digit', minute: '2-digit'}) }} + {{ accountsMap.get(transaction.accountId).name }} + + {{ transaction.description }} + + +