@chevre/domain 20.7.0-alpha.9 → 20.8.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.
@@ -134,6 +134,7 @@ function createPayObjectServiceOutput(params) {
134
134
  }
135
135
  function movieTicket2reservation4invoice(movieTicket, order, paymentMethodType) {
136
136
  var _a, _b;
137
+ let ticketToken;
137
138
  let priceComponents4invoice = [];
138
139
  // Orderから対象予約を取得
139
140
  const reservationOffer = (_a = order === null || order === void 0 ? void 0 : order.acceptedOffers) === null || _a === void 0 ? void 0 : _a.find((o) => {
@@ -167,6 +168,14 @@ function movieTicket2reservation4invoice(movieTicket, order, paymentMethodType)
167
168
  && o.itemOffered.reservedTicket.ticketedSeat.seatSection === movieTicket.serviceOutput.reservedTicket.ticketedSeat.seatSection;
168
169
  });
169
170
  if (reservationOffer !== undefined) {
171
+ if (reservationOffer.itemOffered.typeOf !== factory.reservationType.EventReservation
172
+ && reservationOffer.itemOffered.typeOf !== factory.reservationType.BusReservation) {
173
+ throw new factory.errors.NotImplemented(`itemOffered.typeOf: ${reservationOffer.itemOffered.typeOf} not implemented`);
174
+ }
175
+ const ticketTokenByReservationOffer = reservationOffer.itemOffered.reservedTicket.ticketToken;
176
+ if (typeof ticketTokenByReservationOffer === 'string' && ticketTokenByReservationOffer.length > 0) {
177
+ ticketToken = ticketTokenByReservationOffer;
178
+ }
170
179
  const priceComponent = (_b = reservationOffer.priceSpecification) === null || _b === void 0 ? void 0 : _b.priceComponent;
171
180
  if (Array.isArray(priceComponent)) {
172
181
  priceComponents4invoice = priceComponent.map((component) => {
@@ -188,12 +197,12 @@ function movieTicket2reservation4invoice(movieTicket, order, paymentMethodType)
188
197
  });
189
198
  }
190
199
  }
191
- return {
192
- priceSpecification: {
200
+ return Object.assign({ priceSpecification: {
193
201
  typeOf: factory.priceSpecificationType.CompoundPriceSpecification,
194
202
  priceComponent: priceComponents4invoice
195
- }
196
- };
203
+ } }, (typeof ticketToken === 'string')
204
+ ? { reservedTicket: { ticketToken } }
205
+ : undefined);
197
206
  }
198
207
  function createInformPaymentActions(params) {
199
208
  var _a;
@@ -27,7 +27,6 @@ function createAppliesToMovieTicket(params) {
27
27
  }
28
28
  const availablePaymentMethod = availablePaymentMethodType.codeValue;
29
29
  movieTicketTypeChargePriceSpec = {
30
- project: { typeOf: factory.organizationType.Project, id: params.project.id },
31
30
  typeOf: factory.priceSpecificationType.MovieTicketTypeChargeSpecification,
32
31
  name: { ja: params.ticketInfo.ticketName, en: params.ticketInfo.ticketNameEng },
33
32
  price: Number(params.ticketInfo.addPrice),
@@ -49,11 +48,89 @@ function createAppliesToMovieTicket(params) {
49
48
  }
50
49
  return { movieTicketTypeChargePriceSpec, appliesToMovieTicket };
51
50
  }
51
+ function createPriceComponent(params) {
52
+ var _a, _b, _c, _d, _e, _f, _g;
53
+ const acceptedOffer = params.acceptedOffer;
54
+ const availableUnitPriceOffer = params.availableUnitPriceOffer;
55
+ const { name, ticketInfo } = acceptedOffer;
56
+ // appliesToMovieTicket.serviceOutput.typeOfを自動補完(2023-03-13~)
57
+ const { appliesToMovieTicket, movieTicketTypeChargePriceSpec } = createAppliesToMovieTicket({
58
+ ticketInfo,
59
+ availablePaymentMethodTypes: params.availablePaymentMethodTypes
60
+ });
61
+ let surfrockChargePriceSpec;
62
+ let appliesToMovieTicket4surfrock;
63
+ // appliesToSurfrockの指定があれば強制的にMovieTicket決済
64
+ let eligibleMonetaryAmount;
65
+ const surfrockIdentifier = (_b = (_a = acceptedOffer.priceSpecification) === null || _a === void 0 ? void 0 : _a.appliesToSurfrock) === null || _b === void 0 ? void 0 : _b.identifier;
66
+ const surfrockPaymentMethodType = (_e = (_d = (_c = acceptedOffer.priceSpecification) === null || _c === void 0 ? void 0 : _c.appliesToSurfrock) === null || _d === void 0 ? void 0 : _d.serviceOutput) === null || _e === void 0 ? void 0 : _e.typeOf;
67
+ if (typeof surfrockIdentifier === 'string' && surfrockIdentifier.length > 0
68
+ && typeof surfrockPaymentMethodType === 'string' && surfrockPaymentMethodType.length > 0) {
69
+ // serviceTypeはticketCode
70
+ const serviceType = (_g = (_f = availableUnitPriceOffer.additionalProperty) === null || _f === void 0 ? void 0 : _f.find((p) => p.name === 'ticketCode')) === null || _g === void 0 ? void 0 : _g.value;
71
+ if (typeof serviceType !== 'string') {
72
+ throw new factory.errors.NotFound('ticketCode of unitPriceOffer');
73
+ }
74
+ surfrockChargePriceSpec = {
75
+ appliesToMovieTicket: {
76
+ typeOf: factory.service.paymentService.PaymentServiceType.MovieTicket,
77
+ serviceOutput: { typeOf: surfrockPaymentMethodType },
78
+ serviceType
79
+ },
80
+ appliesToVideoFormat: 'Default',
81
+ name,
82
+ price: 0,
83
+ priceCurrency: factory.priceCurrency.JPY,
84
+ typeOf: factory.priceSpecificationType.MovieTicketTypeChargeSpecification,
85
+ valueAddedTaxIncluded: true
86
+ };
87
+ appliesToMovieTicket4surfrock = {
88
+ typeOf: factory.service.paymentService.PaymentServiceType.MovieTicket,
89
+ identifier: surfrockIdentifier,
90
+ serviceOutput: { typeOf: surfrockPaymentMethodType },
91
+ serviceType
92
+ };
93
+ }
94
+ else {
95
+ // appliesToSurfrockの指定がなければ単価オファーの適用通貨条件を強制適用
96
+ if (Array.isArray(availableUnitPriceOffer.eligibleMonetaryAmount)) {
97
+ eligibleMonetaryAmount = availableUnitPriceOffer.eligibleMonetaryAmount;
98
+ }
99
+ }
100
+ const unitPriceSpec = Object.assign({ typeOf: factory.priceSpecificationType.UnitPriceSpecification, name: { ja: ticketInfo.ticketName, en: ticketInfo.ticketNameEng }, price: Number(ticketInfo.stdPrice), priceCurrency: factory.priceCurrency.JPY, referenceQuantity: {
101
+ typeOf: 'QuantitativeValue',
102
+ unitCode: factory.unitCode.C62,
103
+ value: 1
104
+ }, valueAddedTaxIncluded: true }, (appliesToMovieTicket !== undefined || appliesToMovieTicket4surfrock !== undefined)
105
+ ? {
106
+ appliesToMovieTicket: [
107
+ ...(appliesToMovieTicket !== undefined) ? [appliesToMovieTicket] : [],
108
+ ...(appliesToMovieTicket4surfrock !== undefined) ? [appliesToMovieTicket4surfrock] : []
109
+ ]
110
+ }
111
+ : undefined);
112
+ switch (ticketInfo.limitUnit) {
113
+ case '001':
114
+ unitPriceSpec.referenceQuantity.value = Number(ticketInfo.limitCount);
115
+ unitPriceSpec.price = Number(ticketInfo.limitCount) * Number(ticketInfo.stdPrice);
116
+ break;
117
+ case '002':
118
+ unitPriceSpec.referenceQuantity.minValue = Number(ticketInfo.limitCount);
119
+ break;
120
+ default:
121
+ unitPriceSpec.referenceQuantity.value = 1;
122
+ }
123
+ const priceComponent = [
124
+ unitPriceSpec,
125
+ ...(movieTicketTypeChargePriceSpec !== undefined) ? [movieTicketTypeChargePriceSpec] : [],
126
+ ...(surfrockChargePriceSpec !== undefined) ? [surfrockChargePriceSpec] : []
127
+ ];
128
+ return { priceComponent, eligibleMonetaryAmount };
129
+ }
52
130
  /**
53
131
  * 受け入れらたオファーの内容を検証
54
132
  */
55
133
  function validateAcceptedOffers(params) {
56
- // tslint:disable-next-line:max-func-body-length
57
134
  return (repos) => __awaiter(this, void 0, void 0, function* () {
58
135
  const offerIds = (Array.isArray(params.object.acceptedOffer))
59
136
  ? [...new Set(params.object.acceptedOffer.map((o) => o.id))]
@@ -66,9 +143,8 @@ function validateAcceptedOffers(params) {
66
143
  project: { id: { $eq: params.project.id } }
67
144
  });
68
145
  }
69
- // tslint:disable-next-line:max-func-body-length
70
146
  const acceptedOffers = params.object.acceptedOffer.map((acceptedOffer) => {
71
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
147
+ var _a, _b, _c, _d, _e, _f;
72
148
  const availableUnitPriceOffer = availableUnitPriceOffers.find((unitPriceOffer) => unitPriceOffer.id === acceptedOffer.id);
73
149
  if (availableUnitPriceOffer === undefined) {
74
150
  throw new factory.errors.NotFound(factory.offerType.Offer, `${acceptedOffer.identifier} not found`);
@@ -77,69 +153,12 @@ function validateAcceptedOffers(params) {
77
153
  if (priceSpecification === undefined) {
78
154
  throw new factory.errors.NotFound('priceSpecification');
79
155
  }
80
- const unitPriceSpecByRequest = priceSpecification.priceComponent.find((component) => component.typeOf === factory.priceSpecificationType.UnitPriceSpecification);
81
- if (unitPriceSpecByRequest === undefined) {
82
- throw new factory.errors.ArgumentNull('offer.priceSpecification.priceComponent');
83
- }
84
- // appliesToMovieTicket.serviceOutput.typeOfを自動補完(2023-03-13~)
85
- const { appliesToMovieTicket, movieTicketTypeChargePriceSpec } = createAppliesToMovieTicket({
86
- project: { id: params.project.id },
87
- ticketInfo,
88
- availablePaymentMethodTypes: params.availablePaymentMethodTypes
156
+ // priceComponentを再生成(2023-03-14~)
157
+ const { priceComponent, eligibleMonetaryAmount } = createPriceComponent({
158
+ availablePaymentMethodTypes: params.availablePaymentMethodTypes,
159
+ acceptedOffer,
160
+ availableUnitPriceOffer
89
161
  });
90
- let surfrockChargePriceSpec;
91
- let appliesToMovieTicket4surfrock;
92
- // appliesToSurfrockの指定があれば強制的にMovieTicket決済
93
- let eligibleMonetaryAmount;
94
- const surfrockIdentifier = (_b = (_a = acceptedOffer.priceSpecification) === null || _a === void 0 ? void 0 : _a.appliesToSurfrock) === null || _b === void 0 ? void 0 : _b.identifier;
95
- const surfrockPaymentMethodType = (_e = (_d = (_c = acceptedOffer.priceSpecification) === null || _c === void 0 ? void 0 : _c.appliesToSurfrock) === null || _d === void 0 ? void 0 : _d.serviceOutput) === null || _e === void 0 ? void 0 : _e.typeOf;
96
- if (typeof surfrockIdentifier === 'string' && surfrockIdentifier.length > 0
97
- && typeof surfrockPaymentMethodType === 'string' && surfrockPaymentMethodType.length > 0) {
98
- // serviceTypeはticketCode
99
- const serviceType = (_g = (_f = availableUnitPriceOffer.additionalProperty) === null || _f === void 0 ? void 0 : _f.find((p) => p.name === 'ticketCode')) === null || _g === void 0 ? void 0 : _g.value;
100
- if (typeof serviceType !== 'string') {
101
- throw new factory.errors.NotFound('ticketCode of unitPriceOffer');
102
- }
103
- surfrockChargePriceSpec = {
104
- appliesToMovieTicket: {
105
- typeOf: factory.service.paymentService.PaymentServiceType.MovieTicket,
106
- serviceOutput: { typeOf: surfrockPaymentMethodType },
107
- serviceType
108
- },
109
- appliesToVideoFormat: 'Default',
110
- name,
111
- price: 0,
112
- priceCurrency: factory.priceCurrency.JPY,
113
- typeOf: factory.priceSpecificationType.MovieTicketTypeChargeSpecification,
114
- valueAddedTaxIncluded: true
115
- };
116
- appliesToMovieTicket4surfrock = {
117
- typeOf: factory.service.paymentService.PaymentServiceType.MovieTicket,
118
- identifier: surfrockIdentifier,
119
- serviceOutput: { typeOf: surfrockPaymentMethodType },
120
- serviceType
121
- };
122
- }
123
- else {
124
- // appliesToSurfrockの指定がなければ単価オファーの適用通貨条件を強制適用
125
- if (Array.isArray(availableUnitPriceOffer.eligibleMonetaryAmount)) {
126
- eligibleMonetaryAmount = availableUnitPriceOffer.eligibleMonetaryAmount;
127
- }
128
- }
129
- const unitPriceSpec = Object.assign({ typeOf: factory.priceSpecificationType.UnitPriceSpecification, name: unitPriceSpecByRequest.name, price: unitPriceSpecByRequest.price, priceCurrency: factory.priceCurrency.JPY, referenceQuantity: unitPriceSpecByRequest.referenceQuantity, valueAddedTaxIncluded: true }, (appliesToMovieTicket !== undefined || appliesToMovieTicket4surfrock !== undefined)
130
- ? {
131
- appliesToMovieTicket: [
132
- ...(appliesToMovieTicket !== undefined) ? [appliesToMovieTicket] : [],
133
- ...(appliesToMovieTicket4surfrock !== undefined) ? [appliesToMovieTicket4surfrock] : []
134
- ]
135
- }
136
- : undefined);
137
- // priceComponentを再生成
138
- const priceComponent = [
139
- unitPriceSpec,
140
- ...(movieTicketTypeChargePriceSpec !== undefined) ? [movieTicketTypeChargePriceSpec] : [],
141
- ...(surfrockChargePriceSpec !== undefined) ? [surfrockChargePriceSpec] : []
142
- ];
143
162
  priceSpecification.priceComponent = priceComponent;
144
163
  return Object.assign(Object.assign({ additionalProperty,
145
164
  itemOffered,
@@ -151,10 +170,10 @@ function validateAcceptedOffers(params) {
151
170
  priceCurrency: availableUnitPriceOffer.priceCurrency, id: String(availableUnitPriceOffer.id), identifier: String(availableUnitPriceOffer.identifier), typeOf: availableUnitPriceOffer.typeOf }, (Array.isArray(eligibleMonetaryAmount)) ? { eligibleMonetaryAmount } : undefined), {
152
171
  // tslint:disable-next-line:no-suspicious-comment
153
172
  // TODO itemOfferedに完全置き換え
154
- seatNumber: (_k = (_j = (_h = itemOffered.serviceOutput) === null || _h === void 0 ? void 0 : _h.reservedTicket) === null || _j === void 0 ? void 0 : _j.ticketedSeat) === null || _k === void 0 ? void 0 : _k.seatNumber,
173
+ seatNumber: (_c = (_b = (_a = itemOffered.serviceOutput) === null || _a === void 0 ? void 0 : _a.reservedTicket) === null || _b === void 0 ? void 0 : _b.ticketedSeat) === null || _c === void 0 ? void 0 : _c.seatNumber,
155
174
  // tslint:disable-next-line:no-suspicious-comment
156
175
  // TODO itemOfferedに完全置き換え
157
- seatSection: (_o = (_m = (_l = itemOffered.serviceOutput) === null || _l === void 0 ? void 0 : _l.reservedTicket) === null || _m === void 0 ? void 0 : _m.ticketedSeat) === null || _o === void 0 ? void 0 : _o.seatSection
176
+ seatSection: (_f = (_e = (_d = itemOffered.serviceOutput) === null || _d === void 0 ? void 0 : _d.reservedTicket) === null || _e === void 0 ? void 0 : _e.ticketedSeat) === null || _f === void 0 ? void 0 : _f.seatSection
158
177
  });
159
178
  });
160
179
  return { acceptedOffers };
package/package.json CHANGED
@@ -9,8 +9,8 @@
9
9
  }
10
10
  ],
11
11
  "dependencies": {
12
- "@chevre/factory": "4.301.0-alpha.2",
13
- "@cinerino/sdk": "3.149.0-alpha.4",
12
+ "@chevre/factory": "4.302.0",
13
+ "@cinerino/sdk": "3.149.0",
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.7.0-alpha.9"
123
+ "version": "20.8.0"
124
124
  }