mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-19 09:14:27 +08:00
support not in options for transaction type, transaction category and account filters
This commit is contained in:
@@ -74,6 +74,7 @@ export class TransactionExplorerConditionField implements NameValue {
|
|||||||
|
|
||||||
export enum TransactionExplorerConditionOperatorType {
|
export enum TransactionExplorerConditionOperatorType {
|
||||||
In = 'in',
|
In = 'in',
|
||||||
|
NotIn = 'notIn',
|
||||||
GreaterThan = 'greaterThan',
|
GreaterThan = 'greaterThan',
|
||||||
LessThan = 'lessThan',
|
LessThan = 'lessThan',
|
||||||
Equals = 'equals',
|
Equals = 'equals',
|
||||||
@@ -103,6 +104,7 @@ export class TransactionExplorerConditionOperator implements NameValue {
|
|||||||
private static readonly allInstancesByValue: Record<string, TransactionExplorerConditionOperator> = {};
|
private static readonly allInstancesByValue: Record<string, TransactionExplorerConditionOperator> = {};
|
||||||
|
|
||||||
public static readonly In = new TransactionExplorerConditionOperator('In', TransactionExplorerConditionOperatorType.In);
|
public static readonly In = new TransactionExplorerConditionOperator('In', TransactionExplorerConditionOperatorType.In);
|
||||||
|
public static readonly NotIn = new TransactionExplorerConditionOperator('Not in', TransactionExplorerConditionOperatorType.NotIn);
|
||||||
public static readonly GreaterThan = new TransactionExplorerConditionOperator('Greater than', TransactionExplorerConditionOperatorType.GreaterThan);
|
public static readonly GreaterThan = new TransactionExplorerConditionOperator('Greater than', TransactionExplorerConditionOperatorType.GreaterThan);
|
||||||
public static readonly LessThan = new TransactionExplorerConditionOperator('Less than', TransactionExplorerConditionOperatorType.LessThan);
|
public static readonly LessThan = new TransactionExplorerConditionOperator('Less than', TransactionExplorerConditionOperatorType.LessThan);
|
||||||
public static readonly Equals = new TransactionExplorerConditionOperator('Equal to', TransactionExplorerConditionOperatorType.Equals);
|
public static readonly Equals = new TransactionExplorerConditionOperator('Equal to', TransactionExplorerConditionOperatorType.Equals);
|
||||||
|
|||||||
@@ -1558,6 +1558,7 @@
|
|||||||
"Between": "Zwischen",
|
"Between": "Zwischen",
|
||||||
"Not between": "Nicht zwischen",
|
"Not between": "Nicht zwischen",
|
||||||
"In": "In",
|
"In": "In",
|
||||||
|
"Not in": "Not in",
|
||||||
"Has any": "Hat eines",
|
"Has any": "Hat eines",
|
||||||
"Has all": "Hat alle",
|
"Has all": "Hat alle",
|
||||||
"Not has any": "Hat keines",
|
"Not has any": "Hat keines",
|
||||||
|
|||||||
@@ -1558,6 +1558,7 @@
|
|||||||
"Between": "Between",
|
"Between": "Between",
|
||||||
"Not between": "Not between",
|
"Not between": "Not between",
|
||||||
"In": "In",
|
"In": "In",
|
||||||
|
"Not in": "Not in",
|
||||||
"Has any": "Has any",
|
"Has any": "Has any",
|
||||||
"Has all": "Has all",
|
"Has all": "Has all",
|
||||||
"Not has any": "Not has any",
|
"Not has any": "Not has any",
|
||||||
|
|||||||
@@ -1558,6 +1558,7 @@
|
|||||||
"Between": "Entre",
|
"Between": "Entre",
|
||||||
"Not between": "No entre",
|
"Not between": "No entre",
|
||||||
"In": "En",
|
"In": "En",
|
||||||
|
"Not in": "Not in",
|
||||||
"Has any": "Tiene cualquiera",
|
"Has any": "Tiene cualquiera",
|
||||||
"Has all": "Tiene todas",
|
"Has all": "Tiene todas",
|
||||||
"Not has any": "No tiene cualquiera",
|
"Not has any": "No tiene cualquiera",
|
||||||
|
|||||||
@@ -1558,6 +1558,7 @@
|
|||||||
"Between": "Entre",
|
"Between": "Entre",
|
||||||
"Not between": "Pas entre",
|
"Not between": "Pas entre",
|
||||||
"In": "In",
|
"In": "In",
|
||||||
|
"Not in": "Not in",
|
||||||
"Has any": "Has any",
|
"Has any": "Has any",
|
||||||
"Has all": "Has all",
|
"Has all": "Has all",
|
||||||
"Not has any": "Not has any",
|
"Not has any": "Not has any",
|
||||||
|
|||||||
@@ -1558,6 +1558,7 @@
|
|||||||
"Between": "Tra",
|
"Between": "Tra",
|
||||||
"Not between": "Non tra",
|
"Not between": "Non tra",
|
||||||
"In": "In",
|
"In": "In",
|
||||||
|
"Not in": "Not in",
|
||||||
"Has any": "Has any",
|
"Has any": "Has any",
|
||||||
"Has all": "Has all",
|
"Has all": "Has all",
|
||||||
"Not has any": "Not has any",
|
"Not has any": "Not has any",
|
||||||
|
|||||||
@@ -1558,6 +1558,7 @@
|
|||||||
"Between": "間",
|
"Between": "間",
|
||||||
"Not between": "間ではない",
|
"Not between": "間ではない",
|
||||||
"In": "In",
|
"In": "In",
|
||||||
|
"Not in": "Not in",
|
||||||
"Has any": "Has any",
|
"Has any": "Has any",
|
||||||
"Has all": "Has all",
|
"Has all": "Has all",
|
||||||
"Not has any": "Not has any",
|
"Not has any": "Not has any",
|
||||||
|
|||||||
@@ -1558,6 +1558,7 @@
|
|||||||
"Between": "ನಡುವೆ",
|
"Between": "ನಡುವೆ",
|
||||||
"Not between": "ನಡುವಲ್ಲ",
|
"Not between": "ನಡುವಲ್ಲ",
|
||||||
"In": "In",
|
"In": "In",
|
||||||
|
"Not in": "Not in",
|
||||||
"Has any": "Has any",
|
"Has any": "Has any",
|
||||||
"Has all": "Has all",
|
"Has all": "Has all",
|
||||||
"Not has any": "Not has any",
|
"Not has any": "Not has any",
|
||||||
|
|||||||
@@ -1558,6 +1558,7 @@
|
|||||||
"Between": "사이",
|
"Between": "사이",
|
||||||
"Not between": "사이 아님",
|
"Not between": "사이 아님",
|
||||||
"In": "In",
|
"In": "In",
|
||||||
|
"Not in": "Not in",
|
||||||
"Has any": "Has any",
|
"Has any": "Has any",
|
||||||
"Has all": "Has all",
|
"Has all": "Has all",
|
||||||
"Not has any": "Not has any",
|
"Not has any": "Not has any",
|
||||||
|
|||||||
@@ -1558,6 +1558,7 @@
|
|||||||
"Between": "Tussen",
|
"Between": "Tussen",
|
||||||
"Not between": "Niet tussen",
|
"Not between": "Niet tussen",
|
||||||
"In": "In",
|
"In": "In",
|
||||||
|
"Not in": "Not in",
|
||||||
"Has any": "Has any",
|
"Has any": "Has any",
|
||||||
"Has all": "Has all",
|
"Has all": "Has all",
|
||||||
"Not has any": "Not has any",
|
"Not has any": "Not has any",
|
||||||
|
|||||||
@@ -1558,6 +1558,7 @@
|
|||||||
"Between": "Entre",
|
"Between": "Entre",
|
||||||
"Not between": "Não entre",
|
"Not between": "Não entre",
|
||||||
"In": "Em",
|
"In": "Em",
|
||||||
|
"Not in": "Not in",
|
||||||
"Has any": "Contém algum",
|
"Has any": "Contém algum",
|
||||||
"Has all": "Contém todos",
|
"Has all": "Contém todos",
|
||||||
"Not has any": "Não contém nenhum",
|
"Not has any": "Não contém nenhum",
|
||||||
|
|||||||
@@ -1558,6 +1558,7 @@
|
|||||||
"Between": "Между",
|
"Between": "Между",
|
||||||
"Not between": "Не между",
|
"Not between": "Не между",
|
||||||
"In": "В",
|
"In": "В",
|
||||||
|
"Not in": "Not in",
|
||||||
"Has any": "Содержит любой",
|
"Has any": "Содержит любой",
|
||||||
"Has all": "Содержит все",
|
"Has all": "Содержит все",
|
||||||
"Not has any": "Не содержит любой",
|
"Not has any": "Не содержит любой",
|
||||||
|
|||||||
@@ -1558,6 +1558,7 @@
|
|||||||
"Between": "Med",
|
"Between": "Med",
|
||||||
"Not between": "Ni med",
|
"Not between": "Ni med",
|
||||||
"In": "V",
|
"In": "V",
|
||||||
|
"Not in": "Not in",
|
||||||
"Has any": "Vsebuje katerokoli",
|
"Has any": "Vsebuje katerokoli",
|
||||||
"Has all": "Vsebuje vse",
|
"Has all": "Vsebuje vse",
|
||||||
"Not has any": "Ne vsebuje nobene",
|
"Not has any": "Ne vsebuje nobene",
|
||||||
|
|||||||
@@ -1558,6 +1558,7 @@
|
|||||||
"Between": "இடையே",
|
"Between": "இடையே",
|
||||||
"Not between": "இடையில் இல்லை",
|
"Not between": "இடையில் இல்லை",
|
||||||
"In": "In",
|
"In": "In",
|
||||||
|
"Not in": "Not in",
|
||||||
"Has any": "ஏதேனும் உள்ளது",
|
"Has any": "ஏதேனும் உள்ளது",
|
||||||
"Has all": "அனைத்தும் உள்ளது",
|
"Has all": "அனைத்தும் உள்ளது",
|
||||||
"Not has any": "ஏதும் இல்லை",
|
"Not has any": "ஏதும் இல்லை",
|
||||||
|
|||||||
@@ -1558,6 +1558,7 @@
|
|||||||
"Between": "ระหว่าง",
|
"Between": "ระหว่าง",
|
||||||
"Not between": "ไม่อยู่ระหว่าง",
|
"Not between": "ไม่อยู่ระหว่าง",
|
||||||
"In": "In",
|
"In": "In",
|
||||||
|
"Not in": "Not in",
|
||||||
"Has any": "Has any",
|
"Has any": "Has any",
|
||||||
"Has all": "Has all",
|
"Has all": "Has all",
|
||||||
"Not has any": "Not has any",
|
"Not has any": "Not has any",
|
||||||
|
|||||||
@@ -1558,6 +1558,7 @@
|
|||||||
"Between": "Arasında",
|
"Between": "Arasında",
|
||||||
"Not between": "Arasında değil",
|
"Not between": "Arasında değil",
|
||||||
"In": "In",
|
"In": "In",
|
||||||
|
"Not in": "Not in",
|
||||||
"Has any": "Has any",
|
"Has any": "Has any",
|
||||||
"Has all": "Has all",
|
"Has all": "Has all",
|
||||||
"Not has any": "Not has any",
|
"Not has any": "Not has any",
|
||||||
|
|||||||
@@ -1558,6 +1558,7 @@
|
|||||||
"Between": "Між",
|
"Between": "Між",
|
||||||
"Not between": "Не між",
|
"Not between": "Не між",
|
||||||
"In": "In",
|
"In": "In",
|
||||||
|
"Not in": "Not in",
|
||||||
"Has any": "Has any",
|
"Has any": "Has any",
|
||||||
"Has all": "Has all",
|
"Has all": "Has all",
|
||||||
"Not has any": "Not has any",
|
"Not has any": "Not has any",
|
||||||
|
|||||||
@@ -1558,6 +1558,7 @@
|
|||||||
"Between": "Giữa",
|
"Between": "Giữa",
|
||||||
"Not between": "Không giữa",
|
"Not between": "Không giữa",
|
||||||
"In": "In",
|
"In": "In",
|
||||||
|
"Not in": "Not in",
|
||||||
"Has any": "Has any",
|
"Has any": "Has any",
|
||||||
"Has all": "Has all",
|
"Has all": "Has all",
|
||||||
"Not has any": "Not has any",
|
"Not has any": "Not has any",
|
||||||
|
|||||||
@@ -1558,6 +1558,7 @@
|
|||||||
"Between": "介于",
|
"Between": "介于",
|
||||||
"Not between": "不介于",
|
"Not between": "不介于",
|
||||||
"In": "在范围内",
|
"In": "在范围内",
|
||||||
|
"Not in": "不在范围内",
|
||||||
"Has any": "包含任意",
|
"Has any": "包含任意",
|
||||||
"Has all": "包含全部",
|
"Has all": "包含全部",
|
||||||
"Not has any": "不包含任意",
|
"Not has any": "不包含任意",
|
||||||
|
|||||||
@@ -1558,6 +1558,7 @@
|
|||||||
"Between": "介於",
|
"Between": "介於",
|
||||||
"Not between": "不介於",
|
"Not between": "不介於",
|
||||||
"In": "包含於",
|
"In": "包含於",
|
||||||
|
"Not in": "不包含於",
|
||||||
"Has any": "包含任一",
|
"Has any": "包含任一",
|
||||||
"Has all": "包含所有",
|
"Has all": "包含所有",
|
||||||
"Not has any": "不包含任一",
|
"Not has any": "不包含任一",
|
||||||
|
|||||||
+102
-33
@@ -301,16 +301,16 @@ export class TransactionExplorerQuery {
|
|||||||
|
|
||||||
switch (field) {
|
switch (field) {
|
||||||
case TransactionExplorerConditionField.TransactionType:
|
case TransactionExplorerConditionField.TransactionType:
|
||||||
condition = new TransactionExplorerTransactionTypeCondition([ TransactionType.Expense, TransactionType.Income, TransactionType.Transfer ]);
|
condition = new TransactionExplorerTransactionTypeCondition(TransactionExplorerConditionOperatorType.In, [ TransactionType.Expense, TransactionType.Income, TransactionType.Transfer ]);
|
||||||
break;
|
break;
|
||||||
case TransactionExplorerConditionField.TransactionCategory:
|
case TransactionExplorerConditionField.TransactionCategory:
|
||||||
condition = new TransactionExplorerTransactionCategoryCondition([]);
|
condition = new TransactionExplorerTransactionCategoryCondition(TransactionExplorerConditionOperatorType.In, []);
|
||||||
break;
|
break;
|
||||||
case TransactionExplorerConditionField.SourceAccount:
|
case TransactionExplorerConditionField.SourceAccount:
|
||||||
condition = new TransactionExplorerSourceAccountCondition([]);
|
condition = new TransactionExplorerSourceAccountCondition(TransactionExplorerConditionOperatorType.In, []);
|
||||||
break;
|
break;
|
||||||
case TransactionExplorerConditionField.DestinationAccount:
|
case TransactionExplorerConditionField.DestinationAccount:
|
||||||
condition = new TransactionExplorerDestinationAccountCondition([]);
|
condition = new TransactionExplorerDestinationAccountCondition(TransactionExplorerConditionOperatorType.In, []);
|
||||||
break;
|
break;
|
||||||
case TransactionExplorerConditionField.SourceAmount:
|
case TransactionExplorerConditionField.SourceAmount:
|
||||||
condition = new TransactionExplorerSourceAmountCondition(TransactionExplorerConditionOperatorType.Between, [0, 0]);
|
condition = new TransactionExplorerSourceAmountCondition(TransactionExplorerConditionOperatorType.Between, [0, 0]);
|
||||||
@@ -331,7 +331,7 @@ export class TransactionExplorerQuery {
|
|||||||
condition = new TransactionExplorerDescriptionCondition(TransactionExplorerConditionOperatorType.Contains, '');
|
condition = new TransactionExplorerDescriptionCondition(TransactionExplorerConditionOperatorType.Contains, '');
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
condition = new TransactionExplorerTransactionTypeCondition([ TransactionType.Expense, TransactionType.Income, TransactionType.Transfer ]);
|
condition = new TransactionExplorerTransactionTypeCondition(TransactionExplorerConditionOperatorType.In, [ TransactionType.Expense, TransactionType.Income, TransactionType.Transfer ]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -737,23 +737,23 @@ export class TransactionExplorerConditionWithRelation {
|
|||||||
|
|
||||||
switch (conditionField) {
|
switch (conditionField) {
|
||||||
case TransactionExplorerConditionField.TransactionType.value:
|
case TransactionExplorerConditionField.TransactionType.value:
|
||||||
if (conditionOperator === TransactionExplorerConditionOperatorType.In && Array.isArray(conditionValue)) {
|
if (TransactionExplorerTransactionTypeCondition.supportedOperators[conditionOperator] && Array.isArray(conditionValue)) {
|
||||||
condition = new TransactionExplorerTransactionTypeCondition(conditionValue as number[]);
|
condition = new TransactionExplorerTransactionTypeCondition(conditionOperator as TransactionTypeConditionOperator, conditionValue as number[]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TransactionExplorerConditionField.TransactionCategory.value:
|
case TransactionExplorerConditionField.TransactionCategory.value:
|
||||||
if (conditionOperator === TransactionExplorerConditionOperatorType.In && Array.isArray(conditionValue)) {
|
if (TransactionExplorerTransactionCategoryCondition.supportedOperators[conditionOperator] && Array.isArray(conditionValue)) {
|
||||||
condition = new TransactionExplorerTransactionCategoryCondition(conditionValue as string[]);
|
condition = new TransactionExplorerTransactionCategoryCondition(conditionOperator as TransactionCategoryConditionOperator, conditionValue as string[]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TransactionExplorerConditionField.SourceAccount.value:
|
case TransactionExplorerConditionField.SourceAccount.value:
|
||||||
if (conditionOperator === TransactionExplorerConditionOperatorType.In && Array.isArray(conditionValue)) {
|
if (TransactionExplorerSourceAccountCondition.supportedOperators[conditionOperator] && Array.isArray(conditionValue)) {
|
||||||
condition = new TransactionExplorerSourceAccountCondition(conditionValue as string[]);
|
condition = new TransactionExplorerSourceAccountCondition(conditionOperator as AccountConditionOperator, conditionValue as string[]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TransactionExplorerConditionField.DestinationAccount.value:
|
case TransactionExplorerConditionField.DestinationAccount.value:
|
||||||
if (conditionOperator === TransactionExplorerConditionOperatorType.In && Array.isArray(conditionValue)) {
|
if (TransactionExplorerDestinationAccountCondition.supportedOperators[conditionOperator] && Array.isArray(conditionValue)) {
|
||||||
condition = new TransactionExplorerDestinationAccountCondition(conditionValue as string[]);
|
condition = new TransactionExplorerDestinationAccountCondition(conditionOperator as AccountConditionOperator, conditionValue as string[]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TransactionExplorerConditionField.SourceAmount.value:
|
case TransactionExplorerConditionField.SourceAmount.value:
|
||||||
@@ -831,15 +831,20 @@ export class TransactionExplorerUndefinedCondition implements TransactionExplore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type TransactionTypeConditionOperator = TransactionExplorerConditionOperatorType.In |
|
||||||
|
TransactionExplorerConditionOperatorType.NotIn;
|
||||||
|
|
||||||
export class TransactionExplorerTransactionTypeCondition implements TransactionExplorerCondition<TransactionExplorerConditionFieldType.TransactionType, number[]> {
|
export class TransactionExplorerTransactionTypeCondition implements TransactionExplorerCondition<TransactionExplorerConditionFieldType.TransactionType, number[]> {
|
||||||
public static readonly supportedOperators: PartialRecord<TransactionExplorerConditionOperatorType, true> = {
|
public static readonly supportedOperators: PartialRecord<TransactionExplorerConditionOperatorType, true> = {
|
||||||
[TransactionExplorerConditionOperatorType.In]: true
|
[TransactionExplorerConditionOperatorType.In]: true,
|
||||||
|
[TransactionExplorerConditionOperatorType.NotIn]: true
|
||||||
};
|
};
|
||||||
public readonly field = TransactionExplorerConditionFieldType.TransactionType;
|
public readonly field = TransactionExplorerConditionFieldType.TransactionType;
|
||||||
public readonly operator: TransactionExplorerConditionOperatorType.In = TransactionExplorerConditionOperatorType.In;
|
public readonly operator: TransactionTypeConditionOperator = TransactionExplorerConditionOperatorType.In;
|
||||||
public value: number[];
|
public value: number[];
|
||||||
|
|
||||||
constructor(value: number[]) {
|
constructor(operator: TransactionTypeConditionOperator, value: number[]) {
|
||||||
|
this.operator = operator;
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -848,7 +853,13 @@ export class TransactionExplorerTransactionTypeCondition implements TransactionE
|
|||||||
}
|
}
|
||||||
|
|
||||||
public match(transaction: TransactionInsightDataItem): boolean {
|
public match(transaction: TransactionInsightDataItem): boolean {
|
||||||
return this.value.includes(transaction.type);
|
if (this.operator === TransactionExplorerConditionOperatorType.In) {
|
||||||
|
return this.value.includes(transaction.type);
|
||||||
|
} else if (this.operator === TransactionExplorerConditionOperatorType.NotIn) {
|
||||||
|
return !this.value.includes(transaction.type);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public toExpression(): string {
|
public toExpression(): string {
|
||||||
@@ -863,19 +874,31 @@ export class TransactionExplorerTransactionTypeCondition implements TransactionE
|
|||||||
return type.toString();
|
return type.toString();
|
||||||
}
|
}
|
||||||
}).join(', ');
|
}).join(', ');
|
||||||
return `type IN (${textualTypes})`;
|
|
||||||
|
if (this.operator === TransactionExplorerConditionOperatorType.In) {
|
||||||
|
return `type IN (${textualTypes})`;
|
||||||
|
} else if (this.operator === TransactionExplorerConditionOperatorType.NotIn) {
|
||||||
|
return `type NOT IN (${textualTypes})`;
|
||||||
|
} else {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type TransactionCategoryConditionOperator = TransactionExplorerConditionOperatorType.In |
|
||||||
|
TransactionExplorerConditionOperatorType.NotIn;
|
||||||
|
|
||||||
export class TransactionExplorerTransactionCategoryCondition implements TransactionExplorerCondition<TransactionExplorerConditionFieldType.TransactionCategory, string[]> {
|
export class TransactionExplorerTransactionCategoryCondition implements TransactionExplorerCondition<TransactionExplorerConditionFieldType.TransactionCategory, string[]> {
|
||||||
public static readonly supportedOperators: PartialRecord<TransactionExplorerConditionOperatorType, true> = {
|
public static readonly supportedOperators: PartialRecord<TransactionExplorerConditionOperatorType, true> = {
|
||||||
[TransactionExplorerConditionOperatorType.In]: true
|
[TransactionExplorerConditionOperatorType.In]: true,
|
||||||
|
[TransactionExplorerConditionOperatorType.NotIn]: true
|
||||||
};
|
};
|
||||||
public readonly field = TransactionExplorerConditionFieldType.TransactionCategory;
|
public readonly field = TransactionExplorerConditionFieldType.TransactionCategory;
|
||||||
public readonly operator: TransactionExplorerConditionOperatorType.In = TransactionExplorerConditionOperatorType.In;
|
public readonly operator: TransactionCategoryConditionOperator = TransactionExplorerConditionOperatorType.In;
|
||||||
public value: string[];
|
public value: string[];
|
||||||
|
|
||||||
constructor(value: string[]) {
|
constructor(operator: TransactionCategoryConditionOperator, value: string[]) {
|
||||||
|
this.operator = operator
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -884,7 +907,13 @@ export class TransactionExplorerTransactionCategoryCondition implements Transact
|
|||||||
}
|
}
|
||||||
|
|
||||||
public match(transaction: TransactionInsightDataItem): boolean {
|
public match(transaction: TransactionInsightDataItem): boolean {
|
||||||
return this.value.includes(transaction.primaryCategory?.id ?? '') || this.value.includes(transaction.secondaryCategory?.id ?? transaction.categoryId);
|
if (this.operator === TransactionExplorerConditionOperatorType.In) {
|
||||||
|
return this.value.includes(transaction.primaryCategory?.id ?? '') || this.value.includes(transaction.secondaryCategory?.id ?? transaction.categoryId);
|
||||||
|
} else if (this.operator === TransactionExplorerConditionOperatorType.NotIn) {
|
||||||
|
return !this.value.includes(transaction.primaryCategory?.id ?? '') && !this.value.includes(transaction.secondaryCategory?.id ?? transaction.categoryId);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public toExpression(allCategoriesMap: Record<string, TransactionCategory>): string {
|
public toExpression(allCategoriesMap: Record<string, TransactionCategory>): string {
|
||||||
@@ -901,19 +930,31 @@ export class TransactionExplorerTransactionCategoryCondition implements Transact
|
|||||||
return `'${id}'`;
|
return `'${id}'`;
|
||||||
}
|
}
|
||||||
}).filter(item => !!item).join(', ');
|
}).filter(item => !!item).join(', ');
|
||||||
return `category IN (${textualCategories})`;
|
|
||||||
|
if (this.operator === TransactionExplorerConditionOperatorType.In) {
|
||||||
|
return `category IN (${textualCategories})`;
|
||||||
|
} else if (this.operator === TransactionExplorerConditionOperatorType.NotIn) {
|
||||||
|
return `category NOT IN (${textualCategories})`;
|
||||||
|
} else {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type AccountConditionOperator = TransactionExplorerConditionOperatorType.In |
|
||||||
|
TransactionExplorerConditionOperatorType.NotIn;
|
||||||
|
|
||||||
export class TransactionExplorerSourceAccountCondition implements TransactionExplorerCondition<TransactionExplorerConditionFieldType.SourceAccount, string[]> {
|
export class TransactionExplorerSourceAccountCondition implements TransactionExplorerCondition<TransactionExplorerConditionFieldType.SourceAccount, string[]> {
|
||||||
public static readonly supportedOperators: PartialRecord<TransactionExplorerConditionOperatorType, true> = {
|
public static readonly supportedOperators: PartialRecord<TransactionExplorerConditionOperatorType, true> = {
|
||||||
[TransactionExplorerConditionOperatorType.In]: true
|
[TransactionExplorerConditionOperatorType.In]: true,
|
||||||
|
[TransactionExplorerConditionOperatorType.NotIn]: true
|
||||||
};
|
};
|
||||||
public readonly field = TransactionExplorerConditionFieldType.SourceAccount;
|
public readonly field = TransactionExplorerConditionFieldType.SourceAccount;
|
||||||
public readonly operator: TransactionExplorerConditionOperatorType.In = TransactionExplorerConditionOperatorType.In;
|
public readonly operator: AccountConditionOperator = TransactionExplorerConditionOperatorType.In;
|
||||||
public value: string[];
|
public value: string[];
|
||||||
|
|
||||||
constructor(value: string[]) {
|
constructor(operator: AccountConditionOperator, value: string[]) {
|
||||||
|
this.operator = operator;
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -922,7 +963,13 @@ export class TransactionExplorerSourceAccountCondition implements TransactionExp
|
|||||||
}
|
}
|
||||||
|
|
||||||
public match(transaction: TransactionInsightDataItem): boolean {
|
public match(transaction: TransactionInsightDataItem): boolean {
|
||||||
return this.value.includes(transaction.sourceAccountId);
|
if (this.operator === TransactionExplorerConditionOperatorType.In) {
|
||||||
|
return this.value.includes(transaction.sourceAccountId);
|
||||||
|
} else if (this.operator === TransactionExplorerConditionOperatorType.NotIn) {
|
||||||
|
return !this.value.includes(transaction.sourceAccountId);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public toExpression(allCategoriesMap: Record<string, TransactionCategory>, allAccountsMap: Record<string, Account>): string {
|
public toExpression(allCategoriesMap: Record<string, TransactionCategory>, allAccountsMap: Record<string, Account>): string {
|
||||||
@@ -939,19 +986,28 @@ export class TransactionExplorerSourceAccountCondition implements TransactionExp
|
|||||||
return `'${id}'`;
|
return `'${id}'`;
|
||||||
}
|
}
|
||||||
}).filter(item => !!item).join(', ');
|
}).filter(item => !!item).join(', ');
|
||||||
return `source_account IN (${textualAccounts})`;
|
|
||||||
|
if (this.operator === TransactionExplorerConditionOperatorType.In) {
|
||||||
|
return `source_account IN (${textualAccounts})`;
|
||||||
|
} else if (this.operator === TransactionExplorerConditionOperatorType.NotIn) {
|
||||||
|
return `source_account NOT IN (${textualAccounts})`;
|
||||||
|
} else {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class TransactionExplorerDestinationAccountCondition implements TransactionExplorerCondition<TransactionExplorerConditionFieldType.DestinationAccount, string[]> {
|
export class TransactionExplorerDestinationAccountCondition implements TransactionExplorerCondition<TransactionExplorerConditionFieldType.DestinationAccount, string[]> {
|
||||||
public static readonly supportedOperators: PartialRecord<TransactionExplorerConditionOperatorType, true> = {
|
public static readonly supportedOperators: PartialRecord<TransactionExplorerConditionOperatorType, true> = {
|
||||||
[TransactionExplorerConditionOperatorType.In]: true
|
[TransactionExplorerConditionOperatorType.In]: true,
|
||||||
|
[TransactionExplorerConditionOperatorType.NotIn]: true
|
||||||
};
|
};
|
||||||
public readonly field = TransactionExplorerConditionFieldType.DestinationAccount;
|
public readonly field = TransactionExplorerConditionFieldType.DestinationAccount;
|
||||||
public readonly operator: TransactionExplorerConditionOperatorType.In = TransactionExplorerConditionOperatorType.In;
|
public readonly operator: AccountConditionOperator = TransactionExplorerConditionOperatorType.In;
|
||||||
public value: string[];
|
public value: string[];
|
||||||
|
|
||||||
constructor(value: string[]) {
|
constructor(operator: AccountConditionOperator, value: string[]) {
|
||||||
|
this.operator = operator;
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -960,7 +1016,13 @@ export class TransactionExplorerDestinationAccountCondition implements Transacti
|
|||||||
}
|
}
|
||||||
|
|
||||||
public match(transaction: TransactionInsightDataItem): boolean {
|
public match(transaction: TransactionInsightDataItem): boolean {
|
||||||
return this.value.includes(transaction.destinationAccountId);
|
if (this.operator === TransactionExplorerConditionOperatorType.In) {
|
||||||
|
return this.value.includes(transaction.destinationAccountId);
|
||||||
|
} else if (this.operator === TransactionExplorerConditionOperatorType.NotIn) {
|
||||||
|
return !this.value.includes(transaction.destinationAccountId);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public toExpression(allCategoriesMap: Record<string, TransactionCategory>, allAccountsMap: Record<string, Account>): string {
|
public toExpression(allCategoriesMap: Record<string, TransactionCategory>, allAccountsMap: Record<string, Account>): string {
|
||||||
@@ -977,7 +1039,14 @@ export class TransactionExplorerDestinationAccountCondition implements Transacti
|
|||||||
return `'${id}'`;
|
return `'${id}'`;
|
||||||
}
|
}
|
||||||
}).filter(item => !!item).join(', ');
|
}).filter(item => !!item).join(', ');
|
||||||
return `destination_account IN (${textualAccounts})`;
|
|
||||||
|
if (this.operator === TransactionExplorerConditionOperatorType.In) {
|
||||||
|
return `destination_account IN (${textualAccounts})`;
|
||||||
|
} else if (this.operator === TransactionExplorerConditionOperatorType.NotIn) {
|
||||||
|
return `destination_account NOT IN (${textualAccounts})`;
|
||||||
|
} else {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user