Compare commits
No commits in common. "6632222c4b46b59f6b073b157a894ffdad732f6a" and "b3f0752ca0bfe97aefde4348d35bb43dd3e0acd7" have entirely different histories.
6632222c4b
...
b3f0752ca0
|
@ -20,16 +20,12 @@ 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;
|
|
||||||
|
|
||||||
if (!columns.includes('status::text')) {
|
const arr = data?.map((el) =>
|
||||||
arr = data?.map((el) =>
|
el.includes("'")
|
||||||
el.includes("'")
|
? `'%${el.trim().replace(/'/g, "''").replace(/\s+/g, ' ')}%'`
|
||||||
? `'%${el.trim().replace(/'/g, "''").replace(/\s+/g, ' ')}%'`
|
: `'%${el.trim().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`,
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
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,10 +5,7 @@ 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 {
|
import { RefundType } from 'src/modules/transaction/refund/constants';
|
||||||
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')
|
||||||
|
@ -55,11 +52,6 @@ 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);
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
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,7 +86,6 @@ 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,7 +2,6 @@ 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
|
||||||
|
@ -22,16 +21,6 @@ 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,8 +7,11 @@ 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 { Injectable } from '@nestjs/common';
|
import {
|
||||||
import { validateRelation } from './helpers/validasi-relation.helper';
|
HttpStatus,
|
||||||
|
Injectable,
|
||||||
|
UnprocessableEntityException,
|
||||||
|
} from '@nestjs/common';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class BatchDeleteItemManager extends BaseBatchDeleteManager<ItemEntity> {
|
export class BatchDeleteItemManager extends BaseBatchDeleteManager<ItemEntity> {
|
||||||
|
@ -17,7 +20,21 @@ export class BatchDeleteItemManager extends BaseBatchDeleteManager<ItemEntity> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async validateData(data: ItemEntity): Promise<void> {
|
async validateData(data: ItemEntity): Promise<void> {
|
||||||
await validateRelation(this.dataService, data.id);
|
const haveRelation = await this.dataService.getOneByOptions({
|
||||||
|
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,12 +8,10 @@ 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> {
|
||||||
async validateData(data: ItemEntity): Promise<void> {
|
validateData(data: ItemEntity): Promise<void> {
|
||||||
await validateRelation(this.dataService, data.id);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
import { Injectable } from '@nestjs/common';
|
import {
|
||||||
|
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 {
|
||||||
|
@ -7,7 +11,6 @@ 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> {
|
||||||
|
@ -16,7 +19,21 @@ export class DeleteItemManager extends BaseDeleteManager<ItemEntity> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async validateProcess(): Promise<void> {
|
async validateProcess(): Promise<void> {
|
||||||
await validateRelation(this.dataService, this.dataId);
|
const haveRelation = await this.dataService.getOneByOptions({
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
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,7 +7,6 @@ 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> {
|
||||||
|
@ -16,7 +15,6 @@ export class InactiveItemManager extends BaseUpdateStatusManager<ItemEntity> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async validateProcess(): Promise<void> {
|
async validateProcess(): Promise<void> {
|
||||||
await validateRelation(this.dataService, this.dataId);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,16 +19,6 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +28,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', 'item'],
|
selectRelations: ['season_period', 'season_period.season_type'],
|
||||||
|
|
||||||
// relation yang hanya ingin dihitung (akan return number)
|
// relation yang hanya ingin dihitung (akan return number)
|
||||||
countRelations: [],
|
countRelations: [],
|
||||||
|
@ -51,10 +41,6 @@ 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,9 +2,3 @@ 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 { RefundReasonType, RefundType } from '../../constants';
|
import { RefundType } from '../../constants';
|
||||||
|
|
||||||
@Entity(TABLE_NAME.REFUND)
|
@Entity(TABLE_NAME.REFUND)
|
||||||
export class RefundModel
|
export class RefundModel
|
||||||
|
@ -33,16 +33,6 @@ 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 { RefundReasonType, RefundType } from '../../constants';
|
import { RefundType } from '../../constants';
|
||||||
|
|
||||||
export interface RefundEntity extends BaseStatusEntity {
|
export interface RefundEntity extends BaseStatusEntity {
|
||||||
type: RefundType;
|
type: RefundType;
|
||||||
|
@ -8,8 +8,6 @@ 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,12 +17,7 @@ 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 (
|
if (data?.['transaction']?.status != STATUS.SETTLED) {
|
||||||
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,12 +38,7 @@ export class ConfirmRefundManager extends BaseUpdateStatusManager<RefundEntity>
|
||||||
relations: ['transaction'],
|
relations: ['transaction'],
|
||||||
});
|
});
|
||||||
|
|
||||||
if (
|
if (data.transaction.status != STATUS.SETTLED) {
|
||||||
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,8 +39,6 @@ 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,8 +50,6 @@ 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,25 +4,9 @@ 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 { RefundReasonType, RefundType } from '../../constants';
|
import { 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,7 +51,6 @@ 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,7 +61,6 @@ 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,9 +103,10 @@ export class TransactionDto extends BaseStatusDto {
|
||||||
|
|
||||||
@ApiProperty({
|
@ApiProperty({
|
||||||
type: String,
|
type: String,
|
||||||
required: false,
|
required: true,
|
||||||
example: TransactionPaymentType.MIDTRANS,
|
example: TransactionPaymentType.MIDTRANS,
|
||||||
})
|
})
|
||||||
|
@IsString()
|
||||||
payment_type: TransactionPaymentType;
|
payment_type: TransactionPaymentType;
|
||||||
|
|
||||||
@ApiProperty({
|
@ApiProperty({
|
||||||
|
|
Loading…
Reference in New Issue