fix: bank rules

This commit is contained in:
Ahmed Bouhuolia
2024-07-02 12:16:51 +02:00
parent 50861940a8
commit 8a09de9771
15 changed files with 87 additions and 55 deletions

View File

@@ -1,11 +1,11 @@
exports.up = function (knex) {
return knex.schema.table('uncategorized_cashflow_transactions', (table) => {
table.boolean('excluded');
table.datetime('excluded_at');
});
};
exports.down = function (knex) {
return knex.schema.table('uncategorized_cashflow_transactions', (table) => {
table.dropColumn('excluded');
table.dropColumn('excluded_at');
});
};

View File

@@ -98,14 +98,14 @@ export default class UncategorizedCashflowTransaction extends mixin(
* Filters the not excluded transactions.
*/
notExcluded(query) {
query.whereNull('excluded');
query.whereNull('excluded_at');
},
/**
* Filters the excluded transactions.
*/
excluded(query) {
query.where('excluded', true)
query.whereNotNull('excluded_at')
}
};
},

View File

@@ -34,7 +34,7 @@ export class ExcludeBankTransaction {
await UncategorizedCashflowTransaction.query(trx)
.findById(uncategorizedTransactionId)
.patch({
excluded: true,
excludedAt: new Date(),
});
});
}

View File

@@ -33,7 +33,7 @@ export class GetExcludedBankTransactionsService {
const { results, pagination } =
await UncategorizedCashflowTransaction.query()
.onBuild((q) => {
q.where('excluded', true);
q.modify('excluded');
q.orderBy('date', 'DESC');
if (_query.accountId) {

View File

@@ -34,7 +34,7 @@ export class UnexcludeBankTransaction {
await UncategorizedCashflowTransaction.query(trx)
.findById(uncategorizedTransactionId)
.patch({
excluded: null,
excludedAt: null,
});
});
}