refactor(nestjs): exportable modules

This commit is contained in:
Ahmed Bouhuolia
2025-04-08 22:44:24 +02:00
parent 04c25bd31a
commit e8f1fedf35
21 changed files with 408 additions and 408 deletions

View File

@@ -1,45 +1,43 @@
// import { Inject, Service } from 'typedi';
// import { Knex } from 'knex';
// import { IAccountCreateDTO } from '@/interfaces';
// import { CreateAccount } from './CreateAccount.service';
// import { Importable } from '../Import/Importable';
// import { AccountsSampleData } from './AccountsImportable.SampleData';
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';
// @Service()
// export class AccountsImportable extends Importable {
// @Inject()
// private createAccountService: CreateAccount;
@Injectable()
export class AccountsImportable extends Importable {
constructor(private readonly createAccountService: CreateAccountService) {
super();
}
// /**
// * Importing to account service.
// * @param {number} tenantId
// * @param {IAccountCreateDTO} createAccountDTO
// * @returns
// */
// public importable(
// tenantId: number,
// createAccountDTO: IAccountCreateDTO,
// trx?: Knex.Transaction
// ) {
// return this.createAccountService.createAccount(
// tenantId,
// createAccountDTO,
// trx
// );
// }
/**
* 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;
// }
/**
* 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;
// }
// }
/**
* Retrieves the sample data that used to download accounts sample sheet.
*/
public sampleData(): any[] {
return AccountsSampleData;
}
}

View File

@@ -3,12 +3,14 @@ import { CreateUncategorizedTransactionService } from './commands/CreateUncatego
import { CategorizeTransactionAsExpense } from './commands/CategorizeTransactionAsExpense';
import { BankingTransactionsModule } from '../BankingTransactions/BankingTransactions.module';
import { ExpensesModule } from '../Expenses/Expenses.module';
import { UncategorizedTransactionsImportable } from './commands/UncategorizedTransactionsImportable';
@Module({
imports: [BankingTransactionsModule, ExpensesModule],
providers: [
CreateUncategorizedTransactionService,
CategorizeTransactionAsExpense,
UncategorizedTransactionsImportable
],
exports: [
CreateUncategorizedTransactionService,

View File

@@ -13,6 +13,7 @@ import { CustomersController } from './Customers.controller';
import { CustomersApplication } from './CustomersApplication.service';
import { DeleteCustomer } from './commands/DeleteCustomer.service';
import { CustomersExportable } from './CustomersExportable';
import { CustomersImportable } from './CustomersImportable';
@Module({
imports: [TenancyDatabaseModule],
@@ -31,7 +32,8 @@ import { CustomersExportable } from './CustomersExportable';
TenancyContext,
TransformerInjectable,
GetCustomerService,
CustomersExportable
CustomersExportable,
CustomersImportable
],
})
export class CustomersModule {}

View File

@@ -1,34 +1,34 @@
// import { Inject, Service } from 'typedi';
// import { Importable } from '@/services/Import/Importable';
// import { CreateCustomer } from './CRUD/CreateCustomer';
// import { Knex } from 'knex';
// import { ICustomer, ICustomerNewDTO } from '@/interfaces';
// import { CustomersSampleData } from './_SampleData';
import { Knex } from 'knex';
import { CustomersSampleData } from './_SampleData';
import { Injectable } from '@nestjs/common';
import { Importable } from '../Import/Importable';
import { CreateCustomer } from './commands/CreateCustomer.service';
import { CreateCustomerDto } from './dtos/CreateCustomer.dto';
// @Service()
// export class CustomersImportable extends Importable {
// @Inject()
// private createCustomerService: CreateCustomer;
@Injectable()
export class CustomersImportable extends Importable {
constructor(private readonly createCustomerService: CreateCustomer) {
super();
}
// /**
// * Mapps the imported data to create a new customer service.
// * @param {number} tenantId
// * @param {ICustomerNewDTO} createDTO
// * @param {Knex.Transaction} trx
// * @returns {Promise<void>}
// */
// public async importable(
// tenantId: number,
// createDTO: ICustomerNewDTO,
// trx?: Knex.Transaction<any, any[]>
// ): Promise<void> {
// await this.createCustomerService.createCustomer(tenantId, createDTO, trx);
// }
/**
* Mapps the imported data to create a new customer service.
* @param {number} tenantId
* @param {ICustomerNewDTO} createDTO
* @param {Knex.Transaction} trx
* @returns {Promise<void>}
*/
public async importable(
createDTO: CreateCustomerDto,
trx?: Knex.Transaction<any, any[]>,
): Promise<void> {
await this.createCustomerService.createCustomer(createDTO, trx);
}
// /**
// * Retrieves the sample data of customers used to download sample sheet.
// */
// public sampleData(): any[] {
// return CustomersSampleData;
// }
// }
/**
* Retrieves the sample data of customers used to download sample sheet.
*/
public sampleData(): any[] {
return CustomersSampleData;
}
}

View File

@@ -18,6 +18,7 @@ import { BranchesModule } from '../Branches/Branches.module';
import { GetExpensesService } from './queries/GetExpenses.service';
import { DynamicListModule } from '../DynamicListing/DynamicList.module';
import { ExpensesExportable } from './ExpensesExportable';
import { ExpensesImportable } from './ExpensesImportable';
@Module({
imports: [LedgerModule, BranchesModule, DynamicListModule],
@@ -38,7 +39,8 @@ import { ExpensesExportable } from './ExpensesExportable';
ExpenseGLEntriesStorageService,
ExpenseGLEntriesService,
GetExpensesService,
ExpensesExportable
ExpensesExportable,
ExpensesImportable
],
})
export class ExpensesModule {}

View File

@@ -1,46 +1,41 @@
// import { Inject, Service } from 'typedi';
// import { Knex } from 'knex';
// import { IExpenseCreateDTO } from '@/interfaces';
// import { Importable } from '../Import/Importable';
// import { CreateExpense } from './CRUD/CreateExpense.service';
// import { ExpensesSampleData } from './constants';
import { Knex } from 'knex';
import { Importable } from '../Import/Importable';
import { ExpensesSampleData } from './constants';
import { Injectable } from '@nestjs/common';
import { CreateExpense } from './commands/CreateExpense.service';
import { CreateExpenseDto } from './dtos/Expense.dto';
// @Service()
// export class ExpensesImportable extends Importable {
// @Inject()
// private createExpenseService: CreateExpense;
@Injectable()
export class ExpensesImportable extends Importable {
constructor(private readonly createExpenseService: CreateExpense) {
super();
}
// /**
// * Importing to account service.
// * @param {number} tenantId
// * @param {IAccountCreateDTO} createAccountDTO
// * @returns
// */
// public importable(
// tenantId: number,
// createAccountDTO: IExpenseCreateDTO,
// trx?: Knex.Transaction
// ) {
// return this.createExpenseService.newExpense(
// tenantId,
// createAccountDTO,
// {},
// trx
// );
// }
/**
* Importing to account service.
* @param {number} tenantId
* @param {IAccountCreateDTO} createAccountDTO
* @returns
*/
public importable(
createAccountDTO: CreateExpenseDto,
trx?: Knex.Transaction,
) {
return this.createExpenseService.newExpense(createAccountDTO, trx);
}
// /**
// * Concurrrency controlling of the importing process.
// * @returns {number}
// */
// public get concurrency() {
// return 1;
// }
/**
* 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 ExpensesSampleData;
// }
// }
/**
* Retrieves the sample data that used to download accounts sample sheet.
*/
public sampleData(): any[] {
return ExpensesSampleData;
}
}

View File

@@ -1,38 +1,32 @@
// import { Inject, Service } from 'typedi';
// import ItemCategoriesService from './ItemCategoriesService';
// import { Importable } from '../Import/Importable';
// import { Knex } from 'knex';
// import { IItemCategoryOTD } from '@/interfaces';
// import { ItemCategoriesSampleData } from './constants';
import { Importable } from '../Import/Importable';
import { Knex } from 'knex';
import { ItemCategoriesSampleData } from './constants';
import { Injectable } from '@nestjs/common';
import { CreateItemCategoryDto } from './dtos/ItemCategory.dto';
import { ItemCategoryApplication } from './ItemCategory.application';
// @Service()
// export class ItemCategoriesImportable extends Importable {
// @Inject()
// private itemCategoriesService: ItemCategoriesService;
@Injectable()
export class ItemCategoriesImportable extends Importable {
constructor(private readonly itemCategoriesApp: ItemCategoryApplication) {
super();
}
// /**
// * Importing to create new item category service.
// * @param {number} tenantId
// * @param {any} createDTO
// * @param {Knex.Transaction} trx
// */
// public async importable(
// tenantId: number,
// createDTO: IItemCategoryOTD,
// trx?: Knex.Transaction
// ) {
// await this.itemCategoriesService.newItemCategory(
// tenantId,
// createDTO,
// {},
// trx
// );
// }
/**
* Importing to create new item category service.
* @param {CreateItemCategoryDto} createDTO
* @param {Knex.Transaction} trx
*/
public async importable(
createDTO: CreateItemCategoryDto,
trx?: Knex.Transaction,
) {
await this.itemCategoriesApp.createItemCategory(createDTO, trx);
}
// /**
// * Item categories sample data used to download sample sheet file.
// */
// public sampleData(): any[] {
// return ItemCategoriesSampleData;
// }
// }
/**
* Item categories sample data used to download sample sheet file.
*/
public sampleData(): any[] {
return ItemCategoriesSampleData;
}
}

View File

@@ -9,6 +9,7 @@ import { EditItemCategoryService } from './commands/EditItemCategory.service';
import { GetItemCategoryService } from './queries/GetItemCategory.service';
import { GetItemCategoriesService } from './queries/GetItemCategories.service';
import { CreateItemCategoryDto, EditItemCategoryDto } from './dtos/ItemCategory.dto';
import { Knex } from 'knex';
@Injectable()
export class ItemCategoryApplication {
@@ -33,8 +34,9 @@ export class ItemCategoryApplication {
*/
public createItemCategory(
itemCategoryDTO: CreateItemCategoryDto,
trx?: Knex.Transaction,
) {
return this.createItemCategoryService.newItemCategory(itemCategoryDTO);
return this.createItemCategoryService.newItemCategory(itemCategoryDTO, trx);
}
/**

View File

@@ -12,6 +12,7 @@ import { TenancyContext } from '../Tenancy/TenancyContext.service';
import { GetItemCategoriesService } from './queries/GetItemCategories.service';
import { DynamicListModule } from '../DynamicListing/DynamicList.module';
import { ItemCategoriesExportable } from './ItemCategoriesExportable';
import { ItemCategoriesImportable } from './ItemCategoriesImportable';
@Module({
imports: [TenancyDatabaseModule, DynamicListModule],
@@ -27,6 +28,7 @@ import { ItemCategoriesExportable } from './ItemCategoriesExportable';
ItemCategoriesExportable,
TransformerInjectable,
TenancyContext,
ItemCategoriesImportable
],
})
export class ItemCategoryModule {}

View File

@@ -16,6 +16,7 @@ import { ManualJournalWriteGLSubscriber } from './commands/ManualJournalGLEntrie
import { ManualJournalGLEntries } from './commands/ManualJournalGLEntries';
import { LedgerModule } from '../Ledger/Ledger.module';
import { ManualJournalsExportable } from './commands/ManualJournalExportable';
import { ManualJournalImportable } from './commands/ManualJournalsImport';
@Module({
imports: [BranchesModule, LedgerModule],
@@ -35,7 +36,8 @@ import { ManualJournalsExportable } from './commands/ManualJournalExportable';
GetManualJournal,
ManualJournalGLEntries,
ManualJournalWriteGLSubscriber,
ManualJournalsExportable
ManualJournalsExportable,
ManualJournalImportable
],
})
export class ManualJournalsModule {}

View File

@@ -1,60 +1,57 @@
// import { Inject } from 'typedi';
// import { Knex } from 'knex';
// import * as Yup from 'yup';
// import { Importable } from '../../Import/Importable';
// import { CreateManualJournalService } from './CreateManualJournal.service';
// import { IManualJournalDTO } from '@/interfaces';
// import { ImportableContext } from '../../Import/interfaces';
// import { ManualJournalsSampleData } from '../constants';
import { Knex } from 'knex';
import * as Yup from 'yup';
import { Importable } from '../../Import/Importable';
import { CreateManualJournalService } from './CreateManualJournal.service';
import { ImportableContext } from '../../Import/interfaces';
import { ManualJournalsSampleData } from '../constants';
import { CreateManualJournalDto } from '../dtos/ManualJournal.dto';
// export class ManualJournalImportable extends Importable {
// @Inject()
// private createManualJournalService: CreateManualJournalService;
export class ManualJournalImportable extends Importable {
constructor(
private readonly createManualJournalService: CreateManualJournalService,
) {
super();
}
// /**
// * Importing to account service.
// * @param {number} tenantId
// * @param {IAccountCreateDTO} createAccountDTO
// * @returns
// */
// public importable(
// tenantId: number,
// createJournalDTO: IManualJournalDTO,
// trx?: Knex.Transaction
// ) {
// return this.createManualJournalService.makeJournalEntries(
// tenantId,
// createJournalDTO,
// {},
// trx
// );
// }
/**
* Importing to account service.
* @param {CreateManualJournalDto} createAccountDTO
*/
public importable(
createJournalDTO: CreateManualJournalDto,
trx?: Knex.Transaction,
) {
return this.createManualJournalService.makeJournalEntries(
createJournalDTO,
trx,
);
}
// /**
// * Transformes the DTO before passing it to importable and validation.
// * @param {Record<string, any>} createDTO
// * @param {ImportableContext} context
// * @returns {Record<string, any>}
// */
// public transform(createDTO: Record<string, any>, context: ImportableContext) {
// return createDTO;
// }
/**
* Transformes the DTO before passing it to importable and validation.
* @param {Record<string, any>} createDTO
* @param {ImportableContext} context
* @returns {Record<string, any>}
*/
public transform(createDTO: Record<string, any>, context: ImportableContext) {
return createDTO;
}
// /**
// * Params validation schema.
// * @returns {ValidationSchema[]}
// */
// public paramsValidationSchema() {
// return Yup.object().shape({
// autoIncrement: Yup.boolean(),
// });
// }
/**
* Params validation schema.
* @returns {ValidationSchema[]}
*/
public paramsValidationSchema() {
return Yup.object().shape({
autoIncrement: Yup.boolean(),
});
}
// /**
// * Retrieves the sample data of manual journals that used to download sample sheet.
// * @returns {Record<string, any>}
// */
// public sampleData(): Record<string, any>[] {
// return ManualJournalsSampleData;
// }
// }
/**
* Retrieves the sample data of manual journals that used to download sample sheet.
* @returns {Record<string, any>}
*/
public sampleData(): Record<string, any>[] {
return ManualJournalsSampleData;
}
}

View File

@@ -35,6 +35,7 @@ import { SendPaymentReceivedMailProcessor } from './processors/PaymentReceivedMa
import { BullModule } from '@nestjs/bull';
import { SEND_PAYMENT_RECEIVED_MAIL_QUEUE } from './constants';
import { PaymentsReceivedExportable } from './commands/PaymentsReceivedExportable';
import { PaymentsReceivedImportable } from './commands/PaymentsReceivedImportable';
@Module({
controllers: [PaymentReceivesController],
@@ -60,7 +61,8 @@ import { PaymentsReceivedExportable } from './commands/PaymentsReceivedExportabl
GetPaymentsReceivedService,
SendPaymentReceiveMailNotification,
SendPaymentReceivedMailProcessor,
PaymentsReceivedExportable
PaymentsReceivedExportable,
PaymentsReceivedImportable
],
exports: [
PaymentReceivesApplication,

View File

@@ -1,46 +1,45 @@
// import { Inject, Service } from 'typedi';
// import { Knex } from 'knex';
// import { IPaymentReceivedCreateDTO } from '@/interfaces';
// import { Importable } from '@/services/Import/Importable';
// import { CreatePaymentReceived } from './commands/CreatePaymentReceived.serivce';
// import { PaymentsReceiveSampleData } from './constants';
import { Knex } from 'knex';
import { CreatePaymentReceivedDto } from '../dtos/PaymentReceived.dto';
import { Injectable } from '@nestjs/common';
import { PaymentsReceiveSampleData } from '../constants';
import { CreatePaymentReceivedService } from './CreatePaymentReceived.serivce';
import { Importable } from '@/modules/Import/Importable';
// @Service()
// export class PaymentsReceivedImportable extends Importable {
// @Inject()
// private createPaymentReceiveService: CreatePaymentReceived;
@Injectable()
export class PaymentsReceivedImportable extends Importable {
constructor(
private readonly createPaymentReceiveService: CreatePaymentReceivedService,
) {
super();
}
// /**
// * Importing to account service.
// * @param {number} tenantId
// * @param {IAccountCreateDTO} createAccountDTO
// * @returns
// */
// public importable(
// tenantId: number,
// createPaymentDTO: IPaymentReceivedCreateDTO,
// trx?: Knex.Transaction
// ) {
// return this.createPaymentReceiveService.createPaymentReceived(
// tenantId,
// createPaymentDTO,
// {},
// trx
// );
// }
/**
* Importing to account service.
* @param {CreatePaymentReceivedDto} createAccountDTO
* @returns
*/
public importable(
createPaymentDTO: CreatePaymentReceivedDto,
trx?: Knex.Transaction,
) {
return this.createPaymentReceiveService.createPaymentReceived(
createPaymentDTO,
trx,
);
}
// /**
// * Concurrrency controlling of the importing process.
// * @returns {number}
// */
// public get concurrency() {
// return 1;
// }
/**
* 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 PaymentsReceiveSampleData;
// }
// }
/**
* Retrieves the sample data that used to download accounts sample sheet.
*/
public sampleData(): any[] {
return PaymentsReceiveSampleData;
}
}

View File

@@ -36,6 +36,7 @@ import { SaleEstimatePdfTemplate } from '../SaleInvoices/queries/SaleEstimatePdf
import { PdfTemplatesModule } from '../PdfTemplate/PdfTemplates.module';
import { SendSaleEstimateMailQueue } from './types/SaleEstimates.types';
import { SaleEstimatesExportable } from './SaleEstimatesExportable';
import { SaleEstimatesImportable } from './SaleEstimatesImportable';
@Module({
imports: [
@@ -76,7 +77,8 @@ import { SaleEstimatesExportable } from './SaleEstimatesExportable';
SendSaleEstimateMail,
GetSaleEstimatePdf,
SaleEstimatePdfTemplate,
SaleEstimatesExportable
SaleEstimatesExportable,
SaleEstimatesImportable
],
})
export class SaleEstimatesModule {}

View File

@@ -1,45 +1,45 @@
// import { Inject, Service } from 'typedi';
// import { Knex } from 'knex';
// import { ISaleEstimateDTO } from '@/interfaces';
// import { CreateSaleEstimate } from './commands/CreateSaleEstimate.service';
// import { Importable } from '@/services/Import/Importable';
// import { SaleEstimatesSampleData } from './constants';
import { Knex } from 'knex';
import { CreateSaleEstimate } from './commands/CreateSaleEstimate.service';
import { SaleEstimatesSampleData } from './constants';
import { Injectable } from '@nestjs/common';
import { CreateSaleEstimateDto } from './dtos/SaleEstimate.dto';
import { Importable } from '../Import/Importable';
// @Service()
// export class SaleEstimatesImportable extends Importable {
// @Inject()
// private createEstimateService: CreateSaleEstimate;
@Injectable()
export class SaleEstimatesImportable extends Importable{
constructor(
private readonly createEstimateService: CreateSaleEstimate
) {
super();
}
// /**
// * Importing to account service.
// * @param {number} tenantId
// * @param {IAccountCreateDTO} createAccountDTO
// * @returns
// */
// public importable(
// tenantId: number,
// createEstimateDTO: ISaleEstimateDTO,
// trx?: Knex.Transaction
// ) {
// return this.createEstimateService.createEstimate(
// tenantId,
// createEstimateDTO,
// trx
// );
// }
/**
* Importing to account service.
* @param {CreateSaleEstimateDto} createAccountDTO
* @returns
*/
public importable(
createEstimateDTO: CreateSaleEstimateDto,
trx?: Knex.Transaction
) {
return this.createEstimateService.createEstimate(
createEstimateDTO,
trx
);
}
// /**
// * Concurrrency controlling of the importing process.
// * @returns {number}
// */
// public get concurrency() {
// return 1;
// }
/**
* 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 SaleEstimatesSampleData;
// }
// }
/**
* Retrieves the sample data that used to download accounts sample sheet.
*/
public sampleData(): any[] {
return SaleEstimatesSampleData;
}
}

View File

@@ -36,6 +36,7 @@ import { SendSaleReceiptMailProcess } from './processes/SendSaleReceiptMail.proc
import { MailModule } from '../Mail/Mail.module';
import { SendSaleReceiptMailQueue } from './constants';
import { SaleReceiptsExportable } from './commands/SaleReceiptsExportable';
import { SaleReceiptsImportable } from './commands/SaleReceiptsImportable';
@Module({
controllers: [SaleReceiptsController],
@@ -76,7 +77,8 @@ import { SaleReceiptsExportable } from './commands/SaleReceiptsExportable';
SaleReceiptInventoryTransactions,
SaleReceiptInventoryTransactionsSubscriber,
SendSaleReceiptMailProcess,
SaleReceiptsExportable
SaleReceiptsExportable,
SaleReceiptsImportable,
],
})
export class SaleReceiptsModule {}

View File

@@ -1,45 +1,44 @@
// import { Inject, Service } from 'typedi';
// import { Knex } from 'knex';
// import { IAccountCreateDTO, ISaleReceiptDTO } from '@/interfaces';
// import { CreateSaleReceipt } from './commands/CreateSaleReceipt.service';
// import { Importable } from '@/services/Import/Importable';
// import { SaleReceiptsSampleData } from './constants';
import { Injectable } from '@nestjs/common';
import { Knex } from 'knex';
import { CreateSaleReceipt } from './CreateSaleReceipt.service';
import { Importable } from '@/modules/Import/Importable';
import { CreateSaleReceiptDto } from '../dtos/SaleReceipt.dto';
import { SaleReceiptsSampleData } from '../constants';
// @Service()
// export class SaleReceiptsImportable extends Importable {
// @Inject()
// private createReceiptService: CreateSaleReceipt;
@Injectable()
export class SaleReceiptsImportable extends Importable {
constructor(private readonly createReceiptService: CreateSaleReceipt) {
super();
}
// /**
// * Importing to sale receipts service.
// * @param {number} tenantId
// * @param {IAccountCreateDTO} createAccountDTO
// * @returns
// */
// public importable(
// tenantId: number,
// createAccountDTO: ISaleReceiptDTO,
// trx?: Knex.Transaction
// ) {
// return this.createReceiptService.createSaleReceipt(
// tenantId,
// createAccountDTO,
// trx
// );
// }
/**
* Importing to sale receipts service.
* @param {number} tenantId
* @param {IAccountCreateDTO} createAccountDTO
* @returns
*/
public importable(
createAccountDTO: CreateSaleReceiptDto,
trx?: Knex.Transaction,
) {
return this.createReceiptService.createSaleReceipt(
createAccountDTO,
trx,
);
}
// /**
// * Concurrrency controlling of the importing process.
// * @returns {number}
// */
// public get concurrency() {
// return 1;
// }
/**
* 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 SaleReceiptsSampleData;
// }
// }
/**
* Retrieves the sample data that used to download accounts sample sheet.
*/
public sampleData(): any[] {
return SaleReceiptsSampleData;
}
}

View File

@@ -22,6 +22,7 @@ import { SyncItemTaxRateOnEditTaxRate } from './SyncItemTaxRateOnEditTaxRate';
import { RegisterTenancyModel } from '../Tenancy/TenancyModels/Tenancy.module';
import { TaxRateTransaction } from './models/TaxRateTransaction.model';
import { TaxRatesExportable } from './TaxRatesExportable';
import { TaxRatesImportable } from './TaxRatesImportable';
const models = [RegisterTenancyModel(TaxRateTransaction)];
@@ -48,7 +49,8 @@ const models = [RegisterTenancyModel(TaxRateTransaction)];
SyncItemTaxRateOnEditTaxSubscriber,
WriteTaxTransactionsItemEntries,
SyncItemTaxRateOnEditTaxRate,
TaxRatesExportable
TaxRatesExportable,
TaxRatesImportable
],
exports: [ItemEntriesTaxTransactions, ...models],
})

View File

@@ -1,46 +1,40 @@
// import { Inject, Service } from 'typedi';
// import { Knex } from 'knex';
// import { ICreateTaxRateDTO } from '@/interfaces';
// import { CreateTaxRate } from './commands/CreateTaxRate.service';
// import { Importable } from '../Import/Importable';
// import { TaxRatesSampleData } from './TaxRatesImportable.SampleData';
import { Knex } from 'knex';
import { CreateTaxRate } from './commands/CreateTaxRate.service';
import { Importable } from '../Import/Importable';
import { TaxRatesSampleData } from './TaxRatesImportable.SampleData';
import { CreateTaxRateDto } from './dtos/TaxRate.dto';
import { Injectable } from '@nestjs/common';
// @Service()
// export class TaxRatesImportable extends Importable {
// @Inject()
// private createTaxRateService: CreateTaxRate;
@Injectable()
export class TaxRatesImportable extends Importable {
constructor(private readonly createTaxRateService: CreateTaxRate) {
super();
}
// /**
// * Importing to tax rate creating service.
// * @param {number} tenantId -
// * @param {ICreateTaxRateDTO} ICreateTaxRateDTO -
// * @param {Knex.Transaction} trx -
// * @returns
// */
// public importable(
// tenantId: number,
// createAccountDTO: ICreateTaxRateDTO,
// trx?: Knex.Transaction
// ) {
// return this.createTaxRateService.createTaxRate(
// tenantId,
// createAccountDTO,
// trx
// );
// }
/**
* Importing to tax rate creating service.
* @param {CreateTaxRateDto} ICreateTaxRateDTO -
* @param {Knex.Transaction} trx -
*/
public importable(
createAccountDTO: CreateTaxRateDto,
trx?: Knex.Transaction,
) {
return this.createTaxRateService.createTaxRate(createAccountDTO, trx);
}
// /**
// * Concurrrency controlling of the importing process.
// * @returns {number}
// */
// public get concurrency() {
// return 1;
// }
/**
* 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 TaxRatesSampleData;
// }
// }
/**
* Retrieves the sample data that used to download accounts sample sheet.
*/
public sampleData(): any[] {
return TaxRatesSampleData;
}
}

View File

@@ -15,6 +15,7 @@ import { VendorsController } from './Vendors.controller';
import { GetVendorsService } from './queries/GetVendors.service';
import { DynamicListModule } from '../DynamicListing/DynamicList.module';
import { VendorsExportable } from './VendorsExportable';
import { VendorsImportable } from './VendorsImportable';
@Module({
imports: [TenancyDatabaseModule, DynamicListModule],
@@ -32,7 +33,8 @@ import { VendorsExportable } from './VendorsExportable';
VendorsApplication,
TransformerInjectable,
TenancyContext,
VendorsExportable
VendorsExportable,
VendorsImportable
],
})
export class VendorsModule {}

View File

@@ -1,32 +1,34 @@
// import { Importable } from '@/services/Import/Importable';
// import { CreateVendor } from './CRUD/CreateVendor.service';
// import { Knex } from 'knex';
// import { Inject, Service } from 'typedi';
// import { VendorsSampleData } from './_SampleData';
import { Knex } from 'knex';
import { VendorsSampleData } from './_SampleData';
import { Injectable } from '@nestjs/common';
import { Importable } from '../Import/Importable';
import { CreateVendorService } from './commands/CreateVendor.service';
import { CreateVendorDto } from './dtos/CreateVendor.dto';
// @Service()
// export class VendorsImportable extends Importable {
// @Inject()
// private createVendorService: CreateVendor;
@Injectable()
export class VendorsImportable extends Importable {
constructor(
private readonly createVendorService: CreateVendorService,
) {
super();
}
// /**
// * Maps the imported data to create a new vendor service.
// * @param {number} tenantId
// * @param {} createDTO
// * @param {Knex.Transaction} trx
// */
// public async importable(
// tenantId: number,
// createDTO: any,
// trx?: Knex.Transaction<any, any[]>
// ): Promise<void> {
// await this.createVendorService.createVendor(tenantId, createDTO, trx);
// }
/**
* Maps the imported data to create a new vendor service.
* @param {CreateVendorDto} createDTO
* @param {Knex.Transaction} trx
*/
public async importable(
createDTO: CreateVendorDto,
trx?: Knex.Transaction<any, any[]>
): Promise<void> {
await this.createVendorService.createVendor(createDTO, trx);
}
// /**
// * Retrieves the sample data of vendors sample sheet.
// */
// public sampleData(): any[] {
// return VendorsSampleData;
// }
// }
/**
* Retrieves the sample data of vendors sample sheet.
*/
public sampleData(): any[] {
return VendorsSampleData;
}
}