@chevre/domain 21.6.0-alpha.2 → 21.6.0-alpha.4

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.
@@ -105,7 +105,6 @@ async function main() {
105
105
  },
106
106
  offers: {
107
107
  typeOf: chevre.factory.offerType.Offer,
108
- priceCurrency: chevre.factory.priceCurrency.JPY,
109
108
  availabilityEnds: moment('2023-06-26T14:20:00.000Z')
110
109
  .toDate(),
111
110
  availabilityStarts: moment('2023-06-23T15:00:00.000Z')
@@ -275,7 +274,6 @@ async function main() {
275
274
  },
276
275
  offers: {
277
276
  typeOf: chevre.factory.offerType.Offer,
278
- priceCurrency: chevre.factory.priceCurrency.JPY,
279
277
  availabilityEnds: moment('2023-06-26T14:20:00.000Z')
280
278
  .toDate(),
281
279
  availabilityStarts: moment('2023-06-23T15:00:00.000Z')
@@ -6,14 +6,26 @@ import { chevre } from '../../../lib/index';
6
6
  async function main() {
7
7
  await mongoose.connect(<string>process.env.MONGOLAB_URI);
8
8
 
9
- const offerRepo = new chevre.repository.Offer(mongoose.connection);
9
+ const eventRepo = new chevre.repository.Event(mongoose.connection);
10
10
 
11
11
  let updateResult: any;
12
- updateResult = await offerRepo.unsetUnnecessaryFields({
13
- filter: { 'category.project': { $exists: true } },
14
- $unset: { 'category.project': 1 }
12
+ updateResult = await eventRepo.unsetUnnecessaryFields({
13
+ filter: { 'offers.acceptedPaymentMethod': { $exists: true } },
14
+ $unset: { 'offers.acceptedPaymentMethod': 1 }
15
15
  });
16
- console.log('offers unset', updateResult);
16
+ console.log('events unset', updateResult);
17
+
18
+ updateResult = await eventRepo.unsetUnnecessaryFields({
19
+ filter: { 'offers.project': { $exists: true } },
20
+ $unset: { 'offers.project': 1 }
21
+ });
22
+ console.log('events unset', updateResult);
23
+
24
+ updateResult = await eventRepo.unsetUnnecessaryFields({
25
+ filter: { 'offers.priceCurrency': { $exists: true } },
26
+ $unset: { 'offers.priceCurrency': 1 }
27
+ });
28
+ console.log('events unset', updateResult);
17
29
  }
18
30
 
19
31
  main()
@@ -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,
@@ -455,14 +455,13 @@ function createScreeningEventFromCOA(params) {
455
455
  .toDate();
456
456
  }
457
457
  const offers = {
458
- // 不要なので廃止(2022-12-19~)
459
- // project: { typeOf: params.project.typeOf, id: params.project.id },
460
458
  typeOf: factory.offerType.Offer,
461
459
  offeredThrough: {
462
460
  typeOf: 'WebAPI',
463
461
  identifier: factory.service.webAPI.Identifier.COA
464
462
  },
465
- priceCurrency: factory.priceCurrency.JPY,
463
+ // 廃止(2023-08-07~)
464
+ // priceCurrency: factory.priceCurrency.JPY,
466
465
  itemOffered: {
467
466
  serviceOutput: {
468
467
  reservedTicket: {
@@ -605,10 +604,7 @@ function createScreeningEventSeriesFromCOA(params) {
605
604
  endDate: endDate,
606
605
  startDate: startDate,
607
606
  coaInfo,
608
- offers: Object.assign({
609
- // 不要なので廃止(2023-06-09~)
610
- // project: { typeOf: params.project.typeOf, id: params.project.id },
611
- typeOf: factory.offerType.Offer, priceCurrency: factory.priceCurrency.JPY }, (Array.isArray(unacceptedPaymentMethod)) ? { unacceptedPaymentMethod: unacceptedPaymentMethod } : undefined),
607
+ offers: Object.assign({ typeOf: factory.offerType.Offer }, (Array.isArray(unacceptedPaymentMethod)) ? { unacceptedPaymentMethod: unacceptedPaymentMethod } : undefined),
612
608
  additionalProperty
613
609
  };
614
610
  }
@@ -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
  };
@@ -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.1",
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.2"
120
+ "version": "21.6.0-alpha.4"
121
121
  }