feat(SPG-651) BE Reason Refund Request
parent
7e38a67e80
commit
3e85d40885
|
@ -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);
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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,
|
||||||
|
|
Loading…
Reference in New Issue