@chevre/domain 25.2.0-alpha.34 → 25.2.0-alpha.36

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 (35) hide show
  1. package/lib/chevre/repo/aggregateOffer.d.ts +2 -3
  2. package/lib/chevre/repo/creativeWork.d.ts +2 -3
  3. package/lib/chevre/repo/customerType.d.ts +2 -3
  4. package/lib/chevre/repo/event.d.ts +10 -11
  5. package/lib/chevre/repo/eventOffer.d.ts +4 -5
  6. package/lib/chevre/repo/eventSellerMakesOffer.d.ts +2 -3
  7. package/lib/chevre/repo/eventSeries.d.ts +4 -5
  8. package/lib/chevre/repo/note.d.ts +3 -4
  9. package/lib/chevre/repo/noteAboutOrder.d.ts +2 -3
  10. package/lib/chevre/repo/offerCatalog.d.ts +2 -3
  11. package/lib/chevre/repo/offerCatalogItem.d.ts +2 -3
  12. package/lib/chevre/repo/orderInTransaction.d.ts +16 -1
  13. package/lib/chevre/repo/orderInTransaction.js +6 -3
  14. package/lib/chevre/repo/place/entranceGate.d.ts +4 -5
  15. package/lib/chevre/repo/place/movieTheater.d.ts +3 -4
  16. package/lib/chevre/repo/place/screeningRoom.d.ts +4 -5
  17. package/lib/chevre/repo/place/seat.d.ts +4 -5
  18. package/lib/chevre/repo/place/section.d.ts +3 -4
  19. package/lib/chevre/repo/product.d.ts +3 -4
  20. package/lib/chevre/repo/rateLimit/offer.js +0 -12
  21. package/lib/chevre/repo/reservation.d.ts +2 -3
  22. package/lib/chevre/repo/sellerMakesOffer.d.ts +3 -4
  23. package/lib/chevre/repo/stockHolder.d.ts +1 -1
  24. package/lib/chevre/repo/stockHolder.js +0 -146
  25. package/lib/chevre/repo/transactionNumberCounter.js +0 -34
  26. package/lib/chevre/repo/transactionProcess.js +0 -13
  27. package/lib/chevre/service/order/placeOrder/createPlacingOrderFromExistingTransaction.d.ts +2 -1
  28. package/lib/chevre/service/order/placeOrder/createPlacingOrderFromExistingTransaction.js +13 -58
  29. package/lib/chevre/service/order/placeOrder/factory.js +3 -21
  30. package/lib/chevre/service/order/placeOrder.d.ts +2 -5
  31. package/lib/chevre/service/order/placeOrder.js +20 -31
  32. package/lib/chevre/service/task/placeOrder.js +2 -0
  33. package/lib/chevre/service/transaction/placeOrder/confirm.js +1 -2
  34. package/lib/chevre/service/transaction/placeOrder/start.d.ts +1 -1
  35. package/package.json +6 -8
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.StockHolderRepo = void 0;
4
- // import type { RedisClientType } from 'redis';
5
4
  const factory_1 = require("../factory");
6
5
  const pendingReservation_1 = require("./pendingReservation");
7
6
  const SEARCH_OFFERS_MAX_LENGTH = 100;
@@ -9,36 +8,11 @@ const SEARCH_OFFERS_MAX_LENGTH = 100;
9
8
  * 保留予約リポジトリ
10
9
  */
11
10
  class StockHolderRepo {
12
- // public static KEY_PREFIX_NEW: string = 'stockHolder';
13
- // private readonly redisClient: RedisClientType | undefined;
14
11
  pendingReservationRepo;
15
12
  constructor(params) {
16
13
  const { connection } = params;
17
- // this.redisClient = redisClient;
18
14
  this.pendingReservationRepo = new pendingReservation_1.PendingReservationRepo(connection);
19
15
  }
20
- // private static offer2field(params: IOffer, hasTicketedSeat: boolean) {
21
- // if (hasTicketedSeat) {
22
- // return `${params.seatSection}:${params.seatNumber}`;
23
- // } else {
24
- // // 予約IDをfieldにする場合
25
- // const serviceOutputId = params.itemOffered?.serviceOutput?.id;
26
- // if (typeof serviceOutputId === 'string') {
27
- // return serviceOutputId;
28
- // } else {
29
- // throw new factory.errors.Internal('offer2field requires itemOffered.serviceOutput.id');
30
- // }
31
- // }
32
- // }
33
- // private static createKey(params: {
34
- // eventId: string;
35
- // startDate: Date;
36
- // }): string {
37
- // if (!(params.startDate instanceof Date)) {
38
- // throw new factory.errors.Argument('startDate', 'must be Date');
39
- // }
40
- // return `${StockHolderRepo.KEY_PREFIX_NEW}:${params.eventId}`;
41
- // }
42
16
  /**
43
17
  * 座席をロックする(maxキャパシティチェック有)
44
18
  */
@@ -54,16 +28,6 @@ class StockHolderRepo {
54
28
  }
55
29
  else {
56
30
  throw new factory_1.factory.errors.NotImplemented('useRedis discontinued.');
57
- // if (this.redisClient === undefined) {
58
- // throw new factory.errors.Internal('redisClient required');
59
- // }
60
- // const key = StockHolderRepo.createKey({ eventId: lockKey.eventId, startDate: lockKey.startDate });
61
- // await this.redisClient.watch(key);
62
- // const hashCount = await this.redisClient.hLen(key);
63
- // if (hashCount + lockKey.offers.length > maximum) {
64
- // throw new factory.errors.Argument('Event', 'maximumAttendeeCapacity exceeded');
65
- // }
66
- // await this.lock(lockKey);
67
31
  }
68
32
  }
69
33
  /**
@@ -79,59 +43,11 @@ class StockHolderRepo {
79
43
  startDate: lockKey.startDate,
80
44
  hasTicketedSeat: lockKey.hasTicketedSeat
81
45
  });
82
- // const key = StockHolderRepo.createKey({ eventId: lockKey.eventId, startDate: lockKey.startDate });
83
- // await this.checkIfConflicted({ key, eventId: lockKey.eventId, useMongoose });
84
46
  if (useMongoose) {
85
47
  return this.pendingReservationRepo.lock(lockKey);
86
48
  }
87
49
  else {
88
50
  throw new factory_1.factory.errors.NotImplemented('useRedis discontinued.');
89
- // if (this.redisClient === undefined) {
90
- // throw new factory.errors.Internal('redisClient required');
91
- // }
92
- // const value = lockKey.holder;
93
- // const multi = this.redisClient.multi();
94
- // const fields = lockKey.offers.map((offer) => StockHolderRepo.offer2field(offer, lockKey.hasTicketedSeat));
95
- // // check uniqueness(2025-04-20~)
96
- // const uniqueFields = [...new Set(fields)];
97
- // if (uniqueFields.length !== fields.length) {
98
- // throw new factory.errors.Argument('offers', 'offers must be unique');
99
- // }
100
- // fields.forEach((field) => {
101
- // multi.hSetNX(key, field, value);
102
- // });
103
- // const results = await multi.expireAt(
104
- // key,
105
- // moment(lockKey.expires)
106
- // .unix()
107
- // )
108
- // .exec();
109
- // const lockedFields: string[] = [];
110
- // if (Array.isArray(results)) {
111
- // results.slice(0, fields.length)
112
- // .forEach((r, index) => {
113
- // if (r === 1 || (<any>r) === true) {
114
- // lockedFields.push(fields[index]);
115
- // }
116
- // });
117
- // }
118
- // const lockedAll = lockedFields.length === fields.length;
119
- // // expireAtReplyの検証も追加する(2023-04-19~)
120
- // const expiredAll = results.slice(fields.length)
121
- // .every((r) => (r === 1 || (<any>r) === true));
122
- // if (!lockedAll || !expiredAll) {
123
- // if (lockedFields.length > 0) {
124
- // // 全て仮押さえできなければ仮押さえできたものは解除
125
- // await this.redisClient.multi()
126
- // .hDel(key, lockedFields)
127
- // .exec();
128
- // }
129
- // if (!lockedAll) {
130
- // throw new factory.errors.AlreadyInUse(factory.reservationType.EventReservation, ['ticketedSeat'], 'Already hold');
131
- // } else {
132
- // throw new factory.errors.Internal('timeout cannot be set unexpectedly');
133
- // }
134
- // }
135
51
  }
136
52
  }
137
53
  /**
@@ -144,20 +60,11 @@ class StockHolderRepo {
144
60
  startDate: params.startDate,
145
61
  hasTicketedSeat: params.hasTicketedSeat
146
62
  });
147
- // const key = StockHolderRepo.createKey({ eventId: params.eventId, startDate: params.startDate });
148
- // await this.checkIfConflicted({ key, eventId: params.eventId, useMongoose });
149
63
  if (useMongoose) {
150
64
  return this.pendingReservationRepo.unlock(params);
151
65
  }
152
66
  else {
153
67
  throw new factory_1.factory.errors.NotImplemented('useRedis discontinued.');
154
- // if (this.redisClient === undefined) {
155
- // throw new factory.errors.Internal('redisClient required');
156
- // }
157
- // const field = StockHolderRepo.offer2field(params.offer, params.hasTicketedSeat);
158
- // await this.redisClient.multi()
159
- // .hDel(key, field)
160
- // .exec();
161
68
  }
162
69
  }
163
70
  /**
@@ -174,16 +81,6 @@ class StockHolderRepo {
174
81
  }
175
82
  else {
176
83
  throw new factory_1.factory.errors.NotImplemented('useRedis discontinued.');
177
- // if (this.redisClient === undefined) {
178
- // throw new factory.errors.Internal('redisClient required');
179
- // }
180
- // const key = StockHolderRepo.createKey({ eventId: params.event.id, startDate: params.event.startDate });
181
- // const reply = await this.redisClient.hLen(key);
182
- // let fieldCount: number = 0;
183
- // if (typeof reply === 'number') {
184
- // fieldCount = Number(reply);
185
- // }
186
- // return fieldCount;
187
84
  }
188
85
  }
189
86
  /**
@@ -200,12 +97,6 @@ class StockHolderRepo {
200
97
  }
201
98
  else {
202
99
  throw new factory_1.factory.errors.NotImplemented('useRedis discontinued.');
203
- // if (this.redisClient === undefined) {
204
- // throw new factory.errors.Internal('redisClient required');
205
- // }
206
- // const key = StockHolderRepo.createKey({ eventId: params.eventId, startDate: params.startDate });
207
- // const field = StockHolderRepo.offer2field(params.offer, params.hasTicketedSeat);
208
- // return this.redisClient.hGet(key, field);
209
100
  }
210
101
  }
211
102
  async searchHolders(params) {
@@ -223,32 +114,8 @@ class StockHolderRepo {
223
114
  }
224
115
  else {
225
116
  throw new factory_1.factory.errors.NotImplemented('useRedis discontinued.');
226
- // if (this.redisClient === undefined) {
227
- // throw new factory.errors.Internal('redisClient required');
228
- // }
229
- // const key = StockHolderRepo.createKey({ eventId: params.eventId, startDate: params.startDate });
230
- // const fields = params.offers.map((o) => {
231
- // return StockHolderRepo.offer2field(o, params.hasTicketedSeat);
232
- // });
233
- // // Array reply: list of values associated with the given fields, in the same order as they are requested.
234
- // const result = await this.redisClient.hmGet(key, fields);
235
- // if (!Array.isArray(result)) {
236
- // throw new factory.errors.Internal(`searchAvailability got non-array: ${typeof result}`);
237
- // }
238
- // // そのまま返却(2023-04-17~)
239
- // return result;
240
117
  }
241
118
  }
242
- // public async checkIfConflicted(params: {
243
- // eventId: string;
244
- // startDate: Date;
245
- // }): Promise<void> {
246
- // const redisKeyExists = await this.redisKeyExists(params);
247
- // const mongoDocExists = await this.pendingReservationRepo.docExists(params);
248
- // if (redisKeyExists && mongoDocExists) {
249
- // throw new factory.errors.Internal(`repository conflicted. eventId:${params.eventId}`);
250
- // }
251
- // }
252
119
  /**
253
120
  * 新リポジトリを使用するかどうか
254
121
  */
@@ -258,19 +125,6 @@ class StockHolderRepo {
258
125
  }
259
126
  // always use mongo(2025-08-17~)
260
127
  return true;
261
- // let useMongoose = false;
262
- // const redisKeyExists = await this.redisKeyExists(params);
263
- // if (redisKeyExists) {
264
- // useMongoose = false;
265
- // } else {
266
- // // redis keyが存在しなければmongo利用
267
- // useMongoose = true;
268
- // }
269
- // // check confliction for test
270
- // if (USE_STOCK_HOLDER_CHECK_CONFLICT) {
271
- // await this.checkIfConflicted(params);
272
- // }
273
- // return useMongoose;
274
128
  }
275
129
  }
276
130
  exports.StockHolderRepo = StockHolderRepo;
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TransactionNumberCounterRepo = void 0;
4
- // import { RedisClientType } from 'redis';
5
4
  const errorHandler_1 = require("../errorHandler");
6
5
  const factory_1 = require("../factory");
7
6
  const transactionNumber_1 = require("./mongoose/schemas/transactionNumber");
@@ -10,44 +9,11 @@ const MAX_RETRY_INCREMENT = 1;
10
9
  * 取引番号カウンターリポジトリ
11
10
  */
12
11
  class TransactionNumberCounterRepo {
13
- // private readonly redisClient: RedisClientType;
14
12
  transactionNumberModel;
15
13
  constructor(params) {
16
14
  const { connection } = params;
17
- // this.redisClient = redisClient;
18
15
  this.transactionNumberModel = connection.model(transactionNumber_1.modelName, (0, transactionNumber_1.createSchema)());
19
16
  }
20
- // public async incrementByRedis(params: {
21
- // identifier: string;
22
- // includedInDataCatalog: {
23
- // identifier: DataCatalogIdentifier;
24
- // };
25
- // expires: Date;
26
- // }): Promise<number> {
27
- // // const now = moment();
28
- // const { expires } = params;
29
- // const key = `${params.includedInDataCatalog.identifier}:${params.identifier}`;
30
- // // const TTL = moment(expires)
31
- // // .diff(now, 'seconds');
32
- // const [incrReply, expireAtReply] = await this.redisClient.multi()
33
- // .incr(key)
34
- // // .expire(key, TTL)
35
- // .expireAt(key, expires)
36
- // .exec();
37
- // // tslint:disable-next-line:no-single-line-block-comment
38
- // /* istanbul ignore else: please write tests */
39
- // if (typeof incrReply !== 'number') {
40
- // // 基本的にありえないフロー
41
- // throw new factory.errors.Internal('transaction number not incremented unexpectedly');
42
- // }
43
- // // expireAtReplyの検証も追加する(2023-04-19~)
44
- // const expiredSet = expireAtReply === 1 || <any>expireAtReply === true;
45
- // if (!expiredSet) {
46
- // // 基本的にありえないフロー
47
- // throw new factory.errors.Internal('transaction number expiration not set unexpectedly');
48
- // }
49
- // return incrReply;
50
- // }
51
17
  async incrementByMongo(params) {
52
18
  const now = new Date();
53
19
  const dataFeedExpires = params.expires;
@@ -16,10 +16,8 @@ const DEFAULT_LOCK_EXPIRES = 120;
16
16
  class TransactionProcessRepo {
17
17
  concurrentLockRepo;
18
18
  options;
19
- // private readonly redisClient: RedisClientType;
20
19
  constructor(redisClient, options) {
21
20
  this.concurrentLockRepo = new concurrentLock_1.ConcurrentLockRepo({ redisClient });
22
- // this.redisClient = redisClient;
23
21
  this.options = options;
24
22
  }
25
23
  static CREATE_REDIS_KEY(params) {
@@ -44,16 +42,6 @@ class TransactionProcessRepo {
44
42
  catch (_error) {
45
43
  throw new factory_1.factory.errors.AlreadyInUse(params.typeOf, [], 'Another transaction process in progress');
46
44
  }
47
- // const results = await this.redisClient.multi()
48
- // .setNX(key, '1')
49
- // .expire(key, ttl)
50
- // .exec();
51
- // debug('locked,', params.id, results);
52
- // if (Array.isArray(results) && (results[0] === 1 || (<any>results)[0] === true)) {
53
- // return;
54
- // } else {
55
- // throw new factory.errors.AlreadyInUse(params.typeOf, [], 'Another transaction process in progress');
56
- // }
57
45
  }
58
46
  async unlock(params) {
59
47
  const key = TransactionProcessRepo.CREATE_REDIS_KEY(params);
@@ -62,7 +50,6 @@ class TransactionProcessRepo {
62
50
  about: { identifier: key, typeOf: 'Thing' },
63
51
  audience: { identifier: '1', typeOf: 'Audience' }
64
52
  });
65
- // await this.redisClient.del([key]);
66
53
  }
67
54
  }
68
55
  exports.TransactionProcessRepo = TransactionProcessRepo;
@@ -5,7 +5,6 @@ import type { PlaceOrderRepo } from '../../../repo/transaction/placeOrder';
5
5
  import { factory } from '../../../factory';
6
6
  type IPlaceOrderTransaction = Pick<factory.transaction.placeOrder.ITransaction, 'id' | 'project' | 'typeOf' | 'result' | 'object' | 'seller'>;
7
7
  interface ICreatePlacingOrderFromExistingTransactionRepos {
8
- action?: never;
9
8
  authorizeOfferAction: AuthorizeOfferActionRepo;
10
9
  authorizePaymentMethodAction: AuthorizePaymentMethodActionRepo;
11
10
  orderInTransaction: OrderInTransactionRepo;
@@ -18,6 +17,8 @@ declare function createPlacingOrderFromExistingTransaction(params: {
18
17
  confirmationNumber: string;
19
18
  orderNumber: string;
20
19
  }): (repos: ICreatePlacingOrderFromExistingTransactionRepos) => Promise<{
20
+ orderNumber: string;
21
+ confirmationNumber: string;
21
22
  order: IPlacingOrder;
22
23
  placeOrderTransaction: IPlaceOrderTransaction;
23
24
  serialNumbers: string[];
@@ -17,12 +17,6 @@ function createPlacingOrderFromExistingTransaction(params) {
17
17
  object: {
18
18
  orderNumber: { $eq: orderNumber },
19
19
  },
20
- // result: {
21
- // order: {
22
- // confirmationNumber: { $eq: confirmationNumber },
23
- // orderNumbers: [orderNumber]
24
- // }
25
- // },
26
20
  inclusion: ['project', 'typeOf', 'result', 'object', 'seller']
27
21
  });
28
22
  const placeOrderTransactionWithResult = placeOrderTransactions.shift();
@@ -39,43 +33,12 @@ function createPlacingOrderFromExistingTransaction(params) {
39
33
  const authorizeActionsAsResult = placeOrderTransactionWithResult.result?.authorizeActions;
40
34
  if (Array.isArray(authorizeActionsAsResult) && authorizeActionsAsResult.length > 0) {
41
35
  const completedAuthorizeActionIds = authorizeActionsAsResult.map(({ id }) => id);
36
+ /* istanbul ignore else -- @preserve */
42
37
  if (completedAuthorizeActionIds.length > 0) {
43
- // authorizePaymentActions = <Pick<factory.action.authorize.paymentMethod.any.IAction, 'result'>[]>
44
- // await repos.action.search<factory.actionType.AuthorizeAction>(
45
- // {
46
- // typeOf: factory.actionType.AuthorizeAction,
47
- // purpose: {
48
- // typeOf: { $in: [factory.transactionType.PlaceOrder] },
49
- // id: { $in: [placeOrderTransactionWithResult.id] }
50
- // },
51
- // object: { typeOf: { $eq: factory.action.authorize.paymentMethod.any.ResultType.Payment } },
52
- // id: { $in: completedAuthorizeActionIds }
53
- // },
54
- // ['result']
55
- // );
56
38
  authorizePaymentActions = await repos.authorizePaymentMethodAction.findAuthorizePaymentMethodResultsById({
57
39
  purpose: { id: placeOrderTransactionWithResult.id },
58
40
  ids: completedAuthorizeActionIds
59
41
  });
60
- // authorizeOfferActionsWithInstrument = <IAuthorizeActionWithInstrument[]>await repos.action.search<factory.actionType.AuthorizeAction>(
61
- // {
62
- // typeOf: factory.actionType.AuthorizeAction,
63
- // purpose: {
64
- // typeOf: { $in: [factory.transactionType.PlaceOrder] },
65
- // id: { $in: [placeOrderTransactionWithResult.id] }
66
- // },
67
- // object: {
68
- // typeOf: {
69
- // $in: [
70
- // factory.action.authorize.offer.eventService.ObjectType.SeatReservation,
71
- // factory.offerType.Offer
72
- // ]
73
- // }
74
- // },
75
- // id: { $in: completedAuthorizeActionIds }
76
- // },
77
- // ['instrument']
78
- // );
79
42
  authorizeOfferActionsWithInstrument = await repos.authorizeOfferAction.findAuthorizeOfferInstrumentsByIds({
80
43
  purpose: { id: placeOrderTransactionWithResult.id },
81
44
  ids: completedAuthorizeActionIds
@@ -87,26 +50,18 @@ function createPlacingOrderFromExistingTransaction(params) {
87
50
  const serialNumbers = authorizeOfferActionsWithInstrument
88
51
  .filter(({ instrument }) => typeof instrument.transactionNumber === 'string')
89
52
  .map(({ instrument }) => String(instrument.transactionNumber));
90
- try {
91
- // すでにtypeOf: Orderに変更済の場合acceptedOffersは空になるが、そもそもorderedItemはその後上書きされないので、空のまま処理して問題なし
92
- acceptedOffers = (await repos.orderInTransaction.findAcceptedOffersWithPriceByIdentifier({
93
- // orderNumber,
94
- identifier: placeOrderTransactionWithResult.id,
95
- project: { id: params.project.id }
96
- }))
97
- .filter(({ serialNumber }) => typeof serialNumber === 'string' && serialNumbers.includes(serialNumber));
98
- }
99
- catch (error) {
100
- let throwsError = true;
101
- // すでにtypeOf: Orderに変更済の場合、NotFoundとなる
102
- if (error instanceof factory_1.factory.errors.NotFound) {
103
- throwsError = false;
104
- }
105
- if (throwsError) {
106
- throw error;
107
- }
108
- }
53
+ // すでにtypeOf: Orderに変更済の場合acceptedOffersは空になるが、そもそもorderedItemはその後上書きされないので、空のまま処理して問題なし
54
+ acceptedOffers = (await repos.orderInTransaction.findAcceptedOffersWithPriceByIdentifier({
55
+ identifier: placeOrderTransactionWithResult.id,
56
+ project: { id: params.project.id }
57
+ }, { onlyPlaceOrder: false } // typeOf:PlaceOrderフィルターを無効化したのでもうNotFoundになる心配はなし(2026-07-20~)
58
+ ))
59
+ .filter(({ serialNumber }) => typeof serialNumber === 'string' && serialNumbers.includes(serialNumber));
109
60
  const order = (0, factory_2.createPlacingOrder)({ transaction: placeOrderTransactionWithResult, authorizePaymentActions, acceptedOffers });
110
- return { order, placeOrderTransaction: placeOrderTransactionWithResult, serialNumbers };
61
+ return {
62
+ orderNumber,
63
+ confirmationNumber,
64
+ order, placeOrderTransaction: placeOrderTransactionWithResult, serialNumbers
65
+ };
111
66
  };
112
67
  }
@@ -68,7 +68,6 @@ function createSeller(params) {
68
68
  }
69
69
  function createPlacingOrder(params) {
70
70
  const { transaction, authorizePaymentActions } = params;
71
- let orderDateByTransaction;
72
71
  const { confirmationNumber, orderDate, orderNumber } = transaction.object;
73
72
  if (typeof confirmationNumber !== 'string') {
74
73
  // 事前に発行済なはずなので、ありえないフロー
@@ -79,25 +78,8 @@ function createPlacingOrder(params) {
79
78
  throw new factory_1.factory.errors.Internal('object.orderNumber undefined');
80
79
  }
81
80
  if (orderDate === undefined) {
82
- // orderDateByTransaction = transaction.result?.order?.orderDate
83
- }
84
- else {
85
- orderDateByTransaction = orderDate;
86
- }
87
- if (orderDateByTransaction === undefined) {
88
81
  throw new factory_1.factory.errors.NotFound('orderDate in the transaction');
89
82
  }
90
- // const orderByTransaction = transaction.result?.order;
91
- // if (orderByTransaction === undefined) {
92
- // throw new factory.errors.NotFound('transaction.result.order');
93
- // }
94
- // const seller = createSeller({ transaction });
95
- // discontinue(2026-06-11~)
96
- // const name: string | undefined =
97
- // (typeof transaction.object.name === 'string') ? transaction.object.name : undefined;
98
- // discontinue(2026-06-22~)
99
- // const broker: factory.order.IBroker | undefined =
100
- // (typeof transaction.object.broker?.typeOf === 'string') ? transaction.object.broker : undefined;
101
83
  const { paymentMethods, price } = createPaymentMethods({ authorizePaymentActions });
102
84
  const eventReservationAcceptedOffers = [];
103
85
  params.acceptedOffers.forEach((acceptedOffer) => {
@@ -115,15 +97,15 @@ function createPlacingOrder(params) {
115
97
  });
116
98
  return {
117
99
  // ...orderByTransaction, // transaction.result.orderへの依存廃止(2026-06-15~)
118
- confirmationNumber,
119
- orderNumber,
100
+ // confirmationNumber, // placeOrder時に上書きする必要なし(2026-07-20~)
101
+ // orderNumber, // placeOrder時に上書きする必要なし(2026-07-20~)
120
102
  typeOf: factory_1.factory.order.OrderType.Order, // 取引保管を廃止するためにここで指定(2026-06-14~)
121
103
  orderStatus: factory_1.factory.orderStatus.OrderPaymentDue, // 取引保管を廃止するためにここで指定(2026-06-14~)
122
104
  // seller, // 取引開始時の注文ドキュメント作成へ移行(2026-06-25~)
123
105
  paymentMethods, // 2024-06-17~
124
106
  price, // 2024-06-17~
125
107
  priceCurrency: factory_1.factory.priceCurrency.JPY, // 取引保管を廃止するためにここで指定(2026-06-14~)
126
- orderDate: (0, moment_1.default)(orderDateByTransaction)
108
+ orderDate: (0, moment_1.default)(orderDate)
127
109
  .toDate(),
128
110
  orderedItem, // 2024-06-18~
129
111
  // ...(typeof name === 'string') ? { name } : undefined, // discontinue(2026-06-11~)
@@ -11,7 +11,6 @@ import type { TaskRepo } from '../../repo/task';
11
11
  import type { PlaceOrderRepo } from '../../repo/transaction/placeOrder';
12
12
  import { factory } from '../../factory';
13
13
  import type { IntegrationSettingRepo as Settings } from '../../repo/setting/integration';
14
- import { IPlacingOrder } from './placeOrder/createPlacingOrderFromExistingTransaction';
15
14
  interface IPlaceOrderRepos {
16
15
  acceptedOffer: AcceptedOfferRepo;
17
16
  accountingReport: AccountingReportRepo;
@@ -29,7 +28,7 @@ interface IPlaceOrderRepos {
29
28
  * 注文を作成する
30
29
  */
31
30
  declare function placeOrder(params: {
32
- agent?: factory.action.trade.order.IAgent;
31
+ agent: factory.action.trade.order.IAgent;
33
32
  project: {
34
33
  id: string;
35
34
  };
@@ -38,7 +37,5 @@ declare function placeOrder(params: {
38
37
  orderNumber: string;
39
38
  };
40
39
  useOnOrderStatusChanged: boolean;
41
- }): (repos: IPlaceOrderRepos, settings: Settings) => Promise<{
42
- order: IPlacingOrder;
43
- }>;
40
+ }): (repos: IPlaceOrderRepos, settings: Settings) => Promise<void>;
44
41
  export { IPlaceOrderRepos, placeOrder };
@@ -11,11 +11,8 @@ const voidAcceptedOfferIfNecessary_1 = require("./placeOrder/voidAcceptedOfferIf
11
11
  */
12
12
  function placeOrder(params) {
13
13
  return async (repos, settings) => {
14
- if (typeof params.useOnOrderStatusChanged !== 'boolean') {
15
- throw new factory_1.factory.errors.Argument('useOnOrderStatusChanged', 'must be boolean');
16
- }
17
14
  // 注文番号から取引と注文をfixする
18
- const { order, placeOrderTransaction, serialNumbers } = await (0, createPlacingOrderFromExistingTransaction_1.createPlacingOrderFromExistingTransaction)({
15
+ const { orderNumber, confirmationNumber, order, placeOrderTransaction, serialNumbers } = await (0, createPlacingOrderFromExistingTransaction_1.createPlacingOrderFromExistingTransaction)({
19
16
  project: { id: params.project.id },
20
17
  confirmationNumber: params.object.confirmationNumber,
21
18
  orderNumber: params.object.orderNumber
@@ -31,14 +28,14 @@ function placeOrder(params) {
31
28
  }
32
29
  const simpleOrder = {
33
30
  typeOf: order.typeOf,
34
- orderNumber: order.orderNumber,
31
+ orderNumber,
35
32
  orderDate: order.orderDate
36
33
  };
37
34
  const orderActionPurpose = {
38
35
  typeOf: placeOrderTransaction.typeOf, id: placeOrderTransaction.id
39
36
  };
40
37
  const orderActionAttributes = {
41
- agent: (typeof params.agent?.typeOf === 'string') ? params.agent : placeOrderTransaction.project,
38
+ agent: params.agent,
42
39
  object: simpleOrder,
43
40
  project: placeOrderTransaction.project,
44
41
  purpose: orderActionPurpose,
@@ -61,7 +58,6 @@ function placeOrder(params) {
61
58
  try {
62
59
  // 冗長なオファーを除外する(念のため)
63
60
  await (0, voidAcceptedOfferIfNecessary_1.voidAcceptedOfferIfNecessary)({
64
- // object: { orderNumber: order.orderNumber },
65
61
  placeOrderId: placeOrderTransaction.id,
66
62
  serialNumbers
67
63
  })(repos);
@@ -81,38 +77,31 @@ function placeOrder(params) {
81
77
  if (params.useOnOrderStatusChanged) {
82
78
  // 経理レポートを保管->CreateAccountingReportへ移行(2024-02-02~)
83
79
  // PaymentDueであればonOrderStatusChangedを実行(2023-08-23~)
84
- if (order.orderStatus === factory_1.factory.orderStatus.OrderPaymentDue) {
85
- await (0, onOrderStatusChanged_1.onOrderPaymentDue)({
86
- order: {
87
- paymentMethods: order.paymentMethods,
88
- project: placeOrderTransaction.project,
89
- orderNumber: order.orderNumber,
90
- confirmationNumber: order.confirmationNumber,
91
- orderDate: order.orderDate,
92
- // seller: order.seller,
93
- typeOf: order.typeOf,
94
- // price: order.price,
95
- // priceCurrency: order.priceCurrency,
96
- orderStatus: order.orderStatus
97
- }
98
- })({
99
- task: repos.task
100
- });
101
- }
102
- else {
103
- throw new factory_1.factory.errors.NotImplemented(`placing an order on the status '${order.orderStatus}' not implemented`);
104
- }
80
+ await (0, onOrderStatusChanged_1.onOrderPaymentDue)({
81
+ order: {
82
+ paymentMethods: order.paymentMethods,
83
+ project: placeOrderTransaction.project,
84
+ orderNumber,
85
+ confirmationNumber,
86
+ orderDate: order.orderDate,
87
+ typeOf: order.typeOf,
88
+ orderStatus: order.orderStatus
89
+ }
90
+ })({
91
+ task: repos.task
92
+ });
105
93
  // paymentMethods.length: 0の場合を考慮(2023-08-24~)
94
+ /* istanbul ignore else -- @preserve */
106
95
  if (order.paymentMethods.length === 0) {
107
96
  // paymentMethods.length: 0の場合に、confirmPayTransactionは実行されないので、ここで強制的にpaymentDue2Processingを実行する必要がある
108
97
  await (0, onAssetTransactionStatusChanged_1.paymentDue2Processing)({
109
98
  project: { id: placeOrderTransaction.project.id },
110
- confirmationNumber: order.confirmationNumber,
111
- orderNumber: order.orderNumber,
99
+ confirmationNumber,
100
+ orderNumber,
112
101
  useOnOrderStatusChanged: params.useOnOrderStatusChanged === true
113
102
  })(repos, settings);
114
103
  }
115
104
  }
116
- return { order };
105
+ // return { order };
117
106
  };
118
107
  }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.call = call;
4
+ const factory_1 = require("../../factory");
4
5
  const acceptedOffer_1 = require("../../repo/acceptedOffer");
5
6
  const accountingReport_1 = require("../../repo/accountingReport");
6
7
  const action_1 = require("../../repo/action");
@@ -22,6 +23,7 @@ function call(data) {
22
23
  const settings = new integration_1.IntegrationSettingRepo({ connection });
23
24
  await (0, placeOrder_2.placeOrder)({
24
25
  ...data,
26
+ agent: { id: data.project.id, typeOf: factory_1.factory.organizationType.Project },
25
27
  useOnOrderStatusChanged: true
26
28
  })({
27
29
  acceptedOffer: new acceptedOffer_1.AcceptedOfferRepo(connection),
@@ -112,10 +112,9 @@ function confirm(params, options) {
112
112
  serialNumbers } = dissolveAuthorizeActions(completedAuthorizeActions);
113
113
  // orderInTransactionから検索する(2024-03-04~)
114
114
  const acceptedOffers = (await repos.orderInTransaction.findAcceptedOffersWithPriceByIdentifier({
115
- // orderNumber,
116
115
  identifier: transaction.id,
117
116
  project: { id: transaction.project.id }
118
- }))
117
+ }, { onlyPlaceOrder: true }))
119
118
  .filter(({ serialNumber }) => typeof serialNumber === 'string' && serialNumbers.includes(serialNumber));
120
119
  // 単価オファーの全適用条件を検証するために、単価オファーを参照(2026-07-06~)
121
120
  const unitPriceOfferConditions = await (0, prepareUnitPriceOfferConditions_1.prepareUnitPriceOfferConditions)({
@@ -9,7 +9,7 @@ import type { ProjectMakesOfferRepo } from '../../../repo/projectMakesOffer';
9
9
  import type { SellerRepo } from '../../../repo/seller';
10
10
  import type { IStartedPlaceOrder, PlaceOrderRepo } from '../../../repo/transaction/placeOrder';
11
11
  import { IStartPlaceOrderParams } from './start/factory';
12
- interface IStartOperationRepos {
12
+ export interface IStartOperationRepos {
13
13
  issuer: IssuerRepo;
14
14
  member: MemberRepo;
15
15
  memberProgram: MemberProgramRepo;