@chevre/domain 21.6.0-alpha.1 → 21.6.0-alpha.3

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.
@@ -43,7 +43,7 @@ function createPayActions(params) {
43
43
  return payActions;
44
44
  }
45
45
  function createPayObject(params) {
46
- var _a, _b;
46
+ var _a;
47
47
  const transaction = params.transaction;
48
48
  const paymentMethod = transaction.object.paymentMethod;
49
49
  const paymentMethodType = String(paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.typeOf);
@@ -100,7 +100,7 @@ function createPayObject(params) {
100
100
  totalPaymentDue: {
101
101
  typeOf: 'MonetaryAmount',
102
102
  currency: factory.unitCode.C62,
103
- value: (_b = paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.movieTickets) === null || _b === void 0 ? void 0 : _b.length
103
+ value: (Array.isArray(paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.movieTickets)) ? paymentMethod.movieTickets.length : 0
104
104
  },
105
105
  typeOf: paymentMethodType
106
106
  }, movieTickets: paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.movieTickets }, (Array.isArray(paymentServiceOutput)) ? { serviceOutput: paymentServiceOutput } : undefined);
@@ -243,9 +243,6 @@ function processAuthorizeAccount(params, transaction, paymentServiceId) {
243
243
  typeOf: 'MonetaryAmount',
244
244
  currency,
245
245
  value: amount
246
- // value: (typeof pendingTransaction.object.amount === 'number')
247
- // ? pendingTransaction.object.amount
248
- // : pendingTransaction.object.amount.value
249
246
  };
250
247
  const savingPendingTransaction = {
251
248
  typeOf: pendingTransaction.typeOf,
@@ -113,7 +113,7 @@ exports.checkMovieTicket = checkMovieTicket;
113
113
  */
114
114
  function authorize(params, transaction, paymentServiceId, useCheckMovieTicketBeforePay, useCheckByIdentifierIfNotYet) {
115
115
  return (repos) => __awaiter(this, void 0, void 0, function* () {
116
- var _a, _b;
116
+ var _a;
117
117
  let accountId;
118
118
  let payAction;
119
119
  let accountsReceivablesByServiceType = [];
@@ -138,7 +138,7 @@ function authorize(params, transaction, paymentServiceId, useCheckMovieTicketBef
138
138
  paymentMethod: Object.assign({ additionalProperty: (Array.isArray(additionalProperty)) ? additionalProperty : [], name: paymentMethodName, paymentMethodId: paymentMethodId, totalPaymentDue: {
139
139
  typeOf: 'MonetaryAmount',
140
140
  currency: factory.unitCode.C62,
141
- value: (_b = paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.movieTickets) === null || _b === void 0 ? void 0 : _b.length
141
+ value: (Array.isArray(paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.movieTickets)) ? paymentMethod.movieTickets.length : 0
142
142
  }, typeOf: paymentMethodType }, (typeof accountId === 'string') ? { accountId } : undefined),
143
143
  movieTickets: paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.movieTickets
144
144
  };
@@ -53,6 +53,15 @@ function onResourceDeleted(params) {
53
53
  ids: params.id
54
54
  })(repos);
55
55
  break;
56
+ case factory.product.ProductType.EventService:
57
+ case factory.product.ProductType.Product:
58
+ case factory.product.ProductType.Transportation:
59
+ yield deleteResourcesByProduct({
60
+ project: { id: params.project.id },
61
+ ids: params.id,
62
+ typeOf: params.typeOf
63
+ })(repos);
64
+ break;
56
65
  default:
57
66
  // no op
58
67
  throw new factory.errors.NotImplemented(`${params.typeOf} onDeleted not implemented`);
@@ -333,3 +342,46 @@ function deleteResourcesByOfferCatalog(params) {
333
342
  }
334
343
  });
335
344
  }
345
+ function deleteResourcesByProduct(params) {
346
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
347
+ if (params.ids.length !== 1) {
348
+ throw new factory.errors.Argument('id', 'id.length must be 1');
349
+ }
350
+ for (const productId of params.ids) {
351
+ const deleteActionAttributes = {
352
+ agent: { id: params.project.id, typeOf: factory.organizationType.Project },
353
+ object: { id: productId, typeOf: params.typeOf },
354
+ project: { id: params.project.id, typeOf: factory.organizationType.Project },
355
+ typeOf: factory.actionType.DeleteAction
356
+ };
357
+ let deleteResult;
358
+ const action = yield repos.action.start(deleteActionAttributes);
359
+ try {
360
+ let deleteEventResult;
361
+ let updateOfferResult;
362
+ // 興行を設定されたイベント削除
363
+ deleteEventResult = yield repos.event.deleteManyByItemOfferedId({
364
+ project: { id: params.project.id },
365
+ offers: { itemOffered: { id: { $in: [productId] } } }
366
+ });
367
+ // アドオンから除外
368
+ updateOfferResult = yield repos.offer.pullAddOns({
369
+ project: { id: params.project.id },
370
+ addOn: { itemOffered: { id: { $in: [productId] } } }
371
+ });
372
+ deleteResult = { deleteEventResult, updateOfferResult };
373
+ }
374
+ catch (error) {
375
+ try {
376
+ const actionError = Object.assign(Object.assign({}, error), { message: error.message, name: error.name });
377
+ yield repos.action.giveUp({ typeOf: deleteActionAttributes.typeOf, id: action.id, error: actionError });
378
+ }
379
+ catch (_) {
380
+ // no op
381
+ }
382
+ throw error;
383
+ }
384
+ yield repos.action.complete({ typeOf: deleteActionAttributes.typeOf, id: action.id, result: deleteResult });
385
+ }
386
+ });
387
+ }
@@ -82,11 +82,18 @@ function createPaymentMethods(params) {
82
82
  });
83
83
  });
84
84
  // 決済方法から注文金額の計算
85
+ // price += authorizePaymentActions
86
+ // .filter((a) => {
87
+ // return a.result?.totalPaymentDue?.currency === factory.priceCurrency.JPY;
88
+ // })
89
+ // .reduce((a, b) => a + (<IAuthorizeAnyPaymentResult>b.result).amount, 0);
85
90
  price += authorizePaymentActions
86
- .filter((a) => {
91
+ .reduce((a, b) => {
87
92
  var _a, _b;
88
- return ((_b = (_a = a.result) === null || _a === void 0 ? void 0 : _a.totalPaymentDue) === null || _b === void 0 ? void 0 : _b.currency) === factory.priceCurrency.JPY;
89
- })
90
- .reduce((a, b) => a + b.result.amount, 0);
93
+ const jpyAmount = (((_b = (_a = b.result) === null || _a === void 0 ? void 0 : _a.totalPaymentDue) === null || _b === void 0 ? void 0 : _b.currency) === factory.priceCurrency.JPY)
94
+ ? b.result.totalPaymentDue.value
95
+ : 0;
96
+ return a + jpyAmount;
97
+ }, 0);
91
98
  return { paymentMethods, price };
92
99
  }
@@ -99,9 +99,17 @@ function validatePrice(transaction, authorizeActions) {
99
99
  return a.actionStatus === factory.actionStatusType.CompletedActionStatus
100
100
  && ((_a = a.result) === null || _a === void 0 ? void 0 : _a.typeOf) === factory.action.authorize.paymentMethod.any.ResultType.Payment;
101
101
  });
102
+ // priceByAgent += authorizePaymentActions
103
+ // .filter((a) => a.result?.totalPaymentDue?.currency === factory.priceCurrency.JPY)
104
+ // .reduce((a, b) => a + (<IAuthorizeAnyPaymentResult>b.result).amount, 0);
102
105
  priceByAgent += authorizePaymentActions
103
- .filter((a) => { var _a, _b; return ((_b = (_a = a.result) === null || _a === void 0 ? void 0 : _a.totalPaymentDue) === null || _b === void 0 ? void 0 : _b.currency) === factory.priceCurrency.JPY; })
104
- .reduce((a, b) => a + b.result.amount, 0);
106
+ .reduce((a, b) => {
107
+ var _a, _b;
108
+ const jpyAmount = (((_b = (_a = b.result) === null || _a === void 0 ? void 0 : _a.totalPaymentDue) === null || _b === void 0 ? void 0 : _b.currency) === factory.priceCurrency.JPY)
109
+ ? b.result.totalPaymentDue.value
110
+ : 0;
111
+ return a + jpyAmount;
112
+ }, 0);
105
113
  // 販売者が提供するアイテムの発生金額
106
114
  priceBySeller += authorizeActions
107
115
  .filter((authorizeAction) => authorizeAction.actionStatus === factory.actionStatusType.CompletedActionStatus)
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  }
10
10
  ],
11
11
  "dependencies": {
12
- "@chevre/factory": "4.323.0",
12
+ "@chevre/factory": "4.324.0-alpha.0",
13
13
  "@cinerino/sdk": "3.162.2",
14
14
  "@motionpicture/coa-service": "9.2.0",
15
15
  "@motionpicture/gmo-service": "5.2.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.6.0-alpha.1"
120
+ "version": "21.6.0-alpha.3"
121
121
  }