law-common 11.3.3-beta.3 → 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.
|
@@ -37,4 +37,16 @@ export declare class TimesheetEntityModel extends BaseEntityModel<EntityEnum.TIM
|
|
|
37
37
|
get formattedDate(): string;
|
|
38
38
|
get userName(): string | undefined;
|
|
39
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
|
+
};
|
|
40
52
|
}
|
|
@@ -23,13 +23,6 @@ class TimesheetEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
|
23
23
|
this.updatedBy = 0;
|
|
24
24
|
this.createdOn = 0;
|
|
25
25
|
this.updatedOn = 0;
|
|
26
|
-
// get latestStatusFromHistory(): TimesheetStatusEnum | undefined {
|
|
27
|
-
// const allHistoryModelSortedByIdInDesc = [...(this.history || [])].sort((a, b) => b.id - a.id);
|
|
28
|
-
// for (const model of allHistoryModelSortedByIdInDesc) {
|
|
29
|
-
// if (model.hasStatusKeyInData()) return model.status;
|
|
30
|
-
// }
|
|
31
|
-
// return undefined;
|
|
32
|
-
// }
|
|
33
26
|
}
|
|
34
27
|
static fromEntity(entity) {
|
|
35
28
|
const result = new TimesheetEntityModel(entity_utils_interface_1.EntityEnum.TIMESHEET);
|
|
@@ -56,6 +49,32 @@ class TimesheetEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
|
56
49
|
const sorted = [...(this.history || [])].sort((a, b) => b.id - a.id);
|
|
57
50
|
return (_a = sorted[1]) === null || _a === void 0 ? void 0 : _a.status;
|
|
58
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
|
+
}
|
|
59
78
|
}
|
|
60
79
|
exports.TimesheetEntityModel = TimesheetEntityModel;
|
|
61
80
|
TimesheetEntityModel.relationConfigs = [
|
|
@@ -87,3 +106,11 @@ TimesheetEntityModel.relationConfigs = [
|
|
|
87
106
|
},
|
|
88
107
|
},
|
|
89
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
|
+
};
|