batch adding transaction tags in import transaction tool
This commit is contained in:
@@ -1805,6 +1805,7 @@
|
||||
"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",
|
||||
"Batch Add Transaction Tags": "Batch Add 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",
|
||||
|
||||
@@ -1805,6 +1805,7 @@
|
||||
"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",
|
||||
"Batch Add Transaction Tags": "Batch Add 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",
|
||||
|
||||
@@ -1805,6 +1805,7 @@
|
||||
"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",
|
||||
"Batch Add Transaction Tags": "Batch Add 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",
|
||||
|
||||
@@ -1805,6 +1805,7 @@
|
||||
"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",
|
||||
"Batch Add Transaction Tags": "Batch Add 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",
|
||||
|
||||
@@ -1805,6 +1805,7 @@
|
||||
"Batch Replace Selected Accounts": "バッチ選択した口座を置き換えます",
|
||||
"Batch Replace Selected Destination Accounts": "バッチは選択した宛先口座を置き換えます",
|
||||
"Batch Replace Selected Transaction Tags": "Batch Replace Selected Transaction Tags",
|
||||
"Batch Add Transaction Tags": "Batch Add Transaction Tags",
|
||||
"Replace Invalid Expense Categories": "無効な支出カテゴリを置き換えます",
|
||||
"Replace Invalid Income Categories": "無効な収入カテゴリを置き換えます",
|
||||
"Replace Invalid Transfer Categories": "無効な振替カテゴリを置き換えます",
|
||||
|
||||
@@ -1805,6 +1805,7 @@
|
||||
"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",
|
||||
"Batch Add Transaction Tags": "Batch Add 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",
|
||||
|
||||
@@ -1805,6 +1805,7 @@
|
||||
"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",
|
||||
"Batch Add Transaction Tags": "Batch Add 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",
|
||||
|
||||
@@ -1805,6 +1805,7 @@
|
||||
"Batch Replace Selected Accounts": "Пакетная замена выбранных счетов",
|
||||
"Batch Replace Selected Destination Accounts": "Пакетная замена выбранных целевых счетов",
|
||||
"Batch Replace Selected Transaction Tags": "Batch Replace Selected Transaction Tags",
|
||||
"Batch Add Transaction Tags": "Batch Add Transaction Tags",
|
||||
"Replace Invalid Expense Categories": "Заменить недействительные категории расходов",
|
||||
"Replace Invalid Income Categories": "Заменить недействительные категории доходов",
|
||||
"Replace Invalid Transfer Categories": "Заменить недействительные категории переводов",
|
||||
|
||||
@@ -1805,6 +1805,7 @@
|
||||
"Batch Replace Selected Accounts": "Пакетна заміна вибраних рахунків",
|
||||
"Batch Replace Selected Destination Accounts": "Пакетна заміна вибраних цільових рахунків",
|
||||
"Batch Replace Selected Transaction Tags": "Batch Replace Selected Transaction Tags",
|
||||
"Batch Add Transaction Tags": "Batch Add Transaction Tags",
|
||||
"Replace Invalid Expense Categories": "Замінити недійсні категорії витрат",
|
||||
"Replace Invalid Income Categories": "Замінити недійсні категорії доходів",
|
||||
"Replace Invalid Transfer Categories": "Замінити недійсні категорії переказів",
|
||||
|
||||
@@ -1805,6 +1805,7 @@
|
||||
"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",
|
||||
"Batch Add Transaction Tags": "Batch Add 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ệ",
|
||||
|
||||
@@ -1805,6 +1805,7 @@
|
||||
"Batch Replace Selected Accounts": "批量替换选中的账户",
|
||||
"Batch Replace Selected Destination Accounts": "批量替换选中的目标账户",
|
||||
"Batch Replace Selected Transaction Tags": "批量替换选中的交易标签",
|
||||
"Batch Add Transaction Tags": "批量添加交易标签",
|
||||
"Replace Invalid Expense Categories": "替换无效的支出分类",
|
||||
"Replace Invalid Income Categories": "替换无效的收入分类",
|
||||
"Replace Invalid Transfer Categories": "替换无效的转账分类",
|
||||
|
||||
@@ -1805,6 +1805,7 @@
|
||||
"Batch Replace Selected Accounts": "批次替換選中的帳戶",
|
||||
"Batch Replace Selected Destination Accounts": "批次替換選中的目標帳戶",
|
||||
"Batch Replace Selected Transaction Tags": "批次替換選中的交易標籤",
|
||||
"Batch Add Transaction Tags": "批次新增交易標籤",
|
||||
"Replace Invalid Expense Categories": "替換無效的支出分類",
|
||||
"Replace Invalid Income Categories": "替換無效的收入分類",
|
||||
"Replace Invalid Transfer Categories": "替換無效的轉帳分類",
|
||||
|
||||
@@ -42,8 +42,8 @@ export class ImportTransaction implements ImportTransactionResponse {
|
||||
this.originalDestinationAccountCurrency = response.originalDestinationAccountCurrency;
|
||||
this.sourceAmount = response.sourceAmount;
|
||||
this.destinationAmount = response.destinationAmount || 0;
|
||||
this.tagIds = response.tagIds;
|
||||
this.originalTagNames = response.originalTagNames;
|
||||
this.tagIds = response.tagIds || [];
|
||||
this.originalTagNames = response.originalTagNames || [];
|
||||
this.comment = response.comment;
|
||||
this.geoLocation = response.geoLocation;
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
<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 === 'batchAdd' && type === 'tag'">{{ tt('Batch Add 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>
|
||||
@@ -189,7 +190,7 @@
|
||||
</template>
|
||||
</v-autocomplete>
|
||||
</v-col>
|
||||
<v-col cols="12" class="pt-0">
|
||||
<v-col cols="12" class="pt-0" v-if="mode === 'batchReplace' || mode === 'replaceInvalidItems'">
|
||||
<v-switch :disabled="loading"
|
||||
:label="tt('Remove Tag')" v-model="removeTag"/>
|
||||
</v-col>
|
||||
@@ -235,7 +236,7 @@ import {
|
||||
mdiPound
|
||||
} from '@mdi/js';
|
||||
|
||||
export type BatchReplaceDialogMode = 'batchReplace' | 'replaceInvalidItems';
|
||||
export type BatchReplaceDialogMode = 'batchReplace' | 'batchAdd' | 'replaceInvalidItems';
|
||||
export type BatchReplaceDialogDataType = 'expenseCategory' | 'incomeCategory' | 'transferCategory' | 'account' | 'destinationAccount' | 'tag';
|
||||
|
||||
type SnackBarType = InstanceType<typeof SnackBar>;
|
||||
@@ -291,10 +292,10 @@ function open(options: { mode: BatchReplaceDialogMode; type: BatchReplaceDialogD
|
||||
type.value = options.type;
|
||||
sourceItem.value = undefined;
|
||||
|
||||
if (mode.value === 'batchReplace') {
|
||||
invalidItems.value = undefined;
|
||||
} else if (mode.value === 'replaceInvalidItems') {
|
||||
if (mode.value === 'replaceInvalidItems') {
|
||||
invalidItems.value = options.invalidItems;
|
||||
} else {
|
||||
invalidItems.value = undefined;
|
||||
}
|
||||
|
||||
if (type.value === 'tag' && mode.value === 'batchReplace') {
|
||||
@@ -369,6 +370,10 @@ function confirm(): void {
|
||||
sourceItem: sourceItem.value,
|
||||
targetItem: targetItemValue
|
||||
});
|
||||
} else if (mode.value === 'batchAdd') {
|
||||
resolveFunc?.({
|
||||
targetItem: targetItemValue
|
||||
});
|
||||
} else if (mode.value === 'replaceInvalidItems') {
|
||||
resolveFunc?.({
|
||||
sourceItem: sourceItem.value,
|
||||
|
||||
@@ -671,6 +671,12 @@ const toolMenus = computed<ImportTransactionCheckDataMenu[]>(() => [
|
||||
disabled: isEditing.value || selectedImportTransactionCount.value < 1,
|
||||
onClick: () => showBatchReplaceDialog('tag', allOriginalTransactionTagNames.value)
|
||||
},
|
||||
{
|
||||
prependIcon: mdiFindReplace,
|
||||
title: tt('Batch Add Transaction Tags'),
|
||||
disabled: isEditing.value || selectedImportTransactionCount.value < 1,
|
||||
onClick: () => showBatchAddDialog('tag')
|
||||
},
|
||||
{
|
||||
prependIcon: mdiFindReplace,
|
||||
title: tt('Replace Invalid Expense Categories'),
|
||||
@@ -1485,7 +1491,7 @@ function showBatchReplaceDialog(type: BatchReplaceDialogDataType, allSourceTagIt
|
||||
updated = true;
|
||||
}
|
||||
} else if (type === 'tag') {
|
||||
let removeIndex: number[] = [];
|
||||
const removeIndex: number[] = [];
|
||||
|
||||
for (let tagIndex = 0; tagIndex < importTransaction.originalTagNames.length; tagIndex++) {
|
||||
const originalTagName = importTransaction.originalTagNames ? (importTransaction.originalTagNames[tagIndex] ?? '') : '';
|
||||
@@ -1522,6 +1528,69 @@ function showBatchReplaceDialog(type: BatchReplaceDialogDataType, allSourceTagIt
|
||||
});
|
||||
}
|
||||
|
||||
function showBatchAddDialog(type: BatchReplaceDialogDataType): void {
|
||||
if (isEditing.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
batchReplaceDialog.value?.open({
|
||||
mode: 'batchAdd',
|
||||
type: type
|
||||
}).then(result => {
|
||||
if (!result || !result.targetItem) {
|
||||
return;
|
||||
}
|
||||
|
||||
let updatedCount = 0;
|
||||
|
||||
if (props.importTransactions) {
|
||||
for (const importTransaction of props.importTransactions) {
|
||||
if (!importTransaction.selected) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let updated = false;
|
||||
|
||||
if (type === 'tag') {
|
||||
let containsTag = false;
|
||||
|
||||
for (const tagName of importTransaction.originalTagNames) {
|
||||
if (tagName === result.targetItem) {
|
||||
containsTag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!containsTag) {
|
||||
if (!importTransaction.tagIds) {
|
||||
importTransaction.tagIds = [];
|
||||
}
|
||||
|
||||
if (!importTransaction.originalTagNames) {
|
||||
importTransaction.originalTagNames = [];
|
||||
}
|
||||
|
||||
importTransaction.tagIds.push(result.targetItem);
|
||||
importTransaction.originalTagNames.push(allTagsMap.value[result.targetItem]?.name ?? '');
|
||||
updated = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (updated) {
|
||||
updatedCount++;
|
||||
updateTransactionData(importTransaction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (updatedCount > 0) {
|
||||
snackbar.value?.showMessage('format.misc.youHaveUpdatedTransactions', {
|
||||
count: getDisplayCount(updatedCount)
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function showReplaceInvalidItemDialog(type: BatchReplaceDialogDataType, invalidItems: NameValue[]): void {
|
||||
if (isEditing.value) {
|
||||
return;
|
||||
@@ -1584,7 +1653,7 @@ function showReplaceInvalidItemDialog(type: BatchReplaceDialogDataType, invalidI
|
||||
updated = true;
|
||||
}
|
||||
} else if (type === 'tag' && importTransaction.tagIds) {
|
||||
let removeIndex: number[] = [];
|
||||
const removeIndex: number[] = [];
|
||||
|
||||
for (let tagIndex = 0; tagIndex < importTransaction.tagIds.length; tagIndex++) {
|
||||
const tagId = importTransaction.tagIds[tagIndex] as string;
|
||||
|
||||
Reference in New Issue
Block a user