law-common 10.74.0 → 10.75.0

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/README.md CHANGED
@@ -1 +1 @@
1
- # law-common
1
+ # law-common
@@ -1,8 +1,14 @@
1
1
  import { CronJobNames } from "./cron-jobs-name.enum";
2
2
  export declare enum ConfigurationKeyEnum {
3
- PENDING_APPROVAL_TIMESHEET_REMINDER = "pendingApprovalTimesheetReminder"
3
+ PENDING_APPROVAL_TIMESHEET_REMINDER = "pendingApprovalTimesheetReminder",
4
+ TIMESHEET_VIEW_RANGE = "timesheetViewRange",
5
+ TIMESHEET_VIEW_THRESHOLD = "timesheetViewThreshold",
6
+ TIMESHEET_THRESHOLD = "timesheetThreshold",
7
+ TIMESHEET_ENTER_THRESHOLD = "timesheetEnterThreshold",
8
+ ORGANIZATION_BILLING_OVERDUE_THRESHOLD = "organization_billing_overdue_threshold",
9
+ PROJECT_ENTITY_USAGE_NOTIFICATION_SENT_PERCENTAGE_RESET = "projectEntityUsageNotificationSentPercentageReset"
4
10
  }
5
11
  export declare namespace ConfigurationKeyEnum {
6
12
  function IsCronJobConfigurationKey(key: ConfigurationKeyEnum): boolean;
7
- function getCronJobName(configurationKey: ConfigurationKeyEnum): CronJobNames;
13
+ function getCronJobName(configurationKey: ConfigurationKeyEnum): CronJobNames | undefined;
8
14
  }
@@ -5,6 +5,12 @@ const cron_jobs_name_enum_1 = require("./cron-jobs-name.enum");
5
5
  var ConfigurationKeyEnum;
6
6
  (function (ConfigurationKeyEnum) {
7
7
  ConfigurationKeyEnum["PENDING_APPROVAL_TIMESHEET_REMINDER"] = "pendingApprovalTimesheetReminder";
8
+ ConfigurationKeyEnum["TIMESHEET_VIEW_RANGE"] = "timesheetViewRange";
9
+ ConfigurationKeyEnum["TIMESHEET_VIEW_THRESHOLD"] = "timesheetViewThreshold";
10
+ ConfigurationKeyEnum["TIMESHEET_THRESHOLD"] = "timesheetThreshold";
11
+ ConfigurationKeyEnum["TIMESHEET_ENTER_THRESHOLD"] = "timesheetEnterThreshold";
12
+ ConfigurationKeyEnum["ORGANIZATION_BILLING_OVERDUE_THRESHOLD"] = "organization_billing_overdue_threshold";
13
+ ConfigurationKeyEnum["PROJECT_ENTITY_USAGE_NOTIFICATION_SENT_PERCENTAGE_RESET"] = "projectEntityUsageNotificationSentPercentageReset";
8
14
  })(ConfigurationKeyEnum || (exports.ConfigurationKeyEnum = ConfigurationKeyEnum = {}));
9
15
  (function (ConfigurationKeyEnum) {
10
16
  function IsCronJobConfigurationKey(key) {
@@ -16,6 +22,7 @@ var ConfigurationKeyEnum;
16
22
  function getCronJobName(configurationKey) {
17
23
  const cronJobConfigurationKeyMapping = {
18
24
  [ConfigurationKeyEnum.PENDING_APPROVAL_TIMESHEET_REMINDER]: cron_jobs_name_enum_1.CronJobNames.PENDING_APPROVAL_TIMESHEET_REMINDER,
25
+ [ConfigurationKeyEnum.PROJECT_ENTITY_USAGE_NOTIFICATION_SENT_PERCENTAGE_RESET]: cron_jobs_name_enum_1.CronJobNames.PROJECT_ENTITY_USAGE_NOTIFICATION_SENT_PERCENTAGE_RESET,
19
26
  };
20
27
  return cronJobConfigurationKeyMapping[configurationKey];
21
28
  }
@@ -1,3 +1,4 @@
1
1
  export declare enum CronJobNames {
2
- PENDING_APPROVAL_TIMESHEET_REMINDER = "pending_approval_timesheet_reminder"
2
+ PENDING_APPROVAL_TIMESHEET_REMINDER = "pending_approval_timesheet_reminder",
3
+ PROJECT_ENTITY_USAGE_NOTIFICATION_SENT_PERCENTAGE_RESET = "project_entity_usage_notification_sent_percentage_reset"
3
4
  }
@@ -4,4 +4,5 @@ exports.CronJobNames = void 0;
4
4
  var CronJobNames;
5
5
  (function (CronJobNames) {
6
6
  CronJobNames["PENDING_APPROVAL_TIMESHEET_REMINDER"] = "pending_approval_timesheet_reminder";
7
+ CronJobNames["PROJECT_ENTITY_USAGE_NOTIFICATION_SENT_PERCENTAGE_RESET"] = "project_entity_usage_notification_sent_percentage_reset";
7
8
  })(CronJobNames || (exports.CronJobNames = CronJobNames = {}));
@@ -1,9 +1,10 @@
1
+ import { ConfigurationKeyEnum } from "../enums/configuration-key.enum";
1
2
  import { ConfigurationTypeEnum } from "../enums/configuration.type.enum";
2
3
  import { IEntityAuditColumn } from "./entity-audit-columns.interface";
3
4
  import { IEntityCreateDto, IEntityFilterData, IEntityUpdateDto } from "./entity.utils.interface";
4
5
  export interface IConfigurationEntity extends IEntityAuditColumn {
5
6
  id: number;
6
- key: string;
7
+ key: ConfigurationKeyEnum;
7
8
  value: string;
8
9
  organizationId: number;
9
10
  label: string;
@@ -41,4 +41,6 @@ export declare class ProjectEntityModel extends BaseEntityModel<EntityEnum.PROJE
41
41
  isForeignCurrencyProjoect(): boolean;
42
42
  get parsedBillingRate(): any;
43
43
  isHourlyProject(): boolean;
44
+ isFixedProject(): boolean;
45
+ isAdhocProject(): boolean;
44
46
  }
@@ -99,6 +99,12 @@ class ProjectEntityModel extends base_entity_model_1.BaseEntityModel {
99
99
  isHourlyProject() {
100
100
  return this.billingType === project_entity_enum_1.ProjectBillingTypeEnum.HOURLY;
101
101
  }
102
+ isFixedProject() {
103
+ return this.billingType === project_entity_enum_1.ProjectBillingTypeEnum.FIXED;
104
+ }
105
+ isAdhocProject() {
106
+ return this.billingType === project_entity_enum_1.ProjectBillingTypeEnum.ADHOC;
107
+ }
102
108
  }
103
109
  exports.ProjectEntityModel = ProjectEntityModel;
104
110
  ProjectEntityModel.relationConfigs = [
package/dist/src/index.js CHANGED
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
26
36
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
27
37
  };
@@ -149,12 +149,12 @@ export declare function getEnumNames(enumType: object): string[];
149
149
  export declare function getFilterByPermission<T extends EnumEntityType<EntityEnum>>(permissionFilterConfig: {
150
150
  [key: string]: IEntityFilterData<T>;
151
151
  }, propertyName: keyof T, userPermission: string, filterDto: IEntityFilterData<T>, emptyValue?: any): {
152
- [x: string]: any;
152
+ [propertyName]: any;
153
153
  };
154
154
  export declare function getFilterByPermissionFn<T extends EnumEntityType<EntityEnum>>(permissionFilterConfig: {
155
155
  [key: string]: () => Promise<IEntityFilterData<T>>;
156
156
  }, propertyName: keyof T, userPermission: string, filterDto: IEntityFilterData<T>, emptyValue?: any): Promise<{
157
- [x: string]: any;
157
+ [propertyName]: any;
158
158
  }>;
159
159
  export declare function getPropertyFilterByPermissionFn<T extends EnumEntityType<EntityEnum>>(permissionFilterConfig: {
160
160
  [key: string]: () => Promise<IEntityFilterData<T>>;
@@ -25,6 +25,10 @@ export declare class DateCodeModel {
25
25
  };
26
26
  getRange(dateCodeModel: DateCodeModel): DateCodeModel[];
27
27
  static diffInDays(startModel: DateCodeModel, endModel: DateCodeModel, excludeDays?: Weekday[], excludeDateCodes?: DateCodeModel[]): number;
28
+ getMonthStartDateCodeEndDateCodeIST(): {
29
+ startDate: DateCodeModel;
30
+ endDate: DateCodeModel;
31
+ };
28
32
  static getByPredicates(models: DateCodeModel[], includePredicates: ((dateModel: DateCodeModel) => boolean)[], excludePredicates: ((dateModel: DateCodeModel) => boolean)[]): DateCodeModel[];
29
33
  static getWeekdaysPredicate(weekdays: Weekday[]): (dateModel: DateCodeModel) => boolean;
30
34
  static getDateCodesPredicate(dateCodes: DateCodeModel[]): (dateModel: DateCodeModel) => boolean;
@@ -103,6 +103,19 @@ class DateCodeModel {
103
103
  const excludeDatePredicates = (dateModel) => !excludeDateCodes.some((d) => d.isSame(dateModel));
104
104
  return dateRange.filter((dateModel) => excludeDayPredicates(dateModel) && excludeDatePredicates(dateModel)).length;
105
105
  }
106
+ getMonthStartDateCodeEndDateCodeIST() {
107
+ const date = this.getDate();
108
+ // Convert to IST
109
+ const istDate = new Date(date.toLocaleString("en-US", { timeZone: "Asia/Kolkata" }));
110
+ const year = istDate.getFullYear();
111
+ const month = istDate.getMonth();
112
+ const startDate = new Date(year, month, 1);
113
+ const endDate = new Date(year, month + 1, 0);
114
+ return {
115
+ startDate: new DateCodeModel(DateCodeModel.fromDate(startDate)),
116
+ endDate: new DateCodeModel(DateCodeModel.fromDate(endDate)),
117
+ };
118
+ }
106
119
  static getByPredicates(models, includePredicates, excludePredicates) {
107
120
  return models.filter((model) => includePredicates.every((predicate) => predicate(model)) && excludePredicates.every((predicate) => !predicate(model)));
108
121
  }
package/package.json CHANGED
@@ -1,41 +1,41 @@
1
- {
2
- "name": "law-common",
3
- "version": "10.74.0",
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 version prerelease --preid beta && git push && npm run build && npm publish --tag beta && npm run link",
13
- "publish:patch": "npm version patch && git push && npm run build && npm publish",
14
- "publish:minor": "npm version minor && git push && npm run build && npm publish",
15
- "publish:major": "npm version major && git push && npm run build && npm publish",
16
- "link": "npm run build && npm link",
17
- "test": "jest",
18
- "format": "prettier --write .",
19
- "check-format": "prettier --check .",
20
- "pull:link": "git pull && npm run link"
21
- },
22
- "keywords": [],
23
- "author": "",
24
- "license": "ISC",
25
- "devDependencies": {
26
- "@types/jest": "^29.5.13",
27
- "@types/lodash": "^4.17.21",
28
- "@types/node": "^22.6.1",
29
- "jest": "^29.7.0",
30
- "prettier": "3.8.1",
31
- "ts-jest": "^29.2.5",
32
- "ts-node": "^10.9.2",
33
- "typescript": "^5.6.2"
34
- },
35
- "dependencies": {
36
- "@types/express": "^5.0.0",
37
- "@types/multer": "^1.4.12",
38
- "date-fns": "^4.1.0",
39
- "lodash": "4.17.21"
40
- }
41
- }
1
+ {
2
+ "name": "law-common",
3
+ "version": "10.75.0",
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 version prerelease --preid beta && git push && npm run build && npm publish --tag beta && npm run link",
13
+ "publish:patch": "npm version patch && git push && npm run build && npm publish",
14
+ "publish:minor": "npm version minor && git push && npm run build && npm publish",
15
+ "publish:major": "npm version major && git push && npm run build && npm publish",
16
+ "link": "npm run build && npm link",
17
+ "test": "jest",
18
+ "format": "prettier --write .",
19
+ "check-format": "prettier --check .",
20
+ "pull:link": "git pull && npm run link"
21
+ },
22
+ "keywords": [],
23
+ "author": "",
24
+ "license": "ISC",
25
+ "devDependencies": {
26
+ "@types/jest": "^29.5.13",
27
+ "@types/lodash": "^4.17.21",
28
+ "@types/node": "^22.6.1",
29
+ "jest": "^29.7.0",
30
+ "prettier": "3.8.1",
31
+ "ts-jest": "^29.2.5",
32
+ "ts-node": "^10.9.2",
33
+ "typescript": "^5.6.2"
34
+ },
35
+ "dependencies": {
36
+ "@types/express": "^5.0.0",
37
+ "@types/multer": "^1.4.12",
38
+ "date-fns": "^4.1.0",
39
+ "lodash": "4.17.21"
40
+ }
41
+ }