batch removing specified tag or batch removing invalid tag in import transaction tool
This commit is contained in:
@@ -1804,6 +1804,7 @@
|
||||
"Batch Replace Selected Transfer Categories": "Ausgewählte Überweisungskategorien im Batch ersetzen",
|
||||
"Batch Replace Selected Accounts": "Ausgewählte Konten im Batch ersetzen",
|
||||
"Batch Replace Selected Destination Accounts": "Ausgewählte Zielkonten im Batch ersetzen",
|
||||
"Batch Replace Selected Transaction Tags": "Batch Replace Selected Transaction Tags",
|
||||
"Replace Invalid Expense Categories": "Ungültige Ausgabenkategorien ersetzen",
|
||||
"Replace Invalid Income Categories": "Ungültige Einnahmenkategorien ersetzen",
|
||||
"Replace Invalid Transfer Categories": "Ungültige Überweisungskategorien ersetzen",
|
||||
@@ -1829,6 +1830,7 @@
|
||||
"Target Account": "Zielkonto",
|
||||
"Invalid Tag": "Ungültiges Tag",
|
||||
"Target Tag": "Ziel-Tag",
|
||||
"Remove Tag": "Remove Tag",
|
||||
"(Empty)": "(Leer)",
|
||||
"Source Value": "Source Value",
|
||||
"Target Value": "Target Value",
|
||||
|
||||
@@ -1804,6 +1804,7 @@
|
||||
"Batch Replace Selected Transfer Categories": "Batch Replace Selected Transfer Categories",
|
||||
"Batch Replace Selected Accounts": "Batch Replace Selected Accounts",
|
||||
"Batch Replace Selected Destination Accounts": "Batch Replace Selected Destination Accounts",
|
||||
"Batch Replace Selected Transaction Tags": "Batch Replace Selected Transaction Tags",
|
||||
"Replace Invalid Expense Categories": "Replace Invalid Expense Categories",
|
||||
"Replace Invalid Income Categories": "Replace Invalid Income Categories",
|
||||
"Replace Invalid Transfer Categories": "Replace Invalid Transfer Categories",
|
||||
@@ -1829,6 +1830,7 @@
|
||||
"Target Account": "Target Account",
|
||||
"Invalid Tag": "Invalid Tag",
|
||||
"Target Tag": "Target Tag",
|
||||
"Remove Tag": "Remove Tag",
|
||||
"(Empty)": "(Empty)",
|
||||
"Source Value": "Source Value",
|
||||
"Target Value": "Target Value",
|
||||
|
||||
@@ -1804,6 +1804,7 @@
|
||||
"Batch Replace Selected Transfer Categories": "Reemplazar por lotes las categorías de transferencia seleccionadas",
|
||||
"Batch Replace Selected Accounts": "Reemplazo por lotes de cuentas seleccionadas",
|
||||
"Batch Replace Selected Destination Accounts": "Reemplazar por lotes cuentas de destino seleccionadas",
|
||||
"Batch Replace Selected Transaction Tags": "Batch Replace Selected Transaction Tags",
|
||||
"Replace Invalid Expense Categories": "Reemplazar categorías de gastos no válidas",
|
||||
"Replace Invalid Income Categories": "Reemplazar categorías de ingresos no válidas",
|
||||
"Replace Invalid Transfer Categories": "Reemplazar categorías de transferencia no válidas",
|
||||
@@ -1829,6 +1830,7 @@
|
||||
"Target Account": "Cuenta de destino",
|
||||
"Invalid Tag": "Etiqueta no válida",
|
||||
"Target Tag": "Etiqueta de destino",
|
||||
"Remove Tag": "Remove Tag",
|
||||
"(Empty)": "(Vacío)",
|
||||
"Source Value": "Source Value",
|
||||
"Target Value": "Target Value",
|
||||
|
||||
@@ -1804,6 +1804,7 @@
|
||||
"Batch Replace Selected Transfer Categories": "Sostituisci in blocco categorie di trasferimento selezionate",
|
||||
"Batch Replace Selected Accounts": "Sostituisci in blocco conti selezionati",
|
||||
"Batch Replace Selected Destination Accounts": "Sostituisci in blocco conti di destinazione selezionati",
|
||||
"Batch Replace Selected Transaction Tags": "Batch Replace Selected Transaction Tags",
|
||||
"Replace Invalid Expense Categories": "Sostituisci categorie di spesa non valide",
|
||||
"Replace Invalid Income Categories": "Sostituisci categorie di entrata non valide",
|
||||
"Replace Invalid Transfer Categories": "Sostituisci categorie di trasferimento non valide",
|
||||
@@ -1829,6 +1830,7 @@
|
||||
"Target Account": "Conto di destinazione",
|
||||
"Invalid Tag": "Tag non valido",
|
||||
"Target Tag": "Tag di destinazione",
|
||||
"Remove Tag": "Remove Tag",
|
||||
"(Empty)": "(Vuoto)",
|
||||
"Source Value": "Source Value",
|
||||
"Target Value": "Target Value",
|
||||
|
||||
@@ -1804,6 +1804,7 @@
|
||||
"Batch Replace Selected Transfer Categories": "バッチは選択した振替カテゴリを置き換えます",
|
||||
"Batch Replace Selected Accounts": "バッチ選択した口座を置き換えます",
|
||||
"Batch Replace Selected Destination Accounts": "バッチは選択した宛先口座を置き換えます",
|
||||
"Batch Replace Selected Transaction Tags": "Batch Replace Selected Transaction Tags",
|
||||
"Replace Invalid Expense Categories": "無効な支出カテゴリを置き換えます",
|
||||
"Replace Invalid Income Categories": "無効な収入カテゴリを置き換えます",
|
||||
"Replace Invalid Transfer Categories": "無効な振替カテゴリを置き換えます",
|
||||
@@ -1829,6 +1830,7 @@
|
||||
"Target Account": "対象口座",
|
||||
"Invalid Tag": "無効なタグ",
|
||||
"Target Tag": "対象タグ",
|
||||
"Remove Tag": "Remove Tag",
|
||||
"(Empty)": "(空)",
|
||||
"Source Value": "Source Value",
|
||||
"Target Value": "Target Value",
|
||||
|
||||
@@ -1804,6 +1804,7 @@
|
||||
"Batch Replace Selected Transfer Categories": "Geselecteerde overboekingscategorieën batchgewijs vervangen",
|
||||
"Batch Replace Selected Accounts": "Geselecteerde rekeningen batchgewijs vervangen",
|
||||
"Batch Replace Selected Destination Accounts": "Geselecteerde bestemmingsrekeningen batchgewijs vervangen",
|
||||
"Batch Replace Selected Transaction Tags": "Batch Replace Selected Transaction Tags",
|
||||
"Replace Invalid Expense Categories": "Ongeldige uitgavecategorieën vervangen",
|
||||
"Replace Invalid Income Categories": "Ongeldige inkomencategorieën vervangen",
|
||||
"Replace Invalid Transfer Categories": "Ongeldige overboekingscategorieën vervangen",
|
||||
@@ -1829,6 +1830,7 @@
|
||||
"Target Account": "Doelrekening",
|
||||
"Invalid Tag": "Ongeldige tag",
|
||||
"Target Tag": "Doeltag",
|
||||
"Remove Tag": "Remove Tag",
|
||||
"(Empty)": "(Leeg)",
|
||||
"Source Value": "Bronwaarde",
|
||||
"Target Value": "Doelwaarde",
|
||||
|
||||
@@ -1804,6 +1804,7 @@
|
||||
"Batch Replace Selected Transfer Categories": "Substituir em Lote as Categorias de Transferência Selecionadas",
|
||||
"Batch Replace Selected Accounts": "Substituir em Lote as Contas Selecionadas",
|
||||
"Batch Replace Selected Destination Accounts": "Substituir em Lote as Contas de Destino Selecionadas",
|
||||
"Batch Replace Selected Transaction Tags": "Batch Replace Selected Transaction Tags",
|
||||
"Replace Invalid Expense Categories": "Substituir Categorias de Despesas Inválidas",
|
||||
"Replace Invalid Income Categories": "Substituir Categorias de Renda Inválidas",
|
||||
"Replace Invalid Transfer Categories": "Substituir Categorias de Transferência Inválidas",
|
||||
@@ -1829,6 +1830,7 @@
|
||||
"Target Account": "Conta Alvo",
|
||||
"Invalid Tag": "Tag Inválida",
|
||||
"Target Tag": "Tag Alvo",
|
||||
"Remove Tag": "Remove Tag",
|
||||
"(Empty)": "(Vazio)",
|
||||
"Source Value": "Source Value",
|
||||
"Target Value": "Target Value",
|
||||
|
||||
@@ -1804,6 +1804,7 @@
|
||||
"Batch Replace Selected Transfer Categories": "Пакетная замена выбранных категорий переводов",
|
||||
"Batch Replace Selected Accounts": "Пакетная замена выбранных счетов",
|
||||
"Batch Replace Selected Destination Accounts": "Пакетная замена выбранных целевых счетов",
|
||||
"Batch Replace Selected Transaction Tags": "Batch Replace Selected Transaction Tags",
|
||||
"Replace Invalid Expense Categories": "Заменить недействительные категории расходов",
|
||||
"Replace Invalid Income Categories": "Заменить недействительные категории доходов",
|
||||
"Replace Invalid Transfer Categories": "Заменить недействительные категории переводов",
|
||||
@@ -1829,6 +1830,7 @@
|
||||
"Target Account": "Целевой счет",
|
||||
"Invalid Tag": "Недействительный тег",
|
||||
"Target Tag": "Целевой тег",
|
||||
"Remove Tag": "Remove Tag",
|
||||
"(Empty)": "(Пусто)",
|
||||
"Source Value": "Source Value",
|
||||
"Target Value": "Target Value",
|
||||
|
||||
@@ -1804,6 +1804,7 @@
|
||||
"Batch Replace Selected Transfer Categories": "Пакетна заміна вибраних категорій переказів",
|
||||
"Batch Replace Selected Accounts": "Пакетна заміна вибраних рахунків",
|
||||
"Batch Replace Selected Destination Accounts": "Пакетна заміна вибраних цільових рахунків",
|
||||
"Batch Replace Selected Transaction Tags": "Batch Replace Selected Transaction Tags",
|
||||
"Replace Invalid Expense Categories": "Замінити недійсні категорії витрат",
|
||||
"Replace Invalid Income Categories": "Замінити недійсні категорії доходів",
|
||||
"Replace Invalid Transfer Categories": "Замінити недійсні категорії переказів",
|
||||
@@ -1829,6 +1830,7 @@
|
||||
"Target Account": "Цільовий рахунок",
|
||||
"Invalid Tag": "Недійсний тег",
|
||||
"Target Tag": "Цільовий тег",
|
||||
"Remove Tag": "Remove Tag",
|
||||
"(Empty)": "(Порожньо)",
|
||||
"Source Value": "Source Value",
|
||||
"Target Value": "Target Value",
|
||||
|
||||
@@ -1804,6 +1804,7 @@
|
||||
"Batch Replace Selected Transfer Categories": "Thay thế hàng loạt các danh mục chuyển khoản đã chọn",
|
||||
"Batch Replace Selected Accounts": "Thay thế hàng loạt các tài khoản đã chọn",
|
||||
"Batch Replace Selected Destination Accounts": "Thay thế hàng loạt các tài khoản đích đã chọn",
|
||||
"Batch Replace Selected Transaction Tags": "Batch Replace Selected Transaction Tags",
|
||||
"Replace Invalid Expense Categories": "Thay thế các danh mục chi phí không hợp lệ",
|
||||
"Replace Invalid Income Categories": "Thay thế các danh mục thu nhập không hợp lệ",
|
||||
"Replace Invalid Transfer Categories": "Thay thế các danh mục chuyển khoản không hợp lệ",
|
||||
@@ -1829,6 +1830,7 @@
|
||||
"Target Account": "Tài khoản mục tiêu",
|
||||
"Invalid Tag": "Thẻ không hợp lệ",
|
||||
"Target Tag": "Thẻ mục tiêu",
|
||||
"Remove Tag": "Remove Tag",
|
||||
"(Empty)": "(Trống)",
|
||||
"Source Value": "Source Value",
|
||||
"Target Value": "Target Value",
|
||||
|
||||
@@ -1804,6 +1804,7 @@
|
||||
"Batch Replace Selected Transfer Categories": "批量替换选中的转账分类",
|
||||
"Batch Replace Selected Accounts": "批量替换选中的账户",
|
||||
"Batch Replace Selected Destination Accounts": "批量替换选中的目标账户",
|
||||
"Batch Replace Selected Transaction Tags": "批量替换选中的交易标签",
|
||||
"Replace Invalid Expense Categories": "替换无效的支出分类",
|
||||
"Replace Invalid Income Categories": "替换无效的收入分类",
|
||||
"Replace Invalid Transfer Categories": "替换无效的转账分类",
|
||||
@@ -1829,6 +1830,7 @@
|
||||
"Target Account": "目标账户",
|
||||
"Invalid Tag": "无效标签",
|
||||
"Target Tag": "目标标签",
|
||||
"Remove Tag": "删除标签",
|
||||
"(Empty)": "(空白)",
|
||||
"Source Value": "来源值",
|
||||
"Target Value": "目标值",
|
||||
|
||||
@@ -1804,6 +1804,7 @@
|
||||
"Batch Replace Selected Transfer Categories": "批次替換選中的轉帳分類",
|
||||
"Batch Replace Selected Accounts": "批次替換選中的帳戶",
|
||||
"Batch Replace Selected Destination Accounts": "批次替換選中的目標帳戶",
|
||||
"Batch Replace Selected Transaction Tags": "批次替換選中的交易標籤",
|
||||
"Replace Invalid Expense Categories": "替換無效的支出分類",
|
||||
"Replace Invalid Income Categories": "替換無效的收入分類",
|
||||
"Replace Invalid Transfer Categories": "替換無效的轉帳分類",
|
||||
@@ -1829,6 +1830,7 @@
|
||||
"Target Account": "目標帳戶",
|
||||
"Invalid Tag": "無效標籤",
|
||||
"Target Tag": "目標標籤",
|
||||
"Remove Tag": "移除標籤",
|
||||
"(Empty)": "(空白)",
|
||||
"Source Value": "來源值",
|
||||
"Target Value": "目標值",
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
<h4 class="text-h4" v-if="mode === 'batchReplace' && type === 'transferCategory'">{{ tt('Batch Replace Selected Transfer Categories') }}</h4>
|
||||
<h4 class="text-h4" v-if="mode === 'batchReplace' && type === 'account'">{{ tt('Batch Replace Selected Accounts') }}</h4>
|
||||
<h4 class="text-h4" v-if="mode === 'batchReplace' && type === 'destinationAccount'">{{ tt('Batch Replace Selected Destination Accounts') }}</h4>
|
||||
<h4 class="text-h4" v-if="mode === 'batchReplace' && type === 'tag'">{{ tt('Batch Replace Selected Transaction Tags') }}</h4>
|
||||
<h4 class="text-h4" v-if="mode === 'replaceInvalidItems' && type === 'expenseCategory'">{{ tt('Replace Invalid Expense Categories') }}</h4>
|
||||
<h4 class="text-h4" v-if="mode === 'replaceInvalidItems' && type === 'incomeCategory'">{{ tt('Replace Invalid Income Categories') }}</h4>
|
||||
<h4 class="text-h4" v-if="mode === 'replaceInvalidItems' && type === 'transferCategory'">{{ tt('Replace Invalid Transfer Categories') }}</h4>
|
||||
@@ -131,6 +132,19 @@
|
||||
</v-card-text>
|
||||
<v-card-text class="my-md-4 w-100 d-flex justify-center" v-if="type === 'tag'">
|
||||
<v-row>
|
||||
<v-col cols="12" v-if="mode === 'batchReplace'">
|
||||
<v-autocomplete
|
||||
item-title="name"
|
||||
item-value="value"
|
||||
persistent-placeholder
|
||||
:disabled="loading"
|
||||
:label="tt('Source Value')"
|
||||
:placeholder="tt('Source Value')"
|
||||
:items="allSourceTagItems"
|
||||
:no-data-text="tt('No available tag')"
|
||||
v-model="sourceItem">
|
||||
</v-autocomplete>
|
||||
</v-col>
|
||||
<v-col cols="12" v-if="mode === 'replaceInvalidItems'">
|
||||
<v-autocomplete
|
||||
item-title="name"
|
||||
@@ -150,7 +164,7 @@
|
||||
item-value="id"
|
||||
persistent-placeholder
|
||||
chips
|
||||
:disabled="loading"
|
||||
:disabled="loading || removeTag"
|
||||
:label="tt('Target Tag')"
|
||||
:placeholder="tt('Target Tag')"
|
||||
:items="allTags"
|
||||
@@ -175,11 +189,15 @@
|
||||
</template>
|
||||
</v-autocomplete>
|
||||
</v-col>
|
||||
<v-col cols="12" class="pt-0">
|
||||
<v-switch :disabled="loading"
|
||||
:label="tt('Remove Tag')" v-model="removeTag"/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-card-text>
|
||||
<v-card-text class="overflow-y-visible">
|
||||
<div class="w-100 d-flex justify-center gap-4">
|
||||
<v-btn :disabled="loading || (mode === 'replaceInvalidItems' && !sourceItem && sourceItem !== '') || (!targetItem && targetItem !== '')" @click="confirm">{{ tt('OK') }}</v-btn>
|
||||
<v-btn :disabled="loading || ((mode === 'replaceInvalidItems' || (mode === 'batchReplace' && type === 'tag')) && !sourceItem && sourceItem !== '') || (!targetItem && targetItem !== '' && !removeTag)" @click="confirm">{{ tt('OK') }}</v-btn>
|
||||
<v-btn color="secondary" variant="tonal" :disabled="loading" @click="cancel">{{ tt('Cancel') }}</v-btn>
|
||||
</div>
|
||||
</v-card-text>
|
||||
@@ -192,7 +210,7 @@
|
||||
<script setup lang="ts">
|
||||
import SnackBar from '@/components/desktop/SnackBar.vue';
|
||||
|
||||
import { ref, computed, useTemplateRef } from 'vue';
|
||||
import { ref, computed, useTemplateRef, watch } from 'vue';
|
||||
|
||||
import { useI18n } from '@/locales/helpers.ts';
|
||||
|
||||
@@ -241,8 +259,10 @@ const loading = ref<boolean>(false);
|
||||
const mode = ref<BatchReplaceDialogMode | ''>('');
|
||||
const type = ref<BatchReplaceDialogDataType | ''>('');
|
||||
const invalidItems = ref<NameValue[] | undefined>([]);
|
||||
const allSourceTagItems = ref<NameValue[] | undefined>([]);
|
||||
const sourceItem = ref<string | undefined>(undefined);
|
||||
const targetItem = ref<string | undefined>(undefined);
|
||||
const removeTag = ref<boolean>(false);
|
||||
|
||||
let resolveFunc: ((response: BatchReplaceDialogResponse) => void) | null = null;
|
||||
let rejectFunc: ((reason?: unknown) => void) | null = null;
|
||||
@@ -266,7 +286,7 @@ function getAccountDisplayName(accountId?: string): string {
|
||||
}
|
||||
}
|
||||
|
||||
function open(options: { mode: BatchReplaceDialogMode; type: BatchReplaceDialogDataType; invalidItems?: NameValue[] }): Promise<BatchReplaceDialogResponse> {
|
||||
function open(options: { mode: BatchReplaceDialogMode; type: BatchReplaceDialogDataType; invalidItems?: NameValue[], allSourceTagItems?: NameValue[] }): Promise<BatchReplaceDialogResponse> {
|
||||
mode.value = options.mode;
|
||||
type.value = options.type;
|
||||
sourceItem.value = undefined;
|
||||
@@ -277,7 +297,14 @@ function open(options: { mode: BatchReplaceDialogMode; type: BatchReplaceDialogD
|
||||
invalidItems.value = options.invalidItems;
|
||||
}
|
||||
|
||||
if (type.value === 'tag' && mode.value === 'batchReplace') {
|
||||
allSourceTagItems.value = options.allSourceTagItems;
|
||||
} else {
|
||||
allSourceTagItems.value = undefined;
|
||||
}
|
||||
|
||||
targetItem.value = undefined;
|
||||
removeTag.value = false;
|
||||
showState.value = true;
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
@@ -327,14 +354,25 @@ function reload(): void {
|
||||
}
|
||||
|
||||
function confirm(): void {
|
||||
if (mode.value === 'batchReplace') {
|
||||
let targetItemValue: string | undefined = targetItem.value;
|
||||
|
||||
if (type.value === 'tag' && removeTag.value) {
|
||||
targetItemValue = undefined;
|
||||
}
|
||||
|
||||
if (mode.value === 'batchReplace' && type.value !== 'tag') {
|
||||
resolveFunc?.({
|
||||
targetItem: targetItem.value
|
||||
targetItem: targetItemValue
|
||||
});
|
||||
} else if (mode.value === 'batchReplace' && type.value === 'tag') {
|
||||
resolveFunc?.({
|
||||
sourceItem: sourceItem.value,
|
||||
targetItem: targetItemValue
|
||||
});
|
||||
} else if (mode.value === 'replaceInvalidItems') {
|
||||
resolveFunc?.({
|
||||
sourceItem: sourceItem.value,
|
||||
targetItem: targetItem.value
|
||||
targetItem: targetItemValue
|
||||
});
|
||||
}
|
||||
|
||||
@@ -346,6 +384,12 @@ function cancel(): void {
|
||||
showState.value = false;
|
||||
}
|
||||
|
||||
watch(removeTag, (newValue) => {
|
||||
if (newValue) {
|
||||
targetItem.value = undefined;
|
||||
}
|
||||
});
|
||||
|
||||
defineExpose({
|
||||
open
|
||||
});
|
||||
|
||||
@@ -348,7 +348,7 @@ import { useAccountsStore } from '@/stores/account.ts';
|
||||
import { useTransactionCategoriesStore } from '@/stores/transactionCategory.ts';
|
||||
import { useTransactionTagsStore } from '@/stores/transactionTag.ts';
|
||||
|
||||
import { type NameValue, type NameNumeralValue, itemAndIndex, keys } from '@/core/base.ts';
|
||||
import { type NameValue, type NameNumeralValue, itemAndIndex, reversed, keys } from '@/core/base.ts';
|
||||
import { type NumeralSystem } from '@/core/numeral.ts';
|
||||
import { CategoryType } from '@/core/category.ts';
|
||||
import { TransactionType } from '@/core/transaction.ts';
|
||||
@@ -665,6 +665,12 @@ const toolMenus = computed<ImportTransactionCheckDataMenu[]>(() => [
|
||||
disabled: isEditing.value || selectedTransferTransactionCount.value < 1,
|
||||
onClick: () => showBatchReplaceDialog('destinationAccount')
|
||||
},
|
||||
{
|
||||
prependIcon: mdiFindReplace,
|
||||
title: tt('Batch Replace Selected Transaction Tags'),
|
||||
disabled: isEditing.value || selectedImportTransactionCount.value < 1,
|
||||
onClick: () => showBatchReplaceDialog('tag', allOriginalTransactionTagNames.value)
|
||||
},
|
||||
{
|
||||
prependIcon: mdiFindReplace,
|
||||
title: tt('Replace Invalid Expense Categories'),
|
||||
@@ -984,6 +990,7 @@ const allInvalidIncomeCategoryNames = computed<NameValue[]>(() => getCurrentInva
|
||||
const allInvalidTransferCategoryNames = computed<NameValue[]>(() => getCurrentInvalidCategoryNames(TransactionType.Transfer));
|
||||
const allInvalidAccountNames = computed<NameValue[]>(() => getCurrentInvalidAccountNames());
|
||||
const allInvalidTransactionTagNames = computed<NameValue[]>(() => getCurrentInvalidTagNames());
|
||||
const allOriginalTransactionTagNames = computed<NameValue[]>(() => getAllOriginalTagNames());
|
||||
|
||||
const displayFilterCustomDateRange = computed<string>(() => {
|
||||
if (filters.value.minDatetime === null || filters.value.maxDatetime === null) {
|
||||
@@ -1279,6 +1286,34 @@ function getCurrentInvalidTagNames(): NameValue[] {
|
||||
return invalidTags;
|
||||
}
|
||||
|
||||
function getAllOriginalTagNames(): NameValue[] {
|
||||
const allOriginalTagNames: Record<string, boolean> = {};
|
||||
const allOriginalTags: NameValue[] = [];
|
||||
|
||||
if (!props.importTransactions || props.importTransactions.length < 1) {
|
||||
return allOriginalTags;
|
||||
}
|
||||
|
||||
for (const importTransaction of props.importTransactions) {
|
||||
if (!importTransaction.originalTagNames) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (const tagName of importTransaction.originalTagNames) {
|
||||
allOriginalTagNames[tagName] = true;
|
||||
}
|
||||
}
|
||||
|
||||
for (const name of keys(allOriginalTagNames)) {
|
||||
allOriginalTags.push({
|
||||
name: name || tt('(Empty)'),
|
||||
value: name
|
||||
});
|
||||
}
|
||||
|
||||
return allOriginalTags;
|
||||
}
|
||||
|
||||
function importTransactionsFilter(value: string, query: string, item?: { value: unknown, raw: ImportTransaction }): boolean {
|
||||
if (!item || !item.raw) {
|
||||
return false;
|
||||
@@ -1396,19 +1431,26 @@ function updateTransactionData(transaction: ImportTransaction): void {
|
||||
}
|
||||
}
|
||||
|
||||
function showBatchReplaceDialog(type: BatchReplaceDialogDataType): void {
|
||||
function showBatchReplaceDialog(type: BatchReplaceDialogDataType, allSourceTagItems?: NameValue[]): void {
|
||||
if (isEditing.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
batchReplaceDialog.value?.open({
|
||||
mode: 'batchReplace',
|
||||
type: type
|
||||
type: type,
|
||||
allSourceTagItems: allSourceTagItems
|
||||
}).then(result => {
|
||||
if (!result || !result.targetItem) {
|
||||
if (!result) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (type !== 'tag') {
|
||||
if (!result.targetItem) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
let updatedCount = 0;
|
||||
|
||||
if (props.importTransactions) {
|
||||
@@ -1421,27 +1463,48 @@ function showBatchReplaceDialog(type: BatchReplaceDialogDataType): void {
|
||||
|
||||
if (type === 'expenseCategory') {
|
||||
if (importTransaction.type === TransactionType.Expense) {
|
||||
importTransaction.categoryId = result.targetItem;
|
||||
importTransaction.categoryId = result.targetItem as string;
|
||||
updated = true;
|
||||
}
|
||||
} else if (type === 'incomeCategory') {
|
||||
if (importTransaction.type === TransactionType.Income) {
|
||||
importTransaction.categoryId = result.targetItem;
|
||||
importTransaction.categoryId = result.targetItem as string;
|
||||
updated = true;
|
||||
}
|
||||
} else if (type === 'transferCategory') {
|
||||
if (importTransaction.type === TransactionType.Transfer) {
|
||||
importTransaction.categoryId = result.targetItem;
|
||||
importTransaction.categoryId = result.targetItem as string;
|
||||
updated = true;
|
||||
}
|
||||
} else if (type === 'account') {
|
||||
importTransaction.sourceAccountId = result.targetItem;
|
||||
importTransaction.sourceAccountId = result.targetItem as string;
|
||||
updated = true;
|
||||
} else if (type === 'destinationAccount') {
|
||||
if (importTransaction.type === TransactionType.Transfer) {
|
||||
importTransaction.destinationAccountId = result.targetItem;
|
||||
importTransaction.destinationAccountId = result.targetItem as string;
|
||||
updated = true;
|
||||
}
|
||||
} else if (type === 'tag') {
|
||||
let removeIndex: number[] = [];
|
||||
|
||||
for (let tagIndex = 0; tagIndex < importTransaction.originalTagNames.length; tagIndex++) {
|
||||
const originalTagName = importTransaction.originalTagNames ? (importTransaction.originalTagNames[tagIndex] ?? '') : '';
|
||||
|
||||
if (originalTagName === result.sourceItem) {
|
||||
if (result.targetItem) {
|
||||
importTransaction.tagIds[tagIndex] = result.targetItem;
|
||||
importTransaction.originalTagNames[tagIndex] = allTagsMap.value[result.targetItem]?.name || '';
|
||||
} else {
|
||||
removeIndex.push(tagIndex);
|
||||
}
|
||||
updated = true;
|
||||
}
|
||||
}
|
||||
|
||||
for (const tagIndex of reversed(removeIndex)) {
|
||||
importTransaction.tagIds.splice(tagIndex, 1);
|
||||
importTransaction.originalTagNames.splice(tagIndex, 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (updated) {
|
||||
@@ -1469,10 +1532,16 @@ function showReplaceInvalidItemDialog(type: BatchReplaceDialogDataType, invalidI
|
||||
type: type,
|
||||
invalidItems: invalidItems
|
||||
}).then(result => {
|
||||
if (!result || (!result.sourceItem && result.sourceItem !== '') || !result.targetItem) {
|
||||
if (!result || (!result.sourceItem && result.sourceItem !== '')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (type !== 'tag') {
|
||||
if (!result.targetItem) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
let updatedCount = 0;
|
||||
|
||||
if (props.importTransactions) {
|
||||
@@ -1489,13 +1558,13 @@ function showReplaceInvalidItemDialog(type: BatchReplaceDialogDataType, invalidI
|
||||
|
||||
if (importTransaction.type !== TransactionType.ModifyBalance && originalCategoryName === result.sourceItem && (!categoryId || categoryId === '0' || !allCategoriesMap.value[categoryId])) {
|
||||
if (type === 'expenseCategory' && importTransaction.type === TransactionType.Expense) {
|
||||
importTransaction.categoryId = result.targetItem;
|
||||
importTransaction.categoryId = result.targetItem as string;
|
||||
updated = true;
|
||||
} else if (type === 'incomeCategory' && importTransaction.type === TransactionType.Income) {
|
||||
importTransaction.categoryId = result.targetItem;
|
||||
importTransaction.categoryId = result.targetItem as string;
|
||||
updated = true;
|
||||
} else if (type === 'transferCategory' && importTransaction.type === TransactionType.Transfer) {
|
||||
importTransaction.categoryId = result.targetItem;
|
||||
importTransaction.categoryId = result.targetItem as string;
|
||||
updated = true;
|
||||
}
|
||||
}
|
||||
@@ -1506,24 +1575,36 @@ function showReplaceInvalidItemDialog(type: BatchReplaceDialogDataType, invalidI
|
||||
const originalDestinationAccountName = importTransaction.originalDestinationAccountName;
|
||||
|
||||
if (originalSourceAccountName === result.sourceItem && (!sourceAccountId || sourceAccountId === '0' || !allAccountsMap.value[sourceAccountId])) {
|
||||
importTransaction.sourceAccountId = result.targetItem;
|
||||
importTransaction.sourceAccountId = result.targetItem as string;
|
||||
updated = true;
|
||||
}
|
||||
|
||||
if (importTransaction.type === TransactionType.Transfer && originalDestinationAccountName === result.sourceItem && (!destinationAccountId || destinationAccountId === '0' || !allAccountsMap.value[destinationAccountId])) {
|
||||
importTransaction.destinationAccountId = result.targetItem;
|
||||
importTransaction.destinationAccountId = result.targetItem as string;
|
||||
updated = true;
|
||||
}
|
||||
} else if (type === 'tag' && importTransaction.tagIds) {
|
||||
let removeIndex: number[] = [];
|
||||
|
||||
for (let tagIndex = 0; tagIndex < importTransaction.tagIds.length; tagIndex++) {
|
||||
const tagId = importTransaction.tagIds[tagIndex] as string;
|
||||
const originalTagName = importTransaction.originalTagNames ? (importTransaction.originalTagNames[tagIndex] ?? '') : '';
|
||||
|
||||
if (originalTagName === result.sourceItem && (!tagId || tagId === '0' || !allTagsMap.value[tagId])) {
|
||||
importTransaction.tagIds[tagIndex] = result.targetItem;
|
||||
if (result.targetItem) {
|
||||
importTransaction.tagIds[tagIndex] = result.targetItem;
|
||||
importTransaction.originalTagNames[tagIndex] = allTagsMap.value[result.targetItem]?.name || '';
|
||||
} else {
|
||||
removeIndex.push(tagIndex);
|
||||
}
|
||||
updated = true;
|
||||
}
|
||||
}
|
||||
|
||||
for (const tagIndex of reversed(removeIndex)) {
|
||||
importTransaction.tagIds.splice(tagIndex, 1);
|
||||
importTransaction.originalTagNames.splice(tagIndex, 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (updated) {
|
||||
|
||||
Reference in New Issue
Block a user