dt-common-device 13.1.8 → 13.1.9

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.
@@ -8,4 +8,5 @@ export declare class PmsRepository {
8
8
  getGuest(guestId: string): Promise<IGuest | null>;
9
9
  getGuestId(scheduleId: string): Promise<string | null>;
10
10
  getScheduleByGuestId(guestId: string): Promise<IPmsSchedule | null>;
11
+ getScheduleAccessGroups(scheduleId: string): Promise<any[]>;
11
12
  }
@@ -116,6 +116,16 @@ let PmsRepository = (() => {
116
116
  }
117
117
  return null;
118
118
  }
119
+ async getScheduleAccessGroups(scheduleId) {
120
+ try {
121
+ const scheduleAccessGroups = await this.pmsPostgres.query(`SELECT * FROM dt_schedule_accessgroup_map WHERE "scheduleId" = $1 AND "isDeleted" = false ORDER BY "startTime" ASC`, [scheduleId]);
122
+ return scheduleAccessGroups.rows || [];
123
+ }
124
+ catch (error) {
125
+ console.error("Error in getScheduleAccessGroups:", error);
126
+ throw new Error("Failed to get schedule access groups");
127
+ }
128
+ }
119
129
  };
120
130
  __setFunctionName(_classThis, "PmsRepository");
121
131
  (() => {
@@ -8,4 +8,5 @@ export declare class PmsService {
8
8
  getGuest(guestId: string): Promise<IGuest | null>;
9
9
  getGuestId(scheduleId: string): Promise<string | null>;
10
10
  getScheduleByGuestId(guestId: string): Promise<IPmsSchedule | null>;
11
+ checkConsecutiveRoomOccupancy(scheduleId: string, accessGroupId: string): Promise<boolean>;
11
12
  }
@@ -137,6 +137,42 @@ let PmsService = (() => {
137
137
  return null;
138
138
  return schedule;
139
139
  }
140
+ async checkConsecutiveRoomOccupancy(scheduleId, accessGroupId) {
141
+ if (!scheduleId) {
142
+ throw new Error("Schedule ID is required");
143
+ }
144
+ if (!accessGroupId) {
145
+ throw new Error("Access Group ID is required");
146
+ }
147
+ const scheduleAccessGroups = await this.pmsRepository.getScheduleAccessGroups(scheduleId);
148
+ console.log("Schedule Access Groups for consecutive room occupancy check:", scheduleAccessGroups);
149
+ if (!scheduleAccessGroups || scheduleAccessGroups.length === 0) {
150
+ return false;
151
+ }
152
+ const orderedAccessGroups = [...scheduleAccessGroups].sort((a, b) => new Date(a.startTime).getTime() - new Date(b.startTime).getTime());
153
+ console.log("Ordered Access Groups for consecutive room occupancy check:", orderedAccessGroups);
154
+ const matchingIndices = [];
155
+ for (let i = 0; i < orderedAccessGroups.length; i++) {
156
+ if (orderedAccessGroups[i].accessGroupId === accessGroupId) {
157
+ matchingIndices.push(i);
158
+ }
159
+ }
160
+ if (matchingIndices.length === 0) {
161
+ return false;
162
+ }
163
+ const firstIndex = matchingIndices[0];
164
+ const lastIndex = matchingIndices[matchingIndices.length - 1];
165
+ // Ensure all occurrences are contiguous (no other room between them)
166
+ if (lastIndex - firstIndex + 1 !== matchingIndices.length) {
167
+ return false;
168
+ }
169
+ for (let i = firstIndex; i <= lastIndex; i++) {
170
+ if (orderedAccessGroups[i].accessGroupId !== accessGroupId) {
171
+ return false;
172
+ }
173
+ }
174
+ return true;
175
+ }
140
176
  };
141
177
  __setFunctionName(_classThis, "PmsService");
142
178
  (() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dt-common-device",
3
- "version": "13.1.8",
3
+ "version": "13.1.9",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [