@managemint-solutions/entities 1.28.0 → 1.33.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.
@@ -24,6 +24,7 @@ export declare enum AuditTrailEntityType {
24
24
  LEAVE_TYPES = "leave_types",
25
25
  LEAVE_ENTITLEMENTS = "leave_entitlements",
26
26
  LEAVE_REQUESTS = "leave_requests",
27
+ LEAVE_ADJUSTMENTS = "leave_adjustments",
27
28
  BILLING_TRANSACTIONS = "billing_transactions",
28
29
  INVOICE = "invoices",
29
30
  NOTIFICATION = "notifications"
@@ -29,6 +29,7 @@ var AuditTrailEntityType;
29
29
  AuditTrailEntityType["LEAVE_TYPES"] = "leave_types";
30
30
  AuditTrailEntityType["LEAVE_ENTITLEMENTS"] = "leave_entitlements";
31
31
  AuditTrailEntityType["LEAVE_REQUESTS"] = "leave_requests";
32
+ AuditTrailEntityType["LEAVE_ADJUSTMENTS"] = "leave_adjustments";
32
33
  AuditTrailEntityType["BILLING_TRANSACTIONS"] = "billing_transactions";
33
34
  AuditTrailEntityType["INVOICE"] = "invoices";
34
35
  AuditTrailEntityType["NOTIFICATION"] = "notifications";
@@ -1,4 +1,4 @@
1
- import { LeaveRequestStatus, LeaveReviewDecision } from '../enum';
1
+ import { LeaveGrantMethod, LeaveRequestStatus, LeaveReviewDecision } from '../enum';
2
2
  /**
3
3
  * The wire shapes of the leave routes. The api runs a global ValidationPipe with
4
4
  * `forbidNonWhitelisted`, so every field a route accepts is declared here and mirrored by
@@ -14,21 +14,29 @@ export type GetLeaveTypesDto = {
14
14
  /** Omitted = every type; true/false filters on the flag. */
15
15
  active?: boolean | null;
16
16
  };
17
- export type CreateLeaveTypeDto = {
18
- name: string;
19
- description: string | null;
17
+ /** The policy half of a leave type; see LeaveTypeEntity for what each field means. */
18
+ type LeaveTypePolicyDto = {
20
19
  default_days: number;
21
20
  is_paid: boolean;
22
21
  requires_approval: boolean;
23
- requires_document: boolean;
22
+ document_after_days: number | null;
23
+ cycle_years: number;
24
+ grant_method: LeaveGrantMethod;
25
+ max_carry_over_days: number;
26
+ carry_over_expiry_months: number | null;
27
+ min_service_months: number;
28
+ min_days_per_week: number;
29
+ initial_months: number;
30
+ initial_days_per_month: number | null;
31
+ paid_on_exit: boolean;
24
32
  };
25
- export type UpdateLeaveTypeDto = {
33
+ export type CreateLeaveTypeDto = LeaveTypePolicyDto & {
34
+ name: string;
35
+ description: string | null;
36
+ };
37
+ export type UpdateLeaveTypeDto = LeaveTypePolicyDto & {
26
38
  name: string;
27
39
  description: string | null;
28
- default_days: number;
29
- is_paid: boolean;
30
- requires_approval: boolean;
31
- requires_document: boolean;
32
40
  active: boolean;
33
41
  };
34
42
  export type LeaveEntitlementIdDto = {
@@ -45,20 +53,36 @@ export type GetLeaveEntitlementsDto = {
45
53
  export type CreateLeaveEntitlementDto = {
46
54
  user_id: string;
47
55
  leave_type_id: string;
48
- days_entitled: number;
49
- /** Null = the organization's current leave year. */
56
+ /** Null = the type's `default_days`, pro-rated when the period is shorter than a full cycle. */
57
+ days_entitled: number | null;
58
+ /** Null = the start of the type's current cycle for this person (their start date, if later). */
50
59
  period_start: string | null;
51
- /** Null = one year after `period_start`, less a day. */
60
+ /** Null = the end of that cycle. */
52
61
  period_end: string | null;
53
- max_carry_over_days: number;
62
+ /** Null = the type's cap. */
63
+ max_carry_over_days: number | null;
64
+ /** An opening balance brought in from before - 0 for none. */
65
+ days_carried: number;
66
+ carried_expires_on: string | null;
54
67
  notes: string | null;
55
68
  };
56
69
  export type UpdateLeaveEntitlementDto = {
57
70
  days_entitled: number;
58
- period_end: string;
59
71
  max_carry_over_days: number;
72
+ days_carried: number;
73
+ carried_expires_on: string | null;
60
74
  notes: string | null;
61
75
  };
76
+ /** One entitlement of a type for each person in `user_ids` (null = every active user), for their current cycle. */
77
+ export type BulkCreateLeaveEntitlementsDto = {
78
+ leave_type_id: string;
79
+ user_ids: string[] | null;
80
+ };
81
+ export type CreateLeaveAdjustmentDto = {
82
+ /** Either sign, never zero. */
83
+ days: number;
84
+ reason: string;
85
+ };
62
86
  export type LeaveRequestIdDto = {
63
87
  leaveRequestId: string;
64
88
  };
@@ -72,8 +96,9 @@ export type GetLeaveRequestsDto = {
72
96
  start_date_after?: string | null;
73
97
  start_date_before?: string | null;
74
98
  };
75
- /** Always the caller's own request: there is no `user_id` to file on someone's behalf. */
76
99
  export type CreateLeaveRequestDto = {
100
+ /** Null = the caller's own request; a manager may file one for a report. */
101
+ user_id: string | null;
77
102
  leave_type_id: string;
78
103
  start_date: string;
79
104
  end_date: string;
@@ -92,3 +117,11 @@ export type ReviewLeaveRequestDto = {
92
117
  status: LeaveReviewDecision;
93
118
  review_note: string | null;
94
119
  };
120
+ /** The organization-wide calendar: pending and approved leave touching `date_from`..`date_to`. */
121
+ export type GetLeaveCalendarDto = {
122
+ date_from: string;
123
+ date_to: string;
124
+ user_id?: string | null;
125
+ leave_type_id?: string | null;
126
+ };
127
+ export {};
@@ -1,8 +1,7 @@
1
1
  /**
2
2
  * The lifecycle of a leave request. Stored as text on `leave_requests.status` and validated
3
3
  * here, never by a Postgres enum. `pending` moves to any of the other three; `approved` may
4
- * still be cancelled (a future booking the employee no longer needs); `rejected` and
5
- * `cancelled` are terminal.
4
+ * still be cancelled by a manager before its first day; `rejected` and `cancelled` are terminal.
6
5
  */
7
6
  export declare enum LeaveRequestStatus {
8
7
  PENDING = "pending",
@@ -15,3 +14,8 @@ export declare enum LeaveReviewDecision {
15
14
  APPROVED = "approved",
16
15
  REJECTED = "rejected"
17
16
  }
17
+ /** Whether a period's days are all available on its first day, or earned month by month. */
18
+ export declare enum LeaveGrantMethod {
19
+ UPFRONT = "upfront",
20
+ MONTHLY = "monthly"
21
+ }
@@ -1,11 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LeaveReviewDecision = exports.LeaveRequestStatus = void 0;
3
+ exports.LeaveGrantMethod = exports.LeaveReviewDecision = exports.LeaveRequestStatus = void 0;
4
4
  /**
5
5
  * The lifecycle of a leave request. Stored as text on `leave_requests.status` and validated
6
6
  * here, never by a Postgres enum. `pending` moves to any of the other three; `approved` may
7
- * still be cancelled (a future booking the employee no longer needs); `rejected` and
8
- * `cancelled` are terminal.
7
+ * still be cancelled by a manager before its first day; `rejected` and `cancelled` are terminal.
9
8
  */
10
9
  var LeaveRequestStatus;
11
10
  (function (LeaveRequestStatus) {
@@ -20,3 +19,9 @@ var LeaveReviewDecision;
20
19
  LeaveReviewDecision["APPROVED"] = "approved";
21
20
  LeaveReviewDecision["REJECTED"] = "rejected";
22
21
  })(LeaveReviewDecision || (exports.LeaveReviewDecision = LeaveReviewDecision = {}));
22
+ /** Whether a period's days are all available on its first day, or earned month by month. */
23
+ var LeaveGrantMethod;
24
+ (function (LeaveGrantMethod) {
25
+ LeaveGrantMethod["UPFRONT"] = "upfront";
26
+ LeaveGrantMethod["MONTHLY"] = "monthly";
27
+ })(LeaveGrantMethod || (exports.LeaveGrantMethod = LeaveGrantMethod = {}));
@@ -1,4 +1,4 @@
1
- import { LeaveRequestStatus } from './enum';
1
+ import { LeaveGrantMethod, LeaveRequestStatus } from './enum';
2
2
  import { UserIdentity } from '../users';
3
3
  export * from './enum';
4
4
  /**
@@ -11,8 +11,13 @@ export type LeaveTypeIdentity = {
11
11
  mms_id: string;
12
12
  name: string;
13
13
  /** Carried on requests and entitlements so a reviewer knows without a second fetch. */
14
- requires_document: boolean;
14
+ document_after_days: number | null;
15
15
  };
16
+ /**
17
+ * A leave type is also its policy. The policy fields are copied onto an entitlement when it is
18
+ * created, so editing a type shapes the periods created after the edit and never rewrites a
19
+ * balance that already exists.
20
+ */
16
21
  export type LeaveTypeEntity = {
17
22
  mms_id: string;
18
23
  created_at: string;
@@ -21,22 +26,67 @@ export type LeaveTypeEntity = {
21
26
  last_updated_by: UserIdentity | null;
22
27
  name: string;
23
28
  description: string | null;
24
- /** The days a full year of this type is worth - the suggested entitlement. */
29
+ /** The days a full cycle of this type is worth; a shorter first cycle gets its share. */
25
30
  default_days: number;
26
31
  is_paid: boolean;
27
32
  /** False auto-approves a request on submission. */
28
33
  requires_approval: boolean;
29
- /** Approval waits until a supporting file is attached to the request; implies `requires_approval`. */
30
- requires_document: boolean;
34
+ /**
35
+ * Approval waits for a supporting file when a request is longer than this many days: 0 asks
36
+ * for one on every request, 2 on the third day onwards (the BCEA sick note), null never.
37
+ * Needs `requires_approval`.
38
+ */
39
+ document_after_days: number | null;
40
+ /**
41
+ * How many leave years one cycle runs: 1 for annual leave, 3 for a three-year sick-leave
42
+ * cycle. Every cycle starts in the organization's leave-year month; a person's first cycle
43
+ * begins in the leave year they joined and is pro-rated from their start date.
44
+ */
45
+ cycle_years: number;
46
+ grant_method: LeaveGrantMethod;
47
+ /** The most unused days the rollover carries into the next cycle. */
48
+ max_carry_over_days: number;
49
+ /** Carried days not taken within this many months of the new cycle are forfeited; null keeps them. */
50
+ carry_over_expiry_months: number | null;
51
+ /** Service needed before this type can be requested (4 for family responsibility leave). */
52
+ min_service_months: number;
53
+ /** Working days a week needed before this type can be requested (4 for family responsibility). */
54
+ min_days_per_week: number;
55
+ /**
56
+ * A slower rate for a person's first months: during `initial_months` from their start date
57
+ * they earn `initial_days_per_month` per completed month, capped at the cycle's days. The
58
+ * BCEA sick-leave rule of a day per 26 worked for the first six months is 6 and 0.83.
59
+ */
60
+ initial_months: number;
61
+ initial_days_per_month: number | null;
62
+ /** Unused days are paid out when someone leaves - annual leave, under the BCEA. */
63
+ paid_on_exit: boolean;
31
64
  /** An inactive type keeps its history but cannot be chosen for new requests. */
32
65
  active: boolean;
33
66
  };
34
- /** The window an entitlement covers - normally the organization's leave year. */
67
+ /** The window an entitlement covers - one cycle of its type, or the part of it after a joiner started. */
35
68
  export type LeavePeriod = {
36
69
  period_start: string;
37
70
  period_end: string;
38
71
  };
39
- export type LeaveEntitlementEntity = LeavePeriod & {
72
+ /**
73
+ * The balance of an entitlement on `as_of`. Nothing here is stored; it is worked out from the
74
+ * entitlement, its adjustments and the requests whose start date falls inside the period.
75
+ * `days_remaining` is accrued + carried - forfeited + adjusted - used - pending.
76
+ */
77
+ export type LeaveBalance = {
78
+ as_of: string;
79
+ /** The part of `days_entitled` earned by `as_of` - all of it on an upfront type. */
80
+ days_accrued: number;
81
+ /** Carried days that expired before they were taken. */
82
+ days_forfeited: number;
83
+ /** The sum of the manual adjustments, either sign. */
84
+ days_adjusted: number;
85
+ days_used: number;
86
+ days_pending: number;
87
+ days_remaining: number;
88
+ };
89
+ export type LeaveEntitlementEntity = LeavePeriod & LeaveBalance & {
40
90
  mms_id: string;
41
91
  created_at: string;
42
92
  created_by: UserIdentity | null;
@@ -44,17 +94,29 @@ export type LeaveEntitlementEntity = LeavePeriod & {
44
94
  last_updated_by: UserIdentity | null;
45
95
  user: UserIdentity;
46
96
  leave_type: LeaveTypeIdentity;
97
+ /** The days this period is worth, excluding anything carried in. */
47
98
  days_entitled: number;
99
+ /** Unused days brought in from the previous period; spent before `days_entitled`. */
100
+ days_carried: number;
101
+ /** The last day carried days can be taken; null when they do not expire. */
102
+ carried_expires_on: string | null;
103
+ /** Copied from the type when this entitlement was created, like the three below. */
104
+ grant_method: LeaveGrantMethod;
105
+ /** The last day of the slower first-months rate, or null when it does not apply. */
106
+ initial_until: string | null;
107
+ initial_days_per_month: number | null;
48
108
  /** Cap on the unused days the nightly rollover carries into the next period. */
49
109
  max_carry_over_days: number;
50
110
  notes: string | null;
51
- /**
52
- * Computed on read, never stored: the approved and pending requests of this user and
53
- * type whose start date falls inside the period. `days_remaining` already subtracts both.
54
- */
55
- days_used: number;
56
- days_pending: number;
57
- days_remaining: number;
111
+ };
112
+ /** A manual correction to an entitlement, either sign. Never edited or deleted - a mistake is corrected by another. */
113
+ export type LeaveAdjustmentEntity = {
114
+ mms_id: string;
115
+ created_at: string;
116
+ created_by: UserIdentity | null;
117
+ leave_entitlement_id: string;
118
+ days: number;
119
+ reason: string;
58
120
  };
59
121
  export type LeaveRequestEntity = {
60
122
  mms_id: string;
@@ -69,7 +131,7 @@ export type LeaveRequestEntity = {
69
131
  /** Only for a single-day request; halves its `days`. */
70
132
  is_half_day: boolean;
71
133
  /**
72
- * Working days (Monday to Friday, less the organization's public holidays) as counted
134
+ * The requester's working days (their `working_days`, less public holidays) as counted
73
135
  * when the request was submitted or last edited. A snapshot: a holiday added afterwards
74
136
  * does not rewrite approved history.
75
137
  */
@@ -83,3 +145,30 @@ export type LeaveRequestEntity = {
83
145
  cancelled_by: UserIdentity | null;
84
146
  cancelled_at: string | null;
85
147
  };
148
+ /** Who is off when: the organization-wide calendar, without reasons or review notes. */
149
+ export type LeaveCalendarEntry = {
150
+ mms_id: string;
151
+ user: UserIdentity;
152
+ /** Who filed it - a manager, when it differs from `user`. */
153
+ created_by: UserIdentity | null;
154
+ leave_type: {
155
+ mms_id: string;
156
+ name: string;
157
+ };
158
+ start_date: string;
159
+ end_date: string;
160
+ is_half_day: boolean;
161
+ status: LeaveRequestStatus;
162
+ };
163
+ /** What `POST /bulk` did: one entitlement per person created, or skipped with the reason why. */
164
+ export type BulkLeaveEntitlementsResult = {
165
+ created: number;
166
+ skipped: {
167
+ user: UserIdentity;
168
+ reason: string;
169
+ }[];
170
+ };
171
+ /** A private subscription address for the leave calendar; shown once, when it is made. */
172
+ export type LeaveCalendarFeedEntity = {
173
+ url: string;
174
+ };
@@ -16,6 +16,8 @@ export declare enum NotificationType {
16
16
  LEAVE_REQUEST_SUBMITTED = "leave_request_submitted",
17
17
  LEAVE_REQUEST_APPROVED = "leave_request_approved",
18
18
  LEAVE_REQUEST_REJECTED = "leave_request_rejected",
19
+ LEAVE_REQUEST_CANCELLED = "leave_request_cancelled",
20
+ LEAVE_REQUEST_FILED_FOR_YOU = "leave_request_filed_for_you",
19
21
  TIMESHEET_SUBMITTED = "timesheet_submitted",
20
22
  TIMESHEET_APPROVED = "timesheet_approved",
21
23
  TIMESHEET_REJECTED = "timesheet_rejected",
@@ -24,6 +24,8 @@ var NotificationType;
24
24
  NotificationType["LEAVE_REQUEST_SUBMITTED"] = "leave_request_submitted";
25
25
  NotificationType["LEAVE_REQUEST_APPROVED"] = "leave_request_approved";
26
26
  NotificationType["LEAVE_REQUEST_REJECTED"] = "leave_request_rejected";
27
+ NotificationType["LEAVE_REQUEST_CANCELLED"] = "leave_request_cancelled";
28
+ NotificationType["LEAVE_REQUEST_FILED_FOR_YOU"] = "leave_request_filed_for_you";
27
29
  NotificationType["TIMESHEET_SUBMITTED"] = "timesheet_submitted";
28
30
  NotificationType["TIMESHEET_APPROVED"] = "timesheet_approved";
29
31
  NotificationType["TIMESHEET_REJECTED"] = "timesheet_rejected";
@@ -60,4 +60,6 @@ export type UpdateOrganizationDto = {
60
60
  industry?: string | null;
61
61
  marketing_consent?: boolean;
62
62
  currency?: string;
63
+ /** The month (1-12) the leave year starts on; shapes entitlements created after the change. */
64
+ leave_calendar_start_month?: number;
63
65
  };
@@ -16,3 +16,6 @@ export type UpdateStatusDto = {
16
16
  colour: string;
17
17
  is_complete?: boolean;
18
18
  };
19
+ export type ReorderStatusesDto = {
20
+ status_ids: string[];
21
+ };
@@ -7,4 +7,5 @@ export type StatusEntity = {
7
7
  is_fail: boolean;
8
8
  is_triage: boolean;
9
9
  is_won: boolean;
10
+ position: number;
10
11
  };
@@ -8,6 +8,8 @@ export type GetUsersDto = {
8
8
  page_size: number;
9
9
  /** Comma-joined booleans on the wire, e.g. "true,false". Absent = all users. */
10
10
  active_in?: string | null;
11
+ /** A manager's team: everyone naming this user as their manager or second manager. */
12
+ manager_id?: string | null;
11
13
  };
12
14
  export type CreateUserDto = {
13
15
  email: string;
@@ -29,6 +31,8 @@ export type UpdateUserDto = {
29
31
  start_date?: string | null;
30
32
  end_date?: string | null;
31
33
  employment_type?: EmploymentType | null;
34
+ /** ISO weekdays, 1 (Monday) to 7 (Sunday), at least one. */
35
+ working_days?: number[];
32
36
  job_title?: string | null;
33
37
  manager_id?: string | null;
34
38
  /** Must differ from `manager_id` and needs a manager set first; the api refuses otherwise. */
@@ -39,6 +39,8 @@ export interface UserEntity {
39
39
  job_title: string | null;
40
40
  start_date: Date;
41
41
  end_date: Date | null;
42
+ /** ISO weekdays this person works, 1 (Monday) to 7 (Sunday); leave counts only these days. */
43
+ working_days: number[];
42
44
  social_facebook: URL | null;
43
45
  social_linkedin: URL | null;
44
46
  social_twitter: URL | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@managemint-solutions/entities",
3
- "version": "1.28.0",
3
+ "version": "1.33.0",
4
4
  "description": "Entity types used by both the api and portal",
5
5
  "homepage": "https://github.com/ManageMint-Solutions/managemint-solutions-entities#readme",
6
6
  "bugs": {