Merge pull request 'fix/data' (#42) from fix/data into development
continuous-integration/drone/tag Build is passing
Details
continuous-integration/drone/tag Build is passing
Details
Reviewed-on: #42pull/44/head devel_12.0.0
commit
e1004b3843
|
@ -20,12 +20,16 @@ export class SpecificSearchFilter<Entity = any> {
|
||||||
new Brackets((qb) => {
|
new Brackets((qb) => {
|
||||||
params.forEach((param) => {
|
params.forEach((param) => {
|
||||||
const { cols, data, additional, leftJoin } = param;
|
const { cols, data, additional, leftJoin } = param;
|
||||||
|
const columns = cols.split('.');
|
||||||
|
let arr = data;
|
||||||
|
|
||||||
const arr = data?.map((el) =>
|
if (!columns.includes('status::text')) {
|
||||||
el.includes("'")
|
arr = data?.map((el) =>
|
||||||
? `'%${el.trim().replace(/'/g, "''").replace(/\s+/g, ' ')}%'`
|
el.includes("'")
|
||||||
: `'%${el.trim().replace(/\s+/g, ' ')}%'`,
|
? `'%${el.trim().replace(/'/g, "''").replace(/\s+/g, ' ')}%'`
|
||||||
);
|
: `'%${el.trim().replace(/\s+/g, ' ')}%'`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const aliases = !cols.match(/\./g)
|
const aliases = !cols.match(/\./g)
|
||||||
? this.table.concat(`.${cols}`)
|
? this.table.concat(`.${cols}`)
|
||||||
|
|
|
@ -50,7 +50,7 @@ export abstract class BaseIndexManager<Entity> extends BaseReadManager {
|
||||||
|
|
||||||
// jika searching status terdapat dalam enum, maka dia mencari specific data
|
// jika searching status terdapat dalam enum, maka dia mencari specific data
|
||||||
// ? karena jika tidak, ketika dia search "active" maka "inactive" juga ikut
|
// ? karena jika tidak, ketika dia search "active" maka "inactive" juga ikut
|
||||||
return STATUS[statusData.toUpperCase()] ?? statusData;
|
return `'${STATUS[statusData.toUpperCase()]}'` ?? `'%${statusData}%'`;
|
||||||
});
|
});
|
||||||
specificFilter.push({
|
specificFilter.push({
|
||||||
cols: `${this.tableName}.status::text`,
|
cols: `${this.tableName}.status::text`,
|
||||||
|
|
|
@ -51,7 +51,6 @@ export const PrivilegeAdminConstant = [
|
||||||
menu_label: 'Rekonsiliasi',
|
menu_label: 'Rekonsiliasi',
|
||||||
actions: [
|
actions: [
|
||||||
PrivilegeAction.VIEW,
|
PrivilegeAction.VIEW,
|
||||||
PrivilegeAction.CREATE,
|
|
||||||
PrivilegeAction.CONFIRM,
|
PrivilegeAction.CONFIRM,
|
||||||
PrivilegeAction.DELETE,
|
PrivilegeAction.DELETE,
|
||||||
PrivilegeAction.CANCEL,
|
PrivilegeAction.CANCEL,
|
||||||
|
@ -160,7 +159,7 @@ export const PrivilegePOSConstant = [
|
||||||
{
|
{
|
||||||
menu: 'BOOKING',
|
menu: 'BOOKING',
|
||||||
menu_label: 'Pemesanan',
|
menu_label: 'Pemesanan',
|
||||||
actions: [PrivilegeAction.VIEW, PrivilegeAction.CREATE],
|
actions: [PrivilegeAction.VIEW],
|
||||||
index: 16,
|
index: 16,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||||
|
|
||||||
|
export class AddColumnToRefundTable1722318939681 implements MigrationInterface {
|
||||||
|
name = 'AddColumnToRefundTable1722318939681';
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(
|
||||||
|
`CREATE TYPE "public"."refunds_refund_reason_type_enum" AS ENUM('weather', 'ride malfunction', 'other')`,
|
||||||
|
);
|
||||||
|
await queryRunner.query(
|
||||||
|
`ALTER TABLE "refunds" ADD "refund_reason_type" "public"."refunds_refund_reason_type_enum" NOT NULL DEFAULT 'ride malfunction'`,
|
||||||
|
);
|
||||||
|
await queryRunner.query(`ALTER TABLE "refunds" ADD "refund_reason" text`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(
|
||||||
|
`ALTER TABLE "refunds" DROP COLUMN "refund_reason"`,
|
||||||
|
);
|
||||||
|
await queryRunner.query(
|
||||||
|
`ALTER TABLE "refunds" DROP COLUMN "refund_reason_type"`,
|
||||||
|
);
|
||||||
|
await queryRunner.query(
|
||||||
|
`DROP TYPE "public"."refunds_refund_reason_type_enum"`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,7 +5,10 @@ import { STATUS } from 'src/core/strings/constants/base.constants';
|
||||||
import { ItemType } from 'src/modules/item-related/item-category/constants';
|
import { ItemType } from 'src/modules/item-related/item-category/constants';
|
||||||
import { LimitType } from 'src/modules/item-related/item/constants';
|
import { LimitType } from 'src/modules/item-related/item/constants';
|
||||||
import { PaymentMethodType } from 'src/modules/transaction/payment-method/constants';
|
import { PaymentMethodType } from 'src/modules/transaction/payment-method/constants';
|
||||||
import { RefundType } from 'src/modules/transaction/refund/constants';
|
import {
|
||||||
|
RefundReasonType,
|
||||||
|
RefundType,
|
||||||
|
} from 'src/modules/transaction/refund/constants';
|
||||||
import { GateType } from 'src/modules/web-information/gate/constants';
|
import { GateType } from 'src/modules/web-information/gate/constants';
|
||||||
|
|
||||||
@ApiTags('configuration - constant')
|
@ApiTags('configuration - constant')
|
||||||
|
@ -52,6 +55,11 @@ export class ConstantController {
|
||||||
return Object.values(RefundType);
|
return Object.values(RefundType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Get('refund-reason-type')
|
||||||
|
async refundReasonType(): Promise<any> {
|
||||||
|
return Object.values(RefundReasonType);
|
||||||
|
}
|
||||||
|
|
||||||
@Get('gate-type')
|
@Get('gate-type')
|
||||||
async gateType(): Promise<any> {
|
async gateType(): Promise<any> {
|
||||||
return Object.values(GateType);
|
return Object.values(GateType);
|
||||||
|
|
|
@ -27,7 +27,11 @@ export class UpdateItemCategoryManager extends BaseUpdateManager<ItemCategoryEnt
|
||||||
}
|
}
|
||||||
|
|
||||||
get validateRelations(): validateRelations[] {
|
get validateRelations(): validateRelations[] {
|
||||||
return [];
|
return [
|
||||||
|
{
|
||||||
|
relation: 'items',
|
||||||
|
},
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
get uniqueColumns(): columnUniques[] {
|
get uniqueColumns(): columnUniques[] {
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
import { BaseFilterEntity } from 'src/core/modules/domain/entities/base-filter.entity';
|
import { BaseFilterEntity } from 'src/core/modules/domain/entities/base-filter.entity';
|
||||||
|
import { ItemType } from 'src/modules/item-related/item-category/constants';
|
||||||
|
|
||||||
export interface FilterItemRateEntity extends BaseFilterEntity {
|
export interface FilterItemRateEntity extends BaseFilterEntity {
|
||||||
item_ids: string[];
|
item_ids: string[];
|
||||||
|
item_types: ItemType[];
|
||||||
season_period_ids: string[];
|
season_period_ids: string[];
|
||||||
start_date: Date;
|
start_date: Date;
|
||||||
end_date: Date;
|
end_date: Date;
|
||||||
|
|
|
@ -86,6 +86,7 @@ export class IndexItemRateManager extends BaseIndexManager<ItemEntity> {
|
||||||
get selects(): string[] {
|
get selects(): string[] {
|
||||||
return [
|
return [
|
||||||
`${this.tableName}.id`,
|
`${this.tableName}.id`,
|
||||||
|
`${this.tableName}.item_type`,
|
||||||
`${this.tableName}.status`,
|
`${this.tableName}.status`,
|
||||||
`${this.tableName}.created_at`,
|
`${this.tableName}.created_at`,
|
||||||
`${this.tableName}.name`,
|
`${this.tableName}.name`,
|
||||||
|
|
|
@ -2,6 +2,7 @@ import { BaseFilterDto } from 'src/core/modules/infrastructure/dto/base-filter.d
|
||||||
import { FilterItemRateEntity } from '../../domain/entities/filter-item-rate.entity';
|
import { FilterItemRateEntity } from '../../domain/entities/filter-item-rate.entity';
|
||||||
import { ApiProperty } from '@nestjs/swagger';
|
import { ApiProperty } from '@nestjs/swagger';
|
||||||
import { Transform } from 'class-transformer';
|
import { Transform } from 'class-transformer';
|
||||||
|
import { ItemType } from 'src/modules/item-related/item-category/constants';
|
||||||
|
|
||||||
export class FilterItemRateDto
|
export class FilterItemRateDto
|
||||||
extends BaseFilterDto
|
extends BaseFilterDto
|
||||||
|
@ -21,6 +22,16 @@ export class FilterItemRateDto
|
||||||
})
|
})
|
||||||
end_date: Date;
|
end_date: Date;
|
||||||
|
|
||||||
|
@ApiProperty({
|
||||||
|
type: ['string'],
|
||||||
|
required: false,
|
||||||
|
description: `Select ["${Object.values(ItemType)}"]`,
|
||||||
|
})
|
||||||
|
@Transform((body) => {
|
||||||
|
return Array.isArray(body.value) ? body.value : [body.value];
|
||||||
|
})
|
||||||
|
item_types: ItemType[];
|
||||||
|
|
||||||
@ApiProperty({ type: ['string'], required: false })
|
@ApiProperty({ type: ['string'], required: false })
|
||||||
@Transform((body) => {
|
@Transform((body) => {
|
||||||
return Array.isArray(body.value) ? body.value : [body.value];
|
return Array.isArray(body.value) ? body.value : [body.value];
|
||||||
|
|
|
@ -7,11 +7,8 @@ import {
|
||||||
import { ItemModel } from '../../../data/models/item.model';
|
import { ItemModel } from '../../../data/models/item.model';
|
||||||
import { ItemDeletedEvent } from '../../entities/event/item-deleted.event';
|
import { ItemDeletedEvent } from '../../entities/event/item-deleted.event';
|
||||||
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||||
import {
|
import { Injectable } from '@nestjs/common';
|
||||||
HttpStatus,
|
import { validateRelation } from './helpers/validasi-relation.helper';
|
||||||
Injectable,
|
|
||||||
UnprocessableEntityException,
|
|
||||||
} from '@nestjs/common';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class BatchDeleteItemManager extends BaseBatchDeleteManager<ItemEntity> {
|
export class BatchDeleteItemManager extends BaseBatchDeleteManager<ItemEntity> {
|
||||||
|
@ -20,21 +17,7 @@ export class BatchDeleteItemManager extends BaseBatchDeleteManager<ItemEntity> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async validateData(data: ItemEntity): Promise<void> {
|
async validateData(data: ItemEntity): Promise<void> {
|
||||||
const haveRelation = await this.dataService.getOneByOptions({
|
await validateRelation(this.dataService, data.id);
|
||||||
where: {
|
|
||||||
bundling_items: {
|
|
||||||
id: data.id,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (haveRelation) {
|
|
||||||
throw new UnprocessableEntityException({
|
|
||||||
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
|
||||||
message: `Failed! this data already connected to bunding item`,
|
|
||||||
error: 'Unprocessable Entity',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,10 +8,12 @@ import { ItemModel } from '../../../data/models/item.model';
|
||||||
import { ItemChangeStatusEvent } from '../../entities/event/item-change-status.event';
|
import { ItemChangeStatusEvent } from '../../entities/event/item-change-status.event';
|
||||||
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { validateRelation } from './helpers/validasi-relation.helper';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class BatchInactiveItemManager extends BaseBatchUpdateStatusManager<ItemEntity> {
|
export class BatchInactiveItemManager extends BaseBatchUpdateStatusManager<ItemEntity> {
|
||||||
validateData(data: ItemEntity): Promise<void> {
|
async validateData(data: ItemEntity): Promise<void> {
|
||||||
|
await validateRelation(this.dataService, data.id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,4 @@
|
||||||
import {
|
import { Injectable } from '@nestjs/common';
|
||||||
HttpStatus,
|
|
||||||
Injectable,
|
|
||||||
UnprocessableEntityException,
|
|
||||||
} from '@nestjs/common';
|
|
||||||
import { BaseDeleteManager } from 'src/core/modules/domain/usecase/managers/base-delete.manager';
|
import { BaseDeleteManager } from 'src/core/modules/domain/usecase/managers/base-delete.manager';
|
||||||
import { ItemEntity } from '../../entities/item.entity';
|
import { ItemEntity } from '../../entities/item.entity';
|
||||||
import {
|
import {
|
||||||
|
@ -11,6 +7,7 @@ import {
|
||||||
} from 'src/core/strings/constants/interface.constants';
|
} from 'src/core/strings/constants/interface.constants';
|
||||||
import { ItemModel } from '../../../data/models/item.model';
|
import { ItemModel } from '../../../data/models/item.model';
|
||||||
import { ItemDeletedEvent } from '../../entities/event/item-deleted.event';
|
import { ItemDeletedEvent } from '../../entities/event/item-deleted.event';
|
||||||
|
import { validateRelation } from './helpers/validasi-relation.helper';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class DeleteItemManager extends BaseDeleteManager<ItemEntity> {
|
export class DeleteItemManager extends BaseDeleteManager<ItemEntity> {
|
||||||
|
@ -19,21 +16,7 @@ export class DeleteItemManager extends BaseDeleteManager<ItemEntity> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async validateProcess(): Promise<void> {
|
async validateProcess(): Promise<void> {
|
||||||
const haveRelation = await this.dataService.getOneByOptions({
|
await validateRelation(this.dataService, this.dataId);
|
||||||
where: {
|
|
||||||
bundling_items: {
|
|
||||||
id: this.dataId,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (haveRelation) {
|
|
||||||
throw new UnprocessableEntityException({
|
|
||||||
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
|
||||||
message: `Failed! this data already connected to bunding item`,
|
|
||||||
error: 'Unprocessable Entity',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
import { HttpStatus, UnprocessableEntityException } from '@nestjs/common';
|
||||||
|
|
||||||
|
export async function validateRelation(dataService, id) {
|
||||||
|
const haveRelation = await dataService.getOneByOptions({
|
||||||
|
where: {
|
||||||
|
bundling_items: {
|
||||||
|
id: id,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (haveRelation) {
|
||||||
|
throw new UnprocessableEntityException({
|
||||||
|
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
||||||
|
message: `Failed! this data already connected to bunding item`,
|
||||||
|
error: 'Unprocessable Entity',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,6 +7,7 @@ import {
|
||||||
} from 'src/core/strings/constants/interface.constants';
|
} from 'src/core/strings/constants/interface.constants';
|
||||||
import { ItemModel } from '../../../data/models/item.model';
|
import { ItemModel } from '../../../data/models/item.model';
|
||||||
import { ItemChangeStatusEvent } from '../../entities/event/item-change-status.event';
|
import { ItemChangeStatusEvent } from '../../entities/event/item-change-status.event';
|
||||||
|
import { validateRelation } from './helpers/validasi-relation.helper';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class InactiveItemManager extends BaseUpdateStatusManager<ItemEntity> {
|
export class InactiveItemManager extends BaseUpdateStatusManager<ItemEntity> {
|
||||||
|
@ -15,6 +16,7 @@ export class InactiveItemManager extends BaseUpdateStatusManager<ItemEntity> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async validateProcess(): Promise<void> {
|
async validateProcess(): Promise<void> {
|
||||||
|
await validateRelation(this.dataService, this.dataId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,16 @@ export class IndexItemRatesManager extends BaseIndexManager<ItemRateEntity> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async afterProcess(): Promise<void> {
|
async afterProcess(): Promise<void> {
|
||||||
|
this.result.data?.map((item) => {
|
||||||
|
const item_price =
|
||||||
|
Number(item['item']?.total_price ?? 0) == 0
|
||||||
|
? item['item']?.total_price
|
||||||
|
: item['item']?.base_price;
|
||||||
|
|
||||||
|
Object.assign(item, {
|
||||||
|
price: item.price ?? item_price,
|
||||||
|
});
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +38,7 @@ export class IndexItemRatesManager extends BaseIndexManager<ItemRateEntity> {
|
||||||
joinRelations: [],
|
joinRelations: [],
|
||||||
|
|
||||||
// relation join and select (relasi yang ingin ditampilkan),
|
// relation join and select (relasi yang ingin ditampilkan),
|
||||||
selectRelations: ['season_period', 'season_period.season_type'],
|
selectRelations: ['season_period', 'season_period.season_type', 'item'],
|
||||||
|
|
||||||
// relation yang hanya ingin dihitung (akan return number)
|
// relation yang hanya ingin dihitung (akan return number)
|
||||||
countRelations: [],
|
countRelations: [],
|
||||||
|
@ -41,6 +51,10 @@ export class IndexItemRatesManager extends BaseIndexManager<ItemRateEntity> {
|
||||||
`${this.tableName}.item_id`,
|
`${this.tableName}.item_id`,
|
||||||
`${this.tableName}.price`,
|
`${this.tableName}.price`,
|
||||||
|
|
||||||
|
'item.id',
|
||||||
|
'item.total_price',
|
||||||
|
'item.base_price',
|
||||||
|
|
||||||
`season_period.id`,
|
`season_period.id`,
|
||||||
`season_period.priority`,
|
`season_period.priority`,
|
||||||
`season_period.created_at`,
|
`season_period.created_at`,
|
||||||
|
|
|
@ -2,3 +2,9 @@ export enum RefundType {
|
||||||
BOOKING = 'pengembalian booking',
|
BOOKING = 'pengembalian booking',
|
||||||
WAHANA = 'pengembalian wahana',
|
WAHANA = 'pengembalian wahana',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum RefundReasonType {
|
||||||
|
WEATHER = 'weather',
|
||||||
|
RIDE_MALFUNCTION = 'ride malfunction',
|
||||||
|
OTHER = 'other',
|
||||||
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { Column, Entity, JoinColumn, OneToMany, OneToOne } from 'typeorm';
|
||||||
import { BaseStatusModel } from 'src/core/modules/data/model/base-status.model';
|
import { BaseStatusModel } from 'src/core/modules/data/model/base-status.model';
|
||||||
import { TransactionModel } from 'src/modules/transaction/transaction/data/models/transaction.model';
|
import { TransactionModel } from 'src/modules/transaction/transaction/data/models/transaction.model';
|
||||||
import { RefundItemModel } from './refund-item.model';
|
import { RefundItemModel } from './refund-item.model';
|
||||||
import { RefundType } from '../../constants';
|
import { RefundReasonType, RefundType } from '../../constants';
|
||||||
|
|
||||||
@Entity(TABLE_NAME.REFUND)
|
@Entity(TABLE_NAME.REFUND)
|
||||||
export class RefundModel
|
export class RefundModel
|
||||||
|
@ -33,6 +33,16 @@ export class RefundModel
|
||||||
@Column('decimal', { name: 'refund_total', nullable: true })
|
@Column('decimal', { name: 'refund_total', nullable: true })
|
||||||
refund_total: number;
|
refund_total: number;
|
||||||
|
|
||||||
|
@Column('enum', {
|
||||||
|
name: 'refund_reason_type',
|
||||||
|
enum: RefundReasonType,
|
||||||
|
default: RefundReasonType.RIDE_MALFUNCTION,
|
||||||
|
})
|
||||||
|
refund_reason_type: RefundReasonType;
|
||||||
|
|
||||||
|
@Column('text', { name: 'refund_reason', nullable: true })
|
||||||
|
refund_reason: string;
|
||||||
|
|
||||||
// bank info
|
// bank info
|
||||||
@Column('varchar', { name: 'bank_name', nullable: true })
|
@Column('varchar', { name: 'bank_name', nullable: true })
|
||||||
bank_name: string;
|
bank_name: string;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { BaseStatusEntity } from 'src/core/modules/domain/entities/base-status.entity';
|
import { BaseStatusEntity } from 'src/core/modules/domain/entities/base-status.entity';
|
||||||
import { RefundType } from '../../constants';
|
import { RefundReasonType, RefundType } from '../../constants';
|
||||||
|
|
||||||
export interface RefundEntity extends BaseStatusEntity {
|
export interface RefundEntity extends BaseStatusEntity {
|
||||||
type: RefundType;
|
type: RefundType;
|
||||||
|
@ -8,6 +8,8 @@ export interface RefundEntity extends BaseStatusEntity {
|
||||||
refund_date: Date;
|
refund_date: Date;
|
||||||
refund_sub_total: number;
|
refund_sub_total: number;
|
||||||
refund_total: number;
|
refund_total: number;
|
||||||
|
refund_reason_type: RefundReasonType;
|
||||||
|
refund_reason: string;
|
||||||
|
|
||||||
bank_name: string;
|
bank_name: string;
|
||||||
bank_account_name: string;
|
bank_account_name: string;
|
||||||
|
|
|
@ -17,7 +17,12 @@ import { STATUS } from 'src/core/strings/constants/base.constants';
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class BatchConfirmRefundManager extends BaseBatchUpdateStatusManager<RefundEntity> {
|
export class BatchConfirmRefundManager extends BaseBatchUpdateStatusManager<RefundEntity> {
|
||||||
async validateData(data: RefundEntity): Promise<void> {
|
async validateData(data: RefundEntity): Promise<void> {
|
||||||
if (data?.['transaction']?.status != STATUS.SETTLED) {
|
if (
|
||||||
|
this.data.status == STATUS.DRAFT &&
|
||||||
|
data['trnsaction']?.status != STATUS.SETTLED &&
|
||||||
|
this.data.status == STATUS.PENDING &&
|
||||||
|
data['trnsaction']?.status != STATUS.PROCESS_REFUND
|
||||||
|
) {
|
||||||
throw new UnprocessableEntityException({
|
throw new UnprocessableEntityException({
|
||||||
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
||||||
message: `Failed! only transaction with status ${STATUS.SETTLED} can be refund`,
|
message: `Failed! only transaction with status ${STATUS.SETTLED} can be refund`,
|
||||||
|
|
|
@ -38,7 +38,12 @@ export class ConfirmRefundManager extends BaseUpdateStatusManager<RefundEntity>
|
||||||
relations: ['transaction'],
|
relations: ['transaction'],
|
||||||
});
|
});
|
||||||
|
|
||||||
if (data.transaction.status != STATUS.SETTLED) {
|
if (
|
||||||
|
data.status == STATUS.DRAFT &&
|
||||||
|
data.transaction.status != STATUS.SETTLED &&
|
||||||
|
data.status == STATUS.PENDING &&
|
||||||
|
data.transaction.status != STATUS.PROCESS_REFUND
|
||||||
|
) {
|
||||||
throw new UnprocessableEntityException({
|
throw new UnprocessableEntityException({
|
||||||
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
||||||
message: `Failed! only transaction with status ${STATUS.SETTLED} can be refund`,
|
message: `Failed! only transaction with status ${STATUS.SETTLED} can be refund`,
|
||||||
|
|
|
@ -39,6 +39,8 @@ export class DetailRefundManager extends BaseDetailManager<RefundEntity> {
|
||||||
`${this.tableName}.status`,
|
`${this.tableName}.status`,
|
||||||
`${this.tableName}.type`,
|
`${this.tableName}.type`,
|
||||||
|
|
||||||
|
`${this.tableName}.refund_reason`,
|
||||||
|
`${this.tableName}.refund_reason_type`,
|
||||||
`${this.tableName}.request_date`,
|
`${this.tableName}.request_date`,
|
||||||
`${this.tableName}.refund_date`,
|
`${this.tableName}.refund_date`,
|
||||||
`${this.tableName}.created_at`,
|
`${this.tableName}.created_at`,
|
||||||
|
|
|
@ -50,6 +50,8 @@ export class IndexRefundManager extends BaseIndexManager<RefundEntity> {
|
||||||
`${this.tableName}.status`,
|
`${this.tableName}.status`,
|
||||||
`${this.tableName}.type`,
|
`${this.tableName}.type`,
|
||||||
|
|
||||||
|
`${this.tableName}.refund_reason`,
|
||||||
|
`${this.tableName}.refund_reason_type`,
|
||||||
`${this.tableName}.request_date`,
|
`${this.tableName}.request_date`,
|
||||||
`${this.tableName}.refund_date`,
|
`${this.tableName}.refund_date`,
|
||||||
`${this.tableName}.created_at`,
|
`${this.tableName}.created_at`,
|
||||||
|
|
|
@ -4,9 +4,25 @@ import { ApiProperty } from '@nestjs/swagger';
|
||||||
import { IsNumber, IsString, ValidateIf } from 'class-validator';
|
import { IsNumber, IsString, ValidateIf } from 'class-validator';
|
||||||
import { Exclude } from 'class-transformer';
|
import { Exclude } from 'class-transformer';
|
||||||
import { TransactionEntity } from 'src/modules/transaction/transaction/domain/entities/transaction.entity';
|
import { TransactionEntity } from 'src/modules/transaction/transaction/domain/entities/transaction.entity';
|
||||||
import { RefundType } from '../../constants';
|
import { RefundReasonType, RefundType } from '../../constants';
|
||||||
|
|
||||||
export class RefundDto extends BaseStatusDto implements RefundEntity {
|
export class RefundDto extends BaseStatusDto implements RefundEntity {
|
||||||
|
@ApiProperty({
|
||||||
|
type: String,
|
||||||
|
required: true,
|
||||||
|
example: RefundReasonType.RIDE_MALFUNCTION,
|
||||||
|
})
|
||||||
|
@IsString()
|
||||||
|
refund_reason_type: RefundReasonType;
|
||||||
|
|
||||||
|
@ApiProperty({
|
||||||
|
type: String,
|
||||||
|
required: false,
|
||||||
|
example: '',
|
||||||
|
})
|
||||||
|
@ValidateIf((object) => object.refund_reason_type == RefundReasonType.OTHER)
|
||||||
|
refund_reason: string;
|
||||||
|
|
||||||
@ApiProperty({
|
@ApiProperty({
|
||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
|
|
|
@ -51,6 +51,7 @@ export class BatchConfirmTransactionManager extends BaseBatchUpdateStatusManager
|
||||||
Object.assign(data, {
|
Object.assign(data, {
|
||||||
invoice_code: await generateInvoiceCodeHelper(this.dataService, 'INV'),
|
invoice_code: await generateInvoiceCodeHelper(this.dataService, 'INV'),
|
||||||
status: freeTransaction ? STATUS.ACTIVE : STATUS.PENDING,
|
status: freeTransaction ? STATUS.ACTIVE : STATUS.PENDING,
|
||||||
|
invoice_date: new Date(),
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,6 +61,7 @@ export class ConfirmTransactionManager extends BaseUpdateStatusManager<Transacti
|
||||||
? null
|
? null
|
||||||
: await generateInvoiceCodeHelper(this.dataService, 'INV'),
|
: await generateInvoiceCodeHelper(this.dataService, 'INV'),
|
||||||
status: freeTransaction ? STATUS.ACTIVE : STATUS.PENDING,
|
status: freeTransaction ? STATUS.ACTIVE : STATUS.PENDING,
|
||||||
|
invoice_date: new Date(),
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,10 +103,9 @@ export class TransactionDto extends BaseStatusDto {
|
||||||
|
|
||||||
@ApiProperty({
|
@ApiProperty({
|
||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: false,
|
||||||
example: TransactionPaymentType.MIDTRANS,
|
example: TransactionPaymentType.MIDTRANS,
|
||||||
})
|
})
|
||||||
@IsString()
|
|
||||||
payment_type: TransactionPaymentType;
|
payment_type: TransactionPaymentType;
|
||||||
|
|
||||||
@ApiProperty({
|
@ApiProperty({
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
import { BaseFilterEntity } from 'src/core/modules/domain/entities/base-filter.entity';
|
import { BaseFilterEntity } from 'src/core/modules/domain/entities/base-filter.entity';
|
||||||
|
|
||||||
export interface FilterBannerEntity extends BaseFilterEntity {}
|
export interface FilterBannerEntity extends BaseFilterEntity {
|
||||||
|
titles: string[];
|
||||||
|
}
|
||||||
|
|
|
@ -52,8 +52,8 @@ export class IndexBannerManager extends BaseIndexManager<BannerEntity> {
|
||||||
get specificFilter(): Param[] {
|
get specificFilter(): Param[] {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
cols: `${this.tableName}.name`,
|
cols: `${this.tableName}.title`,
|
||||||
data: this.filterParam.names,
|
data: this.filterParam.titles,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,15 @@
|
||||||
import { BaseFilterDto } from 'src/core/modules/infrastructure/dto/base-filter.dto';
|
import { BaseFilterDto } from 'src/core/modules/infrastructure/dto/base-filter.dto';
|
||||||
import { FilterBannerEntity } from '../../domain/entities/filter-banner.entity';
|
import { FilterBannerEntity } from '../../domain/entities/filter-banner.entity';
|
||||||
|
import { Transform } from 'class-transformer';
|
||||||
|
import { ApiProperty } from '@nestjs/swagger';
|
||||||
|
|
||||||
export class FilterBannerDto
|
export class FilterBannerDto
|
||||||
extends BaseFilterDto
|
extends BaseFilterDto
|
||||||
implements FilterBannerEntity {}
|
implements FilterBannerEntity
|
||||||
|
{
|
||||||
|
@ApiProperty({ type: ['string'], required: false })
|
||||||
|
@Transform((body) => {
|
||||||
|
return Array.isArray(body.value) ? body.value : [body.value];
|
||||||
|
})
|
||||||
|
titles: string[];
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue