@chevre/domain 24.1.0-alpha.3 → 24.1.0-alpha.31

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 (173) hide show
  1. package/README.md +0 -2
  2. package/lib/chevre/repo/acceptedOffer.d.ts +14 -13
  3. package/lib/chevre/repo/acceptedOffer.js +135 -51
  4. package/lib/chevre/repo/acceptedOfferInReserve.d.ts +30 -0
  5. package/lib/chevre/repo/acceptedOfferInReserve.js +78 -0
  6. package/lib/chevre/repo/accountingReport.d.ts +9 -2
  7. package/lib/chevre/repo/accountingReport.js +6 -34
  8. package/lib/chevre/repo/action/actionProcess.d.ts +1 -1
  9. package/lib/chevre/repo/assetTransaction/reserve.d.ts +0 -1
  10. package/lib/chevre/repo/assetTransaction/reserve.js +4 -50
  11. package/lib/chevre/repo/event.js +12 -8
  12. package/lib/chevre/repo/factory/acceptedOffer/reserveTransaction2itemOffered.d.ts +7 -0
  13. package/lib/chevre/repo/factory/acceptedOffer/reserveTransaction2itemOffered.js +74 -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/mongoose/schemas/setting.d.ts +43 -0
  20. package/lib/chevre/repo/mongoose/schemas/setting.js +2 -1
  21. package/lib/chevre/repo/order.d.ts +2 -83
  22. package/lib/chevre/repo/order.js +171 -364
  23. package/lib/chevre/repo/orderInTransaction.d.ts +39 -3
  24. package/lib/chevre/repo/orderInTransaction.js +43 -1
  25. package/lib/chevre/repo/reservation.d.ts +20 -7
  26. package/lib/chevre/repo/reservation.js +14 -10
  27. package/lib/chevre/repo/role.d.ts +1 -15
  28. package/lib/chevre/repo/role.js +7 -14
  29. package/lib/chevre/repo/setting/integration.d.ts +19 -0
  30. package/lib/chevre/repo/setting/integration.js +72 -0
  31. package/lib/chevre/repo/transaction.d.ts +6 -6
  32. package/lib/chevre/repository.d.ts +5 -0
  33. package/lib/chevre/repository.js +11 -0
  34. package/lib/chevre/service/aggregation/event/aggregateOffers.js +22 -26
  35. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +0 -1
  36. package/lib/chevre/service/assetTransaction/cancelReservation/factory.js +14 -11
  37. package/lib/chevre/service/assetTransaction/cancelReservation/start.d.ts +1 -1
  38. package/lib/chevre/service/assetTransaction/cancelReservation/start.js +1 -1
  39. package/lib/chevre/service/assetTransaction/pay/check.d.ts +1 -1
  40. package/lib/chevre/service/assetTransaction/pay/publishPaymentUrl.d.ts +1 -1
  41. package/lib/chevre/service/assetTransaction/pay/searchGMOTrade.d.ts +1 -1
  42. package/lib/chevre/service/assetTransaction/pay/start/processAuthorize.d.ts +1 -1
  43. package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeCreditCard.d.ts +1 -1
  44. package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeMovieTicket.d.ts +1 -1
  45. package/lib/chevre/service/assetTransaction/pay/start.d.ts +1 -1
  46. package/lib/chevre/service/assetTransaction/reserve/cancel.d.ts +1 -1
  47. package/lib/chevre/service/assetTransaction/reserve/confirm.d.ts +1 -1
  48. package/lib/chevre/service/assetTransaction/reserve/start/factory/createReservation.js +0 -12
  49. package/lib/chevre/service/assetTransaction/reserve/start/factory/price.d.ts +1 -1
  50. package/lib/chevre/service/assetTransaction/reserve/start.d.ts +1 -1
  51. package/lib/chevre/service/delivery/factory.d.ts +6 -1
  52. package/lib/chevre/service/delivery/factory.js +1 -1
  53. package/lib/chevre/service/delivery/reservation/factory.d.ts +1 -3
  54. package/lib/chevre/service/delivery/reservation/factory.js +0 -17
  55. package/lib/chevre/service/notification/notifyAbortedTasksByEmail.d.ts +2 -2
  56. package/lib/chevre/service/notification/notifyAbortedTasksByEmail.js +1 -1
  57. package/lib/chevre/service/offer/any.d.ts +6 -1
  58. package/lib/chevre/service/offer/event/authorize/factory.d.ts +6 -3
  59. package/lib/chevre/service/offer/event/authorize/factory.js +4 -7
  60. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.d.ts +1 -1
  61. package/lib/chevre/service/offer/event/authorize.d.ts +7 -1
  62. package/lib/chevre/service/offer/event/authorize.js +11 -3
  63. package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4chevre.d.ts +1 -1
  64. package/lib/chevre/service/offer/event/voidTransaction.d.ts +1 -1
  65. package/lib/chevre/service/offer/event/voidTransactionByActionId.d.ts +1 -1
  66. package/lib/chevre/service/offer/eventServiceByCOA/authorize/factory.d.ts +1 -3
  67. package/lib/chevre/service/order/createAccountingReportIfNotExist.d.ts +1 -3
  68. package/lib/chevre/service/order/createAccountingReportIfNotExist.js +67 -72
  69. package/lib/chevre/service/order/deleteOrder.js +21 -44
  70. package/lib/chevre/service/order/onAssetTransactionStatusChanged/onPayTransactionConfirmed.d.ts +1 -1
  71. package/lib/chevre/service/order/onAssetTransactionStatusChanged/onReserveTransactionConfirmed.d.ts +1 -1
  72. package/lib/chevre/service/order/onAssetTransactionStatusChanged/paymentDue2Processing.d.ts +1 -1
  73. package/lib/chevre/service/order/onAssetTransactionStatusChanged/paymentDue2Processing.js +9 -11
  74. package/lib/chevre/service/order/onAssetTransactionStatusChanged/processing2inTransit.d.ts +1 -1
  75. package/lib/chevre/service/order/onAssetTransactionStatusChanged.d.ts +1 -1
  76. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.js +0 -1
  77. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts +6 -1
  78. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially.js +0 -1
  79. package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.d.ts +1 -1
  80. package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.js +1 -1
  81. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.d.ts +1 -1
  82. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.js +2 -1
  83. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned.js +0 -1
  84. package/lib/chevre/service/order/onOrderUpdated.js +0 -1
  85. package/lib/chevre/service/order/payOrder.d.ts +1 -1
  86. package/lib/chevre/service/order/placeOrder/factory/orderedItem.d.ts +1 -1
  87. package/lib/chevre/service/order/placeOrder/factory/orderedItem.js +0 -5
  88. package/lib/chevre/service/order/placeOrder/factory.d.ts +1 -1
  89. package/lib/chevre/service/order/placeOrder.d.ts +1 -1
  90. package/lib/chevre/service/order/returnOrder.js +0 -1
  91. package/lib/chevre/service/order/sendOrder.js +2 -5
  92. package/lib/chevre/service/payment/any/authorize.d.ts +1 -1
  93. package/lib/chevre/service/payment/any/person2username.js +0 -1
  94. package/lib/chevre/service/payment/any/publishPaymentUrl.d.ts +1 -1
  95. package/lib/chevre/service/payment/creditCard/authorize.d.ts +1 -1
  96. package/lib/chevre/service/payment/creditCard/authorize.js +3 -3
  97. package/lib/chevre/service/payment/creditCard/payCreditCard.d.ts +1 -1
  98. package/lib/chevre/service/payment/creditCard/payCreditCard.js +1 -1
  99. package/lib/chevre/service/payment/creditCard/refundCreditCard.d.ts +1 -1
  100. package/lib/chevre/service/payment/creditCard/refundCreditCard.js +1 -1
  101. package/lib/chevre/service/payment/creditCard/searchGMOTrade.d.ts +1 -1
  102. package/lib/chevre/service/payment/creditCard/searchGMOTrade.js +1 -1
  103. package/lib/chevre/service/payment/creditCard/voidTransaction.d.ts +1 -1
  104. package/lib/chevre/service/payment/creditCard/voidTransaction.js +1 -1
  105. package/lib/chevre/service/payment/factory/createPayObjectServiceOutput.d.ts +8 -1
  106. package/lib/chevre/service/payment/factory/createPayObjectServiceOutput.js +1 -1
  107. package/lib/chevre/service/payment/movieTicket/authorize.d.ts +1 -1
  108. package/lib/chevre/service/payment/movieTicket/checkMovieTicket.d.ts +1 -1
  109. package/lib/chevre/service/payment/movieTicket/payMovieTicket.d.ts +1 -1
  110. package/lib/chevre/service/payment/movieTicket/payMovieTicket.js +1 -1
  111. package/lib/chevre/service/payment/movieTicket/processPurchaseNumberAuth.d.ts +1 -1
  112. package/lib/chevre/service/payment/movieTicket/processPurchaseNumberAuth.js +1 -1
  113. package/lib/chevre/service/payment/movieTicket/refundMovieTicket.d.ts +1 -1
  114. package/lib/chevre/service/payment/movieTicket/refundMovieTicket.js +2 -2
  115. package/lib/chevre/service/payment/movieTicket/voidTransaction.d.ts +1 -1
  116. package/lib/chevre/service/reserve/confirmReservation.js +7 -7
  117. package/lib/chevre/service/reserve/factory.js +2 -1
  118. package/lib/chevre/service/reserve/findByCode.d.ts +1 -1
  119. package/lib/chevre/service/reserve/findByCode.js +2 -1
  120. package/lib/chevre/service/reserve/findReservations.d.ts +4 -4
  121. package/lib/chevre/service/reserve/findReservations.js +16 -26
  122. package/lib/chevre/service/reserve/potentialActions/onPendingReservationCanceled.js +0 -1
  123. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +0 -1
  124. package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.d.ts +4 -3
  125. package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +1 -10
  126. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +0 -1
  127. package/lib/chevre/service/reserve/potentialActions/onReservationsCreated.js +0 -1
  128. package/lib/chevre/service/reserve/searchByOrder.js +8 -3
  129. package/lib/chevre/service/reserve/useReservation.d.ts +1 -1
  130. package/lib/chevre/service/reserve/useReservation.js +20 -24
  131. package/lib/chevre/service/task/acceptCOAOffer.js +2 -2
  132. package/lib/chevre/service/task/authorizePayment.js +1 -1
  133. package/lib/chevre/service/task/cancelPendingReservation.js +1 -1
  134. package/lib/chevre/service/task/checkMovieTicket.js +1 -1
  135. package/lib/chevre/service/task/confirmReserveTransaction.d.ts +1 -1
  136. package/lib/chevre/service/task/confirmReserveTransaction.js +3 -2
  137. package/lib/chevre/service/task/createAccountingReport.js +7 -9
  138. package/lib/chevre/service/task/importEventCapacitiesFromCOA.js +1 -1
  139. package/lib/chevre/service/task/importEventsFromCOA.js +1 -1
  140. package/lib/chevre/service/task/importOffersFromCOA.js +1 -1
  141. package/lib/chevre/service/task/onResourceUpdated/onHasPOSUpdated.js +0 -1
  142. package/lib/chevre/service/task/pay.js +1 -1
  143. package/lib/chevre/service/task/payment/invalidatePaymentUrlByTask.d.ts +1 -1
  144. package/lib/chevre/service/task/payment/payByTask.d.ts +1 -1
  145. package/lib/chevre/service/task/payment/payByTask.js +3 -2
  146. package/lib/chevre/service/task/payment/refundByTask.d.ts +1 -1
  147. package/lib/chevre/service/task/payment/voidPaymentByTask.d.ts +1 -1
  148. package/lib/chevre/service/task/refund.js +1 -1
  149. package/lib/chevre/service/task/returnReserveTransaction.js +1 -1
  150. package/lib/chevre/service/task/syncResourcesFromCOA.js +1 -1
  151. package/lib/chevre/service/task/useReservation.d.ts +2 -2
  152. package/lib/chevre/service/task/useReservation.js +6 -18
  153. package/lib/chevre/service/task/voidPayment.js +1 -1
  154. package/lib/chevre/service/task/voidReserveTransaction.js +1 -1
  155. package/lib/chevre/service/task.d.ts +1 -1
  156. package/lib/chevre/service/taskHandler.js +1 -0
  157. package/lib/chevre/service/transaction/placeOrder/confirm/potentialActions/sendEmailMessage.js +0 -1
  158. package/lib/chevre/service/transaction/placeOrder/confirm/potentialActions.js +0 -1
  159. package/lib/chevre/service/transaction/placeOrder/confirm/validation/validateInvoiceReferencesOrder.d.ts +1 -1
  160. package/lib/chevre/service/transaction/placeOrder/confirm/validation/validateMovieTicket.d.ts +1 -1
  161. package/lib/chevre/service/transaction/placeOrder/confirm/validation.d.ts +2 -2
  162. package/lib/chevre/service/transaction/placeOrder/confirm.js +5 -3
  163. package/lib/chevre/service/transaction/placeOrder/exportTasksById.js +0 -1
  164. package/lib/chevre/service/transaction/placeOrder/updateAgent.js +0 -1
  165. package/lib/chevre/service/transaction/returnOrder/exportTasks/factory.js +0 -1
  166. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.js +0 -1
  167. package/lib/chevre/service/transaction/returnOrder/potentialActions.js +0 -1
  168. package/lib/chevre/service/transaction/returnOrder/preStart.js +2 -4
  169. package/lib/chevre/service/validation/validateOrder.js +5 -79
  170. package/lib/chevre/settings.d.ts +0 -55
  171. package/lib/chevre/settings.js +1 -29
  172. package/lib/chevre/taskSettings.d.ts +1 -1
  173. 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
  /**
@@ -1071,199 +1072,5 @@ class OrderRepo {
1071
1072
  }
1072
1073
  return { aggregation: aggregations[0] };
1073
1074
  }
1074
- async aggregateOrderOfSeat(params) {
1075
- const seatNumber = params.acceptedOffers.itemOffered.reservedTicket.ticketedSeat.seatNumber;
1076
- const screenCode = params.acceptedOffers.itemOffered.reservationFor.location.branchCode;
1077
- const movieTheaterCode = params.acceptedOffers.itemOffered.reservationFor.superEvent.location.branchCode;
1078
- const customerEmailIn = params.customer?.email?.$in;
1079
- const matchConditions = {
1080
- orderDate: {
1081
- $gte: params.orderDate.$gte,
1082
- $lte: params.orderDate.$lte
1083
- },
1084
- typeOf: { $eq: factory_1.factory.order.OrderType.Order },
1085
- 'project.id': { $eq: params.project.id.$eq },
1086
- 'acceptedOffers.itemOffered.reservationFor.superEvent.location.branchCode': { $exists: true, $eq: movieTheaterCode },
1087
- 'acceptedOffers.itemOffered.reservationFor.location.branchCode': { $exists: true, $eq: screenCode },
1088
- 'acceptedOffers.itemOffered.reservedTicket.ticketedSeat.seatNumber': { $exists: true, $eq: seatNumber },
1089
- ...(Array.isArray(customerEmailIn))
1090
- ? { 'customer.email': { $exists: true, $in: customerEmailIn } }
1091
- : undefined
1092
- };
1093
- const aggregations4email = await this.orderModel.aggregate([
1094
- { $match: matchConditions },
1095
- {
1096
- $group: {
1097
- _id: '$customer.email'
1098
- }
1099
- },
1100
- {
1101
- $count: 'emailCount'
1102
- }
1103
- ])
1104
- .exec();
1105
- const emailCount = (aggregations4email.length > 0) ? aggregations4email[0].emailCount : 0;
1106
- const aggregations = await this.orderModel.aggregate([
1107
- { $match: matchConditions },
1108
- {
1109
- $project: {
1110
- typeOf: '$typeOf',
1111
- graceTime: {
1112
- $subtract: [
1113
- { $first: '$acceptedOffers.itemOffered.reservationFor.startDate' },
1114
- '$orderDate'
1115
- ]
1116
- }
1117
- }
1118
- },
1119
- {
1120
- $group: {
1121
- _id: '$typeOf',
1122
- orderCount: { $sum: 1 },
1123
- sumGraceTime: { $sum: '$graceTime' }
1124
- }
1125
- },
1126
- {
1127
- $project: {
1128
- _id: 0,
1129
- orderCount: '$orderCount',
1130
- sumGraceTime: '$sumGraceTime'
1131
- }
1132
- }
1133
- ])
1134
- .exec();
1135
- if (aggregations.length === 0) {
1136
- return {
1137
- aggregation: {
1138
- orderCount: 0
1139
- }
1140
- };
1141
- }
1142
- return {
1143
- aggregation: {
1144
- ...aggregations[0],
1145
- emailCount
1146
- }
1147
- };
1148
- }
1149
- async aggregateOrderOfCustomerByProject(params) {
1150
- const matchConditions = {
1151
- orderDate: {
1152
- $gte: params.orderDate.$gte,
1153
- $lte: params.orderDate.$lte
1154
- },
1155
- typeOf: { $eq: factory_1.factory.order.OrderType.Order },
1156
- ...(typeof params.project?.id.$eq === 'string') ? { 'project.id': { $eq: params.project.id.$eq } } : undefined,
1157
- 'customer.email': { $exists: true, $eq: params.customer.email.$eq }
1158
- };
1159
- const aggregations = await this.orderModel.aggregate([
1160
- { $match: matchConditions },
1161
- {
1162
- $project: {
1163
- typeOf: '$typeOf',
1164
- graceTime: {
1165
- $subtract: [
1166
- { $first: '$acceptedOffers.itemOffered.reservationFor.startDate' },
1167
- '$orderDate'
1168
- ]
1169
- }
1170
- }
1171
- },
1172
- {
1173
- $group: {
1174
- _id: '$typeOf',
1175
- orderCount: { $sum: 1 },
1176
- sumGraceTime: { $sum: '$graceTime' }
1177
- }
1178
- },
1179
- {
1180
- $project: {
1181
- _id: 0,
1182
- orderCount: '$orderCount',
1183
- sumGraceTime: '$sumGraceTime'
1184
- }
1185
- }
1186
- ])
1187
- .exec();
1188
- if (aggregations.length === 0) {
1189
- return {
1190
- aggregation: {
1191
- orderCount: 0
1192
- }
1193
- };
1194
- }
1195
- return {
1196
- aggregation: {
1197
- ...aggregations[0]
1198
- }
1199
- };
1200
- }
1201
- async aggregateOrderOfCustomerGlobally(params) {
1202
- const matchConditions = {
1203
- orderDate: {
1204
- $gte: params.orderDate.$gte,
1205
- $lte: params.orderDate.$lte
1206
- },
1207
- typeOf: { $eq: factory_1.factory.order.OrderType.Order },
1208
- 'customer.email': { $exists: true, $eq: params.customer.email.$eq }
1209
- };
1210
- const aggregations = await this.orderModel.aggregate([
1211
- { $match: matchConditions },
1212
- {
1213
- $project: {
1214
- typeOf: '$typeOf'
1215
- }
1216
- },
1217
- {
1218
- $group: {
1219
- _id: '$typeOf',
1220
- orderCount: { $sum: 1 }
1221
- }
1222
- },
1223
- {
1224
- $project: {
1225
- _id: 0,
1226
- orderCount: '$orderCount'
1227
- }
1228
- }
1229
- ])
1230
- .exec();
1231
- if (aggregations.length === 0) {
1232
- return {
1233
- aggregation: {
1234
- orderCount: 0,
1235
- aggregateProject: { projectCount: 0 }
1236
- }
1237
- };
1238
- }
1239
- const aggregations2 = await this.orderModel.aggregate([
1240
- { $match: matchConditions },
1241
- {
1242
- $project: {
1243
- project: '$project'
1244
- }
1245
- },
1246
- {
1247
- $group: {
1248
- _id: '$project.id'
1249
- }
1250
- },
1251
- {
1252
- $count: 'projectCount'
1253
- },
1254
- {
1255
- $project: {
1256
- aggregateProject: { projectCount: '$projectCount' }
1257
- }
1258
- }
1259
- ])
1260
- .exec();
1261
- return {
1262
- aggregation: {
1263
- ...aggregations[0],
1264
- ...aggregations2[0]
1265
- }
1266
- };
1267
- }
1268
1075
  }
1269
1076
  exports.OrderRepo = OrderRepo;
@@ -1,21 +1,49 @@
1
1
  import type { Connection } from 'mongoose';
2
2
  import { factory } from '../factory';
3
+ import { AcceptedOfferInReserveRepo } from './acceptedOfferInReserve';
3
4
  type IOrderInTransaction = Pick<factory.order.IOrder, 'orderNumber' | 'project'> & {
4
5
  typeOf: factory.transactionType.PlaceOrder;
5
6
  orderDate: Date;
6
7
  acceptedOffers: factory.order.IAcceptedOffer[];
7
8
  customer?: factory.order.ICustomer;
8
9
  };
10
+ type IAcceptedOffer = factory.order.IAcceptedOffer & {
11
+ /**
12
+ * 受け入れ時に指定必須
13
+ */
14
+ offeredThrough: factory.offer.IOfferedThrough;
15
+ };
16
+ /**
17
+ * typeOf: Orderへドキュメント変換時の編集フィールド
18
+ */
9
19
  export type IPlacingOrder = Pick<factory.order.IOrder, 'broker' | 'confirmationNumber' | 'identifier' | 'isGift' | 'name' | 'orderDate' | 'orderNumber' | 'orderStatus' | 'orderedItem' | 'paymentMethods' | 'price' | 'priceCurrency' | 'seller' | 'typeOf' | 'url'> & {
20
+ /**
21
+ * 上書きしてはいけない
22
+ */
10
23
  acceptedOffers?: never;
24
+ /**
25
+ * 上書きしてはいけない
26
+ */
11
27
  customer?: never;
12
28
  };
13
29
  /**
14
30
  * 取引中注文リポジトリ
15
31
  */
16
- export declare class OrderInTransactionRepo {
32
+ export declare class OrderInTransactionRepo extends AcceptedOfferInReserveRepo {
17
33
  private readonly orderModel;
18
34
  constructor(connection: Connection);
35
+ /**
36
+ * 取引進行中の注文からacceptedOffersを検索する
37
+ * 予約取引から予約ごとの価格仕様も参照する
38
+ */
39
+ findAcceptedOffersWithPriceByOrderNumber(params: {
40
+ orderNumber: string;
41
+ project: {
42
+ id: string;
43
+ };
44
+ }): Promise<(Omit<factory.order.IAcceptedOffer, 'priceSpecification'> & {
45
+ priceSpecification?: factory.order.ITicketPriceSpecification;
46
+ })[]>;
19
47
  /**
20
48
  * 取引進行中の注文からacceptedOffersを検索する
21
49
  */
@@ -23,16 +51,24 @@ export declare class OrderInTransactionRepo {
23
51
  orderNumber: {
24
52
  $eq: string;
25
53
  };
26
- }): Promise<factory.order.IAcceptedOffer[]>;
54
+ }): Promise<Pick<factory.order.IAcceptedOffer, 'itemOffered' | 'serialNumber'>[]>;
27
55
  /**
28
56
  * 注文を受注する
57
+ * typeOf: PlaceOrder -> typeOf: Order
29
58
  */
30
59
  placeOrder(order: IPlacingOrder): Promise<void>;
31
60
  /**
32
61
  * 注文documentがなければ作成し、受け入れられたオファーを追加する
33
62
  * このメソッドでdocumentが初めて生成される(typeOf:PlaceOrderとして)
34
63
  */
35
- acceptOffer(params: Pick<IOrderInTransaction, 'acceptedOffers' | 'orderNumber' | 'project'>): Promise<import("mongoose").UpdateWriteOpResult | undefined>;
64
+ acceptOffer(params: Pick<IOrderInTransaction, 'orderNumber' | 'project'> & {
65
+ acceptedOffers: (Omit<IAcceptedOffer, 'priceSpecification'> & {
66
+ /**
67
+ * COA以外では注文ドキュメントにpriceSpecificationが存在しないのでIFを補完
68
+ */
69
+ priceSpecification?: factory.order.ITicketPriceSpecification;
70
+ })[];
71
+ }): Promise<import("mongoose").UpdateWriteOpResult | undefined>;
36
72
  /**
37
73
  * serialNumberからオファーを除外する
38
74
  * ホワイトリストとブラックリスト両方に対応