tripstorekrabi-shared 1.18.0 → 1.18.1

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 (2) hide show
  1. package/package.json +1 -1
  2. package/price.js +8 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tripstorekrabi-shared",
3
- "version": "1.18.0",
3
+ "version": "1.18.1",
4
4
  "description": "Shared library for Trip Store Krabi",
5
5
  "author": "Stefan Sommer <tonprince@gmail.com>",
6
6
  "repository": {
package/price.js CHANGED
@@ -49,8 +49,14 @@ function calculateSellingPrice(commissionRate, price) {
49
49
  }
50
50
 
51
51
  function calculateProductPrice(booking, pricing, options = { mode: SELLING_MODE }) {
52
- if (pricing.promotion && dayjs(booking.departureDate.toDate()).isBetween(pricing.promotion.startDate.toDate(), pricing.promotion.endDate.toDate(), "day", "[]")) {
53
- pricing = { ...pricing, volumes: pricing.promotion.volumes };
52
+ if (pricing.promotion) {
53
+ let departureDate = booking.departureDate instanceof Date ? dayjs(booking.departureDate) : typeof booking.departureDate.toDate === 'function' ? dayjs(booking.departureDate.toDate()) : null;
54
+ let startDate = pricing.promotion.startDate instanceof Date ? pricing.promotion.startDate : typeof pricing.promotion.startDate.toDate === 'function' ? pricing.promotion.startDate.toDate() : null;
55
+ let endDate = pricing.promotion.endDate instanceof Date ? pricing.promotion.endDate : typeof pricing.promotion.endDate.toDate === 'function' ? pricing.promotion.endDate.toDate() : null;
56
+
57
+ if (departureDate?.isBetween(startDate, endDate, "day", "[]")) {
58
+ pricing = { ...pricing, volumes: pricing.promotion.volumes };
59
+ }
54
60
  }
55
61
 
56
62
  let type = pricing.type;