mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 22:00:31 +00:00
refactor: inventory to nestjs
This commit is contained in:
@@ -15,12 +15,14 @@ import { GetAccountTypesService } from './GetAccountTypes.service';
|
||||
import { GetAccountTransactionsService } from './GetAccountTransactions.service';
|
||||
import { RegisterTenancyModel } from '../Tenancy/TenancyModels/Tenancy.module';
|
||||
import { BankAccount } from '../BankingTransactions/models/BankAccount';
|
||||
import { GetAccountsService } from './GetAccounts.service';
|
||||
import { DynamicListModule } from '../DynamicListing/DynamicList.module';
|
||||
// import { GetAccountsService } from './GetAccounts.service';
|
||||
|
||||
const models = [RegisterTenancyModel(BankAccount)];
|
||||
|
||||
@Module({
|
||||
imports: [TenancyDatabaseModule],
|
||||
imports: [TenancyDatabaseModule, DynamicListModule],
|
||||
controllers: [AccountsController],
|
||||
providers: [
|
||||
AccountsApplication,
|
||||
@@ -35,6 +37,7 @@ const models = [RegisterTenancyModel(BankAccount)];
|
||||
ActivateAccount,
|
||||
GetAccountTypesService,
|
||||
GetAccountTransactionsService,
|
||||
GetAccountsService,
|
||||
...models,
|
||||
],
|
||||
exports: [AccountRepository, CreateAccountService, ...models],
|
||||
|
||||
@@ -41,6 +41,7 @@ export interface IAccountEventCreatingPayload {
|
||||
accountDTO: any;
|
||||
trx: Knex.Transaction;
|
||||
}
|
||||
|
||||
export interface IAccountEventCreatedPayload {
|
||||
account: Account;
|
||||
accountId: number;
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { kebabCase } from 'lodash';
|
||||
import { Knex } from 'knex';
|
||||
import { EventEmitter2 } from '@nestjs/event-emitter';
|
||||
import {
|
||||
// IAccount,
|
||||
// IAccountEventCreatedPayload,
|
||||
// IAccountCreateDTO,
|
||||
IAccountEventCreatingPayload,
|
||||
CreateAccountParams,
|
||||
IAccountEventCreatedPayload,
|
||||
} from './Accounts.types';
|
||||
import { CommandAccountValidators } from './CommandAccountValidators.service';
|
||||
import { Account } from './models/Account.model';
|
||||
@@ -16,6 +13,7 @@ import { UnitOfWork } from '../Tenancy/TenancyDB/UnitOfWork.service';
|
||||
import { TenancyContext } from '../Tenancy/TenancyContext.service';
|
||||
import { events } from '@/common/events/events';
|
||||
import { CreateAccountDTO } from './CreateAccount.dto';
|
||||
import { PartialModelObject } from 'objection';
|
||||
|
||||
@Injectable()
|
||||
export class CreateAccountService {
|
||||
@@ -80,7 +78,7 @@ export class CreateAccountService {
|
||||
private transformDTOToModel = (
|
||||
createAccountDTO: CreateAccountDTO,
|
||||
baseCurrency: string,
|
||||
) => {
|
||||
): PartialModelObject<Account> => {
|
||||
return {
|
||||
...createAccountDTO,
|
||||
slug: kebabCase(createAccountDTO.name),
|
||||
@@ -127,11 +125,11 @@ export class CreateAccountService {
|
||||
...accountInputModel,
|
||||
});
|
||||
// Triggers `onAccountCreated` event.
|
||||
// await this.eventEmitter.emitAsync(events.accounts.onCreated, {
|
||||
// account,
|
||||
// accountId: account.id,
|
||||
// trx,
|
||||
// } as IAccountEventCreatedPayload);
|
||||
await this.eventEmitter.emitAsync(events.accounts.onCreated, {
|
||||
account,
|
||||
accountId: account.id,
|
||||
trx,
|
||||
} as IAccountEventCreatedPayload);
|
||||
|
||||
return account;
|
||||
}, trx);
|
||||
|
||||
@@ -33,9 +33,10 @@ export class Account extends TenantBaseModel {
|
||||
public bankBalance!: number;
|
||||
public lastFeedsUpdatedAt!: string | Date | null;
|
||||
public amount!: number;
|
||||
public plaidItemId!: number;
|
||||
public plaidItemId!: string;
|
||||
public plaidAccountId!: string | null;
|
||||
public isFeedsActive!: boolean;
|
||||
public isSyncingOwner!: boolean;
|
||||
public plaidItem!: PlaidItem;
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user