@vendit-dev/thirdparty-adapters 0.7.6 → 0.7.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.
Files changed (43) hide show
  1. package/.idea/codeStyles/Project.xml +50 -0
  2. package/.idea/codeStyles/codeStyleConfig.xml +5 -0
  3. package/.idea/inspectionProfiles/Project_Default.xml +6 -0
  4. package/.idea/modules.xml +8 -0
  5. package/.idea/thirdparty-adapters.iml +12 -0
  6. package/.idea/vcs.xml +6 -0
  7. package/lib/adapters/externalChannelManagers/externalChannelManager.type.d.ts +130 -0
  8. package/lib/adapters/externalChannelManagers/externalChannelManager.type.js +40 -0
  9. package/lib/adapters/externalChannelManagers/externalChannelManagerCaller.d.ts +10 -0
  10. package/lib/adapters/externalChannelManagers/externalChannelManagerCaller.js +79 -0
  11. package/lib/adapters/externalChannelManagers/externalChannelManagerCaller.type.d.ts +4 -0
  12. package/lib/adapters/externalChannelManagers/externalChannelManagerCaller.type.js +27 -0
  13. package/lib/adapters/externalChannelManagers/tl-lincoln.d.ts +25 -0
  14. package/lib/adapters/externalChannelManagers/tl-lincoln.helper.d.ts +23 -0
  15. package/lib/adapters/externalChannelManagers/tl-lincoln.helper.js +381 -0
  16. package/lib/adapters/externalChannelManagers/tl-lincoln.js +321 -0
  17. package/lib/adapters/externalChannelManagers/tl-lincoln.types.d.ts +583 -0
  18. package/lib/adapters/externalChannelManagers/tl-lincoln.types.js +32 -0
  19. package/lib/adapters/externalChannelManagers/tl-sample.d.ts +1218 -0
  20. package/lib/adapters/externalChannelManagers/tl-sample.js +3974 -0
  21. package/lib/adapters/parking/amano.d.ts +1 -0
  22. package/lib/adapters/parking/amano.js +3 -0
  23. package/lib/adapters/parking/nicePark.d.ts +2 -1
  24. package/lib/adapters/parking/nicePark.js +37 -2
  25. package/lib/adapters/parking/parkingThirdParty.type.d.ts +11 -0
  26. package/lib/adapters/parking/parkingThridPartyCaller.d.ts +1 -0
  27. package/lib/adapters/parking/parkingThridPartyCaller.js +20 -0
  28. package/lib/adapters/smartAccess.d.ts +7 -2
  29. package/lib/adapters/smartAccess.js +26 -25
  30. package/lib/index.d.ts +4 -2
  31. package/lib/index.js +7 -3
  32. package/lib/types/common.d.ts +385 -0
  33. package/lib/types/common.js +2 -0
  34. package/lib/types/index.d.ts +2 -0
  35. package/lib/types/index.js +18 -0
  36. package/lib/types/tl-lincoln.ota.d.ts +1 -0
  37. package/lib/types/tl-lincoln.ota.js +121 -0
  38. package/lib/utils/function.d.ts +2 -0
  39. package/lib/utils/function.js +15 -0
  40. package/package.json +48 -49
  41. package/lib/utils/number.util.d.ts +0 -1
  42. package/lib/utils/number.util.js +0 -26
  43. package/yarn-error.log +0 -4583
@@ -0,0 +1,381 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
14
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
15
+ if (ar || !(i in from)) {
16
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
17
+ ar[i] = from[i];
18
+ }
19
+ }
20
+ return to.concat(ar || Array.prototype.slice.call(from));
21
+ };
22
+ var __importDefault = (this && this.__importDefault) || function (mod) {
23
+ return (mod && mod.__esModule) ? mod : { "default": mod };
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.withAsyncBandwidth = exports.refineReservationData = exports.formattedPaxCountText = exports.formattedNameForMealCondition = exports.getExternalReservationTypeFromDataClassification = exports.getReservationStatusFromDataClassification = exports.xmlToJson = exports.jsonToXml = void 0;
27
+ var fast_xml_parser_1 = require("fast-xml-parser");
28
+ var moment_1 = __importDefault(require("moment"));
29
+ var tl_lincoln_types_1 = require("./tl-lincoln.types");
30
+ var function_1 = require("../../utils/function");
31
+ var tl_lincoln_ota_1 = require("../../types/tl-lincoln.ota");
32
+ function jsonToXml(json) {
33
+ var options = {
34
+ ignoreAttributes: false,
35
+ format: true,
36
+ suppressEmptyNode: true,
37
+ };
38
+ var builder = new fast_xml_parser_1.XMLBuilder(options);
39
+ var xmlContent = {
40
+ 'soapenv:Envelope': {
41
+ '@_xmlns:soapenv': 'http://schemas.xmlsoap.org/soap/envelope/',
42
+ '@_xmlns:pms': json.pmsUrl,
43
+ 'soapenv:Body': {
44
+ 'pms:execute': {
45
+ arg0: __assign({ commonRequest: __assign({}, json.commonRequest) }, json.request),
46
+ },
47
+ },
48
+ },
49
+ };
50
+ return builder.build(xmlContent);
51
+ }
52
+ exports.jsonToXml = jsonToXml;
53
+ function xmlToJson(xml) {
54
+ // &#xD; 문자는 제거하고 파싱합니다.
55
+ try {
56
+ var parser = new fast_xml_parser_1.XMLParser();
57
+ return parser.parse(xml.replace(/&#xD;/g, ''));
58
+ }
59
+ catch (e) {
60
+ console.error("xmlToJson failed: ".concat(e));
61
+ return {};
62
+ }
63
+ }
64
+ exports.xmlToJson = xmlToJson;
65
+ function getReservationStatusFromDataClassification(dataClassification) {
66
+ switch (dataClassification) {
67
+ case 'NewBookReport':
68
+ case 'ModificationReport':
69
+ return 'RESERVED';
70
+ case 'CancellationReport':
71
+ return 'CANCELLED';
72
+ default:
73
+ return 'RESERVED';
74
+ }
75
+ }
76
+ exports.getReservationStatusFromDataClassification = getReservationStatusFromDataClassification;
77
+ function getExternalReservationTypeFromDataClassification(dataClassification) {
78
+ switch (dataClassification) {
79
+ case 'NewBookReport':
80
+ return 'CREATED';
81
+ case 'ModificationReport':
82
+ return 'UPDATED';
83
+ case 'CancellationReport':
84
+ return 'CANCELLED';
85
+ default:
86
+ return 'CREATED';
87
+ }
88
+ }
89
+ exports.getExternalReservationTypeFromDataClassification = getExternalReservationTypeFromDataClassification;
90
+ var getSpecificMealConditionText = function (_specificType) {
91
+ switch (_specificType) {
92
+ case 'IncludingBreakfast':
93
+ return ['조식'];
94
+ case 'IncludingLunch':
95
+ return ['중식'];
96
+ case 'IncludingDinner':
97
+ return ['석식'];
98
+ case 'IncludingLunchAndDinner':
99
+ return ['중식', '석식'];
100
+ case 'IncludingBreakfastAndLunch':
101
+ return ['조식', '중식'];
102
+ case 'IncludingBreakfastAndDinner':
103
+ return ['조식', '석식'];
104
+ case 'IncludingBreakfastAndLunchAndDinner':
105
+ return ['조식', '중식', '석식'];
106
+ case 'None Specified':
107
+ return [];
108
+ default:
109
+ return [];
110
+ }
111
+ };
112
+ var getMealConditionText = function (_mealCondition) {
113
+ switch (_mealCondition) {
114
+ case '1night2meals':
115
+ return '1박2식';
116
+ case '1nightBreakfast':
117
+ return '1박조식';
118
+ default:
119
+ return '조식 없음';
120
+ }
121
+ };
122
+ var formattedNameForMealCondition = function (mealCondition, specificMealCondition) {
123
+ var _a;
124
+ return "".concat(getMealConditionText(mealCondition)).concat(((_a = getSpecificMealConditionText(specificMealCondition)) === null || _a === void 0 ? void 0 : _a.length) > 0
125
+ ? "(".concat(getSpecificMealConditionText(specificMealCondition).join(', '), ")")
126
+ : '');
127
+ };
128
+ exports.formattedNameForMealCondition = formattedNameForMealCondition;
129
+ var formattedPaxCountText = function (roomInformation, genderDivision) {
130
+ if ('RoomPaxMaleCount' in roomInformation) {
131
+ var _a = roomInformation, _b = _a.RoomPaxMaleCount, RoomPaxMaleCount = _b === void 0 ? 0 : _b, _c = _a.RoomPaxFemaleCount, RoomPaxFemaleCount = _c === void 0 ? 0 : _c, _d = _a.RoomChildA70Count, RoomChildA70Count = _d === void 0 ? 0 : _d, _e = _a.RoomChildB50Count, RoomChildB50Count = _e === void 0 ? 0 : _e, _f = _a.RoomChildC30Count, RoomChildC30Count = _f === void 0 ? 0 : _f, _g = _a.RoomChildDNoneCount, RoomChildDNoneCount = _g === void 0 ? 0 : _g, _h = _a.RoomChildOtherCount, RoomChildOtherCount = _h === void 0 ? 0 : _h;
132
+ return "".concat([
133
+ genderDivision
134
+ ? "\uB0A8 ".concat(RoomPaxMaleCount, "\uBA85, \uC5EC ").concat(RoomPaxFemaleCount, "\uBA85")
135
+ : "\uC131\uC778 ".concat(RoomPaxMaleCount + RoomPaxFemaleCount, "\uBA85"),
136
+ RoomChildA70Count ? "\uD559\uC0DD ".concat(RoomChildA70Count, "\uBA85") : '',
137
+ RoomChildB50Count || RoomChildC30Count || RoomChildOtherCount
138
+ ? "\uC544\uB3D9 ".concat(RoomChildB50Count + RoomChildC30Count + RoomChildOtherCount, "\uBA85")
139
+ : '',
140
+ RoomChildDNoneCount ? "\uC720\uC544 ".concat(RoomChildDNoneCount, "\uBA85") : '',
141
+ ]
142
+ .filter(Boolean)
143
+ .join(', '));
144
+ }
145
+ var _j = roomInformation, _k = _j.TotalPaxMaleCount, TotalPaxMaleCount = _k === void 0 ? 0 : _k, _l = _j.TotalPaxFemaleCount, TotalPaxFemaleCount = _l === void 0 ? 0 : _l, _m = _j.TotalChildA70Count, TotalChildA70Count = _m === void 0 ? 0 : _m, _o = _j.TotalChildB50Count, TotalChildB50Count = _o === void 0 ? 0 : _o, _p = _j.TotalChildC30Count, TotalChildC30Count = _p === void 0 ? 0 : _p, _q = _j.TotalChildDNoneCount, TotalChildDNoneCount = _q === void 0 ? 0 : _q, _r = _j.TotalChildOtherCount, TotalChildOtherCount = _r === void 0 ? 0 : _r;
146
+ return "".concat([
147
+ genderDivision
148
+ ? "\uB0A8 ".concat(TotalPaxMaleCount, "\uBA85, \uC5EC ").concat(TotalPaxFemaleCount, "\uBA85")
149
+ : "\uC131\uC778 ".concat(TotalPaxMaleCount + TotalPaxFemaleCount, "\uBA85"),
150
+ TotalChildA70Count ? "\uD559\uC0DD ".concat(TotalChildA70Count, "\uBA85") : '',
151
+ TotalChildB50Count || TotalChildC30Count || TotalChildOtherCount
152
+ ? "\uC544\uB3D9 ".concat(TotalChildB50Count + TotalChildC30Count + TotalChildOtherCount, "\uBA85")
153
+ : '',
154
+ TotalChildDNoneCount ? "\uC720\uC544 ".concat(TotalChildDNoneCount, "\uBA85") : '',
155
+ ]
156
+ .filter(Boolean)
157
+ .join(', '));
158
+ };
159
+ exports.formattedPaxCountText = formattedPaxCountText;
160
+ function formatPhoneNumber(text) {
161
+ var onlyNumberText = text === null || text === void 0 ? void 0 : text.replace(/[^0-9]/g, '');
162
+ return onlyNumberText ? "010".concat(onlyNumberText.slice(-8)) : '';
163
+ }
164
+ var makePaymentInfo = function (_a) {
165
+ var datas = _a.datas, basicRateInformation = _a.basicRateInformation, basicInformation = _a.basicInformation, reservationType = _a.reservationType, CheckInDate = _a.CheckInDate, OptionList = _a.OptionList, roomsSortedByDate = _a.roomsSortedByDate;
166
+ return datas.reduce(function (paymentInput, _a) {
167
+ var _b, _c, _d;
168
+ var RoomInfo = _a.RoomInformation, RoomRateInformation = _a.RoomRateInformation;
169
+ var roomAmount = (RoomRateInformation === null || RoomRateInformation === void 0 ? void 0 : RoomRateInformation.TotalPerRoomRate)
170
+ || ((RoomRateInformation === null || RoomRateInformation === void 0 ? void 0 : RoomRateInformation.PerMaleRate) || 0)
171
+ * (RoomInfo.RoomPaxMaleCount || 0)
172
+ + ((RoomRateInformation === null || RoomRateInformation === void 0 ? void 0 : RoomRateInformation.PerFemaleRate)
173
+ || (RoomRateInformation === null || RoomRateInformation === void 0 ? void 0 : RoomRateInformation.PerMaleRate)
174
+ || 0)
175
+ * (RoomInfo.RoomPaxFemaleCount || 0)
176
+ || (RoomRateInformation === null || RoomRateInformation === void 0 ? void 0 : RoomRateInformation.TotalPerRoomRate)
177
+ || basicRateInformation.TotalAccommodationCharge
178
+ || 0;
179
+ paymentInput.amount += roomAmount;
180
+ (_b = paymentInput.segments) === null || _b === void 0 ? void 0 : _b.push({
181
+ amount: roomAmount,
182
+ servedAt: RoomRateInformation.RoomDate,
183
+ referenceType: 'RESERVATION',
184
+ referenceSubType: reservationType,
185
+ });
186
+ if (basicInformation.MealCondition !== 'Other'
187
+ && basicInformation.MealCondition !== 'WithoutMeal') {
188
+ paymentInput.amount += (RoomRateInformation === null || RoomRateInformation === void 0 ? void 0 : RoomRateInformation.TotalPerRoomServiceFee) || 0;
189
+ (_c = paymentInput.segments) === null || _c === void 0 ? void 0 : _c.push({
190
+ amount: (RoomRateInformation === null || RoomRateInformation === void 0 ? void 0 : RoomRateInformation.TotalPerRoomServiceFee) || 0,
191
+ servedAt: RoomRateInformation.RoomDate,
192
+ referenceType: 'SERVICE',
193
+ referenceSubType: (0, exports.formattedNameForMealCondition)(basicInformation.MealCondition, basicInformation.SpecificMealCondition),
194
+ });
195
+ }
196
+ if ((OptionList === null || OptionList === void 0 ? void 0 : OptionList.length) > 0) {
197
+ (_d = paymentInput.segments) === null || _d === void 0 ? void 0 : _d.push.apply(_d, OptionList.map(function (option) { return ({
198
+ amount: 0,
199
+ servedAt: option.OptionDate,
200
+ referenceType: 'SERVICE',
201
+ referenceSubType: option.Name,
202
+ }); }));
203
+ }
204
+ return Object.assign(paymentInput, {
205
+ reservationType: reservationType,
206
+ type: 'platform',
207
+ externalRoomTypeCode: roomsSortedByDate[0].RoomInformation.NetRmTypeGroupCode,
208
+ externalRoomTypeName: roomsSortedByDate[0].RoomInformation.RoomTypeName,
209
+ useStartAt: "".concat(CheckInDate).concat((basicInformation === null || basicInformation === void 0 ? void 0 : basicInformation.CheckInTime)
210
+ ? " ".concat(basicInformation === null || basicInformation === void 0 ? void 0 : basicInformation.CheckInTime)
211
+ : ''),
212
+ });
213
+ }, {
214
+ amount: 0,
215
+ commissionAmount: 0,
216
+ reservationType: 'lodge',
217
+ segments: [],
218
+ externalRoomTypeCode: '',
219
+ externalRoomTypeName: '',
220
+ type: 'platform',
221
+ useStartAt: '',
222
+ });
223
+ };
224
+ var refineReservationData = function (infoTravelXML) {
225
+ var _a, _b;
226
+ var _c = infoTravelXML.AllotmentBookingReport, TransactionType = _c.TransactionType, RisaplsInformation = _c.RisaplsInformation, BasicInformation = _c.BasicInformation, BasicRateInformation = _c.BasicRateInformation, SalesOfficeInformation = _c.SalesOfficeInformation;
227
+ var _d = TransactionType.DataID.split('-'), ID = _d[0], REVISION = _d[1];
228
+ var isGroupReservation = BasicInformation.TotalRoomCount > 1;
229
+ var RisaplsCommonInformation = RisaplsInformation.RisaplsCommonInformation, AgentNativeInformation = RisaplsInformation.AgentNativeInformation;
230
+ var RoomAndRoomRateInformation = RisaplsCommonInformation.RoomAndRoomRateInformation, Allotment = RisaplsCommonInformation.Allotment, Member = RisaplsCommonInformation.Member, OtherInfo = RisaplsCommonInformation.OtherInfo, Basic = RisaplsCommonInformation.Basic, BasicRate = RisaplsCommonInformation.BasicRate, Option = RisaplsCommonInformation.Option;
231
+ var isFullyPaid = !!((_a = AgentNativeInformation === null || AgentNativeInformation === void 0 ? void 0 : AgentNativeInformation.Extendmytrip) === null || _a === void 0 ? void 0 : _a.SettlementDiv)
232
+ && !((_b = AgentNativeInformation === null || AgentNativeInformation === void 0 ? void 0 : AgentNativeInformation.Extend) === null || _b === void 0 ? void 0 : _b.AmountClaimed)
233
+ && (BasicRateInformation === null || BasicRateInformation === void 0 ? void 0 : BasicRateInformation.Payment) !== 'Hotel Collect';
234
+ var roomAndRoomRateInformations = (0, tl_lincoln_types_1.makeArray)(RoomAndRoomRateInformation);
235
+ var groupedRooms = (0, function_1.groupBy)(roomAndRoomRateInformations, 'RoomInformation.RoomByRoomConfirmationNumber');
236
+ var status = getReservationStatusFromDataClassification(TransactionType.DataClassification);
237
+ var useStartAt = "".concat(BasicInformation.CheckInDate).concat((BasicInformation === null || BasicInformation === void 0 ? void 0 : BasicInformation.CheckInTime) ? " ".concat(BasicInformation === null || BasicInformation === void 0 ? void 0 : BasicInformation.CheckInTime) : '');
238
+ var useExpireAt = "".concat((0, moment_1.default)(BasicInformation.CheckInDate)
239
+ .add(BasicInformation.Nights, 'days')
240
+ .format('YYYY-MM-DD')).concat((BasicInformation === null || BasicInformation === void 0 ? void 0 : BasicInformation.CheckOutTime) ? " ".concat(BasicInformation === null || BasicInformation === void 0 ? void 0 : BasicInformation.CheckOutTime) : '');
241
+ var PointDiscountList = [];
242
+ if (BasicRate === null || BasicRate === void 0 ? void 0 : BasicRate.PointsDiscountList) {
243
+ PointDiscountList = (0, tl_lincoln_types_1.makeArray)(BasicRate.PointsDiscountList);
244
+ }
245
+ return {
246
+ type: getExternalReservationTypeFromDataClassification(TransactionType.DataClassification),
247
+ externalId: ID,
248
+ externalRevision: REVISION,
249
+ guestOrGroupInfo: {
250
+ isGroupReservation: isGroupReservation,
251
+ name: BasicInformation.GuestOrGroupNameKanjiName,
252
+ email: Member === null || Member === void 0 ? void 0 : Member.UserMailAddr,
253
+ reservedBy: SalesOfficeInformation === null || SalesOfficeInformation === void 0 ? void 0 : SalesOfficeInformation.SalesOfficeCompanyName,
254
+ memo: "".concat((Member === null || Member === void 0 ? void 0 : Member.UserKana)
255
+ || (Member === null || Member === void 0 ? void 0 : Member.UserName)
256
+ || "".concat(BasicInformation.GuestOrGroupNameKanjiName), " ").concat(BasicInformation === null || BasicInformation === void 0 ? void 0 : BasicInformation.PackagePlanName, "\n").concat((OtherInfo === null || OtherInfo === void 0 ? void 0 : OtherInfo.GuestRequest)
257
+ ? "[\uC694\uCCAD\uC0AC\uD56D]\n".concat(OtherInfo.GuestRequest)
258
+ : '', "\n").concat((OtherInfo === null || OtherInfo === void 0 ? void 0 : OtherInfo.AdditionalInformation)
259
+ ? "[\uCD94\uAC00\uC815\uBCF4]\n".concat(OtherInfo.AdditionalInformation)
260
+ : '', "\n").concat((0, exports.formattedPaxCountText)(BasicInformation), "\n[\uACB0\uC81C\uC815\uBCF4]\n\uC9C0\uBD88\uC218\uB2E8: ").concat(BasicRateInformation.Payment || '정보 없음', "\n").concat(BasicRateInformation.Payment === 'CreditCard'
261
+ ? "\uCE74\uB4DC\uC0AC\uBA85: ".concat(BasicRateInformation.CreditCardAuthority, "\n\uCE74\uB4DC\uBC88\uD638: ").concat(BasicRateInformation.CreditCardNumber, "\n\uC720\uD6A8\uAE30\uAC04: ").concat(BasicRateInformation.ExpireDate, "\n\uC18C\uC9C0\uC790\uBA85: ").concat(BasicRateInformation.CardHolderName, "\n\uC774\uC804 \uCDE8\uC18C\uAE08\uC561: ").concat(BasicRateInformation.CancellationCharge, "\n")
262
+ : '', "\n\uC218\uC218\uB8CC\uC728: ").concat(BasicRateInformation.CommissionPercentage
263
+ ? "".concat(BasicRateInformation.CommissionPercentage, "%")
264
+ : '정보 없음', "\n\uC218\uC218\uB8CC \uCD1D\uC561: ").concat(BasicRateInformation.TotalAccommodationCommissionAmount
265
+ ? "".concat(BasicRateInformation.TotalAccommodationCommissionAmount, "\uC6D0")
266
+ : '정보 없음', "\n[\uD560\uC778\uC815\uBCF4]\n").concat((PointDiscountList === null || PointDiscountList === void 0 ? void 0 : PointDiscountList.length) > 0
267
+ ? "".concat(PointDiscountList.map(function (point) { return "".concat(point.PointsDiscountName, ": ").concat(point.PointsDiscount); }).join('\n'))
268
+ : ''),
269
+ status: 'reserved',
270
+ phone: formatPhoneNumber("".concat((Member === null || Member === void 0 ? void 0 : Member.UserTel) || Basic.PhoneNumber || '')),
271
+ useExpireAt: useExpireAt,
272
+ useStartAt: useStartAt,
273
+ platform: tl_lincoln_ota_1.TL_LINCOLN_TO_VENDIT_OTA_MAP[(SalesOfficeInformation === null || SalesOfficeInformation === void 0 ? void 0 : SalesOfficeInformation.SalesOfficeCompanyName) || 'ANONYMOUS'] || (SalesOfficeInformation === null || SalesOfficeInformation === void 0 ? void 0 : SalesOfficeInformation.SalesOfficeCompanyName),
274
+ externalPlatformCode: SalesOfficeInformation === null || SalesOfficeInformation === void 0 ? void 0 : SalesOfficeInformation.SalesOfficeCode,
275
+ externalPlatformName: (SalesOfficeInformation === null || SalesOfficeInformation === void 0 ? void 0 : SalesOfficeInformation.SalesOfficeCompanyName)
276
+ || (SalesOfficeInformation === null || SalesOfficeInformation === void 0 ? void 0 : SalesOfficeInformation.SalesOfficeName),
277
+ },
278
+ reservations: Object.keys(groupedRooms).map(function (key, index) {
279
+ var _a, _b, _c, _d;
280
+ var datas = groupedRooms[key];
281
+ var roomsSortedByDate = datas.sort(function (a, b) {
282
+ return new Date(a.RoomRateInformation.RoomDate).valueOf()
283
+ - new Date(b.RoomRateInformation.RoomDate).valueOf();
284
+ });
285
+ var reservationType = Number(Allotment.UseDiv) === 1
286
+ && BasicInformation.CheckInDate === BasicInformation.CheckOutDate
287
+ ? 'rent'
288
+ : 'lodge';
289
+ var CheckInDate = roomsSortedByDate[0].RoomRateInformation.RoomDate;
290
+ var CheckOutDate = (_a = (0, moment_1.default)(CheckInDate)
291
+ .add(BasicInformation === null || BasicInformation === void 0 ? void 0 : BasicInformation.Nights, 'days')) === null || _a === void 0 ? void 0 : _a.format('YYYY-MM-DD');
292
+ var OptionList = Option
293
+ ? (0, tl_lincoln_types_1.makeArray)(Option)
294
+ : [];
295
+ var DepositList = (BasicRate === null || BasicRate === void 0 ? void 0 : BasicRate.DepositList) && (0, tl_lincoln_types_1.makeArray)(BasicRate.DepositList);
296
+ var paymentInfo = makePaymentInfo({
297
+ datas: datas,
298
+ basicRateInformation: BasicRateInformation,
299
+ basicInformation: BasicInformation,
300
+ reservationType: reservationType,
301
+ CheckInDate: CheckInDate,
302
+ OptionList: OptionList,
303
+ roomsSortedByDate: roomsSortedByDate,
304
+ });
305
+ return {
306
+ useStartAt: "".concat(CheckInDate).concat((BasicInformation === null || BasicInformation === void 0 ? void 0 : BasicInformation.CheckInTime)
307
+ ? " ".concat(BasicInformation === null || BasicInformation === void 0 ? void 0 : BasicInformation.CheckInTime)
308
+ : ''),
309
+ useExpireAt: "".concat(CheckOutDate).concat((BasicInformation === null || BasicInformation === void 0 ? void 0 : BasicInformation.CheckOutTime)
310
+ ? " ".concat(BasicInformation === null || BasicInformation === void 0 ? void 0 : BasicInformation.CheckOutTime)
311
+ : ''),
312
+ sleeps: (_c = (_b = roomsSortedByDate[0]) === null || _b === void 0 ? void 0 : _b.RoomInformation) === null || _c === void 0 ? void 0 : _c.PerRoomPaxCount,
313
+ guestName: "".concat(BasicInformation.GuestOrGroupNameSingleByte
314
+ || BasicInformation.GuestOrGroupNameKanjiName
315
+ || 'Anonymous').concat(isGroupReservation ? " ".concat(index + 1) : ''),
316
+ externalPlatformCode: SalesOfficeInformation === null || SalesOfficeInformation === void 0 ? void 0 : SalesOfficeInformation.SalesOfficeCode,
317
+ externalPlatformName: (SalesOfficeInformation === null || SalesOfficeInformation === void 0 ? void 0 : SalesOfficeInformation.SalesOfficeCompanyName)
318
+ || (SalesOfficeInformation === null || SalesOfficeInformation === void 0 ? void 0 : SalesOfficeInformation.SalesOfficeName),
319
+ cmsOtaNumber: "".concat(BasicInformation.TravelAgencyBookingNumber).concat(isGroupReservation ? "-v".concat(index + 1) : ''),
320
+ cmsProductName: roomsSortedByDate[0].RoomInformation.RoomTypeName
321
+ || BasicInformation.PackagePlanName,
322
+ platform: tl_lincoln_ota_1.TL_LINCOLN_TO_VENDIT_OTA_MAP[(SalesOfficeInformation === null || SalesOfficeInformation === void 0 ? void 0 : SalesOfficeInformation.SalesOfficeCompanyName) || 'ANONYMOUS'] || (SalesOfficeInformation === null || SalesOfficeInformation === void 0 ? void 0 : SalesOfficeInformation.SalesOfficeCompanyName),
323
+ otaNumber: "".concat(tl_lincoln_ota_1.TL_LINCOLN_TO_VENDIT_OTA_MAP[(SalesOfficeInformation === null || SalesOfficeInformation === void 0 ? void 0 : SalesOfficeInformation.SalesOfficeCompanyName) || 'ANONYMOUS'] || (SalesOfficeInformation === null || SalesOfficeInformation === void 0 ? void 0 : SalesOfficeInformation.SalesOfficeCompanyName), "|").concat((_d = "".concat(BasicInformation.TravelAgencyBookingNumber)) === null || _d === void 0 ? void 0 : _d.slice(-4)),
324
+ externalRoomTypeCode: roomsSortedByDate[0].RoomInformation.NetRmTypeGroupCode,
325
+ externalRoomTypeName: roomsSortedByDate[0].RoomInformation.RoomTypeName,
326
+ type: reservationType,
327
+ phone: formatPhoneNumber("".concat((Member === null || Member === void 0 ? void 0 : Member.UserTel) || Basic.PhoneNumber || '')),
328
+ status: status,
329
+ memoContent: "".concat((Member === null || Member === void 0 ? void 0 : Member.UserKana)
330
+ || (Member === null || Member === void 0 ? void 0 : Member.UserName)
331
+ || "".concat(BasicInformation.GuestOrGroupNameKanjiName), " ").concat(roomsSortedByDate[0].RoomInformation.RoomTypeName
332
+ || BasicInformation.PackagePlanName, "\n").concat((OtherInfo === null || OtherInfo === void 0 ? void 0 : OtherInfo.GuestRequest)
333
+ ? "[\uC694\uCCAD\uC0AC\uD56D]\n".concat(OtherInfo.GuestRequest)
334
+ : '', "\n").concat((OtherInfo === null || OtherInfo === void 0 ? void 0 : OtherInfo.AdditionalInformation)
335
+ ? "[\uCD94\uAC00\uC815\uBCF4]\n".concat(OtherInfo.AdditionalInformation)
336
+ : '', "\n[\uC778\uC6D0\uC815\uBCF4]\n").concat((0, exports.formattedPaxCountText)(roomsSortedByDate[0].RoomInformation), "\n").concat((OptionList === null || OptionList === void 0 ? void 0 : OptionList.length) > 0
337
+ ? "[\uC635\uC158]\n".concat(OptionList.map(function (option) { return "".concat(option.Name, ": ").concat(option.OptionCount, "(").concat(option.OptionDate, ")"); }).join('\n'))
338
+ : ''),
339
+ paymentInfo: Object.assign(paymentInfo, !isFullyPaid && {
340
+ amount: (DepositList === null || DepositList === void 0 ? void 0 : DepositList.reduce(function (acc, deposit) { return acc + ((deposit === null || deposit === void 0 ? void 0 : deposit.DepositAmount) || 0); }, 0)) || 0,
341
+ isFullyPaid: false,
342
+ outstandingAmount: paymentInfo.amount
343
+ - ((DepositList === null || DepositList === void 0 ? void 0 : DepositList.reduce(function (acc, deposit) { return acc + ((deposit === null || deposit === void 0 ? void 0 : deposit.DepositAmount) || 0); }, 0)) || 0),
344
+ }),
345
+ };
346
+ }),
347
+ rawData: JSON.stringify(infoTravelXML),
348
+ };
349
+ };
350
+ exports.refineReservationData = refineReservationData;
351
+ var withAsyncBandwidth = function (array, asyncMapper, _a) {
352
+ var _b = _a === void 0 ? {} : _a, _c = _b.bandwidth, bandwidth = _c === void 0 ? 5 : _c;
353
+ if (bandwidth < 2)
354
+ throw new Error('Bandwidth must bigger than 1');
355
+ var entries = __spreadArray([], array, true);
356
+ var chainedResponses = new Array(bandwidth)
357
+ .fill(undefined)
358
+ .map(function () { return new Promise(function (resolve) { return resolve(); }); });
359
+ var iterator = 0;
360
+ var index = 0;
361
+ var _loop_1 = function () {
362
+ var currentEntry = entries.pop();
363
+ var currentIndex = index;
364
+ var beforeResponse = chainedResponses[iterator];
365
+ chainedResponses[iterator] = beforeResponse.then(function () {
366
+ return asyncMapper(currentEntry, currentIndex);
367
+ });
368
+ index += 1;
369
+ if (iterator < bandwidth - 1) {
370
+ iterator += 1;
371
+ }
372
+ else {
373
+ iterator = 0;
374
+ }
375
+ };
376
+ while (entries.length) {
377
+ _loop_1();
378
+ }
379
+ return chainedResponses;
380
+ };
381
+ exports.withAsyncBandwidth = withAsyncBandwidth;