law-common 11.3.6-beta.3 → 11.3.6-beta.4

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.
@@ -9,7 +9,9 @@ export declare enum ConfigurationKeyEnum {
9
9
  PROJECT_ENTITY_USAGE_NOTIFICATION_SENT_PERCENTAGE_RESET = "projectEntityUsageNotificationSentPercentageReset",
10
10
  LEAVE_ESCALATION = "leaveEscalation",
11
11
  TIMESHEET_AUTO_CLASSIFICATION = "timesheetAutoClassification",
12
- TIMESHEET_CLASSIFICATION_NOTIFICATION = "timesheetClassificationNotification"
12
+ TIMESHEET_CLASSIFICATION_NOTIFICATION = "timesheetClassificationNotification",
13
+ TIMESHEET_CLASSIFICATION_BUFFER_DAYS = "timesheetClassificationBufferDays",
14
+ TIMESHEET_CLASSIFICATION_WINDOWS = "timesheetClassificationWindows"
13
15
  }
14
16
  export declare namespace ConfigurationKeyEnum {
15
17
  function getNames(): string[];
@@ -16,6 +16,8 @@ var ConfigurationKeyEnum;
16
16
  ConfigurationKeyEnum["LEAVE_ESCALATION"] = "leaveEscalation";
17
17
  ConfigurationKeyEnum["TIMESHEET_AUTO_CLASSIFICATION"] = "timesheetAutoClassification";
18
18
  ConfigurationKeyEnum["TIMESHEET_CLASSIFICATION_NOTIFICATION"] = "timesheetClassificationNotification";
19
+ ConfigurationKeyEnum["TIMESHEET_CLASSIFICATION_BUFFER_DAYS"] = "timesheetClassificationBufferDays";
20
+ ConfigurationKeyEnum["TIMESHEET_CLASSIFICATION_WINDOWS"] = "timesheetClassificationWindows";
19
21
  })(ConfigurationKeyEnum || (exports.ConfigurationKeyEnum = ConfigurationKeyEnum = {}));
20
22
  (function (ConfigurationKeyEnum) {
21
23
  function getNames() {
@@ -1,13 +1,20 @@
1
1
  import { CurrencyEnum } from "../../enums";
2
2
  import { TimesheetClassificationStatusEnum } from "../enums/timesheet.classification.status.enum";
3
3
  import { TimesheetStatusEnum } from "../enums/timesheet.status.enum";
4
- import { EntityEnum } from "../interface/entity.utils.interface";
4
+ import { EntityEnum, Nullable } from "../interface/entity.utils.interface";
5
5
  import { RelationConfigs } from "../interface/relation-config.interface";
6
6
  import { ITimesheetEntity } from "../interface/timesheet.entity.interface";
7
7
  import { BaseEntityModel } from "./base.entity.model";
8
8
  import { ProjectEntityModel } from "./project.entity.model";
9
9
  import { TimesheetHistoryEntityModel } from "./timesheet_history.entity.model";
10
10
  import { UserEntityModel } from "./user.entity.model";
11
+ export interface IClassificationWindowConfig {
12
+ bufferDays: number;
13
+ windows: Array<{
14
+ startDay: number;
15
+ endDay: Nullable<number>;
16
+ }>;
17
+ }
11
18
  export declare class TimesheetEntityModel extends BaseEntityModel<EntityEnum.TIMESHEET> implements ITimesheetEntity {
12
19
  id: number;
13
20
  userId: number;
@@ -38,22 +45,12 @@ export declare class TimesheetEntityModel extends BaseEntityModel<EntityEnum.TIM
38
45
  get userName(): string | undefined;
39
46
  get latestStatusFromHistory(): TimesheetStatusEnum | undefined;
40
47
  getDateCodeDay(): number;
41
- getClassificationDeadline(): Date;
42
- static readonly CLASSIFICATION_WINDOW_CONFIG: {
43
- bufferDays: number;
44
- windows: ({
45
- startDay: number;
46
- endDay: number;
47
- } | {
48
- startDay: number;
49
- endDay: null;
50
- })[];
51
- };
52
- static getTimesheetAutoClassificationDateCodeRange(): {
48
+ getClassificationDeadline(config: IClassificationWindowConfig): Date;
49
+ static getTimesheetAutoClassificationDateCodeRange(config: IClassificationWindowConfig): {
53
50
  windowStart: string;
54
51
  windowEnd: string;
55
52
  } | null;
56
- static getActiveClassificationWindowRange(): {
53
+ static getActiveClassificationWindowRange(config: IClassificationWindowConfig): {
57
54
  windowStart: string;
58
55
  windowEnd: string;
59
56
  } | null;
@@ -61,12 +61,12 @@ class TimesheetEntityModel extends base_entity_model_1.BaseEntityModel {
61
61
  const normalized = this.dateCode.length === 6 ? `20${this.dateCode}` : this.dateCode;
62
62
  return parseInt(normalized.substring(6, 8), 10);
63
63
  }
64
- getClassificationDeadline() {
64
+ getClassificationDeadline(config) {
65
65
  const normalized = this.dateCode.length === 6 ? `20${this.dateCode}` : this.dateCode;
66
66
  const year = parseInt(normalized.substring(0, 4), 10);
67
67
  const month = parseInt(normalized.substring(4, 6), 10);
68
68
  const day = this.getDateCodeDay();
69
- const { bufferDays, windows } = TimesheetEntityModel.CLASSIFICATION_WINDOW_CONFIG;
69
+ const { bufferDays, windows } = config;
70
70
  const window = windows.find((w) => day >= w.startDay && (w.endDay === null || day <= w.endDay));
71
71
  if (!window) {
72
72
  const d = new Date(year, month - 1, day + bufferDays);
@@ -82,9 +82,9 @@ class TimesheetEntityModel extends base_entity_model_1.BaseEntityModel {
82
82
  d.setHours(23, 59, 59, 999);
83
83
  return d;
84
84
  }
85
- static getTimesheetAutoClassificationDateCodeRange() {
85
+ static getTimesheetAutoClassificationDateCodeRange(config) {
86
86
  var _a;
87
- const { bufferDays, windows } = TimesheetEntityModel.CLASSIFICATION_WINDOW_CONFIG;
87
+ const { bufferDays, windows } = config;
88
88
  const today = new Date();
89
89
  for (const window of windows) {
90
90
  // Last window (endDay === null) belongs to the previous month
@@ -102,9 +102,9 @@ class TimesheetEntityModel extends base_entity_model_1.BaseEntityModel {
102
102
  }
103
103
  return null;
104
104
  }
105
- static getActiveClassificationWindowRange() {
105
+ static getActiveClassificationWindowRange(config) {
106
106
  var _a;
107
- const { windows } = TimesheetEntityModel.CLASSIFICATION_WINDOW_CONFIG;
107
+ const { bufferDays, windows } = config;
108
108
  const today = new Date();
109
109
  const day = today.getDate();
110
110
  const year = today.getFullYear();
@@ -119,7 +119,7 @@ class TimesheetEntityModel extends base_entity_model_1.BaseEntityModel {
119
119
  const windowEndDay = actualEndDay;
120
120
  // check if today falls within this window's active period
121
121
  // active period = from windowStart until triggerDate (endDay + bufferDays)
122
- const triggerDate = (0, date_fns_1.addDays)(new Date(targetYear, targetMonth, actualEndDay), TimesheetEntityModel.CLASSIFICATION_WINDOW_CONFIG.bufferDays);
122
+ const triggerDate = (0, date_fns_1.addDays)(new Date(targetYear, targetMonth, actualEndDay), bufferDays);
123
123
  const triggerDay = triggerDate.getDate();
124
124
  const triggerMonth = triggerDate.getMonth();
125
125
  const triggerYear = triggerDate.getFullYear();
@@ -167,11 +167,3 @@ TimesheetEntityModel.relationConfigs = [
167
167
  },
168
168
  },
169
169
  ];
170
- TimesheetEntityModel.CLASSIFICATION_WINDOW_CONFIG = {
171
- bufferDays: 3,
172
- windows: [
173
- { startDay: 1, endDay: 10 },
174
- { startDay: 11, endDay: 20 },
175
- { startDay: 21, endDay: null },
176
- ],
177
- };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "law-common",
3
- "version": "11.3.6-beta.3",
3
+ "version": "11.3.6-beta.4",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "files": [