@roomstay/core 0.1.50-0 → 0.1.50
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.
- package/dist/index.d.ts +0 -0
- package/dist/node.js +1 -1
- package/dist/types/Addon/Addon.enum.d.ts +14 -0
- package/dist/types/Addon/Addon.type.d.ts +24 -0
- package/dist/types/Api/Reservations.type.d.ts +102 -0
- package/dist/types/Api/RoomNightRate.type.d.ts +7 -0
- package/dist/types/Booking/IBookingCreateErrorResponse.d.ts +0 -0
- package/dist/types/Booking/IBookingPayment.type.d.ts +0 -0
- package/dist/types/Booking/IBookingQuote.type.d.ts +0 -0
- package/dist/types/Booking/IBookingStatus.type.d.ts +0 -0
- package/dist/types/Booking/ICheckoutBrowserSession.type.d.ts +14 -0
- package/dist/types/Booking/IPrice.type.d.ts +0 -0
- package/dist/types/Company/ECompanyProvider.enum.d.ts +0 -0
- package/dist/types/Company/IAdminCompany.type.d.ts +0 -0
- package/dist/types/Company/IAdminCompanyUser.type.d.ts +0 -0
- package/dist/types/Events/IRoomstayEvent.type.d.ts +0 -0
- package/dist/types/General/HttpMethod.enum.d.ts +0 -0
- package/dist/types/General/IJsonString.type.d.ts +6 -0
- package/dist/types/Hotel/EHotelPriceModel.enum.d.ts +0 -0
- package/dist/types/Hotel/EHotelWeekdayStartsOn.enum.d.ts +0 -0
- package/dist/types/Hotel/IAuxiliaryFilter.type.d.ts +0 -0
- package/dist/types/Hotel/IHotelColorScheme.type.d.ts +0 -0
- package/dist/types/Hotel/IHotelOverrides.type.d.ts +0 -0
- package/dist/types/Hotel/IHotelReplica.type.d.ts +0 -0
- package/dist/types/Hotel/IHotelService.type.d.ts +0 -0
- package/dist/types/Image/IRoomstayImage.type.d.ts +0 -0
- package/dist/types/Member/IRoomstayCognitoMember.type.d.ts +0 -0
- package/dist/types/Member/IRoomstayMember.type.d.ts +0 -0
- package/dist/types/Member/IRoomstayMemberBooking.type.d.ts +0 -0
- package/dist/types/Member/IRoomstayMemberBookingAddress.type.d.ts +0 -0
- package/dist/types/Member/IRoomstayMemberBookingItem.type.d.ts +0 -0
- package/dist/types/Member/IRoomstayMemberBookingProfile.type.d.ts +0 -0
- package/dist/types/Member/IRoomstayMemberCards.type.d.ts +0 -0
- package/dist/types/Member/ISession.type.d.ts +0 -0
- package/dist/types/Policies/EGuaranteePolicy.enum.d.ts +0 -0
- package/dist/types/RMS/ERMSDiscountType.enum.d.ts +0 -0
- package/dist/types/RMS/IRMSPropertyDiscount.type.d.ts +0 -0
- package/dist/types/RMS/IRMSRequirement.type.d.ts +0 -0
- package/dist/types/Room/IRoomGroup.type.d.ts +0 -0
- package/dist/types/index.d.ts +36 -38
- package/dist/utils/TotalCalculator.d.ts +71 -0
- package/dist/utils/bookingTotal.d.ts +0 -0
- package/dist/utils/index.d.ts +0 -0
- package/dist/utils/nameof.d.ts +2 -0
- package/dist/utils/roomstayImageResize.d.ts +0 -0
- package/dist/utils/roundMoney.d.ts +1 -11
- package/dist/utils/uppercaseString.d.ts +0 -0
- package/dist/web.js +1 -1
- package/package.json +1 -1
- package/dist/types/Analytics/IBigQueryResponse.type.d.ts +0 -24
- package/dist/types/Fees/IFeeOptions.type.d.ts +0 -6
- package/dist/utils/feeOptionRules.d.ts +0 -0
package/dist/index.d.ts
CHANGED
|
File without changes
|
package/dist/node.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{"use strict";var e={n:n=>{var o=n&&n.__esModule?()=>n.default:()=>n;return e.d(o,{a:o}),o},d:(n,o)=>{for(var t in o)e.o(o,t)&&!e.o(n,t)&&Object.defineProperty(n,t,{enumerable:!0,get:o[t]})},o:(e,n)=>Object.prototype.hasOwnProperty.call(e,n),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},n={};let o,t,r;e.r(n),e.d(n,{EBookingPaymentMethod:()=>o,ECompanyProvider:()=>c,EDistanceUnitType:()=>
|
|
1
|
+
(()=>{"use strict";var e={n:n=>{var o=n&&n.__esModule?()=>n.default:()=>n;return e.d(o,{a:o}),o},d:(n,o)=>{for(var t in o)e.o(o,t)&&!e.o(n,t)&&Object.defineProperty(n,t,{enumerable:!0,get:o[t]})},o:(e,n)=>Object.prototype.hasOwnProperty.call(e,n),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},n={};let o,t,r;e.r(n),e.d(n,{EBookingPaymentMethod:()=>o,ECompanyProvider:()=>c,EDistanceUnitType:()=>y,EFeeType:()=>C,EGuarantyPolicyPrepaymentType:()=>m,EHotelCardProcessor:()=>t,EHotelPriceModel:()=>u,EHotelStateFieldConfiguration:()=>d,EHotelWeekdayStartsOn:()=>g,EIntegration:()=>l,EPlanpayBookingStatus:()=>r,ERMSDiscountType:()=>P,ERoomstayEventSource:()=>p,ERoomstayImageSize:()=>f,HttpMethod:()=>h,IAuxiliaryFilterType:()=>s,IBookingStatus:()=>i,PCIBookingCardProcessorTypes:()=>a,calculateFeeAmount:()=>F,calculateTotalForMemberBooking:()=>S,getFeeOptionValidity:()=>w,getFilteredBookingAddonFees:()=>N,getFilteredBookingFees:()=>M,getFilteredBookingRateFees:()=>D,nameof:()=>R,resizeRoomstayImageUrl:()=>O,roundMoney:()=>A,subset:()=>E,uppercaseString:()=>T}),function(e){e.Card="Card",e.SavedCard="SavedCard",e.Planpay="Planpay",e.Adyen="Adyen",e.Afterpay="Afterpay",e.PCIBookingCard="PCIBookingCard"}(o||(o={})),function(e){e.Passthrough="Passthrough",e.Adyen="Adyen",e.Till="Till",e.RMSPay="RMSPay",e.Windcave="Windcave"}(t||(t={})),function(e){e.Unknown="unknown",e.Unpaid="unpaid",e.Accepted="accepted",e.Cancelled="cancelled",e.Refunded="refunded",e.Rejected="rejected"}(r||(r={}));const a=[];let i,c,u,d,g,l,s,y,P,f,m,p,h,C;function T(e){return e.toUpperCase()}!function(e){e.Pending="Pending",e.Committed="Committed",e.Cancelled="Cancelled"}(i||(i={})),function(e){e.Synxis="Synxis",e.Availpro="Availpro",e.RMS="RMS",e.Siteminder="Siteminder",e.Roomstay="Roomstay"}(c||(c={})),function(e){e.PerPerson="PerPerson",e.PerDay="PerDay",e.PerOccupancy="PerOccupancy"}(u||(u={})),function(e){e.NotIncluded="NotIncluded",e.Optional="Optional",e.Required="Required"}(d||(d={})),function(e){e.Monday="monday",e.Sunday="sunday"}(g||(g={})),function(e){e.Big4="Big4",e.RmsTop10="Top10",e.Top10="NewTop10",e.Gday="Gday",e.Salesforce="Salesforce"}(l||(l={})),function(e){e.AreaDwellingLength="AreaDwellingLength",e.AreaDwellingType="AreaDwellingType"}(s||(s={})),function(e){e.Metric="metric",e.Imperial="imperial"}(y||(y={})),function(e){e.Percentage="Percentage",e.Amount="Amount",e.Bogo="BOGO",e.NightlyRateOverride="NightlyRateOverride"}(P||(P={})),function(e){e[e.Icon=128]="Icon",e[e.Tiny=256]="Tiny",e[e.Small=512]="Small",e[e.Medium=768]="Medium",e[e.Large=1024]="Large",e[e.ExtraLarge=1600]="ExtraLarge"}(f||(f={})),function(e){e.FixedAmount="fixed",e.Percentage="percentage",e.Nights="nights"}(m||(m={})),function(e){e.Eventbrite="eventbrite",e.ATDW="atdw"}(p||(p={})),function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.DELETE="DELETE",e.PATCH="PATCH",e.OPTIONS="OPTIONS",e.HEAD="HEAD"}(h||(h={})),function(e){e.PercentageOfBooking="PercentageOfBooking",e.FixedChargePerRoom="FixedChargePerRoom",e.NightlyChargePerRoom="NightlyChargePerRoom",e.FixedChargePerBooking="FixedChargePerBooking",e.DepositSurcharge="DepositSurcharge"}(C||(C={}));const S=e=>{let n=0;const o=Object.values(e.itinerary);for(const e of o){const o=Object.keys(e.nights);for(const t of o)n+=e.nights[t].total}return n},O=(e,n)=>e.includes("cdn.app.roomstay.io")?e+"?w="+n:e,R=e=>e,E=(e,n)=>{const o={};return n.forEach((n=>{n in e&&(o[n]=e[n])})),o},B=require("decimal.js");var k=e.n(B);const A=e=>new(k())(e).toDecimalPlaces(2).toNumber();function F(e,n={}){const{baseAmount:o=0,numberOfNights:t=1,feeIncludedInBaseAmount:r=!1,extractedFromRates:a=!1,removedPercentages:i=[]}=n,c=A(o);switch(e.feeType){case C.PercentageOfBooking:if(r)return A(c*e.amount/(100+e.amount));if(a){const n=i.reduce(((e,n)=>e+n/(100+n)),0);return A(c/(1-n)*e.amount/(100+e.amount))}return A(c*(e.amount/100));case C.FixedChargePerRoom:case C.FixedChargePerBooking:return e.amount;case C.NightlyChargePerRoom:return A(e.amount*t);default:return 0}}const v=[C.FixedChargePerBooking],I=[C.PercentageOfBooking,C.FixedChargePerRoom,C.NightlyChargePerRoom],x=[C.PercentageOfBooking];function b(e,n){return e.filter((e=>n.includes(e.feeType)))}function M(e){return b(e,v)}function D(e){return b(e,I)}function N(e){return b(e,x)}function w(e){return{includeInRates:[C.PercentageOfBooking,C.NightlyChargePerRoom].includes(e),extractFeeFromRates:e===C.PercentageOfBooking,appliesToAddons:e===C.PercentageOfBooking,includePreviousFeesInCalculation:e===C.PercentageOfBooking}}module.exports=n})();
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare enum AddonPricingType {
|
|
2
|
+
PER_STAY = "Per stay",
|
|
3
|
+
PER_NIGHT = "Per night",
|
|
4
|
+
PER_PERSON = "Per person",
|
|
5
|
+
PER_PERSON_PER_NIGHT = "Per person per night",
|
|
6
|
+
PER_ALL_PERSONS = "Per all persons",
|
|
7
|
+
PER_ALL_PERSONS_PER_NIGHT = "Per all persons per night",
|
|
8
|
+
PER_QUANTITY_NAME_PER_NIGHT = "Per Quantity Name Per Night",
|
|
9
|
+
PER_ROOM_QUANTITY_PER_NIGHT = "Per Room Quantity Per Night",
|
|
10
|
+
PER_PERSON_OCCUPANCY_PER_NIGHT = "Per Person Occupancy Per Night",
|
|
11
|
+
PER_ADULT_OCCUPANCY_PER_NIGHT = "Per Adult Occupancy Per Night",
|
|
12
|
+
PER_CHILD_OCCUPANCY_PER_NIGHT = "Per Child Occupancy Per Night"
|
|
13
|
+
}
|
|
14
|
+
export declare const ADDON_PER_NIGHT_TYPES: AddonPricingType[];
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { SimpleItemisedFee } from "types/Fees/IFee.type";
|
|
2
|
+
export type BasketAddonDTO = {
|
|
3
|
+
availability: any;
|
|
4
|
+
code: string;
|
|
5
|
+
inclusive: false;
|
|
6
|
+
pricingType: string;
|
|
7
|
+
quantity: number;
|
|
8
|
+
adultQuantity: number;
|
|
9
|
+
childQuantity?: number;
|
|
10
|
+
description: string;
|
|
11
|
+
name: string;
|
|
12
|
+
category: string;
|
|
13
|
+
image: string;
|
|
14
|
+
price: number;
|
|
15
|
+
adultPrice?: number;
|
|
16
|
+
childPrice?: number;
|
|
17
|
+
fee: number;
|
|
18
|
+
adultFee?: number;
|
|
19
|
+
childFee?: number;
|
|
20
|
+
fees?: SimpleItemisedFee[];
|
|
21
|
+
adultFees?: SimpleItemisedFee[];
|
|
22
|
+
childFees?: SimpleItemisedFee[];
|
|
23
|
+
nights?: number;
|
|
24
|
+
};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { RoomNightRateDTO } from "types/Api/RoomNightRate.type";
|
|
2
|
+
import { EBookingPaymentMethod } from "types/Booking/IBookingPayment.type";
|
|
3
|
+
import { SimpleItemisedFee } from "types/Fees/IFee.type";
|
|
4
|
+
export type ReservationsDTO = {
|
|
5
|
+
roomstayId: string;
|
|
6
|
+
reservations: ReservationDTO[];
|
|
7
|
+
itineraryNumber: string;
|
|
8
|
+
hotelFrontendId?: string;
|
|
9
|
+
warnings?: string[];
|
|
10
|
+
total?: string;
|
|
11
|
+
payment?: {
|
|
12
|
+
planpay?: {
|
|
13
|
+
id: string;
|
|
14
|
+
checkoutWorkflow: {
|
|
15
|
+
type: string;
|
|
16
|
+
id: string;
|
|
17
|
+
scriptUrl: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
external?: {
|
|
21
|
+
id: string;
|
|
22
|
+
redirectUrl: string;
|
|
23
|
+
};
|
|
24
|
+
adyen?: {
|
|
25
|
+
roomstayId: string;
|
|
26
|
+
sessionData: string;
|
|
27
|
+
sessionId: string;
|
|
28
|
+
clientKey: string;
|
|
29
|
+
isLive: boolean;
|
|
30
|
+
currency: string;
|
|
31
|
+
amount: string;
|
|
32
|
+
countryCode: string;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
itemisedFees?: SimpleItemisedFee[];
|
|
36
|
+
feesSummary?: SimpleItemisedFee[];
|
|
37
|
+
};
|
|
38
|
+
export type ReservationAddonDTO = {
|
|
39
|
+
code: string;
|
|
40
|
+
inclusive: false;
|
|
41
|
+
pricingType: string;
|
|
42
|
+
quantity: number;
|
|
43
|
+
adultQuantity: number;
|
|
44
|
+
childQuantity?: number;
|
|
45
|
+
description: string;
|
|
46
|
+
name: string;
|
|
47
|
+
category: string;
|
|
48
|
+
image: string;
|
|
49
|
+
price: number;
|
|
50
|
+
fees?: number;
|
|
51
|
+
itemisedFees?: SimpleItemisedFee[];
|
|
52
|
+
displayPrice: number;
|
|
53
|
+
adultPrice?: number;
|
|
54
|
+
childPrice?: number;
|
|
55
|
+
nights?: number;
|
|
56
|
+
};
|
|
57
|
+
export type ReservationDTO = {
|
|
58
|
+
nights: {
|
|
59
|
+
[date: string]: RoomNightRateDTO;
|
|
60
|
+
};
|
|
61
|
+
guestCounts: {
|
|
62
|
+
adults: number;
|
|
63
|
+
children: number;
|
|
64
|
+
};
|
|
65
|
+
guest: {
|
|
66
|
+
address: {
|
|
67
|
+
line1: string;
|
|
68
|
+
city: string;
|
|
69
|
+
postalCode: string;
|
|
70
|
+
};
|
|
71
|
+
firstName: string;
|
|
72
|
+
lastName: string;
|
|
73
|
+
phone: string;
|
|
74
|
+
email: string;
|
|
75
|
+
};
|
|
76
|
+
paymentCard: {
|
|
77
|
+
type?: string;
|
|
78
|
+
last4: string;
|
|
79
|
+
expiry: string;
|
|
80
|
+
name: string;
|
|
81
|
+
};
|
|
82
|
+
paymentMethod?: EBookingPaymentMethod;
|
|
83
|
+
comments?: string[];
|
|
84
|
+
addons?: ReservationAddonDTO[];
|
|
85
|
+
itemisedFees?: SimpleItemisedFee[];
|
|
86
|
+
reservationNumber: string;
|
|
87
|
+
cancelPolicy: string;
|
|
88
|
+
cancellationPolicyLongDescription?: string;
|
|
89
|
+
guaranteePolicy: string;
|
|
90
|
+
guaranteePolicyLongDescription?: string;
|
|
91
|
+
roomType: string;
|
|
92
|
+
roomCode: string;
|
|
93
|
+
rate: string;
|
|
94
|
+
images: [string];
|
|
95
|
+
status: string;
|
|
96
|
+
isCancelable: boolean;
|
|
97
|
+
total: {
|
|
98
|
+
beforeTax: number;
|
|
99
|
+
afterTax: number;
|
|
100
|
+
beforeFees?: number;
|
|
101
|
+
};
|
|
102
|
+
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { EHotelCardProcessor, EHotelCardProcessorInitData } from './IBookingPayment.type';
|
|
2
|
+
export type ICheckoutBrowserSession<T extends EHotelCardProcessor | undefined = EHotelCardProcessor> = {
|
|
3
|
+
browserSessionId: string;
|
|
4
|
+
checkoutSessionId: string;
|
|
5
|
+
rows: {}[];
|
|
6
|
+
/**
|
|
7
|
+
* ISO 8601 date string
|
|
8
|
+
*/
|
|
9
|
+
expiry: string;
|
|
10
|
+
payment: {
|
|
11
|
+
processor: T;
|
|
12
|
+
data: EHotelCardProcessorInitData[T];
|
|
13
|
+
};
|
|
14
|
+
};
|
|
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/dist/types/index.d.ts
CHANGED
|
@@ -1,62 +1,60 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Booking Details
|
|
3
3
|
*/
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
4
|
+
export * from "./Booking/IBookingPayment.type";
|
|
5
|
+
export * from "./Booking/IBookingStatus.type";
|
|
6
|
+
export * from "./Booking/IPrice.type";
|
|
7
|
+
export * from "./Booking/IBookingCreateErrorResponse";
|
|
8
|
+
export * from "./Booking/IBookingQuote.type";
|
|
9
9
|
/**
|
|
10
10
|
* Company
|
|
11
11
|
*/
|
|
12
|
-
export * from
|
|
13
|
-
export * from
|
|
14
|
-
export * from
|
|
12
|
+
export * from "./Company/ECompanyProvider.enum";
|
|
13
|
+
export * from "./Company/IAdminCompany.type";
|
|
14
|
+
export * from "./Company/IAdminCompanyUser.type";
|
|
15
15
|
/**
|
|
16
16
|
* Hotel
|
|
17
17
|
*/
|
|
18
|
-
export * from
|
|
19
|
-
export * from
|
|
20
|
-
export * from
|
|
21
|
-
export * from
|
|
22
|
-
export * from
|
|
23
|
-
export * from
|
|
24
|
-
export * from
|
|
25
|
-
export * from
|
|
26
|
-
export * from
|
|
18
|
+
export * from "./Hotel/EHotelPriceModel.enum";
|
|
19
|
+
export * from "./Hotel/EHotelStateFieldConfiguration.enum";
|
|
20
|
+
export * from "./Hotel/EHotelWeekdayStartsOn.enum";
|
|
21
|
+
export * from "./Hotel/EIntegration.enum";
|
|
22
|
+
export * from "./Hotel/IAuxiliaryFilter.type";
|
|
23
|
+
export * from "./Hotel/IHotelColorScheme.type";
|
|
24
|
+
export * from "./Hotel/IHotelOverrides.type";
|
|
25
|
+
export * from "./Hotel/IHotelReplica.type";
|
|
26
|
+
export * from "./Hotel/IHotelService.type";
|
|
27
27
|
/**
|
|
28
28
|
* Room
|
|
29
29
|
*/
|
|
30
|
-
export * from
|
|
30
|
+
export * from "./Room/IRoomGroup.type";
|
|
31
31
|
/**
|
|
32
32
|
* RMS
|
|
33
33
|
*/
|
|
34
|
-
export * from
|
|
35
|
-
export * from
|
|
36
|
-
export * from
|
|
34
|
+
export * from "./RMS/ERMSDiscountType.enum";
|
|
35
|
+
export * from "./RMS/IRMSPropertyDiscount.type";
|
|
36
|
+
export * from "./RMS/IRMSRequirement.type";
|
|
37
37
|
/**
|
|
38
38
|
* Image
|
|
39
39
|
*/
|
|
40
|
-
export * from
|
|
41
|
-
/** Maintenance */
|
|
42
|
-
export * from './Maintenance/IMaintenanceStatus.type';
|
|
40
|
+
export * from "./Image/IRoomstayImage.type";
|
|
43
41
|
/**
|
|
44
42
|
* Member Details
|
|
45
43
|
*/
|
|
46
|
-
export * from
|
|
47
|
-
export * from
|
|
48
|
-
export * from
|
|
49
|
-
export * from
|
|
50
|
-
export * from
|
|
51
|
-
export * from
|
|
52
|
-
export * from
|
|
53
|
-
export * from
|
|
54
|
-
export * from
|
|
55
|
-
export * from
|
|
44
|
+
export * from "./Member/IMember.type";
|
|
45
|
+
export * from "./Member/IMemberVerification.type";
|
|
46
|
+
export * from "./Member/IRoomstayCognitoMember.type";
|
|
47
|
+
export * from "./Member/IRoomstayMember.type";
|
|
48
|
+
export * from "./Member/IRoomstayMemberBooking.type";
|
|
49
|
+
export * from "./Member/IRoomstayMemberBookingAddress.type";
|
|
50
|
+
export * from "./Member/IRoomstayMemberBookingItem.type";
|
|
51
|
+
export * from "./Member/IRoomstayMemberBookingProfile.type";
|
|
52
|
+
export * from "./Member/IRoomstayMemberCards.type";
|
|
53
|
+
export * from "./Member/ISession.type";
|
|
56
54
|
/**
|
|
57
55
|
* Policies
|
|
58
56
|
*/
|
|
59
|
-
export * from
|
|
57
|
+
export * from "./Policies/EGuaranteePolicy.enum";
|
|
60
58
|
/**
|
|
61
59
|
* Roomstay Events
|
|
62
60
|
*/
|
|
@@ -65,12 +63,12 @@ export * from "./Events/ERoomstayEventSource.enum";
|
|
|
65
63
|
/**
|
|
66
64
|
* General
|
|
67
65
|
*/
|
|
68
|
-
export * from
|
|
69
|
-
export * from
|
|
66
|
+
export * from "./General/HttpMethod.enum";
|
|
67
|
+
export * from "./General/IMessage.type";
|
|
70
68
|
/**
|
|
71
69
|
* Media
|
|
72
70
|
*/
|
|
73
|
-
export * from
|
|
71
|
+
export * from "./Media/IMedia.type";
|
|
74
72
|
/**
|
|
75
73
|
* Fees
|
|
76
74
|
*/
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { BasketAddonDTO, ReservationAddonDTO, ReservationsDTO } from "../types/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* A utility class to perform calculations related to addon pricing and reservation totals.
|
|
4
|
+
*/
|
|
5
|
+
export declare class TotalCalculator {
|
|
6
|
+
/**
|
|
7
|
+
* Calculates the base total cost for a single addon, without considering any additional fees.
|
|
8
|
+
*
|
|
9
|
+
* @param addon - A `BasketAddonDTO` or `ReservationAddonDTO` representing the addon details.
|
|
10
|
+
* @param dismissAddonNightCount - If true, skips multiplying totals by the number of nights.
|
|
11
|
+
* @returns An object containing:
|
|
12
|
+
* - `indPrice`: Total price without per adult/child pricing.
|
|
13
|
+
* - `indAdultPrice`: Price calculated based on adult quantities.
|
|
14
|
+
* - `indChildPrice`: Price calculated based on child quantities.
|
|
15
|
+
* - `addonTotal`: Sum of the above prices, optionally multiplied by nights.
|
|
16
|
+
*/
|
|
17
|
+
static calculateBaseAddonTotal: (addon: BasketAddonDTO | ReservationAddonDTO, dismissAddonNightCount: boolean) => {
|
|
18
|
+
indPrice: number;
|
|
19
|
+
indAdultPrice: number;
|
|
20
|
+
indChildPrice: number;
|
|
21
|
+
addonTotal: number;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Calculates the total for one or more basket addons, including all associated fees.
|
|
25
|
+
*
|
|
26
|
+
* @param addons - A single or an array of `BasketAddonDTO` objects.
|
|
27
|
+
* @param dismissAddonNightCount - If true, disables night-based multiplier for addons.
|
|
28
|
+
* @returns An object with:
|
|
29
|
+
* - `price`: Total base price (excluding adult/child prices).
|
|
30
|
+
* - `adultPrice`: Total based on adult quantities and prices.
|
|
31
|
+
* - `childPrice`: Total based on child quantities and prices.
|
|
32
|
+
* - `totalFees`: Total of all applicable addon fees.
|
|
33
|
+
* - `total`: Sum of prices and fees.
|
|
34
|
+
*/
|
|
35
|
+
static calculateBasketAddonTotal: (addons: BasketAddonDTO | BasketAddonDTO[], dismissAddonNightCount?: boolean) => {
|
|
36
|
+
price: number;
|
|
37
|
+
adultPrice: number;
|
|
38
|
+
childPrice: number;
|
|
39
|
+
totalFees: number;
|
|
40
|
+
total: number;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Calculates the total for one or more reservation addons, including itemised fees.
|
|
44
|
+
*
|
|
45
|
+
* @param addons - A single or an array of `ReservationAddonDTO` objects.
|
|
46
|
+
* @param dismissAddonNightCount - If true, disables night-based multiplier for addons.
|
|
47
|
+
* @returns An object with:
|
|
48
|
+
* - `price`: Base addon price without adult/child multipliers.
|
|
49
|
+
* - `adultPrice`: Addon cost based on adult rates.
|
|
50
|
+
* - `childPrice`: Addon cost based on child rates.
|
|
51
|
+
* - `totalFees`: Total of all fees (itemised if available).
|
|
52
|
+
* - `total`: Final addon cost including fees.
|
|
53
|
+
* - `displayPrice`: Price displayed to the user (varies depending on fee breakdown).
|
|
54
|
+
*/
|
|
55
|
+
static calculateReservationAddonTotal: (addons: ReservationAddonDTO | ReservationAddonDTO[], dismissAddonNightCount?: boolean) => {
|
|
56
|
+
price: number;
|
|
57
|
+
adultPrice: number;
|
|
58
|
+
childPrice: number;
|
|
59
|
+
totalFees: number;
|
|
60
|
+
total: number;
|
|
61
|
+
displayPrice: number;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Calculates the total cost for a reservation, including individual reservation totals and global itemised fees.
|
|
65
|
+
*
|
|
66
|
+
* @param reservation - The full reservation data in `ReservationsDTO` format.
|
|
67
|
+
* @param dismissAddonNightCount - If true, disables night-based multipliers on addons.
|
|
68
|
+
* @returns The rounded total cost of the reservation.
|
|
69
|
+
*/
|
|
70
|
+
static calculateTotalForReservation: (reservation: ReservationsDTO, dismissAddonNightCount?: boolean) => number;
|
|
71
|
+
}
|
|
File without changes
|
package/dist/utils/index.d.ts
CHANGED
|
File without changes
|
|
File without changes
|
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
import Decimal from "decimal.js";
|
|
2
|
-
export declare const RoundingType: {
|
|
3
|
-
[key: string]: Decimal.Rounding;
|
|
4
|
-
};
|
|
5
|
-
interface RoundMoneyOptions {
|
|
6
|
-
precision?: number;
|
|
7
|
-
rounding?: Decimal.Rounding;
|
|
8
|
-
}
|
|
9
1
|
/**
|
|
10
2
|
* Rounds a monetary amount to two decimal places.
|
|
11
3
|
*
|
|
@@ -13,8 +5,6 @@ interface RoundMoneyOptions {
|
|
|
13
5
|
* with some systems, such as RMS.
|
|
14
6
|
*
|
|
15
7
|
* @param amount a string or number to be rounded
|
|
16
|
-
* @param options an object containing precision and rounding options
|
|
17
8
|
* @returns the rounded amount as a number
|
|
18
9
|
*/
|
|
19
|
-
export declare const roundMoney: (amount: string | number
|
|
20
|
-
export {};
|
|
10
|
+
export declare const roundMoney: (amount: string | number) => number;
|
|
File without changes
|
package/dist/web.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
define("@roomstay/core",["decimal.js"],(e=>(()=>{"use strict";var n={60:n=>{n.exports=e}},o={};function t(e){var r=o[e];if(void 0!==r)return r.exports;var a=o[e]={exports:{}};return n[e](a,a.exports,t),a.exports}t.n=e=>{var n=e&&e.__esModule?()=>e.default:()=>e;return t.d(n,{a:n}),n},t.d=(e,n)=>{for(var o in n)t.o(n,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:n[o]})},t.o=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),t.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{let e,n,o;t.r(r),t.d(r,{EBookingPaymentMethod:()=>e,ECompanyProvider:()=>c,EDistanceUnitType:()=>
|
|
1
|
+
define("@roomstay/core",["decimal.js"],(e=>(()=>{"use strict";var n={60:n=>{n.exports=e}},o={};function t(e){var r=o[e];if(void 0!==r)return r.exports;var a=o[e]={exports:{}};return n[e](a,a.exports,t),a.exports}t.n=e=>{var n=e&&e.__esModule?()=>e.default:()=>e;return t.d(n,{a:n}),n},t.d=(e,n)=>{for(var o in n)t.o(n,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:n[o]})},t.o=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),t.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{let e,n,o;t.r(r),t.d(r,{EBookingPaymentMethod:()=>e,ECompanyProvider:()=>c,EDistanceUnitType:()=>y,EFeeType:()=>C,EGuarantyPolicyPrepaymentType:()=>m,EHotelCardProcessor:()=>n,EHotelPriceModel:()=>u,EHotelStateFieldConfiguration:()=>d,EHotelWeekdayStartsOn:()=>g,EIntegration:()=>l,EPlanpayBookingStatus:()=>o,ERMSDiscountType:()=>P,ERoomstayEventSource:()=>p,ERoomstayImageSize:()=>f,HttpMethod:()=>h,IAuxiliaryFilterType:()=>s,IBookingStatus:()=>i,PCIBookingCardProcessorTypes:()=>a,calculateFeeAmount:()=>v,calculateTotalForMemberBooking:()=>S,getFeeOptionValidity:()=>w,getFilteredBookingAddonFees:()=>N,getFilteredBookingFees:()=>M,getFilteredBookingRateFees:()=>D,nameof:()=>R,resizeRoomstayImageUrl:()=>O,roundMoney:()=>A,subset:()=>E,uppercaseString:()=>T}),function(e){e.Card="Card",e.SavedCard="SavedCard",e.Planpay="Planpay",e.Adyen="Adyen",e.Afterpay="Afterpay",e.PCIBookingCard="PCIBookingCard"}(e||(e={})),function(e){e.Passthrough="Passthrough",e.Adyen="Adyen",e.Till="Till",e.RMSPay="RMSPay",e.Windcave="Windcave"}(n||(n={})),function(e){e.Unknown="unknown",e.Unpaid="unpaid",e.Accepted="accepted",e.Cancelled="cancelled",e.Refunded="refunded",e.Rejected="rejected"}(o||(o={}));const a=[];let i,c,u,d,g,l,s,y,P,f,m,p,h,C;function T(e){return e.toUpperCase()}!function(e){e.Pending="Pending",e.Committed="Committed",e.Cancelled="Cancelled"}(i||(i={})),function(e){e.Synxis="Synxis",e.Availpro="Availpro",e.RMS="RMS",e.Siteminder="Siteminder",e.Roomstay="Roomstay"}(c||(c={})),function(e){e.PerPerson="PerPerson",e.PerDay="PerDay",e.PerOccupancy="PerOccupancy"}(u||(u={})),function(e){e.NotIncluded="NotIncluded",e.Optional="Optional",e.Required="Required"}(d||(d={})),function(e){e.Monday="monday",e.Sunday="sunday"}(g||(g={})),function(e){e.Big4="Big4",e.RmsTop10="Top10",e.Top10="NewTop10",e.Gday="Gday",e.Salesforce="Salesforce"}(l||(l={})),function(e){e.AreaDwellingLength="AreaDwellingLength",e.AreaDwellingType="AreaDwellingType"}(s||(s={})),function(e){e.Metric="metric",e.Imperial="imperial"}(y||(y={})),function(e){e.Percentage="Percentage",e.Amount="Amount",e.Bogo="BOGO",e.NightlyRateOverride="NightlyRateOverride"}(P||(P={})),function(e){e[e.Icon=128]="Icon",e[e.Tiny=256]="Tiny",e[e.Small=512]="Small",e[e.Medium=768]="Medium",e[e.Large=1024]="Large",e[e.ExtraLarge=1600]="ExtraLarge"}(f||(f={})),function(e){e.FixedAmount="fixed",e.Percentage="percentage",e.Nights="nights"}(m||(m={})),function(e){e.Eventbrite="eventbrite",e.ATDW="atdw"}(p||(p={})),function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.DELETE="DELETE",e.PATCH="PATCH",e.OPTIONS="OPTIONS",e.HEAD="HEAD"}(h||(h={})),function(e){e.PercentageOfBooking="PercentageOfBooking",e.FixedChargePerRoom="FixedChargePerRoom",e.NightlyChargePerRoom="NightlyChargePerRoom",e.FixedChargePerBooking="FixedChargePerBooking",e.DepositSurcharge="DepositSurcharge"}(C||(C={}));const S=e=>{let n=0;const o=Object.values(e.itinerary);for(const e of o){const o=Object.keys(e.nights);for(const t of o)n+=e.nights[t].total}return n},O=(e,n)=>e.includes("cdn.app.roomstay.io")?e+"?w="+n:e,R=e=>e,E=(e,n)=>{const o={};return n.forEach((n=>{n in e&&(o[n]=e[n])})),o};var B=t(60),k=t.n(B);const A=e=>new(k())(e).toDecimalPlaces(2).toNumber();function v(e,n={}){const{baseAmount:o=0,numberOfNights:t=1,feeIncludedInBaseAmount:r=!1,extractedFromRates:a=!1,removedPercentages:i=[]}=n,c=A(o);switch(e.feeType){case C.PercentageOfBooking:if(r)return A(c*e.amount/(100+e.amount));if(a){const n=i.reduce(((e,n)=>e+n/(100+n)),0);return A(c/(1-n)*e.amount/(100+e.amount))}return A(c*(e.amount/100));case C.FixedChargePerRoom:case C.FixedChargePerBooking:return e.amount;case C.NightlyChargePerRoom:return A(e.amount*t);default:return 0}}const F=[C.FixedChargePerBooking],x=[C.PercentageOfBooking,C.FixedChargePerRoom,C.NightlyChargePerRoom],I=[C.PercentageOfBooking];function b(e,n){return e.filter((e=>n.includes(e.feeType)))}function M(e){return b(e,F)}function D(e){return b(e,x)}function N(e){return b(e,I)}function w(e){return{includeInRates:[C.PercentageOfBooking,C.NightlyChargePerRoom].includes(e),extractFeeFromRates:e===C.PercentageOfBooking,appliesToAddons:e===C.PercentageOfBooking,includePreviousFeesInCalculation:e===C.PercentageOfBooking}}})(),r})()));
|
package/package.json
CHANGED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export type IDailyRevenue = {
|
|
2
|
-
date: string;
|
|
3
|
-
revenue: number;
|
|
4
|
-
};
|
|
5
|
-
export type IDailyRoomBreakdown = {
|
|
6
|
-
date: string;
|
|
7
|
-
roomName: string;
|
|
8
|
-
purchases: number;
|
|
9
|
-
};
|
|
10
|
-
export type IRegionBreakdown = {
|
|
11
|
-
country: string;
|
|
12
|
-
region: string;
|
|
13
|
-
purchases: number;
|
|
14
|
-
revenue: number;
|
|
15
|
-
};
|
|
16
|
-
export type IBigQueryResponse = {
|
|
17
|
-
purchases: number;
|
|
18
|
-
cancellations: number;
|
|
19
|
-
revenue: number;
|
|
20
|
-
conversionRate: number;
|
|
21
|
-
dailyRevenue: IDailyRevenue[];
|
|
22
|
-
dailyRoomsBreakdown: IDailyRoomBreakdown[];
|
|
23
|
-
regionBreakdown: IRegionBreakdown[];
|
|
24
|
-
};
|
|
File without changes
|