Compare commits
No commits in common. "fc36997b912a3b3cc01b6a86dfa4c68323ce9922" and "2a8d5e87cf5b0c014528f659ccde0e0d58f910d9" have entirely different histories.
fc36997b91
...
2a8d5e87cf
|
@ -33,6 +33,4 @@ export interface FilterTransactionEntity extends BaseFilterEntity {
|
||||||
invoice_date_to?: Date;
|
invoice_date_to?: Date;
|
||||||
settlement_date_from?: Date;
|
settlement_date_from?: Date;
|
||||||
settlement_date_to?: Date;
|
settlement_date_to?: Date;
|
||||||
request_refund_date_from?: Date;
|
|
||||||
request_refund_date_to?: Date;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,14 +9,14 @@ export async function generateInvoiceCodeHelper(dataService) {
|
||||||
const char = generateRandom(1);
|
const char = generateRandom(1);
|
||||||
const number = generateRandom(1, true);
|
const number = generateRandom(1, true);
|
||||||
|
|
||||||
const invoice_code = await dataService.getManyByOptions({
|
const invoice_code = await dataService.getOneByOptions({
|
||||||
where: {
|
where: {
|
||||||
invoice_code: ILike(`%${month_year}%`),
|
invoice_code: ILike(`%${month_year}%`),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const current_number = invoice_code.length + 1;
|
|
||||||
|
|
||||||
return `INV-${month_year}${char}${number}/${current_number
|
return `INV-${month_year}${char}${number}/${invoice_code
|
||||||
|
.count()
|
||||||
.toString()
|
.toString()
|
||||||
.padStart(5, '0')}`;
|
.padStart(5, '0')}`;
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,6 +81,9 @@ export function mappingRevertTransaction(data, type) {
|
||||||
booking_date: data.created_at,
|
booking_date: data.created_at,
|
||||||
settlement_date: data.created_at,
|
settlement_date: data.created_at,
|
||||||
payment_type: data.payment_type,
|
payment_type: data.payment_type,
|
||||||
|
payment_type_method_id: data.payment_type_bank?._id,
|
||||||
|
payment_type_method_name: data.payment_type_bank?.issuer_name,
|
||||||
|
payment_type_method_number: data.payment_type_bank?.account_number,
|
||||||
payment_card_information: data.card_information,
|
payment_card_information: data.card_information,
|
||||||
payment_code_reference: data.payment_code,
|
payment_code_reference: data.payment_code,
|
||||||
discount_code_id: data.discount_code?.id,
|
discount_code_id: data.discount_code?.id,
|
||||||
|
@ -106,7 +109,7 @@ export function mappingRevertTransaction(data, type) {
|
||||||
data.payment_type_method?.id ?? data.payment_type_bank?.id,
|
data.payment_type_method?.id ?? data.payment_type_bank?.id,
|
||||||
payment_type_method_number:
|
payment_type_method_number:
|
||||||
data.payment_type_method?.account_number ??
|
data.payment_type_method?.account_number ??
|
||||||
data.payment_type_bank?.account_number,
|
data.payment_type?.account_number,
|
||||||
payment_type_method_name:
|
payment_type_method_name:
|
||||||
data.payment_type_method?.issuer_name ??
|
data.payment_type_method?.issuer_name ??
|
||||||
data.payment_type_bank?.issuer_name,
|
data.payment_type_bank?.issuer_name,
|
||||||
|
|
|
@ -6,7 +6,6 @@ import {
|
||||||
Param,
|
Param,
|
||||||
RelationParam,
|
RelationParam,
|
||||||
} from 'src/core/modules/domain/entities/base-filter.entity';
|
} from 'src/core/modules/domain/entities/base-filter.entity';
|
||||||
import { BetweenQueryHelper } from 'src/core/helpers/query/between-query.helper';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class IndexTransactionManager extends BaseIndexManager<TransactionEntity> {
|
export class IndexTransactionManager extends BaseIndexManager<TransactionEntity> {
|
||||||
|
@ -76,43 +75,14 @@ export class IndexTransactionManager extends BaseIndexManager<TransactionEntity>
|
||||||
`refund.id`,
|
`refund.id`,
|
||||||
`refund.code`,
|
`refund.code`,
|
||||||
`refund.refund_date`,
|
`refund.refund_date`,
|
||||||
`refund.request_date`,
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
get specificFilter(): Param[] {
|
get specificFilter(): Param[] {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
cols: `${this.tableName}.invoice_code`,
|
cols: `${this.tableName}.name`,
|
||||||
data: this.filterParam.invoice_codes,
|
data: this.filterParam.names,
|
||||||
},
|
|
||||||
{
|
|
||||||
cols: `${this.tableName}.type`,
|
|
||||||
data: this.filterParam.types,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
cols: `${this.tableName}.customer_type`,
|
|
||||||
data: this.filterParam.customer_types,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
cols: `${this.tableName}.customer_name`,
|
|
||||||
data: this.filterParam.customer_names,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
cols: `${this.tableName}.payment_type`,
|
|
||||||
data: this.filterParam.payment_types,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
cols: `${this.tableName}.payment_bank`,
|
|
||||||
data: this.filterParam.payment_banks,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
cols: `refund.code`,
|
|
||||||
data: this.filterParam.refund_codes,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
cols: `${this.tableName}.creator_name`,
|
|
||||||
data: this.filterParam.creator_names,
|
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -120,49 +90,6 @@ export class IndexTransactionManager extends BaseIndexManager<TransactionEntity>
|
||||||
setQueryFilter(
|
setQueryFilter(
|
||||||
queryBuilder: SelectQueryBuilder<TransactionEntity>,
|
queryBuilder: SelectQueryBuilder<TransactionEntity>,
|
||||||
): SelectQueryBuilder<TransactionEntity> {
|
): SelectQueryBuilder<TransactionEntity> {
|
||||||
if (this.filterParam.booking_date_from) {
|
|
||||||
new BetweenQueryHelper(
|
|
||||||
queryBuilder,
|
|
||||||
this.tableName,
|
|
||||||
'booking_date',
|
|
||||||
this.filterParam.booking_date_from,
|
|
||||||
this.filterParam.booking_date_to,
|
|
||||||
'booking_date',
|
|
||||||
).getQuery();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.filterParam.invoice_date_from) {
|
|
||||||
new BetweenQueryHelper(
|
|
||||||
queryBuilder,
|
|
||||||
this.tableName,
|
|
||||||
'invoice_date',
|
|
||||||
this.filterParam.invoice_date_from,
|
|
||||||
this.filterParam.invoice_date_to,
|
|
||||||
'invoice_date',
|
|
||||||
).getQuery();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.filterParam.settlement_date_from) {
|
|
||||||
new BetweenQueryHelper(
|
|
||||||
queryBuilder,
|
|
||||||
this.tableName,
|
|
||||||
'settlement_date',
|
|
||||||
this.filterParam.settlement_date_from,
|
|
||||||
this.filterParam.settlement_date_to,
|
|
||||||
'settlement_date',
|
|
||||||
).getQuery();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.filterParam.request_refund_date_from) {
|
|
||||||
new BetweenQueryHelper(
|
|
||||||
queryBuilder,
|
|
||||||
this.tableName,
|
|
||||||
'request_refund_date',
|
|
||||||
this.filterParam.request_refund_date_from,
|
|
||||||
this.filterParam.request_refund_date_to,
|
|
||||||
'request_refund',
|
|
||||||
).getQuery();
|
|
||||||
}
|
|
||||||
queryBuilder.andWhere(`${this.tableName}.is_recap_transaction is false`);
|
queryBuilder.andWhere(`${this.tableName}.is_recap_transaction is false`);
|
||||||
return queryBuilder;
|
return queryBuilder;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,125 +0,0 @@
|
||||||
import { Injectable } from '@nestjs/common';
|
|
||||||
import { UserPrivilegeConfigurationEntity } from '../../../entities/user-privilege-configuration.entity';
|
|
||||||
import {
|
|
||||||
Param,
|
|
||||||
RelationParam,
|
|
||||||
} from 'src/core/modules/domain/entities/base-filter.entity';
|
|
||||||
import { BaseIndexManager } from 'src/core/modules/domain/usecase/managers/base-index.manager';
|
|
||||||
import { ORDER_TYPE } from 'src/core/strings/constants/base.constants';
|
|
||||||
import { SelectQueryBuilder } from 'typeorm';
|
|
||||||
import { FilterMenuUserPrivilegeConfigurationDto } from 'src/modules/user-related/user-privilege/infrastructure/dto/filter-menu-user-privilege-configuration.dto';
|
|
||||||
import { mod } from 'mathjs';
|
|
||||||
import { PaginationResponse } from 'src/core/response/domain/ok-response.interface';
|
|
||||||
import { UserRole } from 'src/modules/user-related/user/constants';
|
|
||||||
import { UserPrivilegeConfigurationHelper } from '../helpers/generate-user-privilege-configuration.helper';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class MenuUserPrivilegeConfigurationManager extends BaseIndexManager<UserPrivilegeConfigurationEntity> {
|
|
||||||
async prepareData(): Promise<void> {
|
|
||||||
Object.assign(this.filterParam, {
|
|
||||||
order_by: `${this.tableName}.index`,
|
|
||||||
order_type: ORDER_TYPE.ASC,
|
|
||||||
limit: 100,
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async beforeProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async afterProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
get relations(): RelationParam {
|
|
||||||
return {
|
|
||||||
joinRelations: [],
|
|
||||||
selectRelations: [],
|
|
||||||
countRelations: [],
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
get selects(): string[] {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
get specificFilter(): Param[] {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
setQueryFilter(
|
|
||||||
queryBuilder: SelectQueryBuilder<UserPrivilegeConfigurationEntity>,
|
|
||||||
): SelectQueryBuilder<UserPrivilegeConfigurationEntity> {
|
|
||||||
if (this.filterParam.modules) {
|
|
||||||
queryBuilder.andWhere('module In (:...modules)', {
|
|
||||||
modules: this.filterParam.modules,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.filterParam.menus) {
|
|
||||||
queryBuilder.andWhere('menu In (:...menus)', {
|
|
||||||
menus: this.filterParam.menus,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
queryBuilder.andWhere('user_privilege_id = :user_privilege_id', {
|
|
||||||
user_privilege_id: this.userProvider.user.user_privilege_id,
|
|
||||||
});
|
|
||||||
|
|
||||||
queryBuilder.andWhere('view = :view', {
|
|
||||||
view: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
return queryBuilder;
|
|
||||||
}
|
|
||||||
|
|
||||||
getMenuSuperAdmin(params: FilterMenuUserPrivilegeConfigurationDto) {
|
|
||||||
const modules = params?.modules ?? [];
|
|
||||||
const menus = params?.menus ?? [];
|
|
||||||
let configs = UserPrivilegeConfigurationHelper.createConfigurations();
|
|
||||||
|
|
||||||
if (modules.length > 0) {
|
|
||||||
configs = configs.filter((item) => modules.includes(item.module));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (menus.length > 0) {
|
|
||||||
configs = configs.filter((item) => menus.includes(item.menu));
|
|
||||||
}
|
|
||||||
|
|
||||||
const newResult = configs.map((item) => {
|
|
||||||
const newItem = item;
|
|
||||||
|
|
||||||
item.actions?.forEach((element) => {
|
|
||||||
item[element] = true;
|
|
||||||
});
|
|
||||||
|
|
||||||
newItem.actions = undefined;
|
|
||||||
|
|
||||||
const cleanData = Object.entries(newItem)
|
|
||||||
.filter(([key, value]) => value !== undefined)
|
|
||||||
.reduce((obj, [key, value]) => {
|
|
||||||
obj[key] = value;
|
|
||||||
return obj;
|
|
||||||
}, {});
|
|
||||||
|
|
||||||
return cleanData;
|
|
||||||
});
|
|
||||||
|
|
||||||
return newResult as any;
|
|
||||||
}
|
|
||||||
|
|
||||||
getResult(): PaginationResponse<UserPrivilegeConfigurationEntity> {
|
|
||||||
const role = this.userProvider.user.role;
|
|
||||||
const isSuperAdmin = role === UserRole.SUPERADMIN;
|
|
||||||
|
|
||||||
if (isSuperAdmin) {
|
|
||||||
return {
|
|
||||||
data: this.getMenuSuperAdmin(this.filterParam),
|
|
||||||
total: 100,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.result;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -5,14 +5,12 @@ import { UserPrivilegeConfigurationService } from '../../../data/service/user-pr
|
||||||
import { IndexUserPrivilegeConfigurationManager } from './managers/index-user-privilege-configuration.manager';
|
import { IndexUserPrivilegeConfigurationManager } from './managers/index-user-privilege-configuration.manager';
|
||||||
import { PaginationResponse } from 'src/core/response/domain/ok-response.interface';
|
import { PaginationResponse } from 'src/core/response/domain/ok-response.interface';
|
||||||
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
||||||
import { MenuUserPrivilegeConfigurationManager } from './managers/menu-user-privilege-configuration.manager';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class UserPrivilegeConfigurationDataOrchestrator {
|
export class UserPrivilegeConfigurationDataOrchestrator {
|
||||||
constructor(
|
constructor(
|
||||||
private updateManager: UpdateUserPrivilegeConfigurationManager,
|
private updateManager: UpdateUserPrivilegeConfigurationManager,
|
||||||
private indexManager: IndexUserPrivilegeConfigurationManager,
|
private indexManager: IndexUserPrivilegeConfigurationManager,
|
||||||
private privilegeMenuManager: MenuUserPrivilegeConfigurationManager,
|
|
||||||
private serviceData: UserPrivilegeConfigurationService,
|
private serviceData: UserPrivilegeConfigurationService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
@ -37,21 +35,4 @@ export class UserPrivilegeConfigurationDataOrchestrator {
|
||||||
await this.indexManager.execute();
|
await this.indexManager.execute();
|
||||||
return this.indexManager.getResult();
|
return this.indexManager.getResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
async privilegeMenu(
|
|
||||||
params,
|
|
||||||
): Promise<PaginationResponse<UserPrivilegeConfigurationEntity>> {
|
|
||||||
this.privilegeMenuManager.setFilterParam({
|
|
||||||
page: 1,
|
|
||||||
limit: 100,
|
|
||||||
...(params ?? {}),
|
|
||||||
});
|
|
||||||
|
|
||||||
this.privilegeMenuManager.setService(
|
|
||||||
this.serviceData,
|
|
||||||
TABLE_NAME.USER_PRIVILEGE_CONFIGURATION,
|
|
||||||
);
|
|
||||||
await this.privilegeMenuManager.execute();
|
|
||||||
return this.privilegeMenuManager.getResult();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
import { ApiProperty } from '@nestjs/swagger';
|
|
||||||
import { Transform } from 'class-transformer';
|
|
||||||
|
|
||||||
export class FilterMenuUserPrivilegeConfigurationDto {
|
|
||||||
@ApiProperty({ type: ['string'], required: false })
|
|
||||||
@Transform((body) => {
|
|
||||||
return Array.isArray(body.value) ? body.value : [body.value];
|
|
||||||
})
|
|
||||||
modules: string[];
|
|
||||||
|
|
||||||
@ApiProperty({ type: ['string'], required: false })
|
|
||||||
@Transform((body) => {
|
|
||||||
return Array.isArray(body.value) ? body.value : [body.value];
|
|
||||||
})
|
|
||||||
menus: string[];
|
|
||||||
}
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { Body, Controller, Get, Param, Put, Query } from '@nestjs/common';
|
import { Body, Controller, Get, Param, Put, Query } from '@nestjs/common';
|
||||||
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
||||||
import { ExcludePrivilege, Public } from 'src/core/guards';
|
import { Public } from 'src/core/guards';
|
||||||
import { MODULE_NAME } from 'src/core/strings/constants/module.constants';
|
import { MODULE_NAME } from 'src/core/strings/constants/module.constants';
|
||||||
import { UserPrivilegeConfigurationDataOrchestrator } from '../domain/usecases/user-privilege-configuration/user-privilege-configuration-data.orchestrator';
|
import { UserPrivilegeConfigurationDataOrchestrator } from '../domain/usecases/user-privilege-configuration/user-privilege-configuration-data.orchestrator';
|
||||||
import { UserPrivilegeConfigurationDto } from './dto/user-privilege-configuration.dto';
|
import { UserPrivilegeConfigurationDto } from './dto/user-privilege-configuration.dto';
|
||||||
|
@ -8,7 +8,6 @@ import { UserPrivilegeConfigurationEntity } from '../domain/entities/user-privil
|
||||||
import { FilterUserPrivilegeConfigurationDto } from './dto/filter-user-privilege-configuration.dto';
|
import { FilterUserPrivilegeConfigurationDto } from './dto/filter-user-privilege-configuration.dto';
|
||||||
import { PaginationResponse } from 'src/core/response/domain/ok-response.interface';
|
import { PaginationResponse } from 'src/core/response/domain/ok-response.interface';
|
||||||
import { Pagination } from 'src/core/response';
|
import { Pagination } from 'src/core/response';
|
||||||
import { FilterMenuUserPrivilegeConfigurationDto } from './dto/filter-menu-user-privilege-configuration.dto';
|
|
||||||
|
|
||||||
@ApiTags(
|
@ApiTags(
|
||||||
`${MODULE_NAME.USER_PRIVILEGE_CONFIGURATION.split('-').join(' ')} - data`,
|
`${MODULE_NAME.USER_PRIVILEGE_CONFIGURATION.split('-').join(' ')} - data`,
|
||||||
|
@ -35,12 +34,4 @@ export class UserPrivilegeConfigurationController {
|
||||||
): Promise<PaginationResponse<UserPrivilegeConfigurationEntity>> {
|
): Promise<PaginationResponse<UserPrivilegeConfigurationEntity>> {
|
||||||
return await this.orchestrator.index(params);
|
return await this.orchestrator.index(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get('/menu')
|
|
||||||
@ExcludePrivilege()
|
|
||||||
async privilegeMenu(
|
|
||||||
@Query() params: FilterMenuUserPrivilegeConfigurationDto,
|
|
||||||
): Promise<UserPrivilegeConfigurationEntity[]> {
|
|
||||||
return (await this.orchestrator.privilegeMenu(params)).data ?? [];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,6 @@ import { UserPrivilegeConfigurationController } from './infrastructure/user-priv
|
||||||
import { UserPrivilegeConfigurationDataOrchestrator } from './domain/usecases/user-privilege-configuration/user-privilege-configuration-data.orchestrator';
|
import { UserPrivilegeConfigurationDataOrchestrator } from './domain/usecases/user-privilege-configuration/user-privilege-configuration-data.orchestrator';
|
||||||
import { IndexUserPrivilegeConfigurationManager } from './domain/usecases/user-privilege-configuration/managers/index-user-privilege-configuration.manager';
|
import { IndexUserPrivilegeConfigurationManager } from './domain/usecases/user-privilege-configuration/managers/index-user-privilege-configuration.manager';
|
||||||
import { UserPrivilegeModels } from './constants';
|
import { UserPrivilegeModels } from './constants';
|
||||||
import { MenuUserPrivilegeConfigurationManager } from './domain/usecases/user-privilege-configuration/managers/menu-user-privilege-configuration.manager';
|
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
|
@ -56,7 +55,6 @@ import { MenuUserPrivilegeConfigurationManager } from './domain/usecases/user-pr
|
||||||
|
|
||||||
IndexUserPrivilegeConfigurationManager,
|
IndexUserPrivilegeConfigurationManager,
|
||||||
UpdateUserPrivilegeConfigurationManager,
|
UpdateUserPrivilegeConfigurationManager,
|
||||||
MenuUserPrivilegeConfigurationManager,
|
|
||||||
|
|
||||||
UserPrivilegeDataService,
|
UserPrivilegeDataService,
|
||||||
UserPrivilegeReadService,
|
UserPrivilegeReadService,
|
||||||
|
|
Loading…
Reference in New Issue