@chevre/domain 21.8.0-alpha.20 → 21.8.0-alpha.22

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.
@@ -17,9 +17,11 @@ async function main() {
17
17
  typeOf: { $eq: chevre.factory.assetTransactionType.Pay },
18
18
  // 'project.id': { $eq: project.id },
19
19
  startDate: {
20
- $gte: moment()
20
+ $gte: moment('2023-05-08T00:00:00Z')
21
21
  // tslint:disable-next-line:no-magic-numbers
22
- .add(-24, 'months')
22
+ // .add(-12, 'months')
23
+ .toDate(),
24
+ $lte: moment('2023-08-30T21:00:00Z')
23
25
  .toDate()
24
26
  }
25
27
  },
@@ -48,7 +50,8 @@ async function main() {
48
50
  if (alreadyMigrated) {
49
51
  console.log(
50
52
  'already exist.',
51
- payTransaction.project.id, payTransaction.typeOf, payTransaction.transactionNumber, payTransaction.startDate, i);
53
+ payTransaction.project.id, payTransaction.typeOf, payTransaction.transactionNumber, payTransaction.startDate,
54
+ i, updateCount);
52
55
  } else {
53
56
  const paymentMethodIdentifier = (<any>payTransaction.object.paymentMethod).typeOf;
54
57
  console.log(
@@ -52,6 +52,7 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
52
52
  };
53
53
  }, {
54
54
  additionalProperty: any[];
55
+ offers: any[];
55
56
  addOn: any[];
56
57
  availability: string;
57
58
  availableAtOrFrom: any[];
@@ -83,6 +84,7 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
83
84
  validRateLimit?: any;
84
85
  }, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
85
86
  additionalProperty: any[];
87
+ offers: any[];
86
88
  addOn: any[];
87
89
  availability: string;
88
90
  availableAtOrFrom: any[];
@@ -114,6 +116,7 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
114
116
  validRateLimit?: any;
115
117
  }>> & Omit<import("mongoose").FlatRecord<{
116
118
  additionalProperty: any[];
119
+ offers: any[];
117
120
  addOn: any[];
118
121
  availability: string;
119
122
  availableAtOrFrom: any[];
@@ -29,6 +29,7 @@ const schema = new mongoose_1.Schema({
29
29
  availableAtOrFrom: [mongoose_1.SchemaTypes.Mixed],
30
30
  hasMerchantReturnPolicy: mongoose_1.SchemaTypes.Mixed,
31
31
  itemOffered: mongoose_1.SchemaTypes.Mixed,
32
+ offers: [mongoose_1.SchemaTypes.Mixed],
32
33
  priceCurrency: String,
33
34
  priceSpecification: mongoose_1.SchemaTypes.Mixed,
34
35
  eligibleCustomerType: mongoose_1.SchemaTypes.Mixed,
@@ -386,21 +386,62 @@ function createReservations4transactionObject(params) {
386
386
  }
387
387
  }
388
388
  // 指定されたアドオンがオファーに存在すれば、アドオンの単価仕様作成
389
- let acceptedAddOns = [];
389
+ const acceptedAddOns = [];
390
390
  let availableAddOns;
391
- const acceptedAddOnParams = acceptedOffer.addOn;
392
- if (Array.isArray(acceptedAddOnParams) && acceptedAddOnParams.length > 0) {
391
+ const acceptedAddOnsParams = acceptedOffer.addOn;
392
+ if (Array.isArray(acceptedAddOnsParams) && acceptedAddOnsParams.length > 0) {
393
393
  // アドオンオファー検索(2023-03-02~)
394
394
  availableAddOns = yield searchAvailableAddOns({
395
- ids: acceptedAddOnParams.map((acceptedAddOn) => String(acceptedAddOn.id)),
395
+ ids: acceptedAddOnsParams.map((acceptedAddOn) => String(acceptedAddOn.id)),
396
396
  project: { id: params.transaction.project.id },
397
397
  ticketOffer,
398
398
  availableAtOrFrom: params.availableAtOrFrom
399
399
  })(repos);
400
400
  }
401
- // availableAddOns = <factory.product.ITicketAddOn[] | undefined>ticketOffer.addOn;
402
- if (Array.isArray(availableAddOns) && Array.isArray(acceptedAddOnParams)) {
403
- acceptedAddOns = availableAddOns.filter((availableAddOn) => acceptedAddOnParams.some((acceptedAddOn) => availableAddOn.id === acceptedAddOn.id));
401
+ if (Array.isArray(availableAddOns) && Array.isArray(acceptedAddOnsParams)) {
402
+ acceptedAddOnsParams.forEach((acceptedAddOnParams) => {
403
+ var _a, _b, _c;
404
+ const availableAddOn = availableAddOns === null || availableAddOns === void 0 ? void 0 : availableAddOns.find((addOn) => addOn.id === acceptedAddOnParams.id);
405
+ if (availableAddOn !== undefined) {
406
+ // acceptedAddOnsの重複を避ける(単価オファーIDに対して)
407
+ if (!acceptedAddOns.some((addOn) => addOn.id === availableAddOn.id)) {
408
+ const availableAddOnReferenceQuantityValue = availableAddOn.priceSpecification.referenceQuantity.value;
409
+ if (typeof availableAddOnReferenceQuantityValue !== 'number') {
410
+ throw new factory.errors.NotImplemented('addOn.priceSpecification.referenceQuantity.value must be number');
411
+ }
412
+ // 受入数量はデフォルトで単価オファーの基準数量
413
+ let referenceQuantityValueAccepted = availableAddOnReferenceQuantityValue;
414
+ // 数量指定を検証(2023-08-31~)
415
+ const specifiedReferencedQuantityValue = (_b = (_a = acceptedAddOnParams.priceSpecification) === null || _a === void 0 ? void 0 : _a.referenceQuantity) === null || _b === void 0 ? void 0 : _b.value;
416
+ if (typeof specifiedReferencedQuantityValue === 'number') {
417
+ if (specifiedReferencedQuantityValue < 1) {
418
+ throw new factory.errors.Argument('addOn.priceSpecification.referenceQuantity.value must be > 0');
419
+ }
420
+ // 数量が適用単位要件を満たしていなければエラー
421
+ if (specifiedReferencedQuantityValue % availableAddOnReferenceQuantityValue !== 0) {
422
+ throw new factory.errors.Argument('addOn.priceSpecification.referenceQuantity.value', `Offer ${availableAddOn.id} requires reference quantity value ${specifiedReferencedQuantityValue}`);
423
+ }
424
+ // 基準数量上書き
425
+ referenceQuantityValueAccepted = specifiedReferencedQuantityValue;
426
+ }
427
+ const priceAccepted = availableAddOn.priceSpecification.price *
428
+ (referenceQuantityValueAccepted / availableAddOnReferenceQuantityValue);
429
+ const accountsReceivableAccepted = (typeof ((_c = availableAddOn.priceSpecification.accounting) === null || _c === void 0 ? void 0 : _c.accountsReceivable) === 'number')
430
+ ? availableAddOn.priceSpecification.accounting.accountsReceivable *
431
+ (referenceQuantityValueAccepted / availableAddOnReferenceQuantityValue)
432
+ : undefined;
433
+ const acceptedAddOn = Object.assign(Object.assign({}, availableAddOn), { priceSpecification: Object.assign(Object.assign(Object.assign({}, availableAddOn.priceSpecification), (typeof accountsReceivableAccepted === 'number')
434
+ ? {
435
+ accounting: Object.assign(Object.assign({}, availableAddOn.priceSpecification.accounting), { accountsReceivable: accountsReceivableAccepted, typeOf: 'Accounting' })
436
+ }
437
+ : undefined), { price: priceAccepted, referenceQuantity: Object.assign(Object.assign({}, availableAddOn.priceSpecification.referenceQuantity), { value: referenceQuantityValueAccepted }) }) });
438
+ acceptedAddOns.push(acceptedAddOn);
439
+ }
440
+ }
441
+ });
442
+ // acceptedAddOns = availableAddOns.filter(
443
+ // (availableAddOn) => acceptedAddOnsParams.some((acceptedAddOn) => availableAddOn.id === acceptedAddOn.id)
444
+ // );
404
445
  }
405
446
  const subReservation = (_j = (_h = acceptedOffer.itemOffered) === null || _h === void 0 ? void 0 : _h.serviceOutput) === null || _j === void 0 ? void 0 : _j.subReservation;
406
447
  const reservationId = `${reservationNumber}-${reservationIndex}`;
@@ -299,6 +299,7 @@ function createReservation(params) {
299
299
  }
300
300
  return reservationItem;
301
301
  }
302
+ // tslint:disable-next-line:max-func-body-length
302
303
  function coaTicket2offer(params) {
303
304
  var _a, _b;
304
305
  // 適用通貨区分
@@ -322,7 +323,6 @@ function coaTicket2offer(params) {
322
323
  }]
323
324
  : undefined;
324
325
  const unitPriceSpec = {
325
- // project: { typeOf: factory.organizationType.Project, id: params.project.id },
326
326
  typeOf: factory.priceSpecificationType.UnitPriceSpecification,
327
327
  price: 0,
328
328
  priceCurrency: factory.priceCurrency.JPY,
@@ -332,15 +332,25 @@ function coaTicket2offer(params) {
332
332
  unitCode: factory.unitCode.C62,
333
333
  value: 1
334
334
  }
335
- // appliesToMovieTicket?: {};
336
335
  };
337
336
  const identifier = (0, util_1.format)('%s-%s-%s', factory.service.webAPI.Identifier.COA, params.theaterCode, params.ticketResult.ticketCode);
338
- return Object.assign(Object.assign(Object.assign({ project: { typeOf: factory.organizationType.Project, id: params.project.id }, typeOf: factory.offerType.Offer, priceCurrency: factory.priceCurrency.JPY, id: '', identifier: identifier, name: {
339
- ja: params.ticketResult.ticketName,
340
- en: (typeof params.ticketResult.ticketNameEng === 'string')
341
- ? params.ticketResult.ticketNameEng
342
- : ''
343
- }, description: {
337
+ const offerName = {
338
+ ja: params.ticketResult.ticketName,
339
+ en: (typeof params.ticketResult.ticketNameEng === 'string')
340
+ ? params.ticketResult.ticketNameEng
341
+ : ''
342
+ };
343
+ const subOfferPriceSpec = {
344
+ price: unitPriceSpec.price,
345
+ typeOf: unitPriceSpec.typeOf
346
+ };
347
+ const subOffers = [{
348
+ typeOf: factory.offerType.Offer,
349
+ identifier: identifier,
350
+ name: offerName,
351
+ priceSpecification: subOfferPriceSpec
352
+ }];
353
+ return Object.assign(Object.assign(Object.assign({ project: { typeOf: factory.organizationType.Project, id: params.project.id }, typeOf: factory.offerType.Offer, priceCurrency: factory.priceCurrency.JPY, id: '', identifier: identifier, name: offerName, description: {
344
354
  ja: '',
345
355
  en: ''
346
356
  }, alternateName: {
@@ -350,7 +360,7 @@ function coaTicket2offer(params) {
350
360
  : ''
351
361
  }, availability: factory.itemAvailability.InStock, itemOffered: {
352
362
  typeOf: factory.product.ProductType.EventService
353
- }, priceSpecification: unitPriceSpec }, (Array.isArray(eligibleMembershipType)) ? { eligibleMembershipType } : undefined), (Array.isArray(eligibleMonetaryAmount)) ? { eligibleMonetaryAmount } : undefined), { additionalProperty: [
363
+ }, offers: subOffers, priceSpecification: unitPriceSpec }, (Array.isArray(eligibleMembershipType)) ? { eligibleMembershipType } : undefined), (Array.isArray(eligibleMonetaryAmount)) ? { eligibleMonetaryAmount } : undefined), { additionalProperty: [
354
364
  { name: 'theaterCode', value: params.theaterCode },
355
365
  ...Object.keys(params.ticketResult)
356
366
  .map((key) => {
@@ -186,9 +186,14 @@ function processVoidPayTransaction(params) {
186
186
  project: { id: { $eq: action.project.id } },
187
187
  typeOf: factory.assetTransactionType.Pay,
188
188
  transactionNumber: { $eq: transactionNumber }
189
- });
190
- if (payTransactions.length > 0) {
191
- yield PayTransactionService.cancel({ transactionNumber })(repos);
189
+ }, ['_id', 'status']);
190
+ const payTransaction = payTransactions.shift();
191
+ if (payTransaction !== undefined) {
192
+ // ステータス検証(Expiredから実行される可能性がある)
193
+ if (payTransaction.status !== factory.transactionStatusType.Canceled
194
+ && payTransaction.status !== factory.transactionStatusType.Expired) {
195
+ yield PayTransactionService.cancel({ transactionNumber })(repos);
196
+ }
192
197
  }
193
198
  }
194
199
  yield repos.action.cancel({ typeOf: action.typeOf, id: action.id });
@@ -159,7 +159,11 @@ function transaction2refundFee(params) {
159
159
  return refundFee;
160
160
  }
161
161
  function createStartRefundTransactionParams(params) {
162
- var _a;
162
+ var _a, _b;
163
+ const paymentMethodType = (_a = params.object.paymentMethod) === null || _a === void 0 ? void 0 : _a.identifier;
164
+ if (typeof paymentMethodType !== 'string') {
165
+ throw new factory.errors.NotFound('object.paymentMethod.identifier');
166
+ }
163
167
  return {
164
168
  project: { id: params.project.id, typeOf: factory.organizationType.Project },
165
169
  typeOf: factory.assetTransactionType.Refund,
@@ -173,11 +177,12 @@ function createStartRefundTransactionParams(params) {
173
177
  recipient: { typeOf: params.recipient.typeOf, name: params.recipient.name },
174
178
  object: {
175
179
  typeOf: params.paymentServiceType,
176
- id: (typeof ((_a = params.object.issuedThrough) === null || _a === void 0 ? void 0 : _a.id) === 'string') ? params.object.issuedThrough.id : '',
180
+ id: (typeof ((_b = params.object.issuedThrough) === null || _b === void 0 ? void 0 : _b.id) === 'string') ? params.object.issuedThrough.id : '',
177
181
  paymentMethod: {
178
182
  additionalProperty: params.object.additionalProperty,
179
183
  name: params.object.name,
180
- typeOf: params.object.typeOf,
184
+ // typeOf: params.object.typeOf,
185
+ typeOf: paymentMethodType,
181
186
  paymentMethodId: params.object.paymentMethodId
182
187
  },
183
188
  refundFee: params.refundFee
@@ -149,10 +149,10 @@ function authorizeSeatReservationActions2requiredMovieTickets(params) {
149
149
  appliesToMovieTickets4paymentMethod = appliesToMovieTickets4reservation.filter((a) => {
150
150
  return a.serviceOutput.typeOf === paymentMethodType;
151
151
  });
152
- }
153
- else if (typeof (appliesToMovieTickets4reservation === null || appliesToMovieTickets4reservation === void 0 ? void 0 : appliesToMovieTickets4reservation.identifier) === 'string') {
154
- // Arrayでない場合を廃止(2022-08-01~)
155
- throw new factory.errors.NotImplemented('appliesToMovieTickets.typeOf as string not implemented');
152
+ // Array以外への考慮自体を廃止(2023-09-01~)
153
+ // } else if (typeof appliesToMovieTickets4reservation?.identifier === 'string') {
154
+ // // Arrayでない場合を廃止(2022-08-01~)
155
+ // throw new factory.errors.NotImplemented('appliesToMovieTickets.typeOf as string not implemented');
156
156
  }
157
157
  if (Array.isArray(appliesToMovieTickets4paymentMethod) && appliesToMovieTickets4paymentMethod.length > 0) {
158
158
  appliesToMovieTickets4paymentMethod.forEach((appliesToMovieTicket) => {
@@ -138,18 +138,19 @@ function createReturnPaymentMethodIssuedThroughMovieTicketActions(params) {
138
138
  const order = params.order;
139
139
  const returnFeesMovieTicketByTransaction = params.transaction.object.returnPolicy.returnFeesMovieTicket;
140
140
  return Promise.all(params.order.paymentMethods
141
- .filter((paymentMethod) => {
142
- return paymentMethod.issuedThrough.typeOf === factory.service.paymentService.PaymentServiceType.MovieTicket;
141
+ .filter((invoice) => {
142
+ return invoice.issuedThrough.typeOf === factory.service.paymentService.PaymentServiceType.MovieTicket;
143
143
  })
144
144
  // 決済カード着券取消有無設定を適用
145
- .filter((paymentMethod) => {
145
+ .filter((invoice) => {
146
146
  // デフォルトで実行する
147
147
  let returnPaymentMethod = true;
148
- const movieTicketIdentifier = paymentMethod.accountId;
148
+ const movieTicketIdentifier = invoice.accountId;
149
149
  const returnFeesMovieTicketSettingsByIdentifier = returnFeesMovieTicketByTransaction === null || returnFeesMovieTicketByTransaction === void 0 ? void 0 : returnFeesMovieTicketByTransaction.filter((r) => {
150
- var _a;
150
+ var _a, _b;
151
151
  return r.identifier === String(movieTicketIdentifier)
152
- && ((_a = r.serviceOutput) === null || _a === void 0 ? void 0 : _a.typeOf) === paymentMethod.typeOf;
152
+ // && r.serviceOutput?.typeOf === invoice.typeOf;
153
+ && ((_a = r.serviceOutput) === null || _a === void 0 ? void 0 : _a.typeOf) === ((_b = invoice.paymentMethod) === null || _b === void 0 ? void 0 : _b.identifier);
153
154
  });
154
155
  // 設定がなければスルー
155
156
  if (Array.isArray(returnFeesMovieTicketSettingsByIdentifier) && returnFeesMovieTicketSettingsByIdentifier.length > 0) {
@@ -356,7 +356,11 @@ function isSellerReturnPolicyApplicable(params) {
356
356
  if (Array.isArray(applicablePaymentMethod)) {
357
357
  const everyOrderApplicable = params.orders.every((order) => {
358
358
  // 全決済方法区分がapplicablePaymentMethodに含まれれば適用
359
- return order.paymentMethods.every((paymentMethod) => applicablePaymentMethod.includes(paymentMethod.typeOf));
359
+ return order.paymentMethods.every((invoice) => {
360
+ var _a;
361
+ return typeof ((_a = invoice.paymentMethod) === null || _a === void 0 ? void 0 : _a.identifier) === 'string'
362
+ && applicablePaymentMethod.includes(invoice.paymentMethod.identifier);
363
+ });
360
364
  });
361
365
  // 全注文について確認ができれば適用
362
366
  if (everyOrderApplicable) {
package/package.json CHANGED
@@ -9,8 +9,8 @@
9
9
  }
10
10
  ],
11
11
  "dependencies": {
12
- "@chevre/factory": "4.327.0",
13
- "@cinerino/sdk": "3.165.0",
12
+ "@chevre/factory": "4.329.0-alpha.0",
13
+ "@cinerino/sdk": "3.166.0-alpha.3",
14
14
  "@motionpicture/coa-service": "9.2.0",
15
15
  "@motionpicture/gmo-service": "5.2.0",
16
16
  "@sendgrid/mail": "6.4.0",
@@ -117,5 +117,5 @@
117
117
  "postversion": "git push origin --tags",
118
118
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
119
119
  },
120
- "version": "21.8.0-alpha.20"
120
+ "version": "21.8.0-alpha.22"
121
121
  }