feat: import resources from csv/xlsx

This commit is contained in:
Ahmed Bouhuolia
2024-03-11 00:21:36 +02:00
parent 1fc6445123
commit 90b4f3ef6d
16 changed files with 467 additions and 184 deletions

View 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';
}
}