@chevre/domain 20.0.0-alpha.1 → 20.0.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.
@@ -33,7 +33,7 @@ async function main() {
33
33
  let updateCount = 0;
34
34
  await cursor.eachAsync(async (doc) => {
35
35
  i += 1;
36
- const offer = <chevre.factory.offer.IUnitPriceOffer>doc.toObject();
36
+ const offer = <chevre.factory.unitPriceOffer.IUnitPriceOffer>doc.toObject();
37
37
  const applieToMovieTicket = offer.priceSpecification?.appliesToMovieTicket;
38
38
  if (Array.isArray(applieToMovieTicket)) {
39
39
  console.log('is Array', offer.project.id, offer.id, i);
@@ -35,24 +35,6 @@ async function main() {
35
35
  const product = products[0];
36
36
  console.log(product);
37
37
 
38
- // オファーカタログ検索
39
- // const offerCatalog = await offerRepo.findOfferCatalogById({ id: product.hasOfferCatalog.id });
40
- // console.log(offerCatalog);
41
-
42
- // オファー検索
43
- // const offers = await offerRepo.offerModel.find(
44
- // { _id: { $in: (offerCatalog.itemListElement).map((e) => e.id) } },
45
- // {
46
- // __v: 0,
47
- // createdAt: 0,
48
- // updatedAt: 0
49
- // }
50
- // )
51
- // .exec()
52
- // .then((docs) => docs.map((doc) => doc.toObject()));
53
- // console.log(offers);
54
- // console.log(offers.length, 'offers found');
55
-
56
38
  const identifier = `CIN${(new Date()).valueOf()}`;
57
39
  const transaction = await chevre.service.assetTransaction.registerService.start({
58
40
  project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
@@ -35,24 +35,6 @@ async function main() {
35
35
  const product = products[0];
36
36
  console.log(product);
37
37
 
38
- // オファーカタログ検索
39
- // const offerCatalog = await offerRepo.findOfferCatalogById({ id: product.hasOfferCatalog.id });
40
- // console.log(offerCatalog);
41
-
42
- // オファー検索
43
- // const offers = await offerRepo.offerModel.find(
44
- // { _id: { $in: (offerCatalog.itemListElement).map((e) => e.id) } },
45
- // {
46
- // __v: 0,
47
- // createdAt: 0,
48
- // updatedAt: 0
49
- // }
50
- // )
51
- // .exec()
52
- // .then((docs) => docs.map((doc) => doc.toObject()));
53
- // console.log(offers);
54
- // console.log(offers.length, 'offers found');
55
-
56
38
  const transactionNumber = `CIN${(new Date()).valueOf()}`;
57
39
  const identifier = transactionNumber;
58
40
  const accessCode = '123';
@@ -310,17 +310,6 @@ class MongoRepository {
310
310
  : [];
311
311
  let offers = [];
312
312
  if (sortedOfferIds.length > 0) {
313
- // offers = await this.offerModel.find(
314
- // { _id: { $in: sortedOfferIds } },
315
- // {
316
- // __v: 0,
317
- // createdAt: 0,
318
- // updatedAt: 0
319
- // }
320
- // )
321
- // .setOptions({ maxTimeMS: 10000 })
322
- // .exec()
323
- // .then((docs) => docs.map((doc) => doc.toObject()));
324
313
  offers = yield this.search({ id: { $in: sortedOfferIds } });
325
314
  // sorting
326
315
  offers = offers.sort((a, b) => sortedOfferIds.indexOf(String(a.id)) - sortedOfferIds.indexOf(String(b.id)));
@@ -182,16 +182,20 @@ function movieTicket2reservation4invoice(movieTicket, order, paymentMethodType)
182
182
  if (Array.isArray(priceComponent)) {
183
183
  reservationPrice = priceComponent.reduce((a, b) => a + Number(b.price), 0);
184
184
  priceComponents4invoice = priceComponent.map((component) => {
185
- var _a, _b;
185
+ var _a;
186
+ const accounting = (typeof ((_a = component.accounting) === null || _a === void 0 ? void 0 : _a.accountsReceivable) === 'number')
187
+ ? { accountsReceivable: component.accounting.accountsReceivable }
188
+ : undefined;
186
189
  if (component.typeOf === factory.priceSpecificationType.UnitPriceSpecification) {
187
- return Object.assign(Object.assign({ typeOf: component.typeOf, price: component.price, referenceQuantity: component.referenceQuantity }, (Array.isArray(component.appliesToAddOn) ? { appliesToAddOn: component.appliesToAddOn } : undefined)), (typeof ((_a = component.accounting) === null || _a === void 0 ? void 0 : _a.accountsReceivable) === 'number')
188
- ? { accounting: { accountsReceivable: component.accounting.accountsReceivable } }
189
- : undefined);
190
+ const appliesToAddOn = (Array.isArray(component.appliesToAddOn))
191
+ ? component.appliesToAddOn.map((addOn) => {
192
+ return { typeOf: addOn.typeOf };
193
+ })
194
+ : undefined;
195
+ return Object.assign(Object.assign({ typeOf: component.typeOf, price: component.price, referenceQuantity: component.referenceQuantity }, (Array.isArray(appliesToAddOn)) ? { appliesToAddOn } : undefined), (typeof (accounting === null || accounting === void 0 ? void 0 : accounting.accountsReceivable) === 'number') ? { accounting } : undefined);
190
196
  }
191
197
  else {
192
- return Object.assign({ typeOf: component.typeOf, price: component.price }, (typeof ((_b = component.accounting) === null || _b === void 0 ? void 0 : _b.accountsReceivable) === 'number')
193
- ? { accounting: { accountsReceivable: component.accounting.accountsReceivable } }
194
- : undefined);
198
+ return Object.assign({ typeOf: component.typeOf, price: component.price }, (typeof (accounting === null || accounting === void 0 ? void 0 : accounting.accountsReceivable) === 'number') ? { accounting } : undefined);
195
199
  }
196
200
  });
197
201
  }
@@ -52,7 +52,7 @@ function createUnitPriceSpecsAppliedToAddOn(params) {
52
52
  id: acceptedAddOn.itemOffered.id,
53
53
  name: acceptedAddOn.itemOffered.name,
54
54
  productID: acceptedAddOn.itemOffered.productID,
55
- project: acceptedAddOn.itemOffered.project,
55
+ // project: acceptedAddOn.itemOffered.project,
56
56
  typeOf: acceptedAddOn.itemOffered.typeOf
57
57
  };
58
58
  const appliesToAddOn = {
@@ -103,7 +103,7 @@ function createPriceSpecsByEventOffer(params) {
103
103
  name: priceSpec.name,
104
104
  price: priceSpec.price,
105
105
  priceCurrency: priceSpec.priceCurrency,
106
- project: priceSpec.project,
106
+ // project: priceSpec.project,
107
107
  typeOf: priceSpec.typeOf,
108
108
  appliesToVideoFormat: priceSpec.appliesToVideoFormat,
109
109
  valueAddedTaxIncluded: priceSpec.valueAddedTaxIncluded,
@@ -116,7 +116,7 @@ function createPriceSpecsByEventOffer(params) {
116
116
  name: priceSpec.name,
117
117
  price: priceSpec.price,
118
118
  priceCurrency: priceSpec.priceCurrency,
119
- project: priceSpec.project,
119
+ // project: priceSpec.project,
120
120
  typeOf: priceSpec.typeOf,
121
121
  appliesToCategoryCode: priceSpec.appliesToCategoryCode,
122
122
  valueAddedTaxIncluded: priceSpec.valueAddedTaxIncluded
@@ -194,5 +194,7 @@ function eventOfferUnitPriceSpec2reservationUnitPriceSpec(params) {
194
194
  }
195
195
  : undefined);
196
196
  }
197
- return Object.assign(Object.assign({ name: priceSpec.name, price: priceSpec.price, priceCurrency: priceSpec.priceCurrency, project: priceSpec.project, referenceQuantity: priceSpec.referenceQuantity, typeOf: priceSpec.typeOf, valueAddedTaxIncluded: priceSpec.valueAddedTaxIncluded }, (Array.isArray(appliesToMovieTicket)) ? { appliesToMovieTicket } : undefined), (typeof (accounting4reservation === null || accounting4reservation === void 0 ? void 0 : accounting4reservation.typeOf) === 'string') ? { accounting: accounting4reservation } : undefined);
197
+ return Object.assign(Object.assign({ name: priceSpec.name, price: priceSpec.price, priceCurrency: priceSpec.priceCurrency,
198
+ // project: priceSpec.project,
199
+ referenceQuantity: priceSpec.referenceQuantity, typeOf: priceSpec.typeOf, valueAddedTaxIncluded: priceSpec.valueAddedTaxIncluded }, (Array.isArray(appliesToMovieTicket)) ? { appliesToMovieTicket } : undefined), (typeof (accounting4reservation === null || accounting4reservation === void 0 ? void 0 : accounting4reservation.typeOf) === 'string') ? { accounting: accounting4reservation } : undefined);
198
200
  }
@@ -281,7 +281,7 @@ function coaTicket2offer(params) {
281
281
  }]
282
282
  : undefined;
283
283
  const unitPriceSpec = {
284
- project: { typeOf: factory.organizationType.Project, id: params.project.id },
284
+ // project: { typeOf: factory.organizationType.Project, id: params.project.id },
285
285
  typeOf: factory.priceSpecificationType.UnitPriceSpecification,
286
286
  price: 0,
287
287
  priceCurrency: factory.priceCurrency.JPY,
@@ -2,18 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.responseBody2acceptedOffers4result = exports.offers2resultPrice = exports.createAuthorizeSeatReservationActionAttributes = exports.WebAPIIdentifier = void 0;
4
4
  const moment = require("moment");
5
- // import * as COA from '../../../coa';
6
5
  const factory = require("../../../factory");
7
6
  exports.WebAPIIdentifier = factory.service.webAPI.Identifier;
8
- // export type IAcceptedOfferWithoutDetail =
9
- // factory.action.authorize.offer.seatReservation.IAcceptedOfferWithoutDetail<WebAPIIdentifier.COA> & {
10
- // additionalProperty?: factory.propertyValue.IPropertyValue<string>[];
11
- // ticketInfo: factory.offer.seatReservation.ICOATicketInfo & {
12
- // spseatAdd1: number;
13
- // spseatAdd2: number;
14
- // spseatKbn: string;
15
- // };
16
- // };
17
7
  function createAuthorizeSeatReservationActionAttributes(params) {
18
8
  var _a;
19
9
  const transaction = params.transaction;
@@ -68,25 +58,6 @@ function offers2resultPrice(offers) {
68
58
  return { price, requiredPoint };
69
59
  }
70
60
  exports.offers2resultPrice = offers2resultPrice;
71
- // export function createUpdTmpReserveSeatArgs(params: {
72
- // object: factory.action.authorize.offer.seatReservation.IObjectWithoutDetail<WebAPIIdentifier.COA>;
73
- // coaInfo: factory.event.screeningEvent.ICOAInfo;
74
- // }): COA.factory.reserve.IUpdTmpReserveSeatArgs {
75
- // return {
76
- // theaterCode: params.coaInfo.theaterCode,
77
- // dateJouei: params.coaInfo.dateJouei,
78
- // titleCode: params.coaInfo.titleCode,
79
- // titleBranchNum: params.coaInfo.titleBranchNum,
80
- // timeBegin: params.coaInfo.timeBegin,
81
- // screenCode: params.coaInfo.screenCode,
82
- // listSeat: params.object.acceptedOffer.map((offer) => {
83
- // return {
84
- // seatSection: offer.seatSection,
85
- // seatNum: offer.seatNumber
86
- // };
87
- // })
88
- // };
89
- // }
90
61
  /**
91
62
  * COA仮予約結果から注文アイテムを生成する
92
63
  */
@@ -202,6 +173,15 @@ function responseBody2acceptedOffers4result(params) {
202
173
  const reservation = Object.assign(Object.assign(Object.assign({ project: { typeOf: event.project.typeOf, id: event.project.id }, typeOf: factory.reservationType.EventReservation, id: reservationId, issuedThrough: { typeOf: factory.product.ProductType.EventService }, bookingTime: params.bookingTime }, (Array.isArray(additionalProperty)) ? { additionalProperty } : undefined), (typeof additionalTicketText === 'string') ? { additionalTicketText } : undefined), {
203
174
  // numSeats: 1, // 廃止(2022-08-18~)
204
175
  reservationFor: reservationFor, reservationNumber: reservationNumber, reservedTicket: reservedTicket });
176
+ if (requestedOffer.priceSpecification === undefined) {
177
+ throw new factory.errors.NotFound('acceptedOffer.priceSpecification');
178
+ }
179
+ const priceSpecification = {
180
+ typeOf: requestedOffer.priceSpecification.typeOf,
181
+ priceCurrency: requestedOffer.priceSpecification.priceCurrency,
182
+ valueAddedTaxIncluded: requestedOffer.priceSpecification.valueAddedTaxIncluded,
183
+ priceComponent: requestedOffer.priceSpecification.priceComponent
184
+ };
205
185
  return {
206
186
  project: { typeOf: event.project.typeOf, id: event.project.id },
207
187
  typeOf: factory.offerType.Offer,
@@ -209,7 +189,7 @@ function responseBody2acceptedOffers4result(params) {
209
189
  name: requestedOffer.name,
210
190
  itemOffered: reservation,
211
191
  offeredThrough: { typeOf: 'WebAPI', identifier: factory.service.webAPI.Identifier.COA },
212
- priceSpecification: requestedOffer.priceSpecification,
192
+ priceSpecification,
213
193
  priceCurrency: factory.priceCurrency.JPY,
214
194
  seller: {
215
195
  project: { typeOf: event.project.typeOf, id: event.project.id },
@@ -12,6 +12,8 @@ function createCompoundPriceSpec4event(params) {
12
12
  // 区分加算料金は決済カード適用でも価格要素に含まれるはず(2022-11-02~)
13
13
  const priceComponent = [
14
14
  unitPriceSpec,
15
+ // tslint:disable-next-line:no-suspicious-comment
16
+ // TODO strictコーディングで最適化
15
17
  ...params.videoFormatChargeSpecifications,
16
18
  ...params.soundFormatChargeSpecifications
17
19
  ];
@@ -40,6 +42,8 @@ function createCompoundPriceSpec4event(params) {
40
42
  }
41
43
  }
42
44
  });
45
+ // tslint:disable-next-line:no-suspicious-comment
46
+ // TODO strictコーディングで最適化
43
47
  priceComponent.push(...mvtkSpecs);
44
48
  }
45
49
  else {
@@ -82,8 +82,7 @@ function responseBody2resultAcceptedOffer(params) {
82
82
  let acceptedOffers = [];
83
83
  if (Array.isArray(params.responseBody.object)) {
84
84
  acceptedOffers = params.responseBody.object.map((responseBodyObject) => {
85
- var _a, _b, _c;
86
- // const productTypeOf = responseBodyObject.itemOffered?.serviceOutput?.issuedThrough?.typeOf;
85
+ var _a, _b, _c, _d;
87
86
  const serviceOutputIdentifier = (_b = (_a = responseBodyObject.itemOffered) === null || _a === void 0 ? void 0 : _a.serviceOutput) === null || _b === void 0 ? void 0 : _b.identifier;
88
87
  if (serviceOutputIdentifier !== undefined && typeof serviceOutputIdentifier !== 'string') {
89
88
  // 基本的にありえないフロー↓
@@ -96,13 +95,50 @@ function responseBody2resultAcceptedOffer(params) {
96
95
  if (offer === undefined) {
97
96
  throw new factory.errors.ServiceUnavailable(`Offer ${responseBodyObject.id} from registerService not found`);
98
97
  }
98
+ if (typeof ((_d = offer.priceSpecification) === null || _d === void 0 ? void 0 : _d.typeOf) !== 'string') {
99
+ throw new factory.errors.NotFound('acceptedOffer.priceSpecification');
100
+ }
101
+ const priceSpecification = {
102
+ typeOf: offer.priceSpecification.typeOf,
103
+ valueAddedTaxIncluded: offer.priceSpecification.valueAddedTaxIncluded,
104
+ priceCurrency: offer.priceSpecification.priceCurrency,
105
+ priceComponent: offer.priceSpecification.priceComponent.map((component) => {
106
+ var _a, _b;
107
+ if (component.typeOf === factory.priceSpecificationType.UnitPriceSpecification) {
108
+ // tslint:disable-next-line:no-unnecessary-local-variable
109
+ const unitPriceComponent = Object.assign(Object.assign(Object.assign({ accounting: component.accounting, name: component.name, price: component.price, priceCurrency: component.priceCurrency, referenceQuantity: component.referenceQuantity, typeOf: component.typeOf, valueAddedTaxIncluded: component.valueAddedTaxIncluded }, (Array.isArray(component.appliesToAddOn))
110
+ ? { appliesToAddOn: component.appliesToAddOn }
111
+ : undefined), (Array.isArray(component.appliesToMovieTicket))
112
+ ? { appliesToMovieTicket: component.appliesToMovieTicket }
113
+ : undefined), (typeof ((_a = component.accounting) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string')
114
+ ? {
115
+ accounting: Object.assign(Object.assign({ typeOf: component.accounting.typeOf }, (typeof component.accounting.accountsReceivable === 'number')
116
+ ? { accountsReceivable: component.accounting.accountsReceivable }
117
+ : undefined), (typeof ((_b = component.accounting.operatingRevenue) === null || _b === void 0 ? void 0 : _b.typeOf) === 'string')
118
+ ? {
119
+ operatingRevenue: {
120
+ project: component.accounting.operatingRevenue.project,
121
+ typeOf: component.accounting.operatingRevenue.typeOf,
122
+ codeValue: component.accounting.operatingRevenue.codeValue
123
+ }
124
+ }
125
+ : undefined)
126
+ }
127
+ : undefined);
128
+ return unitPriceComponent;
129
+ }
130
+ else {
131
+ return component;
132
+ }
133
+ })
134
+ };
99
135
  return {
100
136
  project: { typeOf: params.project.typeOf, id: params.project.id },
101
137
  typeOf: responseBodyObject.typeOf,
102
138
  id: offer.id,
103
139
  name: offer.name,
104
140
  itemOffered,
105
- priceSpecification: offer.priceSpecification,
141
+ priceSpecification,
106
142
  priceCurrency: offer.priceCurrency,
107
143
  seller: offer.seller
108
144
  };
@@ -133,14 +133,16 @@ function createMoneyTransferAcceptedOffers(params) {
133
133
  name: `${amountValue} ${currency}`
134
134
  };
135
135
  acceptedOffers.push({
136
- project: { typeOf: params.transaction.project.typeOf, id: params.transaction.project.id },
136
+ // 不要なので廃止(2022-11-05~)
137
+ // project: { typeOf: params.transaction.project.typeOf, id: params.transaction.project.id },
137
138
  typeOf: factory.offerType.Offer,
138
139
  itemOffered,
139
140
  // ↓いったん廃止(2022-05-17~)
140
141
  // price: authorizeMoneyTansferAction.result.price,
141
142
  priceCurrency: authorizeMoneyTansferAction.result.priceCurrency,
142
143
  seller: {
143
- project: { typeOf: params.transaction.project.typeOf, id: params.transaction.project.id },
144
+ // 不要なので廃止(2022-11-05~)
145
+ // project: { typeOf: params.transaction.project.typeOf, id: params.transaction.project.id },
144
146
  typeOf: params.seller.typeOf,
145
147
  name: params.seller.name
146
148
  }
package/package.json CHANGED
@@ -9,8 +9,8 @@
9
9
  }
10
10
  ],
11
11
  "dependencies": {
12
- "@chevre/factory": "4.273.1",
13
- "@cinerino/sdk": "3.130.0-alpha.1",
12
+ "@chevre/factory": "4.274.0-alpha.3",
13
+ "@cinerino/sdk": "3.130.0-alpha.5",
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.0.0-alpha.1"
123
+ "version": "20.0.0-alpha.3"
124
124
  }