law-common 11.3.3-beta.2 → 11.3.3-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.
|
@@ -5,6 +5,7 @@ import { EntityEnum } 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
|
+
import { ProjectEntityModel } from "./project.entity.model";
|
|
8
9
|
import { TimesheetHistoryEntityModel } from "./timesheet_history.entity.model";
|
|
9
10
|
import { UserEntityModel } from "./user.entity.model";
|
|
10
11
|
export declare class TimesheetEntityModel extends BaseEntityModel<EntityEnum.TIMESHEET> implements ITimesheetEntity {
|
|
@@ -28,11 +29,24 @@ export declare class TimesheetEntityModel extends BaseEntityModel<EntityEnum.TIM
|
|
|
28
29
|
updatedOn: number;
|
|
29
30
|
user?: UserEntityModel;
|
|
30
31
|
history?: TimesheetHistoryEntityModel[];
|
|
32
|
+
project?: ProjectEntityModel;
|
|
31
33
|
static fromEntity(entity: ITimesheetEntity): TimesheetEntityModel;
|
|
32
34
|
getRelationConfigs(): any[];
|
|
33
|
-
static relationConfigs: RelationConfigs<[EntityEnum.USER, EntityEnum.TIMESHEET_HISTORY], EntityEnum.TIMESHEET>;
|
|
35
|
+
static relationConfigs: RelationConfigs<[EntityEnum.USER, EntityEnum.TIMESHEET_HISTORY, EntityEnum.PROJECT], EntityEnum.TIMESHEET>;
|
|
34
36
|
getTimesheetAmount(projectCurrency: CurrencyEnum): number;
|
|
35
37
|
get formattedDate(): string;
|
|
36
38
|
get userName(): string | undefined;
|
|
37
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
|
+
};
|
|
38
52
|
}
|
|
@@ -7,6 +7,7 @@ const timesheet_classification_status_enum_1 = require("../enums/timesheet.class
|
|
|
7
7
|
const timesheet_status_enum_1 = require("../enums/timesheet.status.enum");
|
|
8
8
|
const entity_utils_interface_1 = require("../interface/entity.utils.interface");
|
|
9
9
|
const base_entity_model_1 = require("./base.entity.model");
|
|
10
|
+
// Use this mdoel for UI & BACKEND
|
|
10
11
|
class TimesheetEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
11
12
|
constructor() {
|
|
12
13
|
super(...arguments);
|
|
@@ -22,13 +23,6 @@ class TimesheetEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
|
22
23
|
this.updatedBy = 0;
|
|
23
24
|
this.createdOn = 0;
|
|
24
25
|
this.updatedOn = 0;
|
|
25
|
-
// get latestStatusFromHistory(): TimesheetStatusEnum | undefined {
|
|
26
|
-
// const allHistoryModelSortedByIdInDesc = [...(this.history || [])].sort((a, b) => b.id - a.id);
|
|
27
|
-
// for (const model of allHistoryModelSortedByIdInDesc) {
|
|
28
|
-
// if (model.hasStatusKeyInData()) return model.status;
|
|
29
|
-
// }
|
|
30
|
-
// return undefined;
|
|
31
|
-
// }
|
|
32
26
|
}
|
|
33
27
|
static fromEntity(entity) {
|
|
34
28
|
const result = new TimesheetEntityModel(entity_utils_interface_1.EntityEnum.TIMESHEET);
|
|
@@ -55,6 +49,32 @@ class TimesheetEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
|
55
49
|
const sorted = [...(this.history || [])].sort((a, b) => b.id - a.id);
|
|
56
50
|
return (_a = sorted[1]) === null || _a === void 0 ? void 0 : _a.status;
|
|
57
51
|
}
|
|
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
|
+
}
|
|
58
78
|
}
|
|
59
79
|
exports.TimesheetEntityModel = TimesheetEntityModel;
|
|
60
80
|
TimesheetEntityModel.relationConfigs = [
|
|
@@ -76,4 +96,21 @@ TimesheetEntityModel.relationConfigs = [
|
|
|
76
96
|
key: "id",
|
|
77
97
|
},
|
|
78
98
|
},
|
|
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
|
+
},
|
|
79
108
|
];
|
|
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
|
+
};
|
|
@@ -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.
|