@chevre/domain 25.0.0-alpha.11 → 25.0.0-alpha.12
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.
- package/lib/chevre/repo/orderInTransaction.d.ts +2 -1
- package/lib/chevre/repo/orderInTransaction.js +3 -1
- package/lib/chevre/service/transaction/placeOrder/start/factory.d.ts +4 -0
- package/lib/chevre/service/transaction/placeOrder/start.d.ts +7 -1
- package/lib/chevre/service/transaction/placeOrder/start.js +24 -1
- package/lib/chevre/service/transaction/placeOrder.d.ts +1 -2
- package/lib/chevre/service/transaction/placeOrder.js +1 -3
- package/package.json +1 -1
|
@@ -10,6 +10,7 @@ type IOrderInTransaction = Pick<factory.order.IOrder, 'orderNumber' | 'project'
|
|
|
10
10
|
identifier: string;
|
|
11
11
|
acceptedOffers: factory.order.IAcceptedOffer[];
|
|
12
12
|
customer?: factory.order.ICustomer;
|
|
13
|
+
seller?: factory.order.ISeller;
|
|
13
14
|
};
|
|
14
15
|
/**
|
|
15
16
|
* typeOf: Orderへドキュメント変換時の編集フィールド
|
|
@@ -57,7 +58,7 @@ export type IMinimizedAcceptedOffer = Pick<factory.order.IOptimizedAcceptedOffer
|
|
|
57
58
|
export declare class OrderInTransactionRepo extends AcceptedOfferInReserveRepo {
|
|
58
59
|
private readonly orderModel;
|
|
59
60
|
constructor(connection: Connection);
|
|
60
|
-
createPlaceOrderIfNotExists(params: Pick<IOrderInTransaction, 'orderNumber' | 'project' | 'identifier' | 'broker'>): Promise<import("mongoose").UpdateWriteOpResult | undefined>;
|
|
61
|
+
createPlaceOrderIfNotExists(params: Pick<IOrderInTransaction, 'orderNumber' | 'project' | 'identifier' | 'broker' | 'seller' | 'customer'>): Promise<import("mongoose").UpdateWriteOpResult | undefined>;
|
|
61
62
|
/**
|
|
62
63
|
* 取引進行中の注文からacceptedOffersを検索する
|
|
63
64
|
* 予約取引から予約ごとの価格仕様も参照する
|
|
@@ -17,13 +17,15 @@ class OrderInTransactionRepo extends acceptedOfferInReserve_1.AcceptedOfferInRes
|
|
|
17
17
|
this.orderModel = connection.model(order_1.modelName, (0, order_1.createSchema)());
|
|
18
18
|
}
|
|
19
19
|
async createPlaceOrderIfNotExists(params) {
|
|
20
|
-
const { orderNumber, project, identifier, broker } = params;
|
|
20
|
+
const { orderNumber, project, identifier, broker, seller, customer } = params;
|
|
21
21
|
const setOnInsert = {
|
|
22
22
|
typeOf: factory_1.factory.transactionType.PlaceOrder,
|
|
23
23
|
orderDate: new Date(), // orderDate required(2024-12-09~)
|
|
24
24
|
orderNumber,
|
|
25
25
|
project,
|
|
26
26
|
identifier, // 取引ID(2026-06-22~)
|
|
27
|
+
...((seller !== undefined) && { seller }),
|
|
28
|
+
...((customer !== undefined) && { customer }),
|
|
27
29
|
...((broker !== undefined) && { broker })
|
|
28
30
|
};
|
|
29
31
|
try {
|
|
@@ -13,6 +13,10 @@ type IStartPlaceOrderParams = factory.transaction.placeOrder.IStartParamsWithout
|
|
|
13
13
|
*/
|
|
14
14
|
clientUser: factory.transaction.placeOrder.IClientUserBeforeStart;
|
|
15
15
|
};
|
|
16
|
+
/**
|
|
17
|
+
* 注文ドキュメントに保管する代理人
|
|
18
|
+
*/
|
|
19
|
+
broker?: factory.order.IBroker;
|
|
16
20
|
};
|
|
17
21
|
declare function createStartParams(params: IStartPlaceOrderParams, expiresInSeconds: number, passport: IVerifiedPassport | undefined, seller: Pick<factory.seller.ISeller, 'id' | 'name' | 'typeOf' | 'project' | 'additionalProperty'>, customerType?: string): factory.transaction.placeOrder.IStartParams;
|
|
18
22
|
export { AGENT_IDENTIFIER_NAME_PASSPORT, createStartParams, IStartPlaceOrderParams };
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import type { IssuerRepo } from '../../../repo/issuer';
|
|
2
2
|
import type { MemberRepo } from '../../../repo/member';
|
|
3
3
|
import type { MemberProgramRepo } from '../../../repo/memberProgram';
|
|
4
|
+
import type { OrderInTransactionRepo } from '../../../repo/orderInTransaction';
|
|
5
|
+
import type { OrderNumberRepo } from '../../../repo/orderNumber';
|
|
4
6
|
import type { PassportRepo } from '../../../repo/passport';
|
|
7
|
+
import type { ProjectRepo } from '../../../repo/project';
|
|
5
8
|
import type { ProjectMakesOfferRepo } from '../../../repo/projectMakesOffer';
|
|
6
9
|
import type { SellerRepo } from '../../../repo/seller';
|
|
7
10
|
import type { IStartedPlaceOrder, PlaceOrderRepo } from '../../../repo/transaction/placeOrder';
|
|
@@ -14,10 +17,13 @@ interface IStartOperationRepos {
|
|
|
14
17
|
projectMakesOffer: ProjectMakesOfferRepo;
|
|
15
18
|
seller: SellerRepo;
|
|
16
19
|
placeOrder: PlaceOrderRepo;
|
|
20
|
+
orderInTransaction: OrderInTransactionRepo;
|
|
21
|
+
project: ProjectRepo;
|
|
22
|
+
orderNumber: OrderNumberRepo;
|
|
17
23
|
}
|
|
18
24
|
type IStartOperation<T> = (repos: IStartOperationRepos) => Promise<T>;
|
|
19
25
|
interface IStartOptions {
|
|
20
|
-
|
|
26
|
+
createOrderDocument: boolean;
|
|
21
27
|
}
|
|
22
28
|
/**
|
|
23
29
|
* 取引開始
|
|
@@ -4,6 +4,7 @@ exports.start = start;
|
|
|
4
4
|
const factory_1 = require("../../../factory");
|
|
5
5
|
const factory_2 = require("./start/factory");
|
|
6
6
|
const validateStartRequest_1 = require("./start/validateStartRequest");
|
|
7
|
+
const issueOrderNumberIfNotExist_1 = require("./issueOrderNumberIfNotExist");
|
|
7
8
|
/**
|
|
8
9
|
* 取引開始
|
|
9
10
|
*/
|
|
@@ -25,7 +26,7 @@ function start(params, options) {
|
|
|
25
26
|
const startParams = (0, factory_2.createStartParams)(params, expiresInSeconds, passport, seller, customerType);
|
|
26
27
|
let transaction;
|
|
27
28
|
// lock passport(2024-07-05~)
|
|
28
|
-
if (
|
|
29
|
+
if (passport !== undefined) {
|
|
29
30
|
try {
|
|
30
31
|
await repos.passport.lock(passport);
|
|
31
32
|
}
|
|
@@ -51,6 +52,28 @@ function start(params, options) {
|
|
|
51
52
|
if (transaction === undefined) {
|
|
52
53
|
transaction = await repos.placeOrder.startPlaceOrder(startParams);
|
|
53
54
|
}
|
|
55
|
+
// support createOrderDocument(2026-06-23~)
|
|
56
|
+
if (options.createOrderDocument) {
|
|
57
|
+
const orderNumber = await (0, issueOrderNumberIfNotExist_1.issueOrderNumberIfNotExist)({
|
|
58
|
+
project: { id: params.project.id },
|
|
59
|
+
id: transaction.id,
|
|
60
|
+
object: { orderDate: new Date() }
|
|
61
|
+
})(repos);
|
|
62
|
+
await repos.orderInTransaction.createPlaceOrderIfNotExists({
|
|
63
|
+
orderNumber,
|
|
64
|
+
project: { id: params.project.id, typeOf: factory_1.factory.organizationType.Project },
|
|
65
|
+
identifier: transaction.id,
|
|
66
|
+
seller: {
|
|
67
|
+
id: seller.id,
|
|
68
|
+
name: (typeof seller.name === 'string') ? seller.name : String(seller.name?.ja),
|
|
69
|
+
typeOf: seller.typeOf,
|
|
70
|
+
additionalProperty: (Array.isArray(seller.additionalProperty)) ? seller.additionalProperty : [] // 追加特性を追加(2023-08-08~)
|
|
71
|
+
},
|
|
72
|
+
...((typeof params.object.customer?.typeOf === 'string') && { customer: params.object.customer }),
|
|
73
|
+
...((typeof params.broker?.typeOf === 'string') && { broker: params.broker })
|
|
74
|
+
});
|
|
75
|
+
// console.log('createPlaceOrderResult:', createPlaceOrderResult);
|
|
76
|
+
}
|
|
54
77
|
return transaction;
|
|
55
78
|
};
|
|
56
79
|
}
|
|
@@ -5,5 +5,4 @@ import { confirm } from './placeOrder/confirm';
|
|
|
5
5
|
import { exportTasksById } from './placeOrder/exportTasksById';
|
|
6
6
|
import { start, IStartPlaceOrderParams } from './placeOrder/start';
|
|
7
7
|
import { updateAgent } from './placeOrder/updateAgent';
|
|
8
|
-
|
|
9
|
-
export { confirm, start, IStartPlaceOrderParams, exportTasksById, updateAgent, issueOrderNumberIfNotExist };
|
|
8
|
+
export { confirm, start, IStartPlaceOrderParams, exportTasksById, updateAgent };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.updateAgent = exports.exportTasksById = exports.start = exports.confirm = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* 注文取引サービス
|
|
6
6
|
*/
|
|
@@ -12,5 +12,3 @@ const start_1 = require("./placeOrder/start");
|
|
|
12
12
|
Object.defineProperty(exports, "start", { enumerable: true, get: function () { return start_1.start; } });
|
|
13
13
|
const updateAgent_1 = require("./placeOrder/updateAgent");
|
|
14
14
|
Object.defineProperty(exports, "updateAgent", { enumerable: true, get: function () { return updateAgent_1.updateAgent; } });
|
|
15
|
-
const issueOrderNumberIfNotExist_1 = require("./placeOrder/issueOrderNumberIfNotExist");
|
|
16
|
-
Object.defineProperty(exports, "issueOrderNumberIfNotExist", { enumerable: true, get: function () { return issueOrderNumberIfNotExist_1.issueOrderNumberIfNotExist; } });
|
package/package.json
CHANGED