Compare commits
10 Commits
f9c36582e1
...
ce6343dfa2
Author | SHA1 | Date |
---|---|---|
|
ce6343dfa2 | |
|
5f3e05a9e3 | |
|
cafbb82af6 | |
|
b9c5cb17d3 | |
|
d4d4101d69 | |
|
5ab14f5c62 | |
|
0410b481e1 | |
|
6bb8c928c0 | |
|
dba03ff81c | |
|
fec27cf294 |
|
@ -63,7 +63,7 @@ export class ValidateRelationHelper<Entity> {
|
|||
)
|
||||
)
|
||||
throw new UnprocessableEntityException(message);
|
||||
} else if (data[`total_${relation.relation} `])
|
||||
} else if (data[`total_${relation.relation}`] > 0)
|
||||
throw new UnprocessableEntityException(message);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -128,14 +128,24 @@ export const PrivilegeAdminConstant = [
|
|||
{
|
||||
menu: 'LAPORAN',
|
||||
menu_label: 'Laporan',
|
||||
sub_menu: 'LAPORAN',
|
||||
sub_menu_label: 'Laporan',
|
||||
actions: [PrivilegeAction.VIEW],
|
||||
index: 12,
|
||||
},
|
||||
{
|
||||
menu: 'LAPORAN',
|
||||
menu_label: 'Laporan',
|
||||
sub_menu: 'LAPORAN_TENANT',
|
||||
sub_menu_label: 'Laporan Tenant',
|
||||
actions: [PrivilegeAction.VIEW],
|
||||
index: 13,
|
||||
},
|
||||
{
|
||||
menu: 'DISKON_CODE',
|
||||
menu_label: 'Generate Diskon Kode',
|
||||
actions: [PrivilegeAction.CREATE],
|
||||
index: 13,
|
||||
index: 14,
|
||||
},
|
||||
];
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,36 +38,12 @@ export async function ValidateSeasonPeriodHelper(dataService, data) {
|
|||
|
||||
let datas = await query
|
||||
.andWhere('data.priority = :priority', { priority: priority })
|
||||
.andWhere(
|
||||
new Brackets((query) => {
|
||||
// contoh data tanggal 1 Agustus - 31 Agustus
|
||||
query.orWhere(
|
||||
new Brackets((q) => {
|
||||
return q
|
||||
.andWhere('data.start_date <= :inputStartDate ', {
|
||||
inputStartDate: data.start_date,
|
||||
})
|
||||
.andWhere('data.end_date >= :inputEndDate', {
|
||||
inputEndDate: data.end_date,
|
||||
});
|
||||
}),
|
||||
);
|
||||
|
||||
query.orWhere(
|
||||
new Brackets((q) => {
|
||||
return q
|
||||
.andWhere('data.start_date >= :inputStartDate ', {
|
||||
inputStartDate: data.start_date,
|
||||
})
|
||||
.andWhere('data.end_date <= :inputEndDate', {
|
||||
inputEndDate: data.end_date,
|
||||
});
|
||||
}),
|
||||
);
|
||||
|
||||
return query;
|
||||
}),
|
||||
)
|
||||
.andWhere(`data.start_date < :inputStartDate`, {
|
||||
inputStartDate: data.end_date,
|
||||
})
|
||||
.andWhere(`data.end_date > :inputEndDate`, {
|
||||
inputEndDate: data.start_date,
|
||||
})
|
||||
.getMany();
|
||||
|
||||
if (priority == 2) {
|
||||
|
|
|
@ -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