feat(SPG-384) REST API Read Booking
parent
36d430484e
commit
ac522bc55a
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -14,6 +14,69 @@ export class DetailTransactionManager extends BaseDetailManager<TransactionEntit
|
|||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
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<TransactionEntit
|
|||
joinRelations: [],
|
||||
|
||||
// relation join and select (relasi yang ingin ditampilkan),
|
||||
selectRelations: [],
|
||||
selectRelations: ['items'],
|
||||
|
||||
// relation yang hanya ingin dihitung (akan return number)
|
||||
countRelations: [],
|
||||
|
@ -31,7 +94,43 @@ export class DetailTransactionManager extends BaseDetailManager<TransactionEntit
|
|||
}
|
||||
|
||||
get selects(): string[] {
|
||||
return [];
|
||||
return [
|
||||
`${this.tableName}.id`,
|
||||
`${this.tableName}.creator_name`,
|
||||
`${this.tableName}.created_at`,
|
||||
`${this.tableName}.updated_at`,
|
||||
`${this.tableName}.editor_name`,
|
||||
`${this.tableName}.invoice_code`,
|
||||
|
||||
`${this.tableName}.season_period_id`,
|
||||
`${this.tableName}.season_period_name`,
|
||||
`${this.tableName}.season_period_type_id`,
|
||||
`${this.tableName}.season_period_type_name`,
|
||||
|
||||
`${this.tableName}.status`,
|
||||
`${this.tableName}.no_of_group`,
|
||||
`${this.tableName}.customer_type`,
|
||||
`${this.tableName}.customer_name`,
|
||||
`${this.tableName}.customer_phone`,
|
||||
`${this.tableName}.customer_email`,
|
||||
`${this.tableName}.customer_description`,
|
||||
`${this.tableName}.booking_date`,
|
||||
|
||||
`${this.tableName}.discount_percentage`,
|
||||
`${this.tableName}.discount_value`,
|
||||
`${this.tableName}.payment_type`,
|
||||
`${this.tableName}.payment_date`,
|
||||
`${this.tableName}.payment_total_pay`,
|
||||
`${this.tableName}.payment_type_method_id`,
|
||||
`${this.tableName}.payment_type_method_name`,
|
||||
`${this.tableName}.payment_type_method_number`,
|
||||
|
||||
`${this.tableName}.payment_sub_total`,
|
||||
`${this.tableName}.payment_discount_total`,
|
||||
`${this.tableName}.payment_total`,
|
||||
|
||||
'items',
|
||||
];
|
||||
}
|
||||
|
||||
get setFindProperties(): any {
|
||||
|
|
|
@ -27,7 +27,7 @@ export class IndexTransactionManager extends BaseIndexManager<TransactionEntity>
|
|||
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<TransactionEntity>
|
|||
}
|
||||
|
||||
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<TransactionEntity>
|
|||
setQueryFilter(
|
||||
queryBuilder: SelectQueryBuilder<TransactionEntity>,
|
||||
): SelectQueryBuilder<TransactionEntity> {
|
||||
queryBuilder.andWhere(`${this.tableName}.is_recap_transaction is false`);
|
||||
return queryBuilder;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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({
|
||||
|
|
Loading…
Reference in New Issue