@chevre/domain 25.0.0-alpha.14 → 25.0.0-alpha.15

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.
@@ -69,6 +69,16 @@ export declare class OrderInTransactionRepo extends AcceptedOfferInReserveRepo {
69
69
  id: string;
70
70
  };
71
71
  }): Promise<string>;
72
+ /**
73
+ * 注文取引からcustomerを参照する
74
+ * 存在しなければNotFoundError
75
+ */
76
+ findCustomerByIdentifier(params: {
77
+ identifier: string;
78
+ project: {
79
+ id: string;
80
+ };
81
+ }): Promise<Pick<IOrderInTransaction, 'customer'>>;
72
82
  /**
73
83
  * 取引進行中の注文からacceptedOffersを検索する
74
84
  * 予約取引から予約ごとの価格仕様も参照する
@@ -61,12 +61,32 @@ class OrderInTransactionRepo extends acceptedOfferInReserve_1.AcceptedOfferInRes
61
61
  })
62
62
  .lean()
63
63
  .exec();
64
- console.log('findOrderNumberByIdentifier:', JSON.stringify(doc));
65
64
  if (doc === null) {
66
65
  throw new factory_1.factory.errors.NotFound('orderInTransaction');
67
66
  }
68
67
  return doc.orderNumber;
69
68
  }
69
+ /**
70
+ * 注文取引からcustomerを参照する
71
+ * 存在しなければNotFoundError
72
+ */
73
+ async findCustomerByIdentifier(params) {
74
+ const { project, identifier } = params;
75
+ const doc = await this.orderModel.findOne({
76
+ identifier: { $eq: identifier },
77
+ typeOf: { $eq: factory_1.factory.transactionType.PlaceOrder },
78
+ 'project.id': { $eq: project.id }
79
+ }, {
80
+ _id: 0,
81
+ customer: 1
82
+ })
83
+ .lean()
84
+ .exec();
85
+ if (doc === null) {
86
+ throw new factory_1.factory.errors.NotFound('orderInTransaction');
87
+ }
88
+ return doc;
89
+ }
70
90
  /**
71
91
  * 取引進行中の注文からacceptedOffersを検索する
72
92
  * 予約取引から予約ごとの価格仕様も参照する
@@ -4,7 +4,6 @@ exports.updateAgent = updateAgent;
4
4
  const google_libphonenumber_1 = require("google-libphonenumber");
5
5
  const factory_1 = require("../../../factory");
6
6
  const issueOrderNumberIfNotExist_1 = require("./issueOrderNumberIfNotExist");
7
- // export type ITransactionOperation<T> = (repos: { transaction: TransactionRepo }) => Promise<T>;
8
7
  function fixCustomer(params) {
9
8
  return async (repos) => {
10
9
  let formattedTelephone;
@@ -20,7 +19,7 @@ function fixCustomer(params) {
20
19
  throw new factory_1.factory.errors.Argument('telephone', (error instanceof Error) ? error.message : String(error));
21
20
  }
22
21
  const transaction = await repos.placeOrder.findPlaceOrderInProgressById({
23
- typeOf: params.typeOf,
22
+ typeOf: factory_1.factory.transactionType.PlaceOrder,
24
23
  id: params.id
25
24
  }, ['agent', 'object', 'typeOf', 'project']);
26
25
  if (transaction.agent.id !== params.agent.id) {
@@ -29,20 +28,20 @@ function fixCustomer(params) {
29
28
  // 注文取引の場合、object.customerにも適用
30
29
  let customer;
31
30
  if (transaction.typeOf === factory_1.factory.transactionType.PlaceOrder) {
32
- // いったんtransaction.object.customer?.typeOfは取引開始時にセットされている前提
33
- const trasactionObject = transaction.object;
34
- if (typeof trasactionObject.customer?.typeOf === 'string') {
31
+ // orderInTransaction.customer?.typeOfは取引開始時にセットされている前提で再実装(2026-06-24~)
32
+ const { customer: customerByTransaction } = await repos.orderInTransaction.findCustomerByIdentifier({
33
+ identifier: params.id,
34
+ project: { id: transaction.project.id }
35
+ });
36
+ // // いったんtransaction.object.customer?.typeOfは取引開始時にセットされている前提
37
+ // const customerByTransaction = transaction.object.customer;
38
+ if (typeof customerByTransaction?.typeOf === 'string') {
35
39
  customer = {
36
- typeOf: trasactionObject.customer.typeOf,
37
- id: trasactionObject.customer.id,
38
- ...(Array.isArray(trasactionObject.customer.identifier))
39
- ? { identifier: trasactionObject.customer.identifier }
40
+ typeOf: customerByTransaction.typeOf,
41
+ id: customerByTransaction.id,
42
+ ...(Array.isArray(customerByTransaction.identifier))
43
+ ? { identifier: customerByTransaction.identifier }
40
44
  : /* istanbul ignore next */ undefined,
41
- // discontinue(2024-05-16~)
42
- // ...(transaction.object.customer.typeOf === factory.personType.Person
43
- // && typeof transaction.object.customer.memberOf?.typeOf === 'string')
44
- // ? { memberOf: transaction.object.customer.memberOf }
45
- // : undefined,
46
45
  ...(Array.isArray(params.agent.additionalProperty))
47
46
  ? { additionalProperty: params.agent.additionalProperty }
48
47
  : /* istanbul ignore next */ undefined,
package/package.json CHANGED
@@ -91,5 +91,5 @@
91
91
  "postversion": "git push origin --tags",
92
92
  "prepublishOnly": "npm run clean && npm run build"
93
93
  },
94
- "version": "25.0.0-alpha.14"
94
+ "version": "25.0.0-alpha.15"
95
95
  }