@roomstay/core 0.1.50 → 0.1.51-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.
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:()=>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})();
1
+ (()=>{"use strict";var e={n:t=>{var n=t&&t.__esModule?()=>t.default:()=>t;return e.d(n,{a:n}),n},d:(t,n)=>{for(var i in n)e.o(n,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:n[i]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};let n,i,a;e.r(t),e.d(t,{ADDON_PER_NIGHT_TYPES:()=>m,AddonPricingType:()=>N,EBookingPaymentMethod:()=>n,ECompanyProvider:()=>c,EDistanceUnitType:()=>g,EFeeType:()=>p,EGuarantyPolicyPrepaymentType:()=>h,EHotelCardProcessor:()=>i,EHotelPriceModel:()=>l,EHotelStateFieldConfiguration:()=>d,EHotelWeekdayStartsOn:()=>u,EIntegration:()=>P,EPlanpayBookingStatus:()=>a,ERMSDiscountType:()=>y,ERoomstayEventSource:()=>E,ERoomstayImageSize:()=>R,HttpMethod:()=>T,IAuxiliaryFilterType:()=>s,IBookingStatus:()=>o,IMaintenanceStatusService:()=>_,PCIBookingCardProcessorTypes:()=>r,RoundingType:()=>C,TotalCalculator:()=>Q,calculateFeeAmount:()=>I,calculateTotalForMemberBooking:()=>O,getFeeOptionValidity:()=>v,getFilteredBookingAddonFees:()=>k,getFilteredBookingFees:()=>U,getFilteredBookingRateFees:()=>B,nameof:()=>G,resizeRoomstayImageUrl:()=>M,roundMoney:()=>F,subset:()=>b,uppercaseString:()=>x}),function(e){e.Card="Card",e.SavedCard="SavedCard",e.Planpay="Planpay",e.Adyen="Adyen",e.Afterpay="Afterpay",e.PCIBookingCard="PCIBookingCard"}(n||(n={})),function(e){e.Passthrough="Passthrough",e.Adyen="Adyen",e.Till="Till",e.RMSPay="RMSPay",e.Windcave="Windcave"}(i||(i={})),function(e){e.Unknown="unknown",e.Unpaid="unpaid",e.Accepted="accepted",e.Cancelled="cancelled",e.Refunded="refunded",e.Rejected="rejected"}(a||(a={}));const r=[];let o,c,l,d,u,P,s,g,y,R,_,h,E,T,p,N;!function(e){e.Pending="Pending",e.Committed="Committed",e.Cancelled="Cancelled"}(o||(o={})),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"}(l||(l={})),function(e){e.NotIncluded="NotIncluded",e.Optional="Optional",e.Required="Required"}(d||(d={})),function(e){e.Monday="monday",e.Sunday="sunday"}(u||(u={})),function(e){e.Big4="Big4",e.RmsTop10="Top10",e.Top10="NewTop10",e.Gday="Gday",e.Salesforce="Salesforce"}(P||(P={})),function(e){e.AreaDwellingLength="AreaDwellingLength",e.AreaDwellingType="AreaDwellingType"}(s||(s={})),function(e){e.Metric="metric",e.Imperial="imperial"}(g||(g={})),function(e){e.Percentage="Percentage",e.Amount="Amount",e.Bogo="BOGO",e.NightlyRateOverride="NightlyRateOverride"}(y||(y={})),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"}(R||(R={})),function(e){e.Frontend="frontend",e.Hotel="hotel",e.Events="events"}(_||(_={})),function(e){e.FixedAmount="fixed",e.Percentage="percentage",e.Nights="nights"}(h||(h={})),function(e){e.Eventbrite="eventbrite",e.ATDW="atdw"}(E||(E={})),function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.DELETE="DELETE",e.PATCH="PATCH",e.OPTIONS="OPTIONS",e.HEAD="HEAD"}(T||(T={})),function(e){e.PercentageOfBooking="PercentageOfBooking",e.FixedChargePerRoom="FixedChargePerRoom",e.NightlyChargePerRoom="NightlyChargePerRoom",e.FixedChargePerBooking="FixedChargePerBooking",e.DepositSurcharge="DepositSurcharge"}(p||(p={})),function(e){e.PER_STAY="Per stay",e.PER_NIGHT="Per night",e.PER_PERSON="Per person",e.PER_PERSON_PER_NIGHT="Per person per night",e.PER_ALL_PERSONS="Per all persons",e.PER_ALL_PERSONS_PER_NIGHT="Per all persons per night",e.PER_QUANTITY_NAME_PER_NIGHT="Per Quantity Name Per Night",e.PER_ROOM_QUANTITY_PER_NIGHT="Per Room Quantity Per Night",e.PER_PERSON_OCCUPANCY_PER_NIGHT="Per Person Occupancy Per Night",e.PER_ADULT_OCCUPANCY_PER_NIGHT="Per Adult Occupancy Per Night",e.PER_CHILD_OCCUPANCY_PER_NIGHT="Per Child Occupancy Per Night"}(N||(N={}));const m=[N.PER_NIGHT,N.PER_PERSON_PER_NIGHT,N.PER_QUANTITY_NAME_PER_NIGHT,N.PER_ROOM_QUANTITY_PER_NIGHT,N.PER_PERSON_OCCUPANCY_PER_NIGHT,N.PER_ADULT_OCCUPANCY_PER_NIGHT,N.PER_CHILD_OCCUPANCY_PER_NIGHT,N.PER_ALL_PERSONS_PER_NIGHT],O=e=>{let t=0;const n=Object.values(e.itinerary);for(const e of n){const n=Object.keys(e.nights);for(const i of n)t+=e.nights[i].total}return t},f=require("decimal.js");var A=e.n(f);const C={UP:A().ROUND_UP,DOWN:A().ROUND_DOWN,CEIL:A().ROUND_CEIL,FLOOR:A().ROUND_FLOOR,HALF_UP:A().ROUND_HALF_UP,HALF_DOWN:A().ROUND_HALF_DOWN,HALF_EVEN:A().ROUND_HALF_EVEN,HALF_CEIL:A().ROUND_HALF_CEIL,HALF_FLOOR:A().ROUND_HALF_FLOOR},F=(e,t)=>{const{precision:n=2,rounding:i=C.HALF_UP}=t||{};return new(A())(e).toDecimalPlaces(n,i).toNumber()};function I(e,t={}){const{baseAmount:n=0,numberOfNights:i=1,feeIncludedInBaseAmount:a=!1,extractedFromRates:r=!1,removedPercentages:o=[]}=t,c=F(n);switch(e.feeType){case p.PercentageOfBooking:if(a)return F(c*e.amount/(100+e.amount));if(r){const t=o.reduce(((e,t)=>e+t/(100+t)),0);return F(c/(1-t)*e.amount/(100+e.amount))}return F(c*(e.amount/100));case p.FixedChargePerRoom:case p.FixedChargePerBooking:return e.amount;case p.NightlyChargePerRoom:return F(e.amount*i);default:return 0}}const S=[p.FixedChargePerBooking],H=[p.PercentageOfBooking,p.FixedChargePerRoom,p.NightlyChargePerRoom],L=[p.PercentageOfBooking];function D(e,t){return e.filter((e=>t.includes(e.feeType)))}function U(e){return D(e,S)}function B(e){return D(e,H)}function k(e){return D(e,L)}function v(e){return{includeInRates:[p.PercentageOfBooking,p.NightlyChargePerRoom].includes(e),extractFeeFromRates:e===p.PercentageOfBooking,appliesToAddons:e===p.PercentageOfBooking,includePreviousFeesInCalculation:e===p.PercentageOfBooking}}const G=e=>e,b=(e,t)=>{const n={};return t.forEach((t=>{t in e&&(n[t]=e[t])})),n},M=(e,t)=>e.includes("cdn.app.roomstay.io")?e+"?w="+t:e;class Q{}function x(e){return e.toUpperCase()}Q.calculateBaseAddonTotal=(e,t)=>{let n=0,i=0,a=0;e.price&&e.quantity&&(n=e.quantity*Number(e.price)),e.pricingType===N.PER_ADULT_OCCUPANCY_PER_NIGHT&&e.adultQuantity?n*=e.adultQuantity:e.pricingType===N.PER_CHILD_OCCUPANCY_PER_NIGHT&&e.childQuantity&&(n*=e.childQuantity),e.adultPrice&&e.adultQuantity&&(i=e.adultQuantity*Number(e.adultPrice)),e.childPrice&&e.childQuantity&&(a=e.childQuantity*Number(e.childPrice));let r=n+i+a;return m.includes(e.pricingType)&&e.nights&&!t&&(r*=e.nights),{indPrice:n,indAdultPrice:i,indChildPrice:a,addonTotal:r}},Q.calculateBasketAddonTotal=(e,t=!1)=>(Array.isArray(e)||(e=[e]),e.reduce(((e,n)=>{const i=Q.calculateBaseAddonTotal(n,t);let a=0;return(n.fee||n.fees?.length)&&n.quantity?n.fees?.length?n.fees.forEach((e=>{a+=n.quantity*e.amount})):a=n.quantity*Number(n.fee):((n.adultFee||n.adultFees?.length)&&n.adultQuantity&&(n.adultFees?.length?n.adultFees.forEach((e=>{a+=n.adultQuantity*e.amount})):a+=n.adultQuantity??1*Number(n.adultFee)),(n.childFee||n.childFees?.length)&&n.childQuantity&&(n.childFees?.length?n.childFees.forEach((e=>{a+=n.childQuantity??1*e.amount})):a+=n.childQuantity*Number(n.childFee))),m.includes(n.pricingType)&&n.nights&&!t&&(a*=n.nights),{price:e.price+i.indPrice,adultPrice:e.adultPrice+i.indAdultPrice,childPrice:e.childPrice+i.indChildPrice,totalFees:e.totalFees+a,total:e.total+i.addonTotal+a}}),{price:0,adultPrice:0,childPrice:0,totalFees:0,total:0})),Q.calculateReservationAddonTotal=(e,t=!1)=>(Array.isArray(e)||(e=[e]),e.reduce(((e,n)=>{const i=Q.calculateBaseAddonTotal(n,t);let a=n.fees||0;n.itemisedFees?.length&&(a=n.itemisedFees.reduce(((e,t)=>e+t.amount),0));const r=n.itemisedFees?.length?i.addonTotal:i.addonTotal+a;return{price:e.price+i.indPrice,adultPrice:e.adultPrice+i.indAdultPrice,childPrice:e.childPrice+i.indChildPrice,totalFees:e.totalFees+a,total:e.total+i.addonTotal+a,displayPrice:e.displayPrice+r}}),{price:0,adultPrice:0,childPrice:0,totalFees:0,total:0,displayPrice:0})),Q.calculateTotalForReservation=(e,t=!1)=>{let n=0;return e.itemisedFees?.forEach((e=>{n+=e.amount})),e.reservations.forEach((e=>{n+=e.total.afterTax;const i=Object.keys(e.nights)?.length??0;if(e.addons?.length){const a=(e.addons??[]).map((e=>({...e,nights:i})));n+=Q.calculateReservationAddonTotal(a,t)?.total}})),F(n)},module.exports=t})();
@@ -4,3 +4,8 @@ export interface IFee {
4
4
  amount: number;
5
5
  feeType: EFeeType;
6
6
  }
7
+ export type SimpleItemisedFee = {
8
+ name: string;
9
+ description?: string;
10
+ amount: number;
11
+ };
@@ -1,4 +1,4 @@
1
- import { ERMSDiscountType } from './ERMSDiscountType.enum';
1
+ import { ERMSDiscountType } from "./ERMSDiscountType.enum";
2
2
  export type IRMSPropertyDiscount = {
3
3
  name: string;
4
4
  hotelId: string;
@@ -1,74 +1,76 @@
1
1
  /**
2
2
  * Booking Details
3
3
  */
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";
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 "./Company/ECompanyProvider.enum";
13
- export * from "./Company/IAdminCompany.type";
14
- export * from "./Company/IAdminCompanyUser.type";
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 "./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";
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 "./Room/IRoomGroup.type";
30
+ export * from './Room/IRoomGroup.type';
31
31
  /**
32
32
  * RMS
33
33
  */
34
- export * from "./RMS/ERMSDiscountType.enum";
35
- export * from "./RMS/IRMSPropertyDiscount.type";
36
- export * from "./RMS/IRMSRequirement.type";
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 "./Image/IRoomstayImage.type";
40
+ export * from './Image/IRoomstayImage.type';
41
+ /** Maintenance */
42
+ export * from './Maintenance/IMaintenanceStatus.type';
41
43
  /**
42
44
  * Member Details
43
45
  */
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";
46
+ export * from './Member/IMember.type';
47
+ export * from './Member/IMemberVerification.type';
48
+ export * from './Member/IRoomstayCognitoMember.type';
49
+ export * from './Member/IRoomstayMember.type';
50
+ export * from './Member/IRoomstayMemberBooking.type';
51
+ export * from './Member/IRoomstayMemberBookingAddress.type';
52
+ export * from './Member/IRoomstayMemberBookingItem.type';
53
+ export * from './Member/IRoomstayMemberBookingProfile.type';
54
+ export * from './Member/IRoomstayMemberCards.type';
55
+ export * from './Member/ISession.type';
54
56
  /**
55
57
  * Policies
56
58
  */
57
- export * from "./Policies/EGuaranteePolicy.enum";
59
+ export * from './Policies/EGuaranteePolicy.enum';
58
60
  /**
59
61
  * Roomstay Events
60
62
  */
61
- export * from "./Events/IRoomstayEvent.type";
62
63
  export * from "./Events/ERoomstayEventSource.enum";
64
+ export * from "./Events/IRoomstayEvent.type";
63
65
  /**
64
66
  * General
65
67
  */
66
- export * from "./General/HttpMethod.enum";
67
- export * from "./General/IMessage.type";
68
+ export * from './General/HttpMethod.enum';
69
+ export * from './General/IMessage.type';
68
70
  /**
69
71
  * Media
70
72
  */
71
- export * from "./Media/IMedia.type";
73
+ export * from './Media/IMedia.type';
72
74
  /**
73
75
  * Fees
74
76
  */
@@ -76,6 +78,12 @@ export * from "./Fees/EFeeType.enum";
76
78
  export * from "./Fees/IFee.type";
77
79
  export * from "./Fees/IFeeConfigurationOptions.type";
78
80
  /**
79
- * Analytics
81
+ * Addon
82
+ */
83
+ export * from "./Addon/Addon.enum";
84
+ export * from "./Addon/Addon.type";
85
+ /**
86
+ * Api
80
87
  */
81
- export * from "./Analytics/IBigQueryResults.type";
88
+ export * from "./Api/Reservations.type";
89
+ export * from "./Api/RoomNightRate.type";
@@ -1,8 +1,9 @@
1
- export * from './uppercaseString';
2
- export * from './bookingTotal';
3
- export * from './roomstayImageResize';
4
- export * from './reflection';
5
- export * from './roundMoney';
6
- export * from './typeUtils';
7
- export * from './calculateFee';
8
- export * from './feeTypes';
1
+ export * from "./bookingTotal";
2
+ export * from "./calculateFee";
3
+ export * from "./feeTypes";
4
+ export * from "./reflection";
5
+ export * from "./roomstayImageResize";
6
+ export * from "./roundMoney";
7
+ export * from "./TotalCalculator";
8
+ export * from "./typeUtils";
9
+ export * from "./uppercaseString";
@@ -1,3 +1,11 @@
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
+ }
1
9
  /**
2
10
  * Rounds a monetary amount to two decimal places.
3
11
  *
@@ -5,6 +13,8 @@
5
13
  * with some systems, such as RMS.
6
14
  *
7
15
  * @param amount a string or number to be rounded
16
+ * @param options an object containing precision and rounding options
8
17
  * @returns the rounded amount as a number
9
18
  */
10
- export declare const roundMoney: (amount: string | number) => number;
19
+ export declare const roundMoney: (amount: string | number, options?: RoundMoneyOptions) => number;
20
+ export {};
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:()=>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})()));
1
+ define("@roomstay/core",["decimal.js"],(e=>(()=>{"use strict";var t={60:t=>{t.exports=e}},n={};function r(e){var i=n[e];if(void 0!==i)return i.exports;var o=n[e]={exports:{}};return t[e](o,o.exports,r),o.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};return(()=>{let e,t,n;r.r(i),r.d(i,{ADDON_PER_NIGHT_TYPES:()=>f,AddonPricingType:()=>N,EBookingPaymentMethod:()=>e,ECompanyProvider:()=>c,EDistanceUnitType:()=>g,EFeeType:()=>T,EGuarantyPolicyPrepaymentType:()=>h,EHotelCardProcessor:()=>t,EHotelPriceModel:()=>l,EHotelStateFieldConfiguration:()=>d,EHotelWeekdayStartsOn:()=>u,EIntegration:()=>P,EPlanpayBookingStatus:()=>n,ERMSDiscountType:()=>y,ERoomstayEventSource:()=>E,ERoomstayImageSize:()=>R,HttpMethod:()=>p,IAuxiliaryFilterType:()=>s,IBookingStatus:()=>a,IMaintenanceStatusService:()=>_,PCIBookingCardProcessorTypes:()=>o,RoundingType:()=>C,TotalCalculator:()=>M,calculateFeeAmount:()=>I,calculateTotalForMemberBooking:()=>m,getFeeOptionValidity:()=>k,getFilteredBookingAddonFees:()=>B,getFilteredBookingFees:()=>U,getFilteredBookingRateFees:()=>v,nameof:()=>G,resizeRoomstayImageUrl:()=>x,roundMoney:()=>F,subset:()=>b,uppercaseString:()=>Q}),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"}(t||(t={})),function(e){e.Unknown="unknown",e.Unpaid="unpaid",e.Accepted="accepted",e.Cancelled="cancelled",e.Refunded="refunded",e.Rejected="rejected"}(n||(n={}));const o=[];let a,c,l,d,u,P,s,g,y,R,_,h,E,p,T,N;!function(e){e.Pending="Pending",e.Committed="Committed",e.Cancelled="Cancelled"}(a||(a={})),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"}(l||(l={})),function(e){e.NotIncluded="NotIncluded",e.Optional="Optional",e.Required="Required"}(d||(d={})),function(e){e.Monday="monday",e.Sunday="sunday"}(u||(u={})),function(e){e.Big4="Big4",e.RmsTop10="Top10",e.Top10="NewTop10",e.Gday="Gday",e.Salesforce="Salesforce"}(P||(P={})),function(e){e.AreaDwellingLength="AreaDwellingLength",e.AreaDwellingType="AreaDwellingType"}(s||(s={})),function(e){e.Metric="metric",e.Imperial="imperial"}(g||(g={})),function(e){e.Percentage="Percentage",e.Amount="Amount",e.Bogo="BOGO",e.NightlyRateOverride="NightlyRateOverride"}(y||(y={})),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"}(R||(R={})),function(e){e.Frontend="frontend",e.Hotel="hotel",e.Events="events"}(_||(_={})),function(e){e.FixedAmount="fixed",e.Percentage="percentage",e.Nights="nights"}(h||(h={})),function(e){e.Eventbrite="eventbrite",e.ATDW="atdw"}(E||(E={})),function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.DELETE="DELETE",e.PATCH="PATCH",e.OPTIONS="OPTIONS",e.HEAD="HEAD"}(p||(p={})),function(e){e.PercentageOfBooking="PercentageOfBooking",e.FixedChargePerRoom="FixedChargePerRoom",e.NightlyChargePerRoom="NightlyChargePerRoom",e.FixedChargePerBooking="FixedChargePerBooking",e.DepositSurcharge="DepositSurcharge"}(T||(T={})),function(e){e.PER_STAY="Per stay",e.PER_NIGHT="Per night",e.PER_PERSON="Per person",e.PER_PERSON_PER_NIGHT="Per person per night",e.PER_ALL_PERSONS="Per all persons",e.PER_ALL_PERSONS_PER_NIGHT="Per all persons per night",e.PER_QUANTITY_NAME_PER_NIGHT="Per Quantity Name Per Night",e.PER_ROOM_QUANTITY_PER_NIGHT="Per Room Quantity Per Night",e.PER_PERSON_OCCUPANCY_PER_NIGHT="Per Person Occupancy Per Night",e.PER_ADULT_OCCUPANCY_PER_NIGHT="Per Adult Occupancy Per Night",e.PER_CHILD_OCCUPANCY_PER_NIGHT="Per Child Occupancy Per Night"}(N||(N={}));const f=[N.PER_NIGHT,N.PER_PERSON_PER_NIGHT,N.PER_QUANTITY_NAME_PER_NIGHT,N.PER_ROOM_QUANTITY_PER_NIGHT,N.PER_PERSON_OCCUPANCY_PER_NIGHT,N.PER_ADULT_OCCUPANCY_PER_NIGHT,N.PER_CHILD_OCCUPANCY_PER_NIGHT,N.PER_ALL_PERSONS_PER_NIGHT],m=e=>{let t=0;const n=Object.values(e.itinerary);for(const e of n){const n=Object.keys(e.nights);for(const r of n)t+=e.nights[r].total}return t};var O=r(60),A=r.n(O);const C={UP:A().ROUND_UP,DOWN:A().ROUND_DOWN,CEIL:A().ROUND_CEIL,FLOOR:A().ROUND_FLOOR,HALF_UP:A().ROUND_HALF_UP,HALF_DOWN:A().ROUND_HALF_DOWN,HALF_EVEN:A().ROUND_HALF_EVEN,HALF_CEIL:A().ROUND_HALF_CEIL,HALF_FLOOR:A().ROUND_HALF_FLOOR},F=(e,t)=>{const{precision:n=2,rounding:r=C.HALF_UP}=t||{};return new(A())(e).toDecimalPlaces(n,r).toNumber()};function I(e,t={}){const{baseAmount:n=0,numberOfNights:r=1,feeIncludedInBaseAmount:i=!1,extractedFromRates:o=!1,removedPercentages:a=[]}=t,c=F(n);switch(e.feeType){case T.PercentageOfBooking:if(i)return F(c*e.amount/(100+e.amount));if(o){const t=a.reduce(((e,t)=>e+t/(100+t)),0);return F(c/(1-t)*e.amount/(100+e.amount))}return F(c*(e.amount/100));case T.FixedChargePerRoom:case T.FixedChargePerBooking:return e.amount;case T.NightlyChargePerRoom:return F(e.amount*r);default:return 0}}const S=[T.FixedChargePerBooking],H=[T.PercentageOfBooking,T.FixedChargePerRoom,T.NightlyChargePerRoom],L=[T.PercentageOfBooking];function D(e,t){return e.filter((e=>t.includes(e.feeType)))}function U(e){return D(e,S)}function v(e){return D(e,H)}function B(e){return D(e,L)}function k(e){return{includeInRates:[T.PercentageOfBooking,T.NightlyChargePerRoom].includes(e),extractFeeFromRates:e===T.PercentageOfBooking,appliesToAddons:e===T.PercentageOfBooking,includePreviousFeesInCalculation:e===T.PercentageOfBooking}}const G=e=>e,b=(e,t)=>{const n={};return t.forEach((t=>{t in e&&(n[t]=e[t])})),n},x=(e,t)=>e.includes("cdn.app.roomstay.io")?e+"?w="+t:e;class M{}function Q(e){return e.toUpperCase()}M.calculateBaseAddonTotal=(e,t)=>{let n=0,r=0,i=0;e.price&&e.quantity&&(n=e.quantity*Number(e.price)),e.pricingType===N.PER_ADULT_OCCUPANCY_PER_NIGHT&&e.adultQuantity?n*=e.adultQuantity:e.pricingType===N.PER_CHILD_OCCUPANCY_PER_NIGHT&&e.childQuantity&&(n*=e.childQuantity),e.adultPrice&&e.adultQuantity&&(r=e.adultQuantity*Number(e.adultPrice)),e.childPrice&&e.childQuantity&&(i=e.childQuantity*Number(e.childPrice));let o=n+r+i;return f.includes(e.pricingType)&&e.nights&&!t&&(o*=e.nights),{indPrice:n,indAdultPrice:r,indChildPrice:i,addonTotal:o}},M.calculateBasketAddonTotal=(e,t=!1)=>(Array.isArray(e)||(e=[e]),e.reduce(((e,n)=>{const r=M.calculateBaseAddonTotal(n,t);let i=0;return(n.fee||n.fees?.length)&&n.quantity?n.fees?.length?n.fees.forEach((e=>{i+=n.quantity*e.amount})):i=n.quantity*Number(n.fee):((n.adultFee||n.adultFees?.length)&&n.adultQuantity&&(n.adultFees?.length?n.adultFees.forEach((e=>{i+=n.adultQuantity*e.amount})):i+=n.adultQuantity??1*Number(n.adultFee)),(n.childFee||n.childFees?.length)&&n.childQuantity&&(n.childFees?.length?n.childFees.forEach((e=>{i+=n.childQuantity??1*e.amount})):i+=n.childQuantity*Number(n.childFee))),f.includes(n.pricingType)&&n.nights&&!t&&(i*=n.nights),{price:e.price+r.indPrice,adultPrice:e.adultPrice+r.indAdultPrice,childPrice:e.childPrice+r.indChildPrice,totalFees:e.totalFees+i,total:e.total+r.addonTotal+i}}),{price:0,adultPrice:0,childPrice:0,totalFees:0,total:0})),M.calculateReservationAddonTotal=(e,t=!1)=>(Array.isArray(e)||(e=[e]),e.reduce(((e,n)=>{const r=M.calculateBaseAddonTotal(n,t);let i=n.fees||0;n.itemisedFees?.length&&(i=n.itemisedFees.reduce(((e,t)=>e+t.amount),0));const o=n.itemisedFees?.length?r.addonTotal:r.addonTotal+i;return{price:e.price+r.indPrice,adultPrice:e.adultPrice+r.indAdultPrice,childPrice:e.childPrice+r.indChildPrice,totalFees:e.totalFees+i,total:e.total+r.addonTotal+i,displayPrice:e.displayPrice+o}}),{price:0,adultPrice:0,childPrice:0,totalFees:0,total:0,displayPrice:0})),M.calculateTotalForReservation=(e,t=!1)=>{let n=0;return e.itemisedFees?.forEach((e=>{n+=e.amount})),e.reservations.forEach((e=>{n+=e.total.afterTax;const r=Object.keys(e.nights)?.length??0;if(e.addons?.length){const i=(e.addons??[]).map((e=>({...e,nights:r})));n+=M.calculateReservationAddonTotal(i,t)?.total}})),F(n)}})(),i})()));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@roomstay/core",
3
- "version": "0.1.50",
3
+ "version": "0.1.51-0",
4
4
  "description": "Details shared between Roomstay libraries. Anything from Currency, to Generic types",
5
5
  "types": "./dist/index.d.ts",
6
6
  "files": [
@@ -1,35 +0,0 @@
1
- export type IDailyMetrics = {
2
- date: string;
3
- revenue: number;
4
- purchases: number;
5
- sessionCount: number;
6
- };
7
- export type IDailyRoomBreakdown = {
8
- date: string;
9
- roomName: string;
10
- purchases: number;
11
- };
12
- export type IRegionBreakdown = {
13
- country: string;
14
- region: string;
15
- purchases: number;
16
- revenue: number;
17
- };
18
- export type ICheckoutFunnel = {
19
- roomName: string;
20
- selectedDate: number;
21
- addedToCart: number;
22
- startedCheckout: number;
23
- completedCheckout: number;
24
- };
25
- export type IBigQueryResults = {
26
- purchases: number;
27
- cancellations: number;
28
- revenue: number;
29
- conversionRate: number;
30
- totalDateSelections: number;
31
- dailyMetrics: IDailyMetrics[];
32
- dailyRoomsBreakdown: IDailyRoomBreakdown[];
33
- regionBreakdown: IRegionBreakdown[];
34
- checkoutFunnel: ICheckoutFunnel[];
35
- };