Skip to content

Open source personal finance application

chore(Currencies): stabilize names

ilkome03dc167ce501
diff --git a/components/amount/Amount.vue b/components/amount/Amount.vue
index 0d10020d..31687314 100644
--- a/components/amount/Amount.vue
+++ b/components/amount/Amount.vue
@@ -3,7 +3,7 @@ import useAmount from '~/components/amount/useAmount'
const props = withDefaults(defineProps<{
amount: number
- currency: string
+ currencyCode: string
colorize: string
type: number
align: string
@@ -14,7 +14,7 @@ const props = withDefaults(defineProps<{
isShowSign: true,
})
-const { baseCurrency, formatAmount, getCurrencySymbol, getAmountInBaseRate } = useAmount()
+const { baseCurrencyCode, formatAmount, getCurrencySymbol, getAmountInBaseRate } = useAmount()
const sign = props.type === 0 ? '-' : '+'
const alignClasses = computed(() => ({
@@ -42,17 +42,17 @@ const amountClasses = computed(() => ([{
:class="alignClasses"
)
.text-md.leading-none(v-if="isShowSign && sign === '-'") {{ sign }}
- .text-md.leading-none {{ formatAmount(amount, currency) }}
- .text-xs.leading-none {{ getCurrencySymbol(currency) }}
+ .text-md.leading-none {{ formatAmount(amount, currencyCode) }}
+ .text-xs.leading-none {{ getCurrencySymbol(currencyCode) }}
//- Base
.text-neutral-400.gap-1.flex.items-baseline.whitespace-nowrap.opacity-80(
- v-if="isShowBaseRate && currency !== baseCurrency"
+ v-if="isShowBaseRate && currencyCode !== baseCurrencyCode"
:class="alignClasses"
)
.text-xs.leading-none(v-if="isShowSign && sign === '-'") {{ sign }}
- .text-xs.leading-none {{ getAmountInBaseRate({ amount, currency }) }}
- .text-2xs.leading-none {{ getCurrencySymbol(baseCurrency) }}
+ .text-xs.leading-none {{ getAmountInBaseRate({ amount, currencyCode }) }}
+ .text-2xs.leading-none {{ getCurrencySymbol(baseCurrencyCode) }}
//- 0
template(v-if="amount === 0")
@@ -60,5 +60,5 @@ const amountClasses = computed(() => ([{
:class="alignClasses"
)
.text-md.leading-none.flex.items-baseline 0
- .text-xs.leading-none {{ getCurrencySymbol(currency) }}
+ .text-xs.leading-none {{ getCurrencySymbol(currencyCode) }}
</template>
diff --git a/components/amount/useAmount.ts b/components/amount/useAmount.ts
index 540cfc83..ec0ec8c2 100644
--- a/components/amount/useAmount.ts
+++ b/components/amount/useAmount.ts
@@ -29,31 +29,31 @@ function formatAmount(amount: number, currencyCode?: CurrencyCode) {
export default function useAmount() {
const { $store } = useNuxtApp()
- function getAmountInBaseRate({ amount, currency, noFormat }: {
+ function getAmountInBaseRate({ amount, currencyCode, noFormat }: {
amount: number
- currency: string // TODO: add typings
+ currencyCode: string // TODO: add typings
noFormat?: boolean
}) {
const rates = $store.state.currencies.rates
- const baseRate = $store.state.currencies.base
+ const baseCurrencyCode = $store.state.currencies.base
const amountInBaseRate = getAmountInRate({
amount,
- currency,
+ currencyCode,
rates,
- baseRate,
+ baseCurrencyCode,
})
if (noFormat)
return +amountInBaseRate
- return formatAmount(amountInBaseRate, baseRate)
+ return formatAmount(amountInBaseRate, baseCurrencyCode)
}
- const baseCurrency = computed(() => $store.state.currencies.base)
+ const baseCurrencyCode = computed(() => $store.state.currencies.base)
return {
- baseCurrency,
+ baseCurrencyCode,
formatAmount,
getCurrencySymbol,
diff --git a/components/chart/chartOprions.ts b/components/chart/chartOprions.ts
index b6788f2a..6ca77db3 100644
--- a/components/chart/chartOprions.ts
+++ b/components/chart/chartOprions.ts
@@ -114,7 +114,7 @@ export const options = {
backgroundColor: 'var(--color-item-main-active)',
},
},
- // valueFormatter: value => `${formatAmount(value)} ${getCurrencySymbol(baseCurrency.value)}`,
+ // valueFormatter: value => `${formatAmount(value)} ${getCurrencySymbol(baseCurrencyCode.value)}`,
// position(pos, params, dom, rect, size) {
// // tooltip will be fixed on the right if mouse hovering on the left,
diff --git a/components/layout/Sidebar.vue b/components/layout/Sidebar.vue
index da36c019..65102af8 100644
--- a/components/layout/Sidebar.vue
+++ b/components/layout/Sidebar.vue
@@ -57,7 +57,7 @@ function setWalletFilter(walletId: WalletID) {
.text-skin-item-base
Amount(
:amount="walletItem.amount"
- :currency="walletItem.currency"
+ :currencyCode="walletItem.currency"
:isShowSign="false"
)
diff --git a/components/stat/Filter.vue b/components/stat/Filter.vue
index 1d048110..48ef5cac 100644
--- a/components/stat/Filter.vue
+++ b/components/stat/Filter.vue
@@ -57,7 +57,7 @@ const onClearFilter = () => {
.text-sm.text-skin-item-base
Amount(
:amount="$store.getters['wallets/walletsTotal'][walletId]"
- :currency="walletItem.currency"
+ :currencyCode="walletItem.currency"
:type="3"
:isShowBaseRate="false"
:isShowSign="false"
diff --git a/components/stat/StatItem.vue b/components/stat/StatItem.vue
index 1a9609a3..b68366d0 100644
--- a/components/stat/StatItem.vue
+++ b/components/stat/StatItem.vue
@@ -6,7 +6,7 @@ export default {
biggest: { type: Number, required: true },
category: { type: Object, required: true },
categoryId: { type: String, required: true },
- currency: { type: String, required: true },
+ currencyCode: { type: String, required: true },
total: { type: Number, required: true },
type: { type: Number, required: true },
},
@@ -93,7 +93,7 @@ export default {
.statItem__amount.text-skin-item-base
Amount(
:amount="total"
- :currency="currency"
+ :currencyCode="currencyCode"
:type="type"
:isShowBaseRate="false"
)
diff --git a/components/stat/StatItemChildCatsItem.vue b/components/stat/StatItemChildCatsItem.vue
index 63b8ce1d..822e68ce 100644
--- a/components/stat/StatItemChildCatsItem.vue
+++ b/components/stat/StatItemChildCatsItem.vue
@@ -61,7 +61,7 @@ export default {
.statItem__amount.text-skin-item-base
Amount(
:amount="total"
- :currency="$store.state.currencies.base"
+ :currencyCode="$store.state.currencies.base"
:type="type"
:isShowBaseRate="false"
)
diff --git a/components/stat/StatItemRound.vue b/components/stat/StatItemRound.vue
index d89d7891..527c3d5c 100644
--- a/components/stat/StatItemRound.vue
+++ b/components/stat/StatItemRound.vue
@@ -7,7 +7,7 @@ export default {
props: {
category: { type: Object, required: true },
categoryId: { type: String, required: true },
- currency: { type: String, required: true },
+ currencyCode: { type: String, required: true },
total: { type: Number, required: true },
type: { type: Number, required: true },
},
@@ -49,7 +49,7 @@ export default {
.statItemRound__amount.js-getWidth.text-skin-item-base
Amount(
:amount="total"
- :currency="currency"
+ :currencyCode="currencyCode"
:type="type"
:isShowBaseRate="false"
)
diff --git a/components/stat/SummaryRowItemView.vue b/components/stat/SummaryRowItemView.vue
index e355fd51..5d70b710 100644
--- a/components/stat/SummaryRowItemView.vue
+++ b/components/stat/SummaryRowItemView.vue
@@ -23,7 +23,7 @@ export default {
.summaryItem__amount.text-skin-item-base
Amount(
:amount="amount"
- :currency="$store.state.currencies.base"
+ :currencyCode="$store.state.currencies.base"
:type="type"
:colorize="type === 0 ? 'expense' : 'income'"
:isShowBaseRate="false"
diff --git a/components/stat/group/Horizontal.vue b/components/stat/group/Horizontal.vue
index 47f6f191..321990e6 100644
--- a/components/stat/group/Horizontal.vue
+++ b/components/stat/group/Horizontal.vue
@@ -34,7 +34,7 @@ export default defineComponent({
:biggest="statPage.current[typeText].biggest"
:category="$store.state.categories.items[categoryId]"
:categoryId="categoryId"
- :currency="$store.state.currencies.base"
+ :currencyCode="$store.state.currencies.base"
:total="statPage.current.categories[categoryId][typeText]"
:type="typeNumber"
)
diff --git a/components/stat/group/Round.vue b/components/stat/group/Round.vue
index 27e2876e..3f75edf6 100644
--- a/components/stat/group/Round.vue
+++ b/components/stat/group/Round.vue
@@ -66,7 +66,7 @@ export default defineComponent({
v-for="categoryId in statPage.current[typeText].categoriesIds"
:category="$store.state.categories.items[categoryId]"
:categoryId="categoryId"
- :currency="$store.state.currencies.base"
+ :currencyCode="$store.state.currencies.base"
:key="categoryId"
:total="statPage.current.categories[categoryId][typeText]"
:type="typeNumber"
@@ -79,7 +79,7 @@ export default defineComponent({
v-if="statPage.filter.categoryId"
:category="$store.state.categories.items[categoryId]"
:categoryId="categoryId"
- :currency="$store.state.currencies.base"
+ :currencyCode="$store.state.currencies.base"
:key="categoryId"
:total="0"
:type="typeNumber"
diff --git a/components/stat/sum/Group.vue b/components/stat/sum/Group.vue
index 4abea336..2890998c 100644
--- a/components/stat/sum/Group.vue
+++ b/components/stat/sum/Group.vue
@@ -21,7 +21,7 @@ const typeNumber = computed(() => moneyTypes.find(t => t.id === `${props.typeTex
Amount(
:amount="statPage.current[typeText].total"
:colorize="typeText"
- :currency="$store.state.currencies.base"
+ :currencyCode="$store.state.currencies.base"
:isShowBaseRate="false"
:type="typeNumber"
)
diff --git a/components/stat/sum/Total.vue b/components/stat/sum/Total.vue
index 5042a268..cfed2772 100644
--- a/components/stat/sum/Total.vue
+++ b/components/stat/sum/Total.vue
@@ -14,7 +14,7 @@ const statAverage = computed(() => $store.getters['stat/statAverage'])
Amount(
:amount="statCurrentPeriod.income.total - statCurrentPeriod.expense.total"
:colorize="(statCurrentPeriod.income.total - statCurrentPeriod.expense.total) > 0 ? 'income' : 'expense'"
- :currency="$store.state.currencies.base"
+ :currencyCode="$store.state.currencies.base"
:isShowBaseRate="false"
:isShowSign="false"
:type="(statCurrentPeriod.income.total - statCurrentPeriod.expense.total) > 0 ? 1 : 0"
diff --git a/components/trnForm/ModalWallets.vue b/components/trnForm/ModalWallets.vue
index 94dc2784..f6c731ad 100644
--- a/components/trnForm/ModalWallets.vue
+++ b/components/trnForm/ModalWallets.vue
@@ -49,7 +49,7 @@ BaseBottomSheet(
.text-skin-item-base
Amount(
:amount="walletItem.amount"
- :currency="walletItem.currency"
+ :currencyCode="walletItem.currency"
:isShowSign="false"
)
</template>
diff --git a/components/trnForm/SelectedWallet.vue b/components/trnForm/SelectedWallet.vue
index 53e5eee2..d7316686 100644
--- a/components/trnForm/SelectedWallet.vue
+++ b/components/trnForm/SelectedWallet.vue
@@ -30,7 +30,7 @@ const wallet = computed(() => walletsItemsSorted.value[props.walletId])
.text-skin-item-base
Amount(
:amount="wallet.amount"
- :currency="wallet.currency"
+ :currencyCode="wallet.currency"
:isShowBaseRate="false"
:isShowSign="false"
align="left"
diff --git a/components/trnForm/TrnForm.vue b/components/trnForm/TrnForm.vue
index a24efec0..d265fed7 100644
--- a/components/trnForm/TrnForm.vue
+++ b/components/trnForm/TrnForm.vue
@@ -264,7 +264,7 @@ function handleSubmitForm() {
.text-sm
Amount(
:amount="walletItem.amount"
- :currency="walletItem.currency"
+ :currencyCode="walletItem.currency"
:isShowBaseRate="false"
align="left"
)
diff --git a/components/trns/getTotal.ts b/components/trns/getTotal.ts
index 686258e0..9b8dd2b2 100644
--- a/components/trns/getTotal.ts
+++ b/components/trns/getTotal.ts
@@ -5,20 +5,20 @@ import { TrnType } from '~/components/trns/types'
export function getAmountInRate({
amount,
- currency,
- baseRate,
+ currencyCode,
+ baseCurrencyCode,
rates,
}: {
amount: number
- currency: string
- baseRate: string // TODO: add typings
+ currencyCode: string
+ baseCurrencyCode: string // TODO: add typings
rates: Record<string, number> // TODO: add typings
}): number {
- if (!baseRate || !rates)
+ if (!baseCurrencyCode || !rates)
return amount
- if (baseRate !== currency)
- return amount / rates[currency] * rates[baseRate]
+ if (baseCurrencyCode !== currencyCode)
+ return amount / rates[currencyCode] * rates[baseCurrencyCode]
return amount
}
@@ -29,7 +29,7 @@ interface TotalProps {
walletsItems: Record<WalletID, WalletItem>
transferCategoriesIds?: CategoryID[]
walletsIds?: WalletID[]
- baseRate?: string // TODO: add typings
+ baseCurrencyCode?: string // TODO: add typings
rates?: Record<string, number> // TODO: add typings
}
@@ -43,13 +43,13 @@ export interface TotalReturns {
}
export function getTotal(props: TotalProps): TotalReturns {
- const { baseRate, rates, transferCategoriesIds, trnsIds, trnsItems, walletsIds, walletsItems } = props
+ const { baseCurrencyCode, rates, transferCategoriesIds, trnsIds, trnsItems, walletsIds, walletsItems } = props
- function getFormattedAmount(amount: number, currency: string) {
+ function getAmount(amount: number, currencyCode: string) {
return getAmountInRate({
amount,
- baseRate,
- currency,
+ baseCurrencyCode,
+ currencyCode,
rates,
})
}
@@ -66,7 +66,7 @@ export function getTotal(props: TotalProps): TotalReturns {
if (trn.type === TrnType.Income || trn.type === TrnType.Expense) {
const isTransferCategory = transferCategoriesIds?.includes(trn.categoryId)
const wallet = walletsItems[trn.walletId]
- const sum = getFormattedAmount(trn.amount, wallet.currency)
+ const sum = getAmount(trn.amount, wallet.currency)
// Income
if (trn.type === TrnType.Income) {
@@ -87,8 +87,8 @@ export function getTotal(props: TotalProps): TotalReturns {
else if (trn.type === TrnType.Transfer && 'incomeWalletId' in trn) {
const incomeWallet = walletsItems[trn.incomeWalletId]
const expenseWallet = walletsItems[trn.expenseWalletId]
- const incomeAmount = getFormattedAmount(trn.incomeAmount, incomeWallet.currency)
- const expenseAmount = getFormattedAmount(trn.expenseAmount, expenseWallet.currency)
+ const incomeAmount = getAmount(trn.incomeAmount, incomeWallet.currency)
+ const expenseAmount = getAmount(trn.expenseAmount, expenseWallet.currency)
// Include only selected wallets
if (walletsIds && walletsIds.length > 0) {
@@ -112,8 +112,8 @@ export function getTotal(props: TotalProps): TotalReturns {
else if (trn.type === TrnType.Transfer && 'walletFromId' in trn) {
const incomeWallet = walletsItems[trn.walletToId]
const expenseWallet = walletsItems[trn.walletFromId]
- const incomeAmount = getFormattedAmount(trn.amountTo, incomeWallet.currency)
- const expenseAmount = getFormattedAmount(trn.amountFrom, expenseWallet.currency)
+ const incomeAmount = getAmount(trn.amountTo, incomeWallet.currency)
+ const expenseAmount = getAmount(trn.amountFrom, expenseWallet.currency)
// Include only selected wallets
if (walletsIds && walletsIds.length > 0) {
diff --git a/components/trns/item/Details.vue b/components/trns/item/Details.vue
index 1b1f2e79..b862672d 100644
--- a/components/trns/item/Details.vue
+++ b/components/trns/item/Details.vue
@@ -82,7 +82,7 @@ export default {
.text-2xl.text-skin-item-base
Amount(
:amount="trn.expenseAmount"
- :currency="$store.state.wallets.items[trn.expenseWalletId].currency"
+ :currencyCode="$store.state.wallets.items[trn.expenseWalletId].currency"
:type="0"
align="center"
colorize="expense"
@@ -101,7 +101,7 @@ export default {
.text-2xl.text-skin-item-base
Amount(
:amount="trn.incomeAmount"
- :currency="$store.state.wallets.items[trn.incomeWalletId].currency"
+ :currencyCode="$store.state.wallets.items[trn.incomeWalletId].currency"
:type="1"
align="center"
colorize="income"
@@ -138,7 +138,7 @@ export default {
)
Amount(
:amount="trn.amount"
- :currency="wallet.currency"
+ :currencyCode="wallet.currency"
:colorize="trn.type === 0 ? 'expense' : 'income'"
:type="trn.type"
align="center"
diff --git a/components/trns/item/History.vue b/components/trns/item/History.vue
index 2d6e80e5..d79e1faf 100644
--- a/components/trns/item/History.vue
+++ b/components/trns/item/History.vue
@@ -90,7 +90,7 @@ const actions = {
)
Amount(
:amount="trnItem.expenseAmount || trnItem.amount"
- :currency="trnItem.expenseWallet.currency"
+ :currencyCode="trnItem.expenseWallet.currency"
:type="0"
verti
colorize="expense"
@@ -107,7 +107,7 @@ const actions = {
)
Amount(
:amount="trnItem.incomeAmount || trnItem.amount"
- :currency="trnItem.incomeWallet.currency"
+ :currencyCode="trnItem.incomeWallet.currency"
:type="1"
colorize="income"
)
@@ -119,7 +119,7 @@ const actions = {
)
Amount(
:amount="trnItem.amount"
- :currency="trnItem.wallet.currency"
+ :currencyCode="trnItem.wallet.currency"
:type="trnItem.type"
colorize="income"
)
diff --git a/components/trns/item/WithoutCat.vue b/components/trns/item/WithoutCat.vue
index 1ba422c2..64c1d8aa 100644
--- a/components/trns/item/WithoutCat.vue
+++ b/components/trns/item/WithoutCat.vue
@@ -56,7 +56,7 @@ export default defineComponent({
.cursor-pointer
Amount(
:amount="trnItem.amount"
- :currency="trnItem.wallet.currency"
+ :currencyCode="trnItem.wallet.currency"
:type="trnItem.type"
colorize="income"
@click="onOpenEdit"
diff --git a/components/wallets/Item.vue b/components/wallets/Item.vue
index 6d3f4b2d..4c5ddd16 100644
--- a/components/wallets/Item.vue
+++ b/components/wallets/Item.vue
@@ -44,7 +44,7 @@ export default defineComponent({
template(v-if="isShowAmount")
Amount(
:amount="wallet.total"
- :currency="wallet.currency"
+ :currencyCode="wallet.currency"
align="right"
)
</template>
diff --git a/components/wallets/ItemTotalSum.vue b/components/wallets/ItemTotalSum.vue
index de2cac0a..48b7131e 100644
--- a/components/wallets/ItemTotalSum.vue
+++ b/components/wallets/ItemTotalSum.vue
@@ -41,7 +41,7 @@ const total = computed(() => {
.text-xl
Amount(
:amount="total.expenseTransactions"
- :currency="wallet.currency"
+ :currencyCode="wallet.currency"
:type="0"
colorize="expense"
)
@@ -53,7 +53,7 @@ const total = computed(() => {
.text-xl
Amount(
:amount="total.incomeTransactions"
- :currency="wallet.currency"
+ :currencyCode="wallet.currency"
:type="1"
colorize="income"
)
@@ -65,7 +65,7 @@ const total = computed(() => {
.text-xl
Amount(
:amount="total.sumTransactions"
- :currency="wallet.currency"
+ :currencyCode="wallet.currency"
:type="3"
)
</template>
diff --git a/components/wallets/Total.vue b/components/wallets/Total.vue
index e3f0ee75..3d4c7949 100644
--- a/components/wallets/Total.vue
+++ b/components/wallets/Total.vue
@@ -21,7 +21,7 @@ const totalInWallets = computed(() => {
else {
walletTotal = getAmountInBaseRate({
amount: walletsTotal[walletId],
- currency: walletsItems[walletId].currency,
+ currencyCode: walletsItems[walletId].currency,
noFormat: true,
})
}
@@ -80,7 +80,7 @@ const counts = computed(() => ({
.text-skin-item-base
Amount(
- :currency="$store.state.currencies.base"
+ :currencyCode="$store.state.currencies.base"
:amount="item.value"
)
</template>
diff --git a/components/wallets/page/List.vue b/components/wallets/page/List.vue
index 4461fb8a..2de9b5ef 100644
--- a/components/wallets/page/List.vue
+++ b/components/wallets/page/List.vue
@@ -72,7 +72,7 @@ UiPage
//- Amount
Amount(
:amount="walletItem.amount"
- :currency="walletItem.currency"
+ :currencyCode="walletItem.currency"
)
template(#bottom)
diff --git a/components/wallets/page/id/Index.vue b/components/wallets/page/id/Index.vue
index bb3646f3..cf5b9346 100644
--- a/components/wallets/page/id/Index.vue
+++ b/components/wallets/page/id/Index.vue
@@ -70,7 +70,7 @@ UiPage(v-if="wallet")
.flex.text-3xl.font-normal
Amount(
:amount="total"
- :currency="wallet.currency"
+ :currencyCode="wallet.currency"
)
template(#actions)
diff --git a/pages/wallets/total.vue b/pages/wallets/total.vue
index dbdcafc5..22733273 100644
--- a/pages/wallets/total.vue
+++ b/pages/wallets/total.vue
@@ -14,7 +14,7 @@ import { getTrnsIds } from '~/components/trns/getTrns'
type DateValueOf = number
-const { baseCurrency, formatAmount, getCurrencySymbol } = useAmount()
+const { baseCurrencyCode, formatAmount, getCurrencySymbol } = useAmount()
const { $store } = useNuxtApp()
/**
@@ -84,13 +84,13 @@ function getPeriodsDates({ fromDate, periodName, periodsCount }: {
return periods
}
-const periodshey = computed(() => getPeriodsDates({
+const periodsGenerated = computed(() => getPeriodsDates({
fromDate: oldestTrnDate,
periodName: activePeriod.value,
periodsCount: maxPeriodsNumber.value,
}))
-const series = computed(() => periodshey.value.map((period) => {
+const series = computed(() => periodsGenerated.value.map((period) => {
const periodDates = getPeriodDates({ date: period.date, period: activePeriod.value })
const trnsIds = getTrnsIds({
fromDate: periodDates.from,
@@ -100,11 +100,11 @@ const series = computed(() => periodshey.value.map((period) => {
const categoriesItems = $store.state.categories.items
const walletsItems = $store.state.wallets.items
- const baseRate = $store.state.currencies.base
+ const baseCurrencyCode = $store.state.currencies.base
const rates = $store.state.currencies.rates
const transferCategoriesIds = getTransferCategoriesIds(categoriesItems)
const total = getTotal({
- baseRate,
+ baseCurrencyCode,
rates,
transferCategoriesIds,
trnsIds,
@@ -170,7 +170,7 @@ const chartOptions = computed(() => ({
}],
tooltip: {
- valueFormatter: value => `${formatAmount(value)} ${getCurrencySymbol(baseCurrency.value)}`,
+ valueFormatter: value => `${formatAmount(value)} ${getCurrencySymbol(baseCurrencyCode.value)}`,
},
dataZoom: [{
diff --git a/store/currencies/actions.ts b/store/currencies/actions.ts
index 65808cb8..cd783619 100644
--- a/store/currencies/actions.ts
+++ b/store/currencies/actions.ts
@@ -34,13 +34,13 @@ export default {
})
},
- async changeBaseCurrency({ commit }, baseCurrency) {
- commit('setBaseRate', baseCurrency)
+ async changeBaseCurrency({ commit }, baseCurrencyCode) {
+ commit('setBaseRate', baseCurrencyCode)
},
- setBaseCurrency({ rootState, dispatch }, baseCurrency) {
+ setBaseCurrency({ rootState, dispatch }, baseCurrencyCode) {
const uid = rootState.user.user.uid
- saveData(`users/${uid}/settings/baseCurrency`, baseCurrency)
+ saveData(`users/${uid}/settings/baseCurrency`, baseCurrencyCode)
dispatch('initCurrencies')
},
}
diff --git a/store/currencies/mutations.js b/store/currencies/mutations.js
index 75653686..8ba8e4c9 100644
--- a/store/currencies/mutations.js
+++ b/store/currencies/mutations.js
@@ -4,8 +4,8 @@ export default {
state.rates = rates
},
- setBaseRate(state, rate) {
- state.base = rate
+ setBaseRate(state, currencyCode) {
+ state.base = currencyCode
},
showBaseCurrenciesModal(state) {
diff --git a/store/stat/getters.ts b/store/stat/getters.ts
index 02deb2e5..832bb13e 100644
--- a/store/stat/getters.ts
+++ b/store/stat/getters.ts
@@ -11,7 +11,7 @@ export default {
const trnsItems = rootState.trns.items
const categoriesItems = rootState.categories.items
const walletsItems = rootState.wallets.items
- const baseRate = rootState.currencies.base
+ const baseCurrencyCode = rootState.currencies.base
const rates = rootState.currencies.rates
const storeFilter = rootState.filter
const transferCategoriesIds = getTransferCategoriesIds(categoriesItems)
@@ -66,7 +66,7 @@ export default {
const categoriesWithTrnsIds = getCatsIdsWithTrnsIds()
const total = getTotal({
- baseRate,
+ baseCurrencyCode,
rates,
trnsIds,
trnsItems,
@@ -80,7 +80,7 @@ export default {
const trnsIdsInCategory = categoriesWithTrnsIds[categoryId]
const totalInCategory = getTotal({
- baseRate,
+ baseCurrencyCode,
rates,
trnsIds: trnsIdsInCategory,
trnsItems,
@@ -163,7 +163,7 @@ export default {
const trnsItems = rootState.trns.items
const walletsItems = rootState.wallets.items
const categoriesItems = rootState.categories.items
- const baseRate = rootState.currencies.base
+ const baseCurrencyCode = rootState.currencies.base
const rates = rootState.currencies.rates
const trnsIds = rootGetters['trns/selectedTrnsIds']
const periodName = rootState.filter.period
@@ -197,7 +197,7 @@ export default {
)
const total = getTotal({
- baseRate,
+ baseCurrencyCode,
rates,
trnsIds: trnsIdsInPeriod,
trnsItems,
diff --git a/tests/getAmount.test.ts b/tests/getAmount.test.ts
index 215b6aef..e3cbbc6f 100644
--- a/tests/getAmount.test.ts
+++ b/tests/getAmount.test.ts
@@ -6,9 +6,9 @@ describe('Get amount', () => {
it('Get amount in same rate as base rate', () => {
const amountInBaseRate = getAmountInRate({
amount: 40,
- currency: 'USD',
+ currencyCode: 'USD',
rates,
- baseRate: 'USD',
+ baseCurrencyCode: 'USD',
})
expect(amountInBaseRate).toEqual(40)
@@ -17,9 +17,9 @@ describe('Get amount', () => {
it('Get amount in RUB when base rate is USD', () => {
const amountInBaseRate = getAmountInRate({
amount: 70,
- currency: 'RUB',
+ currencyCode: 'RUB',
rates,
- baseRate: 'USD',
+ baseCurrencyCode: 'USD',
})
expect(amountInBaseRate).toEqual(1.0810810810810811)
@@ -28,9 +28,9 @@ describe('Get amount', () => {
it('Get amount in RUB when base rate is EUR', () => {
const amountInBaseRate = getAmountInRate({
amount: 70,
- currency: 'RUB',
+ currencyCode: 'RUB',
rates,
- baseRate: 'EUR',
+ baseCurrencyCode: 'EUR',
})
expect(amountInBaseRate).toEqual(1.0383135135135135)
diff --git a/tests/getTotal.test.ts b/tests/getTotal.test.ts
index fc5a45e5..1af95a4d 100644
--- a/tests/getTotal.test.ts
+++ b/tests/getTotal.test.ts
@@ -31,10 +31,10 @@ describe('Total of Transactions', () => {
it('Total in RUB Wallet converted to USD', () => {
const trnsIds = ['transactionIncomeWalletOneRUB700']
- const baseRate = 'USD'
+ const baseCurrencyCode = 'USD'
const total = getTotal({
- baseRate,
+ baseCurrencyCode,
rates,
transferCategoriesIds,
trnsIds,
@@ -52,10 +52,10 @@ describe('Total of Transactions', () => {
it('Total in RUB Wallet converted to EUR', () => {
const trnsIds = ['transactionIncomeWalletOneRUB700']
- const baseRate = 'EUR'
+ const baseCurrencyCode = 'EUR'
const total = getTotal({
- baseRate,
+ baseCurrencyCode,
rates,
transferCategoriesIds,
trnsIds,
@@ -76,10 +76,10 @@ describe('Total of Transactions', () => {
'transactionIncomeWalletCashUSD1000',
'transactionExpenseWalletCashUSD400',
]
- const baseRate = 'USD'
+ const baseCurrencyCode = 'USD'
const total = getTotal({
- baseRate,
+ baseCurrencyCode,
rates,
transferCategoriesIds,
trnsIds,
@@ -100,10 +100,10 @@ describe('Total of Transactions', () => {
'transactionIncomeWalletOneRUB700',
'transactionExpenseWalletCashUSD400',
]
- const baseRate = 'EUR'
+ const baseCurrencyCode = 'EUR'
const total = getTotal({
- baseRate,
+ baseCurrencyCode,
rates,
transferCategoriesIds,
trnsIds,