fix(SPG-590) Pemesanan - Konfirmasi dari status draft muncul error
parent
b9c5cb17d3
commit
cafbb82af6
|
@ -31,4 +31,31 @@ export class ConstantController {
|
|||
async paymentMethodType(): Promise<any> {
|
||||
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'
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,6 +68,20 @@ export class IndexItemRatesManager extends BaseIndexManager<ItemRateEntity> {
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ export class TransactionModel
|
|||
implements TransactionEntity
|
||||
{
|
||||
// general info
|
||||
@Column('bool', { name: 'is_recap_transaction', default: true })
|
||||
@Column('bool', { name: 'is_recap_transaction', default: false })
|
||||
is_recap_transaction: boolean;
|
||||
|
||||
@Column('enum', {
|
||||
|
|
|
@ -17,14 +17,43 @@ import { STATUS } from 'src/core/strings/constants/base.constants';
|
|||
@Injectable()
|
||||
export class BatchConfirmDataTransactionManager extends BaseBatchUpdateStatusManager<TransactionEntity> {
|
||||
validateData(data: TransactionEntity): Promise<void> {
|
||||
if (data.status != STATUS.DRAFT) {
|
||||
if (
|
||||
[STATUS.PENDING, STATUS.REJECTED, STATUS.EXPIRED].includes(data.status)
|
||||
) {
|
||||
throw new UnprocessableEntityException({
|
||||
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',
|
||||
});
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,11 +7,23 @@ import {
|
|||
import { TransactionModel } from '../../../data/models/transaction.model';
|
||||
import { TransactionChangeStatusEvent } from '../../entities/event/transaction-change-status.event';
|
||||
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()
|
||||
export class BatchConfirmTransactionManager extends BaseBatchUpdateStatusManager<TransactionEntity> {
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 { TransactionEntity } from '../../entities/transaction.entity';
|
||||
import {
|
||||
|
@ -22,6 +26,16 @@ export class ConfirmDataTransactionManager extends BaseUpdateStatusManager<Trans
|
|||
async beforeProcess(): Promise<void> {
|
||||
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) {
|
||||
// jika confirm status pending
|
||||
// maka akan kebuat reconsiliasi
|
||||
|
|
|
@ -20,7 +20,7 @@ export class ConfirmTransactionManager extends BaseUpdateStatusManager<Transacti
|
|||
}
|
||||
|
||||
async validateProcess(): Promise<void> {
|
||||
if (this.data.status != STATUS.DRAFT) {
|
||||
if (this.oldData.status != STATUS.DRAFT) {
|
||||
throw new UnprocessableEntityException({
|
||||
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
||||
message: `Failed! only data booking with status ${STATUS.ACTIVE} can be confirm`,
|
||||
|
|
|
@ -57,8 +57,8 @@ export class DetailTransactionManager extends BaseDetailManager<TransactionEntit
|
|||
name: itemData.item_category_name,
|
||||
},
|
||||
},
|
||||
id: itemData.item_category_id,
|
||||
name: itemData.item_category_name,
|
||||
qty: itemData.qty,
|
||||
total_price: itemData.total_price,
|
||||
};
|
||||
});
|
||||
|
||||
|
@ -118,12 +118,15 @@ export class DetailTransactionManager extends BaseDetailManager<TransactionEntit
|
|||
|
||||
`${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_card_information`,
|
||||
`${this.tableName}.payment_code_reference`,
|
||||
|
||||
`${this.tableName}.payment_sub_total`,
|
||||
`${this.tableName}.payment_discount_total`,
|
||||
|
|
|
@ -54,6 +54,13 @@ export class IndexTransactionManager extends BaseIndexManager<TransactionEntity>
|
|||
`${this.tableName}.creator_name`,
|
||||
`${this.tableName}.editor_id`,
|
||||
`${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`,
|
||||
];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue