Files
bigcapital/packages/server/src/modules/Accounts/AccountsImportable.service.ts
2025-04-12 19:26:15 +02:00

47 lines
1.2 KiB
TypeScript

import { Knex } from 'knex';
import { Injectable } from '@nestjs/common';
import { Importable } from '../Import/Importable';
import { AccountsSampleData } from './AccountsImportable.SampleData';
import { CreateAccountDTO } from './CreateAccount.dto';
import { CreateAccountService } from './CreateAccount.service';
import { ImportableService } from '../Import/decorators/Import.decorator';
import { Account } from './models/Account.model';
@Injectable()
@ImportableService({ name: Account.name })
export class AccountsImportable extends Importable {
constructor(private readonly createAccountService: CreateAccountService) {
super();
}
/**
* Importing to account service.
* @param {CreateAccountDTO} createAccountDTO - Create account dto.
* @returns
*/
public importable(
createAccountDTO: CreateAccountDTO,
trx?: Knex.Transaction,
) {
return this.createAccountService.createAccount(
createAccountDTO,
trx,
);
}
/**
* Concurrrency controlling of the importing process.
* @returns {number}
*/
public get concurrency() {
return 1;
}
/**
* Retrieves the sample data that used to download accounts sample sheet.
*/
public sampleData(): any[] {
return AccountsSampleData;
}
}