mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 12:50:38 +00:00
refactor: banking modules to nestjs
This commit is contained in:
@@ -33,7 +33,8 @@ import { GetAccountTransactionsService } from './GetAccountTransactions.service'
|
||||
GetAccountTransactionsService,
|
||||
],
|
||||
exports: [
|
||||
AccountRepository
|
||||
AccountRepository,
|
||||
CreateAccountService,
|
||||
]
|
||||
})
|
||||
export class AccountsModule {}
|
||||
|
||||
@@ -56,6 +56,9 @@ import { PaymentsReceivedModule } from '../PaymentReceived/PaymentsReceived.modu
|
||||
import { LedgerModule } from '../Ledger/Ledger.module';
|
||||
import { BankRulesModule } from '../BankRules/BankRules.module';
|
||||
import { BankAccountsModule } from '../BankingAccounts/BankAccounts.module';
|
||||
import { BankingTransactionsExcludeModule } from '../BankingTransactionsExclude/BankingTransactionsExclude.module';
|
||||
import { BankingTransactionsRegonizeModule } from '../BankingTranasctionsRegonize/BankingTransactionsRegonize.module';
|
||||
import { BankingMatchingModule } from '../BankingMatching/BankingMatching.module';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
@@ -134,9 +137,11 @@ import { BankAccountsModule } from '../BankingAccounts/BankAccounts.module';
|
||||
BillPaymentsModule,
|
||||
PaymentsReceivedModule,
|
||||
LedgerModule,
|
||||
|
||||
BankAccountsModule,
|
||||
BankRulesModule,
|
||||
BankingTransactionsExcludeModule,
|
||||
BankingTransactionsRegonizeModule,
|
||||
// BankingMatchingModule
|
||||
],
|
||||
controllers: [AppController],
|
||||
providers: [
|
||||
|
||||
@@ -10,6 +10,7 @@ import { BankRuleCondition } from './models/BankRuleCondition';
|
||||
import { BankRule } from './models/BankRule';
|
||||
import { BankRulesController } from './BankRules.controller';
|
||||
import { UnlinkBankRuleOnDeleteBankRuleSubscriber } from './events/UnlinkBankRuleOnDeleteBankRule';
|
||||
import { DeleteBankRulesService } from './commands/DeleteBankRules.service';
|
||||
|
||||
const models = [
|
||||
RegisterTenancyModel(BankRule),
|
||||
@@ -24,11 +25,12 @@ const models = [
|
||||
CreateBankRuleService,
|
||||
EditBankRuleService,
|
||||
DeleteBankRuleService,
|
||||
DeleteBankRulesService,
|
||||
GetBankRuleService,
|
||||
GetBankRulesService,
|
||||
BankRulesApplication,
|
||||
UnlinkBankRuleOnDeleteBankRuleSubscriber
|
||||
],
|
||||
exports: [...models],
|
||||
exports: [...models, DeleteBankRuleService, DeleteBankRulesService],
|
||||
})
|
||||
export class BankRulesModule {}
|
||||
|
||||
@@ -7,17 +7,21 @@ import { PauseBankAccountFeeds } from './commands/PauseBankAccountFeeds.service'
|
||||
import { DeleteUncategorizedTransactionsOnAccountDeleting } from './subscribers/DeleteUncategorizedTransactionsOnAccountDeleting';
|
||||
import { DisconnectPlaidItemOnAccountDeleted } from './subscribers/DisconnectPlaidItemOnAccountDeleted';
|
||||
import { BankAccountsController } from './BankAccounts.controller';
|
||||
import { BankingPlaidModule } from '../BankingPlaid/BankingPlaid.module';
|
||||
import { PlaidModule } from '../Plaid/Plaid.module';
|
||||
import { BankRulesModule } from '../BankRules/BankRules.module';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
imports: [BankingPlaidModule, PlaidModule, BankRulesModule],
|
||||
providers: [
|
||||
DisconnectBankAccountService,
|
||||
RefreshBankAccountService,
|
||||
ResumeBankAccountFeedsService,
|
||||
PauseBankAccountFeeds,
|
||||
DeleteUncategorizedTransactionsOnAccountDeleting,
|
||||
// DeleteUncategorizedTransactionsOnAccountDeleting,
|
||||
DisconnectPlaidItemOnAccountDeleted,
|
||||
BankAccountsApplication
|
||||
],
|
||||
providers: [BankAccountsApplication],
|
||||
exports: [BankAccountsApplication],
|
||||
controllers: [BankAccountsController],
|
||||
})
|
||||
|
||||
@@ -13,7 +13,6 @@ import { PlaidItem } from '@/modules/BankingPlaid/models/PlaidItem';
|
||||
import { ServiceError } from '@/modules/Items/ServiceError';
|
||||
import { events } from '@/common/events/events';
|
||||
import { EventEmitter2 } from '@nestjs/event-emitter';
|
||||
|
||||
import { PLAID_CLIENT } from '@/modules/Plaid/Plaid.module';
|
||||
|
||||
@Injectable()
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { CreateUncategorizedTransactionService } from './commands/CreateUncategorizedTransaction.service';
|
||||
import { CategorizeTransactionAsExpense } from './commands/CategorizeTransactionAsExpense';
|
||||
import { BankingTransactionsModule } from '../BankingTransactions/BankingTransactions.module';
|
||||
import { ExpensesModule } from '../Expenses/Expenses.module';
|
||||
|
||||
@Module({
|
||||
imports: [BankingTransactionsModule, ExpensesModule],
|
||||
providers: [
|
||||
CreateUncategorizedTransactionService,
|
||||
CategorizeTransactionAsExpense,
|
||||
],
|
||||
exports: [
|
||||
CreateUncategorizedTransactionService,
|
||||
CategorizeTransactionAsExpense,
|
||||
],
|
||||
})
|
||||
export class BankingCategorizeModule {}
|
||||
@@ -4,8 +4,6 @@ import {
|
||||
} from '@/interfaces';
|
||||
import { Knex } from 'knex';
|
||||
import { EventEmitter2 } from '@nestjs/event-emitter';
|
||||
import { UncategorizedBankTransaction } from '@/modules/BankingTransactions/models/UncategorizedBankTransaction';
|
||||
import { Expense } from '@/modules/Expenses/models/Expense.model';
|
||||
import { BankTransaction } from '@/modules/BankingTransactions/models/BankTransaction';
|
||||
import { CreateExpense } from '@/modules/Expenses/commands/CreateExpense.service';
|
||||
import { Inject } from '@nestjs/common';
|
||||
@@ -21,12 +19,6 @@ export class CategorizeTransactionAsExpense {
|
||||
private readonly eventPublisher: EventEmitter2,
|
||||
private readonly createExpenseService: CreateExpense,
|
||||
|
||||
@Inject(UncategorizedBankTransaction.name)
|
||||
private readonly uncategorizedBankTransactionModel: typeof UncategorizedBankTransaction,
|
||||
|
||||
@Inject(Expense.name)
|
||||
private readonly expenseModel: typeof Expense,
|
||||
|
||||
@Inject(BankTransaction.name)
|
||||
private readonly bankTransactionModel: typeof BankTransaction,
|
||||
) {}
|
||||
|
||||
@@ -30,6 +30,7 @@ export interface ICategorizeCashflowTransactioDTO {
|
||||
transactionNumber: string;
|
||||
transactionType: string;
|
||||
exchangeRate: number;
|
||||
currencyCode: string;
|
||||
description: string;
|
||||
branchId: number;
|
||||
}
|
||||
|
||||
@@ -14,12 +14,24 @@ import { DecrementUncategorizedTransactionOnMatchingSubscriber } from './events/
|
||||
import { ValidateMatchingOnPaymentMadeDeleteSubscriber } from './events/ValidateMatchingOnPaymentMadeDelete';
|
||||
import { ValidateMatchingOnManualJournalDeleteSubscriber } from './events/ValidateMatchingOnManualJournalDelete';
|
||||
import { ValidateMatchingOnCashflowDeleteSubscriber } from './events/ValidateMatchingOnCashflowDelete';
|
||||
import { BillPaymentsModule } from '../BillPayments/BillPayments.module';
|
||||
import { BankingTransactionsModule } from '../BankingTransactions/BankingTransactions.module';
|
||||
import { PaymentsReceivedModule } from '../PaymentReceived/PaymentsReceived.module';
|
||||
import { MatchBankTransactions } from './commands/MatchTransactions';
|
||||
import { MatchTransactionsTypes } from './commands/MatchTransactionsTypes';
|
||||
|
||||
const models = [RegisterTenancyModel(MatchedBankTransaction)];
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
BillPaymentsModule,
|
||||
BankingTransactionsModule,
|
||||
PaymentsReceivedModule,
|
||||
],
|
||||
providers: [
|
||||
...models,
|
||||
MatchBankTransactions,
|
||||
MatchTransactionsTypes,
|
||||
GetMatchedTransactionsByBills,
|
||||
GetMatchedTransactionsByCashflow,
|
||||
GetMatchedTransactionsByExpenses,
|
||||
@@ -32,7 +44,7 @@ const models = [RegisterTenancyModel(MatchedBankTransaction)];
|
||||
DecrementUncategorizedTransactionOnMatchingSubscriber,
|
||||
ValidateMatchingOnPaymentMadeDeleteSubscriber,
|
||||
ValidateMatchingOnManualJournalDeleteSubscriber,
|
||||
ValidateMatchingOnCashflowDeleteSubscriber
|
||||
ValidateMatchingOnCashflowDeleteSubscriber,
|
||||
],
|
||||
exports: [...models],
|
||||
})
|
||||
|
||||
@@ -54,8 +54,8 @@ export class MatchTransactionsTypes {
|
||||
const instance = MatchTransactionsTypesRegistry.getInstance();
|
||||
|
||||
this.registered.forEach((registered) => {
|
||||
const serviceInstanace = Container.get(registered.service);
|
||||
instance.register(registered.type, serviceInstanace);
|
||||
// const serviceInstanace = Container.get(registered.service);
|
||||
// instance.register(registered.type, serviceInstanace);
|
||||
});
|
||||
MatchTransactionsTypes.registry = instance;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { initialize } from 'objection';
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { Knex } from 'knex';
|
||||
import { first } from 'lodash';
|
||||
|
||||
@@ -1,20 +1,44 @@
|
||||
import { Module } from "@nestjs/common";
|
||||
import { PlaidUpdateTransactionsOnItemCreatedSubscriber } from "./subscribers/PlaidUpdateTransactionsOnItemCreatedSubscriber";
|
||||
import { PlaidUpdateTransactions } from "./command/PlaidUpdateTransactions";
|
||||
import { PlaidSyncDb } from "./command/PlaidSyncDB";
|
||||
import { PlaidWebooks } from "./command/PlaidWebhooks";
|
||||
import { PlaidLinkTokenService } from "./queries/GetPlaidLinkToken.service";
|
||||
import { PlaidApplication } from "./PlaidApplication";
|
||||
import { Module } from '@nestjs/common';
|
||||
import { PlaidUpdateTransactionsOnItemCreatedSubscriber } from './subscribers/PlaidUpdateTransactionsOnItemCreatedSubscriber';
|
||||
import { PlaidUpdateTransactions } from './command/PlaidUpdateTransactions';
|
||||
import { PlaidSyncDb } from './command/PlaidSyncDB';
|
||||
import { PlaidWebooks } from './command/PlaidWebhooks';
|
||||
import { PlaidLinkTokenService } from './queries/GetPlaidLinkToken.service';
|
||||
import { PlaidApplication } from './PlaidApplication';
|
||||
import { RegisterTenancyModel } from '../Tenancy/TenancyModels/Tenancy.module';
|
||||
import { PlaidItem } from './models/PlaidItem';
|
||||
import { PlaidModule } from '../Plaid/Plaid.module';
|
||||
import { AccountsModule } from '../Accounts/Accounts.module';
|
||||
import { BankingCategorizeModule } from '../BankingCategorize/BankingCategorize.module';
|
||||
import { BankingTransactionsModule } from '../BankingTransactions/BankingTransactions.module';
|
||||
import { PlaidItemService } from './command/PlaidItem';
|
||||
import { TenancyContext } from '../Tenancy/TenancyContext.service';
|
||||
import { InjectSystemModel } from '../System/SystemModels/SystemModels.module';
|
||||
import { SystemPlaidItem } from './models/SystemPlaidItem';
|
||||
|
||||
const models = [
|
||||
RegisterTenancyModel(PlaidItem),
|
||||
InjectSystemModel(SystemPlaidItem),
|
||||
];
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
PlaidModule,
|
||||
AccountsModule,
|
||||
BankingCategorizeModule,
|
||||
BankingTransactionsModule,
|
||||
],
|
||||
providers: [
|
||||
...models,
|
||||
PlaidItemService,
|
||||
PlaidUpdateTransactions,
|
||||
PlaidSyncDb,
|
||||
PlaidWebooks,
|
||||
PlaidLinkTokenService,
|
||||
PlaidApplication,
|
||||
PlaidUpdateTransactionsOnItemCreatedSubscriber,
|
||||
TenancyContext,
|
||||
],
|
||||
exports: [...models],
|
||||
})
|
||||
export class BankingPlaidModule {}
|
||||
export class BankingPlaidModule {}
|
||||
|
||||
@@ -15,10 +15,12 @@ import { PLAID_CLIENT } from '@/modules/Plaid/Plaid.module';
|
||||
@Injectable()
|
||||
export class PlaidUpdateTransactions {
|
||||
constructor(
|
||||
private readonly plaidItemModel: typeof PlaidItem,
|
||||
private readonly plaidSync: PlaidSyncDb,
|
||||
private readonly uow: UnitOfWork,
|
||||
|
||||
@Inject(PlaidItem.name)
|
||||
private readonly plaidItemModel: typeof PlaidItem,
|
||||
|
||||
@Inject(PLAID_CLIENT)
|
||||
private readonly plaidClient: PlaidApi,
|
||||
) {}
|
||||
|
||||
@@ -5,10 +5,13 @@ import { GetAutofillCategorizeTransactionService } from './queries/GetAutofillCa
|
||||
import { RevertRecognizedTransactionsService } from './commands/RevertRecognizedTransactions.service';
|
||||
import { RecognizeTranasctionsService } from './commands/RecognizeTranasctions.service';
|
||||
import { TriggerRecognizedTransactionsSubscriber } from './events/TriggerRecognizedTransactions';
|
||||
import { BankingTransactionsModule } from '../BankingTransactions/BankingTransactions.module';
|
||||
import { BankRulesModule } from '../BankRules/BankRules.module';
|
||||
|
||||
const models = [RegisterTenancyModel(RecognizedBankTransaction)];
|
||||
|
||||
@Module({
|
||||
imports: [BankingTransactionsModule, BankRulesModule],
|
||||
providers: [
|
||||
...models,
|
||||
GetAutofillCategorizeTransactionService,
|
||||
|
||||
@@ -3,9 +3,7 @@ export interface RevertRecognizedTransactionsCriteria {
|
||||
accountId?: number;
|
||||
}
|
||||
|
||||
|
||||
export interface RecognizeTransactionsCriteria {
|
||||
batch?: string;
|
||||
accountId?: number;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,15 @@ import { PreventDeleteTransactionOnDeleteSubscriber } from './subscribers/Preven
|
||||
import { ValidateDeleteBankAccountTransactions } from './commands/ValidateDeleteBankAccountTransactions.service';
|
||||
import { BankTransactionGLEntriesService } from './commands/BankTransactionGLEntries';
|
||||
import { BankingTransactionsApplication } from './BankingTransactionsApplication.service';
|
||||
import { AutoIncrementOrdersModule } from '../AutoIncrementOrders/AutoIncrementOrders.module';
|
||||
import { LedgerModule } from '../Ledger/Ledger.module';
|
||||
import { DeleteCashflowTransaction } from './commands/DeleteCashflowTransaction.service';
|
||||
import { CreateBankTransactionService } from './commands/CreateBankTransaction.service';
|
||||
import { GetBankTransactionService } from './queries/GetBankTransaction.service';
|
||||
import { CommandBankTransactionValidator } from './commands/CommandCasflowValidator.service';
|
||||
import { BranchTransactionDTOTransformer } from '../Branches/integrations/BranchTransactionDTOTransform';
|
||||
import { BranchesModule } from '../Branches/Branches.module';
|
||||
import { RemovePendingUncategorizedTransaction } from './commands/RemovePendingUncategorizedTransaction.service';
|
||||
|
||||
const models = [
|
||||
RegisterTenancyModel(UncategorizedBankTransaction),
|
||||
@@ -19,7 +28,8 @@ const models = [
|
||||
];
|
||||
|
||||
@Module({
|
||||
exports: [
|
||||
imports: [AutoIncrementOrdersModule, LedgerModule, BranchesModule],
|
||||
providers: [
|
||||
BankTransactionAutoIncrement,
|
||||
BankTransactionGLEntriesService,
|
||||
ValidateDeleteBankAccountTransactions,
|
||||
@@ -28,8 +38,14 @@ const models = [
|
||||
DeleteCashflowTransactionOnUncategorizeSubscriber,
|
||||
PreventDeleteTransactionOnDeleteSubscriber,
|
||||
BankingTransactionsApplication,
|
||||
DeleteCashflowTransaction,
|
||||
CreateBankTransactionService,
|
||||
GetBankTransactionService,
|
||||
CommandBankTransactionValidator,
|
||||
BranchTransactionDTOTransformer,
|
||||
RemovePendingUncategorizedTransaction,
|
||||
...models,
|
||||
],
|
||||
providers: [...models],
|
||||
exports: [...models, RemovePendingUncategorizedTransaction],
|
||||
})
|
||||
export class BankingTransactionsModule {}
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
} from './constants';
|
||||
import { ICashflowNewCommandDTO } from './types/BankingTransactions.types';
|
||||
import { UncategorizedBankTransaction } from './models/UncategorizedBankTransaction';
|
||||
import { ICategorizeCashflowTransactioDTO } from '../BankingCategorize/types/BankingCategorize.types';
|
||||
import { ServiceError } from '../Items/ServiceError';
|
||||
|
||||
/**
|
||||
@@ -50,7 +51,7 @@ export const getCashflowAccountTransactionsTypes = () => {
|
||||
*/
|
||||
export const transformCategorizeTransToCashflow = (
|
||||
uncategorizeTransactions: Array<UncategorizedBankTransaction>,
|
||||
categorizeDTO: ICategorizeBankTransactionDTO,
|
||||
categorizeDTO: ICategorizeCashflowTransactioDTO,
|
||||
): ICashflowNewCommandDTO => {
|
||||
const uncategorizeTransaction = first(uncategorizeTransactions);
|
||||
const amount = sumBy(uncategorizeTransactions, 'amount');
|
||||
|
||||
@@ -7,8 +7,10 @@ import { ExcludeBankTransactionsService } from './commands/ExcludeBankTransactio
|
||||
import { UnexcludeBankTransactionsService } from './commands/UnexcludeBankTransactions.service';
|
||||
import { DecrementUncategorizedTransactionOnExclude } from './subscribers/DecrementUncategorizedTransactionOnExclude';
|
||||
import { BankingTransactionsExcludeController } from './BankingTransactionsExclude.controller';
|
||||
import { BankingTransactionsModule } from '../BankingTransactions/BankingTransactions.module';
|
||||
|
||||
@Module({
|
||||
imports: [BankingTransactionsModule],
|
||||
providers: [
|
||||
ExcludeBankTransactionsApplication,
|
||||
ExcludeBankTransactionService,
|
||||
|
||||
@@ -35,7 +35,7 @@ import { AccountsModule } from '../Accounts/Accounts.module';
|
||||
BillPaymentGLEntries,
|
||||
BillPaymentGLEntriesSubscriber,
|
||||
],
|
||||
exports: [BillPaymentValidators],
|
||||
exports: [BillPaymentValidators, CreateBillPaymentService],
|
||||
controllers: [BillPaymentsController],
|
||||
})
|
||||
export class BillPaymentsModule {}
|
||||
|
||||
@@ -12,7 +12,7 @@ export interface IBillPaymentDTO {
|
||||
amount: number;
|
||||
paymentAccountId: number;
|
||||
paymentNumber?: string;
|
||||
paymentDate: Date;
|
||||
paymentDate: Date | string;
|
||||
exchangeRate?: number;
|
||||
statement: string;
|
||||
reference: string;
|
||||
|
||||
@@ -19,6 +19,9 @@ import { BranchesModule } from '../Branches/Branches.module';
|
||||
@Module({
|
||||
imports: [LedgerModule, BranchesModule],
|
||||
controllers: [ExpensesController],
|
||||
exports: [
|
||||
CreateExpense,
|
||||
],
|
||||
providers: [
|
||||
CreateExpense,
|
||||
ExpenseDTOTransformer,
|
||||
|
||||
@@ -46,10 +46,8 @@ export class PaymentReceivesApplication {
|
||||
|
||||
/**
|
||||
* Edit details the given payment receive with associated entries.
|
||||
* @param {number} tenantId
|
||||
* @param {number} paymentReceiveId
|
||||
* @param {IPaymentReceivedEditDTO} paymentReceiveDTO
|
||||
* @param {ISystemUser} authorizedUser
|
||||
* @param {number} paymentReceiveId - Payment receive id.
|
||||
* @param {IPaymentReceivedEditDTO} paymentReceiveDTO - Payment receive data.
|
||||
* @returns
|
||||
*/
|
||||
public editPaymentReceive(
|
||||
|
||||
@@ -49,7 +49,7 @@ import { AccountsModule } from '../Accounts/Accounts.module';
|
||||
PaymentReceivedGLEntriesSubscriber,
|
||||
PaymentReceivedSyncInvoicesSubscriber,
|
||||
],
|
||||
exports: [PaymentReceivesApplication],
|
||||
exports: [PaymentReceivesApplication, CreatePaymentReceivedService],
|
||||
imports: [
|
||||
ChromiumlyTenancyModule,
|
||||
TemplateInjectableModule,
|
||||
|
||||
@@ -18,7 +18,7 @@ const modelProviders = models.map((model) => {
|
||||
});
|
||||
|
||||
export const InjectSystemModel = (model: typeof Model) => ({
|
||||
value: model,
|
||||
useValue: model,
|
||||
provide: model.name,
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user