mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 22:00:31 +00:00
refactor: nestjs
This commit is contained in:
@@ -20,6 +20,16 @@ import { IFilterMeta } from '@/interfaces/Model';
|
||||
|
||||
@Injectable()
|
||||
export class AccountsApplication {
|
||||
/**
|
||||
* @param {CreateAccountService} createAccountService - The create account service.
|
||||
* @param {EditAccount} editAccountService - The edit account service.
|
||||
* @param {DeleteAccount} deleteAccountService - The delete account service.
|
||||
* @param {ActivateAccount} activateAccountService - The activate account service.
|
||||
* @param {GetAccountTypesService} getAccountTypesService - The get account types service.
|
||||
* @param {GetAccount} getAccountService - The get account service.
|
||||
* @param {GetAccountTransactionsService} getAccountTransactionsService - The get account transactions service.
|
||||
* @param {GetAccountsService} getAccountsService - The get accounts service.
|
||||
*/
|
||||
constructor(
|
||||
private readonly createAccountService: CreateAccountService,
|
||||
private readonly editAccountService: EditAccount,
|
||||
|
||||
@@ -10,6 +10,12 @@ import { TenantModelProxy } from '../System/models/TenantBaseModel';
|
||||
|
||||
@Injectable()
|
||||
export class ActivateAccount {
|
||||
/**
|
||||
* @param {EventEmitter2} eventEmitter - The event emitter.
|
||||
* @param {UnitOfWork} uow - The unit of work.
|
||||
* @param {AccountRepository} accountRepository - The account repository.
|
||||
* @param {TenantModelProxy<typeof Account>} accountModel - The account model.
|
||||
*/
|
||||
constructor(
|
||||
private readonly eventEmitter: EventEmitter2,
|
||||
private readonly uow: UnitOfWork,
|
||||
@@ -21,8 +27,8 @@ export class ActivateAccount {
|
||||
|
||||
/**
|
||||
* Activates/Inactivates the given account.
|
||||
* @param {number} accountId
|
||||
* @param {boolean} activate
|
||||
* @param {number} accountId - The account id.
|
||||
* @param {boolean} activate - Activate or inactivate the account.
|
||||
*/
|
||||
public activateAccount = async (accountId: number, activate?: boolean) => {
|
||||
// Retrieve the given account or throw not found error.
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import {
|
||||
IsString,
|
||||
IsOptional,
|
||||
@@ -11,41 +12,92 @@ export class CreateAccountDTO {
|
||||
@IsString()
|
||||
@MinLength(3)
|
||||
@MaxLength(255) // Assuming DATATYPES_LENGTH.STRING is 255
|
||||
@ApiProperty({
|
||||
description: 'Account name',
|
||||
example: 'Cash Account',
|
||||
minLength: 3,
|
||||
maxLength: 255,
|
||||
})
|
||||
name: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MinLength(3)
|
||||
@MaxLength(6)
|
||||
@ApiProperty({
|
||||
description: 'Account code',
|
||||
example: 'CA001',
|
||||
required: false,
|
||||
minLength: 3,
|
||||
maxLength: 6,
|
||||
})
|
||||
code?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@ApiProperty({
|
||||
description: 'Currency code for the account',
|
||||
example: 'USD',
|
||||
required: false,
|
||||
})
|
||||
currencyCode?: string;
|
||||
|
||||
@IsString()
|
||||
@MinLength(3)
|
||||
@MaxLength(255)
|
||||
@ApiProperty({
|
||||
description: 'Type of account',
|
||||
example: 'asset',
|
||||
minLength: 3,
|
||||
maxLength: 255,
|
||||
})
|
||||
accountType: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MaxLength(65535)
|
||||
@ApiProperty({
|
||||
description: 'Account description',
|
||||
example: 'Main cash account for daily operations',
|
||||
required: false,
|
||||
maxLength: 65535,
|
||||
})
|
||||
description?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsInt()
|
||||
@ApiProperty({
|
||||
description: 'ID of the parent account',
|
||||
example: 1,
|
||||
required: false,
|
||||
})
|
||||
parentAccountId?: number;
|
||||
|
||||
@IsOptional()
|
||||
@IsBoolean()
|
||||
@ApiProperty({
|
||||
description: 'Whether the account is active',
|
||||
example: true,
|
||||
required: false,
|
||||
default: true,
|
||||
})
|
||||
active?: boolean;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@ApiProperty({
|
||||
description: 'Plaid account ID for syncing',
|
||||
example: 'plaid_account_123456',
|
||||
required: false,
|
||||
})
|
||||
plaidAccountId?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@ApiProperty({
|
||||
description: 'Plaid item ID for syncing',
|
||||
example: 'plaid_item_123456',
|
||||
required: false,
|
||||
})
|
||||
plaidItemId?: string;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import {
|
||||
IsString,
|
||||
IsOptional,
|
||||
@@ -9,26 +10,45 @@ import {
|
||||
export class EditAccountDTO {
|
||||
@IsString()
|
||||
@MinLength(3)
|
||||
@MaxLength(255) // Assuming DATATYPES_LENGTH.STRING is 255
|
||||
@MaxLength(255)
|
||||
@ApiProperty({
|
||||
description: 'The name of the account',
|
||||
example: 'Bank Account',
|
||||
})
|
||||
name: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MinLength(3)
|
||||
@MaxLength(6)
|
||||
@ApiProperty({
|
||||
description: 'The code of the account',
|
||||
example: '123456',
|
||||
})
|
||||
code?: string;
|
||||
|
||||
@IsString()
|
||||
@MinLength(3)
|
||||
@MaxLength(255) // Assuming DATATYPES_LENGTH.STRING is 255
|
||||
@MaxLength(255)
|
||||
@ApiProperty({
|
||||
description: 'The type of the account',
|
||||
example: 'Bank Account',
|
||||
})
|
||||
accountType: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MaxLength(65535) // Assuming DATATYPES_LENGTH.TEXT is 65535
|
||||
@ApiProperty({
|
||||
description: 'The description of the account',
|
||||
example: 'This is a description',
|
||||
})
|
||||
description?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsInt()
|
||||
@ApiProperty({
|
||||
description: 'The parent account ID of the account',
|
||||
example: 1,
|
||||
})
|
||||
parentAccountId?: number;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user