fix(SPG-590) Pemesanan - Konfirmasi dari status draft muncul error

pull/13/head
Aswin Ashar Abdullah 2024-07-05 06:50:33 +07:00
parent b9c5cb17d3
commit cafbb82af6
9 changed files with 114 additions and 8 deletions

View File

@ -31,4 +31,31 @@ export class ConstantController {
async paymentMethodType(): Promise<any> { async paymentMethodType(): Promise<any> {
return Object.values(PaymentMethodType); return Object.values(PaymentMethodType);
} }
@Get('transaction-user-type')
async userType(): Promise<any> {
return [
'group',
'vip'
];
}
@Get('transaction-payment-type')
async transactionPaymentType(): Promise<any> {
return [
'midtrans',
'bank transfer',
'qris',
'counter',
];
}
@Get('transaction-type')
async transactionType(): Promise<any> {
return [
'counter',
'admin',
'online'
]
}
} }

View File

@ -68,6 +68,20 @@ export class IndexItemRatesManager extends BaseIndexManager<ItemRateEntity> {
itemIds: this.filterParam.item_ids, itemIds: this.filterParam.item_ids,
}); });
} }
if (this.filterParam.start_date) {
queryBuilder.andWhere(`season_period.start_date BETWEEN :from AND :to`, {
from: this.filterParam.start_date,
to: this.filterParam.end_date,
});
}
if (this.filterParam.end_date) {
queryBuilder.andWhere(`season_period.end_date BETWEEN :from AND :to`, {
from: this.filterParam.start_date,
to: this.filterParam.end_date,
});
}
return queryBuilder; return queryBuilder;
} }
} }

View File

@ -18,7 +18,7 @@ export class TransactionModel
implements TransactionEntity implements TransactionEntity
{ {
// general info // general info
@Column('bool', { name: 'is_recap_transaction', default: true }) @Column('bool', { name: 'is_recap_transaction', default: false })
is_recap_transaction: boolean; is_recap_transaction: boolean;
@Column('enum', { @Column('enum', {

View File

@ -17,14 +17,43 @@ import { STATUS } from 'src/core/strings/constants/base.constants';
@Injectable() @Injectable()
export class BatchConfirmDataTransactionManager extends BaseBatchUpdateStatusManager<TransactionEntity> { export class BatchConfirmDataTransactionManager extends BaseBatchUpdateStatusManager<TransactionEntity> {
validateData(data: TransactionEntity): Promise<void> { validateData(data: TransactionEntity): Promise<void> {
if (data.status != STATUS.DRAFT) { if (
[STATUS.PENDING, STATUS.REJECTED, STATUS.EXPIRED].includes(data.status)
) {
throw new UnprocessableEntityException({ throw new UnprocessableEntityException({
statusCode: HttpStatus.UNPROCESSABLE_ENTITY, statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
message: `Failed! only data booking with status ${STATUS.ACTIVE} can be confirm`, message: `Failed! only data booking with status ${STATUS.PENDING}, ${STATUS.REJECTED}, ${STATUS.EXPIRED} can be confirm`,
error: 'Unprocessable Entity', error: 'Unprocessable Entity',
}); });
} }
switch (data.status) {
// jika confirm status pending
// maka akan kebuat reconsiliasi
case STATUS.PENDING:
data.reconciliation_status = STATUS.PENDING;
break;
// jika confirm status rejected
case STATUS.REJECTED:
data.reconciliation_status = STATUS.PENDING;
break;
// jika confirm status expired
case STATUS.EXPIRED:
break;
default:
data.reconciliation_status = STATUS.PENDING;
break;
}
const freeTransaction = data.payment_total < 1;
Object.assign(data, {
status: freeTransaction ? STATUS.ACTIVE : STATUS.PENDING,
});
return; return;
} }

View File

@ -7,11 +7,23 @@ import {
import { TransactionModel } from '../../../data/models/transaction.model'; import { TransactionModel } from '../../../data/models/transaction.model';
import { TransactionChangeStatusEvent } from '../../entities/event/transaction-change-status.event'; import { TransactionChangeStatusEvent } from '../../entities/event/transaction-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 {
HttpStatus,
Injectable,
UnprocessableEntityException,
} from '@nestjs/common';
import { STATUS } from 'src/core/strings/constants/base.constants';
@Injectable() @Injectable()
export class BatchConfirmTransactionManager extends BaseBatchUpdateStatusManager<TransactionEntity> { export class BatchConfirmTransactionManager extends BaseBatchUpdateStatusManager<TransactionEntity> {
validateData(data: TransactionEntity): Promise<void> { validateData(data: TransactionEntity): Promise<void> {
if (data.status != STATUS.DRAFT) {
throw new UnprocessableEntityException({
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
message: `Failed! only data booking with status ${STATUS.ACTIVE} can be confirm`,
error: 'Unprocessable Entity',
});
}
return; return;
} }

View File

@ -1,4 +1,8 @@
import { Injectable } from '@nestjs/common'; import {
HttpStatus,
Injectable,
UnprocessableEntityException,
} from '@nestjs/common';
import { BaseUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-update-status.manager'; import { BaseUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-update-status.manager';
import { TransactionEntity } from '../../entities/transaction.entity'; import { TransactionEntity } from '../../entities/transaction.entity';
import { import {
@ -22,6 +26,16 @@ export class ConfirmDataTransactionManager extends BaseUpdateStatusManager<Trans
async beforeProcess(): Promise<void> { async beforeProcess(): Promise<void> {
const old_status = this.oldData.status; const old_status = this.oldData.status;
if (
[STATUS.PENDING, STATUS.REJECTED, STATUS.EXPIRED].includes(old_status)
) {
throw new UnprocessableEntityException({
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
message: `Failed! only data booking with status ${STATUS.PENDING}, ${STATUS.REJECTED}, ${STATUS.EXPIRED} can be confirm`,
error: 'Unprocessable Entity',
});
}
switch (old_status) { switch (old_status) {
// jika confirm status pending // jika confirm status pending
// maka akan kebuat reconsiliasi // maka akan kebuat reconsiliasi

View File

@ -20,7 +20,7 @@ export class ConfirmTransactionManager extends BaseUpdateStatusManager<Transacti
} }
async validateProcess(): Promise<void> { async validateProcess(): Promise<void> {
if (this.data.status != STATUS.DRAFT) { if (this.oldData.status != STATUS.DRAFT) {
throw new UnprocessableEntityException({ throw new UnprocessableEntityException({
statusCode: HttpStatus.UNPROCESSABLE_ENTITY, statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
message: `Failed! only data booking with status ${STATUS.ACTIVE} can be confirm`, message: `Failed! only data booking with status ${STATUS.ACTIVE} can be confirm`,

View File

@ -57,8 +57,8 @@ export class DetailTransactionManager extends BaseDetailManager<TransactionEntit
name: itemData.item_category_name, name: itemData.item_category_name,
}, },
}, },
id: itemData.item_category_id, qty: itemData.qty,
name: itemData.item_category_name, total_price: itemData.total_price,
}; };
}); });
@ -118,12 +118,15 @@ export class DetailTransactionManager extends BaseDetailManager<TransactionEntit
`${this.tableName}.discount_percentage`, `${this.tableName}.discount_percentage`,
`${this.tableName}.discount_value`, `${this.tableName}.discount_value`,
`${this.tableName}.payment_type`, `${this.tableName}.payment_type`,
`${this.tableName}.payment_date`, `${this.tableName}.payment_date`,
`${this.tableName}.payment_total_pay`, `${this.tableName}.payment_total_pay`,
`${this.tableName}.payment_type_method_id`, `${this.tableName}.payment_type_method_id`,
`${this.tableName}.payment_type_method_name`, `${this.tableName}.payment_type_method_name`,
`${this.tableName}.payment_type_method_number`, `${this.tableName}.payment_type_method_number`,
`${this.tableName}.payment_card_information`,
`${this.tableName}.payment_code_reference`,
`${this.tableName}.payment_sub_total`, `${this.tableName}.payment_sub_total`,
`${this.tableName}.payment_discount_total`, `${this.tableName}.payment_discount_total`,

View File

@ -54,6 +54,13 @@ export class IndexTransactionManager extends BaseIndexManager<TransactionEntity>
`${this.tableName}.creator_name`, `${this.tableName}.creator_name`,
`${this.tableName}.editor_id`, `${this.tableName}.editor_id`,
`${this.tableName}.editor_name`, `${this.tableName}.editor_name`,
`${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`,
]; ];
} }