@chevre/domain 24.0.0-alpha.1 → 24.0.0-alpha.11

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 (184) hide show
  1. package/lib/chevre/repo/acceptedPaymentMethod.js +1 -1
  2. package/lib/chevre/repo/additionalProperty.js +1 -1
  3. package/lib/chevre/repo/aggregateOffer.js +1 -1
  4. package/lib/chevre/repo/confirmationNumber.js +2 -4
  5. package/lib/chevre/repo/creativeWork.js +1 -1
  6. package/lib/chevre/repo/eventOffer.js +1 -1
  7. package/lib/chevre/repo/eventSeries.js +1 -1
  8. package/lib/chevre/repo/identity.js +1 -2
  9. package/lib/chevre/repo/issuer.js +2 -4
  10. package/lib/chevre/repo/message.js +1 -1
  11. package/lib/chevre/repo/mongoose/schemas/transaction.js +31 -0
  12. package/lib/chevre/repo/note.js +1 -1
  13. package/lib/chevre/repo/noteAboutOrder.js +1 -1
  14. package/lib/chevre/repo/offer/unitPriceInCatalog.js +1 -1
  15. package/lib/chevre/repo/offerItemCondition.js +1 -1
  16. package/lib/chevre/repo/order.js +1 -1
  17. package/lib/chevre/repo/orderInTransaction.d.ts +8 -0
  18. package/lib/chevre/repo/orderInTransaction.js +17 -4
  19. package/lib/chevre/repo/orderNumber.d.ts +3 -2
  20. package/lib/chevre/repo/orderNumber.js +25 -32
  21. package/lib/chevre/repo/place/movieTheater.js +1 -1
  22. package/lib/chevre/repo/place/seat.js +1 -1
  23. package/lib/chevre/repo/product.js +1 -1
  24. package/lib/chevre/repo/productOffer.js +1 -1
  25. package/lib/chevre/repo/project.js +1 -1
  26. package/lib/chevre/repo/reservation.js +1 -1
  27. package/lib/chevre/repo/role.js +1 -2
  28. package/lib/chevre/repo/seller.js +1 -1
  29. package/lib/chevre/repo/serviceOutputIdentifier.js +2 -4
  30. package/lib/chevre/repo/transaction/placeOrder.d.ts +140 -0
  31. package/lib/chevre/repo/transaction/placeOrder.js +528 -0
  32. package/lib/chevre/repo/transaction/returnOrder.d.ts +23 -0
  33. package/lib/chevre/repo/transaction/returnOrder.js +213 -0
  34. package/lib/chevre/repo/transaction.d.ts +11 -84
  35. package/lib/chevre/repo/transaction.js +331 -270
  36. package/lib/chevre/repo/transactionNumber.js +2 -4
  37. package/lib/chevre/repo/trip.js +1 -2
  38. package/lib/chevre/repository.d.ts +12 -0
  39. package/lib/chevre/repository.js +26 -1
  40. package/lib/chevre/service/account.js +14 -21
  41. package/lib/chevre/service/accountTransaction/deposit.js +2 -8
  42. package/lib/chevre/service/accountTransaction/transfer.js +2 -8
  43. package/lib/chevre/service/accountTransaction/withdraw.js +2 -8
  44. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +24 -32
  45. package/lib/chevre/service/assetTransaction/cancelReservationCOA.js +2 -4
  46. package/lib/chevre/service/assetTransaction/moneyTransfer.js +2 -23
  47. package/lib/chevre/service/assetTransaction/pay/check.js +6 -11
  48. package/lib/chevre/service/assetTransaction/pay/confirm.js +1 -2
  49. package/lib/chevre/service/assetTransaction/pay/searchGMOTrade.d.ts +1 -1
  50. package/lib/chevre/service/assetTransaction/pay/start/factory.d.ts +51 -3
  51. package/lib/chevre/service/assetTransaction/pay/start/factory.js +58 -21
  52. package/lib/chevre/service/assetTransaction/pay/start/preStart/fixPaymentService.d.ts +10 -0
  53. package/lib/chevre/service/assetTransaction/pay/start/preStart/fixPaymentService.js +88 -0
  54. package/lib/chevre/service/assetTransaction/pay/start/processAuthorize.d.ts +53 -0
  55. package/lib/chevre/service/assetTransaction/pay/start/processAuthorize.js +56 -0
  56. package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeMovieTicket.d.ts +1 -1
  57. package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeMovieTicket.js +1 -11
  58. package/lib/chevre/service/assetTransaction/pay/start.js +8 -132
  59. package/lib/chevre/service/assetTransaction/refund.js +13 -20
  60. package/lib/chevre/service/assetTransaction/registerService.js +1 -7
  61. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateIssuedOfferIfExists.js +2 -4
  62. package/lib/chevre/service/assetTransaction/reserveCOA.js +2 -4
  63. package/lib/chevre/service/delivery/product/factory.js +1 -2
  64. package/lib/chevre/service/delivery/reservation/factory.js +1 -2
  65. package/lib/chevre/service/event/saveScreeningEvents.js +1 -0
  66. package/lib/chevre/service/event.js +0 -1
  67. package/lib/chevre/service/moneyTransfer.js +2 -2
  68. package/lib/chevre/service/notification/factory.js +1 -1
  69. package/lib/chevre/service/notification/notifyByEmail.js +50 -56
  70. package/lib/chevre/service/notification/sendEmailMessage.js +2 -3
  71. package/lib/chevre/service/notification/triggerWebhook.js +32 -37
  72. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.js +1 -2
  73. package/lib/chevre/service/offer/event/authorize.d.ts +2 -2
  74. package/lib/chevre/service/offer/event/authorize.js +4 -4
  75. package/lib/chevre/service/offer/event/issueEventOfferTicket.d.ts +2 -2
  76. package/lib/chevre/service/offer/event/issueEventOfferTicket.js +1 -1
  77. package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4chevre.d.ts +0 -2
  78. package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4chevre.js +1 -0
  79. package/lib/chevre/service/offer/event/voidTransaction.d.ts +2 -2
  80. package/lib/chevre/service/offer/event/voidTransaction.js +2 -2
  81. package/lib/chevre/service/offer/event/voidTransactionByActionId.d.ts +2 -2
  82. package/lib/chevre/service/offer/event/voidTransactionByActionId.js +2 -2
  83. package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer/authorize.js +1 -2
  84. package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer.d.ts +2 -2
  85. package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer.js +6 -6
  86. package/lib/chevre/service/offer/eventServiceByCOA/authorize.d.ts +2 -2
  87. package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +3 -10
  88. package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +2 -2
  89. package/lib/chevre/service/offer/moneyTransfer/authorize.d.ts +2 -2
  90. package/lib/chevre/service/offer/moneyTransfer/authorize.js +53 -57
  91. package/lib/chevre/service/offer/moneyTransfer/voidTransaction.d.ts +2 -2
  92. package/lib/chevre/service/offer/moneyTransfer/voidTransaction.js +4 -1
  93. package/lib/chevre/service/offer/product.d.ts +3 -3
  94. package/lib/chevre/service/offer/product.js +4 -4
  95. package/lib/chevre/service/order/confirmPayTransaction.d.ts +0 -2
  96. package/lib/chevre/service/order/confirmPayTransaction.js +1 -0
  97. package/lib/chevre/service/order/findPlaceOrderTransaction.d.ts +2 -2
  98. package/lib/chevre/service/order/findPlaceOrderTransaction.js +1 -1
  99. package/lib/chevre/service/order/onAssetTransactionStatusChanged.d.ts +4 -4
  100. package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +10 -19
  101. package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled.js +1 -1
  102. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.js +1 -1
  103. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially.js +1 -1
  104. package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.d.ts +2 -2
  105. package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.js +1 -1
  106. package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.js +1 -1
  107. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.js +1 -1
  108. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned.js +1 -1
  109. package/lib/chevre/service/order/onOrderUpdated.js +1 -2
  110. package/lib/chevre/service/order/payOrder.d.ts +2 -2
  111. package/lib/chevre/service/order/placeOrder/createPlacingOrderFromExistingTransaction.d.ts +2 -2
  112. package/lib/chevre/service/order/placeOrder/createPlacingOrderFromExistingTransaction.js +2 -3
  113. package/lib/chevre/service/order/placeOrder.d.ts +2 -2
  114. package/lib/chevre/service/order/returnOrder.d.ts +2 -2
  115. package/lib/chevre/service/order/returnOrder.js +2 -2
  116. package/lib/chevre/service/order/sendOrder.d.ts +2 -2
  117. package/lib/chevre/service/order/sendOrder.js +1 -1
  118. package/lib/chevre/service/payment/any/authorize/fixTransactionNumber.d.ts +3 -3
  119. package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.d.ts +3 -3
  120. package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.js +1 -1
  121. package/lib/chevre/service/payment/any/fixOrderAsNeeded.d.ts +2 -2
  122. package/lib/chevre/service/payment/any/fixOrderAsNeeded.js +4 -8
  123. package/lib/chevre/service/payment/any/publishPaymentUrl/fixTransactionNumberOnPublishPaymentUrl.d.ts +2 -2
  124. package/lib/chevre/service/payment/any.d.ts +6 -6
  125. package/lib/chevre/service/payment/any.js +10 -11
  126. package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard.js +1 -2
  127. package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard3ds.d.ts +1 -1
  128. package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard3ds.js +1 -2
  129. package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard3dsResult2recipe.d.ts +1 -1
  130. package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCardResult2recipe.d.ts +1 -1
  131. package/lib/chevre/service/payment/creditCard/factory.d.ts +1 -1
  132. package/lib/chevre/service/payment/movieTicket/authorize.js +1 -1
  133. package/lib/chevre/service/payment/movieTicket/processPurchaseNumberAuth.js +2 -4
  134. package/lib/chevre/service/payment/movieTicket/refundMovieTicket.js +4 -6
  135. package/lib/chevre/service/payment/movieTicket/voidTransaction.js +1 -2
  136. package/lib/chevre/service/payment/paymentCard.js +2 -4
  137. package/lib/chevre/service/report/telemetry.d.ts +4 -0
  138. package/lib/chevre/service/report/telemetry.js +7 -12
  139. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +2 -6
  140. package/lib/chevre/service/task/acceptCOAOffer.js +6 -4
  141. package/lib/chevre/service/task/authorizePayment.js +4 -2
  142. package/lib/chevre/service/task/confirmPayTransaction.js +2 -2
  143. package/lib/chevre/service/task/confirmReserveTransaction.js +1 -2
  144. package/lib/chevre/service/task/deleteTransaction.js +5 -1
  145. package/lib/chevre/service/task/onAssetTransactionStatusChanged.js +4 -2
  146. package/lib/chevre/service/task/onOrderPaymentCompleted.js +2 -2
  147. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByProduct.js +3 -6
  148. package/lib/chevre/service/task/onResourceUpdated/onOfferCatalogUpdated.js +1 -1
  149. package/lib/chevre/service/task/onResourceUpdated/syncOfferCatalog.js +1 -1
  150. package/lib/chevre/service/task/pay.js +1 -2
  151. package/lib/chevre/service/task/placeOrder.js +6 -4
  152. package/lib/chevre/service/task/publishPaymentUrl.js +4 -2
  153. package/lib/chevre/service/task/returnOrder.js +4 -4
  154. package/lib/chevre/service/task/returnPayTransaction.js +4 -3
  155. package/lib/chevre/service/task/sendOrder.js +2 -2
  156. package/lib/chevre/service/task/voidMoneyTransferTransaction.js +6 -3
  157. package/lib/chevre/service/task/voidPayTransaction.js +4 -2
  158. package/lib/chevre/service/task/voidRegisterServiceTransaction.js +3 -3
  159. package/lib/chevre/service/task/voidReserveTransaction.js +5 -4
  160. package/lib/chevre/service/transaction/deleteTransaction.d.ts +4 -0
  161. package/lib/chevre/service/transaction/deleteTransaction.js +57 -15
  162. package/lib/chevre/service/transaction/moneyTransfer.js +15 -23
  163. package/lib/chevre/service/transaction/placeOrder/confirm/publishCode.js +1 -1
  164. package/lib/chevre/service/transaction/placeOrder/confirm.d.ts +2 -2
  165. package/lib/chevre/service/transaction/placeOrder/confirm.js +12 -13
  166. package/lib/chevre/service/transaction/placeOrder/exportTasksById.d.ts +2 -2
  167. package/lib/chevre/service/transaction/placeOrder/exportTasksById.js +1 -1
  168. package/lib/chevre/service/transaction/placeOrder/{publishOrderNumberIfNotExist.d.ts → issueOrderNumberIfNotExist.d.ts} +4 -4
  169. package/lib/chevre/service/transaction/placeOrder/{publishOrderNumberIfNotExist.js → issueOrderNumberIfNotExist.js} +21 -13
  170. package/lib/chevre/service/transaction/placeOrder/publishConfirmationNumberIfNotExist.d.ts +2 -2
  171. package/lib/chevre/service/transaction/placeOrder/publishConfirmationNumberIfNotExist.js +3 -3
  172. package/lib/chevre/service/transaction/placeOrder/start/validateStartRequest.js +1 -2
  173. package/lib/chevre/service/transaction/placeOrder/start.d.ts +3 -3
  174. package/lib/chevre/service/transaction/placeOrder/start.js +2 -2
  175. package/lib/chevre/service/transaction/placeOrder/updateAgent.d.ts +23 -0
  176. package/lib/chevre/service/transaction/placeOrder/updateAgent.js +126 -0
  177. package/lib/chevre/service/transaction/placeOrder.d.ts +2 -1
  178. package/lib/chevre/service/transaction/placeOrder.js +3 -1
  179. package/lib/chevre/service/transaction/returnOrder/potentialActions.js +1 -2
  180. package/lib/chevre/service/transaction/returnOrder/preStart/getReturnPolicyByProject.js +1 -1
  181. package/lib/chevre/service/transaction/returnOrder.js +4 -4
  182. package/lib/chevre/service/transaction.d.ts +5 -21
  183. package/lib/chevre/service/transaction.js +5 -111
  184. package/package.json +6 -18
@@ -30,11 +30,14 @@ exports.authorize = authorize;
30
30
  const moment_1 = __importDefault(require("moment"));
31
31
  const factory = __importStar(require("../../../factory"));
32
32
  const MoneyTransferAssetTransactionService = __importStar(require("../../assetTransaction/moneyTransfer"));
33
- const publishOrderNumberIfNotExist_1 = require("../../transaction/placeOrder/publishOrderNumberIfNotExist");
33
+ const issueOrderNumberIfNotExist_1 = require("../../transaction/placeOrder/issueOrderNumberIfNotExist");
34
34
  const any_1 = require("../any");
35
35
  function authorize(params) {
36
36
  return async (repos) => {
37
- const transaction = await repos.transaction.projectFieldsInProgressById({
37
+ if (params.purpose.typeOf !== factory.transactionType.PlaceOrder) {
38
+ throw new factory.errors.NotImplemented(`purpose.typeOf: ${params.purpose.typeOf} not implemented`);
39
+ }
40
+ const transaction = await repos.placeOrder.findPlaceOrderInProgressById({
38
41
  typeOf: params.purpose.typeOf,
39
42
  id: params.purpose.id
40
43
  }, ['seller', 'project', 'agent', 'typeOf']);
@@ -42,7 +45,7 @@ function authorize(params) {
42
45
  throw new factory.errors.Forbidden('Transaction not yours');
43
46
  }
44
47
  const now = new Date();
45
- const orderNumber = await (0, publishOrderNumberIfNotExist_1.publishOrderNumberIfNotExist)({
48
+ const orderNumber = await (0, issueOrderNumberIfNotExist_1.issueOrderNumberIfNotExist)({
46
49
  project: { id: params.project.id },
47
50
  id: transaction.id,
48
51
  object: { orderDate: now }
@@ -51,7 +54,7 @@ function authorize(params) {
51
54
  const { transactionNumber } = await repos.transactionNumber.publishByTimestamp({ startDate: now });
52
55
  let requestBody;
53
56
  let responseBody;
54
- let acceptedOffers4result = [];
57
+ let acceptedOffers4result;
55
58
  // 承認アクションを開始
56
59
  const actionAttributes = createAuthorizeMoneyTransferOfferActionattributes({
57
60
  transaction,
@@ -189,66 +192,59 @@ function createAuthorizeMoneyTransferOfferActionattributes(params) {
189
192
  }
190
193
  function processStartDepositTransaction(params) {
191
194
  return async (repos) => {
192
- let requestBody;
193
- let responseBody;
194
- try {
195
- const description = `for ${params.transaction.typeOf} Transaction ${params.transaction.id}`;
196
- // 最大1ヵ月のオーソリ
197
- const expires = (0, moment_1.default)()
198
- .add(1, 'month')
199
- .toDate();
200
- const toLocation = {
201
- typeOf: factory.permit.PermitType.Permit,
202
- identifier: params.object.itemOffered.toLocation.identifier,
203
- issuedThrough: { id: params.object.itemOffered.toLocation.issuedThrough?.id }
204
- };
205
- // 販売者が取引人に入金
206
- requestBody = {
207
- typeOf: factory.assetTransactionType.MoneyTransfer,
208
- project: { typeOf: factory.organizationType.Project, id: params.project.id },
209
- transactionNumber: params.transactionNumber,
210
- agent: {
211
- // project: params.transaction.project,
212
- typeOf: params.transaction.seller.typeOf,
213
- id: String(params.transaction.seller.id),
214
- name: (typeof params.transaction.seller.name === 'string')
215
- ? params.transaction.seller.name
216
- : String(params.transaction.seller.name?.ja)
217
- },
218
- object: {
219
- amount: {
220
- typeOf: 'MonetaryAmount',
221
- value: Number(params.object.itemOffered.amount.value),
222
- currency: ''
223
- },
224
- fromLocation: {
225
- typeOf: params.transaction.agent.typeOf,
226
- id: params.transaction.agent.id,
227
- name: (typeof params.transaction.agent.name === 'string')
228
- ? params.transaction.agent.name
229
- : `${params.transaction.typeOf} Transaction ${params.transaction.id}`
230
- },
231
- toLocation,
232
- description: description,
233
- pendingTransaction: {
234
- typeOf: factory.account.transactionType.Deposit,
235
- transactionNumber: params.transactionNumber
236
- }
195
+ const description = `for ${params.transaction.typeOf} Transaction ${params.transaction.id}`;
196
+ // 最大1ヵ月のオーソリ
197
+ const expires = (0, moment_1.default)()
198
+ .add(1, 'month')
199
+ .toDate();
200
+ const toLocation = {
201
+ typeOf: factory.permit.PermitType.Permit,
202
+ identifier: params.object.itemOffered.toLocation.identifier,
203
+ issuedThrough: { id: params.object.itemOffered.toLocation.issuedThrough?.id }
204
+ };
205
+ // 販売者が取引人に入金
206
+ const requestBody = {
207
+ typeOf: factory.assetTransactionType.MoneyTransfer,
208
+ project: { typeOf: factory.organizationType.Project, id: params.project.id },
209
+ transactionNumber: params.transactionNumber,
210
+ agent: {
211
+ // project: params.transaction.project,
212
+ typeOf: params.transaction.seller.typeOf,
213
+ id: String(params.transaction.seller.id),
214
+ name: (typeof params.transaction.seller.name === 'string')
215
+ ? params.transaction.seller.name
216
+ : String(params.transaction.seller.name?.ja)
217
+ },
218
+ object: {
219
+ amount: {
220
+ typeOf: 'MonetaryAmount',
221
+ value: Number(params.object.itemOffered.amount.value),
222
+ currency: ''
237
223
  },
238
- recipient: {
224
+ fromLocation: {
239
225
  typeOf: params.transaction.agent.typeOf,
240
226
  id: params.transaction.agent.id,
241
227
  name: (typeof params.transaction.agent.name === 'string')
242
228
  ? params.transaction.agent.name
243
229
  : `${params.transaction.typeOf} Transaction ${params.transaction.id}`
244
230
  },
245
- expires: expires
246
- };
247
- responseBody = await MoneyTransferAssetTransactionService.start(requestBody)(repos);
248
- }
249
- catch (error) {
250
- throw error;
251
- }
231
+ toLocation,
232
+ description: description,
233
+ pendingTransaction: {
234
+ typeOf: factory.account.transactionType.Deposit,
235
+ transactionNumber: params.transactionNumber
236
+ }
237
+ },
238
+ recipient: {
239
+ typeOf: params.transaction.agent.typeOf,
240
+ id: params.transaction.agent.id,
241
+ name: (typeof params.transaction.agent.name === 'string')
242
+ ? params.transaction.agent.name
243
+ : `${params.transaction.typeOf} Transaction ${params.transaction.id}`
244
+ },
245
+ expires: expires
246
+ };
247
+ const responseBody = await MoneyTransferAssetTransactionService.start(requestBody)(repos);
252
248
  return { requestBody, responseBody };
253
249
  };
254
250
  }
@@ -1,9 +1,9 @@
1
1
  import * as factory from '../../../factory';
2
2
  import type { ActionRepo } from '../../../repo/action';
3
3
  import type { AssetTransactionRepo } from '../../../repo/assetTransaction';
4
- import type { TransactionRepo } from '../../../repo/transaction';
4
+ import type { PlaceOrderRepo } from '../../../repo/transaction/placeOrder';
5
5
  export declare function voidTransaction(params: factory.task.IData<factory.taskName.VoidMoneyTransferTransaction>): (repos: {
6
6
  action: ActionRepo;
7
7
  assetTransaction: AssetTransactionRepo;
8
- transaction: TransactionRepo;
8
+ placeOrder: PlaceOrderRepo;
9
9
  }) => Promise<void>;
@@ -28,9 +28,12 @@ const factory = __importStar(require("../../../factory"));
28
28
  const MoneyTransferAssetTransactionService = __importStar(require("../../assetTransaction/moneyTransfer"));
29
29
  function voidTransaction(params) {
30
30
  return async (repos) => {
31
+ if (params.purpose.typeOf !== factory.transactionType.PlaceOrder) {
32
+ throw new factory.errors.NotImplemented(`purpose.typeOf: ${params.purpose.typeOf} not implemented`);
33
+ }
31
34
  let transaction;
32
35
  if (params.agent !== undefined && params.agent !== null && typeof params.agent.id === 'string') {
33
- transaction = await repos.transaction.projectFieldsInProgressById({
36
+ transaction = await repos.placeOrder.findPlaceOrderInProgressById({
34
37
  typeOf: params.purpose.typeOf,
35
38
  id: params.purpose.id
36
39
  }, ['typeOf']);
@@ -11,7 +11,7 @@ import type { ProductRepo } from '../../repo/product';
11
11
  import type { ProjectRepo } from '../../repo/project';
12
12
  import type { ServiceOutputRepo } from '../../repo/serviceOutput';
13
13
  import type { ServiceOutputIdentifierRepo } from '../../repo/serviceOutputIdentifier';
14
- import type { TransactionRepo } from '../../repo/transaction';
14
+ import type { PlaceOrderRepo } from '../../repo/transaction/placeOrder';
15
15
  import type { TransactionNumberRepo } from '../../repo/transactionNumber';
16
16
  export interface IAuthorizeOperationRepos {
17
17
  account: AccountRepo;
@@ -26,7 +26,7 @@ export interface IAuthorizeOperationRepos {
26
26
  project: ProjectRepo;
27
27
  serviceOutput: ServiceOutputRepo;
28
28
  serviceOutputIdentifier: ServiceOutputIdentifierRepo;
29
- transaction: TransactionRepo;
29
+ placeOrder: PlaceOrderRepo;
30
30
  transactionNumber: TransactionNumberRepo;
31
31
  }
32
32
  export type IAuthorizeOperation<T> = (repos: IAuthorizeOperationRepos) => Promise<T>;
@@ -96,5 +96,5 @@ export declare function authorize(params: {
96
96
  export declare function voidTransaction(params: factory.task.IData<factory.taskName.VoidRegisterServiceTransaction>): (repos: {
97
97
  action: ActionRepo;
98
98
  assetTransaction: AssetTransactionRepo;
99
- transaction: TransactionRepo;
99
+ placeOrder: PlaceOrderRepo;
100
100
  }) => Promise<void>;
@@ -31,7 +31,7 @@ const factory = __importStar(require("../../factory"));
31
31
  const accountTransactionIdentifier_1 = require("../../factory/accountTransactionIdentifier");
32
32
  const availableProductTypes_1 = require("../../factory/availableProductTypes");
33
33
  const RegisterServiceTransaction = __importStar(require("../assetTransaction/registerService"));
34
- const publishOrderNumberIfNotExist_1 = require("../transaction/placeOrder/publishOrderNumberIfNotExist");
34
+ const issueOrderNumberIfNotExist_1 = require("../transaction/placeOrder/issueOrderNumberIfNotExist");
35
35
  const any_1 = require("./any");
36
36
  const factory_1 = require("./product/factory");
37
37
  const searchProductOffers_1 = require("./product/searchProductOffers");
@@ -99,7 +99,7 @@ function search(params) {
99
99
  function authorize(params) {
100
100
  return async (repos) => {
101
101
  const now = new Date();
102
- const transaction = await repos.transaction.projectFieldsInProgressById({
102
+ const transaction = await repos.placeOrder.findPlaceOrderInProgressById({
103
103
  typeOf: factory.transactionType.PlaceOrder,
104
104
  id: params.transaction.id
105
105
  }, ['agent', 'project', 'seller', 'typeOf', 'expires']);
@@ -117,7 +117,7 @@ function authorize(params) {
117
117
  })(repos);
118
118
  }
119
119
  // ポイント特典の識別子に利用するため注文番号を先に発行
120
- const orderNumber = await (0, publishOrderNumberIfNotExist_1.publishOrderNumberIfNotExist)({
120
+ const orderNumber = await (0, issueOrderNumberIfNotExist_1.issueOrderNumberIfNotExist)({
121
121
  project: { id: transaction.project.id },
122
122
  id: transaction.id,
123
123
  object: { orderDate: new Date() }
@@ -214,7 +214,7 @@ function fixProductAndOffers(params) {
214
214
  }
215
215
  function voidTransaction(params) {
216
216
  return async (repos) => {
217
- const transaction = await repos.transaction.projectFieldsById({
217
+ const transaction = await repos.placeOrder.findPlaceOrderById({
218
218
  typeOf: params.purpose.typeOf,
219
219
  id: params.purpose.id
220
220
  }, ['agent', 'status', 'typeOf']);
@@ -7,7 +7,6 @@ import type { EventRepo } from '../../repo/event';
7
7
  import type { OrderRepo } from '../../repo/order';
8
8
  import type { ProjectRepo } from '../../repo/project';
9
9
  import type { TaskRepo } from '../../repo/task';
10
- import type { TransactionRepo } from '../../repo/transaction';
11
10
  declare function confirmPayTransaction(data: factory.task.IData<factory.taskName.ConfirmPayTransaction> & {
12
11
  project: {
13
12
  id: string;
@@ -22,6 +21,5 @@ declare function confirmPayTransaction(data: factory.task.IData<factory.taskName
22
21
  event: EventRepo;
23
22
  project: ProjectRepo;
24
23
  task: TaskRepo;
25
- transaction: TransactionRepo;
26
24
  }) => Promise<void>;
27
25
  export { confirmPayTransaction };
@@ -25,6 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.confirmPayTransaction = confirmPayTransaction;
27
27
  const factory = __importStar(require("../../factory"));
28
+ // import type { TransactionRepo } from '../../repo/transaction';
28
29
  const PayTransactionService = __importStar(require("../assetTransaction/pay"));
29
30
  function confirmPayTransaction(data, options) {
30
31
  return async (repos) => {
@@ -1,4 +1,4 @@
1
- import type { TransactionRepo } from '../../repo/transaction';
1
+ import type { PlaceOrderRepo } from '../../repo/transaction/placeOrder';
2
2
  import * as factory from '../../factory';
3
3
  type ITransaction = Pick<factory.transaction.placeOrder.ITransaction, 'id' | 'potentialActions' | 'project' | 'typeOf'>;
4
4
  export declare function findPlaceOrderTransaction(params: {
@@ -8,6 +8,6 @@ export declare function findPlaceOrderTransaction(params: {
8
8
  confirmationNumber: string;
9
9
  orderNumber: string;
10
10
  }): (repos: {
11
- transaction: TransactionRepo;
11
+ placeOrder: PlaceOrderRepo;
12
12
  }) => Promise<ITransaction>;
13
13
  export {};
@@ -27,7 +27,7 @@ exports.findPlaceOrderTransaction = findPlaceOrderTransaction;
27
27
  const factory = __importStar(require("../../factory"));
28
28
  function findPlaceOrderTransaction(params) {
29
29
  return async (repos) => {
30
- const placeOrderTransactions = await repos.transaction.projectFields({
30
+ const placeOrderTransactions = await repos.placeOrder.findPlaceOrderTransactions({
31
31
  limit: 1,
32
32
  page: 1,
33
33
  project: { id: { $eq: params.project.id } },
@@ -3,7 +3,7 @@ import type { AssetTransactionRepo } from '../../repo/assetTransaction';
3
3
  import type { OrderRepo } from '../../repo/order';
4
4
  import type { SettingRepo } from '../../repo/setting';
5
5
  import type { TaskRepo } from '../../repo/task';
6
- import type { TransactionRepo } from '../../repo/transaction';
6
+ import type { PlaceOrderRepo } from '../../repo/transaction/placeOrder';
7
7
  import * as factory from '../../factory';
8
8
  import { Settings } from '../../settings';
9
9
  declare function onAssetTransactionStatusChanged(params: factory.task.IData<factory.taskName.OnAssetTransactionStatusChanged>): (repos: {
@@ -12,7 +12,7 @@ declare function onAssetTransactionStatusChanged(params: factory.task.IData<fact
12
12
  order: OrderRepo;
13
13
  setting: SettingRepo;
14
14
  task: TaskRepo;
15
- transaction: TransactionRepo;
15
+ placeOrder: PlaceOrderRepo;
16
16
  }, settings: Settings) => Promise<void>;
17
17
  declare function paymentDue2Processing(params: {
18
18
  project: {
@@ -26,7 +26,7 @@ declare function paymentDue2Processing(params: {
26
26
  order: OrderRepo;
27
27
  setting: SettingRepo;
28
28
  task: TaskRepo;
29
- transaction: TransactionRepo;
29
+ placeOrder: PlaceOrderRepo;
30
30
  }, settings: Settings) => Promise<void>;
31
31
  declare function processing2inTransit(params: {
32
32
  project: {
@@ -37,6 +37,6 @@ declare function processing2inTransit(params: {
37
37
  }): (repos: {
38
38
  order: OrderRepo;
39
39
  task: TaskRepo;
40
- transaction: TransactionRepo;
40
+ placeOrder: PlaceOrderRepo;
41
41
  }, settings: Settings) => Promise<void>;
42
42
  export { onAssetTransactionStatusChanged, paymentDue2Processing, processing2inTransit };
@@ -193,7 +193,7 @@ function isProcessable(params) {
193
193
  inclusion: ['paymentMethods']
194
194
  });
195
195
  // PayTransactionのステータス検証
196
- let allPayTransactionConfirmed = false;
196
+ let allPayTransactionConfirmed;
197
197
  const paymentMethodIds = order.paymentMethods.filter((invoice) => typeof invoice.paymentMethodId === 'string' && invoice.paymentMethodId.length > 0)
198
198
  .map((invoice) => invoice.paymentMethodId);
199
199
  if (paymentMethodIds.length > 0) {
@@ -217,7 +217,7 @@ function paymentDue2Processing(params) {
217
217
  project: { id: params.project.id },
218
218
  confirmationNumber: params.confirmationNumber,
219
219
  orderNumber: params.orderNumber
220
- })({ transaction: repos.transaction });
220
+ })(repos);
221
221
  // const existingOrder: Pick<factory.order.IOrder, 'project'> = await repos.order.projectFieldsByOrderNumber({
222
222
  // orderNumber: params.orderNumber,
223
223
  // project: { id: params.project.id },
@@ -305,19 +305,13 @@ function cancelOrderIfExist(params) {
305
305
  project: { id: params.project.id },
306
306
  confirmationNumber: orderByPaymentMethodId.confirmationNumber,
307
307
  orderNumber: orderByPaymentMethodId.orderNumber
308
- })({ transaction: repos.transaction });
309
- let order;
310
- try {
311
- order = await repos.order.changeStatus({
312
- project: { id: params.project.id },
313
- orderNumber: orderByPaymentMethodId.orderNumber,
314
- orderStatus: factory.orderStatus.OrderCancelled,
315
- previousOrderStatus: factory.orderStatus.OrderPaymentDue
316
- });
317
- }
318
- catch (error) {
319
- throw error;
320
- }
308
+ })(repos);
309
+ const order = await repos.order.changeStatus({
310
+ project: { id: params.project.id },
311
+ orderNumber: orderByPaymentMethodId.orderNumber,
312
+ orderStatus: factory.orderStatus.OrderCancelled,
313
+ previousOrderStatus: factory.orderStatus.OrderPaymentDue
314
+ });
321
315
  if (params.useOnOrderStatusChanged) {
322
316
  await (0, onOrderStatusChanged_1.onOrderCancelled)({
323
317
  order: {
@@ -440,10 +434,7 @@ function processing2inTransit(params) {
440
434
  ...order,
441
435
  orderStatus: factory.orderStatus.OrderInTransit
442
436
  }
443
- })({
444
- task: repos.task,
445
- transaction: repos.transaction
446
- }, settings);
437
+ })(repos, settings);
447
438
  }
448
439
  };
449
440
  }
@@ -37,7 +37,7 @@ const debug = (0, debug_1.default)('chevre-domain:service:order');
37
37
  function onOrderCancelled(params) {
38
38
  return async (repos) => {
39
39
  debug('onOrderStatusChanged called.', params.order.orderNumber, params.order.orderStatus, params.order.orderDate);
40
- let tasks = [];
40
+ let tasks;
41
41
  switch (params.order.orderStatus) {
42
42
  // OrderCancelled追加(2023-08-30~)
43
43
  case factory.orderStatus.OrderCancelled:
@@ -41,7 +41,7 @@ function onOrderDelivered(params) {
41
41
  ) => {
42
42
  const setting = await repos.setting.findOne({ project: { id: { $eq: '*' } } }, ['onOrderStatusChanged']);
43
43
  debug('onOrderStatusChanged called.', params.order.orderNumber, params.order.orderStatus, params.order.orderDate);
44
- let tasks = [];
44
+ let tasks;
45
45
  // const sendOrderPotentialActions =
46
46
  // params.placeOrderTransaction?.potentialActions?.order?.potentialActions?.sendOrder?.potentialActions;
47
47
  switch (params.order.orderStatus) {
@@ -41,7 +41,7 @@ function onOrderDeliveredPartially(params) {
41
41
  ) => {
42
42
  const setting = await repos.setting.findOne({ project: { id: { $eq: '*' } } }, ['onOrderStatusChanged']);
43
43
  debug('onOrderStatusChanged called.', params.order.orderNumber, params.order.orderStatus, params.order.orderDate);
44
- let tasks = [];
44
+ let tasks;
45
45
  switch (params.order.orderStatus) {
46
46
  case factory.orderStatus.OrderInTransit:
47
47
  tasks = [
@@ -1,5 +1,5 @@
1
1
  import type { TaskRepo } from '../../../repo/task';
2
- import type { TransactionRepo } from '../../../repo/transaction';
2
+ import type { PlaceOrderRepo } from '../../../repo/transaction/placeOrder';
3
3
  import * as factory from '../../../factory';
4
4
  import { Settings } from '../../../settings';
5
5
  declare function onOrderInTransit(params: {
@@ -8,6 +8,6 @@ declare function onOrderInTransit(params: {
8
8
  };
9
9
  }): (repos: {
10
10
  task: TaskRepo;
11
- transaction: TransactionRepo;
11
+ placeOrder: PlaceOrderRepo;
12
12
  }, settings: Settings) => Promise<void>;
13
13
  export { onOrderInTransit };
@@ -103,7 +103,7 @@ function createSendOrderTaskIfNotExist(params) {
103
103
  }
104
104
  function createOnAuthorizationCreatedTask(order) {
105
105
  return async (repos) => {
106
- const placeOrderTransaction = (await repos.transaction.projectFields({
106
+ const placeOrderTransaction = (await repos.placeOrder.findPlaceOrderTransactions({
107
107
  limit: 1,
108
108
  page: 1,
109
109
  typeOf: factory.transactionType.PlaceOrder,
@@ -37,7 +37,7 @@ const debug = (0, debug_1.default)('chevre-domain:service:order');
37
37
  function onOrderPaymentDue(params) {
38
38
  return async (repos) => {
39
39
  debug('onOrderStatusChanged called.', params.order.orderNumber, params.order.orderStatus, params.order.orderDate);
40
- let tasks = [];
40
+ let tasks;
41
41
  // const maskedCustomer = createMaskedCustomer(params.order, { noProfile: true });
42
42
  const simpleOrder = {
43
43
  typeOf: params.order.typeOf,
@@ -43,7 +43,7 @@ function onOrderProcessing(params) {
43
43
  const setting = await repos.setting.findOne({ project: { id: { $eq: '*' } } }, ['onOrderStatusChanged']);
44
44
  const { numTryConfirmReserveTransaction } = settings;
45
45
  debug('onOrderStatusChanged called.', params.order.orderNumber, params.order.orderStatus, params.order.orderDate);
46
- let tasks = [];
46
+ let tasks;
47
47
  let creatingCheckResourceTask;
48
48
  const sendEmailMessageByOnOrderProcessing = params.placeOrderTransaction?.potentialActions?.order?.onOrderProcessing?.sendEmailMessage;
49
49
  switch (params.order.orderStatus) {
@@ -43,7 +43,7 @@ function onOrderReturned(params) {
43
43
  ) => {
44
44
  const setting = await repos.setting.findOne({ project: { id: { $eq: '*' } } }, ['onOrderStatusChanged']);
45
45
  debug('onOrderStatusChanged called.', params.order.orderNumber, params.order.orderStatus, params.order.orderDate);
46
- let tasks = [];
46
+ let tasks;
47
47
  // const maskedCustomer = createMaskedCustomer(params.order, { noProfile: true });
48
48
  const simpleOrder = {
49
49
  typeOf: params.order.typeOf,
@@ -32,8 +32,7 @@ function onOrderUpdated(params) {
32
32
  // settings: Settings
33
33
  ) => {
34
34
  const setting = await repos.setting.findOne({ project: { id: { $eq: '*' } } }, ['onOrderStatusChanged']);
35
- let tasks = [];
36
- tasks = (0, factory_1.createInformTasks)({
35
+ const tasks = (0, factory_1.createInformTasks)({
37
36
  typeOf: factory.order.OrderType.Order,
38
37
  orderNumber: params.orderNumber,
39
38
  project: { id: params.project.id, typeOf: factory.organizationType.Project },
@@ -2,7 +2,7 @@ import type { AcceptedOfferRepo } from '../../repo/acceptedOffer';
2
2
  import type { OrderRepo } from '../../repo/order';
3
3
  import type { SettingRepo } from '../../repo/setting';
4
4
  import type { TaskRepo } from '../../repo/task';
5
- import type { TransactionRepo } from '../../repo/transaction';
5
+ import type { PlaceOrderRepo } from '../../repo/transaction/placeOrder';
6
6
  import * as factory from '../../factory';
7
7
  import { Settings } from '../../settings';
8
8
  /**
@@ -13,6 +13,6 @@ declare function payOrder(params: factory.task.IData<factory.taskName.OnOrderPay
13
13
  order: OrderRepo;
14
14
  setting: SettingRepo;
15
15
  task: TaskRepo;
16
- transaction: TransactionRepo;
16
+ placeOrder: PlaceOrderRepo;
17
17
  }, settings: Settings) => Promise<void>;
18
18
  export { payOrder };
@@ -1,6 +1,6 @@
1
1
  import type { ActionRepo } from '../../../repo/action';
2
2
  import type { IPlacingOrder, OrderInTransactionRepo } from '../../../repo/orderInTransaction';
3
- import type { TransactionRepo } from '../../../repo/transaction';
3
+ import type { PlaceOrderRepo } from '../../../repo/transaction/placeOrder';
4
4
  import * as factory from '../../../factory';
5
5
  type IPlaceOrderTransaction = Pick<factory.transaction.placeOrder.ITransaction, 'id' | 'project' | 'typeOf' | 'result' | 'object' | 'seller'>;
6
6
  declare function createPlacingOrderFromExistingTransaction(params: {
@@ -12,7 +12,7 @@ declare function createPlacingOrderFromExistingTransaction(params: {
12
12
  }): (repos: {
13
13
  action: ActionRepo;
14
14
  orderInTransaction: OrderInTransactionRepo;
15
- transaction: TransactionRepo;
15
+ placeOrder: PlaceOrderRepo;
16
16
  }) => Promise<{
17
17
  order: IPlacingOrder;
18
18
  placeOrderTransaction: IPlaceOrderTransaction;
@@ -30,8 +30,7 @@ function createPlacingOrderFromExistingTransaction(params) {
30
30
  return async (repos) => {
31
31
  const confirmationNumber = String(params.confirmationNumber);
32
32
  const orderNumber = params.orderNumber;
33
- let order;
34
- const placeOrderTransactions = await repos.transaction.projectFields({
33
+ const placeOrderTransactions = await repos.placeOrder.findPlaceOrderTransactions({
35
34
  limit: 1,
36
35
  page: 1,
37
36
  project: { id: { $eq: params.project.id } },
@@ -102,7 +101,7 @@ function createPlacingOrderFromExistingTransaction(params) {
102
101
  throw error;
103
102
  }
104
103
  }
105
- order = (0, factory_1.createPlacingOrder)({ transaction: placeOrderTransactionWithResult, authorizePaymentActions, acceptedOffers });
104
+ const order = (0, factory_1.createPlacingOrder)({ transaction: placeOrderTransactionWithResult, authorizePaymentActions, acceptedOffers });
106
105
  return { order, placeOrderTransaction: placeOrderTransactionWithResult, serialNumbers };
107
106
  };
108
107
  }
@@ -5,7 +5,7 @@ import type { OrderRepo } from '../../repo/order';
5
5
  import type { OrderInTransactionRepo } from '../../repo/orderInTransaction';
6
6
  import type { SettingRepo } from '../../repo/setting';
7
7
  import type { TaskRepo } from '../../repo/task';
8
- import type { TransactionRepo } from '../../repo/transaction';
8
+ import type { PlaceOrderRepo } from '../../repo/transaction/placeOrder';
9
9
  import * as factory from '../../factory';
10
10
  import { Settings } from '../../settings';
11
11
  /**
@@ -29,7 +29,7 @@ declare function placeOrder(params: {
29
29
  orderInTransaction: OrderInTransactionRepo;
30
30
  setting: SettingRepo;
31
31
  task: TaskRepo;
32
- transaction: TransactionRepo;
32
+ placeOrder: PlaceOrderRepo;
33
33
  }, settings: Settings) => Promise<{
34
34
  order: factory.transaction.placeOrder.IOrderAsResult;
35
35
  }>;
@@ -4,7 +4,7 @@ import type { OrderRepo } from '../../repo/order';
4
4
  import type { OwnershipInfoRepo } from '../../repo/ownershipInfo';
5
5
  import type { SettingRepo } from '../../repo/setting';
6
6
  import type { TaskRepo } from '../../repo/task';
7
- import type { TransactionRepo } from '../../repo/transaction';
7
+ import type { ReturnOrderRepo } from '../../repo/transaction/returnOrder';
8
8
  import * as factory from '../../factory';
9
9
  declare function returnOrder(params: {
10
10
  agent: factory.action.transfer.returnAction.order.IAgent;
@@ -23,6 +23,6 @@ declare function returnOrder(params: {
23
23
  ownershipInfo: OwnershipInfoRepo;
24
24
  setting: SettingRepo;
25
25
  task: TaskRepo;
26
- transaction: TransactionRepo;
26
+ returnOrder: ReturnOrderRepo;
27
27
  }) => Promise<void>;
28
28
  export { returnOrder };
@@ -72,7 +72,7 @@ function returnOrder(params) {
72
72
  throw new factory.errors.Argument('object.orderNumber', `orderStatus not returnable: ${order.orderStatus}`);
73
73
  }
74
74
  // 返品取引検索
75
- const returnOrderTransactions = await repos.transaction.projectFields({
75
+ const returnOrderTransactions = await repos.returnOrder.findReturnOrderTransactions({
76
76
  limit: 1,
77
77
  page: 1,
78
78
  project: { id: { $eq: order.project.id } },
@@ -105,7 +105,7 @@ function returnOrder(params) {
105
105
  recipient,
106
106
  typeOf: factory.actionType.ReturnAction
107
107
  };
108
- let returnedOwnershipInfos = [];
108
+ let returnedOwnershipInfos;
109
109
  let returnedOrder;
110
110
  const action = await repos.action.start(returnOrderActionAttributes);
111
111
  try {
@@ -4,7 +4,7 @@ import type { OrderRepo } from '../../repo/order';
4
4
  import type { OwnershipInfoRepo } from '../../repo/ownershipInfo';
5
5
  import type { SettingRepo } from '../../repo/setting';
6
6
  import type { TaskRepo } from '../../repo/task';
7
- import type { TransactionRepo } from '../../repo/transaction';
7
+ import type { PlaceOrderRepo } from '../../repo/transaction/placeOrder';
8
8
  import * as factory from '../../factory';
9
9
  import { Settings } from '../../settings';
10
10
  type ISendOperation<T> = (repos: {
@@ -14,7 +14,7 @@ type ISendOperation<T> = (repos: {
14
14
  ownershipInfo: OwnershipInfoRepo;
15
15
  setting: SettingRepo;
16
16
  task: TaskRepo;
17
- transaction: TransactionRepo;
17
+ placeOrder: PlaceOrderRepo;
18
18
  }, settings: Settings) => Promise<T>;
19
19
  /**
20
20
  * 注文を配送する
@@ -63,7 +63,7 @@ function sendOrder(params) {
63
63
  project: { id: params.project.id },
64
64
  confirmationNumber,
65
65
  orderNumber
66
- })({ transaction: repos.transaction });
66
+ })(repos);
67
67
  // 注文取得
68
68
  let order = await repos.order.projectFieldsByOrderNumber({
69
69
  orderNumber,