diff --git a/src/modules/transaction/transaction/domain/entities/filter-transaction.entity.ts b/src/modules/transaction/transaction/domain/entities/filter-transaction.entity.ts index 13bd3af..719a7fb 100644 --- a/src/modules/transaction/transaction/domain/entities/filter-transaction.entity.ts +++ b/src/modules/transaction/transaction/domain/entities/filter-transaction.entity.ts @@ -1,3 +1,36 @@ import { BaseFilterEntity } from 'src/core/modules/domain/entities/base-filter.entity'; -export interface FilterTransactionEntity extends BaseFilterEntity {} +export interface FilterTransactionEntity extends BaseFilterEntity { + // search mdr + customer_names?: string[]; + confirm_by_names?: string[]; + payment_banks?: string[]; + payment_bank_numbers?: string[]; + + // seatch booking; + payment_types?: string[]; + types?: string[]; + customer_types?: string[]; + invoice_codes?: string[]; + refund_codes?: string[]; + creator_names?: string[]; + + // filter mdr + payment_date_from?: Date; + payment_date_to?: Date; + transaction_type?: string; + couner_no?: number; + payment_type?: string; + payment_via?: string; + payment_bank?: string; + confirmation_date_from?: Date; + confirmation_date_to?: Date; + + // filter booking + booking_date_from?: Date; + booking_date_to?: Date; + invoice_date_from?: Date; + invoice_date_to?: Date; + settlement_date_from?: Date; + settlement_date_to?: Date; +} diff --git a/src/modules/transaction/transaction/domain/usecases/managers/detail-transaction.manager.ts b/src/modules/transaction/transaction/domain/usecases/managers/detail-transaction.manager.ts index 16da999..593fdb7 100644 --- a/src/modules/transaction/transaction/domain/usecases/managers/detail-transaction.manager.ts +++ b/src/modules/transaction/transaction/domain/usecases/managers/detail-transaction.manager.ts @@ -14,6 +14,69 @@ export class DetailTransactionManager extends BaseDetailManager { + let payment_type_bank; + + const season_period = { + id: this.result.season_period_id, + holiday_name: this.result.season_period_name, + season_type: { + id: this.result.season_period_type_id, + name: this.result.season_period_type_name, + }, + }; + + if (this.result.payment_type_method_id) { + payment_type_bank = { + id: this.result.payment_type_method_id, + issuer_name: this.result.payment_type_method_name, + account_number: this.result.payment_type_method_number, + }; + } + + const items = this.result?.['items']?.map((itemData) => { + let tenant; + + if (itemData.item_tenant_id) { + tenant = { + id: itemData.item_tenant_id, + name: itemData.item_tenant_name, + share_margin: itemData.item_tenant_share_margin, + }; + } + + return { + item: { + id: itemData.item_id, + name: itemData.item_name, + item_type: itemData.item_type, + base_price: itemData.item_price, + hpp: itemData.item_hpp, + tenant: tenant, + item_category: { + id: itemData.item_category_id, + name: itemData.item_category_name, + }, + }, + id: itemData.item_category_id, + name: itemData.item_category_name, + }; + }); + + Object.assign(this.result, { + season_period: season_period, + items: items, + payment_type_bank: payment_type_bank, + }); + + delete this.result.season_period_id; + delete this.result.season_period_name; + delete this.result.season_period_type_id; + delete this.result.season_period_type_name; + + delete this.result.payment_type_method_id; + delete this.result.payment_type_method_name; + delete this.result.payment_type_method_number; + return; } @@ -23,7 +86,7 @@ export class DetailTransactionManager extends BaseDetailManager joinRelations: [], // relation join and select (relasi yang ingin ditampilkan), - selectRelations: [], + selectRelations: ['items'], // relation yang hanya ingin dihitung (akan return number) countRelations: [], @@ -35,7 +35,26 @@ export class IndexTransactionManager extends BaseIndexManager } get selects(): string[] { - return []; + return [ + `${this.tableName}.id`, + `${this.tableName}.status`, + `${this.tableName}.invoice_code`, + `${this.tableName}.booking_date`, + `${this.tableName}.no_of_group`, + `${this.tableName}.type`, + `${this.tableName}.payment_total`, + `${this.tableName}.customer_type`, + `${this.tableName}.customer_name`, + `${this.tableName}.customer_phone`, + `${this.tableName}.customer_description`, + `${this.tableName}.customer_email`, + `${this.tableName}.invoice_date`, + `${this.tableName}.settlement_date`, + `${this.tableName}.created_at`, + `${this.tableName}.creator_name`, + `${this.tableName}.editor_id`, + `${this.tableName}.editor_name`, + ]; } get specificFilter(): Param[] { @@ -50,6 +69,7 @@ export class IndexTransactionManager extends BaseIndexManager setQueryFilter( queryBuilder: SelectQueryBuilder, ): SelectQueryBuilder { + queryBuilder.andWhere(`${this.tableName}.is_recap_transaction is false`); return queryBuilder; } } diff --git a/src/modules/transaction/transaction/infrastructure/dto/filter-transaction.dto.ts b/src/modules/transaction/transaction/infrastructure/dto/filter-transaction.dto.ts index 57ec65a..fc83ebf 100644 --- a/src/modules/transaction/transaction/infrastructure/dto/filter-transaction.dto.ts +++ b/src/modules/transaction/transaction/infrastructure/dto/filter-transaction.dto.ts @@ -1,6 +1,75 @@ import { BaseFilterDto } from 'src/core/modules/infrastructure/dto/base-filter.dto'; import { FilterTransactionEntity } from '../../domain/entities/filter-transaction.entity'; +import { Transform } from 'class-transformer'; +import { ApiProperty } from '@nestjs/swagger'; export class FilterTransactionDto extends BaseFilterDto - implements FilterTransactionEntity {} + implements FilterTransactionEntity +{ + @ApiProperty({ type: ['string'], required: false }) + @Transform((body) => { + return Array.isArray(body.value) ? body.value : [body.value]; + }) + types?: string[]; + + @ApiProperty({ type: ['string'], required: false }) + @Transform((body) => { + return Array.isArray(body.value) ? body.value : [body.value]; + }) + customer_types?: string[]; + + @ApiProperty({ type: ['string'], required: false }) + @Transform((body) => { + return Array.isArray(body.value) ? body.value : [body.value]; + }) + customer_names?: string[]; + + @ApiProperty({ type: ['string'], required: false }) + @Transform((body) => { + return Array.isArray(body.value) ? body.value : [body.value]; + }) + payment_types?: string[]; + + @ApiProperty({ type: ['string'], required: false }) + @Transform((body) => { + return Array.isArray(body.value) ? body.value : [body.value]; + }) + payment_banks?: string[]; + + @ApiProperty({ type: ['string'], required: false }) + @Transform((body) => { + return Array.isArray(body.value) ? body.value : [body.value]; + }) + invoice_codes?: string[]; + + @ApiProperty({ type: ['string'], required: false }) + @Transform((body) => { + return Array.isArray(body.value) ? body.value : [body.value]; + }) + refund_codes?: string[]; + + @ApiProperty({ type: ['string'], required: false }) + @Transform((body) => { + return Array.isArray(body.value) ? body.value : [body.value]; + }) + creator_names?: string[]; + + @ApiProperty({ type: Date, required: false }) + booking_date_from?: Date; + + @ApiProperty({ type: Date, required: false }) + booking_date_to?: Date; + + @ApiProperty({ type: Date, required: false }) + invoice_date_from?: Date; + + @ApiProperty({ type: Date, required: false }) + invoice_date_to?: Date; + + @ApiProperty({ type: Date, required: false }) + settlement_date_from?: Date; + + @ApiProperty({ type: Date, required: false }) + settlement_date_to?: Date; +} diff --git a/src/modules/transaction/transaction/infrastructure/dto/transaction.dto.ts b/src/modules/transaction/transaction/infrastructure/dto/transaction.dto.ts index cc03ddf..cbb954b 100644 --- a/src/modules/transaction/transaction/infrastructure/dto/transaction.dto.ts +++ b/src/modules/transaction/transaction/infrastructure/dto/transaction.dto.ts @@ -11,7 +11,6 @@ import { } from 'class-validator'; import { SeasonPeriodEntity } from 'src/modules/season-related/season-period/domain/entities/season-period.entity'; import { TransactionItemEntity } from '../../domain/entities/transaction-item.entity'; -import { TransactionItemDto } from './transaction-item.dto'; export class TransactionDto extends BaseStatusDto { @ApiProperty({