mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 12:50:38 +00:00
feat: import resources from csv/xlsx
This commit is contained in:
49
packages/server/src/services/Import/AccountsImportable.ts
Normal file
49
packages/server/src/services/Import/AccountsImportable.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import { IAccountCreateDTO } from '@/interfaces';
|
||||
import { AccountsApplication } from '../Accounts/AccountsApplication';
|
||||
import { AccountDTOSchema } from '../Accounts/CreateAccountDTOSchema';
|
||||
import { Inject, Service } from 'typedi';
|
||||
import { Knex } from 'knex';
|
||||
|
||||
@Service()
|
||||
export class AccountsImportable {
|
||||
@Inject()
|
||||
private accountsApp: AccountsApplication;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {number} tenantId
|
||||
* @param {IAccountCreateDTO} createAccountDTO
|
||||
* @returns
|
||||
*/
|
||||
public importable(
|
||||
tenantId: number,
|
||||
createAccountDTO: IAccountCreateDTO,
|
||||
trx?: Knex.Transaction
|
||||
) {
|
||||
return this.accountsApp.createAccount(tenantId, createAccountDTO, trx);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @returns {}
|
||||
*/
|
||||
public validation() {
|
||||
return AccountDTOSchema;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param data
|
||||
* @returns
|
||||
*/
|
||||
public transform(data) {
|
||||
return {
|
||||
...data,
|
||||
accountType: this.mapAccountType(data.accounType),
|
||||
};
|
||||
}
|
||||
|
||||
mapAccountType(accountType: string) {
|
||||
return 'Cash';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user