rez_core 5.0.52 → 5.0.54

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rez_core",
3
- "version": "5.0.52",
3
+ "version": "5.0.54",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -895,6 +895,24 @@ export class FilterService {
895
895
  // convert to number when needed
896
896
  const numVal = Number(val);
897
897
 
898
+ // INSIDE buildDateCondition
899
+ const subtractBusinessDays = (days: number): string => {
900
+ let d = new Date();
901
+ let count = 0;
902
+
903
+ while (count < days) {
904
+ d.setDate(d.getDate() - 1);
905
+
906
+ const day = d.getDay(); // 0 = Sunday, 6 = Saturday
907
+
908
+ if (day !== 0 && day !== 6) {
909
+ count++;
910
+ }
911
+ }
912
+
913
+ return d.toISOString().split('T')[0];
914
+ };
915
+
898
916
  switch (op) {
899
917
  // ============================================
900
918
  // BASIC COMPARISONS
@@ -1070,30 +1088,14 @@ export class FilterService {
1070
1088
 
1071
1089
  case 'is_before_business_days': {
1072
1090
  if (isNaN(numVal)) {
1073
- throw new BadRequestException(
1074
- 'Value must be a number for is_before_business_days',
1075
- );
1091
+ throw new BadRequestException('Value must be a number');
1076
1092
  }
1077
1093
 
1078
- const businessBefore = (() => {
1079
- let d = new Date();
1080
- let count = 0;
1081
-
1082
- while (count < numVal) {
1083
- d.setDate(d.getDate() - 1);
1084
- const day = d.getDay(); // 0=Sun, 6=Sat
1085
- if (day !== 0 && day !== 6) count++;
1086
- }
1087
-
1088
- // DB shift -1 day
1089
- d.setDate(d.getDate() - 1);
1090
-
1091
- return d.toISOString().split('T')[0];
1092
- })();
1094
+ const targetDate = subtractBusinessDays(numVal);
1093
1095
 
1094
1096
  return {
1095
1097
  query: `${dateColumn} < :${key}`,
1096
- params: { [key]: businessBefore },
1098
+ params: { [key]: targetDate },
1097
1099
  };
1098
1100
  }
1099
1101
 
@@ -8,6 +8,7 @@ import { InjectRepository } from '@nestjs/typeorm';
8
8
  import { DataSource, Repository } from 'typeorm';
9
9
  import { ActionEntity } from '../entity/action.entity';
10
10
  import { UserData } from 'src/module/user/entity/user.entity';
11
+ import { ReflectionHelper } from '../../../utils/service/reflection-helper.service';
11
12
 
12
13
  @Injectable()
13
14
  export class ActionRepository {
@@ -15,6 +16,7 @@ export class ActionRepository {
15
16
  @InjectRepository(ActionEntity)
16
17
  private readonly actionRepository: Repository<ActionEntity>,
17
18
  private readonly dataSource: DataSource,
19
+ private readonly reflectionHelper: ReflectionHelper,
18
20
  ) {}
19
21
 
20
22
  async getReasonCode(loggedInUser: UserData): Promise<any> {
@@ -221,10 +223,14 @@ export class ActionRepository {
221
223
  mapped_entity_type: string,
222
224
  ) {
223
225
  // Step 1: Get all action mappings for the stage
224
- const stageActions = await this.dataSource.query(
225
- `SELECT id, action_id FROM frm_wf_stage_action_mapping WHERE stage_id = $1`,
226
- [stage_id],
227
- );
226
+
227
+ const stageActionMappingRepo =
228
+ this.reflectionHelper.getRepoService('StageActionMapping');
229
+ const stageActions = await stageActionMappingRepo.find({
230
+ where: {
231
+ stage_id: stage_id,
232
+ },
233
+ });
228
234
 
229
235
  if (!stageActions?.length) {
230
236
  return [
@@ -249,13 +255,17 @@ export class ActionRepository {
249
255
  'a.mode AS mode',
250
256
  'a.action_category AS action_category_id',
251
257
  'ac.reason_code AS category_reason_code',
252
- 'ac.modalName AS modalName',
258
+ 'ac.modalname AS modalname',
253
259
  'ac.logo AS logo',
254
260
  'ac.name AS action_category_name',
255
261
  'a.dependent_action_id AS dependent_action_id',
256
262
  ])
257
263
  .from('frm_wf_action', 'a')
258
- .leftJoin('frm_wf_action_category', 'ac', 'ac.id::text = a.action_category::text')
264
+ .leftJoin(
265
+ 'frm_wf_action_category',
266
+ 'ac',
267
+ 'ac.id::text = a.action_category',
268
+ )
259
269
  .where('a.organization_id = :orgId', { orgId: organization_id })
260
270
  .andWhere('a.id IN (:...actionIds)', { actionIds })
261
271
  .getRawMany();
@@ -300,7 +310,7 @@ export class ActionRepository {
300
310
  value: row.action_id,
301
311
  dependent_action_id: row.dependent_action_id,
302
312
  label: row.action_name,
303
- modalName: row.modalName,
313
+ modalname: row.modalname,
304
314
  logo: row.logo,
305
315
  mode: row.mode,
306
316
  name: row.action_category_name,