diff --git a/src/modules/transaction/profit-share-formula/domain/usecases/managers/index-profit-share-formula.manager.ts b/src/modules/transaction/profit-share-formula/domain/usecases/managers/index-profit-share-formula.manager.ts new file mode 100644 index 0000000..f03482e --- /dev/null +++ b/src/modules/transaction/profit-share-formula/domain/usecases/managers/index-profit-share-formula.manager.ts @@ -0,0 +1,56 @@ +import { Injectable } from '@nestjs/common'; +import { + Param, + RelationParam, +} from 'src/core/modules/domain/entities/base-filter.entity'; +import { FormulaType } from 'src/modules/transaction/sales-price-formula/constants'; +import { SalesPriceFormulaEntity } from 'src/modules/transaction/sales-price-formula/domain/entities/sales-price-formula.entity'; +import { BaseIndexManager } from 'src/core/modules/domain/usecase/managers/base-index.manager'; +import { SelectQueryBuilder } from 'typeorm'; + +@Injectable() +export class IndexProfitShareFormulaManager extends BaseIndexManager { + setQueryFilter( + queryBuilder: SelectQueryBuilder, + ): SelectQueryBuilder { + return queryBuilder; + } + + get specificFilter(): Param[] { + return [ + { + cols: `${this.tableName}.type::text`, + data: [FormulaType.PROFIT_SHARE], + }, + ]; + } + + async prepareData(): Promise { + return; + } + + async beforeProcess(): Promise { + return; + } + + async afterProcess(): Promise { + return; + } + + get relations(): RelationParam { + return { + // relation only join (for query purpose) + joinRelations: [], + + // relation join and select (relasi yang ingin ditampilkan), + selectRelations: [], + + // relation yang hanya ingin dihitung (akan return number) + countRelations: [], + }; + } + + get selects(): string[] { + return []; + } +} diff --git a/src/modules/transaction/profit-share-formula/domain/usecases/profit-share-formula-read.orchestrator.ts b/src/modules/transaction/profit-share-formula/domain/usecases/profit-share-formula-read.orchestrator.ts index ef86f67..9dffdab 100644 --- a/src/modules/transaction/profit-share-formula/domain/usecases/profit-share-formula-read.orchestrator.ts +++ b/src/modules/transaction/profit-share-formula/domain/usecases/profit-share-formula-read.orchestrator.ts @@ -3,14 +3,24 @@ import { DetailProfitShareFormulaManager } from './managers/detail-profit-share- import { TABLE_NAME } from 'src/core/strings/constants/table.constants'; import { SalesPriceFormulaReadService } from 'src/modules/transaction/sales-price-formula/data/services/sales-price-formula-read.service'; import { SalesPriceFormulaEntity } from 'src/modules/transaction/sales-price-formula/domain/entities/sales-price-formula.entity'; +import { IndexProfitShareFormulaManager } from './managers/index-profit-share-formula.manager'; @Injectable() export class ProfitShareFormulaReadOrchestrator { constructor( private detailManager: DetailProfitShareFormulaManager, + private indexManager: IndexProfitShareFormulaManager, private serviceData: SalesPriceFormulaReadService, ) {} + async index(): Promise { + this.indexManager.setFilterParam({}); + this.indexManager.setService(this.serviceData, TABLE_NAME.PRICE_FORMULA); + await this.indexManager.execute(); + const { data } = this.indexManager.getResult(); + return data; + } + async detail(): Promise { this.detailManager.setData(''); this.detailManager.setService(this.serviceData, TABLE_NAME.PRICE_FORMULA); diff --git a/src/modules/transaction/profit-share-formula/infrastructure/profit-share-formula-read.controller.ts b/src/modules/transaction/profit-share-formula/infrastructure/profit-share-formula-read.controller.ts index 7a12ffe..aa4c92d 100644 --- a/src/modules/transaction/profit-share-formula/infrastructure/profit-share-formula-read.controller.ts +++ b/src/modules/transaction/profit-share-formula/infrastructure/profit-share-formula-read.controller.ts @@ -1,4 +1,4 @@ -import { Controller, Get, Param } from '@nestjs/common'; +import { Controller, Get } from '@nestjs/common'; import { ProfitShareFormulaReadOrchestrator } from '../domain/usecases/profit-share-formula-read.orchestrator'; import { ApiBearerAuth, ApiTags } from '@nestjs/swagger'; import { Public } from 'src/core/guards'; @@ -15,4 +15,9 @@ export class ProfitShareFormulaReadController { async detail(): Promise { return await this.orchestrator.detail(); } + + @Get('detail') + async breakdown(): Promise { + return await this.orchestrator.index(); + } } diff --git a/src/modules/transaction/profit-share-formula/profit-share-formula.module.ts b/src/modules/transaction/profit-share-formula/profit-share-formula.module.ts index 31ff6f2..51b8947 100644 --- a/src/modules/transaction/profit-share-formula/profit-share-formula.module.ts +++ b/src/modules/transaction/profit-share-formula/profit-share-formula.module.ts @@ -12,6 +12,7 @@ import { DetailProfitShareFormulaManager } from './domain/usecases/managers/deta import { SalesPriceFormulaModel } from '../sales-price-formula/data/models/sales-price-formula.model'; import { TaxDataService } from '../tax/data/services/tax-data.service'; import { TaxModel } from '../tax/data/models/tax.model'; +import { IndexProfitShareFormulaManager } from './domain/usecases/managers/index-profit-share-formula.manager'; @Module({ imports: [ @@ -29,6 +30,7 @@ import { TaxModel } from '../tax/data/models/tax.model'; providers: [ DetailProfitShareFormulaManager, UpdateProfitShareFormulaManager, + IndexProfitShareFormulaManager, ProfitShareFormulaDataOrchestrator, ProfitShareFormulaReadOrchestrator,