law-common 11.3.5 → 11.3.6-beta.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/dist/src/entities/enums/configuration-key.enum.d.ts +3 -1
- package/dist/src/entities/enums/configuration-key.enum.js +4 -0
- package/dist/src/entities/enums/cron-jobs-name.enum.d.ts +3 -1
- package/dist/src/entities/enums/cron-jobs-name.enum.js +2 -0
- package/dist/src/entities/enums/timesheet.action.enum.d.ts +3 -1
- package/dist/src/entities/enums/timesheet.action.enum.js +4 -0
- package/dist/src/entities/enums/timesheet.classification.status.enum.d.ts +10 -0
- package/dist/src/entities/enums/timesheet.classification.status.enum.js +28 -0
- package/dist/src/entities/index.d.ts +1 -0
- package/dist/src/entities/index.js +1 -0
- package/dist/src/entities/interface/timesheet.entity.interface.d.ts +7 -1
- package/dist/src/entities/model/project.entity.model.d.ts +16 -2
- package/dist/src/entities/model/project.entity.model.js +40 -0
- package/dist/src/entities/model/timesheet.entity.model.d.ts +24 -1
- package/dist/src/entities/model/timesheet.entity.model.js +67 -7
- package/dist/src/entities/model/user.entity.model.d.ts +2 -1
- package/dist/src/entities/model/user.entity.model.js +3 -0
- package/dist/src/model/entities/timesheet.model.d.ts +5 -1
- package/dist/src/model/entities/timesheet.model.js +1 -0
- package/dist/src/utils/models/date-code.model.util.d.ts +4 -0
- package/dist/src/utils/models/date-code.model.util.js +13 -0
- package/package.json +47 -47
|
@@ -7,7 +7,9 @@ export declare enum ConfigurationKeyEnum {
|
|
|
7
7
|
TIMESHEET_ENTER_THRESHOLD = "timesheetEnterThreshold",
|
|
8
8
|
ORGANIZATION_BILLING_OVERDUE_THRESHOLD = "organization_billing_overdue_threshold",
|
|
9
9
|
PROJECT_ENTITY_USAGE_NOTIFICATION_SENT_PERCENTAGE_RESET = "projectEntityUsageNotificationSentPercentageReset",
|
|
10
|
-
LEAVE_ESCALATION = "leaveEscalation"
|
|
10
|
+
LEAVE_ESCALATION = "leaveEscalation",
|
|
11
|
+
TIMESHEET_AUTO_CLASSIFICATION = "timesheetAutoClassification",
|
|
12
|
+
TIMESHEET_CLASSIFICATION_NOTIFICATION = "timesheetClassificationNotification"
|
|
11
13
|
}
|
|
12
14
|
export declare namespace ConfigurationKeyEnum {
|
|
13
15
|
function getNames(): string[];
|
|
@@ -14,6 +14,8 @@ var ConfigurationKeyEnum;
|
|
|
14
14
|
ConfigurationKeyEnum["ORGANIZATION_BILLING_OVERDUE_THRESHOLD"] = "organization_billing_overdue_threshold";
|
|
15
15
|
ConfigurationKeyEnum["PROJECT_ENTITY_USAGE_NOTIFICATION_SENT_PERCENTAGE_RESET"] = "projectEntityUsageNotificationSentPercentageReset";
|
|
16
16
|
ConfigurationKeyEnum["LEAVE_ESCALATION"] = "leaveEscalation";
|
|
17
|
+
ConfigurationKeyEnum["TIMESHEET_AUTO_CLASSIFICATION"] = "timesheetAutoClassification";
|
|
18
|
+
ConfigurationKeyEnum["TIMESHEET_CLASSIFICATION_NOTIFICATION"] = "timesheetClassificationNotification";
|
|
17
19
|
})(ConfigurationKeyEnum || (exports.ConfigurationKeyEnum = ConfigurationKeyEnum = {}));
|
|
18
20
|
(function (ConfigurationKeyEnum) {
|
|
19
21
|
function getNames() {
|
|
@@ -41,6 +43,8 @@ var ConfigurationKeyEnum;
|
|
|
41
43
|
[ConfigurationKeyEnum.PENDING_APPROVAL_TIMESHEET_REMINDER]: cron_jobs_name_enum_1.CronJobNames.PENDING_APPROVAL_TIMESHEET_REMINDER,
|
|
42
44
|
[ConfigurationKeyEnum.PROJECT_ENTITY_USAGE_NOTIFICATION_SENT_PERCENTAGE_RESET]: cron_jobs_name_enum_1.CronJobNames.PROJECT_ENTITY_USAGE_NOTIFICATION_SENT_PERCENTAGE_RESET,
|
|
43
45
|
[ConfigurationKeyEnum.LEAVE_ESCALATION]: cron_jobs_name_enum_1.CronJobNames.LEAVE_ESCALATION,
|
|
46
|
+
[ConfigurationKeyEnum.TIMESHEET_AUTO_CLASSIFICATION]: cron_jobs_name_enum_1.CronJobNames.TIMESHEET_AUTO_CLASSIFICATION,
|
|
47
|
+
[ConfigurationKeyEnum.TIMESHEET_CLASSIFICATION_NOTIFICATION]: cron_jobs_name_enum_1.CronJobNames.TIMESHEET_CLASSIFICATION_NOTIFICATION,
|
|
44
48
|
};
|
|
45
49
|
return cronJobConfigurationKeyMapping[configurationKey];
|
|
46
50
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export declare enum CronJobNames {
|
|
2
2
|
PENDING_APPROVAL_TIMESHEET_REMINDER = "pending_approval_timesheet_reminder",
|
|
3
3
|
PROJECT_ENTITY_USAGE_NOTIFICATION_SENT_PERCENTAGE_RESET = "project_entity_usage_notification_sent_percentage_reset",
|
|
4
|
-
LEAVE_ESCALATION = "leave_escalation"
|
|
4
|
+
LEAVE_ESCALATION = "leave_escalation",
|
|
5
|
+
TIMESHEET_AUTO_CLASSIFICATION = "timesheet_auto_classification",
|
|
6
|
+
TIMESHEET_CLASSIFICATION_NOTIFICATION = "timesheet_classification_notification"
|
|
5
7
|
}
|
|
@@ -6,4 +6,6 @@ var CronJobNames;
|
|
|
6
6
|
CronJobNames["PENDING_APPROVAL_TIMESHEET_REMINDER"] = "pending_approval_timesheet_reminder";
|
|
7
7
|
CronJobNames["PROJECT_ENTITY_USAGE_NOTIFICATION_SENT_PERCENTAGE_RESET"] = "project_entity_usage_notification_sent_percentage_reset";
|
|
8
8
|
CronJobNames["LEAVE_ESCALATION"] = "leave_escalation";
|
|
9
|
+
CronJobNames["TIMESHEET_AUTO_CLASSIFICATION"] = "timesheet_auto_classification";
|
|
10
|
+
CronJobNames["TIMESHEET_CLASSIFICATION_NOTIFICATION"] = "timesheet_classification_notification";
|
|
9
11
|
})(CronJobNames || (exports.CronJobNames = CronJobNames = {}));
|
|
@@ -7,7 +7,9 @@ export declare enum TimesheetActionEnum {
|
|
|
7
7
|
REJECT = "reject",
|
|
8
8
|
RECALL = "recall",
|
|
9
9
|
BILLING_UPDATE = "billing_update",
|
|
10
|
-
MOVE_TIMESHEET = "move_timesheet"
|
|
10
|
+
MOVE_TIMESHEET = "move_timesheet",
|
|
11
|
+
CLASSIFY = "classify",
|
|
12
|
+
AUTO_CLASSIFY = "auto_classify"
|
|
11
13
|
}
|
|
12
14
|
export declare namespace TimesheetActionEnum {
|
|
13
15
|
function getLabel(action: TimesheetActionEnum): string;
|
|
@@ -14,6 +14,8 @@ 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
|
+
TimesheetActionEnum["AUTO_CLASSIFY"] = "auto_classify";
|
|
17
19
|
})(TimesheetActionEnum || (exports.TimesheetActionEnum = TimesheetActionEnum = {}));
|
|
18
20
|
(function (TimesheetActionEnum) {
|
|
19
21
|
const actionLabelMap = {
|
|
@@ -26,6 +28,8 @@ var TimesheetActionEnum;
|
|
|
26
28
|
[TimesheetActionEnum.RECALL]: "Recall",
|
|
27
29
|
[TimesheetActionEnum.BILLING_UPDATE]: "Billing Update",
|
|
28
30
|
[TimesheetActionEnum.MOVE_TIMESHEET]: "Move Timesheet",
|
|
31
|
+
[TimesheetActionEnum.CLASSIFY]: "Classify",
|
|
32
|
+
[TimesheetActionEnum.AUTO_CLASSIFY]: "Auto Classify",
|
|
29
33
|
};
|
|
30
34
|
function getLabel(action) {
|
|
31
35
|
if (!Object.values(TimesheetActionEnum).includes(action)) {
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
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 = {}));
|
|
@@ -39,6 +39,7 @@ 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";
|
|
42
43
|
export * from "./enums/billing.action.enum";
|
|
43
44
|
export * from "./enums/configuration.type.enum";
|
|
44
45
|
export * from "./enums/project_user_status.enum";
|
|
@@ -55,6 +55,7 @@ __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);
|
|
58
59
|
__exportStar(require("./enums/billing.action.enum"), exports);
|
|
59
60
|
__exportStar(require("./enums/configuration.type.enum"), exports);
|
|
60
61
|
__exportStar(require("./enums/project_user_status.enum"), exports);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { TimesheetActionEnum } from "../enums/timesheet.action.enum";
|
|
2
|
+
import { TimesheetClassificationStatusEnum } from "../enums/timesheet.classification.status.enum";
|
|
2
3
|
import { TimesheetStatusEnum } from "../enums/timesheet.status.enum";
|
|
3
4
|
import { ProjectUserMappingEntityModel } from "../model/project-user-mapping.entity.model";
|
|
4
5
|
import { TimesheetEntityModel } from "../model/timesheet.entity.model";
|
|
@@ -16,10 +17,15 @@ export interface ITimesheetEntity extends IEntityAuditColumn {
|
|
|
16
17
|
status: TimesheetStatusEnum;
|
|
17
18
|
remark?: string;
|
|
18
19
|
billingId?: number;
|
|
20
|
+
billedDuration?: number;
|
|
21
|
+
notBilledDuration?: number;
|
|
22
|
+
classificationStatus: TimesheetClassificationStatusEnum;
|
|
23
|
+
classifiedBy?: number;
|
|
19
24
|
}
|
|
20
|
-
export type ITimesheetEntityExclude = "status";
|
|
25
|
+
export type ITimesheetEntityExclude = "status" | "billedDuration" | "notBilledDuration" | "classificationStatus" | "classifiedBy";
|
|
21
26
|
export interface ITimesheetEntityCreateDto extends Omit<IEntityCreateDto<ITimesheetEntity>, ITimesheetEntityExclude> {
|
|
22
27
|
status?: TimesheetStatusEnum;
|
|
28
|
+
classificationStatus?: TimesheetClassificationStatusEnum;
|
|
23
29
|
}
|
|
24
30
|
export interface ITimesheetEntityCreateDtoValidationData {
|
|
25
31
|
projectUserMappingEntities: ProjectUserMappingEntityModel[];
|
|
@@ -7,6 +7,7 @@ import { RelationConfigs } from "../interface/relation-config.interface";
|
|
|
7
7
|
import { BaseEntityModel } from "./base.entity.model";
|
|
8
8
|
import { ClientEntityModel } from "./client.entity.model";
|
|
9
9
|
import { ProjectUserMappingEntityModel } from "./project-user-mapping.entity.model";
|
|
10
|
+
import { TimesheetEntityModel } from "./timesheet.entity.model";
|
|
10
11
|
import { UserEntityModel } from "./user.entity.model";
|
|
11
12
|
export declare class ProjectEntityModel extends BaseEntityModel<EntityEnum.PROJECT> implements IProjectEntity {
|
|
12
13
|
id: number;
|
|
@@ -34,10 +35,11 @@ export declare class ProjectEntityModel extends BaseEntityModel<EntityEnum.PROJE
|
|
|
34
35
|
userMappings?: (UserEntityModel & ProjectUserMappingEntityModel)[];
|
|
35
36
|
projectUserMappings?: ProjectUserMappingEntityModel[];
|
|
36
37
|
client: ClientEntityModel;
|
|
38
|
+
timesheets: TimesheetEntityModel[];
|
|
37
39
|
static fromEntity(entity: IProjectEntity): ProjectEntityModel;
|
|
38
|
-
static relationConfigs: RelationConfigs<[EntityEnum.PROJECT_USER_MAPPING, EntityEnum.CLIENT], EntityEnum.PROJECT>;
|
|
40
|
+
static relationConfigs: RelationConfigs<[EntityEnum.PROJECT_USER_MAPPING, EntityEnum.CLIENT, EntityEnum.TIMESHEET], EntityEnum.PROJECT>;
|
|
39
41
|
populateUsers(users: UserEntityModel[], projectUserMapping: ProjectUserMappingEntityModel[]): void;
|
|
40
|
-
getRelationConfigs(): [import("../interface/relation-config.interface").IRelationConfig<EntityEnum.PROJECT_USER_MAPPING, EntityEnum.PROJECT>, import("../interface/relation-config.interface").IRelationConfig<EntityEnum.CLIENT, EntityEnum.PROJECT>];
|
|
42
|
+
getRelationConfigs(): [import("../interface/relation-config.interface").IRelationConfig<EntityEnum.PROJECT_USER_MAPPING, EntityEnum.PROJECT>, import("../interface/relation-config.interface").IRelationConfig<EntityEnum.CLIENT, EntityEnum.PROJECT>, import("../interface/relation-config.interface").IRelationConfig<EntityEnum.TIMESHEET, EntityEnum.PROJECT>];
|
|
41
43
|
isForeignCurrencyProject(): boolean;
|
|
42
44
|
get parsedBillingRate(): any;
|
|
43
45
|
isHourlyProject(): boolean;
|
|
@@ -45,4 +47,16 @@ export declare class ProjectEntityModel extends BaseEntityModel<EntityEnum.PROJE
|
|
|
45
47
|
isAdhocProject(): boolean;
|
|
46
48
|
get partnersOwnerUsersOfProject(): UserEntityModel[];
|
|
47
49
|
get clientName(): string;
|
|
50
|
+
get timesheetsOfProject(): TimesheetEntityModel[];
|
|
51
|
+
getTimesheetsGroupedByUserId(): Map<number, TimesheetEntityModel[]>;
|
|
52
|
+
getAllPartnersClassificationData(): Map<number, {
|
|
53
|
+
resourceCounts: {
|
|
54
|
+
resourceName: string;
|
|
55
|
+
timesheetCount: number;
|
|
56
|
+
}[];
|
|
57
|
+
resources: {
|
|
58
|
+
resourceName: string;
|
|
59
|
+
timesheets: TimesheetEntityModel[];
|
|
60
|
+
}[];
|
|
61
|
+
}>;
|
|
48
62
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ProjectEntityModel = void 0;
|
|
4
4
|
const enums_1 = require("../../enums");
|
|
5
|
+
const helper_fn_util_1 = require("../../utils/helper.fn.util");
|
|
5
6
|
const project_revenue_split_enum_1 = require("../enums/project-revenue-split.enum");
|
|
6
7
|
const project_entity_enum_1 = require("../enums/project.entity.enum");
|
|
7
8
|
const relation_type_enum_1 = require("../enums/relation-type.enum");
|
|
@@ -29,6 +30,7 @@ class ProjectEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
|
29
30
|
this.clientQuoteId = null;
|
|
30
31
|
this.users = [];
|
|
31
32
|
this.client = {};
|
|
33
|
+
this.timesheets = [];
|
|
32
34
|
}
|
|
33
35
|
static fromEntity(entity) {
|
|
34
36
|
const result = new ProjectEntityModel(entity_utils_interface_1.EntityEnum.PROJECT);
|
|
@@ -112,6 +114,35 @@ class ProjectEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
|
112
114
|
get clientName() {
|
|
113
115
|
return this.client.name;
|
|
114
116
|
}
|
|
117
|
+
get timesheetsOfProject() {
|
|
118
|
+
return this.timesheets;
|
|
119
|
+
}
|
|
120
|
+
getTimesheetsGroupedByUserId() {
|
|
121
|
+
return (0, helper_fn_util_1.groupByFunction)(this.timesheets, (t) => t.userId);
|
|
122
|
+
}
|
|
123
|
+
getAllPartnersClassificationData() {
|
|
124
|
+
var _a, _b, _c;
|
|
125
|
+
const result = new Map();
|
|
126
|
+
const timesheetsGroupedByUserId = this.getTimesheetsGroupedByUserId();
|
|
127
|
+
const partnerMappings = (_b = (_a = this.projectUserMappings) === null || _a === void 0 ? void 0 : _a.filter((m) => m.isMappingOfPartnerOwner())) !== null && _b !== void 0 ? _b : [];
|
|
128
|
+
for (const pm of partnerMappings) {
|
|
129
|
+
result.set(pm.userId, { resourceCounts: [], resources: [] });
|
|
130
|
+
}
|
|
131
|
+
for (const mapping of (_c = this.projectUserMappings) !== null && _c !== void 0 ? _c : []) {
|
|
132
|
+
if (!mapping.user)
|
|
133
|
+
continue;
|
|
134
|
+
const userTimesheets = timesheetsGroupedByUserId.get(mapping.userId);
|
|
135
|
+
if (!(userTimesheets === null || userTimesheets === void 0 ? void 0 : userTimesheets.length))
|
|
136
|
+
continue;
|
|
137
|
+
for (const pm of partnerMappings) {
|
|
138
|
+
const entry = result.get(pm.userId);
|
|
139
|
+
const resourceName = mapping.userId === pm.userId ? "You" : mapping.user.name;
|
|
140
|
+
entry.resourceCounts.push({ resourceName, timesheetCount: userTimesheets.length });
|
|
141
|
+
entry.resources.push({ resourceName, timesheets: userTimesheets });
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return result;
|
|
145
|
+
}
|
|
115
146
|
}
|
|
116
147
|
exports.ProjectEntityModel = ProjectEntityModel;
|
|
117
148
|
ProjectEntityModel.relationConfigs = [
|
|
@@ -133,4 +164,13 @@ ProjectEntityModel.relationConfigs = [
|
|
|
133
164
|
key: "clientId",
|
|
134
165
|
},
|
|
135
166
|
},
|
|
167
|
+
{
|
|
168
|
+
name: entity_utils_interface_1.EntityEnum.TIMESHEET,
|
|
169
|
+
relation: relation_type_enum_1.RelationType.MANY,
|
|
170
|
+
key: "timesheets",
|
|
171
|
+
mapKeyConfig: {
|
|
172
|
+
relationKey: "projectId",
|
|
173
|
+
key: "id",
|
|
174
|
+
},
|
|
175
|
+
},
|
|
136
176
|
];
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { CurrencyEnum } from "../../enums";
|
|
2
|
+
import { TimesheetClassificationStatusEnum } from "../enums/timesheet.classification.status.enum";
|
|
2
3
|
import { TimesheetStatusEnum } from "../enums/timesheet.status.enum";
|
|
3
4
|
import { EntityEnum } from "../interface/entity.utils.interface";
|
|
4
5
|
import { RelationConfigs } from "../interface/relation-config.interface";
|
|
5
6
|
import { ITimesheetEntity } from "../interface/timesheet.entity.interface";
|
|
6
7
|
import { BaseEntityModel } from "./base.entity.model";
|
|
8
|
+
import { ProjectEntityModel } from "./project.entity.model";
|
|
7
9
|
import { TimesheetHistoryEntityModel } from "./timesheet_history.entity.model";
|
|
8
10
|
import { UserEntityModel } from "./user.entity.model";
|
|
9
11
|
export declare class TimesheetEntityModel extends BaseEntityModel<EntityEnum.TIMESHEET> implements ITimesheetEntity {
|
|
@@ -17,17 +19,38 @@ export declare class TimesheetEntityModel extends BaseEntityModel<EntityEnum.TIM
|
|
|
17
19
|
status: TimesheetStatusEnum;
|
|
18
20
|
remark?: string;
|
|
19
21
|
billingId?: number;
|
|
22
|
+
billedDuration?: number;
|
|
23
|
+
notBilledDuration?: number;
|
|
24
|
+
classificationStatus: TimesheetClassificationStatusEnum;
|
|
25
|
+
classifiedBy?: number;
|
|
20
26
|
createdBy: number;
|
|
21
27
|
updatedBy: number;
|
|
22
28
|
createdOn: number;
|
|
23
29
|
updatedOn: number;
|
|
24
30
|
user?: UserEntityModel;
|
|
25
31
|
history?: TimesheetHistoryEntityModel[];
|
|
32
|
+
project?: ProjectEntityModel;
|
|
26
33
|
static fromEntity(entity: ITimesheetEntity): TimesheetEntityModel;
|
|
27
34
|
getRelationConfigs(): any[];
|
|
28
|
-
static relationConfigs: RelationConfigs<[EntityEnum.USER, EntityEnum.TIMESHEET_HISTORY], EntityEnum.TIMESHEET>;
|
|
35
|
+
static relationConfigs: RelationConfigs<[EntityEnum.USER, EntityEnum.TIMESHEET_HISTORY, EntityEnum.PROJECT], EntityEnum.TIMESHEET>;
|
|
29
36
|
getTimesheetAmount(projectCurrency: CurrencyEnum): number;
|
|
30
37
|
get formattedDate(): string;
|
|
31
38
|
get userName(): string | undefined;
|
|
32
39
|
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
|
+
static getTimesheetAutoClassificationDateCodeRange(): {
|
|
53
|
+
windowStart: string;
|
|
54
|
+
windowEnd: string;
|
|
55
|
+
} | null;
|
|
33
56
|
}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TimesheetEntityModel = void 0;
|
|
4
|
+
const date_fns_1 = require("date-fns");
|
|
4
5
|
const utils_1 = require("../../utils");
|
|
5
6
|
const relation_type_enum_1 = require("../enums/relation-type.enum");
|
|
7
|
+
const timesheet_classification_status_enum_1 = require("../enums/timesheet.classification.status.enum");
|
|
6
8
|
const timesheet_status_enum_1 = require("../enums/timesheet.status.enum");
|
|
7
9
|
const entity_utils_interface_1 = require("../interface/entity.utils.interface");
|
|
8
10
|
const base_entity_model_1 = require("./base.entity.model");
|
|
11
|
+
// Use this mdoel for UI & BACKEND
|
|
9
12
|
class TimesheetEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
10
13
|
constructor() {
|
|
11
14
|
super(...arguments);
|
|
@@ -16,17 +19,11 @@ class TimesheetEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
|
16
19
|
this.dateCode = "";
|
|
17
20
|
this.totalDuration = 0;
|
|
18
21
|
this.status = timesheet_status_enum_1.TimesheetStatusEnum.CREATE_APPROVAL;
|
|
22
|
+
this.classificationStatus = timesheet_classification_status_enum_1.TimesheetClassificationStatusEnum.PENDING;
|
|
19
23
|
this.createdBy = 0;
|
|
20
24
|
this.updatedBy = 0;
|
|
21
25
|
this.createdOn = 0;
|
|
22
26
|
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
|
-
// }
|
|
30
27
|
}
|
|
31
28
|
static fromEntity(entity) {
|
|
32
29
|
const result = new TimesheetEntityModel(entity_utils_interface_1.EntityEnum.TIMESHEET);
|
|
@@ -53,6 +50,52 @@ class TimesheetEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
|
53
50
|
const sorted = [...(this.history || [])].sort((a, b) => b.id - a.id);
|
|
54
51
|
return (_a = sorted[1]) === null || _a === void 0 ? void 0 : _a.status;
|
|
55
52
|
}
|
|
53
|
+
// get latestStatusFromHistory(): TimesheetStatusEnum | undefined {
|
|
54
|
+
// const allHistoryModelSortedByIdInDesc = [...(this.history || [])].sort((a, b) => b.id - a.id);
|
|
55
|
+
// for (const model of allHistoryModelSortedByIdInDesc) {
|
|
56
|
+
// if (model.hasStatusKeyInData()) return model.status;
|
|
57
|
+
// }
|
|
58
|
+
// return undefined;
|
|
59
|
+
// }
|
|
60
|
+
getDateCodeDay() {
|
|
61
|
+
const normalized = this.dateCode.length === 6 ? `20${this.dateCode}` : this.dateCode;
|
|
62
|
+
return parseInt(normalized.substring(6, 8), 10);
|
|
63
|
+
}
|
|
64
|
+
getClassificationDeadline() {
|
|
65
|
+
const normalized = this.dateCode.length === 6 ? `20${this.dateCode}` : this.dateCode;
|
|
66
|
+
const year = parseInt(normalized.substring(0, 4), 10);
|
|
67
|
+
const month = parseInt(normalized.substring(4, 6), 10);
|
|
68
|
+
const day = this.getDateCodeDay();
|
|
69
|
+
const { bufferDays, windows } = TimesheetEntityModel.CLASSIFICATION_WINDOW_CONFIG;
|
|
70
|
+
const window = windows.find((w) => day >= w.startDay && (w.endDay === null || day <= w.endDay));
|
|
71
|
+
if (!window) {
|
|
72
|
+
return new Date(year, month - 1, day + bufferDays);
|
|
73
|
+
}
|
|
74
|
+
if (window.endDay === null) {
|
|
75
|
+
return new Date(year, month, 3);
|
|
76
|
+
}
|
|
77
|
+
return new Date(year, month - 1, window.endDay + bufferDays);
|
|
78
|
+
}
|
|
79
|
+
static getTimesheetAutoClassificationDateCodeRange() {
|
|
80
|
+
var _a;
|
|
81
|
+
const { bufferDays, windows } = TimesheetEntityModel.CLASSIFICATION_WINDOW_CONFIG;
|
|
82
|
+
const today = new Date();
|
|
83
|
+
for (const window of windows) {
|
|
84
|
+
// Last window (endDay === null) belongs to the previous month
|
|
85
|
+
const targetDate = window.endDay === null ? (0, date_fns_1.subMonths)(today, 1) : today;
|
|
86
|
+
const year = targetDate.getFullYear();
|
|
87
|
+
const month = targetDate.getMonth();
|
|
88
|
+
const actualEndDay = (_a = window.endDay) !== null && _a !== void 0 ? _a : (0, date_fns_1.lastDayOfMonth)(targetDate).getDate();
|
|
89
|
+
const triggerDate = (0, date_fns_1.addDays)(new Date(year, month, actualEndDay), bufferDays);
|
|
90
|
+
if (triggerDate.getFullYear() === today.getFullYear() && triggerDate.getMonth() === today.getMonth() && triggerDate.getDate() === today.getDate()) {
|
|
91
|
+
return {
|
|
92
|
+
windowStart: (0, date_fns_1.format)(new Date(year, month, window.startDay), "yyyyMMdd"),
|
|
93
|
+
windowEnd: (0, date_fns_1.format)(new Date(year, month, actualEndDay), "yyyyMMdd"),
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
56
99
|
}
|
|
57
100
|
exports.TimesheetEntityModel = TimesheetEntityModel;
|
|
58
101
|
TimesheetEntityModel.relationConfigs = [
|
|
@@ -74,4 +117,21 @@ TimesheetEntityModel.relationConfigs = [
|
|
|
74
117
|
key: "id",
|
|
75
118
|
},
|
|
76
119
|
},
|
|
120
|
+
{
|
|
121
|
+
name: entity_utils_interface_1.EntityEnum.PROJECT,
|
|
122
|
+
relation: relation_type_enum_1.RelationType.ONE,
|
|
123
|
+
key: "project",
|
|
124
|
+
mapKeyConfig: {
|
|
125
|
+
relationKey: "id",
|
|
126
|
+
key: "projectId",
|
|
127
|
+
},
|
|
128
|
+
},
|
|
77
129
|
];
|
|
130
|
+
TimesheetEntityModel.CLASSIFICATION_WINDOW_CONFIG = {
|
|
131
|
+
bufferDays: 3,
|
|
132
|
+
windows: [
|
|
133
|
+
{ startDay: 1, endDay: 10 },
|
|
134
|
+
{ startDay: 11, endDay: 20 },
|
|
135
|
+
{ startDay: 21, endDay: null },
|
|
136
|
+
],
|
|
137
|
+
};
|
|
@@ -3,9 +3,9 @@ import { EntityEnum, Nullable } from "../interface/entity.utils.interface";
|
|
|
3
3
|
import { RelationConfigs } from "../interface/relation-config.interface";
|
|
4
4
|
import { IUserEntity } from "../interface/user.entity.interface";
|
|
5
5
|
import { BaseEntityModel } from "./base.entity.model";
|
|
6
|
+
import { DesignationEntityModel } from "./designation.entity.model";
|
|
6
7
|
import { ProjectUserMappingEntityModel } from "./project-user-mapping.entity.model";
|
|
7
8
|
import { ProjectEntityModel } from "./project.entity.model";
|
|
8
|
-
import { DesignationEntityModel } from "./designation.entity.model";
|
|
9
9
|
import { RoleEntityModel } from "./role.entity.model";
|
|
10
10
|
export declare class UserEntityModel extends BaseEntityModel<EntityEnum.USER> implements IUserEntity {
|
|
11
11
|
id: number;
|
|
@@ -56,4 +56,5 @@ export declare class UserEntityModel extends BaseEntityModel<EntityEnum.USER> im
|
|
|
56
56
|
get roleEntityModel(): RoleEntityModel;
|
|
57
57
|
hasPermission(permissionName: string): boolean;
|
|
58
58
|
get projects(): ProjectEntityModel[];
|
|
59
|
+
get isOwnerPartnerRoleUser(): boolean;
|
|
59
60
|
}
|
|
@@ -51,6 +51,9 @@ class UserEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
|
51
51
|
get projects() {
|
|
52
52
|
return this.projecUserMappings.map((mapping) => mapping.project).filter((project) => !!project);
|
|
53
53
|
}
|
|
54
|
+
get isOwnerPartnerRoleUser() {
|
|
55
|
+
return [user_entity_enum_1.UserRoleEnum.owner, user_entity_enum_1.UserRoleEnum.partner].includes(this.role);
|
|
56
|
+
}
|
|
54
57
|
}
|
|
55
58
|
exports.UserEntityModel = UserEntityModel;
|
|
56
59
|
UserEntityModel.relationConfigs = [
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ITimesheetEntity, TimesheetStatusEnum } from "../../entities";
|
|
1
|
+
import { ITimesheetEntity, TimesheetClassificationStatusEnum, 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,6 +14,10 @@ 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;
|
|
17
21
|
/**
|
|
18
22
|
* @param timesheets - Array of TimesheetModel instances
|
|
19
23
|
* @return - Array of Timesheet Model
|
|
@@ -17,6 +17,7 @@ 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;
|
|
20
21
|
}
|
|
21
22
|
/**
|
|
22
23
|
* @param timesheets - Array of TimesheetModel instances
|
|
@@ -67,6 +67,10 @@ 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
|
+
};
|
|
70
74
|
/**
|
|
71
75
|
* Creates a DateCodeModel instance directly from a JavaScript Date object.
|
|
72
76
|
* Internally formats the date to "yyyyMMdd" and constructs the model.
|
|
@@ -331,6 +331,19 @@ 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
|
+
}
|
|
334
347
|
/**
|
|
335
348
|
* Creates a DateCodeModel instance directly from a JavaScript Date object.
|
|
336
349
|
* 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.
|
|
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.6-beta.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 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
|
+
}
|