law-common 11.3.20 → 11.3.21-beta.1

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,6 +1,7 @@
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 { IDesignationEntity } from "../interface/designation.entity.interface";
4
5
  import { EntityEnum, Nullable } from "../interface/entity.utils.interface";
5
6
  import { RelationConfigs } from "../interface/relation-config.interface";
6
7
  import { ITimesheetEntity } from "../interface/timesheet.entity.interface";
@@ -15,6 +16,12 @@ export interface IClassificationWindowConfig {
15
16
  endDay: Nullable<number>;
16
17
  }>;
17
18
  }
19
+ export interface SortableTimesheet {
20
+ projectClientName?: string;
21
+ designation?: string;
22
+ resourceName?: string;
23
+ dateCodeForsorting?: Date;
24
+ }
18
25
  export declare class TimesheetEntityModel extends BaseEntityModel<EntityEnum.TIMESHEET> implements ITimesheetEntity {
19
26
  id: number;
20
27
  userId: number;
@@ -59,4 +66,5 @@ export declare class TimesheetEntityModel extends BaseEntityModel<EntityEnum.TIM
59
66
  startDay: number;
60
67
  endDay: Nullable<number>;
61
68
  }>;
69
+ static sortByProjectAndDesignation(data: SortableTimesheet[], designations: IDesignationEntity[]): SortableTimesheet[];
62
70
  }
@@ -149,6 +149,27 @@ class TimesheetEntityModel extends base_entity_model_1.BaseEntityModel {
149
149
  };
150
150
  });
151
151
  }
152
+ static sortByProjectAndDesignation(data, designations) {
153
+ const priorityMap = new Map();
154
+ designations.forEach((d) => {
155
+ var _a;
156
+ priorityMap.set(d.name, (_a = d.order) !== null && _a !== void 0 ? _a : Number.MAX_SAFE_INTEGER);
157
+ });
158
+ return [...data].sort((a, b) => {
159
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
160
+ const projectCompare = ((_a = a.projectClientName) !== null && _a !== void 0 ? _a : "").localeCompare((_b = b.projectClientName) !== null && _b !== void 0 ? _b : "");
161
+ if (projectCompare !== 0)
162
+ return projectCompare;
163
+ const priorityA = (_d = priorityMap.get((_c = a.designation) !== null && _c !== void 0 ? _c : "")) !== null && _d !== void 0 ? _d : Number.MAX_SAFE_INTEGER;
164
+ const priorityB = (_f = priorityMap.get((_e = b.designation) !== null && _e !== void 0 ? _e : "")) !== null && _f !== void 0 ? _f : Number.MAX_SAFE_INTEGER;
165
+ if (priorityA !== priorityB)
166
+ return priorityA - priorityB;
167
+ const resourceCompare = ((_g = a.resourceName) !== null && _g !== void 0 ? _g : "").localeCompare((_h = b.resourceName) !== null && _h !== void 0 ? _h : "");
168
+ if (resourceCompare !== 0)
169
+ return resourceCompare;
170
+ return ((_k = (_j = b.dateCodeForsorting) === null || _j === void 0 ? void 0 : _j.getTime()) !== null && _k !== void 0 ? _k : 0) - ((_m = (_l = a.dateCodeForsorting) === null || _l === void 0 ? void 0 : _l.getTime()) !== null && _m !== void 0 ? _m : 0);
171
+ });
172
+ }
152
173
  }
153
174
  exports.TimesheetEntityModel = TimesheetEntityModel;
154
175
  TimesheetEntityModel.relationConfigs = [
package/package.json CHANGED
@@ -1,50 +1,50 @@
1
- {
2
- "name": "law-common",
3
- "version": "11.3.20",
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
- "link:backend": "npm run build && npm link && cd ../law-backend && npm link law-common && cd ../law-common",
19
- "link:frontend": "npm run build && npm link && cd ../law-admin-web && npm link law-common && cd ../law-common",
20
- "link:both": "npm run build && npm link && cd ../law-backend && npm link law-common && cd ../law-admin-web && npm link law-common && cd ../law-common",
21
- "test": "jest",
22
- "format": "prettier --write .",
23
- "check-format": "prettier --check .",
24
- "pull:link": "git pull && npm run link",
25
- "check-version": "npm view law-common versions --json | jq -r '.[-1]'",
26
- "script:publish": "node scripts/publish.js",
27
- "script:publish:latest:beta": "npm run build && node scripts/publish.js prerelease beta && git push",
28
- "script:publish:latest:patch": "npm run build && node scripts/publish.js patch && git push"
29
- },
30
- "keywords": [],
31
- "author": "",
32
- "license": "ISC",
33
- "devDependencies": {
34
- "@types/jest": "^29.5.13",
35
- "@types/lodash": "^4.17.21",
36
- "@types/node": "^22.6.1",
37
- "jest": "^29.7.0",
38
- "prettier": "3.8.1",
39
- "semver": "^7.8.1",
40
- "ts-jest": "^29.2.5",
41
- "ts-node": "^10.9.2",
42
- "typescript": "^5.6.2"
43
- },
44
- "dependencies": {
45
- "@types/express": "^5.0.0",
46
- "@types/multer": "^1.4.12",
47
- "date-fns": "^4.1.0",
48
- "lodash": "4.17.21"
49
- }
50
- }
1
+ {
2
+ "name": "law-common",
3
+ "version": "11.3.21-beta.1",
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
+ "link:backend": "npm run build && npm link && cd ../law-backend && npm link law-common && cd ../law-common",
19
+ "link:frontend": "npm run build && npm link && cd ../law-admin-web && npm link law-common && cd ../law-common",
20
+ "link:both": "npm run build && npm link && cd ../law-backend && npm link law-common && cd ../law-admin-web && npm link law-common && cd ../law-common",
21
+ "test": "jest",
22
+ "format": "prettier --write .",
23
+ "check-format": "prettier --check .",
24
+ "pull:link": "git pull && npm run link",
25
+ "check-version": "npm view law-common versions --json | jq -r '.[-1]'",
26
+ "script:publish": "node scripts/publish.js",
27
+ "script:publish:latest:beta": "npm run build && node scripts/publish.js prerelease beta && git push",
28
+ "script:publish:latest:patch": "npm run build && node scripts/publish.js patch && git push"
29
+ },
30
+ "keywords": [],
31
+ "author": "",
32
+ "license": "ISC",
33
+ "devDependencies": {
34
+ "@types/jest": "^29.5.13",
35
+ "@types/lodash": "^4.17.21",
36
+ "@types/node": "^22.6.1",
37
+ "jest": "^29.7.0",
38
+ "prettier": "3.8.1",
39
+ "semver": "^7.8.1",
40
+ "ts-jest": "^29.2.5",
41
+ "ts-node": "^10.9.2",
42
+ "typescript": "^5.6.2"
43
+ },
44
+ "dependencies": {
45
+ "@types/express": "^5.0.0",
46
+ "@types/multer": "^1.4.12",
47
+ "date-fns": "^4.1.0",
48
+ "lodash": "4.17.21"
49
+ }
50
+ }