Merge pull request 'fix/data' (#45) from fix/data into development
continuous-integration/drone/tag Build is passing
Details
continuous-integration/drone/tag Build is passing
Details
Reviewed-on: #45pull/48/head devel_16.0.0
commit
77d8e7ae1e
|
@ -25,7 +25,7 @@ export class RolesGuard extends JWTGuard {
|
|||
if (isNotAllow) {
|
||||
throw new ForbiddenException({
|
||||
statusCode: 10003,
|
||||
message: `Forbidden Access, you don't have access to this module!`,
|
||||
message: `Akses Terlarang, anda tidak punya akses ke module ini!`,
|
||||
error: 'ACCESS_FORBIDDEN',
|
||||
});
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ export class PrivilegeService {
|
|||
if (!moduleKey) {
|
||||
throw new ForbiddenException({
|
||||
statusCode: 10005,
|
||||
message: `Forbidden Access, access Module is Require!`,
|
||||
message: `Akses Terlarang, anda tidak punya akses ke module ini!`,
|
||||
error: 'MODULE_KEY_NOT_FOUND',
|
||||
});
|
||||
}
|
||||
|
|
|
@ -43,9 +43,9 @@ export class CheckDuplicateHelper {
|
|||
if (data_exists > 0) {
|
||||
throw new UnprocessableEntityException({
|
||||
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
||||
message: `Entity with ${columnCheck.column} : ${
|
||||
message: `Gagal! Data dengan ${columnCheck.column} : ${
|
||||
this.entity[columnCheck.column]
|
||||
} already exist`,
|
||||
} telah ada`,
|
||||
error: 'Unprocessable Entity',
|
||||
});
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ export abstract class BaseBatchDeleteManager<Entity> extends BaseManager {
|
|||
if (!entity) {
|
||||
throw new NotFoundException({
|
||||
statusCode: HttpStatus.NOT_FOUND,
|
||||
message: `Failed! Entity with id ${id} not found`,
|
||||
message: `Gagal! data dengan id ${id} tidak ditemukan`,
|
||||
error: 'Entity Not Found',
|
||||
});
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ export abstract class BaseBatchUpdateStatusManager<Entity> extends BaseManager {
|
|||
if (!entity) {
|
||||
throw new NotFoundException({
|
||||
statusCode: HttpStatus.NOT_FOUND,
|
||||
message: `Failed! Entity with id ${id} not found`,
|
||||
message: `Gagal! data dengan id ${id} tidak ditemukan`,
|
||||
error: 'Entity Not Found',
|
||||
});
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ export abstract class BaseChangePosition<Entity> extends BaseManager {
|
|||
if (!this.data?.end || this.data.start == this.data?.end) {
|
||||
throw new UnprocessableEntityException({
|
||||
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
||||
message: 'Please drag to another position',
|
||||
message: 'Gagal! tolong pindahkan ke posisi lain',
|
||||
error: 'Unprocessable Entity',
|
||||
});
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ export abstract class BaseChangePosition<Entity> extends BaseManager {
|
|||
if (!this.startData) {
|
||||
throw new UnprocessableEntityException({
|
||||
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
||||
message: `Entity with id : ${this.data.start} not found`,
|
||||
message: `Gagal! data dengan id : ${this.data.start} tidak ditemukan`,
|
||||
error: 'Unprocessable Entity',
|
||||
});
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ export abstract class BaseChangePosition<Entity> extends BaseManager {
|
|||
if (!this.endData) {
|
||||
throw new UnprocessableEntityException({
|
||||
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
||||
message: `Entity with id : ${this.data.end} not found`,
|
||||
message: `Gagal! data dengan id : ${this.data.end} tidak ditemukan`,
|
||||
error: 'Unprocessable Entity',
|
||||
});
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ export abstract class BaseDeleteManager<Entity> extends BaseManager {
|
|||
if (!this.data)
|
||||
throw new UnprocessableEntityException({
|
||||
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
||||
message: `Data with id ${this.dataId} not found`,
|
||||
message: `Gagal! Data denga id ${this.dataId} tidak ditemukan`,
|
||||
error: 'Unprocessable Entity',
|
||||
});
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ export abstract class BaseUpdateManager<Entity> extends BaseManager {
|
|||
if (!this.oldData) {
|
||||
throw new NotFoundException({
|
||||
statusCode: HttpStatus.NOT_FOUND,
|
||||
message: `Failed! Entity with id ${this.dataId} not found`,
|
||||
message: `Gagal! Data denga id ${this.dataId} tidak ditemukan`,
|
||||
error: 'Entity Not Found',
|
||||
});
|
||||
}
|
||||
|
|
|
@ -179,6 +179,6 @@ export const PrivilegePOSConstant = [
|
|||
menu: 'POS_DISCOUNT_CODE',
|
||||
menu_label: 'Print Receipt',
|
||||
actions: [PrivilegeAction.CREATE],
|
||||
index: 18,
|
||||
index: 19,
|
||||
},
|
||||
];
|
||||
|
|
|
@ -133,7 +133,7 @@ export class LoginManager extends BaseCustomManager<UserEntity> {
|
|||
throwError() {
|
||||
throw new UnauthorizedException({
|
||||
statusCode: HttpStatus.UNAUTHORIZED,
|
||||
message: `Failed! You have entered an invalid username or password`,
|
||||
message: `Gagal! username atau password tidak sesuai`,
|
||||
error: 'Unauthorized',
|
||||
});
|
||||
}
|
||||
|
|
|
@ -45,6 +45,7 @@ export class UserUpdatedHandler
|
|||
],
|
||||
})
|
||||
.then((item) => {
|
||||
if (item.role != 'superadmin') {
|
||||
const user_privilege_configurations = item[
|
||||
'user_privilege'
|
||||
]?.user_privilege_configurations?.filter(
|
||||
|
@ -53,6 +54,7 @@ export class UserUpdatedHandler
|
|||
Object.assign(item['user_privilege'], {
|
||||
user_privilege_configurations: user_privilege_configurations,
|
||||
});
|
||||
}
|
||||
return item;
|
||||
});
|
||||
|
||||
|
@ -103,7 +105,7 @@ export class UserPrivilegeUpdateHandler
|
|||
const users = await this.userService
|
||||
.getManyByOptions({
|
||||
where: {
|
||||
user_privilege_id: data.user_privilege_id,
|
||||
user_privilege_id: data.user_privilege_id ?? data.id,
|
||||
status: STATUS.ACTIVE,
|
||||
},
|
||||
relations: [
|
||||
|
@ -113,7 +115,6 @@ export class UserPrivilegeUpdateHandler
|
|||
})
|
||||
.then((items) => {
|
||||
return items?.map((item) => {
|
||||
console.log(item, 'dsa');
|
||||
const user_privilege_configurations = item[
|
||||
'user_privilege'
|
||||
]?.user_privilege_configurations?.filter(
|
||||
|
|
|
@ -16,12 +16,13 @@ export async function sendEmail(receivers, subject) {
|
|||
let templateName = 'payment-confirmation-bank';
|
||||
|
||||
for (const receiver of receivers) {
|
||||
try {
|
||||
if (receiver.payment_type == TransactionPaymentType.MIDTRANS)
|
||||
templateName = 'payment-confirmation-midtrans';
|
||||
|
||||
let templatePath = path.resolve(
|
||||
__dirname,
|
||||
`../email-template/${templateName}.html`,
|
||||
`../email-template/${ templateName }.html`,
|
||||
);
|
||||
templatePath = templatePath.replace(/dist/g, 'src');
|
||||
const templateSource = fs.readFileSync(templatePath, 'utf8');
|
||||
|
@ -41,10 +42,13 @@ export async function sendEmail(receivers, subject) {
|
|||
|
||||
smtpTransport.sendMail(emailContext, function (err, data) {
|
||||
if (err) {
|
||||
console.log(`Error occurs on send to ${receiver.email}`);
|
||||
console.log(err, `Error occurs on send to ${ receiver.email }`);
|
||||
} else {
|
||||
console.log(`Email sent to ${receiver.email}`);
|
||||
console.log(`Email sent to ${ receiver.email }`);
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.log(error, `Error occurs on send to ${ receiver.email }`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,13 @@ export class BatchDeleteItemCategoryManager extends BaseBatchDeleteManager<ItemC
|
|||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [{ relation: 'items' }];
|
||||
return [
|
||||
{
|
||||
relation: 'items',
|
||||
message:
|
||||
'Gagal! tidak dapat mengubah tipe item karena sudah berelasi dengan item',
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
|
|
|
@ -24,7 +24,13 @@ export class BatchInactiveItemCategoryManager extends BaseBatchUpdateStatusManag
|
|||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [{ relation: 'items' }];
|
||||
return [
|
||||
{
|
||||
relation: 'items',
|
||||
message:
|
||||
'Gagal! tidak dapat mengubah tipe item karena sudah berelasi dengan item',
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
|
|
|
@ -27,7 +27,13 @@ export class DeleteItemCategoryManager extends BaseDeleteManager<ItemCategoryEnt
|
|||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [{ relation: 'items' }];
|
||||
return [
|
||||
{
|
||||
relation: 'items',
|
||||
message:
|
||||
'Gagal! tidak dapat mengubah tipe item karena sudah berelasi dengan item',
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
|
|
|
@ -27,7 +27,13 @@ export class InactiveItemCategoryManager extends BaseUpdateStatusManager<ItemCat
|
|||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [{ relation: 'items' }];
|
||||
return [
|
||||
{
|
||||
relation: 'items',
|
||||
message:
|
||||
'Gagal! tidak dapat mengubah tipe item karena sudah berelasi dengan item',
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
|
|
|
@ -27,11 +27,17 @@ export class UpdateItemCategoryManager extends BaseUpdateManager<ItemCategoryEnt
|
|||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
if (this.data.item_type != this.oldData.item_type) {
|
||||
return [
|
||||
{
|
||||
relation: 'items',
|
||||
message:
|
||||
'Gagal! tidak dapat mengubah tipe item karena sudah berelasi dengan item',
|
||||
},
|
||||
];
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
get uniqueColumns(): columnUniques[] {
|
||||
|
|
|
@ -32,6 +32,7 @@ export class SeasonPeriodHolidayHandler
|
|||
const rate = new ItemRateModel();
|
||||
rate.item_id = event.data.id;
|
||||
rate.season_period_id = season.id;
|
||||
rate.price = event.data.data.total_price ?? event.data.data.base_price;
|
||||
|
||||
rates.push(rate);
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ export class ActiveItemManager extends BaseUpdateStatusManager<ItemEntity> {
|
|||
{
|
||||
relation: 'tenant',
|
||||
singleQuery: ['status', '!=', STATUS.ACTIVE],
|
||||
message: `Failed! Tenant of item must be active first`,
|
||||
message: `Gagal! Belum ada item yang aktif`,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ export class BatchActiveItemManager extends BaseBatchUpdateStatusManager<ItemEnt
|
|||
{
|
||||
relation: 'tenant',
|
||||
singleQuery: ['status', '!=', STATUS.ACTIVE],
|
||||
message: `Failed! Tenant of item must be active first`,
|
||||
message: `Gagal! Belum ada item yang aktif`,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ export class BatchConfirmItemManager extends BaseBatchUpdateStatusManager<ItemEn
|
|||
{
|
||||
relation: 'tenant',
|
||||
singleQuery: ['status', '!=', STATUS.ACTIVE],
|
||||
message: `Failed! Tenant of item must be active first`,
|
||||
message: `Gagal! Belum ada item yang aktif`,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ export class ConfirmItemManager extends BaseUpdateStatusManager<ItemEntity> {
|
|||
{
|
||||
relation: 'tenant',
|
||||
singleQuery: ['status', '!=', STATUS.ACTIVE],
|
||||
message: `Failed! Tenant of item must be active first`,
|
||||
message: `Gagal! Belum ada item yang aktif`,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ export async function validateRelation(dataService, id) {
|
|||
if (haveRelation) {
|
||||
throw new UnprocessableEntityException({
|
||||
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
||||
message: `Failed! this data already connected to bunding item`,
|
||||
message: `Gagal! data telah digunakan untuk bundling`,
|
||||
error: 'Unprocessable Entity',
|
||||
});
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@ import { EnumDays } from '../../constants';
|
|||
export interface FilterSeasonPeriodEntity extends BaseFilterEntity {
|
||||
start_date: Date;
|
||||
end_date: Date;
|
||||
season_type_ids: string[];
|
||||
|
||||
holiday_names: string[];
|
||||
days: EnumDays[];
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ export async function ValidateSeasonPeriodHelper(dataService, data) {
|
|||
if (datas.length > 0) {
|
||||
throw new UnprocessableEntityException({
|
||||
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
||||
message: `Failed! there is another season period in same range date`,
|
||||
message: `Gagal! terdapat data periode dengan rentang tanggal yang sama`,
|
||||
error: 'Unprocessable Entity',
|
||||
});
|
||||
}
|
||||
|
|
|
@ -74,6 +74,12 @@ export class IndexSeasonPeriodManager extends BaseIndexManager<SeasonPeriodEntit
|
|||
);
|
||||
}
|
||||
|
||||
if (this.filterParam.season_type_ids) {
|
||||
queryBuilder.andWhere(`user_privilege_id In (:...seasonIds)`, {
|
||||
seasonIds: this.filterParam.season_type_ids,
|
||||
});
|
||||
}
|
||||
|
||||
return queryBuilder;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ export class UpdateSeasonPeriodPriceManager extends BaseCustomManager<SeasonPeri
|
|||
if (!existSeason) {
|
||||
throw new UnprocessableEntityException({
|
||||
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
||||
message: `Failed! There is no season type ${this.data.season_period.name}`,
|
||||
message: `Gagagl! Tidak terdapat data denga tipe season ${this.data.season_period.name}`,
|
||||
error: 'Unprocessable Entity',
|
||||
});
|
||||
}
|
||||
|
|
|
@ -25,4 +25,10 @@ export class FilterSeasonPeriodDto
|
|||
return Array.isArray(body.value) ? body.value : [body.value];
|
||||
})
|
||||
days: EnumDays[];
|
||||
|
||||
@ApiProperty({ type: ['string'], required: false })
|
||||
@Transform((body) => {
|
||||
return Array.isArray(body.value) ? body.value : [body.value];
|
||||
})
|
||||
season_type_ids: string[];
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ export class BatchCancelReconciliationManager extends BaseBatchUpdateStatusManag
|
|||
if ([STATUS.SETTLED, STATUS.WAITING].includes(transaction.status)) {
|
||||
throw new UnprocessableEntityException({
|
||||
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
||||
message: `Failed! cant cancel transaction not settled`,
|
||||
message: `Gagal! tidak bisa batalkan, karena status transaksi tidak settled`,
|
||||
error: 'Unprocessable Entity',
|
||||
});
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ export class BatchCancelReconciliationManager extends BaseBatchUpdateStatusManag
|
|||
if (data.is_recap_transaction) {
|
||||
throw new UnprocessableEntityException({
|
||||
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
||||
message: `Failed! cant cancel recap data`,
|
||||
message: `Gagagl! tidak dapat batalkan data rekap`,
|
||||
error: 'Unprocessable Entity',
|
||||
});
|
||||
}
|
||||
|
|
|
@ -30,13 +30,13 @@ export class CancelReconciliationManager extends BaseUpdateStatusManager<Transac
|
|||
if ([STATUS.SETTLED, STATUS.WAITING].includes(transaction.status)) {
|
||||
throw new UnprocessableEntityException({
|
||||
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
||||
message: `Failed! cant cancel transaction not settled`,
|
||||
message: `Gagal! tidak bisa batalkan, karena status transaksi tidak settled`,
|
||||
error: 'Unprocessable Entity',
|
||||
});
|
||||
} else if (this.data.is_recap_transaction) {
|
||||
throw new UnprocessableEntityException({
|
||||
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
||||
message: `Failed! cant cancel recap data`,
|
||||
message: `Gagagl! tidak dapat batalkan data rekap`,
|
||||
error: 'Unprocessable Entity',
|
||||
});
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@ export class IndexReconciliationManager extends BaseIndexManager<TransactionEnti
|
|||
`${this.tableName}.customer_name`,
|
||||
`${this.tableName}.creator_counter_no`,
|
||||
|
||||
`${this.tableName}.booking_date`,
|
||||
`${this.tableName}.payment_type`,
|
||||
`${this.tableName}.payment_type_method_id`,
|
||||
`${this.tableName}.payment_type_method_name`,
|
||||
|
|
|
@ -4,23 +4,23 @@ import { EventTopics } from 'src/core/strings/constants/interface.constants';
|
|||
import { TransactionType } from 'src/modules/transaction/transaction/constants';
|
||||
import { TransactionModel } from 'src/modules/transaction/transaction/data/models/transaction.model';
|
||||
import { TransactionEntity } from 'src/modules/transaction/transaction/domain/entities/transaction.entity';
|
||||
import { Between } from 'typeorm';
|
||||
import { Between, ILike } from 'typeorm';
|
||||
import * as _ from 'lodash';
|
||||
import * as moment from 'moment';
|
||||
import { STATUS } from 'src/core/strings/constants/base.constants';
|
||||
import { EMPTY_UUID, STATUS } from 'src/core/strings/constants/base.constants';
|
||||
|
||||
@Injectable()
|
||||
export class RecapReconciliationManager extends BaseCustomManager<TransactionEntity> {
|
||||
private recapTransactions = {};
|
||||
private startOfDay = moment().startOf('day').unix();
|
||||
private endOfDay = moment().endOf('day').unix();
|
||||
private startOfDay = moment().startOf('day').valueOf();
|
||||
private endOfDay = moment().endOf('day').valueOf();
|
||||
|
||||
get entityTarget(): any {
|
||||
return TransactionModel;
|
||||
}
|
||||
|
||||
getResult() {
|
||||
return;
|
||||
return 'Berhasil recap data transaksi';
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
|
@ -36,22 +36,26 @@ export class RecapReconciliationManager extends BaseCustomManager<TransactionEnt
|
|||
where: {
|
||||
is_recap_transaction: false,
|
||||
type: TransactionType.COUNTER,
|
||||
status: STATUS.SETTLED,
|
||||
created_at: Between(this.startOfDay, this.endOfDay),
|
||||
},
|
||||
});
|
||||
|
||||
const payCounserTransactions = await this.dataService.getManyByOptions({
|
||||
where: {
|
||||
is_recap_transaction: false,
|
||||
payment_code: ILike('%SLS%'),
|
||||
status: STATUS.SETTLED,
|
||||
created_at: Between(this.startOfDay, this.endOfDay),
|
||||
},
|
||||
});
|
||||
transactions.push(...payCounserTransactions);
|
||||
|
||||
for (const transaction of transactions) {
|
||||
const {
|
||||
creator_counter_no,
|
||||
payment_type_method_name,
|
||||
payment_type_method_number,
|
||||
} = transaction;
|
||||
const { creator_counter_no, payment_type, payment_type_method_id } =
|
||||
transaction;
|
||||
const group_by =
|
||||
creator_counter_no +
|
||||
'-' +
|
||||
payment_type_method_name +
|
||||
'-' +
|
||||
payment_type_method_number;
|
||||
creator_counter_no + '-' + payment_type + '-' + payment_type_method_id;
|
||||
if (!this.recapTransactions[group_by]) {
|
||||
this.recapTransactions[group_by] = [];
|
||||
}
|
||||
|
@ -65,32 +69,29 @@ export class RecapReconciliationManager extends BaseCustomManager<TransactionEnt
|
|||
const total_recap = Object.keys(this.recapTransactions);
|
||||
for (const recap of total_recap) {
|
||||
const first_transaction = this.recapTransactions[recap][0];
|
||||
const {
|
||||
creator_counter_no,
|
||||
payment_type_method_number,
|
||||
payment_type_method_name,
|
||||
} = first_transaction;
|
||||
const { creator_counter_no, payment_type, payment_type_method_id } =
|
||||
first_transaction;
|
||||
|
||||
const exist = await this.dataService.getOneByOptions({
|
||||
where: {
|
||||
is_recap_transaction: true,
|
||||
created_at: Between(this.startOfDay, this.endOfDay),
|
||||
creator_counter_no: creator_counter_no,
|
||||
payment_type_method_number: payment_type_method_number,
|
||||
payment_type_method_name: payment_type_method_name,
|
||||
payment_type: payment_type,
|
||||
payment_type_method_id: payment_type_method_id ?? EMPTY_UUID,
|
||||
},
|
||||
});
|
||||
|
||||
const new_recap = new TransactionModel();
|
||||
const total = _.sumBy(this.recapTransactions[recap], (recap) =>
|
||||
parseFloat(recap.payment_total),
|
||||
);
|
||||
|
||||
if (exist) {
|
||||
Object.assign(exist, {
|
||||
payment_total: _.sumBy(this.recapTransactions[recap], (recap) =>
|
||||
parseFloat(recap.payment_total),
|
||||
),
|
||||
payment_total_net_profit: _.sumBy(
|
||||
this.recapTransactions[recap],
|
||||
(recap) => parseFloat(recap.payment_total),
|
||||
),
|
||||
payment_total: Number(exist.payment_total) + total,
|
||||
payment_total_net_profit:
|
||||
Number(exist.payment_total_net_profit) + total,
|
||||
editor_id: this.user.id,
|
||||
editor_name: this.user.name,
|
||||
updated_at: new Date().getTime(),
|
||||
|
@ -98,17 +99,13 @@ export class RecapReconciliationManager extends BaseCustomManager<TransactionEnt
|
|||
} else {
|
||||
Object.assign(new_recap, {
|
||||
is_recap_transaction: true,
|
||||
payment_total: _.sumBy(this.recapTransactions[recap], (recap) =>
|
||||
parseFloat(recap.payment_total),
|
||||
),
|
||||
payment_total_net_profit: _.sumBy(
|
||||
this.recapTransactions[recap],
|
||||
(recap) => parseFloat(recap.payment_total),
|
||||
),
|
||||
payment_total: total,
|
||||
payment_total_net_profit: total,
|
||||
reconciliation_status: STATUS.PENDING,
|
||||
status: STATUS.SETTLED,
|
||||
type: TransactionType.COUNTER,
|
||||
booking_date: first_transaction.booking_date,
|
||||
booking_date: new Date(),
|
||||
payment_date: new Date(),
|
||||
creator_counter_no: first_transaction.creator_counter_no,
|
||||
payment_type: first_transaction.payment_type,
|
||||
payment_type_method_id: first_transaction.payment_type_method_id,
|
||||
|
|
|
@ -25,13 +25,13 @@ export class BatchConfirmRefundManager extends BaseBatchUpdateStatusManager<Refu
|
|||
) {
|
||||
throw new UnprocessableEntityException({
|
||||
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
||||
message: `Failed! only transaction with status ${STATUS.SETTLED} can be refund`,
|
||||
message: `Gagal! hanya data dengan status ${STATUS.SETTLED} dapat dikembalikan`,
|
||||
error: 'Unprocessable Entity',
|
||||
});
|
||||
} else if (![STATUS.DRAFT, STATUS.PENDING].includes(data.status)) {
|
||||
throw new UnprocessableEntityException({
|
||||
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
||||
message: `Failed! only data with status ${STATUS.DRAFT} and ${STATUS.PENDING} can be confirmed`,
|
||||
message: `Gagal! hanya data dengan status ${STATUS.DRAFT} and ${STATUS.PENDING} dapat di${this.dataStatus}`,
|
||||
error: 'Unprocessable Entity',
|
||||
});
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ export class ConfirmRefundManager extends BaseUpdateStatusManager<RefundEntity>
|
|||
if (![STATUS.DRAFT, STATUS.PENDING].includes(this.oldData.status)) {
|
||||
throw new UnprocessableEntityException({
|
||||
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
||||
message: `Failed! only data with status ${STATUS.DRAFT} and ${STATUS.PENDING} can be confirmed`,
|
||||
message: `Gagal! hanya data dengan status ${STATUS.DRAFT} dan ${STATUS.PENDING} dapat di${this.dataStatus}`,
|
||||
error: 'Unprocessable Entity',
|
||||
});
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ export class ConfirmRefundManager extends BaseUpdateStatusManager<RefundEntity>
|
|||
) {
|
||||
throw new UnprocessableEntityException({
|
||||
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
||||
message: `Failed! only transaction with status ${STATUS.SETTLED} can be refund`,
|
||||
message: `Gagal! hanya pemesanan dengan status ${STATUS.SETTLED} dapat di${this.dataStatus}`,
|
||||
error: 'Unprocessable Entity',
|
||||
});
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ export class CreateRefundManager extends BaseCreateManager<RefundEntity> {
|
|||
if (exist) {
|
||||
throw new UnprocessableEntityException({
|
||||
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
||||
message: `Failed! refund transaction with invoice ${this.data.transaction.invoice_code} already exist`,
|
||||
message: `Gagal! pengembalian pemesanan dengan nomor invoice ${this.data.transaction.invoice_code} telah dibuat`,
|
||||
error: 'Unprocessable Entity',
|
||||
});
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ export class CreateRefundManager extends BaseCreateManager<RefundEntity> {
|
|||
if (!transaction) {
|
||||
throw new UnprocessableEntityException({
|
||||
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
||||
message: `Failed! only transaction with status ${STATUS.SETTLED} can be refund`,
|
||||
message: `Gagal! hanya pemesanan dengan status ${STATUS.SETTLED} dapat dikembalikan`,
|
||||
error: 'Unprocessable Entity',
|
||||
});
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ export class UpdateRefundManager extends BaseUpdateManager<RefundEntity> {
|
|||
if (!transaction) {
|
||||
throw new UnprocessableEntityException({
|
||||
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
||||
message: `Failed! only transaction with status ${STATUS.SETTLED} can be refund`,
|
||||
message: `Gagal! hanya pemesanan dengan status ${STATUS.SETTLED} yang dapat dikembalikan`,
|
||||
error: 'Unprocessable Entity',
|
||||
});
|
||||
}
|
||||
|
|
|
@ -117,7 +117,7 @@ function returnError(throwError, e, taxes) {
|
|||
if (throwError) {
|
||||
throw new UnprocessableEntityException({
|
||||
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
||||
message: `Failed! Formula error`,
|
||||
message: `Gagal! Formula error`,
|
||||
error: 'Unprocessable Entity',
|
||||
});
|
||||
} else {
|
||||
|
|
|
@ -9,7 +9,7 @@ export async function validateUsedInFormula(formulaDataService, name) {
|
|||
if (allWords.find((item) => item.toLowerCase() == name))
|
||||
throw new UnprocessableEntityException({
|
||||
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
||||
message: `Failed! tax ${name} already used in ${formula.type} formula`,
|
||||
message: `Gagal! pajak dengan nama ${name} telah dogunakan pada formula ${formula.type}`,
|
||||
error: 'Unprocessable Entity',
|
||||
});
|
||||
});
|
||||
|
|
|
@ -40,7 +40,7 @@ export class BatchConfirmDataTransactionManager extends BaseBatchUpdateStatusMan
|
|||
) {
|
||||
throw new UnprocessableEntityException({
|
||||
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
||||
message: `Gagal! hanya pemesanan dengan status ${STATUS.PENDING}, ${STATUS.REJECTED}, ${STATUS.EXPIRED} dapat dikonfirmasi`,
|
||||
message: `Gagal! hanya pemesanan dengan status ${STATUS.PENDING}, ${STATUS.REJECTED}, ${STATUS.EXPIRED} dapat di${this.dataStatus}`,
|
||||
error: 'Unprocessable Entity',
|
||||
});
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ export class BatchConfirmTransactionManager extends BaseBatchUpdateStatusManager
|
|||
if (data.status != STATUS.DRAFT) {
|
||||
throw new UnprocessableEntityException({
|
||||
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
||||
message: `Failed! only data booking with status ${STATUS.ACTIVE} can be confirm`,
|
||||
message: `Gagal! hanya data booking dengan status ${STATUS.DRAFT} yang dapat di${this.dataStatus}`,
|
||||
error: 'Unprocessable Entity',
|
||||
});
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ export class BatchConfirmTransactionManager extends BaseBatchUpdateStatusManager
|
|||
} catch (error) {
|
||||
throw new UnprocessableEntityException({
|
||||
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
||||
message: `Failed! this transaction already created, please check your email to continue payment`,
|
||||
message: `Gagal! transaksi telah terbuat, silahkan periksa email untuk melanjutkan pembayaran`,
|
||||
error: 'Unprocessable Entity',
|
||||
});
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ export class CancelTransactionManager extends BaseUpdateStatusManager<Transactio
|
|||
if (![STATUS.EXPIRED, STATUS.PENDING].includes(this.data.status)) {
|
||||
throw new UnprocessableEntityException({
|
||||
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
||||
message: `Failed! only data booking with status ${STATUS.ACTIVE} can be confirm`,
|
||||
message: `Gagal! hanya tranksaksi dengan status ${STATUS.PENDING} dan ${STATUS.EXPIRED} yang dapat di${this.dataStatus}`,
|
||||
error: 'Unprocessable Entity',
|
||||
});
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ export class ConfirmTransactionManager extends BaseUpdateStatusManager<Transacti
|
|||
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`,
|
||||
message: `Gagal! hanya data booking dengan status ${STATUS.DRAFT} yang dapat di${this.dataStatus}`,
|
||||
error: 'Unprocessable Entity',
|
||||
});
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ export class ConfirmTransactionManager extends BaseUpdateStatusManager<Transacti
|
|||
} catch (error) {
|
||||
throw new UnprocessableEntityException({
|
||||
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
||||
message: `Failed! this transaction already created, please check your email to continue payment`,
|
||||
message: `Gagal! transaksi telah terbuat, silahkan periksa email untuk melanjutkan pembayaran`,
|
||||
error: 'Unprocessable Entity',
|
||||
});
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ export class BatchDeleteTenantManager extends BaseBatchDeleteManager<UserEntity>
|
|||
statuses: [STATUS.ACTIVE],
|
||||
});
|
||||
},
|
||||
message: 'Failed! There is active item',
|
||||
message: 'Gagal! terdapat item yang aktif',
|
||||
},
|
||||
];
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ export class BatchInactiveTenantManager extends BaseBatchUpdateStatusManager<Use
|
|||
statuses: [STATUS.ACTIVE],
|
||||
});
|
||||
},
|
||||
message: 'Failed! There is active item',
|
||||
message: 'Gagal! terdapat item yang aktif',
|
||||
},
|
||||
];
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ export class DeleteTenantManager extends BaseDeleteManager<UserEntity> {
|
|||
statuses: [STATUS.ACTIVE],
|
||||
});
|
||||
},
|
||||
message: 'Failed! There is active item',
|
||||
message: 'Gagal! terdapat item yang aktif',
|
||||
},
|
||||
];
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ export class InactiveTenantManager extends BaseUpdateStatusManager<UserEntity> {
|
|||
statuses: [STATUS.ACTIVE],
|
||||
});
|
||||
},
|
||||
message: 'Failed! There is active item',
|
||||
message: 'Gagal! terdapat item yang aktif',
|
||||
},
|
||||
];
|
||||
}
|
||||
|
|
|
@ -1,66 +1,108 @@
|
|||
import { EventsHandler, IEventHandler } from '@nestjs/cqrs';
|
||||
import { EventBus, EventsHandler, IEventHandler } from '@nestjs/cqrs';
|
||||
import { UserPrivilegeConfigUpdatedEvent } from '../../../entities/event/user-privilege-configuration-updated.event';
|
||||
import { UserPrivilegeConfigurationService } from 'src/modules/user-related/user-privilege/data/service/user-privilege-configuration.service';
|
||||
import { UserPrivilegeConfigurationHelper } from '../helpers/generate-user-privilege-configuration.helper';
|
||||
import { UserPrivilegeDataService } from 'src/modules/user-related/user-privilege/data/service/user-privilege-data.service';
|
||||
import { PrivilegeAction } from 'src/core/strings/constants/privilege.constants';
|
||||
import { UserPrivilegeConfigurationModel } from 'src/modules/user-related/user-privilege/data/models/user-privilege-configuration.model';
|
||||
import { UserPrivilegeUpdatedEvent } from '../../../entities/event/user-privilege-updated.event';
|
||||
import { OPERATION } from 'src/core/strings/constants/base.constants';
|
||||
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
||||
|
||||
@EventsHandler(UserPrivilegeConfigUpdatedEvent)
|
||||
export class UserPrivilegeConfigUpdateHandler
|
||||
implements IEventHandler<UserPrivilegeConfigUpdatedEvent>
|
||||
{
|
||||
constructor(private dataService: UserPrivilegeConfigurationService) {}
|
||||
constructor(
|
||||
private dataService: UserPrivilegeDataService,
|
||||
private eventBus: EventBus,
|
||||
) {}
|
||||
|
||||
async handle(event: UserPrivilegeConfigUpdatedEvent) {
|
||||
const data = event.data.data;
|
||||
console.log(data.user_privilege_id);
|
||||
const configurations = await this.dataService.getManyByOptions({
|
||||
const configuration = await this.dataService.getOneByOptions({
|
||||
where: {
|
||||
user_privilege_id: data.user_privilege_id,
|
||||
id: data.user_privilege_id,
|
||||
},
|
||||
relations: ['user_privilege_configurations'],
|
||||
});
|
||||
let configurationData = configuration?.[
|
||||
'user_privilege_configurations'
|
||||
]?.sort((a, b) => a.index - b.index);
|
||||
const configs = UserPrivilegeConfigurationHelper.createConfigurations();
|
||||
|
||||
const createdConfig = configs
|
||||
configs
|
||||
.filter(
|
||||
(base) =>
|
||||
!configurations.some((data) => {
|
||||
!configurationData.some((data) => {
|
||||
return base.menu_label == data.menu_label;
|
||||
}),
|
||||
)
|
||||
.map((item) => {
|
||||
Object.assign(item, {
|
||||
user_privilege_id: data.user_privilege_id,
|
||||
});
|
||||
|
||||
configurationData.push(item);
|
||||
});
|
||||
|
||||
configurationData = configurationData
|
||||
?.filter((item) =>
|
||||
configs.some((data) => {
|
||||
return item.menu_label == data.menu_label;
|
||||
}),
|
||||
)
|
||||
?.map((item) => {
|
||||
const exist = configs.find(
|
||||
(config) => config.menu_label == item.menu_label,
|
||||
);
|
||||
return {
|
||||
...item,
|
||||
user_privilege_id: data.user_privilege_id,
|
||||
view: exist.actions.includes(PrivilegeAction.VIEW)
|
||||
? item.view ?? false
|
||||
: null,
|
||||
cancel: exist.actions.includes(PrivilegeAction.CANCEL)
|
||||
? item.cancel ?? false
|
||||
: null,
|
||||
confirm: exist.actions.includes(PrivilegeAction.CONFIRM)
|
||||
? item.confirm ?? false
|
||||
: null,
|
||||
create: exist.actions.includes(PrivilegeAction.CREATE)
|
||||
? item.create ?? false
|
||||
: null,
|
||||
delete: exist.actions.includes(PrivilegeAction.DELETE)
|
||||
? item.delete ?? false
|
||||
: null,
|
||||
edit: exist.actions.includes(PrivilegeAction.EDIT)
|
||||
? item.edit ?? false
|
||||
: null,
|
||||
};
|
||||
});
|
||||
|
||||
const deletedConfig = configurations
|
||||
.filter(
|
||||
(base) =>
|
||||
!configs.some((data) => {
|
||||
return base.menu_label == data.menu_label;
|
||||
}),
|
||||
)
|
||||
?.map((item) => item.id);
|
||||
Object.assign(configuration, {
|
||||
user_privilege_configurations: configurationData,
|
||||
});
|
||||
|
||||
const queryRunner = this.dataService
|
||||
.getRepository()
|
||||
.manager.connection.createQueryRunner();
|
||||
|
||||
if (createdConfig.length) {
|
||||
await this.dataService.createBatch(
|
||||
await this.dataService.update(
|
||||
queryRunner,
|
||||
UserPrivilegeConfigurationModel,
|
||||
createdConfig,
|
||||
{ id: data.user_privilege_id },
|
||||
configuration,
|
||||
);
|
||||
}
|
||||
|
||||
if (deletedConfig.length) {
|
||||
await this.dataService.deleteByIds(
|
||||
queryRunner,
|
||||
UserPrivilegeConfigurationModel,
|
||||
deletedConfig,
|
||||
);
|
||||
}
|
||||
this.eventBus.publishAll([
|
||||
new UserPrivilegeUpdatedEvent({
|
||||
id: configuration.id,
|
||||
old: null,
|
||||
data: configuration,
|
||||
user: event.data.user,
|
||||
description: '',
|
||||
module: TABLE_NAME.USER_PRIVILEGE_CONFIGURATION,
|
||||
op: OPERATION.UPDATE,
|
||||
}),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@ import {
|
|||
RelationParam,
|
||||
} from 'src/core/modules/domain/entities/base-filter.entity';
|
||||
import { ORDER_TYPE } from 'src/core/strings/constants/base.constants';
|
||||
import { UserPrivilegeConfigurationHelper } from '../helpers/generate-user-privilege-configuration.helper';
|
||||
import { PrivilegeAction } from 'src/core/strings/constants/privilege.constants';
|
||||
|
||||
@Injectable()
|
||||
export class IndexUserPrivilegeConfigurationManager extends BaseIndexManager<UserPrivilegeConfigurationEntity> {
|
||||
|
@ -24,6 +26,62 @@ export class IndexUserPrivilegeConfigurationManager extends BaseIndexManager<Use
|
|||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
const configs = UserPrivilegeConfigurationHelper.createConfigurations()
|
||||
.filter((item) => this.filterParam.modules.includes(item.module))
|
||||
?.map((item) => {
|
||||
return {
|
||||
...item,
|
||||
};
|
||||
});
|
||||
|
||||
configs
|
||||
.filter(
|
||||
(base) =>
|
||||
!this.result.data.some((data) => {
|
||||
return base.menu_label == data.menu_label;
|
||||
}),
|
||||
)
|
||||
.map((item) => {
|
||||
Object.assign(item, {
|
||||
user_privilege_id: this.filterParam.user_privilege_ids?.[0],
|
||||
});
|
||||
|
||||
this.result.data.push(item);
|
||||
});
|
||||
|
||||
this.result.data = this.result.data
|
||||
?.filter((item) =>
|
||||
configs.some((data) => {
|
||||
return item.menu_label == data.menu_label;
|
||||
}),
|
||||
)
|
||||
?.map((item) => {
|
||||
const exist = configs.find(
|
||||
(config) => config.menu_label == item.menu_label,
|
||||
);
|
||||
return {
|
||||
...item,
|
||||
view: exist.actions.includes(PrivilegeAction.VIEW)
|
||||
? item.view ?? false
|
||||
: null,
|
||||
cancel: exist.actions.includes(PrivilegeAction.CANCEL)
|
||||
? item.cancel ?? false
|
||||
: null,
|
||||
confirm: exist.actions.includes(PrivilegeAction.CONFIRM)
|
||||
? item.confirm ?? false
|
||||
: null,
|
||||
create: exist.actions.includes(PrivilegeAction.CREATE)
|
||||
? item.create ?? false
|
||||
: null,
|
||||
delete: exist.actions.includes(PrivilegeAction.DELETE)
|
||||
? item.delete ?? false
|
||||
: null,
|
||||
edit: exist.actions.includes(PrivilegeAction.EDIT)
|
||||
? item.edit ?? false
|
||||
: null,
|
||||
};
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ export async function validateItemGate(dataService, data, id?) {
|
|||
if (existCode) {
|
||||
throw new UnprocessableEntityException({
|
||||
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
||||
message: `Failed! Gate with code ${data.code} already exist`,
|
||||
message: `Gagal! Gate dengan kode ${data.code} telah ada`,
|
||||
error: 'Unprocessable Entity',
|
||||
});
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ export async function validateItemGate(dataService, data, id?) {
|
|||
if (existType) {
|
||||
throw new UnprocessableEntityException({
|
||||
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
||||
message: `Failed! Gate type ${data.type} with item ${data.item.name} already exist`,
|
||||
message: `Gagal! Gate tipe ${data.type} dengan item ${data.item.name} telah ada`,
|
||||
error: 'Unprocessable Entity',
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue