-
-
Notifications
You must be signed in to change notification settings - Fork 245
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #523 from bigcapitalhq/matching-transactions-fixes
fix: Matching transactions bugs
- Loading branch information
Showing
32 changed files
with
389 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 6 additions & 1 deletion
7
...ations/20240618175241_add_recognized_transaction_id_to_uncategorized_transactins_table.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 5 additions & 1 deletion
6
...s/server/src/database/migrations/20240619133733_create_matched_bank_transactions_table.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { ImportFilePreviewPOJO } from "@/services/Import/interfaces"; | ||
|
||
|
||
export interface IImportFileCommitedEventPayload { | ||
tenantId: number; | ||
importId: number; | ||
meta: ImportFilePreviewPOJO; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
...server/src/services/Cashflow/subscribers/DecrementUncategorizedTransactionOnCategorize.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { Inject, Service } from 'typedi'; | ||
import events from '@/subscribers/events'; | ||
import HasTenancyService from '@/services/Tenancy/TenancyService'; | ||
import { | ||
ICashflowTransactionCategorizedPayload, | ||
ICashflowTransactionUncategorizedPayload, | ||
} from '@/interfaces'; | ||
|
||
@Service() | ||
export class DecrementUncategorizedTransactionOnCategorize { | ||
@Inject() | ||
private tenancy: HasTenancyService; | ||
/** | ||
* Constructor method. | ||
*/ | ||
public attach(bus) { | ||
bus.subscribe( | ||
events.cashflow.onTransactionCategorized, | ||
this.decrementUnCategorizedTransactionsOnCategorized.bind(this) | ||
); | ||
bus.subscribe( | ||
events.cashflow.onTransactionUncategorized, | ||
this.incrementUnCategorizedTransactionsOnUncategorized.bind(this) | ||
); | ||
} | ||
|
||
/** | ||
* Decrement the uncategoirzed transactions on the account once categorizing. | ||
* @param {ICashflowTransactionCategorizedPayload} | ||
*/ | ||
public async decrementUnCategorizedTransactionsOnCategorized({ | ||
tenantId, | ||
uncategorizedTransaction, | ||
}: ICashflowTransactionCategorizedPayload) { | ||
const { Account } = this.tenancy.models(tenantId); | ||
|
||
await Account.query() | ||
.findById(uncategorizedTransaction.accountId) | ||
.decrement('uncategorizedTransactions', 1); | ||
} | ||
|
||
/** | ||
* Increment the uncategorized transaction on the given account on uncategorizing. | ||
* @param {IManualJournalDeletingPayload} | ||
*/ | ||
public async incrementUnCategorizedTransactionsOnUncategorized({ | ||
tenantId, | ||
uncategorizedTransaction, | ||
}: ICashflowTransactionUncategorizedPayload) { | ||
const { Account } = this.tenancy.models(tenantId); | ||
|
||
await Account.query() | ||
.findById(uncategorizedTransaction.accountId) | ||
.increment('uncategorizedTransactions', 1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.