@hyper.software/common-helpers 1.0.29 → 1.0.31

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 (239) hide show
  1. package/README.md +0 -0
  2. package/lib/errors/CriticalError.d.ts +0 -0
  3. package/lib/errors/CriticalError.js +0 -0
  4. package/lib/errors/CriticalError.js.map +0 -0
  5. package/lib/errors/ValidationError.d.ts +0 -0
  6. package/lib/errors/ValidationError.js +0 -0
  7. package/lib/errors/ValidationError.js.map +0 -0
  8. package/lib/errors/ValidationErrorSilent.d.ts +0 -0
  9. package/lib/errors/ValidationErrorSilent.js +0 -0
  10. package/lib/errors/ValidationErrorSilent.js.map +0 -0
  11. package/lib/errors/ValidationErrorWithStatus.d.ts +0 -0
  12. package/lib/errors/ValidationErrorWithStatus.js +0 -0
  13. package/lib/errors/ValidationErrorWithStatus.js.map +0 -0
  14. package/lib/errors/ValidationErrorWithStatusSilent.d.ts +0 -0
  15. package/lib/errors/ValidationErrorWithStatusSilent.js +0 -0
  16. package/lib/errors/ValidationErrorWithStatusSilent.js.map +0 -0
  17. package/lib/errors/__mocks__/errors.mock.d.ts +0 -0
  18. package/lib/errors/__mocks__/errors.mock.js +0 -0
  19. package/lib/errors/__mocks__/errors.mock.js.map +0 -0
  20. package/lib/errors/__tests__/errorMappers.test.d.ts +0 -0
  21. package/lib/errors/__tests__/errorMappers.test.js +0 -0
  22. package/lib/errors/__tests__/errorMappers.test.js.map +0 -0
  23. package/lib/errors/__tests__/errors.test.d.ts +0 -0
  24. package/lib/errors/__tests__/errors.test.js +0 -0
  25. package/lib/errors/__tests__/errors.test.js.map +0 -0
  26. package/lib/errors/errorMappers.d.ts +0 -0
  27. package/lib/errors/errorMappers.js +0 -0
  28. package/lib/errors/errorMappers.js.map +0 -0
  29. package/lib/errors/errors.types.d.ts +0 -0
  30. package/lib/errors/errors.types.js +0 -0
  31. package/lib/errors/errors.types.js.map +0 -0
  32. package/lib/errors/index.d.ts +0 -0
  33. package/lib/errors/index.js +0 -0
  34. package/lib/errors/index.js.map +0 -0
  35. package/lib/express/__tests__/swaggerHelpers.test.d.ts +0 -0
  36. package/lib/express/__tests__/swaggerHelpers.test.js +0 -0
  37. package/lib/express/__tests__/swaggerHelpers.test.js.map +0 -0
  38. package/lib/express/middleware/aliveMiddleware/index.d.ts +0 -0
  39. package/lib/express/middleware/aliveMiddleware/index.js +0 -0
  40. package/lib/express/middleware/aliveMiddleware/index.js.map +0 -0
  41. package/lib/express/middleware/companyMiddleware/company.d.ts +0 -0
  42. package/lib/express/middleware/companyMiddleware/company.js +0 -0
  43. package/lib/express/middleware/companyMiddleware/company.js.map +0 -0
  44. package/lib/express/middleware/companyMiddleware/companyApiRequest.d.ts +0 -0
  45. package/lib/express/middleware/companyMiddleware/companyApiRequest.js +0 -0
  46. package/lib/express/middleware/companyMiddleware/companyApiRequest.js.map +0 -0
  47. package/lib/express/middleware/companyMiddleware/index.d.ts +0 -0
  48. package/lib/express/middleware/companyMiddleware/index.js +0 -0
  49. package/lib/express/middleware/companyMiddleware/index.js.map +0 -0
  50. package/lib/express/middleware/companyMiddleware/index.types.d.ts +0 -0
  51. package/lib/express/middleware/companyMiddleware/index.types.js +0 -0
  52. package/lib/express/middleware/companyMiddleware/index.types.js.map +0 -0
  53. package/lib/express/middleware/expressErrorHandlerMiddleware/__tests__/expressErrorHandlerMiddleware.test.d.ts +0 -0
  54. package/lib/express/middleware/expressErrorHandlerMiddleware/__tests__/expressErrorHandlerMiddleware.test.js +0 -0
  55. package/lib/express/middleware/expressErrorHandlerMiddleware/__tests__/expressErrorHandlerMiddleware.test.js.map +0 -0
  56. package/lib/express/middleware/expressErrorHandlerMiddleware/index.d.ts +0 -0
  57. package/lib/express/middleware/expressErrorHandlerMiddleware/index.js +0 -0
  58. package/lib/express/middleware/expressErrorHandlerMiddleware/index.js.map +0 -0
  59. package/lib/express/middleware/index.d.ts +0 -0
  60. package/lib/express/middleware/index.js +0 -0
  61. package/lib/express/middleware/index.js.map +0 -0
  62. package/lib/express/middleware/languageMiddleware/index.d.ts +0 -0
  63. package/lib/express/middleware/languageMiddleware/index.js +0 -0
  64. package/lib/express/middleware/languageMiddleware/index.js.map +0 -0
  65. package/lib/express/middleware/partnerMiddleware/index.d.ts +0 -0
  66. package/lib/express/middleware/partnerMiddleware/index.js +0 -0
  67. package/lib/express/middleware/partnerMiddleware/index.js.map +0 -0
  68. package/lib/express/middleware/partnerMiddleware/index.types.d.ts +0 -0
  69. package/lib/express/middleware/partnerMiddleware/index.types.js +0 -0
  70. package/lib/express/middleware/partnerMiddleware/index.types.js.map +0 -0
  71. package/lib/express/middleware/partnerMiddleware/partner.d.ts +0 -0
  72. package/lib/express/middleware/partnerMiddleware/partner.js +0 -0
  73. package/lib/express/middleware/partnerMiddleware/partner.js.map +0 -0
  74. package/lib/express/middleware/partnerMiddleware/partnerServiceRequest.d.ts +0 -0
  75. package/lib/express/middleware/partnerMiddleware/partnerServiceRequest.js +0 -0
  76. package/lib/express/middleware/partnerMiddleware/partnerServiceRequest.js.map +0 -0
  77. package/lib/express/middleware/responseHelpersMiddleware/index.d.ts +0 -0
  78. package/lib/express/middleware/responseHelpersMiddleware/index.js +0 -0
  79. package/lib/express/middleware/responseHelpersMiddleware/index.js.map +0 -0
  80. package/lib/express/middleware/responseHelpersMiddleware/types.d.ts +0 -0
  81. package/lib/express/middleware/responseHelpersMiddleware/types.js +0 -0
  82. package/lib/express/middleware/responseHelpersMiddleware/types.js.map +0 -0
  83. package/lib/express/middleware/translationsMiddleware/index.d.ts +0 -0
  84. package/lib/express/middleware/translationsMiddleware/index.js +0 -0
  85. package/lib/express/middleware/translationsMiddleware/index.js.map +0 -0
  86. package/lib/express/swaggerControllersConfig.d.ts +0 -0
  87. package/lib/express/swaggerControllersConfig.js +0 -0
  88. package/lib/express/swaggerControllersConfig.js.map +0 -0
  89. package/lib/express/swaggerHelpers.d.ts +0 -0
  90. package/lib/express/swaggerHelpers.js +0 -0
  91. package/lib/express/swaggerHelpers.js.map +0 -0
  92. package/lib/express/swaggerUiController.d.ts +0 -0
  93. package/lib/express/swaggerUiController.js +0 -0
  94. package/lib/express/swaggerUiController.js.map +0 -0
  95. package/lib/express/swaggerUiTemplate.d.ts +0 -0
  96. package/lib/express/swaggerUiTemplate.js +0 -0
  97. package/lib/express/swaggerUiTemplate.js.map +0 -0
  98. package/lib/helpers/ExecuteOnce.d.ts +0 -0
  99. package/lib/helpers/ExecuteOnce.js +0 -0
  100. package/lib/helpers/ExecuteOnce.js.map +0 -0
  101. package/lib/helpers/UniversalConfig.d.ts +0 -0
  102. package/lib/helpers/UniversalConfig.js +0 -0
  103. package/lib/helpers/UniversalConfig.js.map +0 -0
  104. package/lib/helpers/__tests__/arrays.test.d.ts +0 -0
  105. package/lib/helpers/__tests__/arrays.test.js +0 -0
  106. package/lib/helpers/__tests__/arrays.test.js.map +0 -0
  107. package/lib/helpers/__tests__/emptyValues.test.d.ts +0 -0
  108. package/lib/helpers/__tests__/emptyValues.test.js +0 -0
  109. package/lib/helpers/__tests__/emptyValues.test.js.map +0 -0
  110. package/lib/helpers/__tests__/formatters.formatCurrency.test.d.ts +0 -0
  111. package/lib/helpers/__tests__/formatters.formatCurrency.test.js +0 -0
  112. package/lib/helpers/__tests__/formatters.formatCurrency.test.js.map +0 -0
  113. package/lib/helpers/__tests__/formatters.formatDate.test.d.ts +0 -0
  114. package/lib/helpers/__tests__/formatters.formatDate.test.js +0 -0
  115. package/lib/helpers/__tests__/formatters.formatDate.test.js.map +0 -0
  116. package/lib/helpers/__tests__/formatters.formatDouble.test.d.ts +0 -0
  117. package/lib/helpers/__tests__/formatters.formatDouble.test.js +0 -0
  118. package/lib/helpers/__tests__/formatters.formatDouble.test.js.map +0 -0
  119. package/lib/helpers/__tests__/navigation.test.d.ts +0 -0
  120. package/lib/helpers/__tests__/navigation.test.js +0 -0
  121. package/lib/helpers/__tests__/navigation.test.js.map +0 -0
  122. package/lib/helpers/__tests__/strings.test.d.ts +0 -0
  123. package/lib/helpers/__tests__/strings.test.js +0 -0
  124. package/lib/helpers/__tests__/strings.test.js.map +0 -0
  125. package/lib/helpers/__tests__/validation.test.d.ts +0 -0
  126. package/lib/helpers/__tests__/validation.test.js +0 -0
  127. package/lib/helpers/__tests__/validation.test.js.map +0 -0
  128. package/lib/helpers/arrays.d.ts +0 -0
  129. package/lib/helpers/arrays.js +0 -0
  130. package/lib/helpers/arrays.js.map +0 -0
  131. package/lib/helpers/clientLogger.d.ts +0 -0
  132. package/lib/helpers/clientLogger.js +0 -0
  133. package/lib/helpers/clientLogger.js.map +0 -0
  134. package/lib/helpers/constants/common.d.ts +0 -0
  135. package/lib/helpers/constants/common.js +0 -0
  136. package/lib/helpers/constants/common.js.map +0 -0
  137. package/lib/helpers/constants/fileUploads.d.ts +0 -0
  138. package/lib/helpers/constants/fileUploads.js +0 -0
  139. package/lib/helpers/constants/fileUploads.js.map +0 -0
  140. package/lib/helpers/constants/index.d.ts +0 -0
  141. package/lib/helpers/constants/index.js +0 -0
  142. package/lib/helpers/constants/index.js.map +0 -0
  143. package/lib/helpers/constants/integrations.d.ts +0 -0
  144. package/lib/helpers/constants/integrations.js +0 -0
  145. package/lib/helpers/constants/integrations.js.map +0 -0
  146. package/lib/helpers/constants/language.d.ts +0 -0
  147. package/lib/helpers/constants/language.js +0 -0
  148. package/lib/helpers/constants/language.js.map +0 -0
  149. package/lib/helpers/constants/swagger.d.ts +0 -0
  150. package/lib/helpers/constants/swagger.js +0 -0
  151. package/lib/helpers/constants/swagger.js.map +0 -0
  152. package/lib/helpers/constants/urls.d.ts +0 -0
  153. package/lib/helpers/constants/urls.js +0 -0
  154. package/lib/helpers/constants/urls.js.map +0 -0
  155. package/lib/helpers/constants/user.d.ts +0 -0
  156. package/lib/helpers/constants/user.js +0 -0
  157. package/lib/helpers/constants/user.js.map +0 -0
  158. package/lib/helpers/constants/validators.d.ts +0 -0
  159. package/lib/helpers/constants/validators.js +0 -0
  160. package/lib/helpers/constants/validators.js.map +0 -0
  161. package/lib/helpers/emptyValues.d.ts +0 -0
  162. package/lib/helpers/emptyValues.js +0 -0
  163. package/lib/helpers/emptyValues.js.map +0 -0
  164. package/lib/helpers/formatters.d.ts +0 -0
  165. package/lib/helpers/formatters.js +0 -0
  166. package/lib/helpers/formatters.js.map +0 -0
  167. package/lib/helpers/guards.d.ts +0 -0
  168. package/lib/helpers/guards.js +0 -0
  169. package/lib/helpers/guards.js.map +0 -0
  170. package/lib/helpers/index.d.ts +0 -0
  171. package/lib/helpers/index.js +0 -0
  172. package/lib/helpers/index.js.map +0 -0
  173. package/lib/helpers/isBrowser.d.ts +0 -0
  174. package/lib/helpers/isBrowser.js +0 -0
  175. package/lib/helpers/isBrowser.js.map +0 -0
  176. package/lib/helpers/math.d.ts +0 -0
  177. package/lib/helpers/math.js +0 -0
  178. package/lib/helpers/math.js.map +0 -0
  179. package/lib/helpers/moment.d.ts +0 -0
  180. package/lib/helpers/moment.js +0 -0
  181. package/lib/helpers/moment.js.map +0 -0
  182. package/lib/helpers/navigation.d.ts +0 -0
  183. package/lib/helpers/navigation.js +0 -0
  184. package/lib/helpers/navigation.js.map +0 -0
  185. package/lib/helpers/stringifySafe.d.ts +0 -0
  186. package/lib/helpers/stringifySafe.js +0 -0
  187. package/lib/helpers/stringifySafe.js.map +0 -0
  188. package/lib/helpers/strings.d.ts +0 -0
  189. package/lib/helpers/strings.js +0 -0
  190. package/lib/helpers/strings.js.map +0 -0
  191. package/lib/helpers/validation.d.ts +0 -0
  192. package/lib/helpers/validation.js +0 -0
  193. package/lib/helpers/validation.js.map +0 -0
  194. package/lib/index.d.ts +0 -0
  195. package/lib/index.js +0 -0
  196. package/lib/index.js.map +0 -0
  197. package/lib/interfaces.d.ts +0 -0
  198. package/lib/interfaces.js +0 -0
  199. package/lib/interfaces.js.map +0 -0
  200. package/lib/redux/analyticsMiddleware.d.ts +0 -0
  201. package/lib/redux/analyticsMiddleware.js +0 -0
  202. package/lib/redux/analyticsMiddleware.js.map +0 -0
  203. package/lib/redux/clientMiddleware.d.ts +0 -0
  204. package/lib/redux/clientMiddleware.js +0 -0
  205. package/lib/redux/clientMiddleware.js.map +0 -0
  206. package/lib/redux/emptyMiddleware.d.ts +0 -0
  207. package/lib/redux/emptyMiddleware.js +0 -0
  208. package/lib/redux/emptyMiddleware.js.map +0 -0
  209. package/lib/redux/index.d.ts +0 -0
  210. package/lib/redux/index.js +0 -0
  211. package/lib/redux/index.js.map +0 -0
  212. package/lib/services/bookingService/bookingsServices.d.ts +17 -0
  213. package/lib/services/bookingService/bookingsServices.js +100 -0
  214. package/lib/services/bookingService/bookingsServices.js.map +1 -0
  215. package/lib/services/cookieService/cookieService.d.ts +0 -0
  216. package/lib/services/cookieService/cookieService.js +0 -0
  217. package/lib/services/cookieService/cookieService.js.map +0 -0
  218. package/lib/services/googleAnalyticsService/googleAnalyticsService.d.ts +0 -0
  219. package/lib/services/googleAnalyticsService/googleAnalyticsService.js +0 -0
  220. package/lib/services/googleAnalyticsService/googleAnalyticsService.js.map +0 -0
  221. package/lib/services/imageService/imageService.d.ts +0 -0
  222. package/lib/services/imageService/imageService.js +0 -0
  223. package/lib/services/imageService/imageService.js.map +0 -0
  224. package/lib/services/index.d.ts +0 -0
  225. package/lib/services/index.js +0 -0
  226. package/lib/services/index.js.map +0 -0
  227. package/lib/services/languageService/languageService.d.ts +0 -0
  228. package/lib/services/languageService/languageService.js +0 -0
  229. package/lib/services/languageService/languageService.js.map +0 -0
  230. package/lib/services/localstorageService/localstorageService.d.ts +0 -0
  231. package/lib/services/localstorageService/localstorageService.js +0 -0
  232. package/lib/services/localstorageService/localstorageService.js.map +0 -0
  233. package/lib/services/sessionStorageService/index.d.ts +0 -0
  234. package/lib/services/sessionStorageService/index.js +0 -0
  235. package/lib/services/sessionStorageService/index.js.map +0 -0
  236. package/lib/translations/getAllTranslations.d.ts +0 -0
  237. package/lib/translations/getAllTranslations.js +0 -0
  238. package/lib/translations/getAllTranslations.js.map +0 -0
  239. package/package.json +2 -1
package/README.md CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/lib/index.d.ts CHANGED
File without changes
package/lib/index.js CHANGED
File without changes
package/lib/index.js.map CHANGED
File without changes
File without changes
package/lib/interfaces.js CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,17 @@
1
+ import moment, { Moment } from 'moment';
2
+ import { IRoom, IRoomBooking, IRoomTypePricePlanPricingInformation, IRoomTypePricePlanPricingRules } from '@hyper.software/common-models/lib/interfaces';
3
+ export declare const getTotalCostForRoomBooking: (roomBooking: IRoomBooking & {
4
+ pricingRules?: IRoomTypePricePlanPricingRules;
5
+ pricingInformation?: Partial<IRoomTypePricePlanPricingInformation>;
6
+ }, checkinDate: moment.Moment, checkoutDate: moment.Moment, numberOfAdults: any) => number;
7
+ export declare const getTotalCost: (roomBookings: Array<{
8
+ roomId?: string;
9
+ breakfastIncluded?: boolean;
10
+ pricingInformation?: Partial<IRoomTypePricePlanPricingInformation>;
11
+ pricingRules?: IRoomTypePricePlanPricingRules;
12
+ personsPayingBreakfast?: number;
13
+ room?: IRoom;
14
+ }>, _checkinDate: moment.Moment, _checkoutDate: moment.Moment, numberOfAdults: number) => number;
15
+ export declare const ensureValueIsNumber: (value: string | number, isDouble?: boolean) => number | null;
16
+ export declare const removeInvalidCharacters: (value: string, isDouble: boolean) => string;
17
+ export declare const normalizeDate: (date: Date | Moment | string | null) => Moment | null;
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.normalizeDate = exports.removeInvalidCharacters = exports.ensureValueIsNumber = exports.getTotalCost = exports.getTotalCostForRoomBooking = void 0;
7
+ var moment_1 = __importDefault(require("moment"));
8
+ var helpers_1 = require("../../helpers");
9
+ var interfaces_1 = require("@hyper.software/common-models/lib/interfaces");
10
+ var getTotalCostForRoomBooking = function (roomBooking, checkinDate, checkoutDate, numberOfAdults) {
11
+ var _a, _b, _c;
12
+ if (!roomBooking) {
13
+ return 0;
14
+ }
15
+ var totalCost = 0;
16
+ var maxNumberOfAdults = ((_b = (_a = roomBooking === null || roomBooking === void 0 ? void 0 : roomBooking.room) === null || _a === void 0 ? void 0 : _a.roomType) === null || _b === void 0 ? void 0 : _b.maxNumberOfAdults) || ((_c = roomBooking === null || roomBooking === void 0 ? void 0 : roomBooking.roomType) === null || _c === void 0 ? void 0 : _c.maxNumberOfAdults);
17
+ var actualNumberOfAdults = roomBooking.personsPayingBreakfast || numberOfAdults;
18
+ var shouldIncreasePrice = actualNumberOfAdults > maxNumberOfAdults;
19
+ var adjustmentFactor = shouldIncreasePrice ? 1 : -1;
20
+ var applicablePricingRules = (roomBooking.pricingRules || []).filter(function (pricingRule) { return pricingRule.active; });
21
+ var discountOrIncrease = (roomBooking.pricingRules || [])
22
+ .filter(function (pricingRule) { return pricingRule.active && !!pricingRule.value && !!pricingRule.type; })
23
+ .find(function (pricingRule) { return pricingRule.numberOfAdults === actualNumberOfAdults; });
24
+ if (!discountOrIncrease) {
25
+ discountOrIncrease =
26
+ applicablePricingRules.length > 0
27
+ ? applicablePricingRules.reduce(function (lastRule, currentRule) {
28
+ return currentRule.numberOfAdults > lastRule.numberOfAdults ? currentRule : lastRule;
29
+ })
30
+ : null;
31
+ }
32
+ var cost = roomBooking.pricePerNight ||
33
+ (0, exports.ensureValueIsNumber)(roomBooking.pricingInformation[checkinDate.format(helpers_1.DATE_FORMATS.YYYY_MM_DD)]);
34
+ var calculation = actualNumberOfAdults === maxNumberOfAdults || !(discountOrIncrease === null || discountOrIncrease === void 0 ? void 0 : discountOrIncrease.value)
35
+ ? cost
36
+ : (discountOrIncrease === null || discountOrIncrease === void 0 ? void 0 : discountOrIncrease.type) === interfaces_1.DISCOUNT_TYPE.PERCENTAGE
37
+ ? ((100 + (discountOrIncrease === null || discountOrIncrease === void 0 ? void 0 : discountOrIncrease.value) * adjustmentFactor) / 100) * cost || 0
38
+ : cost + (discountOrIncrease === null || discountOrIncrease === void 0 ? void 0 : discountOrIncrease.value) * adjustmentFactor;
39
+ while (checkoutDate.diff(checkinDate, 'days') > 0) {
40
+ totalCost += calculation;
41
+ checkinDate.add(1, 'days');
42
+ }
43
+ return totalCost;
44
+ };
45
+ exports.getTotalCostForRoomBooking = getTotalCostForRoomBooking;
46
+ var getTotalCost = function (roomBookings, _checkinDate, _checkoutDate, numberOfAdults) {
47
+ if (!_checkinDate || !_checkoutDate) {
48
+ return null;
49
+ }
50
+ var checkinDate = (0, moment_1.default)((0, exports.normalizeDate)(_checkinDate));
51
+ var checkoutDate = (0, moment_1.default)((0, exports.normalizeDate)(_checkoutDate));
52
+ var totalCost = 0;
53
+ for (var _i = 0, roomBookings_1 = roomBookings; _i < roomBookings_1.length; _i++) {
54
+ var roomBooking = roomBookings_1[_i];
55
+ var costForRoomBooking = (0, exports.getTotalCostForRoomBooking)(roomBooking, (0, moment_1.default)(checkinDate.toISOString()), (0, moment_1.default)(checkoutDate.toISOString()), roomBooking.personsPayingBreakfast || numberOfAdults);
56
+ totalCost += costForRoomBooking;
57
+ }
58
+ return totalCost;
59
+ };
60
+ exports.getTotalCost = getTotalCost;
61
+ var ensureValueIsNumber = function (value, isDouble) {
62
+ if (isDouble === void 0) { isDouble = true; }
63
+ if ((0, helpers_1.isEmpty)(value)) {
64
+ return null;
65
+ }
66
+ if (typeof value === 'number') {
67
+ return value;
68
+ }
69
+ if (value === '-') {
70
+ return null;
71
+ }
72
+ if (!isNaN(parseFloat((0, exports.removeInvalidCharacters)(value, isDouble)))) {
73
+ return parseFloat((0, exports.removeInvalidCharacters)(value, isDouble));
74
+ }
75
+ return null;
76
+ };
77
+ exports.ensureValueIsNumber = ensureValueIsNumber;
78
+ var removeInvalidCharacters = function (value, isDouble) {
79
+ var valWithNoInvalidChars = (value || '')
80
+ .replace(/[^0-9,.-]/g, '')
81
+ .replace(/(?!^)-/g, '')
82
+ .replace(/\./g, '');
83
+ if (isDouble) {
84
+ return valWithNoInvalidChars.replace(/,/g, '.');
85
+ }
86
+ return valWithNoInvalidChars.replace(/,/g, '');
87
+ };
88
+ exports.removeInvalidCharacters = removeInvalidCharacters;
89
+ var normalizeDate = function (date) {
90
+ if (!date) {
91
+ return null;
92
+ }
93
+ return (0, moment_1.default)(date).set({
94
+ hour: 18,
95
+ minute: 0,
96
+ second: 0,
97
+ });
98
+ };
99
+ exports.normalizeDate = normalizeDate;
100
+ //# sourceMappingURL=bookingsServices.js.map
@@ -0,0 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KAAK,EAAE,QAAQ,CAAC,CAAC,CAAA;KAC5D;IAED,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAlBY,QAAA,mBAAmB,uBAkB/B;AAEM,IAAM,uBAAuB,GAAG,UAAC,KAAa,EAAE,QAAiB;IACtE,IAAM,qBAAqB,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC;SACxC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC;SACzB,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC;SACtB,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;IAErB,IAAI,QAAQ,EAAE;QACZ,OAAO,qBAAqB,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;KAChD;IAED,OAAO,qBAAqB,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAA;AAChD,CAAC,CAAA;AAXY,QAAA,uBAAuB,2BAWnC;AAEM,IAAM,aAAa,GAAG,UAAC,IAAmC;IAC/D,IAAI,CAAC,IAAI,EAAE;QACT,OAAO,IAAI,CAAA;KACZ;IAED,OAAO,IAAA,gBAAM,EAAC,IAAI,CAAC,CAAC,GAAG,CAAC;QACtB,IAAI,EAAE,EAAE;QACR,MAAM,EAAE,CAAC;QACT,MAAM,EAAE,CAAC;KACV,CAAC,CAAA;AACJ,CAAC,CAAA;AAVY,QAAA,aAAa,iBAUzB"}
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyper.software/common-helpers",
3
- "version": "1.0.29",
3
+ "version": "1.0.31",
4
4
  "author": "Raul Tomescu <tomescu.raul+hyper@gmail.com>",
5
5
  "description": "Hyper Software Common Javascript Helpers",
6
6
  "main": "lib/index.js",
@@ -35,6 +35,7 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "@babel/preset-env": "^7.23.3",
38
+ "@hyper.software/common-models": "^2.0.17",
38
39
  "@hyper.software/tslint-config": "^1.0.1",
39
40
  "@sentry/types": "^7.77.0",
40
41
  "@types/cookie": "^0.5.3",