Compare commits

..

No commits in common. "ce6343dfa2eaaf8a048f97f31176ca1c23a1c723" and "f9c36582e18015a47901c96ea183864b8bdc8479" have entirely different histories.

12 changed files with 40 additions and 132 deletions

View File

@ -63,7 +63,7 @@ export class ValidateRelationHelper<Entity> {
)
)
throw new UnprocessableEntityException(message);
} else if (data[`total_${relation.relation}`] > 0)
} else if (data[`total_${relation.relation} `])
throw new UnprocessableEntityException(message);
}
}

View File

@ -128,24 +128,14 @@ 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: 14,
index: 13,
},
];

View File

@ -31,31 +31,4 @@ 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'
]
}
}

View File

@ -68,20 +68,6 @@ 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;
}
}

View File

@ -38,12 +38,36 @@ export async function ValidateSeasonPeriodHelper(dataService, data) {
let datas = await query
.andWhere('data.priority = :priority', { priority: priority })
.andWhere(`data.start_date < :inputStartDate`, {
inputStartDate: data.end_date,
.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.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;
}),
)
.getMany();
if (priority == 2) {

View File

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

View File

@ -17,43 +17,14 @@ import { STATUS } from 'src/core/strings/constants/base.constants';
@Injectable()
export class BatchConfirmDataTransactionManager extends BaseBatchUpdateStatusManager<TransactionEntity> {
validateData(data: TransactionEntity): Promise<void> {
if (
[STATUS.PENDING, STATUS.REJECTED, STATUS.EXPIRED].includes(data.status)
) {
if (data.status != STATUS.DRAFT) {
throw new UnprocessableEntityException({
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
message: `Failed! only data booking with status ${STATUS.PENDING}, ${STATUS.REJECTED}, ${STATUS.EXPIRED} can be confirm`,
message: `Failed! only data booking with status ${STATUS.ACTIVE} 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;
}

View File

@ -7,23 +7,11 @@ 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 {
HttpStatus,
Injectable,
UnprocessableEntityException,
} from '@nestjs/common';
import { STATUS } from 'src/core/strings/constants/base.constants';
import { Injectable } from '@nestjs/common';
@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;
}

View File

@ -1,8 +1,4 @@
import {
HttpStatus,
Injectable,
UnprocessableEntityException,
} from '@nestjs/common';
import { Injectable } from '@nestjs/common';
import { BaseUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-update-status.manager';
import { TransactionEntity } from '../../entities/transaction.entity';
import {
@ -26,16 +22,6 @@ 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

View File

@ -20,7 +20,7 @@ export class ConfirmTransactionManager extends BaseUpdateStatusManager<Transacti
}
async validateProcess(): Promise<void> {
if (this.oldData.status != STATUS.DRAFT) {
if (this.data.status != STATUS.DRAFT) {
throw new UnprocessableEntityException({
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
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,
},
},
qty: itemData.qty,
total_price: itemData.total_price,
id: itemData.item_category_id,
name: itemData.item_category_name,
};
});
@ -118,15 +118,12 @@ 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`,

View File

@ -54,13 +54,6 @@ 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`,
];
}