@chevre/domain 25.0.0-alpha.13 → 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.
- package/lib/chevre/repo/orderInTransaction.d.ts +20 -0
- package/lib/chevre/repo/orderInTransaction.js +42 -0
- package/lib/chevre/service/offer/event/authorize.js +1 -1
- package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer.d.ts +2 -0
- package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer.js +1 -1
- package/lib/chevre/service/payment/any/authorize/fixOrderAsNeeded.d.ts +2 -0
- package/lib/chevre/service/payment/any/authorize/fixOrderAsNeeded.js +1 -1
- package/lib/chevre/service/payment/any/authorize.d.ts +2 -0
- package/lib/chevre/service/payment/any/publishPaymentUrl.d.ts +2 -0
- package/lib/chevre/service/payment/any/publishPaymentUrl.js +1 -2
- package/lib/chevre/service/task/acceptCOAOffer.js +2 -4
- package/lib/chevre/service/task/authorizePayment.js +2 -6
- package/lib/chevre/service/task/publishPaymentUrl.js +2 -5
- package/lib/chevre/service/transaction/placeOrder/issueOrderNumberIfNotExist.d.ts +4 -0
- package/lib/chevre/service/transaction/placeOrder/issueOrderNumberIfNotExist.js +11 -1
- package/lib/chevre/service/transaction/placeOrder/start.js +1 -1
- package/lib/chevre/service/transaction/placeOrder/updateAgent.js +14 -15
- package/package.json +1 -1
|
@@ -59,6 +59,26 @@ export declare class OrderInTransactionRepo extends AcceptedOfferInReserveRepo {
|
|
|
59
59
|
private readonly orderModel;
|
|
60
60
|
constructor(connection: Connection);
|
|
61
61
|
createPlaceOrderIfNotExists(params: Pick<IOrderInTransaction, 'orderNumber' | 'project' | 'identifier' | 'broker' | 'seller' | 'customer'>): Promise<import("mongoose").UpdateWriteOpResult | undefined>;
|
|
62
|
+
/**
|
|
63
|
+
* 注文取引から注文番号を参照する
|
|
64
|
+
* 存在しなければNotFoundError
|
|
65
|
+
*/
|
|
66
|
+
findOrderNumberByIdentifier(params: {
|
|
67
|
+
identifier: string;
|
|
68
|
+
project: {
|
|
69
|
+
id: string;
|
|
70
|
+
};
|
|
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'>>;
|
|
62
82
|
/**
|
|
63
83
|
* 取引進行中の注文からacceptedOffersを検索する
|
|
64
84
|
* 予約取引から予約ごとの価格仕様も参照する
|
|
@@ -45,6 +45,48 @@ class OrderInTransactionRepo extends acceptedOfferInReserve_1.AcceptedOfferInRes
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* 注文取引から注文番号を参照する
|
|
50
|
+
* 存在しなければNotFoundError
|
|
51
|
+
*/
|
|
52
|
+
async findOrderNumberByIdentifier(params) {
|
|
53
|
+
const { project, identifier } = params;
|
|
54
|
+
const doc = await this.orderModel.findOne({
|
|
55
|
+
identifier: { $eq: identifier },
|
|
56
|
+
typeOf: { $eq: factory_1.factory.transactionType.PlaceOrder },
|
|
57
|
+
'project.id': { $eq: project.id }
|
|
58
|
+
}, {
|
|
59
|
+
_id: 0,
|
|
60
|
+
orderNumber: 1
|
|
61
|
+
})
|
|
62
|
+
.lean()
|
|
63
|
+
.exec();
|
|
64
|
+
if (doc === null) {
|
|
65
|
+
throw new factory_1.factory.errors.NotFound('orderInTransaction');
|
|
66
|
+
}
|
|
67
|
+
return doc.orderNumber;
|
|
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
|
+
}
|
|
48
90
|
/**
|
|
49
91
|
* 取引進行中の注文からacceptedOffersを検索する
|
|
50
92
|
* 予約取引から予約ごとの価格仕様も参照する
|
|
@@ -29,7 +29,7 @@ function authorize(params, options) {
|
|
|
29
29
|
project: { id: params.project.id },
|
|
30
30
|
id: transaction.id,
|
|
31
31
|
object: { orderDate: now }
|
|
32
|
-
})(repos);
|
|
32
|
+
}, { issueForce: false })(repos);
|
|
33
33
|
// まず取引番号発行
|
|
34
34
|
const { transactionNumber } = await repos.transactionNumber.publishByTimestamp({ startDate: now });
|
|
35
35
|
const actionAttributes = (0, factory_2.createAuthorizeSeatReservationActionAttributes)({
|
|
@@ -2,6 +2,7 @@ import type { COA } from '@motionpicture/coa-service';
|
|
|
2
2
|
import type { AcceptCOAOfferActionRepo } from '../../../repo/action/acceptCOAOffer';
|
|
3
3
|
import type { AuthorizeOfferActionRepo } from '../../../repo/action/authorizeOffer';
|
|
4
4
|
import type { EventRepo } from '../../../repo/event';
|
|
5
|
+
import type { OrderInTransactionRepo } from '../../../repo/orderInTransaction';
|
|
5
6
|
import type { OrderNumberRepo } from '../../../repo/orderNumber';
|
|
6
7
|
import type { ProjectRepo } from '../../../repo/project';
|
|
7
8
|
import type { PlaceOrderRepo } from '../../../repo/transaction/placeOrder';
|
|
@@ -9,6 +10,7 @@ import { factory } from '../../../factory';
|
|
|
9
10
|
interface IAcceptRepos {
|
|
10
11
|
action: AcceptCOAOfferActionRepo;
|
|
11
12
|
event: EventRepo;
|
|
13
|
+
orderInTransaction: OrderInTransactionRepo;
|
|
12
14
|
orderNumber: OrderNumberRepo;
|
|
13
15
|
project: ProjectRepo;
|
|
14
16
|
placeOrder: PlaceOrderRepo;
|
|
@@ -44,7 +44,7 @@ function acceptOffer(params) {
|
|
|
44
44
|
project: { id: transaction.project.id },
|
|
45
45
|
id: transaction.id,
|
|
46
46
|
object: { orderDate: new Date() }
|
|
47
|
-
})(repos);
|
|
47
|
+
}, { issueForce: false })(repos);
|
|
48
48
|
const coaInfo = await findCOAInfo({ id: params.object.event.id, project: { id: transaction.project.id } })(repos);
|
|
49
49
|
const updTmpReserveSeatArgs = (0, factory_2.createUpdTmpReserveSeatArgs)({ object: params.object, coaInfo });
|
|
50
50
|
let updTmpReserveSeatResult;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { factory } from '../../../../factory';
|
|
2
2
|
import type { ConfirmationNumberRepo } from '../../../../repo/confirmationNumber';
|
|
3
|
+
import type { OrderInTransactionRepo } from '../../../../repo/orderInTransaction';
|
|
3
4
|
import type { OrderNumberRepo } from '../../../../repo/orderNumber';
|
|
4
5
|
import type { ProjectRepo } from '../../../../repo/project';
|
|
5
6
|
import type { PlaceOrderRepo } from '../../../../repo/transaction/placeOrder';
|
|
@@ -12,6 +13,7 @@ declare function fixOrderAsNeeded(params: {
|
|
|
12
13
|
project: ProjectRepo;
|
|
13
14
|
placeOrder: PlaceOrderRepo;
|
|
14
15
|
confirmationNumber: ConfirmationNumberRepo;
|
|
16
|
+
orderInTransaction: OrderInTransactionRepo;
|
|
15
17
|
orderNumber: OrderNumberRepo;
|
|
16
18
|
}) => Promise<{
|
|
17
19
|
confirmationNumber: string;
|
|
@@ -14,6 +14,7 @@ import type { CredentialsRepo } from '../../../repo/credentials';
|
|
|
14
14
|
import type { EventRepo } from '../../../repo/event';
|
|
15
15
|
import type { EventSeriesRepo } from '../../../repo/eventSeries';
|
|
16
16
|
import type { IssuerRepo } from '../../../repo/issuer';
|
|
17
|
+
import type { OrderInTransactionRepo } from '../../../repo/orderInTransaction';
|
|
17
18
|
import type { OrderNumberRepo } from '../../../repo/orderNumber';
|
|
18
19
|
import type { PaymentServiceRepo } from '../../../repo/paymentService';
|
|
19
20
|
import type { PaymentServiceProviderRepo } from '../../../repo/paymentServiceProvider';
|
|
@@ -43,6 +44,7 @@ interface IAuthorizeRepos {
|
|
|
43
44
|
event: EventRepo;
|
|
44
45
|
eventSeries: EventSeriesRepo;
|
|
45
46
|
issuer: IssuerRepo;
|
|
47
|
+
orderInTransaction: OrderInTransactionRepo;
|
|
46
48
|
orderNumber: OrderNumberRepo;
|
|
47
49
|
paymentAccepted: SellerPaymentAcceptedRepo;
|
|
48
50
|
paymentService: PaymentServiceRepo;
|
|
@@ -7,6 +7,7 @@ import type { AuthorizationRepo } from '../../../repo/authorization';
|
|
|
7
7
|
import type { EventRepo } from '../../../repo/event';
|
|
8
8
|
import type { EventSeriesRepo } from '../../../repo/eventSeries';
|
|
9
9
|
import type { IssuerRepo } from '../../../repo/issuer';
|
|
10
|
+
import type { OrderInTransactionRepo } from '../../../repo/orderInTransaction';
|
|
10
11
|
import type { OrderNumberRepo } from '../../../repo/orderNumber';
|
|
11
12
|
import type { PaymentServiceRepo } from '../../../repo/paymentService';
|
|
12
13
|
import type { PaymentServiceProviderRepo } from '../../../repo/paymentServiceProvider';
|
|
@@ -24,6 +25,7 @@ interface IPublishPaymentUrlRepos {
|
|
|
24
25
|
event: EventRepo;
|
|
25
26
|
eventSeries: EventSeriesRepo;
|
|
26
27
|
issuer: IssuerRepo;
|
|
28
|
+
orderInTransaction: OrderInTransactionRepo;
|
|
27
29
|
orderNumber: OrderNumberRepo;
|
|
28
30
|
paymentAccepted: SellerPaymentAcceptedRepo;
|
|
29
31
|
paymentService: PaymentServiceRepo;
|
|
@@ -35,7 +35,6 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.publishPaymentUrl = publishPaymentUrl;
|
|
37
37
|
const factory_1 = require("../../../factory");
|
|
38
|
-
// import type { TransactionProcessRepo } from '../../repo/transactionProcess';
|
|
39
38
|
const PayTransactionService = __importStar(require("../../assetTransaction/pay"));
|
|
40
39
|
const issueOrderNumberIfNotExist_1 = require("../../transaction/placeOrder/issueOrderNumberIfNotExist");
|
|
41
40
|
const fixTransactionNumberOnPublishPaymentUrl_1 = require("./publishPaymentUrl/fixTransactionNumberOnPublishPaymentUrl");
|
|
@@ -59,7 +58,7 @@ function publishPaymentUrl(params) {
|
|
|
59
58
|
project: { id: transaction.project.id },
|
|
60
59
|
id: transaction.id,
|
|
61
60
|
object: { orderDate: new Date() }
|
|
62
|
-
})(repos);
|
|
61
|
+
}, { issueForce: false })(repos);
|
|
63
62
|
// 取引番号生成
|
|
64
63
|
const { transactionNumber, ticketToken } = await (0, fixTransactionNumberOnPublishPaymentUrl_1.fixTransactionNumberOnPublishPaymentUrl)({
|
|
65
64
|
object: params.object,
|
|
@@ -3,16 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.call = call;
|
|
4
4
|
const coa_service_1 = require("@motionpicture/coa-service");
|
|
5
5
|
const factory_1 = require("../../factory");
|
|
6
|
-
// import { ActionRepo } from '../../repo/action';
|
|
7
6
|
const acceptCOAOffer_1 = require("../../repo/action/acceptCOAOffer");
|
|
8
7
|
const authorizeOffer_1 = require("../../repo/action/authorizeOffer");
|
|
9
8
|
const credentials_1 = require("../../repo/credentials");
|
|
10
9
|
const event_1 = require("../../repo/event");
|
|
10
|
+
const orderInTransaction_1 = require("../../repo/orderInTransaction");
|
|
11
11
|
const orderNumber_1 = require("../../repo/orderNumber");
|
|
12
12
|
const project_1 = require("../../repo/project");
|
|
13
13
|
const reserveInterface_1 = require("../../repo/reserveInterface");
|
|
14
14
|
const integration_1 = require("../../repo/setting/integration");
|
|
15
|
-
// import { TransactionRepo } from '../../repo/transaction';
|
|
16
15
|
const placeOrder_1 = require("../../repo/transaction/placeOrder");
|
|
17
16
|
const acceptOffer_1 = require("../offer/eventServiceByCOA/acceptOffer");
|
|
18
17
|
let coaAuthClient;
|
|
@@ -90,7 +89,6 @@ function call(params) {
|
|
|
90
89
|
orderNumber: new orderNumber_1.OrderNumberRepo({ connection }),
|
|
91
90
|
project: new project_1.ProjectRepo(connection),
|
|
92
91
|
placeOrder: new placeOrder_1.PlaceOrderRepo(connection),
|
|
93
|
-
// transaction: new TransactionRepo(connection),
|
|
94
92
|
reserveService,
|
|
95
93
|
masterService
|
|
96
94
|
});
|
|
@@ -106,10 +104,10 @@ function call(params) {
|
|
|
106
104
|
})({
|
|
107
105
|
action: actionRepo,
|
|
108
106
|
event: new event_1.EventRepo(connection),
|
|
107
|
+
orderInTransaction: new orderInTransaction_1.OrderInTransactionRepo(connection),
|
|
109
108
|
orderNumber: new orderNumber_1.OrderNumberRepo({ connection }),
|
|
110
109
|
project: new project_1.ProjectRepo(connection),
|
|
111
110
|
placeOrder: new placeOrder_1.PlaceOrderRepo(connection),
|
|
112
|
-
// transaction: new TransactionRepo(connection),
|
|
113
111
|
reserveService,
|
|
114
112
|
masterService
|
|
115
113
|
});
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.call = call;
|
|
4
4
|
const factory_1 = require("../../factory");
|
|
5
5
|
const accountingReport_1 = require("../../repo/accountingReport");
|
|
6
|
-
// import { ActionRepo } from '../../repo/action';
|
|
7
6
|
const pay_1 = require("../../repo/action/pay");
|
|
8
7
|
const refund_1 = require("../../repo/action/refund");
|
|
9
8
|
const checkMovieTicket_1 = require("../../repo/action/checkMovieTicket");
|
|
@@ -17,6 +16,7 @@ const credentials_1 = require("../../repo/credentials");
|
|
|
17
16
|
const event_1 = require("../../repo/event");
|
|
18
17
|
const eventSeries_1 = require("../../repo/eventSeries");
|
|
19
18
|
const issuer_1 = require("../../repo/issuer");
|
|
19
|
+
const orderInTransaction_1 = require("../../repo/orderInTransaction");
|
|
20
20
|
const orderNumber_1 = require("../../repo/orderNumber");
|
|
21
21
|
const paymentService_1 = require("../../repo/paymentService");
|
|
22
22
|
const paymentServiceProvider_1 = require("../../repo/paymentServiceProvider");
|
|
@@ -27,10 +27,8 @@ const sellerPaymentAccepted_1 = require("../../repo/sellerPaymentAccepted");
|
|
|
27
27
|
const integration_1 = require("../../repo/setting/integration");
|
|
28
28
|
const task_1 = require("../../repo/task");
|
|
29
29
|
const ticket_1 = require("../../repo/ticket");
|
|
30
|
-
// import { TransactionRepo } from '../../repo/transaction';
|
|
31
30
|
const placeOrder_1 = require("../../repo/transaction/placeOrder");
|
|
32
31
|
const transactionNumber_1 = require("../../repo/transactionNumber");
|
|
33
|
-
// import { TransactionProcessRepo } from '../../repo/transactionProcess';
|
|
34
32
|
const any_1 = require("../payment/any");
|
|
35
33
|
/**
|
|
36
34
|
* タスク実行関数
|
|
@@ -60,7 +58,6 @@ function call(params) {
|
|
|
60
58
|
sameAs: { id: params.id } // タスクIDを関連付け(2024-04-20~)
|
|
61
59
|
})({
|
|
62
60
|
accountingReport: new accountingReport_1.AccountingReportRepo(connection),
|
|
63
|
-
// action: new ActionRepo(connection),
|
|
64
61
|
actions: {
|
|
65
62
|
pay: new pay_1.PayActionRepo(connection),
|
|
66
63
|
refund: new refund_1.RefundActionRepo(connection),
|
|
@@ -79,6 +76,7 @@ function call(params) {
|
|
|
79
76
|
event: new event_1.EventRepo(connection),
|
|
80
77
|
eventSeries: new eventSeries_1.EventSeriesRepo(connection),
|
|
81
78
|
issuer: new issuer_1.IssuerRepo(connection),
|
|
79
|
+
orderInTransaction: new orderInTransaction_1.OrderInTransactionRepo(connection),
|
|
82
80
|
orderNumber: new orderNumber_1.OrderNumberRepo({ connection }),
|
|
83
81
|
paymentAccepted: new sellerPaymentAccepted_1.SellerPaymentAcceptedRepo(connection),
|
|
84
82
|
paymentService: new paymentService_1.PaymentServiceRepo(connection),
|
|
@@ -89,9 +87,7 @@ function call(params) {
|
|
|
89
87
|
task: new task_1.TaskRepo(connection),
|
|
90
88
|
ticket: new ticket_1.TicketRepo(connection),
|
|
91
89
|
placeOrder: new placeOrder_1.PlaceOrderRepo(connection),
|
|
92
|
-
// transaction: new TransactionRepo(connection),
|
|
93
90
|
transactionNumber: new transactionNumber_1.TransactionNumberRepo({ connection })
|
|
94
|
-
// transactionProcess: transactionProcessRepo
|
|
95
91
|
}, settings);
|
|
96
92
|
}
|
|
97
93
|
catch (error) {
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.call = call;
|
|
4
4
|
const factory_1 = require("../../factory");
|
|
5
|
-
// import { ActionRepo } from '../../repo/action';
|
|
6
5
|
const acceptPay_1 = require("../../repo/action/acceptPay");
|
|
7
6
|
const authorizeInvoice_1 = require("../../repo/action/authorizeInvoice");
|
|
8
7
|
const assetTransaction_1 = require("../../repo/assetTransaction");
|
|
@@ -10,6 +9,7 @@ const authorization_1 = require("../../repo/authorization");
|
|
|
10
9
|
const event_1 = require("../../repo/event");
|
|
11
10
|
const eventSeries_1 = require("../../repo/eventSeries");
|
|
12
11
|
const issuer_1 = require("../../repo/issuer");
|
|
12
|
+
const orderInTransaction_1 = require("../../repo/orderInTransaction");
|
|
13
13
|
const orderNumber_1 = require("../../repo/orderNumber");
|
|
14
14
|
const paymentService_1 = require("../../repo/paymentService");
|
|
15
15
|
const paymentServiceProvider_1 = require("../../repo/paymentServiceProvider");
|
|
@@ -17,10 +17,8 @@ const project_1 = require("../../repo/project");
|
|
|
17
17
|
const sellerPaymentAccepted_1 = require("../../repo/sellerPaymentAccepted");
|
|
18
18
|
const integration_1 = require("../../repo/setting/integration");
|
|
19
19
|
const ticket_1 = require("../../repo/ticket");
|
|
20
|
-
// import { TransactionRepo } from '../../repo/transaction';
|
|
21
20
|
const placeOrder_1 = require("../../repo/transaction/placeOrder");
|
|
22
21
|
const transactionNumber_1 = require("../../repo/transactionNumber");
|
|
23
|
-
// import { TransactionProcessRepo } from '../../repo/transactionProcess';
|
|
24
22
|
const any_1 = require("../payment/any");
|
|
25
23
|
/**
|
|
26
24
|
* タスク実行関数
|
|
@@ -43,7 +41,6 @@ function call(params) {
|
|
|
43
41
|
instrument: (Array.isArray(params.data.instrument)) ? params.data.instrument : [],
|
|
44
42
|
sameAs: { id: params.id }
|
|
45
43
|
})({
|
|
46
|
-
// action: new ActionRepo(connection),
|
|
47
44
|
acceptPayAction: actionRepo,
|
|
48
45
|
authorizeInvoiceAction: new authorizeInvoice_1.AuthorizeInvoiceActionRepo(connection),
|
|
49
46
|
assetTransaction: new assetTransaction_1.AssetTransactionRepo(connection),
|
|
@@ -51,6 +48,7 @@ function call(params) {
|
|
|
51
48
|
event: new event_1.EventRepo(connection),
|
|
52
49
|
eventSeries: new eventSeries_1.EventSeriesRepo(connection),
|
|
53
50
|
issuer: new issuer_1.IssuerRepo(connection),
|
|
51
|
+
orderInTransaction: new orderInTransaction_1.OrderInTransactionRepo(connection),
|
|
54
52
|
orderNumber: new orderNumber_1.OrderNumberRepo({ connection }),
|
|
55
53
|
paymentAccepted: new sellerPaymentAccepted_1.SellerPaymentAcceptedRepo(connection),
|
|
56
54
|
paymentService: new paymentService_1.PaymentServiceRepo(connection),
|
|
@@ -58,7 +56,6 @@ function call(params) {
|
|
|
58
56
|
project: new project_1.ProjectRepo(connection),
|
|
59
57
|
ticket: new ticket_1.TicketRepo(connection),
|
|
60
58
|
placeOrder: new placeOrder_1.PlaceOrderRepo(connection),
|
|
61
|
-
// transaction: new TransactionRepo(connection),
|
|
62
59
|
transactionNumber: new transactionNumber_1.TransactionNumberRepo({ connection })
|
|
63
60
|
}, settings);
|
|
64
61
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { OrderInTransactionRepo } from '../../../repo/orderInTransaction';
|
|
1
2
|
import type { OrderNumberRepo } from '../../../repo/orderNumber';
|
|
2
3
|
import type { ProjectRepo } from '../../../repo/project';
|
|
3
4
|
import type { PlaceOrderRepo } from '../../../repo/transaction/placeOrder';
|
|
@@ -15,9 +16,12 @@ declare function issueOrderNumberIfNotExist(params: {
|
|
|
15
16
|
object: {
|
|
16
17
|
orderDate: Date;
|
|
17
18
|
};
|
|
19
|
+
}, options: {
|
|
20
|
+
issueForce: boolean;
|
|
18
21
|
}): (repos: {
|
|
19
22
|
project: ProjectRepo;
|
|
20
23
|
placeOrder: PlaceOrderRepo;
|
|
24
|
+
orderInTransaction: OrderInTransactionRepo;
|
|
21
25
|
orderNumber: OrderNumberRepo;
|
|
22
26
|
}) => Promise<string>;
|
|
23
27
|
export { issueOrderNumberIfNotExist };
|
|
@@ -2,11 +2,21 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.issueOrderNumberIfNotExist = issueOrderNumberIfNotExist;
|
|
4
4
|
const factory_1 = require("../../../factory");
|
|
5
|
+
const USE_LEGACY_ISSUE_ORDER_NUMBER = process.env.USE_LEGACY_ISSUE_ORDER_NUMBER === '1';
|
|
5
6
|
/**
|
|
6
7
|
* 未発行であれば、注文番号を発行して取引に保管する
|
|
7
8
|
*/
|
|
8
|
-
function issueOrderNumberIfNotExist(params) {
|
|
9
|
+
function issueOrderNumberIfNotExist(params, options) {
|
|
9
10
|
return async (repos) => {
|
|
11
|
+
// issueForceオプションあるいは、廃止予定の発行オプションの場合、注文番号を新たに発行する
|
|
12
|
+
const issueOrderNumber = options?.issueForce === true || USE_LEGACY_ISSUE_ORDER_NUMBER;
|
|
13
|
+
if (!issueOrderNumber) {
|
|
14
|
+
// 注文ドキュメントを参照(2026-06-24~)
|
|
15
|
+
return repos.orderInTransaction.findOrderNumberByIdentifier({
|
|
16
|
+
identifier: params.id,
|
|
17
|
+
project: { id: params.project.id }
|
|
18
|
+
});
|
|
19
|
+
}
|
|
10
20
|
// 1. 最初のチェック
|
|
11
21
|
let orderNumber = await repos.placeOrder.findInProgressOrderNumberById({ id: params.id });
|
|
12
22
|
// すでに発行済であれば何もしない
|
|
@@ -58,7 +58,7 @@ function start(params, options) {
|
|
|
58
58
|
project: { id: params.project.id },
|
|
59
59
|
id: transaction.id,
|
|
60
60
|
object: { orderDate: new Date() }
|
|
61
|
-
})(repos);
|
|
61
|
+
}, { issueForce: true })(repos);
|
|
62
62
|
await repos.orderInTransaction.createPlaceOrderIfNotExists({
|
|
63
63
|
orderNumber,
|
|
64
64
|
project: { id: params.project.id, typeOf: factory_1.factory.organizationType.Project },
|
|
@@ -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:
|
|
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
|
-
//
|
|
33
|
-
const
|
|
34
|
-
|
|
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:
|
|
37
|
-
id:
|
|
38
|
-
...(Array.isArray(
|
|
39
|
-
? { 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,
|
|
@@ -79,7 +78,7 @@ function updateAgent(params) {
|
|
|
79
78
|
project: { id: transaction.project.id },
|
|
80
79
|
id: params.id,
|
|
81
80
|
object: { orderDate: new Date() }
|
|
82
|
-
})(repos);
|
|
81
|
+
}, { issueForce: false })(repos);
|
|
83
82
|
const customerName = (typeof customer.name === 'string' && customer.name !== '')
|
|
84
83
|
? customer.name
|
|
85
84
|
: (typeof customer.givenName === 'string' && typeof customer.familyName === 'string'
|
package/package.json
CHANGED