@chevre/domain 24.0.0-alpha.77 → 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.
- package/lib/chevre/repo/action/actionProcess.d.ts +4 -4
- package/lib/chevre/repo/action/authorizeOffer.d.ts +2 -3
- package/lib/chevre/repo/action/authorizeOffer.js +2 -2
- package/lib/chevre/repo/action.d.ts +2 -2
- package/lib/chevre/repo/assetTransaction.d.ts +3 -51
- package/lib/chevre/repo/assetTransaction.js +51 -51
- package/lib/chevre/repo/mongoose/schemas/assetTransaction.d.ts +1 -1
- package/lib/chevre/repo/product.d.ts +0 -10
- package/lib/chevre/repo/product.js +28 -22
- package/lib/chevre/repo/task.d.ts +1 -1
- package/lib/chevre/repository.d.ts +0 -5
- package/lib/chevre/repository.js +0 -11
- package/lib/chevre/service/assetTransaction/pay/publishPaymentUrl.js +1 -1
- package/lib/chevre/service/assetTransaction/pay/start/factory.js +7 -7
- package/lib/chevre/service/assetTransaction/pay/start/preStart/fixPaymentService.js +18 -16
- package/lib/chevre/service/assetTransaction/refund.js +19 -17
- package/lib/chevre/service/assetTransaction/reserve/start.js +8 -8
- package/lib/chevre/service/assetTransaction.d.ts +0 -2
- package/lib/chevre/service/assetTransaction.js +8 -10
- package/lib/chevre/service/delivery/factory.js +13 -13
- package/lib/chevre/service/offer/any.d.ts +1 -1
- package/lib/chevre/service/offer/event/authorize.js +7 -32
- package/lib/chevre/service/offer/product.d.ts +0 -62
- package/lib/chevre/service/offer/product.js +0 -409
- package/lib/chevre/service/order/onAssetTransactionStatusChanged/isDeliverable.d.ts +1 -1
- package/lib/chevre/service/order/onAssetTransactionStatusChanged/isDeliverable.js +48 -43
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +38 -37
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/processOrder.js +2 -96
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.js +18 -15
- package/lib/chevre/service/order/placeOrder/factory/orderedItem.d.ts +0 -1
- package/lib/chevre/service/order/placeOrder/factory/orderedItem.js +3 -28
- package/lib/chevre/service/order/placeOrder/factory.js +5 -5
- package/lib/chevre/service/payment/factory/createPayObjectServiceOutput.js +1 -1
- package/lib/chevre/service/payment/factory.js +23 -23
- package/lib/chevre/service/product.js +16 -16
- package/lib/chevre/service/reserve/confirmReservation.js +19 -17
- package/lib/chevre/service/reserve/factory.d.ts +0 -6
- package/lib/chevre/service/reserve/factory.js +0 -59
- package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +16 -15
- package/lib/chevre/service/transaction/placeOrder/confirm/validation/factory.d.ts +0 -1
- package/lib/chevre/service/transaction/placeOrder/confirm/validation/validatePrice.d.ts +2 -2
- package/lib/chevre/service/transaction/placeOrder/confirm/validation/validatePrice.js +2 -2
- package/lib/chevre/service/transaction/placeOrder/confirm/validation.d.ts +3 -3
- package/lib/chevre/service/transaction/placeOrder/confirm/validation.js +16 -12
- package/lib/chevre/service/transaction/placeOrder/confirm.js +21 -23
- package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +0 -21
- package/lib/chevre/service/transaction/returnOrder/potentialActions.js +4 -4
- package/lib/chevre/service/validation/validateOrder.js +11 -10
- package/package.json +2 -2
- package/lib/chevre/repo/action/authorizeProductOffer.d.ts +0 -26
- package/lib/chevre/repo/action/authorizeProductOffer.js +0 -32
- package/lib/chevre/service/assetTransaction/registerService/factory.d.ts +0 -21
- package/lib/chevre/service/assetTransaction/registerService/factory.js +0 -171
- package/lib/chevre/service/assetTransaction/registerService/potentialActions.d.ts +0 -8
- package/lib/chevre/service/assetTransaction/registerService/potentialActions.js +0 -148
- package/lib/chevre/service/assetTransaction/registerService.d.ts +0 -54
- package/lib/chevre/service/assetTransaction/registerService.js +0 -273
- package/lib/chevre/service/assetTransaction/reserve/start/factory/createPointAward.d.ts +0 -15
- package/lib/chevre/service/assetTransaction/reserve/start/factory/createPointAward.js +0 -44
- package/lib/chevre/service/delivery/product/factory.d.ts +0 -13
- package/lib/chevre/service/delivery/product/factory.js +0 -81
- package/lib/chevre/service/offer/product/factory.d.ts +0 -37
- package/lib/chevre/service/offer/product/factory.js +0 -208
- package/lib/chevre/service/task/confirmRegisterService.d.ts +0 -6
- package/lib/chevre/service/task/confirmRegisterService.js +0 -19
- package/lib/chevre/service/task/confirmRegisterServiceTransaction.d.ts +0 -17
- package/lib/chevre/service/task/confirmRegisterServiceTransaction.js +0 -116
- package/lib/chevre/service/task/voidRegisterServiceTransaction.d.ts +0 -6
- package/lib/chevre/service/task/voidRegisterServiceTransaction.js +0 -23
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPointAward.d.ts +0 -8
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPointAward.js +0 -89
|
@@ -1,148 +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.createPotentialActions = createPotentialActions;
|
|
7
|
-
const moment_1 = __importDefault(require("moment"));
|
|
8
|
-
const factory_1 = require("../../../factory");
|
|
9
|
-
const MAX_VALID_UNTIL = '3000-01-01T00:00:00Z';
|
|
10
|
-
function createMoneyTransferActions(__) {
|
|
11
|
-
return [];
|
|
12
|
-
// const transaction = params.transaction;
|
|
13
|
-
// const serviceOutputs = transaction.object.map((o) => o.itemOffered.serviceOutput);
|
|
14
|
-
// return serviceOutputs
|
|
15
|
-
// .filter((serviceOutput: any) => serviceOutput.typeOf === 'MoneyTransfer')
|
|
16
|
-
// .map((serviceOutput: any) => {
|
|
17
|
-
// return {
|
|
18
|
-
// project: transaction.project,
|
|
19
|
-
// typeOf: factory.actionType.MoneyTransfer,
|
|
20
|
-
// description: transaction.object.description,
|
|
21
|
-
// result: {
|
|
22
|
-
// amount: serviceOutput.amount
|
|
23
|
-
// },
|
|
24
|
-
// object: {
|
|
25
|
-
// pendingTransaction: {
|
|
26
|
-
// typeOf: factory.assetTransactionType.Deposit,
|
|
27
|
-
// transactionNumber: transaction.transactionNumber
|
|
28
|
-
// }
|
|
29
|
-
// },
|
|
30
|
-
// agent: transaction.agent,
|
|
31
|
-
// recipient: transaction.recipient,
|
|
32
|
-
// amount: serviceOutput.amount,
|
|
33
|
-
// toLocation: serviceOutput.toLocation,
|
|
34
|
-
// purpose: {
|
|
35
|
-
// typeOf: transaction.typeOf,
|
|
36
|
-
// id: transaction.id
|
|
37
|
-
// }
|
|
38
|
-
// };
|
|
39
|
-
// });
|
|
40
|
-
}
|
|
41
|
-
function createRegisterServiceActions(params) {
|
|
42
|
-
const validFrom = (params.endDate instanceof Date) ? params.endDate : new Date();
|
|
43
|
-
return params.transaction.object.map((o) => {
|
|
44
|
-
const pointAward = o.itemOffered.pointAward;
|
|
45
|
-
const serviceOutput = o.itemOffered.serviceOutput;
|
|
46
|
-
// validFor:undefinedに対応
|
|
47
|
-
let validUntil;
|
|
48
|
-
if (typeof serviceOutput?.validFor === 'string') {
|
|
49
|
-
// オファーの単価単位で有効期限を決定
|
|
50
|
-
validUntil = (0, moment_1.default)(validFrom)
|
|
51
|
-
.add(moment_1.default.duration(serviceOutput.validFor))
|
|
52
|
-
.toDate();
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
validUntil = (0, moment_1.default)(MAX_VALID_UNTIL)
|
|
56
|
-
.toDate();
|
|
57
|
-
}
|
|
58
|
-
const moneyTransfer = [];
|
|
59
|
-
// ポイント特典があれば適用
|
|
60
|
-
const pointAwardToLocationIdentifier = pointAward?.toLocation?.identifier;
|
|
61
|
-
const pointAwardToLocationTypeOf = pointAward?.toLocation?.typeOf;
|
|
62
|
-
if (typeof pointAward?.amount?.value === 'number'
|
|
63
|
-
&& typeof pointAwardToLocationIdentifier === 'string'
|
|
64
|
-
&& typeof pointAwardToLocationTypeOf === 'string') {
|
|
65
|
-
const fromLocation = {
|
|
66
|
-
typeOf: (typeof serviceOutput?.issuedBy?.typeOf === 'string')
|
|
67
|
-
? serviceOutput?.issuedBy?.typeOf
|
|
68
|
-
: params.transaction.typeOf,
|
|
69
|
-
name: (serviceOutput?.issuedBy?.name !== undefined)
|
|
70
|
-
? (typeof serviceOutput?.issuedBy?.name === 'string')
|
|
71
|
-
? serviceOutput?.issuedBy?.name
|
|
72
|
-
: serviceOutput?.issuedBy?.name.ja
|
|
73
|
-
: params.transaction.id
|
|
74
|
-
};
|
|
75
|
-
const toLocation = {
|
|
76
|
-
identifier: pointAwardToLocationIdentifier,
|
|
77
|
-
typeOf: factory_1.factory.permit.PermitType.Permit,
|
|
78
|
-
issuedThrough: { id: String(pointAward.toLocation?.issuedThrough?.id) }
|
|
79
|
-
};
|
|
80
|
-
const recipient = {
|
|
81
|
-
typeOf: factory_1.factory.personType.Person,
|
|
82
|
-
id: '',
|
|
83
|
-
name: String(fromLocation)
|
|
84
|
-
};
|
|
85
|
-
moneyTransfer.push({
|
|
86
|
-
project: params.transaction.project,
|
|
87
|
-
typeOf: factory_1.factory.actionType.MoneyTransfer,
|
|
88
|
-
agent: params.transaction.project,
|
|
89
|
-
recipient,
|
|
90
|
-
object: {
|
|
91
|
-
typeOf: factory_1.factory.account.transactionType.Deposit
|
|
92
|
-
},
|
|
93
|
-
purpose: {
|
|
94
|
-
typeOf: params.transaction.typeOf,
|
|
95
|
-
id: params.transaction.id,
|
|
96
|
-
// 入金取引に識別子を指定する
|
|
97
|
-
...(typeof pointAward.purpose?.identifier === 'string') ? { identifier: pointAward.purpose.identifier } : undefined
|
|
98
|
-
},
|
|
99
|
-
amount: {
|
|
100
|
-
typeOf: 'MonetaryAmount',
|
|
101
|
-
value: pointAward.amount?.value,
|
|
102
|
-
currency: pointAward.amount?.currency
|
|
103
|
-
},
|
|
104
|
-
fromLocation: fromLocation,
|
|
105
|
-
toLocation: toLocation,
|
|
106
|
-
...(typeof pointAward.description === 'string') ? { description: pointAward.description } : undefined,
|
|
107
|
-
...(pointAward.recipient !== undefined) ? { recipient: pointAward.recipient } : undefined
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
const object = {
|
|
111
|
-
...serviceOutput,
|
|
112
|
-
validFrom: validFrom,
|
|
113
|
-
validUntil: validUntil
|
|
114
|
-
};
|
|
115
|
-
return {
|
|
116
|
-
project: params.transaction.project,
|
|
117
|
-
typeOf: factory_1.factory.actionType.RegisterAction,
|
|
118
|
-
result: {},
|
|
119
|
-
object,
|
|
120
|
-
// プロジェクトに変更(2022-05-26~)
|
|
121
|
-
// agent: <factory.creativeWork.softwareApplication.webApplication.ICreativeWork | factory.person.IPerson>params.transaction.agent,
|
|
122
|
-
agent: params.transaction.project,
|
|
123
|
-
potentialActions: {
|
|
124
|
-
moneyTransfer: moneyTransfer
|
|
125
|
-
},
|
|
126
|
-
purpose: {
|
|
127
|
-
typeOf: params.transaction.typeOf,
|
|
128
|
-
id: params.transaction.id
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* 取引のポストアクションを作成する
|
|
135
|
-
*/
|
|
136
|
-
async function createPotentialActions(params) {
|
|
137
|
-
// 通貨転送アクション属性作成
|
|
138
|
-
const moneyTransferActionAttributesList = createMoneyTransferActions(params);
|
|
139
|
-
// まずは1転送アクションのみ対応
|
|
140
|
-
if (moneyTransferActionAttributesList.length > 1) {
|
|
141
|
-
throw new factory_1.factory.errors.Argument('Transaction', 'Number of moneyTransfer actions must be 1');
|
|
142
|
-
}
|
|
143
|
-
const registerServiceActionAttributes = createRegisterServiceActions(params);
|
|
144
|
-
return {
|
|
145
|
-
moneyTransfer: moneyTransferActionAttributesList,
|
|
146
|
-
registerService: registerServiceActionAttributes
|
|
147
|
-
};
|
|
148
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* サービス登録取引サービス
|
|
3
|
-
*/
|
|
4
|
-
import { factory } from '../../factory';
|
|
5
|
-
import type { AccountRepo } from '../../repo/account';
|
|
6
|
-
import type { AssetTransactionRepo } from '../../repo/assetTransaction';
|
|
7
|
-
import type { OfferRepo } from '../../repo/offer/unitPriceInCatalog';
|
|
8
|
-
import type { OfferCatalogRepo } from '../../repo/offerCatalog';
|
|
9
|
-
import type { ProductRepo } from '../../repo/product';
|
|
10
|
-
import type { ProjectRepo } from '../../repo/project';
|
|
11
|
-
import type { ServiceOutputRepo } from '../../repo/serviceOutput';
|
|
12
|
-
import type { TaskRepo } from '../../repo/task';
|
|
13
|
-
export type IStartOperation<T> = (repos: {
|
|
14
|
-
account: AccountRepo;
|
|
15
|
-
offer: OfferRepo;
|
|
16
|
-
offerCatalog: OfferCatalogRepo;
|
|
17
|
-
product: ProductRepo;
|
|
18
|
-
serviceOutput: ServiceOutputRepo;
|
|
19
|
-
project: ProjectRepo;
|
|
20
|
-
assetTransaction: AssetTransactionRepo;
|
|
21
|
-
}) => Promise<T>;
|
|
22
|
-
export type ICancelOperation<T> = (repos: {
|
|
23
|
-
assetTransaction: AssetTransactionRepo;
|
|
24
|
-
}) => Promise<T>;
|
|
25
|
-
export type IConfirmOperation<T> = (repos: {
|
|
26
|
-
assetTransaction: AssetTransactionRepo;
|
|
27
|
-
}) => Promise<T>;
|
|
28
|
-
export type IExportTasksOperation<T> = (repos: {
|
|
29
|
-
task: TaskRepo;
|
|
30
|
-
assetTransaction: AssetTransactionRepo;
|
|
31
|
-
}) => Promise<T>;
|
|
32
|
-
/**
|
|
33
|
-
* 取引開始
|
|
34
|
-
*/
|
|
35
|
-
export declare function start(params: factory.assetTransaction.registerService.IStartParamsWithoutDetail): IStartOperation<factory.assetTransaction.ITransaction<factory.assetTransactionType.RegisterService>>;
|
|
36
|
-
/**
|
|
37
|
-
* 取引確定
|
|
38
|
-
*/
|
|
39
|
-
export declare function confirm(params: factory.assetTransaction.registerService.IConfirmParams): IConfirmOperation<void>;
|
|
40
|
-
/**
|
|
41
|
-
* 取引中止
|
|
42
|
-
*/
|
|
43
|
-
export declare function cancel(params: {
|
|
44
|
-
id?: string;
|
|
45
|
-
transactionNumber?: string;
|
|
46
|
-
}): ICancelOperation<void>;
|
|
47
|
-
/**
|
|
48
|
-
* 取引タスク出力
|
|
49
|
-
*/
|
|
50
|
-
export declare function exportTasksById(params: {
|
|
51
|
-
id: string;
|
|
52
|
-
}): IExportTasksOperation<{
|
|
53
|
-
id: string;
|
|
54
|
-
}[]>;
|
|
@@ -1,273 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.start = start;
|
|
37
|
-
exports.confirm = confirm;
|
|
38
|
-
exports.cancel = cancel;
|
|
39
|
-
exports.exportTasksById = exportTasksById;
|
|
40
|
-
/**
|
|
41
|
-
* サービス登録取引サービス
|
|
42
|
-
*/
|
|
43
|
-
const factory_1 = require("../../factory");
|
|
44
|
-
const searchProductOffers_1 = require("../offer/product/searchProductOffers");
|
|
45
|
-
const factory_2 = require("./registerService/factory");
|
|
46
|
-
const potentialActions_1 = require("./registerService/potentialActions");
|
|
47
|
-
// import * as AccountService from '../account';
|
|
48
|
-
const PermitService = __importStar(require("../permit"));
|
|
49
|
-
/**
|
|
50
|
-
* 取引開始
|
|
51
|
-
*/
|
|
52
|
-
function start(params) {
|
|
53
|
-
return async (repos) => {
|
|
54
|
-
const project = await repos.project.findById({
|
|
55
|
-
id: params.project.id,
|
|
56
|
-
inclusion: ['typeOf']
|
|
57
|
-
});
|
|
58
|
-
// objectはオファー
|
|
59
|
-
let acceptedOffers = params.object;
|
|
60
|
-
if (!Array.isArray(acceptedOffers)) {
|
|
61
|
-
acceptedOffers = [acceptedOffers];
|
|
62
|
-
}
|
|
63
|
-
const productIds = [...new Set(acceptedOffers.map((o) => String(o.itemOffered.id)))];
|
|
64
|
-
if (productIds.length !== 1) {
|
|
65
|
-
throw new factory_1.factory.errors.Argument('object.itemOffered.id', 'Number of product ID must be 1');
|
|
66
|
-
}
|
|
67
|
-
const productId = productIds[0];
|
|
68
|
-
if (typeof productId !== 'string') {
|
|
69
|
-
throw new factory_1.factory.errors.ArgumentNull('object.itemOffered.id');
|
|
70
|
-
}
|
|
71
|
-
// プロダクト確認
|
|
72
|
-
const product = (await repos.product.projectFields({
|
|
73
|
-
limit: 1,
|
|
74
|
-
page: 1,
|
|
75
|
-
id: { $eq: productId }
|
|
76
|
-
}, ['id', 'project', 'serviceOutput', 'serviceType', 'typeOf']
|
|
77
|
-
// []
|
|
78
|
-
)).shift();
|
|
79
|
-
if (product === undefined) {
|
|
80
|
-
throw new factory_1.factory.errors.NotFound('Product');
|
|
81
|
-
}
|
|
82
|
-
if (product.typeOf !== factory_1.factory.product.ProductType.MembershipService
|
|
83
|
-
&& product.typeOf !== factory_1.factory.product.ProductType.PaymentCard) {
|
|
84
|
-
throw new factory_1.factory.errors.Argument('object.itemOffered.id', `invalid product type: ${product.typeOf}`);
|
|
85
|
-
}
|
|
86
|
-
const transactionNumber = params.transactionNumber;
|
|
87
|
-
if (typeof transactionNumber !== 'string' || transactionNumber.length === 0) {
|
|
88
|
-
throw new factory_1.factory.errors.ArgumentNull('transactionNumber');
|
|
89
|
-
}
|
|
90
|
-
// サービスアウトプット作成
|
|
91
|
-
const dateIssued = new Date();
|
|
92
|
-
const transactionObject = await createTransactionObject({
|
|
93
|
-
acceptedOffers,
|
|
94
|
-
dateIssued,
|
|
95
|
-
product,
|
|
96
|
-
project: { id: project.id },
|
|
97
|
-
transactionNumber
|
|
98
|
-
})(repos);
|
|
99
|
-
// 取引開始
|
|
100
|
-
const startParams = {
|
|
101
|
-
project: { typeOf: project.typeOf, id: project.id },
|
|
102
|
-
typeOf: factory_1.factory.assetTransactionType.RegisterService,
|
|
103
|
-
agent: params.agent,
|
|
104
|
-
object: transactionObject,
|
|
105
|
-
expires: params.expires,
|
|
106
|
-
transactionNumber: transactionNumber
|
|
107
|
-
};
|
|
108
|
-
// 取引作成
|
|
109
|
-
const transaction = await repos.assetTransaction.start(startParams);
|
|
110
|
-
// 必要あれば在庫確認など
|
|
111
|
-
const serviceOutputs = transactionObject.map((o) => o.itemOffered?.serviceOutput);
|
|
112
|
-
// サービスアウトプット保管
|
|
113
|
-
await PermitService.issue({
|
|
114
|
-
project: { id: project.id },
|
|
115
|
-
issuedThrough: { typeOf: product.typeOf },
|
|
116
|
-
serviceOutputs
|
|
117
|
-
})(repos);
|
|
118
|
-
return transaction;
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
function createTransactionObject(params) {
|
|
122
|
-
return async (repos) => {
|
|
123
|
-
// オファー検索
|
|
124
|
-
const offers = await (0, searchProductOffers_1.searchProductOffers)({
|
|
125
|
-
ids: params.acceptedOffers.map((o) => o.id),
|
|
126
|
-
itemOffered: { id: String(params.product.id) },
|
|
127
|
-
onlyValid: true,
|
|
128
|
-
includedInDataCatalog: { id: '' }, // 承認時はカタログ指定の必要なし
|
|
129
|
-
addSortIndex: false,
|
|
130
|
-
useIncludeInDataCatalog: false
|
|
131
|
-
})(repos);
|
|
132
|
-
const transactionObject = [];
|
|
133
|
-
for (const acceptedOffer of params.acceptedOffers) {
|
|
134
|
-
const offer = offers.find((o) => o.id === acceptedOffer.id);
|
|
135
|
-
if (offer === undefined) {
|
|
136
|
-
throw new factory_1.factory.errors.NotFound('Offer', `Offer ${acceptedOffer.id} not found`);
|
|
137
|
-
}
|
|
138
|
-
// discontinue(2026-04-17~)
|
|
139
|
-
// await validatePointAward({ project: { id: params.project.id }, acceptedOffer })(repos);
|
|
140
|
-
const pointAward = (0, factory_2.createPointAward)({
|
|
141
|
-
acceptedOffer: acceptedOffer,
|
|
142
|
-
offer: offer
|
|
143
|
-
});
|
|
144
|
-
const serviceOutput = (0, factory_2.createServiceOutput)({
|
|
145
|
-
dateIssued: params.dateIssued,
|
|
146
|
-
product: params.product,
|
|
147
|
-
acceptedOffer: acceptedOffer,
|
|
148
|
-
offer: offer,
|
|
149
|
-
transactionNumber: params.transactionNumber
|
|
150
|
-
});
|
|
151
|
-
transactionObject.push({
|
|
152
|
-
typeOf: factory_1.factory.offerType.Offer,
|
|
153
|
-
id: String(offer.id),
|
|
154
|
-
itemOffered: {
|
|
155
|
-
// project: params.product.project,
|
|
156
|
-
typeOf: params.product.typeOf,
|
|
157
|
-
id: String(params.product.id),
|
|
158
|
-
serviceOutput: serviceOutput,
|
|
159
|
-
...(pointAward !== undefined) ? { pointAward } : undefined
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
return transactionObject;
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* 取引確定
|
|
168
|
-
*/
|
|
169
|
-
function confirm(params) {
|
|
170
|
-
return async (repos) => {
|
|
171
|
-
let transaction;
|
|
172
|
-
// 取引存在確認
|
|
173
|
-
if (typeof params.id === 'string') {
|
|
174
|
-
transaction = await repos.assetTransaction.findById({
|
|
175
|
-
typeOf: factory_1.factory.assetTransactionType.RegisterService,
|
|
176
|
-
id: params.id
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
else if (typeof params.transactionNumber === 'string') {
|
|
180
|
-
transaction = await repos.assetTransaction.findByTransactionNumber({
|
|
181
|
-
typeOf: factory_1.factory.assetTransactionType.RegisterService,
|
|
182
|
-
transactionNumber: params.transactionNumber
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
else {
|
|
186
|
-
throw new factory_1.factory.errors.ArgumentNull('Transaction ID or Transaction Number');
|
|
187
|
-
}
|
|
188
|
-
const potentialActions = await (0, potentialActions_1.createPotentialActions)({
|
|
189
|
-
transaction: transaction,
|
|
190
|
-
endDate: params.endDate
|
|
191
|
-
});
|
|
192
|
-
// 取引確定
|
|
193
|
-
const result = {};
|
|
194
|
-
await repos.assetTransaction.confirm({
|
|
195
|
-
typeOf: factory_1.factory.assetTransactionType.RegisterService,
|
|
196
|
-
id: transaction.id,
|
|
197
|
-
result: result,
|
|
198
|
-
potentialActions: potentialActions
|
|
199
|
-
});
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
* 取引中止
|
|
204
|
-
*/
|
|
205
|
-
function cancel(params) {
|
|
206
|
-
return async (repos) => {
|
|
207
|
-
await repos.assetTransaction.cancel({
|
|
208
|
-
typeOf: factory_1.factory.assetTransactionType.RegisterService,
|
|
209
|
-
id: params.id,
|
|
210
|
-
transactionNumber: params.transactionNumber
|
|
211
|
-
});
|
|
212
|
-
};
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* 取引タスク出力
|
|
216
|
-
*/
|
|
217
|
-
function exportTasksById(params) {
|
|
218
|
-
return async (repos) => {
|
|
219
|
-
const transaction = await repos.assetTransaction.findById({
|
|
220
|
-
typeOf: factory_1.factory.assetTransactionType.RegisterService,
|
|
221
|
-
id: params.id
|
|
222
|
-
});
|
|
223
|
-
const potentialActions = transaction.potentialActions;
|
|
224
|
-
const taskAttributes = [];
|
|
225
|
-
const taskRunsAt = new Date();
|
|
226
|
-
switch (transaction.status) {
|
|
227
|
-
case factory_1.factory.transactionStatusType.Confirmed:
|
|
228
|
-
/* istanbul ignore else */
|
|
229
|
-
if (potentialActions !== undefined) {
|
|
230
|
-
/* istanbul ignore else */
|
|
231
|
-
if (Array.isArray(potentialActions.registerService)
|
|
232
|
-
&& potentialActions.registerService.length > 0) {
|
|
233
|
-
const registerServiceTask = {
|
|
234
|
-
project: transaction.project,
|
|
235
|
-
name: factory_1.factory.taskName.RegisterService,
|
|
236
|
-
status: factory_1.factory.taskStatus.Ready,
|
|
237
|
-
runsAt: taskRunsAt, // なるはやで実行
|
|
238
|
-
remainingNumberOfTries: 10,
|
|
239
|
-
numberOfTried: 0,
|
|
240
|
-
executionResults: [],
|
|
241
|
-
data: potentialActions.registerService
|
|
242
|
-
};
|
|
243
|
-
taskAttributes.push(registerServiceTask);
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
/* istanbul ignore else */
|
|
247
|
-
if (potentialActions !== undefined) {
|
|
248
|
-
/* istanbul ignore else */
|
|
249
|
-
if (potentialActions.moneyTransfer !== undefined) {
|
|
250
|
-
taskAttributes.push(...potentialActions.moneyTransfer.map((a) => {
|
|
251
|
-
return {
|
|
252
|
-
project: transaction.project,
|
|
253
|
-
name: factory_1.factory.taskName.MoneyTransfer,
|
|
254
|
-
status: factory_1.factory.taskStatus.Ready,
|
|
255
|
-
runsAt: taskRunsAt,
|
|
256
|
-
remainingNumberOfTries: 10,
|
|
257
|
-
numberOfTried: 0,
|
|
258
|
-
executionResults: [],
|
|
259
|
-
data: a
|
|
260
|
-
};
|
|
261
|
-
}));
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
break;
|
|
265
|
-
case factory_1.factory.transactionStatusType.Canceled:
|
|
266
|
-
case factory_1.factory.transactionStatusType.Expired:
|
|
267
|
-
break;
|
|
268
|
-
default:
|
|
269
|
-
throw new factory_1.factory.errors.NotImplemented(`Transaction status "${transaction.status}" not implemented.`);
|
|
270
|
-
}
|
|
271
|
-
return repos.task.saveMany(taskAttributes, { emitImmediately: true });
|
|
272
|
-
};
|
|
273
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { factory } from '../../../../../factory';
|
|
2
|
-
/**
|
|
3
|
-
* ポイント特典を作成する
|
|
4
|
-
*/
|
|
5
|
-
declare function createPointAward(params: {
|
|
6
|
-
acceptedOffer: factory.assetTransaction.reserve.IAcceptedTicketOfferWithoutDetail;
|
|
7
|
-
offer: factory.product.ITicketOffer;
|
|
8
|
-
reservation: {
|
|
9
|
-
id: string;
|
|
10
|
-
};
|
|
11
|
-
project: {
|
|
12
|
-
id: string;
|
|
13
|
-
};
|
|
14
|
-
}): factory.action.transfer.moneyTransfer.IPointAward | undefined;
|
|
15
|
-
export { createPointAward };
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createPointAward = createPointAward;
|
|
4
|
-
const factory_1 = require("../../../../../factory");
|
|
5
|
-
const accountTransactionIdentifier_1 = require("../../../../../factory/accountTransactionIdentifier");
|
|
6
|
-
/**
|
|
7
|
-
* ポイント特典を作成する
|
|
8
|
-
*/
|
|
9
|
-
function createPointAward(params) {
|
|
10
|
-
let pointAward;
|
|
11
|
-
const pointAwardAmount = params.offer.itemOffered?.pointAward?.amount;
|
|
12
|
-
const pointAwardDescription = params.offer.itemOffered?.pointAward?.description;
|
|
13
|
-
const pointAwardToLocationIdentifier = params.acceptedOffer.itemOffered?.pointAward?.toLocation?.identifier;
|
|
14
|
-
const pointAwardToLocationIssuedThroughId = params.acceptedOffer.itemOffered?.pointAward?.toLocation?.issuedThrough.id;
|
|
15
|
-
const pointAwardRecipient = params.acceptedOffer.itemOffered?.pointAward?.recipient;
|
|
16
|
-
// const pointAwardPurposeIdentifier = params.acceptedOffer.itemOffered?.pointAward?.purpose?.identifier;
|
|
17
|
-
// オファーのpointAward設定が適切にされていれば、指定されたtoLocationを反映する
|
|
18
|
-
if (typeof pointAwardAmount?.value === 'number'
|
|
19
|
-
&& typeof pointAwardAmount?.currency === 'string'
|
|
20
|
-
&& typeof pointAwardToLocationIdentifier === 'string'
|
|
21
|
-
&& typeof pointAwardToLocationIssuedThroughId === 'string') {
|
|
22
|
-
// ここで識別子を作成する(入金のユニークネスが保証される)
|
|
23
|
-
const purposeIdentifier = (0, accountTransactionIdentifier_1.createPointAwardPurposeIdentifier4reservation)({
|
|
24
|
-
assetTransaction: { typeOf: factory_1.factory.assetTransactionType.Reserve },
|
|
25
|
-
project: { id: params.project.id },
|
|
26
|
-
reservation: { id: params.reservation.id },
|
|
27
|
-
toLocation: { identifier: pointAwardToLocationIdentifier }
|
|
28
|
-
});
|
|
29
|
-
pointAward = {
|
|
30
|
-
amount: pointAwardAmount,
|
|
31
|
-
purpose: { identifier: purposeIdentifier },
|
|
32
|
-
toLocation: {
|
|
33
|
-
typeOf: factory_1.factory.permit.PermitType.Permit,
|
|
34
|
-
identifier: pointAwardToLocationIdentifier,
|
|
35
|
-
issuedThrough: { id: pointAwardToLocationIssuedThroughId }
|
|
36
|
-
},
|
|
37
|
-
typeOf: factory_1.factory.actionType.MoneyTransfer,
|
|
38
|
-
...(typeof pointAwardDescription === 'string') ? { description: pointAwardDescription } : undefined,
|
|
39
|
-
...(pointAwardRecipient !== undefined) ? { recipient: pointAwardRecipient } : undefined
|
|
40
|
-
// ...(typeof pointAwardPurposeIdentifier === 'string') ? { purpose: { identifier: pointAwardPurposeIdentifier } } : undefined
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
return pointAward;
|
|
44
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { factory } from '../../../factory';
|
|
2
|
-
export type IOwnershipInfo = factory.ownershipInfo.IOwnershipInfo<factory.ownershipInfo.IPermitAsGood>;
|
|
3
|
-
export declare function createProductOwnershipInfo(params: {
|
|
4
|
-
project: {
|
|
5
|
-
typeOf: factory.organizationType.Project;
|
|
6
|
-
id: string;
|
|
7
|
-
};
|
|
8
|
-
ownedBy: factory.ownershipInfo.IOwner[];
|
|
9
|
-
acceptedOffer: factory.order.IAcceptedOffer<factory.order.IPermit>;
|
|
10
|
-
ownedFrom: Date;
|
|
11
|
-
identifier: string;
|
|
12
|
-
acquiredFrom: factory.ownershipInfo.IAcquiredFrom;
|
|
13
|
-
}): IOwnershipInfo;
|
|
@@ -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 {};
|