mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 21:30:31 +00:00
fix: Edit bank rule
This commit is contained in:
@@ -115,17 +115,19 @@ export class GetAutofillCategorizeTransctionTransformer extends Transformer {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Retrieves the assigned category of recognized transaction, if is not recognized
|
||||
* returns the default transaction type depends on the transaction normal.
|
||||
* @returns {string}
|
||||
*/
|
||||
public transactionType() {
|
||||
const assignCategory =
|
||||
const assignedCategory =
|
||||
this.options.firstUncategorizedTransaction?.recognizedTransaction
|
||||
?.assignCategory || null;
|
||||
?.assignedCategory;
|
||||
|
||||
return assignCategory || this.isDepositTransaction()
|
||||
? 'other_income'
|
||||
: 'other_expense';
|
||||
return (
|
||||
assignedCategory ||
|
||||
(this.isDepositTransaction() ? 'other_income' : 'other_expense')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { lowerCase } from 'lodash';
|
||||
import UncategorizedCashflowTransaction from '@/models/UncategorizedCashflowTransaction';
|
||||
import {
|
||||
BankRuleApplyIfTransactionType,
|
||||
@@ -51,12 +52,15 @@ const matchNumberCondition = (
|
||||
const matchTextCondition = (
|
||||
transaction: UncategorizedCashflowTransaction,
|
||||
condition: IBankRuleCondition
|
||||
) => {
|
||||
): boolean => {
|
||||
switch (condition.comparator) {
|
||||
case BankRuleConditionComparator.Equals:
|
||||
return transaction[condition.field] === condition.value;
|
||||
case BankRuleConditionComparator.Contains:
|
||||
return transaction[condition.field]?.includes(condition.value.toString());
|
||||
const fieldValue = lowerCase(transaction[condition.field]);
|
||||
const conditionValue = lowerCase(condition.value);
|
||||
|
||||
return fieldValue.includes(conditionValue);
|
||||
case BankRuleConditionComparator.NotContain:
|
||||
return !transaction[condition.field]?.includes(
|
||||
condition.value.toString()
|
||||
@@ -101,4 +105,4 @@ const determineFieldType = (field: string): string => {
|
||||
default:
|
||||
return 'unknown';
|
||||
}
|
||||
};
|
||||
};
|
||||
@@ -64,9 +64,10 @@ export class EditBankRuleService {
|
||||
} as IBankRuleEventEditingPayload);
|
||||
|
||||
// Updates the given bank rule.
|
||||
await BankRule.query(trx)
|
||||
.findById(ruleId)
|
||||
.patch({ ...tranformDTO });
|
||||
await BankRule.query(trx).upsertGraphAndFetch({
|
||||
...tranformDTO,
|
||||
id: ruleId,
|
||||
});
|
||||
|
||||
// Triggers `onBankRuleEdited` event.
|
||||
await this.eventPublisher.emitAsync(events.bankRules.onEdited, {
|
||||
|
||||
@@ -16,7 +16,7 @@ export interface IBankRuleCondition {
|
||||
id?: number;
|
||||
field: BankRuleConditionField;
|
||||
comparator: BankRuleConditionComparator;
|
||||
value: number;
|
||||
value: string;
|
||||
}
|
||||
|
||||
export enum BankRuleConditionType {
|
||||
|
||||
Reference in New Issue
Block a user