law-common 11.3.3-beta.5 → 11.3.5

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.
@@ -1,5 +1,6 @@
1
1
  export declare enum BillingTimesheetStatusEnum {
2
2
  UNCHANGED = "unchanged",
3
3
  UPDATED = "updated",
4
- DELETED = "deleted"
4
+ DELETED = "deleted",
5
+ NEW = "new"
5
6
  }
@@ -6,4 +6,5 @@ var BillingTimesheetStatusEnum;
6
6
  BillingTimesheetStatusEnum["UNCHANGED"] = "unchanged";
7
7
  BillingTimesheetStatusEnum["UPDATED"] = "updated";
8
8
  BillingTimesheetStatusEnum["DELETED"] = "deleted";
9
+ BillingTimesheetStatusEnum["NEW"] = "new";
9
10
  })(BillingTimesheetStatusEnum || (exports.BillingTimesheetStatusEnum = BillingTimesheetStatusEnum = {}));
@@ -7,8 +7,7 @@ export declare enum TimesheetActionEnum {
7
7
  REJECT = "reject",
8
8
  RECALL = "recall",
9
9
  BILLING_UPDATE = "billing_update",
10
- MOVE_TIMESHEET = "move_timesheet",
11
- CLASSIFY = "classify"
10
+ MOVE_TIMESHEET = "move_timesheet"
12
11
  }
13
12
  export declare namespace TimesheetActionEnum {
14
13
  function getLabel(action: TimesheetActionEnum): string;
@@ -14,7 +14,6 @@ var TimesheetActionEnum;
14
14
  TimesheetActionEnum["RECALL"] = "recall";
15
15
  TimesheetActionEnum["BILLING_UPDATE"] = "billing_update";
16
16
  TimesheetActionEnum["MOVE_TIMESHEET"] = "move_timesheet";
17
- TimesheetActionEnum["CLASSIFY"] = "classify";
18
17
  })(TimesheetActionEnum || (exports.TimesheetActionEnum = TimesheetActionEnum = {}));
19
18
  (function (TimesheetActionEnum) {
20
19
  const actionLabelMap = {
@@ -27,7 +26,6 @@ var TimesheetActionEnum;
27
26
  [TimesheetActionEnum.RECALL]: "Recall",
28
27
  [TimesheetActionEnum.BILLING_UPDATE]: "Billing Update",
29
28
  [TimesheetActionEnum.MOVE_TIMESHEET]: "Move Timesheet",
30
- [TimesheetActionEnum.CLASSIFY]: "Classify",
31
29
  };
32
30
  function getLabel(action) {
33
31
  if (!Object.values(TimesheetActionEnum).includes(action)) {
@@ -39,7 +39,6 @@ export * from "./interface/billing_timesheet_history.entity.interface";
39
39
  export * from "./enums/history_operation.enum";
40
40
  export * from "./enums/timesheet.action.enum";
41
41
  export * from "./enums/timesheet.status.enum";
42
- export * from "./enums/timesheet.classification.status.enum";
43
42
  export * from "./enums/billing.action.enum";
44
43
  export * from "./enums/configuration.type.enum";
45
44
  export * from "./enums/project_user_status.enum";
@@ -55,7 +55,6 @@ __exportStar(require("./interface/billing_timesheet_history.entity.interface"),
55
55
  __exportStar(require("./enums/history_operation.enum"), exports);
56
56
  __exportStar(require("./enums/timesheet.action.enum"), exports);
57
57
  __exportStar(require("./enums/timesheet.status.enum"), exports);
58
- __exportStar(require("./enums/timesheet.classification.status.enum"), exports);
59
58
  __exportStar(require("./enums/billing.action.enum"), exports);
60
59
  __exportStar(require("./enums/configuration.type.enum"), exports);
61
60
  __exportStar(require("./enums/project_user_status.enum"), exports);
@@ -1,5 +1,4 @@
1
1
  import { TimesheetActionEnum } from "../enums/timesheet.action.enum";
2
- import { TimesheetClassificationStatusEnum } from "../enums/timesheet.classification.status.enum";
3
2
  import { TimesheetStatusEnum } from "../enums/timesheet.status.enum";
4
3
  import { ProjectUserMappingEntityModel } from "../model/project-user-mapping.entity.model";
5
4
  import { TimesheetEntityModel } from "../model/timesheet.entity.model";
@@ -17,15 +16,10 @@ export interface ITimesheetEntity extends IEntityAuditColumn {
17
16
  status: TimesheetStatusEnum;
18
17
  remark?: string;
19
18
  billingId?: number;
20
- billedDuration?: number;
21
- notBilledDuration?: number;
22
- classificationStatus: TimesheetClassificationStatusEnum;
23
- classifiedBy?: number;
24
19
  }
25
- export type ITimesheetEntityExclude = "status" | "billedDuration" | "notBilledDuration" | "classificationStatus" | "classifiedBy";
20
+ export type ITimesheetEntityExclude = "status";
26
21
  export interface ITimesheetEntityCreateDto extends Omit<IEntityCreateDto<ITimesheetEntity>, ITimesheetEntityExclude> {
27
22
  status?: TimesheetStatusEnum;
28
- classificationStatus?: TimesheetClassificationStatusEnum;
29
23
  }
30
24
  export interface ITimesheetEntityCreateDtoValidationData {
31
25
  projectUserMappingEntities: ProjectUserMappingEntityModel[];
@@ -1,11 +1,9 @@
1
1
  import { CurrencyEnum } from "../../enums";
2
- import { TimesheetClassificationStatusEnum } from "../enums/timesheet.classification.status.enum";
3
2
  import { TimesheetStatusEnum } from "../enums/timesheet.status.enum";
4
3
  import { EntityEnum } from "../interface/entity.utils.interface";
5
4
  import { RelationConfigs } from "../interface/relation-config.interface";
6
5
  import { ITimesheetEntity } from "../interface/timesheet.entity.interface";
7
6
  import { BaseEntityModel } from "./base.entity.model";
8
- import { ProjectEntityModel } from "./project.entity.model";
9
7
  import { TimesheetHistoryEntityModel } from "./timesheet_history.entity.model";
10
8
  import { UserEntityModel } from "./user.entity.model";
11
9
  export declare class TimesheetEntityModel extends BaseEntityModel<EntityEnum.TIMESHEET> implements ITimesheetEntity {
@@ -19,34 +17,17 @@ export declare class TimesheetEntityModel extends BaseEntityModel<EntityEnum.TIM
19
17
  status: TimesheetStatusEnum;
20
18
  remark?: string;
21
19
  billingId?: number;
22
- billedDuration?: number;
23
- notBilledDuration?: number;
24
- classificationStatus: TimesheetClassificationStatusEnum;
25
- classifiedBy?: number;
26
20
  createdBy: number;
27
21
  updatedBy: number;
28
22
  createdOn: number;
29
23
  updatedOn: number;
30
24
  user?: UserEntityModel;
31
25
  history?: TimesheetHistoryEntityModel[];
32
- project?: ProjectEntityModel;
33
26
  static fromEntity(entity: ITimesheetEntity): TimesheetEntityModel;
34
27
  getRelationConfigs(): any[];
35
- static relationConfigs: RelationConfigs<[EntityEnum.USER, EntityEnum.TIMESHEET_HISTORY, EntityEnum.PROJECT], EntityEnum.TIMESHEET>;
28
+ static relationConfigs: RelationConfigs<[EntityEnum.USER, EntityEnum.TIMESHEET_HISTORY], EntityEnum.TIMESHEET>;
36
29
  getTimesheetAmount(projectCurrency: CurrencyEnum): number;
37
30
  get formattedDate(): string;
38
31
  get userName(): string | undefined;
39
32
  get latestStatusFromHistory(): TimesheetStatusEnum | undefined;
40
- 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
33
  }
@@ -3,11 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TimesheetEntityModel = void 0;
4
4
  const utils_1 = require("../../utils");
5
5
  const relation_type_enum_1 = require("../enums/relation-type.enum");
6
- const timesheet_classification_status_enum_1 = require("../enums/timesheet.classification.status.enum");
7
6
  const timesheet_status_enum_1 = require("../enums/timesheet.status.enum");
8
7
  const entity_utils_interface_1 = require("../interface/entity.utils.interface");
9
8
  const base_entity_model_1 = require("./base.entity.model");
10
- // Use this mdoel for UI & BACKEND
11
9
  class TimesheetEntityModel extends base_entity_model_1.BaseEntityModel {
12
10
  constructor() {
13
11
  super(...arguments);
@@ -18,11 +16,17 @@ class TimesheetEntityModel extends base_entity_model_1.BaseEntityModel {
18
16
  this.dateCode = "";
19
17
  this.totalDuration = 0;
20
18
  this.status = timesheet_status_enum_1.TimesheetStatusEnum.CREATE_APPROVAL;
21
- this.classificationStatus = timesheet_classification_status_enum_1.TimesheetClassificationStatusEnum.PENDING;
22
19
  this.createdBy = 0;
23
20
  this.updatedBy = 0;
24
21
  this.createdOn = 0;
25
22
  this.updatedOn = 0;
23
+ // get latestStatusFromHistory(): TimesheetStatusEnum | undefined {
24
+ // const allHistoryModelSortedByIdInDesc = [...(this.history || [])].sort((a, b) => b.id - a.id);
25
+ // for (const model of allHistoryModelSortedByIdInDesc) {
26
+ // if (model.hasStatusKeyInData()) return model.status;
27
+ // }
28
+ // return undefined;
29
+ // }
26
30
  }
27
31
  static fromEntity(entity) {
28
32
  const result = new TimesheetEntityModel(entity_utils_interface_1.EntityEnum.TIMESHEET);
@@ -49,32 +53,6 @@ class TimesheetEntityModel extends base_entity_model_1.BaseEntityModel {
49
53
  const sorted = [...(this.history || [])].sort((a, b) => b.id - a.id);
50
54
  return (_a = sorted[1]) === null || _a === void 0 ? void 0 : _a.status;
51
55
  }
52
- // get latestStatusFromHistory(): TimesheetStatusEnum | undefined {
53
- // const allHistoryModelSortedByIdInDesc = [...(this.history || [])].sort((a, b) => b.id - a.id);
54
- // for (const model of allHistoryModelSortedByIdInDesc) {
55
- // if (model.hasStatusKeyInData()) return model.status;
56
- // }
57
- // return undefined;
58
- // }
59
- getDateCodeDay() {
60
- const normalized = this.dateCode.length === 6 ? `20${this.dateCode}` : this.dateCode;
61
- return parseInt(normalized.substring(6, 8), 10);
62
- }
63
- getClassificationDeadline() {
64
- const normalized = this.dateCode.length === 6 ? `20${this.dateCode}` : this.dateCode;
65
- const year = parseInt(normalized.substring(0, 4), 10);
66
- const month = parseInt(normalized.substring(4, 6), 10);
67
- const day = this.getDateCodeDay();
68
- const { bufferDays, windows } = TimesheetEntityModel.CLASSIFICATION_WINDOW_CONFIG;
69
- const window = windows.find((w) => day >= w.startDay && (w.endDay === null || day <= w.endDay));
70
- if (!window) {
71
- return new Date(year, month - 1, day + bufferDays);
72
- }
73
- if (window.endDay === null) {
74
- return new Date(year, month, 3);
75
- }
76
- return new Date(year, month - 1, window.endDay + bufferDays);
77
- }
78
56
  }
79
57
  exports.TimesheetEntityModel = TimesheetEntityModel;
80
58
  TimesheetEntityModel.relationConfigs = [
@@ -96,21 +74,4 @@ TimesheetEntityModel.relationConfigs = [
96
74
  key: "id",
97
75
  },
98
76
  },
99
- {
100
- name: entity_utils_interface_1.EntityEnum.PROJECT,
101
- relation: relation_type_enum_1.RelationType.ONE,
102
- key: "project",
103
- mapKeyConfig: {
104
- relationKey: "id",
105
- key: "projectId",
106
- },
107
- },
108
77
  ];
109
- TimesheetEntityModel.CLASSIFICATION_WINDOW_CONFIG = {
110
- bufferDays: 3,
111
- windows: [
112
- { startDay: 1, endDay: 10 },
113
- { startDay: 11, endDay: 20 },
114
- { startDay: 21, endDay: null },
115
- ],
116
- };
@@ -1,4 +1,4 @@
1
- import { ITimesheetEntity, TimesheetClassificationStatusEnum, TimesheetStatusEnum } from "../../entities";
1
+ import { ITimesheetEntity, TimesheetStatusEnum } from "../../entities";
2
2
  import { ITimesheetEntityModel } from "./interface/timesheet.model.interface";
3
3
  export declare class TimesheetEntityModel implements ITimesheetEntityModel {
4
4
  id: number;
@@ -14,10 +14,6 @@ export declare class TimesheetEntityModel implements ITimesheetEntityModel {
14
14
  updatedOn: number;
15
15
  status: TimesheetStatusEnum;
16
16
  billingId?: number;
17
- billedDuration?: number;
18
- notBilledDuration?: number;
19
- classificationStatus: TimesheetClassificationStatusEnum;
20
- classifiedBy?: number;
21
17
  /**
22
18
  * @param timesheets - Array of TimesheetModel instances
23
19
  * @return - Array of Timesheet Model
@@ -17,7 +17,6 @@ class TimesheetEntityModel {
17
17
  this.updatedOn = 0;
18
18
  this.status = entities_1.TimesheetStatusEnum.CREATE_APPROVAL;
19
19
  this.billingId = 0;
20
- this.classificationStatus = entities_1.TimesheetClassificationStatusEnum.PENDING;
21
20
  }
22
21
  /**
23
22
  * @param timesheets - Array of TimesheetModel instances
@@ -67,10 +67,6 @@ export declare class DateCodeModel {
67
67
  currFY: string;
68
68
  };
69
69
  static getCurrentTimestampCode(): string;
70
- static getTodayISTEpochRange(): {
71
- epochStartTime: number;
72
- epochEndTime: number;
73
- };
74
70
  /**
75
71
  * Creates a DateCodeModel instance directly from a JavaScript Date object.
76
72
  * Internally formats the date to "yyyyMMdd" and constructs the model.
@@ -331,19 +331,6 @@ class DateCodeModel {
331
331
  const minutes = String(nowIST.getUTCMinutes()).padStart(2, "0");
332
332
  return `${year}${month}${day} ${hours}${minutes}`;
333
333
  }
334
- static getTodayISTEpochRange() {
335
- const istOffsetMs = 5.5 * 60 * 60 * 1000;
336
- const nowUTC = new Date();
337
- const nowIST = new Date(nowUTC.getTime() + istOffsetMs);
338
- const year = nowIST.getUTCFullYear();
339
- const month = nowIST.getUTCMonth();
340
- const date = nowIST.getUTCDate();
341
- const startOfTodayUTC = new Date(Date.UTC(year, month, date, 0, 0, 0, 0));
342
- const epochStartTime = Math.floor((startOfTodayUTC.getTime() - istOffsetMs) / 1000);
343
- const endOfTodayUTC = new Date(Date.UTC(year, month, date, 23, 59, 59, 999));
344
- const epochEndTime = Math.floor((endOfTodayUTC.getTime() - istOffsetMs) / 1000);
345
- return { epochStartTime, epochEndTime };
346
- }
347
334
  /**
348
335
  * Creates a DateCodeModel instance directly from a JavaScript Date object.
349
336
  * Internally formats the date to "yyyyMMdd" and constructs the model.
package/package.json CHANGED
@@ -1,47 +1,47 @@
1
- {
2
- "name": "law-common",
3
- "version": "11.3.3-beta.5",
4
- "description": "",
5
- "main": "dist/index.js",
6
- "files": [
7
- "dist/**/*"
8
- ],
9
- "scripts": {
10
- "clean": "rm -rf dist",
11
- "build": "npm run clean && tsc",
12
- "publish:beta": "npm run build && npm version prerelease --preid beta && git push && npm publish --tag beta",
13
- "publish:beta:link": "npm run build && npm version prerelease --preid beta && git push && npm publish --tag beta && npm run link",
14
- "publish:patch": "npm version patch && git push && npm run build && npm publish",
15
- "publish:minor": "npm version minor && git push && npm run build && npm publish",
16
- "publish:major": "npm verYsion major && git push && npm run build && npm publish",
17
- "link": "npm run build && npm link",
18
- "test": "jest",
19
- "format": "prettier --write .",
20
- "check-format": "prettier --check .",
21
- "pull:link": "git pull && npm run link",
22
- "check-version": "npm view law-common versions --json | jq -r '.[-1]'",
23
- "script:publish": "node scripts/publish.js",
24
- "script:publish:latest:beta": "npm run build && node scripts/publish.js prerelease beta && git push",
25
- "script:publish:latest:patch": "npm run build && node scripts/publish.js patch && git push"
26
- },
27
- "keywords": [],
28
- "author": "",
29
- "license": "ISC",
30
- "devDependencies": {
31
- "@types/jest": "^29.5.13",
32
- "@types/lodash": "^4.17.21",
33
- "@types/node": "^22.6.1",
34
- "jest": "^29.7.0",
35
- "prettier": "3.8.1",
36
- "semver": "^7.8.1",
37
- "ts-jest": "^29.2.5",
38
- "ts-node": "^10.9.2",
39
- "typescript": "^5.6.2"
40
- },
41
- "dependencies": {
42
- "@types/express": "^5.0.0",
43
- "@types/multer": "^1.4.12",
44
- "date-fns": "^4.1.0",
45
- "lodash": "4.17.21"
46
- }
47
- }
1
+ {
2
+ "name": "law-common",
3
+ "version": "11.3.5",
4
+ "description": "",
5
+ "main": "dist/index.js",
6
+ "files": [
7
+ "dist/**/*"
8
+ ],
9
+ "scripts": {
10
+ "clean": "rm -rf dist",
11
+ "build": "npm run clean && tsc",
12
+ "publish:beta": "npm run build && npm version prerelease --preid beta && git push && npm publish --tag beta",
13
+ "publish:beta:link": "npm run build && npm version prerelease --preid beta && git push && npm publish --tag beta && npm run link",
14
+ "publish:patch": "npm version patch && git push && npm run build && npm publish",
15
+ "publish:minor": "npm version minor && git push && npm run build && npm publish",
16
+ "publish:major": "npm verYsion major && git push && npm run build && npm publish",
17
+ "link": "npm run build && npm link",
18
+ "test": "jest",
19
+ "format": "prettier --write .",
20
+ "check-format": "prettier --check .",
21
+ "pull:link": "git pull && npm run link",
22
+ "check-version": "npm view law-common versions --json | jq -r '.[-1]'",
23
+ "script:publish": "node scripts/publish.js",
24
+ "script:publish:latest:beta": "npm run build && node scripts/publish.js prerelease beta && git push",
25
+ "script:publish:latest:patch": "npm run build && node scripts/publish.js patch && git push"
26
+ },
27
+ "keywords": [],
28
+ "author": "",
29
+ "license": "ISC",
30
+ "devDependencies": {
31
+ "@types/jest": "^29.5.13",
32
+ "@types/lodash": "^4.17.21",
33
+ "@types/node": "^22.6.1",
34
+ "jest": "^29.7.0",
35
+ "prettier": "3.8.1",
36
+ "semver": "^7.8.1",
37
+ "ts-jest": "^29.2.5",
38
+ "ts-node": "^10.9.2",
39
+ "typescript": "^5.6.2"
40
+ },
41
+ "dependencies": {
42
+ "@types/express": "^5.0.0",
43
+ "@types/multer": "^1.4.12",
44
+ "date-fns": "^4.1.0",
45
+ "lodash": "4.17.21"
46
+ }
47
+ }
@@ -1,10 +0,0 @@
1
- export declare enum TimesheetClassificationStatusEnum {
2
- PENDING = "pending",
3
- CLASSIFIED = "classified",
4
- AUTO_CLASSIFIED = "auto_classified",
5
- CORRECTED = "corrected"
6
- }
7
- export declare namespace TimesheetClassificationStatusEnum {
8
- function getNames(): string[];
9
- function parse(value: string): TimesheetClassificationStatusEnum;
10
- }
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TimesheetClassificationStatusEnum = void 0;
4
- const error_key_enum_1 = require("../../enums/error.key.enum");
5
- const exceptions_1 = require("../../exceptions");
6
- var TimesheetClassificationStatusEnum;
7
- (function (TimesheetClassificationStatusEnum) {
8
- TimesheetClassificationStatusEnum["PENDING"] = "pending";
9
- TimesheetClassificationStatusEnum["CLASSIFIED"] = "classified";
10
- TimesheetClassificationStatusEnum["AUTO_CLASSIFIED"] = "auto_classified";
11
- TimesheetClassificationStatusEnum["CORRECTED"] = "corrected";
12
- })(TimesheetClassificationStatusEnum || (exports.TimesheetClassificationStatusEnum = TimesheetClassificationStatusEnum = {}));
13
- (function (TimesheetClassificationStatusEnum) {
14
- function getNames() {
15
- return Object.values(TimesheetClassificationStatusEnum).filter((value) => typeof value === "string");
16
- }
17
- TimesheetClassificationStatusEnum.getNames = getNames;
18
- function parse(value) {
19
- if (Object.values(TimesheetClassificationStatusEnum).includes(value)) {
20
- return value;
21
- }
22
- throw new exceptions_1.AppBadRequestException({
23
- key: error_key_enum_1.ErrorKeyEnum.TIMESHEET_STATUS,
24
- message: ["Invalid timesheet classification status"],
25
- });
26
- }
27
- TimesheetClassificationStatusEnum.parse = parse;
28
- })(TimesheetClassificationStatusEnum || (exports.TimesheetClassificationStatusEnum = TimesheetClassificationStatusEnum = {}));