@chevre/domain 24.0.0-alpha.78 → 24.0.0-alpha.79

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 (53) hide show
  1. package/lib/chevre/repo/action/actionProcess.d.ts +3 -3
  2. package/lib/chevre/repo/action/authorizeOffer.d.ts +2 -3
  3. package/lib/chevre/repo/action/authorizeOffer.js +2 -2
  4. package/lib/chevre/repo/action.d.ts +2 -2
  5. package/lib/chevre/repo/assetTransaction.d.ts +3 -27
  6. package/lib/chevre/repo/assetTransaction.js +21 -21
  7. package/lib/chevre/repo/mongoose/schemas/assetTransaction.d.ts +1 -1
  8. package/lib/chevre/repo/task.d.ts +1 -1
  9. package/lib/chevre/repository.d.ts +0 -5
  10. package/lib/chevre/repository.js +0 -11
  11. package/lib/chevre/service/assetTransaction.d.ts +0 -2
  12. package/lib/chevre/service/assetTransaction.js +8 -10
  13. package/lib/chevre/service/delivery/factory.js +13 -13
  14. package/lib/chevre/service/offer/any.d.ts +1 -1
  15. package/lib/chevre/service/offer/product.d.ts +0 -62
  16. package/lib/chevre/service/offer/product.js +0 -409
  17. package/lib/chevre/service/order/onAssetTransactionStatusChanged/isDeliverable.d.ts +1 -1
  18. package/lib/chevre/service/order/onAssetTransactionStatusChanged/isDeliverable.js +22 -18
  19. package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +20 -20
  20. package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.d.ts +1 -1
  21. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts +1 -1
  22. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/processOrder.js +2 -96
  23. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.d.ts +1 -1
  24. package/lib/chevre/service/order/placeOrder/factory/orderedItem.d.ts +0 -1
  25. package/lib/chevre/service/order/placeOrder/factory/orderedItem.js +3 -28
  26. package/lib/chevre/service/order/placeOrder/factory.js +5 -5
  27. package/lib/chevre/service/transaction/placeOrder/confirm/validation/factory.d.ts +0 -1
  28. package/lib/chevre/service/transaction/placeOrder/confirm/validation/validatePrice.d.ts +2 -2
  29. package/lib/chevre/service/transaction/placeOrder/confirm/validation/validatePrice.js +2 -2
  30. package/lib/chevre/service/transaction/placeOrder/confirm/validation.d.ts +3 -3
  31. package/lib/chevre/service/transaction/placeOrder/confirm/validation.js +4 -2
  32. package/lib/chevre/service/transaction/placeOrder/confirm.js +21 -23
  33. package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +0 -21
  34. package/lib/chevre/service/validation/validateOrder.js +11 -10
  35. package/package.json +2 -2
  36. package/lib/chevre/repo/action/authorizeProductOffer.d.ts +0 -26
  37. package/lib/chevre/repo/action/authorizeProductOffer.js +0 -32
  38. package/lib/chevre/service/assetTransaction/registerService/factory.d.ts +0 -14
  39. package/lib/chevre/service/assetTransaction/registerService/factory.js +0 -140
  40. package/lib/chevre/service/assetTransaction/registerService/potentialActions.d.ts +0 -8
  41. package/lib/chevre/service/assetTransaction/registerService/potentialActions.js +0 -120
  42. package/lib/chevre/service/assetTransaction/registerService.d.ts +0 -54
  43. package/lib/chevre/service/assetTransaction/registerService.js +0 -274
  44. package/lib/chevre/service/delivery/product/factory.d.ts +0 -13
  45. package/lib/chevre/service/delivery/product/factory.js +0 -81
  46. package/lib/chevre/service/offer/product/factory.d.ts +0 -37
  47. package/lib/chevre/service/offer/product/factory.js +0 -208
  48. package/lib/chevre/service/task/confirmRegisterService.d.ts +0 -6
  49. package/lib/chevre/service/task/confirmRegisterService.js +0 -19
  50. package/lib/chevre/service/task/confirmRegisterServiceTransaction.d.ts +0 -17
  51. package/lib/chevre/service/task/confirmRegisterServiceTransaction.js +0 -116
  52. package/lib/chevre/service/task/voidRegisterServiceTransaction.d.ts +0 -6
  53. package/lib/chevre/service/task/voidRegisterServiceTransaction.js +0 -23
@@ -1,81 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createProductOwnershipInfo = createProductOwnershipInfo;
7
- const moment_1 = __importDefault(require("moment"));
8
- const factory_1 = require("../../../factory");
9
- const MAX_OWNED_THROUGH = '3000-01-01T00:00:00Z';
10
- function createProductOwnershipInfo(params) {
11
- let ownedThrough;
12
- // どういう期間でいくらのオファーなのか
13
- const priceSpec = params.acceptedOffer.priceSpecification;
14
- if (priceSpec === undefined) {
15
- throw new factory_1.factory.errors.NotFound('Order.acceptedOffers.priceSpecification');
16
- }
17
- const unitPriceSpec = priceSpec.priceComponent.find((p) => p.typeOf === factory_1.factory.priceSpecificationType.UnitPriceSpecification);
18
- if (unitPriceSpec === undefined) {
19
- throw new factory_1.factory.errors.NotFound('Unit Price Specification in Order.acceptedOffers.priceSpecification');
20
- }
21
- // unitPriceSpec.referenceQuantity.value: 'Infinity'に対応
22
- const referenceQuantityValue = unitPriceSpec.referenceQuantity.value;
23
- if (referenceQuantityValue === factory_1.factory.quantitativeValue.StringValue.Infinity) {
24
- // Infinityの場合ownedThroughは固定値
25
- ownedThrough = (0, moment_1.default)(MAX_OWNED_THROUGH)
26
- .toDate();
27
- }
28
- else if (typeof referenceQuantityValue === 'number') {
29
- switch (unitPriceSpec.referenceQuantity.unitCode) {
30
- case factory_1.factory.unitCode.Ann:
31
- ownedThrough = (0, moment_1.default)(params.ownedFrom)
32
- .add(referenceQuantityValue, 'years')
33
- .toDate();
34
- break;
35
- case factory_1.factory.unitCode.Day:
36
- ownedThrough = (0, moment_1.default)(params.ownedFrom)
37
- .add(referenceQuantityValue, 'days')
38
- .toDate();
39
- break;
40
- case factory_1.factory.unitCode.Sec:
41
- ownedThrough = (0, moment_1.default)(params.ownedFrom)
42
- .add(referenceQuantityValue, 'seconds')
43
- .toDate();
44
- break;
45
- default:
46
- throw new factory_1.factory.errors.NotImplemented(`Reference quantity unit code '${unitPriceSpec.referenceQuantity.unitCode}' not implemented`);
47
- }
48
- }
49
- else {
50
- throw new factory_1.factory.errors.NotFound('Order.acceptedOffers.priceSpecification.referenceQuantity.value');
51
- }
52
- const itemOffered = params.acceptedOffer.itemOffered;
53
- const issuedThrough = (typeof itemOffered.issuedThrough?.typeOf === 'string')
54
- ? {
55
- id: itemOffered.issuedThrough.id,
56
- typeOf: itemOffered.issuedThrough.typeOf,
57
- ...(typeof itemOffered.issuedThrough.serviceType?.typeOf === 'string')
58
- ? { serviceType: itemOffered.issuedThrough.serviceType }
59
- : undefined
60
- }
61
- : undefined;
62
- const typeOfGood = {
63
- identifier: itemOffered.identifier,
64
- typeOf: itemOffered.typeOf,
65
- ...(typeof issuedThrough?.typeOf === 'string') ? { issuedThrough } : undefined,
66
- // ...(itemOffered.validFor !== undefined) ? { validFor: itemOffered.validFor } : undefined,
67
- // ...(itemOffered.name !== undefined) ? { name: itemOffered.name } : undefined
68
- };
69
- const ownershipInfo = {
70
- project: params.project,
71
- typeOf: 'OwnershipInfo',
72
- id: '',
73
- identifier: params.identifier,
74
- ownedBy: params.ownedBy,
75
- acquiredFrom: params.acquiredFrom,
76
- ownedFrom: params.ownedFrom,
77
- ownedThrough: ownedThrough,
78
- typeOfGood: typeOfGood
79
- };
80
- return ownershipInfo;
81
- }
@@ -1,37 +0,0 @@
1
- import { factory } from '../../../factory';
2
- export declare function createRegisterServiceStartParams(params: {
3
- project: {
4
- id: string;
5
- typeOf: factory.organizationType.Project;
6
- };
7
- object: factory.action.authorize.offer.product.IAcceptedOffer[];
8
- transaction: Pick<factory.transaction.ITransaction<factory.transactionType>, 'seller' | 'expires'>;
9
- transactionNumber: string;
10
- }): factory.assetTransaction.registerService.IStartParamsWithoutDetail;
11
- export declare function createActionAttributes(params: {
12
- acceptedOffer: factory.action.authorize.offer.product.IAcceptedOffer[];
13
- transaction: Pick<factory.transaction.ITransaction<factory.transactionType.PlaceOrder>, 'agent' | 'id' | 'project' | 'seller' | 'typeOf'>;
14
- transactionNumber: string;
15
- }): factory.action.authorize.offer.product.IAttributes;
16
- export declare function acceptedOffers2amount(params: {
17
- acceptedOffers: IResultAcceptedOffer;
18
- }): number;
19
- type IResultAcceptedOffer = factory.order.IAcceptedOffer<factory.order.IPermit>[];
20
- export declare function responseBody2resultAcceptedOffer(params: {
21
- project: {
22
- id: string;
23
- typeOf: factory.organizationType.Project;
24
- };
25
- responseBody: factory.assetTransaction.registerService.ITransaction;
26
- acceptedOffer: factory.action.authorize.offer.product.IAcceptedOffer[];
27
- }): IResultAcceptedOffer;
28
- export declare function createResult(params: {
29
- project: {
30
- id: string;
31
- typeOf: factory.organizationType.Project;
32
- };
33
- requestBody: factory.assetTransaction.registerService.IStartParamsWithoutDetail;
34
- responseBody: factory.assetTransaction.registerService.ITransaction;
35
- acceptedOffer: factory.action.authorize.offer.product.IAcceptedOffer[];
36
- }): factory.action.authorize.offer.product.IResult;
37
- export {};
@@ -1,208 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createRegisterServiceStartParams = createRegisterServiceStartParams;
7
- exports.createActionAttributes = createActionAttributes;
8
- exports.acceptedOffers2amount = acceptedOffers2amount;
9
- exports.responseBody2resultAcceptedOffer = responseBody2resultAcceptedOffer;
10
- exports.createResult = createResult;
11
- const moment_1 = __importDefault(require("moment"));
12
- const factory_1 = require("../../../factory");
13
- function createRegisterServiceStartParams(params) {
14
- return {
15
- project: { typeOf: params.project.typeOf, id: params.project.id },
16
- typeOf: factory_1.factory.assetTransactionType.RegisterService,
17
- transactionNumber: params.transactionNumber,
18
- agent: {
19
- typeOf: params.transaction.seller.typeOf,
20
- id: params.transaction.seller.id,
21
- name: (typeof params.transaction.seller.name === 'string')
22
- ? params.transaction.seller.name
23
- : String(params.transaction.seller.name?.ja)
24
- // identifierを廃止(2024-03-05~)
25
- // identifier: [
26
- // { name: 'transaction', value: params.transaction.id },
27
- // {
28
- // name: 'transactionExpires',
29
- // value: moment(params.transaction.expires)
30
- // .toISOString()
31
- // }
32
- // ]
33
- },
34
- object: params.object.map((o) => {
35
- // 許可証コードは自動発行されているはず
36
- const permitIdentifier = o.itemOffered.serviceOutput.identifier;
37
- if (typeof permitIdentifier !== 'string' || permitIdentifier === '') {
38
- throw new factory_1.factory.errors.ArgumentNull('itemOffered.serviceOutput.identifier');
39
- }
40
- return {
41
- typeOf: o.typeOf,
42
- id: String(o.id),
43
- itemOffered: {
44
- ...o.itemOffered,
45
- serviceOutput: {
46
- ...o.itemOffered.serviceOutput,
47
- identifier: permitIdentifier
48
- }
49
- }
50
- };
51
- }),
52
- expires: (0, moment_1.default)(params.transaction.expires)
53
- .add(1, 'day')
54
- .toDate() // 余裕を持って
55
- };
56
- }
57
- function createActionAttributes(params) {
58
- const transaction = params.transaction;
59
- const actionObject = {
60
- typeOf: factory_1.factory.action.authorize.offer.product.ObjectType.AggregateOffer,
61
- itemOffered: {
62
- id: params.acceptedOffer[0].itemOffered.id,
63
- typeOf: params.acceptedOffer[0].itemOffered.typeOf
64
- }
65
- };
66
- return {
67
- project: transaction.project,
68
- typeOf: factory_1.factory.actionType.AuthorizeAction,
69
- instrument: {
70
- typeOf: factory_1.factory.assetTransactionType.RegisterService,
71
- transactionNumber: params.transactionNumber
72
- },
73
- // object: params.acceptedOffer,
74
- object: actionObject, // optimize(2026-03-13~)
75
- agent: {
76
- id: transaction.seller.id,
77
- typeOf: transaction.seller.typeOf,
78
- name: (typeof transaction.seller.name === 'string')
79
- ? transaction.seller.name
80
- : String(transaction.seller.name?.ja)
81
- },
82
- recipient: {
83
- id: transaction.agent.id,
84
- typeOf: transaction.agent.typeOf
85
- },
86
- purpose: { typeOf: transaction.typeOf, id: transaction.id }
87
- };
88
- }
89
- function acceptedOffers2amount(params) {
90
- const acceptedOffers = params.acceptedOffers;
91
- // 金額計算
92
- return acceptedOffers.reduce((a, b) => {
93
- if (b.priceSpecification === undefined || b.priceSpecification === null) {
94
- throw new factory_1.factory.errors.Internal('price specification of result accepted offer undefined');
95
- }
96
- if (b.priceSpecification.typeOf !== factory_1.factory.priceSpecificationType.CompoundPriceSpecification) {
97
- throw new factory_1.factory.errors.Internal('price specification of result accepted offer must be CompoundPriceSpecification');
98
- }
99
- const priceSpecification = b.priceSpecification;
100
- return a + priceSpecification.priceComponent.reduce((a2, b2) => a2 + Number(b2.price), 0);
101
- }, 0);
102
- }
103
- function responseBody2resultAcceptedOffer(params) {
104
- let acceptedOffers = [];
105
- if (Array.isArray(params.responseBody.object)) {
106
- acceptedOffers = params.responseBody.object.map((responseBodyObject) => {
107
- const serviceOutputIdentifier = responseBodyObject.itemOffered?.serviceOutput?.identifier;
108
- if (serviceOutputIdentifier !== undefined && typeof serviceOutputIdentifier !== 'string') {
109
- // 基本的にありえないフロー↓
110
- throw new factory_1.factory.errors.Internal(`invalid type of serviceOutput.identifier: ${typeof serviceOutputIdentifier}`);
111
- }
112
- // itemOfferedを最小限に最適化
113
- const permitByResponse = responseBodyObject.itemOffered.serviceOutput;
114
- const itemOffered = {
115
- // 不要なので廃止(2023-07-01~)
116
- // project: permitByResponse.project,
117
- typeOf: permitByResponse.typeOf,
118
- identifier: permitByResponse.identifier,
119
- issuedThrough: permitByResponse.issuedThrough,
120
- name: permitByResponse.name,
121
- // masked accessCode
122
- // ...(typeof permitByResponse.accessCode === 'string') ? { accessCode: 'xxx' } : undefined,
123
- ...(typeof permitByResponse.validFor === 'string') ? { validFor: permitByResponse.validFor } : undefined,
124
- ...(typeof permitByResponse.amount?.typeOf === 'string') ? { amount: permitByResponse.amount } : undefined
125
- };
126
- const offer = params.acceptedOffer.find((o) => o.id === responseBodyObject.id);
127
- if (offer === undefined) {
128
- throw new factory_1.factory.errors.Internal(`Offer ${responseBodyObject.id} from registerService not found`);
129
- }
130
- if (typeof offer.priceSpecification?.typeOf !== 'string') {
131
- throw new factory_1.factory.errors.NotFound('acceptedOffer.priceSpecification');
132
- }
133
- const priceComponent = [];
134
- offer.priceSpecification.priceComponent.forEach((component) => {
135
- if (typeof component.price === 'number') {
136
- if (component.typeOf === factory_1.factory.priceSpecificationType.UnitPriceSpecification) {
137
- const unitPriceComponent = {
138
- accounting: component.accounting,
139
- name: component.name,
140
- price: component.price,
141
- priceCurrency: component.priceCurrency,
142
- referenceQuantity: component.referenceQuantity,
143
- typeOf: component.typeOf,
144
- valueAddedTaxIncluded: component.valueAddedTaxIncluded,
145
- ...(Array.isArray(component.appliesToAddOn))
146
- ? { appliesToAddOn: component.appliesToAddOn }
147
- : undefined,
148
- ...(Array.isArray(component.appliesToMovieTicket))
149
- ? { appliesToMovieTicket: component.appliesToMovieTicket }
150
- : undefined,
151
- ...(typeof component.accounting?.typeOf === 'string')
152
- ? {
153
- accounting: {
154
- typeOf: component.accounting.typeOf,
155
- ...(typeof component.accounting.accountsReceivable === 'number')
156
- ? { accountsReceivable: component.accounting.accountsReceivable }
157
- : undefined,
158
- ...(typeof component.accounting.operatingRevenue?.typeOf === 'string')
159
- ? {
160
- operatingRevenue: {
161
- // project: component.accounting.operatingRevenue.project, // 削除(2023-12-13~)
162
- typeOf: component.accounting.operatingRevenue.typeOf,
163
- codeValue: component.accounting.operatingRevenue.codeValue
164
- }
165
- }
166
- : undefined
167
- }
168
- }
169
- : undefined
170
- };
171
- priceComponent.push(unitPriceComponent);
172
- }
173
- else {
174
- priceComponent.push(component);
175
- }
176
- }
177
- });
178
- const priceSpecification = {
179
- typeOf: offer.priceSpecification.typeOf,
180
- valueAddedTaxIncluded: offer.priceSpecification.valueAddedTaxIncluded,
181
- priceCurrency: offer.priceSpecification.priceCurrency,
182
- priceComponent
183
- };
184
- const permitAcceptedOffer = {
185
- typeOf: responseBodyObject.typeOf,
186
- id: offer.id,
187
- // name: offer.name,
188
- itemOffered,
189
- priceSpecification,
190
- serialNumber: params.responseBody.transactionNumber
191
- };
192
- return permitAcceptedOffer;
193
- });
194
- }
195
- return acceptedOffers;
196
- }
197
- function createResult(params) {
198
- const acceptedOffers4result = responseBody2resultAcceptedOffer(params);
199
- // 金額計算
200
- const amount = acceptedOffers2amount({ acceptedOffers: acceptedOffers4result });
201
- return {
202
- typeOf: factory_1.factory.offerType.AggregateOffer,
203
- price: amount,
204
- priceCurrency: factory_1.factory.priceCurrency.JPY,
205
- // requestBody: params.requestBody, // discontinue(2026-03-13~)
206
- // responseBody: params.responseBody // discontinue(2026-03-13~)
207
- };
208
- }
@@ -1,6 +0,0 @@
1
- import type { IOperationExecute } from '../taskHandler';
2
- import { factory } from '../../factory';
3
- /**
4
- * タスク実行関数
5
- */
6
- export declare function call(data: factory.task.IData<factory.taskName.ConfirmRegisterService>): IOperationExecute<void>;
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.call = call;
4
- const action_1 = require("../../repo/action");
5
- const assetTransaction_1 = require("../../repo/assetTransaction");
6
- const task_1 = require("../../repo/task");
7
- const confirmRegisterServiceTransaction_1 = require("./confirmRegisterServiceTransaction");
8
- /**
9
- * タスク実行関数
10
- */
11
- function call(data) {
12
- return async ({ connection }) => {
13
- await (0, confirmRegisterServiceTransaction_1.confirmRegisterServiceTransaction)(data)({
14
- action: new action_1.ActionRepo(connection),
15
- assetTransaction: new assetTransaction_1.AssetTransactionRepo(connection),
16
- task: new task_1.TaskRepo(connection)
17
- });
18
- };
19
- }
@@ -1,17 +0,0 @@
1
- import type { IOperationExecute } from '../taskHandler';
2
- import { factory } from '../../factory';
3
- import { ActionRepo } from '../../repo/action';
4
- import { AssetTransactionRepo } from '../../repo/assetTransaction';
5
- import { TaskRepo } from '../../repo/task';
6
- /**
7
- * タスク実行関数
8
- */
9
- export declare function call(data: factory.task.IData<factory.taskName.ConfirmRegisterServiceTransaction>): IOperationExecute<void>;
10
- export declare function confirmRegisterServiceTransaction(params: factory.action.interact.confirm.registerService.IAttributes): (repos: {
11
- action: ActionRepo;
12
- assetTransaction: AssetTransactionRepo;
13
- task: TaskRepo;
14
- }) => Promise<void>;
15
- export declare function onRegistered(params: factory.action.interact.confirm.registerService.IAttributes): (repos: {
16
- task: TaskRepo;
17
- }) => Promise<void>;
@@ -1,116 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.call = call;
7
- exports.confirmRegisterServiceTransaction = confirmRegisterServiceTransaction;
8
- exports.onRegistered = onRegistered;
9
- const moment_1 = __importDefault(require("moment"));
10
- const factory_1 = require("../../factory");
11
- const action_1 = require("../../repo/action");
12
- const assetTransaction_1 = require("../../repo/assetTransaction");
13
- const task_1 = require("../../repo/task");
14
- const registerService_1 = require("../assetTransaction/registerService");
15
- /**
16
- * タスク実行関数
17
- */
18
- function call(data) {
19
- return async ({ connection }) => {
20
- await confirmRegisterServiceTransaction(data)({
21
- action: new action_1.ActionRepo(connection),
22
- assetTransaction: new assetTransaction_1.AssetTransactionRepo(connection),
23
- task: new task_1.TaskRepo(connection)
24
- });
25
- };
26
- }
27
- function confirmRegisterServiceTransaction(params) {
28
- return async (repos) => {
29
- // アクション開始
30
- const confirmActionAttributes = params;
31
- const action = await repos.action.start(confirmActionAttributes);
32
- try {
33
- let transactionNumber;
34
- const serviceOutputIdentifier = params.object.object?.itemOffered?.serviceOutput?.identifier;
35
- if (typeof serviceOutputIdentifier === 'string') {
36
- // serviceOutput.identifierで資産取引検索
37
- const assetTransactions = await repos.assetTransaction.search({
38
- limit: 1,
39
- page: 1,
40
- typeOf: factory_1.factory.assetTransactionType.RegisterService,
41
- object: { itemOffered: { serviceOutput: { identifier: { $eq: serviceOutputIdentifier } } } }
42
- });
43
- const assetTransaction = assetTransactions.shift();
44
- if (assetTransaction === undefined) {
45
- throw new factory_1.factory.errors.NotFound('AssetTransaction', `AssetTransaction with serviceOutputIdentifier '${serviceOutputIdentifier}' not found`);
46
- }
47
- transactionNumber = assetTransaction.transactionNumber;
48
- }
49
- else if (typeof params.object.transactionNumber === 'string') {
50
- transactionNumber = params.object.transactionNumber;
51
- }
52
- if (typeof transactionNumber === 'string') {
53
- await (0, registerService_1.confirm)({
54
- transactionNumber,
55
- ...(confirmActionAttributes.object.endDate !== undefined)
56
- ? {
57
- endDate: (0, moment_1.default)(confirmActionAttributes.object.endDate)
58
- .toDate()
59
- }
60
- : undefined
61
- })(repos);
62
- }
63
- else {
64
- throw new factory_1.factory.errors.Argument('transactionNumber not specified');
65
- }
66
- }
67
- catch (error) {
68
- try {
69
- await repos.action.giveUp({ typeOf: confirmActionAttributes.typeOf, id: action.id, error });
70
- }
71
- catch (__) {
72
- // 失敗したら仕方ない
73
- }
74
- throw error;
75
- }
76
- // アクション完了
77
- const result = {};
78
- await repos.action.completeWithVoid({ typeOf: confirmActionAttributes.typeOf, id: action.id, result: result });
79
- await onRegistered(confirmActionAttributes)(repos);
80
- };
81
- }
82
- function onRegistered(params) {
83
- return async (repos) => {
84
- const taskAttributes = [];
85
- // タスク保管
86
- await repos.task.saveMany(taskAttributes, { emitImmediately: true });
87
- if (params.purpose.typeOf === factory_1.factory.order.OrderType.Order) {
88
- // タスク冪等作成
89
- const onAssetTransactionStatusChangedTaskData = {
90
- project: { id: params.project.id, typeOf: factory_1.factory.organizationType.Project },
91
- object: {
92
- typeOf: params.object.typeOf,
93
- transactionNumber: params.object.transactionNumber,
94
- status: factory_1.factory.transactionStatusType.Confirmed
95
- },
96
- purpose: {
97
- confirmationNumber: '', // OnAssetTransactionStatusChanged処理内で使用されないので空文字でok
98
- orderNumber: params.purpose.orderNumber,
99
- typeOf: factory_1.factory.order.OrderType.Order
100
- },
101
- useOnOrderStatusChanged: true
102
- };
103
- const onAssetTransactionStatusChangedTask = {
104
- project: { id: params.project.id, typeOf: factory_1.factory.organizationType.Project },
105
- name: factory_1.factory.taskName.OnAssetTransactionStatusChanged,
106
- status: factory_1.factory.taskStatus.Ready,
107
- runsAt: new Date(),
108
- remainingNumberOfTries: 10,
109
- numberOfTried: 0,
110
- executionResults: [],
111
- data: onAssetTransactionStatusChangedTaskData
112
- };
113
- await repos.task.createOnAssetTransactionStatusChangedTaskIfNotExist(onAssetTransactionStatusChangedTask, { emitImmediately: true });
114
- }
115
- };
116
- }
@@ -1,6 +0,0 @@
1
- import type { IOperationExecute } from '../taskHandler';
2
- import { factory } from '../../factory';
3
- /**
4
- * タスク実行関数
5
- */
6
- export declare function call(data: factory.task.IData<factory.taskName.VoidRegisterServiceTransaction>): IOperationExecute<void>;
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.call = call;
4
- // import { ActionRepo } from '../../repo/action';
5
- const authorizeProductOffer_1 = require("../../repo/action/authorizeProductOffer");
6
- const assetTransaction_1 = require("../../repo/assetTransaction");
7
- const placeOrder_1 = require("../../repo/transaction/placeOrder");
8
- const product_1 = require("../offer/product");
9
- /**
10
- * タスク実行関数
11
- */
12
- function call(data) {
13
- return async ({ connection }) => {
14
- // const actionRepo = new ActionRepo(connection);
15
- const assetTransactionRepo = new assetTransaction_1.AssetTransactionRepo(connection);
16
- const placeOrderRepo = new placeOrder_1.PlaceOrderRepo(connection);
17
- await (0, product_1.voidTransaction)(data)({
18
- authorizeProductOfferAction: new authorizeProductOffer_1.AuthorizeProductOfferActionRepo(connection),
19
- assetTransaction: assetTransactionRepo,
20
- placeOrder: placeOrderRepo
21
- });
22
- };
23
- }