@roomstay/core 0.1.50-0 → 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.
Files changed (53) hide show
  1. package/dist/index.d.ts +0 -0
  2. package/dist/node.js +1 -1
  3. package/dist/types/Addon/Addon.enum.d.ts +14 -0
  4. package/dist/types/Addon/Addon.type.d.ts +24 -0
  5. package/dist/types/Api/Reservations.type.d.ts +102 -0
  6. package/dist/types/Api/RoomNightRate.type.d.ts +7 -0
  7. package/dist/types/Booking/IBookingCreateErrorResponse.d.ts +0 -0
  8. package/dist/types/Booking/IBookingPayment.type.d.ts +0 -0
  9. package/dist/types/Booking/IBookingQuote.type.d.ts +0 -0
  10. package/dist/types/Booking/IBookingStatus.type.d.ts +0 -0
  11. package/dist/types/Booking/ICheckoutBrowserSession.type.d.ts +14 -0
  12. package/dist/types/Booking/IPrice.type.d.ts +0 -0
  13. package/dist/types/Company/ECompanyProvider.enum.d.ts +0 -0
  14. package/dist/types/Company/IAdminCompany.type.d.ts +0 -0
  15. package/dist/types/Company/IAdminCompanyUser.type.d.ts +0 -0
  16. package/dist/types/Events/IRoomstayEvent.type.d.ts +0 -0
  17. package/dist/types/Fees/IFee.type.d.ts +5 -0
  18. package/dist/types/General/HttpMethod.enum.d.ts +0 -0
  19. package/dist/types/General/IJsonString.type.d.ts +6 -0
  20. package/dist/types/Hotel/EHotelPriceModel.enum.d.ts +0 -0
  21. package/dist/types/Hotel/EHotelWeekdayStartsOn.enum.d.ts +0 -0
  22. package/dist/types/Hotel/IAuxiliaryFilter.type.d.ts +0 -0
  23. package/dist/types/Hotel/IHotelColorScheme.type.d.ts +0 -0
  24. package/dist/types/Hotel/IHotelOverrides.type.d.ts +0 -0
  25. package/dist/types/Hotel/IHotelReplica.type.d.ts +0 -0
  26. package/dist/types/Hotel/IHotelService.type.d.ts +0 -0
  27. package/dist/types/Image/IRoomstayImage.type.d.ts +0 -0
  28. package/dist/types/Member/IRoomstayCognitoMember.type.d.ts +0 -0
  29. package/dist/types/Member/IRoomstayMember.type.d.ts +0 -0
  30. package/dist/types/Member/IRoomstayMemberBooking.type.d.ts +0 -0
  31. package/dist/types/Member/IRoomstayMemberBookingAddress.type.d.ts +0 -0
  32. package/dist/types/Member/IRoomstayMemberBookingItem.type.d.ts +0 -0
  33. package/dist/types/Member/IRoomstayMemberBookingProfile.type.d.ts +0 -0
  34. package/dist/types/Member/IRoomstayMemberCards.type.d.ts +0 -0
  35. package/dist/types/Member/ISession.type.d.ts +0 -0
  36. package/dist/types/Policies/EGuaranteePolicy.enum.d.ts +0 -0
  37. package/dist/types/RMS/ERMSDiscountType.enum.d.ts +0 -0
  38. package/dist/types/RMS/IRMSPropertyDiscount.type.d.ts +1 -1
  39. package/dist/types/RMS/IRMSRequirement.type.d.ts +0 -0
  40. package/dist/types/Room/IRoomGroup.type.d.ts +0 -0
  41. package/dist/types/index.d.ts +9 -3
  42. package/dist/utils/TotalCalculator.d.ts +71 -0
  43. package/dist/utils/bookingTotal.d.ts +0 -0
  44. package/dist/utils/index.d.ts +9 -8
  45. package/dist/utils/nameof.d.ts +2 -0
  46. package/dist/utils/roomstayImageResize.d.ts +0 -0
  47. package/dist/utils/uppercaseString.d.ts +0 -0
  48. package/dist/web.js +1 -1
  49. package/package.json +1 -1
  50. package/dist/types/Analytics/IBigQueryResponse.type.d.ts +0 -24
  51. package/dist/types/Analytics/IBigQueryResults.type.d.ts +0 -35
  52. package/dist/types/Fees/IFeeOptions.type.d.ts +0 -6
  53. 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:()=>P,EFeeType:()=>F,EGuarantyPolicyPrepaymentType:()=>p,EHotelCardProcessor:()=>t,EHotelPriceModel:()=>u,EHotelStateFieldConfiguration:()=>d,EHotelWeekdayStartsOn:()=>g,EIntegration:()=>l,EPlanpayBookingStatus:()=>r,ERMSDiscountType:()=>y,ERoomstayEventSource:()=>O,ERoomstayImageSize:()=>f,HttpMethod:()=>R,IAuxiliaryFilterType:()=>s,IBookingStatus:()=>i,IMaintenanceStatusService:()=>m,PCIBookingCardProcessorTypes:()=>a,RoundingType:()=>D,calculateFeeAmount:()=>k,calculateTotalForMemberBooking:()=>C,getFeeOptionValidity:()=>M,getFilteredBookingAddonFees:()=>x,getFilteredBookingFees:()=>H,getFilteredBookingRateFees:()=>U,nameof:()=>E,resizeRoomstayImageUrl:()=>A,roundMoney:()=>B,subset:()=>S,uppercaseString:()=>h}),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,P,y,f,m,p,O,R,F;function h(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"}(P||(P={})),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"}(f||(f={})),function(e){e.Frontend="frontend",e.Hotel="hotel",e.Events="events"}(m||(m={})),function(e){e.FixedAmount="fixed",e.Percentage="percentage",e.Nights="nights"}(p||(p={})),function(e){e.Eventbrite="eventbrite",e.ATDW="atdw"}(O||(O={})),function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.DELETE="DELETE",e.PATCH="PATCH",e.OPTIONS="OPTIONS",e.HEAD="HEAD"}(R||(R={})),function(e){e.PercentageOfBooking="PercentageOfBooking",e.FixedChargePerRoom="FixedChargePerRoom",e.NightlyChargePerRoom="NightlyChargePerRoom",e.FixedChargePerBooking="FixedChargePerBooking",e.DepositSurcharge="DepositSurcharge"}(F||(F={}));const C=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},A=(e,n)=>e.includes("cdn.app.roomstay.io")?e+"?w="+n:e,E=e=>e,S=(e,n)=>{const o={};return n.forEach((n=>{n in e&&(o[n]=e[n])})),o},T=require("decimal.js");var N=e.n(T);const D={UP:N().ROUND_UP,DOWN:N().ROUND_DOWN,CEIL:N().ROUND_CEIL,FLOOR:N().ROUND_FLOOR,HALF_UP:N().ROUND_HALF_UP,HALF_DOWN:N().ROUND_HALF_DOWN,HALF_EVEN:N().ROUND_HALF_EVEN,HALF_CEIL:N().ROUND_HALF_CEIL,HALF_FLOOR:N().ROUND_HALF_FLOOR},B=(e,n)=>{const{precision:o=2,rounding:t=D.HALF_UP}=n||{};return new(N())(e).toDecimalPlaces(o,t).toNumber()};function k(e,n={}){const{baseAmount:o=0,numberOfNights:t=1,feeIncludedInBaseAmount:r=!1,extractedFromRates:a=!1,removedPercentages:i=[]}=n,c=B(o);switch(e.feeType){case F.PercentageOfBooking:if(r)return B(c*e.amount/(100+e.amount));if(a){const n=i.reduce(((e,n)=>e+n/(100+n)),0);return B(c/(1-n)*e.amount/(100+e.amount))}return B(c*(e.amount/100));case F.FixedChargePerRoom:case F.FixedChargePerBooking:return e.amount;case F.NightlyChargePerRoom:return B(e.amount*t);default:return 0}}const L=[F.FixedChargePerBooking],v=[F.PercentageOfBooking,F.FixedChargePerRoom,F.NightlyChargePerRoom],I=[F.PercentageOfBooking];function _(e,n){return e.filter((e=>n.includes(e.feeType)))}function H(e){return _(e,L)}function U(e){return _(e,v)}function x(e){return _(e,I)}function M(e){return{includeInRates:[F.PercentageOfBooking,F.NightlyChargePerRoom].includes(e),extractFeeFromRates:e===F.PercentageOfBooking,appliesToAddons:e===F.PercentageOfBooking,includePreviousFeesInCalculation:e===F.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})();
@@ -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
+ };
@@ -0,0 +1,7 @@
1
+ export type RoomNightRateDTO = {
2
+ cost: string;
3
+ tax: string;
4
+ fee: string;
5
+ total: string;
6
+ discount: string;
7
+ };
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
@@ -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
+ };
File without changes
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Basic object to wrap a string that is de/encoded as JSON.
3
+ */
4
+ export type IJsonString = {
5
+ message: string;
6
+ };
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
@@ -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;
File without changes
File without changes
@@ -60,8 +60,8 @@ export * from './Policies/EGuaranteePolicy.enum';
60
60
  /**
61
61
  * Roomstay Events
62
62
  */
63
- export * from "./Events/IRoomstayEvent.type";
64
63
  export * from "./Events/ERoomstayEventSource.enum";
64
+ export * from "./Events/IRoomstayEvent.type";
65
65
  /**
66
66
  * General
67
67
  */
@@ -78,6 +78,12 @@ export * from "./Fees/EFeeType.enum";
78
78
  export * from "./Fees/IFee.type";
79
79
  export * from "./Fees/IFeeConfigurationOptions.type";
80
80
  /**
81
- * Analytics
81
+ * Addon
82
+ */
83
+ export * from "./Addon/Addon.enum";
84
+ export * from "./Addon/Addon.type";
85
+ /**
86
+ * Api
82
87
  */
83
- export * from "./Analytics/IBigQueryResults.type";
88
+ export * from "./Api/Reservations.type";
89
+ export * from "./Api/RoomNightRate.type";
@@ -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
@@ -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";
@@ -0,0 +1,2 @@
1
+ export declare const nameof: <T>(name: Extract<keyof T, string>) => string;
2
+ export declare const nameofField: <T>(instance: T, name: keyof T) => string;
File without changes
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:()=>P,EFeeType:()=>F,EGuarantyPolicyPrepaymentType:()=>p,EHotelCardProcessor:()=>n,EHotelPriceModel:()=>u,EHotelStateFieldConfiguration:()=>d,EHotelWeekdayStartsOn:()=>g,EIntegration:()=>l,EPlanpayBookingStatus:()=>o,ERMSDiscountType:()=>y,ERoomstayEventSource:()=>O,ERoomstayImageSize:()=>f,HttpMethod:()=>R,IAuxiliaryFilterType:()=>s,IBookingStatus:()=>i,IMaintenanceStatusService:()=>m,PCIBookingCardProcessorTypes:()=>a,RoundingType:()=>D,calculateFeeAmount:()=>B,calculateTotalForMemberBooking:()=>C,getFeeOptionValidity:()=>M,getFilteredBookingAddonFees:()=>U,getFilteredBookingFees:()=>x,getFilteredBookingRateFees:()=>H,nameof:()=>E,resizeRoomstayImageUrl:()=>A,roundMoney:()=>v,subset:()=>S,uppercaseString:()=>h}),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,P,y,f,m,p,O,R,F;function h(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"}(P||(P={})),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"}(f||(f={})),function(e){e.Frontend="frontend",e.Hotel="hotel",e.Events="events"}(m||(m={})),function(e){e.FixedAmount="fixed",e.Percentage="percentage",e.Nights="nights"}(p||(p={})),function(e){e.Eventbrite="eventbrite",e.ATDW="atdw"}(O||(O={})),function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.DELETE="DELETE",e.PATCH="PATCH",e.OPTIONS="OPTIONS",e.HEAD="HEAD"}(R||(R={})),function(e){e.PercentageOfBooking="PercentageOfBooking",e.FixedChargePerRoom="FixedChargePerRoom",e.NightlyChargePerRoom="NightlyChargePerRoom",e.FixedChargePerBooking="FixedChargePerBooking",e.DepositSurcharge="DepositSurcharge"}(F||(F={}));const C=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},A=(e,n)=>e.includes("cdn.app.roomstay.io")?e+"?w="+n:e,E=e=>e,S=(e,n)=>{const o={};return n.forEach((n=>{n in e&&(o[n]=e[n])})),o};var T=t(60),N=t.n(T);const D={UP:N().ROUND_UP,DOWN:N().ROUND_DOWN,CEIL:N().ROUND_CEIL,FLOOR:N().ROUND_FLOOR,HALF_UP:N().ROUND_HALF_UP,HALF_DOWN:N().ROUND_HALF_DOWN,HALF_EVEN:N().ROUND_HALF_EVEN,HALF_CEIL:N().ROUND_HALF_CEIL,HALF_FLOOR:N().ROUND_HALF_FLOOR},v=(e,n)=>{const{precision:o=2,rounding:t=D.HALF_UP}=n||{};return new(N())(e).toDecimalPlaces(o,t).toNumber()};function B(e,n={}){const{baseAmount:o=0,numberOfNights:t=1,feeIncludedInBaseAmount:r=!1,extractedFromRates:a=!1,removedPercentages:i=[]}=n,c=v(o);switch(e.feeType){case F.PercentageOfBooking:if(r)return v(c*e.amount/(100+e.amount));if(a){const n=i.reduce(((e,n)=>e+n/(100+n)),0);return v(c/(1-n)*e.amount/(100+e.amount))}return v(c*(e.amount/100));case F.FixedChargePerRoom:case F.FixedChargePerBooking:return e.amount;case F.NightlyChargePerRoom:return v(e.amount*t);default:return 0}}const k=[F.FixedChargePerBooking],L=[F.PercentageOfBooking,F.FixedChargePerRoom,F.NightlyChargePerRoom],I=[F.PercentageOfBooking];function _(e,n){return e.filter((e=>n.includes(e.feeType)))}function x(e){return _(e,k)}function H(e){return _(e,L)}function U(e){return _(e,I)}function M(e){return{includeInRates:[F.PercentageOfBooking,F.NightlyChargePerRoom].includes(e),extractFeeFromRates:e===F.PercentageOfBooking,appliesToAddons:e===F.PercentageOfBooking,includePreviousFeesInCalculation:e===F.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-0",
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,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
- };
@@ -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
- };
@@ -1,6 +0,0 @@
1
- export interface IFeeOptions {
2
- includeInRates: boolean;
3
- alreadyIncludedInRates: boolean;
4
- appliesToAddons: boolean;
5
- includePreviousFeesInCalculation: boolean;
6
- }
File without changes