@chevre/domain 20.4.0-alpha.23 → 20.4.0-alpha.24

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.
@@ -314,9 +314,8 @@ function acceptedOfferWithoutDetail2acceptedOffer(params) {
314
314
  addOn: (Array.isArray(offerWithoutDetail.addOn))
315
315
  ? offerWithoutDetail.addOn.map((a) => {
316
316
  return {
317
- // project: offer.project,
318
317
  typeOf: factory.offerType.Offer,
319
- id: a.id,
318
+ id: String(a.id),
320
319
  priceCurrency: offer.priceCurrency
321
320
  };
322
321
  })
@@ -90,7 +90,12 @@ function searchEventTicketOffersByEvent(params) {
90
90
  for (const addOn of availableOffer.addOn) {
91
91
  const productId = (_b = addOn.itemOffered) === null || _b === void 0 ? void 0 : _b.id;
92
92
  if (typeof productId === 'string') {
93
- const productOffers = yield searchAddOns({ product: { id: productId }, onlyValid: params.onlyValid })(repos);
93
+ const productOffers = yield searchAddOns({
94
+ product: { id: productId },
95
+ store: params.store,
96
+ addSortIndex: params.addSortIndex,
97
+ onlyValid: params.onlyValid
98
+ })(repos);
94
99
  offerAddOn.push(...productOffers);
95
100
  }
96
101
  }
@@ -199,33 +204,45 @@ function checkAvailability(params) {
199
204
  function searchAddOns(params) {
200
205
  return (repos) => __awaiter(this, void 0, void 0, function* () {
201
206
  var _a, _b, _c;
202
- let offers = [];
207
+ let addOns = [];
203
208
  const productId = (_a = params.product) === null || _a === void 0 ? void 0 : _a.id;
204
209
  if (typeof productId === 'string') {
205
210
  const productWithAddOns = yield repos.product.findById({ id: productId });
206
211
  const offerCatalogId = (_b = productWithAddOns.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.id;
207
212
  if (typeof offerCatalogId === 'string') {
208
- const findOffersByOfferCatalogIdResult = yield repos.offer.findOffersByOfferCatalogId({
213
+ const { offers, sortedOfferIds } = yield repos.offer.findOffersByOfferCatalogId({
209
214
  offerCatalog: { id: offerCatalogId },
210
215
  availableAtOrFrom: { id: (_c = params.store) === null || _c === void 0 ? void 0 : _c.id },
211
216
  excludeAppliesToMovieTicket: false,
212
217
  onlyValid: params.onlyValid === true,
213
218
  sort: true
214
219
  });
215
- offers = findOffersByOfferCatalogIdResult.offers;
216
- offers = offers.map((o) => {
217
- return Object.assign(Object.assign({ additionalProperty: Array.isArray(o.additionalProperty) ? o.additionalProperty : [], alternateName: o.alternateName, availability: o.availability, availableAtOrFrom: o.availableAtOrFrom, color: o.color, description: o.description, id: o.id, identifier: o.identifier, itemOffered: {
218
- description: productWithAddOns.description,
219
- id: productWithAddOns.id,
220
- name: productWithAddOns.name,
221
- productID: productWithAddOns.productID,
222
- project: productWithAddOns.project,
223
- typeOf: productWithAddOns.typeOf
224
- }, name: o.name, priceCurrency: o.priceCurrency, priceSpecification: o.priceSpecification, project: o.project, typeOf: o.typeOf }, (o.validFrom instanceof Date) ? { validFrom: o.validFrom } : undefined), (o.validThrough instanceof Date) ? { validThrough: o.validThrough } : undefined);
220
+ const unitPriceOffers = offers;
221
+ addOns = unitPriceOffers.map((o) => {
222
+ let sortIndex;
223
+ if (params.addSortIndex) {
224
+ sortIndex = sortedOfferIds.indexOf(String(o.id));
225
+ }
226
+ const itemOffered4addOn = {
227
+ description: productWithAddOns.description,
228
+ id: productWithAddOns.id,
229
+ name: productWithAddOns.name,
230
+ productID: productWithAddOns.productID,
231
+ // project: productWithAddOns.project,
232
+ typeOf: productWithAddOns.typeOf
233
+ };
234
+ return Object.assign(Object.assign(Object.assign({
235
+ // additionalProperty: Array.isArray(o.additionalProperty) ? o.additionalProperty : [],
236
+ alternateName: o.alternateName, availability: o.availability,
237
+ // availableAtOrFrom: o.availableAtOrFrom,
238
+ // color: o.color,
239
+ description: o.description, id: String(o.id), identifier: o.identifier, itemOffered: itemOffered4addOn, name: o.name, priceCurrency: o.priceCurrency, priceSpecification: o.priceSpecification,
240
+ // project: o.project,
241
+ typeOf: o.typeOf }, (o.validFrom instanceof Date) ? { validFrom: o.validFrom } : undefined), (o.validThrough instanceof Date) ? { validThrough: o.validThrough } : undefined), (typeof sortIndex === 'number') ? { sortIndex } : undefined);
225
242
  });
226
243
  }
227
244
  }
228
- return offers;
245
+ return addOns;
229
246
  });
230
247
  }
231
248
  /**
@@ -9,7 +9,7 @@ declare function createCompoundPriceSpec4event(params: {
9
9
  soundFormatChargeSpecifications: ICategoryCodeChargeSpecification[];
10
10
  videoFormatTypes: string[];
11
11
  availability?: factory.itemAvailability;
12
- addOn: factory.offer.IAddOn[];
12
+ addOn: factory.product.ITicketAddOn[];
13
13
  sortIndex?: number;
14
14
  }): factory.product.ITicketOffer & {
15
15
  sortIndex?: number;
package/package.json CHANGED
@@ -9,8 +9,8 @@
9
9
  }
10
10
  ],
11
11
  "dependencies": {
12
- "@chevre/factory": "4.289.0",
13
- "@cinerino/sdk": "3.140.0-alpha.16",
12
+ "@chevre/factory": "4.290.0",
13
+ "@cinerino/sdk": "3.140.0-alpha.18",
14
14
  "@motionpicture/coa-service": "9.2.0",
15
15
  "@motionpicture/gmo-service": "5.2.0",
16
16
  "@sendgrid/mail": "6.4.0",
@@ -120,5 +120,5 @@
120
120
  "postversion": "git push origin --tags",
121
121
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
122
122
  },
123
- "version": "20.4.0-alpha.23"
123
+ "version": "20.4.0-alpha.24"
124
124
  }