fix(SPG_693) di hak akses pos pada bagian penjualan seharusnya ada checkbox pada kolom cancel dan ada hak akses reprint receipt
parent
c6be42299e
commit
197b3478ae
|
@ -62,6 +62,14 @@ export abstract class BaseDataService<Entity> {
|
||||||
await this.repository.delete(id);
|
await this.repository.delete(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async deleteByIds(
|
||||||
|
queryRunner: QueryRunner,
|
||||||
|
entityTarget: EntityTarget<Entity>,
|
||||||
|
ids: string[],
|
||||||
|
): Promise<void> {
|
||||||
|
await this.repository.delete(ids);
|
||||||
|
}
|
||||||
|
|
||||||
async deleteByOptions(
|
async deleteByOptions(
|
||||||
queryRunner: QueryRunner,
|
queryRunner: QueryRunner,
|
||||||
entityTarget: EntityTarget<Entity>,
|
entityTarget: EntityTarget<Entity>,
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
export interface BaseCoreEntity {
|
export interface BaseCoreEntity {
|
||||||
id: string;
|
id?: string;
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,6 +147,7 @@ export const PrivilegePOSConstant = [
|
||||||
PrivilegeAction.CREATE,
|
PrivilegeAction.CREATE,
|
||||||
PrivilegeAction.DELETE,
|
PrivilegeAction.DELETE,
|
||||||
PrivilegeAction.EDIT,
|
PrivilegeAction.EDIT,
|
||||||
|
PrivilegeAction.CANCEL,
|
||||||
],
|
],
|
||||||
index: 14,
|
index: 14,
|
||||||
},
|
},
|
||||||
|
@ -174,4 +175,10 @@ export const PrivilegePOSConstant = [
|
||||||
actions: [PrivilegeAction.CREATE],
|
actions: [PrivilegeAction.CREATE],
|
||||||
index: 18,
|
index: 18,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
menu: 'POS_DISCOUNT_CODE',
|
||||||
|
menu_label: 'Print Receipt',
|
||||||
|
actions: [PrivilegeAction.CREATE],
|
||||||
|
index: 18,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
|
@ -5,13 +5,13 @@ export interface UserPrivilegeConfigurationEntity extends BaseCoreEntity {
|
||||||
module_label: string;
|
module_label: string;
|
||||||
menu: string;
|
menu: string;
|
||||||
menu_label: string;
|
menu_label: string;
|
||||||
sub_menu: string;
|
sub_menu?: string;
|
||||||
sub_menu_label: string;
|
sub_menu_label?: string;
|
||||||
view: boolean;
|
view?: boolean;
|
||||||
create: boolean;
|
create?: boolean;
|
||||||
edit: boolean;
|
edit?: boolean;
|
||||||
delete: boolean;
|
delete?: boolean;
|
||||||
cancel: boolean;
|
cancel?: boolean;
|
||||||
confirm: boolean;
|
confirm?: boolean;
|
||||||
index: number;
|
index?: number;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,66 @@
|
||||||
|
import { 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 { UserPrivilegeConfigurationModel } from 'src/modules/user-related/user-privilege/data/models/user-privilege-configuration.model';
|
||||||
|
|
||||||
|
@EventsHandler(UserPrivilegeConfigUpdatedEvent)
|
||||||
|
export class UserPrivilegeConfigUpdateHandler
|
||||||
|
implements IEventHandler<UserPrivilegeConfigUpdatedEvent>
|
||||||
|
{
|
||||||
|
constructor(private dataService: UserPrivilegeConfigurationService) {}
|
||||||
|
|
||||||
|
async handle(event: UserPrivilegeConfigUpdatedEvent) {
|
||||||
|
const data = event.data.data;
|
||||||
|
console.log(data.user_privilege_id);
|
||||||
|
const configurations = await this.dataService.getManyByOptions({
|
||||||
|
where: {
|
||||||
|
user_privilege_id: data.user_privilege_id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const configs = UserPrivilegeConfigurationHelper.createConfigurations();
|
||||||
|
|
||||||
|
const createdConfig = configs
|
||||||
|
.filter(
|
||||||
|
(base) =>
|
||||||
|
!configurations.some((data) => {
|
||||||
|
return base.menu_label == data.menu_label;
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.map((item) => {
|
||||||
|
return {
|
||||||
|
...item,
|
||||||
|
user_privilege_id: data.user_privilege_id,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
const deletedConfig = configurations
|
||||||
|
.filter(
|
||||||
|
(base) =>
|
||||||
|
!configs.some((data) => {
|
||||||
|
return base.menu_label == data.menu_label;
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
?.map((item) => item.id);
|
||||||
|
|
||||||
|
const queryRunner = this.dataService
|
||||||
|
.getRepository()
|
||||||
|
.manager.connection.createQueryRunner();
|
||||||
|
|
||||||
|
if (createdConfig.length) {
|
||||||
|
await this.dataService.createBatch(
|
||||||
|
queryRunner,
|
||||||
|
UserPrivilegeConfigurationModel,
|
||||||
|
createdConfig,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (deletedConfig.length) {
|
||||||
|
await this.dataService.deleteByIds(
|
||||||
|
queryRunner,
|
||||||
|
UserPrivilegeConfigurationModel,
|
||||||
|
deletedConfig,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -28,6 +28,7 @@ import { UserPrivilegeConfigurationDataOrchestrator } from './domain/usecases/us
|
||||||
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';
|
import { MenuUserPrivilegeConfigurationManager } from './domain/usecases/user-privilege-configuration/managers/menu-user-privilege-configuration.manager';
|
||||||
|
import { UserPrivilegeConfigUpdateHandler } from './domain/usecases/user-privilege-configuration/handlers/update-user-privilege-configuration.helper';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
|
@ -41,6 +42,8 @@ import { MenuUserPrivilegeConfigurationManager } from './domain/usecases/user-pr
|
||||||
UserPrivilegeConfigurationController,
|
UserPrivilegeConfigurationController,
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
|
UserPrivilegeConfigUpdateHandler,
|
||||||
|
|
||||||
IndexUserPrivilegeManager,
|
IndexUserPrivilegeManager,
|
||||||
DetailUserPrivilegeManager,
|
DetailUserPrivilegeManager,
|
||||||
CreateUserPrivilegeManager,
|
CreateUserPrivilegeManager,
|
||||||
|
|
Loading…
Reference in New Issue