@chevre/domain 24.1.0-alpha.2 → 24.1.0-alpha.20

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.
Files changed (67) hide show
  1. package/README.md +0 -2
  2. package/lib/chevre/repo/acceptedOffer.d.ts +16 -11
  3. package/lib/chevre/repo/acceptedOffer.js +172 -48
  4. package/lib/chevre/repo/accountingReport.d.ts +9 -2
  5. package/lib/chevre/repo/accountingReport.js +6 -34
  6. package/lib/chevre/repo/action/actionProcess.d.ts +1 -1
  7. package/lib/chevre/repo/aggregateReservation.d.ts +6 -0
  8. package/lib/chevre/repo/aggregateReservation.js +9 -0
  9. package/lib/chevre/repo/assetTransaction/reserve.d.ts +3 -1
  10. package/lib/chevre/repo/assetTransaction/reserve.js +3 -1
  11. package/lib/chevre/repo/event.js +12 -8
  12. package/lib/chevre/repo/factory/acceptedOffer/reserveTransaction2itemOffered.d.ts +9 -0
  13. package/lib/chevre/repo/factory/acceptedOffer/reserveTransaction2itemOffered.js +72 -0
  14. package/lib/chevre/repo/factory/reservation/createMongoConditions.js +155 -180
  15. package/lib/chevre/repo/mongoose/schemas/accountingReport.js +42 -42
  16. package/lib/chevre/repo/mongoose/schemas/order.js +108 -108
  17. package/lib/chevre/repo/mongoose/schemas/reservation.d.ts +3 -1
  18. package/lib/chevre/repo/mongoose/schemas/reservation.js +128 -146
  19. package/lib/chevre/repo/order.d.ts +2 -1
  20. package/lib/chevre/repo/order.js +171 -170
  21. package/lib/chevre/repo/orderInTransaction.d.ts +32 -2
  22. package/lib/chevre/repo/orderInTransaction.js +77 -0
  23. package/lib/chevre/repo/reservation.d.ts +20 -7
  24. package/lib/chevre/repo/reservation.js +14 -10
  25. package/lib/chevre/repo/role.d.ts +1 -15
  26. package/lib/chevre/repo/role.js +7 -14
  27. package/lib/chevre/repo/transaction.d.ts +6 -6
  28. package/lib/chevre/service/aggregation/event/aggregateOffers.js +22 -26
  29. package/lib/chevre/service/assetTransaction/cancelReservation/factory.js +14 -11
  30. package/lib/chevre/service/assetTransaction/cancelReservation/start.d.ts +1 -1
  31. package/lib/chevre/service/assetTransaction/cancelReservation/start.js +1 -1
  32. package/lib/chevre/service/assetTransaction/reserve/start/factory/createReservation.js +0 -12
  33. package/lib/chevre/service/assetTransaction/reserve/start/factory/price.d.ts +1 -1
  34. package/lib/chevre/service/offer/any.d.ts +3 -1
  35. package/lib/chevre/service/offer/event/authorize/factory.d.ts +2 -1
  36. package/lib/chevre/service/offer/event/authorize/factory.js +4 -7
  37. package/lib/chevre/service/offer/eventServiceByCOA/authorize/factory.d.ts +1 -0
  38. package/lib/chevre/service/order/createAccountingReportIfNotExist.d.ts +1 -3
  39. package/lib/chevre/service/order/createAccountingReportIfNotExist.js +67 -72
  40. package/lib/chevre/service/order/deleteOrder.js +19 -43
  41. package/lib/chevre/service/order/onAssetTransactionStatusChanged/paymentDue2Processing.js +9 -11
  42. package/lib/chevre/service/order/placeOrder/factory/orderedItem.d.ts +1 -1
  43. package/lib/chevre/service/order/placeOrder/factory/orderedItem.js +0 -5
  44. package/lib/chevre/service/order/placeOrder/factory.d.ts +1 -1
  45. package/lib/chevre/service/order/sendOrder.js +0 -3
  46. package/lib/chevre/service/reserve/confirmReservation.js +7 -7
  47. package/lib/chevre/service/reserve/factory.js +2 -1
  48. package/lib/chevre/service/reserve/findByCode.d.ts +1 -1
  49. package/lib/chevre/service/reserve/findByCode.js +1 -1
  50. package/lib/chevre/service/reserve/findReservations.d.ts +5 -2
  51. package/lib/chevre/service/reserve/findReservations.js +16 -2
  52. package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.d.ts +4 -3
  53. package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +1 -9
  54. package/lib/chevre/service/reserve/searchByOrder.js +7 -3
  55. package/lib/chevre/service/reserve/useReservation.d.ts +1 -1
  56. package/lib/chevre/service/reserve/useReservation.js +20 -24
  57. package/lib/chevre/service/task/confirmReserveTransaction.js +1 -1
  58. package/lib/chevre/service/task/createAccountingReport.js +7 -9
  59. package/lib/chevre/service/task/payment/payByTask.js +2 -2
  60. package/lib/chevre/service/task/useReservation.d.ts +2 -2
  61. package/lib/chevre/service/task/useReservation.js +6 -18
  62. package/lib/chevre/service/taskHandler.js +1 -0
  63. package/lib/chevre/service/transaction/placeOrder/confirm/validation/validateInvoiceReferencesOrder.d.ts +1 -1
  64. package/lib/chevre/service/transaction/placeOrder/confirm/validation/validateMovieTicket.d.ts +1 -1
  65. package/lib/chevre/service/transaction/placeOrder/confirm/validation.d.ts +2 -2
  66. package/lib/chevre/service/transaction/placeOrder/confirm.js +5 -2
  67. package/package.json +2 -2
@@ -31,27 +31,27 @@ class OrderRepo {
31
31
  if (typeof projectIdEq === 'string') {
32
32
  andConditions.push({ 'project.id': { $eq: projectIdEq } });
33
33
  }
34
- /* istanbul ignore else */
35
- if (params.identifier !== undefined) {
36
- /* istanbul ignore else */
37
- if (Array.isArray(params.identifier.$all)) {
38
- andConditions.push({
39
- identifier: {
40
- $exists: true,
41
- $all: params.identifier.$all
42
- }
43
- });
44
- }
45
- /* istanbul ignore else */
46
- if (Array.isArray(params.identifier.$in)) {
47
- andConditions.push({
48
- identifier: {
49
- $exists: true,
50
- $in: params.identifier.$in
51
- }
52
- });
53
- }
54
- }
34
+ // /* istanbul ignore else */
35
+ // if (params.identifier !== undefined) {
36
+ // /* istanbul ignore else */
37
+ // if (Array.isArray(params.identifier.$all)) {
38
+ // andConditions.push({
39
+ // identifier: {
40
+ // $exists: true,
41
+ // $all: params.identifier.$all
42
+ // }
43
+ // });
44
+ // }
45
+ // /* istanbul ignore else */
46
+ // if (Array.isArray(params.identifier.$in)) {
47
+ // andConditions.push({
48
+ // identifier: {
49
+ // $exists: true,
50
+ // $in: params.identifier.$in
51
+ // }
52
+ // });
53
+ // }
54
+ // }
55
55
  const providerIdEq = params.provider?.id?.$eq;
56
56
  if (typeof providerIdEq === 'string') {
57
57
  andConditions.push({ 'seller.id': { $exists: true, $eq: providerIdEq } });
@@ -129,44 +129,44 @@ class OrderRepo {
129
129
  });
130
130
  }
131
131
  }
132
- if (params.customer.additionalProperty !== undefined && params.customer.additionalProperty !== null) {
133
- if (Array.isArray(params.customer.additionalProperty.$all)) {
134
- andConditions.push({
135
- 'customer.additionalProperty': {
136
- $exists: true,
137
- $all: params.customer.additionalProperty.$all
138
- }
139
- });
140
- }
141
- if (Array.isArray(params.customer.additionalProperty.$in)) {
142
- andConditions.push({
143
- 'customer.additionalProperty': {
144
- $exists: true,
145
- $in: params.customer.additionalProperty.$in
146
- }
147
- });
148
- }
149
- }
150
- if (params.customer.memberOf !== undefined && params.customer.memberOf !== null) {
151
- if (params.customer.memberOf.membershipNumber !== undefined && params.customer.memberOf.membershipNumber !== null) {
152
- if (typeof params.customer.memberOf.membershipNumber.$eq === 'string') {
153
- andConditions.push({
154
- 'customer.memberOf.membershipNumber': {
155
- $exists: true,
156
- $eq: params.customer.memberOf.membershipNumber.$eq
157
- }
158
- });
159
- }
160
- if (Array.isArray(params.customer.memberOf.membershipNumber.$in)) {
161
- andConditions.push({
162
- 'customer.memberOf.membershipNumber': {
163
- $exists: true,
164
- $in: params.customer.memberOf.membershipNumber.$in
165
- }
166
- });
167
- }
168
- }
169
- }
132
+ // if (params.customer.additionalProperty !== undefined && params.customer.additionalProperty !== null) {
133
+ // if (Array.isArray(params.customer.additionalProperty.$all)) {
134
+ // andConditions.push({
135
+ // 'customer.additionalProperty': {
136
+ // $exists: true,
137
+ // $all: params.customer.additionalProperty.$all
138
+ // }
139
+ // });
140
+ // }
141
+ // if (Array.isArray(params.customer.additionalProperty.$in)) {
142
+ // andConditions.push({
143
+ // 'customer.additionalProperty': {
144
+ // $exists: true,
145
+ // $in: params.customer.additionalProperty.$in
146
+ // }
147
+ // });
148
+ // }
149
+ // }
150
+ // if (params.customer.memberOf !== undefined && params.customer.memberOf !== null) {
151
+ // if (params.customer.memberOf.membershipNumber !== undefined && params.customer.memberOf.membershipNumber !== null) {
152
+ // if (typeof params.customer.memberOf.membershipNumber.$eq === 'string') {
153
+ // andConditions.push({
154
+ // 'customer.memberOf.membershipNumber': {
155
+ // $exists: true,
156
+ // $eq: params.customer.memberOf.membershipNumber.$eq
157
+ // }
158
+ // });
159
+ // }
160
+ // if (Array.isArray(params.customer.memberOf.membershipNumber.$in)) {
161
+ // andConditions.push({
162
+ // 'customer.memberOf.membershipNumber': {
163
+ // $exists: true,
164
+ // $in: params.customer.memberOf.membershipNumber.$in
165
+ // }
166
+ // });
167
+ // }
168
+ // }
169
+ // }
170
170
  if (typeof params.customer.givenName === 'string') {
171
171
  if (params.customer.givenName.length > 0) {
172
172
  andConditions.push({
@@ -325,72 +325,73 @@ class OrderRepo {
325
325
  andConditions.push({ confirmationNumber: { $exists: true, $in: params.confirmationNumbers } });
326
326
  }
327
327
  }
328
- const orderedItemSize = params.orderedItem?.$size;
329
- if (typeof orderedItemSize === 'number') {
330
- andConditions.push({ orderedItem: { $size: orderedItemSize } });
331
- }
332
- const acceptedOffersSize = params.acceptedOffers?.$size;
333
- if (typeof acceptedOffersSize === 'number') {
334
- andConditions.push({ acceptedOffers: { $size: acceptedOffersSize } });
335
- }
328
+ // const orderedItemSize = params.orderedItem?.$size;
329
+ // if (typeof orderedItemSize === 'number') {
330
+ // andConditions.push({ orderedItem: { $size: orderedItemSize } });
331
+ // }
332
+ // const acceptedOffersSize = params.acceptedOffers?.$size;
333
+ // if (typeof acceptedOffersSize === 'number') {
334
+ // andConditions.push({ acceptedOffers: { $size: acceptedOffersSize } });
335
+ // }
336
336
  const serialNumberEq = params.acceptedOffers?.serialNumber?.$eq;
337
337
  if (typeof serialNumberEq === 'string') {
338
338
  andConditions.push({ 'acceptedOffers.serialNumber': { $exists: true, $eq: serialNumberEq } });
339
339
  }
340
- const itemOfferedIdentifierIn = params.acceptedOffers?.itemOffered?.identifier?.$in;
341
- if (Array.isArray(itemOfferedIdentifierIn)) {
342
- andConditions.push({
343
- 'acceptedOffers.itemOffered.identifier': {
344
- $exists: true,
345
- $in: itemOfferedIdentifierIn
346
- }
347
- });
348
- }
349
- const itemOfferedTypeOfIn = params.acceptedOffers?.itemOffered?.typeOf?.$in;
350
- if (Array.isArray(itemOfferedTypeOfIn)) {
351
- andConditions.push({
352
- 'acceptedOffers.itemOffered.typeOf': {
353
- $exists: true,
354
- $in: itemOfferedTypeOfIn
355
- }
356
- });
357
- }
358
- const itemOfferedIssuedThroughTypeOfEq = params.acceptedOffers?.itemOffered?.issuedThrough?.typeOf?.$eq;
359
- if (typeof itemOfferedIssuedThroughTypeOfEq === 'string') {
360
- andConditions.push({
361
- 'acceptedOffers.itemOffered.issuedThrough.typeOf': {
362
- $exists: true,
363
- $eq: itemOfferedIssuedThroughTypeOfEq
364
- }
365
- });
366
- }
367
- const itemOfferedIssuedThroughIdIn = params.acceptedOffers?.itemOffered?.issuedThrough?.id?.$in;
368
- if (Array.isArray(itemOfferedIssuedThroughIdIn)) {
369
- andConditions.push({
370
- 'acceptedOffers.itemOffered.issuedThrough.id': {
371
- $exists: true,
372
- $in: itemOfferedIssuedThroughIdIn
373
- }
374
- });
375
- }
376
- const itemOfferedProgramMembershipUsedIdentifierEq = params.acceptedOffers?.itemOffered?.programMembershipUsed?.identifier?.$eq;
377
- if (typeof itemOfferedProgramMembershipUsedIdentifierEq === 'string') {
378
- andConditions.push({
379
- 'acceptedOffers.itemOffered.programMembershipUsed.identifier': {
380
- $exists: true,
381
- $eq: itemOfferedProgramMembershipUsedIdentifierEq
382
- }
383
- });
384
- }
385
- const itemOfferedProgramMembershipUsedIssuedThroughServiceTypeCodeValueEq = params.acceptedOffers?.itemOffered?.programMembershipUsed?.issuedThrough?.serviceType?.codeValue?.$eq;
386
- if (typeof itemOfferedProgramMembershipUsedIssuedThroughServiceTypeCodeValueEq === 'string') {
387
- andConditions.push({
388
- 'acceptedOffers.itemOffered.programMembershipUsed.issuedThrough.serviceType.codeValue': {
389
- $exists: true,
390
- $eq: itemOfferedProgramMembershipUsedIssuedThroughServiceTypeCodeValueEq
391
- }
392
- });
393
- }
340
+ // const itemOfferedIdentifierIn = params.acceptedOffers?.itemOffered?.identifier?.$in;
341
+ // if (Array.isArray(itemOfferedIdentifierIn)) {
342
+ // andConditions.push({
343
+ // 'acceptedOffers.itemOffered.identifier': {
344
+ // $exists: true,
345
+ // $in: itemOfferedIdentifierIn
346
+ // }
347
+ // });
348
+ // }
349
+ // const itemOfferedTypeOfIn = params.acceptedOffers?.itemOffered?.typeOf?.$in;
350
+ // if (Array.isArray(itemOfferedTypeOfIn)) {
351
+ // andConditions.push({
352
+ // 'acceptedOffers.itemOffered.typeOf': {
353
+ // $exists: true,
354
+ // $in: itemOfferedTypeOfIn
355
+ // }
356
+ // });
357
+ // }
358
+ // const itemOfferedIssuedThroughTypeOfEq = params.acceptedOffers?.itemOffered?.issuedThrough?.typeOf?.$eq;
359
+ // if (typeof itemOfferedIssuedThroughTypeOfEq === 'string') {
360
+ // andConditions.push({
361
+ // 'acceptedOffers.itemOffered.issuedThrough.typeOf': {
362
+ // $exists: true,
363
+ // $eq: itemOfferedIssuedThroughTypeOfEq
364
+ // }
365
+ // });
366
+ // }
367
+ // const itemOfferedIssuedThroughIdIn = params.acceptedOffers?.itemOffered?.issuedThrough?.id?.$in;
368
+ // if (Array.isArray(itemOfferedIssuedThroughIdIn)) {
369
+ // andConditions.push({
370
+ // 'acceptedOffers.itemOffered.issuedThrough.id': {
371
+ // $exists: true,
372
+ // $in: itemOfferedIssuedThroughIdIn
373
+ // }
374
+ // });
375
+ // }
376
+ // const itemOfferedProgramMembershipUsedIdentifierEq = params.acceptedOffers?.itemOffered?.programMembershipUsed?.identifier?.$eq;
377
+ // if (typeof itemOfferedProgramMembershipUsedIdentifierEq === 'string') {
378
+ // andConditions.push({
379
+ // 'acceptedOffers.itemOffered.programMembershipUsed.identifier': {
380
+ // $exists: true,
381
+ // $eq: itemOfferedProgramMembershipUsedIdentifierEq
382
+ // }
383
+ // });
384
+ // }
385
+ // const itemOfferedProgramMembershipUsedIssuedThroughServiceTypeCodeValueEq =
386
+ // params.acceptedOffers?.itemOffered?.programMembershipUsed?.issuedThrough?.serviceType?.codeValue?.$eq;
387
+ // if (typeof itemOfferedProgramMembershipUsedIssuedThroughServiceTypeCodeValueEq === 'string') {
388
+ // andConditions.push({
389
+ // 'acceptedOffers.itemOffered.programMembershipUsed.issuedThrough.serviceType.codeValue': {
390
+ // $exists: true,
391
+ // $eq: itemOfferedProgramMembershipUsedIssuedThroughServiceTypeCodeValueEq
392
+ // }
393
+ // });
394
+ // }
394
395
  const itemOfferedReservedTicketIdentifierEq = params.acceptedOffers?.itemOffered?.reservedTicket?.identifier?.$eq;
395
396
  if (typeof itemOfferedReservedTicketIdentifierEq === 'string') {
396
397
  andConditions.push({
@@ -434,25 +435,25 @@ class OrderRepo {
434
435
  }
435
436
  });
436
437
  }
437
- /* istanbul ignore else */
438
- if (typeof reservationForConditions.name === 'string' && reservationForConditions.name.length > 0) {
439
- andConditions.push({
440
- $or: [
441
- {
442
- 'acceptedOffers.itemOffered.reservationFor.name.ja': {
443
- $exists: true,
444
- $regex: new RegExp(reservationForConditions.name)
445
- }
446
- },
447
- {
448
- 'acceptedOffers.itemOffered.reservationFor.name.en': {
449
- $exists: true,
450
- $regex: new RegExp(reservationForConditions.name)
451
- }
452
- }
453
- ]
454
- });
455
- }
438
+ // /* istanbul ignore else */
439
+ // if (typeof reservationForConditions.name === 'string' && reservationForConditions.name.length > 0) {
440
+ // andConditions.push({
441
+ // $or: [
442
+ // {
443
+ // 'acceptedOffers.itemOffered.reservationFor.name.ja': {
444
+ // $exists: true,
445
+ // $regex: new RegExp(reservationForConditions.name)
446
+ // }
447
+ // },
448
+ // {
449
+ // 'acceptedOffers.itemOffered.reservationFor.name.en': {
450
+ // $exists: true,
451
+ // $regex: new RegExp(reservationForConditions.name)
452
+ // }
453
+ // }
454
+ // ]
455
+ // });
456
+ // }
456
457
  /* istanbul ignore else */
457
458
  if (reservationForConditions.location !== undefined) {
458
459
  if (Array.isArray(reservationForConditions.location.branchCodes)) {
@@ -608,18 +609,18 @@ class OrderRepo {
608
609
  }
609
610
  });
610
611
  }
611
- /* istanbul ignore else */
612
- if (params.orderDateFrom instanceof Date) {
613
- andConditions.push({
614
- orderDate: { $gte: params.orderDateFrom }
615
- });
616
- }
617
- /* istanbul ignore else */
618
- if (params.orderDateThrough instanceof Date) {
619
- andConditions.push({
620
- orderDate: { $lte: params.orderDateThrough }
621
- });
622
- }
612
+ // /* istanbul ignore else */
613
+ // if (params.orderDateFrom instanceof Date) {
614
+ // andConditions.push({
615
+ // orderDate: { $gte: params.orderDateFrom }
616
+ // });
617
+ // }
618
+ // /* istanbul ignore else */
619
+ // if (params.orderDateThrough instanceof Date) {
620
+ // andConditions.push({
621
+ // orderDate: { $lte: params.orderDateThrough }
622
+ // });
623
+ // }
623
624
  if (params.orderDate !== undefined && params.orderDate !== null) {
624
625
  if (params.orderDate.$gte instanceof Date) {
625
626
  andConditions.push({
@@ -632,24 +633,24 @@ class OrderRepo {
632
633
  });
633
634
  }
634
635
  }
635
- if (params.price !== undefined && params.price !== null) {
636
- if (typeof params.price.$gte === 'number') {
637
- andConditions.push({
638
- price: {
639
- $exists: true,
640
- $gte: params.price.$gte
641
- }
642
- });
643
- }
644
- if (typeof params.price.$lte === 'number') {
645
- andConditions.push({
646
- price: {
647
- $exists: true,
648
- $lte: params.price.$lte
649
- }
650
- });
651
- }
652
- }
636
+ // if (params.price !== undefined && params.price !== null) {
637
+ // if (typeof params.price.$gte === 'number') {
638
+ // andConditions.push({
639
+ // price: {
640
+ // $exists: true,
641
+ // $gte: params.price.$gte
642
+ // }
643
+ // });
644
+ // }
645
+ // if (typeof params.price.$lte === 'number') {
646
+ // andConditions.push({
647
+ // price: {
648
+ // $exists: true,
649
+ // $lte: params.price.$lte
650
+ // }
651
+ // });
652
+ // }
653
+ // }
653
654
  return andConditions;
654
655
  }
655
656
  /**
@@ -6,8 +6,23 @@ type IOrderInTransaction = Pick<factory.order.IOrder, 'orderNumber' | 'project'>
6
6
  acceptedOffers: factory.order.IAcceptedOffer[];
7
7
  customer?: factory.order.ICustomer;
8
8
  };
9
+ type IAcceptedOffer = factory.order.IAcceptedOffer & {
10
+ /**
11
+ * 受け入れ時に指定必須
12
+ */
13
+ offeredThrough: factory.offer.IOfferedThrough;
14
+ };
15
+ /**
16
+ * typeOf: Orderへドキュメント変換時の編集フィールド
17
+ */
9
18
  export type IPlacingOrder = Pick<factory.order.IOrder, 'broker' | 'confirmationNumber' | 'identifier' | 'isGift' | 'name' | 'orderDate' | 'orderNumber' | 'orderStatus' | 'orderedItem' | 'paymentMethods' | 'price' | 'priceCurrency' | 'seller' | 'typeOf' | 'url'> & {
19
+ /**
20
+ * 上書きしてはいけない
21
+ */
10
22
  acceptedOffers?: never;
23
+ /**
24
+ * 上書きしてはいけない
25
+ */
11
26
  customer?: never;
12
27
  };
13
28
  /**
@@ -15,7 +30,19 @@ export type IPlacingOrder = Pick<factory.order.IOrder, 'broker' | 'confirmationN
15
30
  */
16
31
  export declare class OrderInTransactionRepo {
17
32
  private readonly orderModel;
33
+ private readonly reserveTransactionModel;
18
34
  constructor(connection: Connection);
35
+ private findSubReservationsByReservationNumbers;
36
+ /**
37
+ * 取引進行中の注文からacceptedOffersを検索する
38
+ * 予約取引から予約ごとの価格仕様も参照する
39
+ */
40
+ findAcceptedOffersWithPriceByOrderNumber(params: {
41
+ orderNumber: string;
42
+ project: {
43
+ id: string;
44
+ };
45
+ }): Promise<factory.order.IAcceptedOffer[]>;
19
46
  /**
20
47
  * 取引進行中の注文からacceptedOffersを検索する
21
48
  */
@@ -23,16 +50,19 @@ export declare class OrderInTransactionRepo {
23
50
  orderNumber: {
24
51
  $eq: string;
25
52
  };
26
- }): Promise<factory.order.IAcceptedOffer[]>;
53
+ }): Promise<Pick<factory.order.IAcceptedOffer, 'itemOffered' | 'serialNumber'>[]>;
27
54
  /**
28
55
  * 注文を受注する
56
+ * typeOf: PlaceOrder -> typeOf: Order
29
57
  */
30
58
  placeOrder(order: IPlacingOrder): Promise<void>;
31
59
  /**
32
60
  * 注文documentがなければ作成し、受け入れられたオファーを追加する
33
61
  * このメソッドでdocumentが初めて生成される(typeOf:PlaceOrderとして)
34
62
  */
35
- acceptOffer(params: Pick<IOrderInTransaction, 'acceptedOffers' | 'orderNumber' | 'project'>): Promise<import("mongoose").UpdateWriteOpResult | undefined>;
63
+ acceptOffer(params: Pick<IOrderInTransaction, 'orderNumber' | 'project'> & {
64
+ acceptedOffers: IAcceptedOffer[];
65
+ }): Promise<import("mongoose").UpdateWriteOpResult | undefined>;
36
66
  /**
37
67
  * serialNumberからオファーを除外する
38
68
  * ホワイトリストとブラックリスト両方に対応
@@ -1,15 +1,91 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.OrderInTransactionRepo = void 0;
7
+ const debug_1 = __importDefault(require("debug"));
8
+ const util_1 = require("util");
4
9
  const factory_1 = require("../factory");
5
10
  const order_1 = require("./mongoose/schemas/order");
11
+ const assetTransaction_1 = require("./mongoose/schemas/assetTransaction");
12
+ const debug = (0, debug_1.default)('chevre-domain:repo:orderInTransaction');
6
13
  /**
7
14
  * 取引中注文リポジトリ
8
15
  */
9
16
  class OrderInTransactionRepo {
10
17
  orderModel;
18
+ reserveTransactionModel;
11
19
  constructor(connection) {
12
20
  this.orderModel = connection.model(order_1.modelName, (0, order_1.createSchema)());
21
+ this.reserveTransactionModel = connection.model(assetTransaction_1.modelName, (0, assetTransaction_1.createSchema)());
22
+ }
23
+ async findSubReservationsByReservationNumbers(params) {
24
+ const { reservationNumbers } = params;
25
+ if (!Array.isArray(reservationNumbers) || reservationNumbers.length === 0) {
26
+ throw new factory_1.factory.errors.ArgumentNull('reservationNumbers');
27
+ }
28
+ const aggregate = this.reserveTransactionModel.aggregate([
29
+ {
30
+ $match: {
31
+ typeOf: { $eq: factory_1.factory.assetTransactionType.Reserve },
32
+ transactionNumber: { $in: reservationNumbers }
33
+ }
34
+ },
35
+ {
36
+ $unwind: {
37
+ path: '$object.subReservation'
38
+ // includeArrayIndex: 'elementIndex'
39
+ }
40
+ },
41
+ {
42
+ $project: {
43
+ _id: 0,
44
+ id: '$object.subReservation.id',
45
+ price: '$object.subReservation.price',
46
+ }
47
+ }
48
+ ]);
49
+ return aggregate.exec();
50
+ }
51
+ /**
52
+ * 取引進行中の注文からacceptedOffersを検索する
53
+ * 予約取引から予約ごとの価格仕様も参照する
54
+ */
55
+ async findAcceptedOffersWithPriceByOrderNumber(params) {
56
+ const doc = await this.orderModel.findOne({
57
+ orderNumber: { $eq: params.orderNumber },
58
+ typeOf: { $eq: factory_1.factory.transactionType.PlaceOrder }
59
+ }, { acceptedOffers: 1 })
60
+ .lean()
61
+ .exec();
62
+ if (doc === null) {
63
+ throw new factory_1.factory.errors.NotFound('orderInTransaction');
64
+ }
65
+ const isCOA = doc.acceptedOffers.at(0)?.offeredThrough?.identifier === factory_1.factory.service.webAPI.Identifier.COA;
66
+ // COAの場合、予約取引は存在しないのでそのまま返す
67
+ if (isCOA) {
68
+ return doc.acceptedOffers;
69
+ }
70
+ // priceSpecificationを予約取引から補完する(2026-05-12~)
71
+ let subReservations = [];
72
+ const reservationNumbers = [...new Set(doc.acceptedOffers.map((aceptedOffer) => aceptedOffer.itemOffered.reservationNumber))];
73
+ if (reservationNumbers.length > 0) {
74
+ subReservations = await this.findSubReservationsByReservationNumbers({ reservationNumbers });
75
+ }
76
+ return doc.acceptedOffers.map((acceptedOffer) => {
77
+ const priceBySubReservation = subReservations.find((subReservation) => subReservation.id === acceptedOffer.itemOffered.id)?.price;
78
+ const priceSpecMatched = (0, util_1.isDeepStrictEqual)(acceptedOffer.priceSpecification, priceBySubReservation);
79
+ debug('findAcceptedOffersWithPriceByOrderNumber: priceSpecMatched?', priceSpecMatched, acceptedOffer.itemOffered.id, params.orderNumber, params.project.id);
80
+ if (!priceSpecMatched) {
81
+ console.error('findAcceptedOffersWithPriceByOrderNumber: priceSpecMatched: false!!!', acceptedOffer.itemOffered.id, params.orderNumber, params.project.id);
82
+ }
83
+ return {
84
+ ...acceptedOffer,
85
+ // 予約取引内の価格仕様と一致した場合のみ上書きしてみる
86
+ ...((priceSpecMatched && priceBySubReservation !== undefined) && { priceSpecification: priceBySubReservation })
87
+ };
88
+ });
13
89
  }
14
90
  /**
15
91
  * 取引進行中の注文からacceptedOffersを検索する
@@ -28,6 +104,7 @@ class OrderInTransactionRepo {
28
104
  }
29
105
  /**
30
106
  * 注文を受注する
107
+ * typeOf: PlaceOrder -> typeOf: Order
31
108
  */
32
109
  async placeOrder(order) {
33
110
  if (!(order.orderDate instanceof Date)) {
@@ -8,9 +8,7 @@ export interface IUpdatePartiallyParams {
8
8
  export type ICancelResult = UpdateWriteOpResult;
9
9
  export type ICheckedInResult = UpdateWriteOpResult;
10
10
  type ISavingReservedTicket = Omit<factory.assetTransaction.reserve.ISubReservationReservedTicket, 'ticketType'> & {
11
- ticketType: {
12
- id?: string;
13
- };
11
+ ticketType?: never;
14
12
  };
15
13
  /**
16
14
  * ドキュメントとして保管する予約
@@ -22,7 +20,7 @@ export type ICreatingReservation = Omit<factory.reservation.eventReservation.IRe
22
20
  /**
23
21
  * 廃止予定の予約属性
24
22
  */
25
- export type IDeprecatedField = 'price' | 'underName';
23
+ export type IDeprecatedField = 'price' | 'underName' | 'priceCurrency' | 'issuedThrough' | 'numSeats';
26
24
  export type IKeyOfProjection = Exclude<keyof factory.reservation.eventReservation.IReservation, IDeprecatedField> | 'reservedTicket.dateUsed' | 'reservationFor.id' | 'reservationFor.typeOf';
27
25
  export type IAttendedReservation = Pick<factory.reservation.eventReservation.IReservation, 'id' | 'typeOf' | 'project' | 'modifiedTime'> & {
28
26
  reservationFor: Pick<factory.reservation.eventReservation.IReservationForMinimized, 'id' | 'typeOf'>;
@@ -37,6 +35,18 @@ export type IReservationAsFindResult = Omit<factory.reservation.eventReservation
37
35
  * 実データとしてはまだ存在しているが型から廃止(2026-03-26~)
38
36
  */
39
37
  underName?: never;
38
+ /**
39
+ * discontinue(2026-05-10~)
40
+ */
41
+ priceCurrency?: never;
42
+ /**
43
+ * discontinue(2026-05-10~)
44
+ */
45
+ issuedThrough?: never;
46
+ /**
47
+ * discontinue(2026-05-11~)
48
+ */
49
+ numSeats?: never;
40
50
  };
41
51
  /**
42
52
  * 予約リポジトリ
@@ -63,7 +73,6 @@ export declare class ReservationRepo {
63
73
  };
64
74
  provider: factory.reservation.IProvider;
65
75
  subReservation: factory.assetTransaction.reserve.IObjectSubReservation[];
66
- issuedThrough: factory.assetTransaction.reserve.IIssuedThrough;
67
76
  reservationFor: factory.assetTransaction.reserve.IReservationFor;
68
77
  reservationNumber: string;
69
78
  underName?: factory.reservation.IUnderName;
@@ -145,16 +154,20 @@ export declare class ReservationRepo {
145
154
  }): Promise<string[]>;
146
155
  getCursor(conditions: any, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, Record<string, never>, IDocType, import("./mongoose/virtuals").IVirtuals, {}> & Omit<import("@chevre/factory/lib/chevre/reservation/event").IReservation, "id"> & {
147
156
  _id: string;
148
- bookingAgent?: any;
149
157
  previousReservationStatus?: factory.reservationStatusType;
158
+ price?: never;
159
+ priceCurrency?: never;
160
+ issuedThrough?: never;
150
161
  } & Required<{
151
162
  _id: string;
152
163
  }> & {
153
164
  __v: number;
154
165
  }, import("mongoose").QueryOptions<IDocType>, (import("mongoose").Document<unknown, Record<string, never>, IDocType, import("./mongoose/virtuals").IVirtuals, {}> & Omit<import("@chevre/factory/lib/chevre/reservation/event").IReservation, "id"> & {
155
166
  _id: string;
156
- bookingAgent?: any;
157
167
  previousReservationStatus?: factory.reservationStatusType;
168
+ price?: never;
169
+ priceCurrency?: never;
170
+ issuedThrough?: never;
158
171
  } & Required<{
159
172
  _id: string;
160
173
  }> & {