@chevre/domain 24.0.0-alpha.32 → 24.0.0-alpha.33
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/factory/transaction.d.ts +0 -3
- package/lib/chevre/repo/action/actionProcess.d.ts +1 -1
- package/lib/chevre/repo/action.d.ts +1 -1
- package/lib/chevre/repo/mongoose/schemas/transaction.d.ts +1 -2
- package/lib/chevre/repo/passport.d.ts +1 -1
- package/lib/chevre/repo/task.d.ts +1 -1
- package/lib/chevre/repo/transaction.d.ts +1 -39
- package/lib/chevre/repository.d.ts +0 -10
- package/lib/chevre/repository.js +0 -22
- package/lib/chevre/service/delivery/factory.js +4 -4
- package/lib/chevre/service/offer/any.d.ts +1 -1
- package/lib/chevre/service/offer.d.ts +1 -2
- package/lib/chevre/service/offer.js +1 -3
- 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 +54 -36
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned.js +78 -64
- package/lib/chevre/service/order/placeOrder/factory/orderedItem.d.ts +0 -1
- package/lib/chevre/service/order/placeOrder/factory/orderedItem.js +3 -8
- package/lib/chevre/service/order/placeOrder/factory.js +5 -5
- package/lib/chevre/service/task/deletePerson.js +0 -1
- package/lib/chevre/service/task/deleteTransaction.js +0 -2
- package/lib/chevre/service/transaction/deleteTransaction.d.ts +0 -2
- package/lib/chevre/service/transaction/deleteTransaction.js +2 -47
- 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 -3
- package/lib/chevre/service/transaction/placeOrder/confirm/validation.d.ts +3 -3
- package/lib/chevre/service/transaction/placeOrder/confirm/validation.js +2 -2
- package/lib/chevre/service/transaction/placeOrder/confirm.js +12 -17
- package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +1 -15
- package/lib/chevre/service/transaction.d.ts +0 -4
- package/lib/chevre/service/transaction.js +1 -11
- package/lib/chevre/service/validation/validateOrder.js +2 -2
- package/package.json +3 -3
- package/lib/chevre/repo/action/authorizeMoneyTransferOffer.d.ts +0 -40
- package/lib/chevre/repo/action/authorizeMoneyTransferOffer.js +0 -61
- package/lib/chevre/repo/transaction/moneyTransfer.d.ts +0 -61
- package/lib/chevre/repo/transaction/moneyTransfer.js +0 -379
- package/lib/chevre/service/offer/moneyTransfer/authorize.d.ts +0 -38
- package/lib/chevre/service/offer/moneyTransfer/authorize.js +0 -250
- package/lib/chevre/service/offer/moneyTransfer/returnMoneyTransfer.d.ts +0 -16
- package/lib/chevre/service/offer/moneyTransfer/returnMoneyTransfer.js +0 -96
- package/lib/chevre/service/offer/moneyTransfer/settleTransaction.d.ts +0 -9
- package/lib/chevre/service/offer/moneyTransfer/settleTransaction.js +0 -91
- package/lib/chevre/service/offer/moneyTransfer/voidTransaction.d.ts +0 -10
- package/lib/chevre/service/offer/moneyTransfer/voidTransaction.js +0 -81
- package/lib/chevre/service/offer/moneyTransfer.d.ts +0 -5
- package/lib/chevre/service/offer/moneyTransfer.js +0 -11
- package/lib/chevre/service/task/confirmMoneyTransfer.d.ts +0 -6
- package/lib/chevre/service/task/confirmMoneyTransfer.js +0 -19
- package/lib/chevre/service/task/returnMoneyTransfer.d.ts +0 -6
- package/lib/chevre/service/task/returnMoneyTransfer.js +0 -55
- package/lib/chevre/service/task/voidMoneyTransferTransaction.d.ts +0 -6
- package/lib/chevre/service/task/voidMoneyTransferTransaction.js +0 -27
- package/lib/chevre/service/transaction/moneyTransfer/exportTasks/factory.d.ts +0 -9
- package/lib/chevre/service/transaction/moneyTransfer/exportTasks/factory.js +0 -138
- package/lib/chevre/service/transaction/moneyTransfer/factory.d.ts +0 -2
- package/lib/chevre/service/transaction/moneyTransfer/factory.js +0 -55
- package/lib/chevre/service/transaction/moneyTransfer/potentialActions.d.ts +0 -9
- package/lib/chevre/service/transaction/moneyTransfer/potentialActions.js +0 -65
- package/lib/chevre/service/transaction/moneyTransfer.d.ts +0 -72
- package/lib/chevre/service/transaction/moneyTransfer.js +0 -649
|
@@ -1,96 +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 (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.returnMoneyTransfer = returnMoneyTransfer;
|
|
30
|
-
const moment_1 = __importDefault(require("moment"));
|
|
31
|
-
const util = __importStar(require("util"));
|
|
32
|
-
const factory = __importStar(require("../../../factory"));
|
|
33
|
-
const MoneyTransferAssetTransactionService = __importStar(require("../../assetTransaction/moneyTransfer"));
|
|
34
|
-
/**
|
|
35
|
-
* 入金を返却する
|
|
36
|
-
*/
|
|
37
|
-
function returnMoneyTransfer(params) {
|
|
38
|
-
return async (repos) => {
|
|
39
|
-
const action = await repos.action.start(params);
|
|
40
|
-
try {
|
|
41
|
-
// 取引番号で通貨転送取引を検索
|
|
42
|
-
const transactionNumber = params.object.object.transactionNumber;
|
|
43
|
-
const existingAssetTransactions = await repos.assetTransaction.search({
|
|
44
|
-
limit: 1,
|
|
45
|
-
page: 1,
|
|
46
|
-
project: { id: { $eq: params.project.id } },
|
|
47
|
-
typeOf: factory.assetTransactionType.MoneyTransfer,
|
|
48
|
-
transactionNumber: { $eq: transactionNumber }
|
|
49
|
-
});
|
|
50
|
-
// 資産取引が存在すれば、出金取引を実行
|
|
51
|
-
const depositTransaction = existingAssetTransactions.shift();
|
|
52
|
-
if (depositTransaction !== undefined) {
|
|
53
|
-
// 冪等性の確保
|
|
54
|
-
// 入金時の資産取引に対して一意な識別子をMoneyTransfer資産取引指定する
|
|
55
|
-
const identifier2withdrawAssetTransaction = util.format('%s:%s:%s', params.project.id, 'returnMoneyTransfer', depositTransaction.transactionNumber);
|
|
56
|
-
// まず取引番号発行
|
|
57
|
-
const publishTransactionNumber4returnMoneyTransferResult = await repos.transactionNumber.publishByTimestamp({ startDate: new Date() });
|
|
58
|
-
const withdrawTransaction = await MoneyTransferAssetTransactionService.start({
|
|
59
|
-
identifier: identifier2withdrawAssetTransaction,
|
|
60
|
-
project: depositTransaction.project,
|
|
61
|
-
transactionNumber: publishTransactionNumber4returnMoneyTransferResult.transactionNumber,
|
|
62
|
-
typeOf: factory.assetTransactionType.MoneyTransfer,
|
|
63
|
-
expires: (0, moment_1.default)()
|
|
64
|
-
.add(1, 'minute')
|
|
65
|
-
.toDate(),
|
|
66
|
-
agent: depositTransaction.agent,
|
|
67
|
-
recipient: depositTransaction.recipient,
|
|
68
|
-
object: {
|
|
69
|
-
amount: depositTransaction.object.amount,
|
|
70
|
-
fromLocation: {
|
|
71
|
-
typeOf: depositTransaction.object.toLocation.typeOf,
|
|
72
|
-
identifier: depositTransaction.object.toLocation.identifier
|
|
73
|
-
},
|
|
74
|
-
toLocation: depositTransaction.object.fromLocation,
|
|
75
|
-
pendingTransaction: {
|
|
76
|
-
typeOf: factory.account.transactionType.Withdraw,
|
|
77
|
-
transactionNumber: publishTransactionNumber4returnMoneyTransferResult.transactionNumber
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
})(repos);
|
|
81
|
-
await MoneyTransferAssetTransactionService.confirm({ id: withdrawTransaction.id })(repos);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
catch (error) {
|
|
85
|
-
try {
|
|
86
|
-
await repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error });
|
|
87
|
-
}
|
|
88
|
-
catch (__) {
|
|
89
|
-
// no op
|
|
90
|
-
}
|
|
91
|
-
throw error;
|
|
92
|
-
}
|
|
93
|
-
const actionResult = {};
|
|
94
|
-
await repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: actionResult });
|
|
95
|
-
};
|
|
96
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import * as factory from '../../../factory';
|
|
2
|
-
import type { ActionRepo } from '../../../repo/action';
|
|
3
|
-
import type { AssetTransactionRepo } from '../../../repo/assetTransaction';
|
|
4
|
-
import type { TaskRepo } from '../../../repo/task';
|
|
5
|
-
export declare function settleTransaction(params: factory.task.IData<factory.taskName.ConfirmMoneyTransfer>): (repos: {
|
|
6
|
-
action: ActionRepo;
|
|
7
|
-
assetTransaction: AssetTransactionRepo;
|
|
8
|
-
task: TaskRepo;
|
|
9
|
-
}) => Promise<void>;
|
|
@@ -1,91 +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 (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.settleTransaction = settleTransaction;
|
|
27
|
-
const factory = __importStar(require("../../../factory"));
|
|
28
|
-
const MoneyTransferAssetTransactionService = __importStar(require("../../assetTransaction/moneyTransfer"));
|
|
29
|
-
function settleTransaction(params) {
|
|
30
|
-
return async (repos) => {
|
|
31
|
-
const action = await repos.action.start(params);
|
|
32
|
-
try {
|
|
33
|
-
// 廃止(2024-01-30~)
|
|
34
|
-
// if (typeof params.object.pendingTransaction.id === 'string' && params.object.pendingTransaction.id.length > 0) {
|
|
35
|
-
// await MoneyTransferAssetTransactionService.confirm({ id: params.object.pendingTransaction.id })(repos);
|
|
36
|
-
// }
|
|
37
|
-
if (typeof params.object.transactionNumber === 'string' && params.object.transactionNumber.length > 0) {
|
|
38
|
-
await MoneyTransferAssetTransactionService.confirm({ transactionNumber: params.object.transactionNumber })(repos);
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
throw new factory.errors.ArgumentNull('object.transactionNumber');
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
catch (error) {
|
|
45
|
-
try {
|
|
46
|
-
await repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error });
|
|
47
|
-
}
|
|
48
|
-
catch (__) {
|
|
49
|
-
// no op
|
|
50
|
-
}
|
|
51
|
-
throw error;
|
|
52
|
-
}
|
|
53
|
-
const actionResult = {};
|
|
54
|
-
await repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: actionResult });
|
|
55
|
-
await onConfirmed(params)({
|
|
56
|
-
task: repos.task
|
|
57
|
-
});
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
function onConfirmed(params) {
|
|
61
|
-
return async (repos) => {
|
|
62
|
-
if (params.purpose.typeOf === factory.order.OrderType.Order) {
|
|
63
|
-
// タスク冪等作成
|
|
64
|
-
const onAssetTransactionStatusChangedTaskData = {
|
|
65
|
-
project: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
66
|
-
object: {
|
|
67
|
-
typeOf: params.object.typeOf,
|
|
68
|
-
transactionNumber: params.object.transactionNumber,
|
|
69
|
-
status: factory.transactionStatusType.Confirmed
|
|
70
|
-
},
|
|
71
|
-
purpose: {
|
|
72
|
-
confirmationNumber: '', // OnAssetTransactionStatusChanged処理内で使用されないので空文字でok
|
|
73
|
-
orderNumber: params.purpose.orderNumber,
|
|
74
|
-
typeOf: factory.order.OrderType.Order
|
|
75
|
-
},
|
|
76
|
-
useOnOrderStatusChanged: true
|
|
77
|
-
};
|
|
78
|
-
const onAssetTransactionStatusChangedTask = {
|
|
79
|
-
project: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
80
|
-
name: factory.taskName.OnAssetTransactionStatusChanged,
|
|
81
|
-
status: factory.taskStatus.Ready,
|
|
82
|
-
runsAt: new Date(),
|
|
83
|
-
remainingNumberOfTries: 10,
|
|
84
|
-
numberOfTried: 0,
|
|
85
|
-
executionResults: [],
|
|
86
|
-
data: onAssetTransactionStatusChangedTaskData
|
|
87
|
-
};
|
|
88
|
-
await repos.task.createOnAssetTransactionStatusChangedTaskIfNotExist(onAssetTransactionStatusChangedTask, { emitImmediately: true });
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import * as factory from '../../../factory';
|
|
2
|
-
import type { AuthorizeMoneyTransferOfferActionRepo } from '../../../repo/action/authorizeMoneyTransferOffer';
|
|
3
|
-
import type { AssetTransactionRepo } from '../../../repo/assetTransaction';
|
|
4
|
-
import type { PlaceOrderRepo } from '../../../repo/transaction/placeOrder';
|
|
5
|
-
export declare function voidTransaction(params: factory.task.IData<factory.taskName.VoidMoneyTransferTransaction>): (repos: {
|
|
6
|
-
action?: never;
|
|
7
|
-
authorizeMoneyTransferOfferAction: AuthorizeMoneyTransferOfferActionRepo;
|
|
8
|
-
assetTransaction: AssetTransactionRepo;
|
|
9
|
-
placeOrder: PlaceOrderRepo;
|
|
10
|
-
}) => Promise<void>;
|
|
@@ -1,81 +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 (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.voidTransaction = voidTransaction;
|
|
27
|
-
const factory = __importStar(require("../../../factory"));
|
|
28
|
-
const MoneyTransferAssetTransactionService = __importStar(require("../../assetTransaction/moneyTransfer"));
|
|
29
|
-
function voidTransaction(params) {
|
|
30
|
-
return async (repos) => {
|
|
31
|
-
if (params.purpose.typeOf !== factory.transactionType.PlaceOrder) {
|
|
32
|
-
throw new factory.errors.NotImplemented(`purpose.typeOf: ${params.purpose.typeOf} not implemented`);
|
|
33
|
-
}
|
|
34
|
-
let transaction;
|
|
35
|
-
if (params.agent !== undefined && params.agent !== null && typeof params.agent.id === 'string') {
|
|
36
|
-
transaction = await repos.placeOrder.findPlaceOrderInProgressById({
|
|
37
|
-
typeOf: params.purpose.typeOf,
|
|
38
|
-
id: params.purpose.id
|
|
39
|
-
}, ['typeOf']);
|
|
40
|
-
}
|
|
41
|
-
let authorizeActions;
|
|
42
|
-
if (typeof params.id === 'string') {
|
|
43
|
-
const authorizeAction = await repos.authorizeMoneyTransferOfferAction.findById({ typeOf: factory.actionType.AuthorizeAction, id: params.id });
|
|
44
|
-
// 取引内のアクションかどうか確認
|
|
45
|
-
if (transaction !== undefined) {
|
|
46
|
-
if (authorizeAction.purpose.typeOf !== transaction.typeOf || authorizeAction.purpose.id !== transaction.id) {
|
|
47
|
-
throw new factory.errors.Argument('Transaction', 'Action not found in the transaction');
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
authorizeActions = [authorizeAction];
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
authorizeActions = await repos.authorizeMoneyTransferOfferAction.findAuthorizeMoneyTransferOfferActionsByPurpose({
|
|
54
|
-
// typeOf: factory.actionType.AuthorizeAction,
|
|
55
|
-
purpose: {
|
|
56
|
-
typeOf: params.purpose.typeOf,
|
|
57
|
-
id: params.purpose.id
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
authorizeActions = authorizeActions.filter((a) => a.object.typeOf === factory.offerType.Offer)
|
|
61
|
-
.filter((a) => a.object.itemOffered?.typeOf === factory.actionType.MoneyTransfer);
|
|
62
|
-
}
|
|
63
|
-
await Promise.all(authorizeActions.map(async (action) => {
|
|
64
|
-
await repos.authorizeMoneyTransferOfferAction.cancelWithVoid({ typeOf: action.typeOf, id: action.id });
|
|
65
|
-
const pendingTransactionTransactionNumber = action.object.itemOffered.object?.pendingTransaction?.transactionNumber;
|
|
66
|
-
if (typeof pendingTransactionTransactionNumber === 'string') {
|
|
67
|
-
// 取引が存在すれば中止
|
|
68
|
-
const existingAssetTransactions = await repos.assetTransaction.search({
|
|
69
|
-
limit: 1,
|
|
70
|
-
page: 1,
|
|
71
|
-
project: { id: { $eq: params.project.id } },
|
|
72
|
-
typeOf: factory.assetTransactionType.MoneyTransfer,
|
|
73
|
-
transactionNumber: { $eq: pendingTransactionTransactionNumber }
|
|
74
|
-
});
|
|
75
|
-
if (existingAssetTransactions.length > 0) {
|
|
76
|
-
await MoneyTransferAssetTransactionService.cancel({ transactionNumber: pendingTransactionTransactionNumber })(repos);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}));
|
|
80
|
-
};
|
|
81
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { authorize } from './moneyTransfer/authorize';
|
|
2
|
-
import { returnMoneyTransfer } from './moneyTransfer/returnMoneyTransfer';
|
|
3
|
-
import { settleTransaction } from './moneyTransfer/settleTransaction';
|
|
4
|
-
import { voidTransaction } from './moneyTransfer/voidTransaction';
|
|
5
|
-
export { authorize, returnMoneyTransfer, settleTransaction, voidTransaction };
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.voidTransaction = exports.settleTransaction = exports.returnMoneyTransfer = exports.authorize = void 0;
|
|
4
|
-
const authorize_1 = require("./moneyTransfer/authorize");
|
|
5
|
-
Object.defineProperty(exports, "authorize", { enumerable: true, get: function () { return authorize_1.authorize; } });
|
|
6
|
-
const returnMoneyTransfer_1 = require("./moneyTransfer/returnMoneyTransfer");
|
|
7
|
-
Object.defineProperty(exports, "returnMoneyTransfer", { enumerable: true, get: function () { return returnMoneyTransfer_1.returnMoneyTransfer; } });
|
|
8
|
-
const settleTransaction_1 = require("./moneyTransfer/settleTransaction");
|
|
9
|
-
Object.defineProperty(exports, "settleTransaction", { enumerable: true, get: function () { return settleTransaction_1.settleTransaction; } });
|
|
10
|
-
const voidTransaction_1 = require("./moneyTransfer/voidTransaction");
|
|
11
|
-
Object.defineProperty(exports, "voidTransaction", { enumerable: true, get: function () { return voidTransaction_1.voidTransaction; } });
|
|
@@ -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 settleTransaction_1 = require("../offer/moneyTransfer/settleTransaction");
|
|
8
|
-
/**
|
|
9
|
-
* タスク実行関数
|
|
10
|
-
*/
|
|
11
|
-
function call(data) {
|
|
12
|
-
return async ({ connection }) => {
|
|
13
|
-
await (0, settleTransaction_1.settleTransaction)(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,55 +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 (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.call = call;
|
|
27
|
-
const factory = __importStar(require("../../factory"));
|
|
28
|
-
const action_1 = require("../../repo/action");
|
|
29
|
-
const assetTransaction_1 = require("../../repo/assetTransaction");
|
|
30
|
-
const product_1 = require("../../repo/product");
|
|
31
|
-
const project_1 = require("../../repo/project");
|
|
32
|
-
const transactionNumber_1 = require("../../repo/transactionNumber");
|
|
33
|
-
const returnMoneyTransfer_1 = require("../offer/moneyTransfer/returnMoneyTransfer");
|
|
34
|
-
/**
|
|
35
|
-
* タスク実行関数
|
|
36
|
-
*/
|
|
37
|
-
function call(data) {
|
|
38
|
-
return async ({ redisClient, connection }) => {
|
|
39
|
-
if (redisClient === undefined) {
|
|
40
|
-
throw new factory.errors.Argument('settings', 'redisClient required');
|
|
41
|
-
}
|
|
42
|
-
const actionRepo = new action_1.ActionRepo(connection);
|
|
43
|
-
const assetTransactionRepo = new assetTransaction_1.AssetTransactionRepo(connection);
|
|
44
|
-
const productRepo = new product_1.ProductRepo(connection);
|
|
45
|
-
const projectRepo = new project_1.ProjectRepo(connection);
|
|
46
|
-
const transactionNumberRepo = new transactionNumber_1.TransactionNumberRepo({ connection });
|
|
47
|
-
await (0, returnMoneyTransfer_1.returnMoneyTransfer)(data)({
|
|
48
|
-
action: actionRepo,
|
|
49
|
-
assetTransaction: assetTransactionRepo,
|
|
50
|
-
product: productRepo,
|
|
51
|
-
project: projectRepo,
|
|
52
|
-
transactionNumber: transactionNumberRepo
|
|
53
|
-
});
|
|
54
|
-
};
|
|
55
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.call = call;
|
|
4
|
-
// import { ActionRepo } from '../../repo/action';
|
|
5
|
-
const authorizeMoneyTransferOffer_1 = require("../../repo/action/authorizeMoneyTransferOffer");
|
|
6
|
-
const assetTransaction_1 = require("../../repo/assetTransaction");
|
|
7
|
-
// import { TransactionRepo } from '../../repo/transaction';
|
|
8
|
-
const placeOrder_1 = require("../../repo/transaction/placeOrder");
|
|
9
|
-
const voidTransaction_1 = require("../offer/moneyTransfer/voidTransaction");
|
|
10
|
-
/**
|
|
11
|
-
* タスク実行関数
|
|
12
|
-
*/
|
|
13
|
-
function call(data) {
|
|
14
|
-
return async ({ connection }) => {
|
|
15
|
-
// const actionRepo = new ActionRepo(connection);
|
|
16
|
-
const assetTransactionRepo = new assetTransaction_1.AssetTransactionRepo(connection);
|
|
17
|
-
const placeOrderRepo = new placeOrder_1.PlaceOrderRepo(connection);
|
|
18
|
-
// const transactionRepo = new TransactionRepo(connection);
|
|
19
|
-
await (0, voidTransaction_1.voidTransaction)(data)({
|
|
20
|
-
// action: actionRepo,
|
|
21
|
-
authorizeMoneyTransferOfferAction: new authorizeMoneyTransferOffer_1.AuthorizeMoneyTransferOfferActionRepo(connection),
|
|
22
|
-
assetTransaction: assetTransactionRepo,
|
|
23
|
-
placeOrder: placeOrderRepo
|
|
24
|
-
// transaction: transactionRepo
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { ISetting } from '../../../../repo/setting';
|
|
2
|
-
import * as factory from '../../../../factory';
|
|
3
|
-
/**
|
|
4
|
-
* 取引のタスクを作成する
|
|
5
|
-
*/
|
|
6
|
-
export declare function createTasks(params: {
|
|
7
|
-
transaction: Pick<factory.transaction.ITransaction<factory.transactionType.MoneyTransfer>, 'id' | 'endDate' | 'status' | 'project' | 'startDate' | 'typeOf' | 'object' | 'potentialActions'>;
|
|
8
|
-
runsAt: Date;
|
|
9
|
-
}, setting: Pick<ISetting, 'storage'> | null): factory.task.IAttributes<factory.taskName>[];
|
|
@@ -1,138 +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 (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.createTasks = createTasks;
|
|
30
|
-
const moment_1 = __importDefault(require("moment"));
|
|
31
|
-
const factory = __importStar(require("../../../../factory"));
|
|
32
|
-
// import { Settings } from '../../../../settings';
|
|
33
|
-
/**
|
|
34
|
-
* 取引のタスクを作成する
|
|
35
|
-
*/
|
|
36
|
-
function createTasks(params, setting
|
|
37
|
-
// settings: Settings
|
|
38
|
-
) {
|
|
39
|
-
const taskAttributes = [];
|
|
40
|
-
const transaction = params.transaction;
|
|
41
|
-
const taskRunsAt = params.runsAt;
|
|
42
|
-
const confirmedStoragePeriodInDays = setting?.storage?.transactionConfirmedInDays;
|
|
43
|
-
const canceledStoragePeriodInDays = setting?.storage?.transactionCanceledInDays;
|
|
44
|
-
if (typeof confirmedStoragePeriodInDays !== 'number') {
|
|
45
|
-
throw new factory.errors.NotFound('setting.storage.confirmedStoragePeriodInDays');
|
|
46
|
-
}
|
|
47
|
-
if (typeof canceledStoragePeriodInDays !== 'number') {
|
|
48
|
-
throw new factory.errors.NotFound('setting.storage.canceledStoragePeriodInDays');
|
|
49
|
-
}
|
|
50
|
-
// 取引削除タスクを作成(取引ステータスによってrunsAtを調整)
|
|
51
|
-
// let deleteAt = moment(transaction.endDate)
|
|
52
|
-
// .add(settings.transaction.confirmedStoragePeriodInDays, 'days')
|
|
53
|
-
// .toDate();
|
|
54
|
-
let deleteAt = (0, moment_1.default)(transaction.endDate)
|
|
55
|
-
.add(confirmedStoragePeriodInDays, 'days')
|
|
56
|
-
.toDate();
|
|
57
|
-
switch (transaction.status) {
|
|
58
|
-
case factory.transactionStatusType.Confirmed:
|
|
59
|
-
break;
|
|
60
|
-
case factory.transactionStatusType.Canceled:
|
|
61
|
-
case factory.transactionStatusType.Expired:
|
|
62
|
-
// deleteAt = moment(transaction.endDate)
|
|
63
|
-
// .add(settings.transaction.canceledStoragePeriodInDays, 'days')
|
|
64
|
-
// .toDate();
|
|
65
|
-
deleteAt = (0, moment_1.default)(transaction.endDate)
|
|
66
|
-
.add(canceledStoragePeriodInDays, 'days')
|
|
67
|
-
.toDate();
|
|
68
|
-
break;
|
|
69
|
-
default:
|
|
70
|
-
}
|
|
71
|
-
const deleteTransactionTask = {
|
|
72
|
-
project: transaction.project,
|
|
73
|
-
name: factory.taskName.DeleteTransaction,
|
|
74
|
-
status: factory.taskStatus.Ready,
|
|
75
|
-
runsAt: deleteAt,
|
|
76
|
-
remainingNumberOfTries: 3,
|
|
77
|
-
numberOfTried: 0,
|
|
78
|
-
executionResults: [],
|
|
79
|
-
data: {
|
|
80
|
-
object: {
|
|
81
|
-
specifyingMethod: factory.action.update.deleteAction.ObjectAsTransactionSpecifyingMethod.Id,
|
|
82
|
-
id: transaction.id,
|
|
83
|
-
object: {
|
|
84
|
-
...(transaction.object.pendingTransaction !== undefined)
|
|
85
|
-
? { pendingTransaction: transaction.object.pendingTransaction }
|
|
86
|
-
: undefined
|
|
87
|
-
},
|
|
88
|
-
project: transaction.project,
|
|
89
|
-
startDate: transaction.startDate,
|
|
90
|
-
typeOf: transaction.typeOf,
|
|
91
|
-
...(transaction.endDate !== undefined) ? { endDate: transaction.endDate } : undefined
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
taskAttributes.push(deleteTransactionTask);
|
|
96
|
-
switch (transaction.status) {
|
|
97
|
-
case factory.transactionStatusType.Confirmed:
|
|
98
|
-
/* istanbul ignore else */
|
|
99
|
-
if (transaction.potentialActions !== undefined) {
|
|
100
|
-
/* istanbul ignore else */
|
|
101
|
-
if (transaction.potentialActions.moneyTransfer !== undefined) {
|
|
102
|
-
taskAttributes.push(...transaction.potentialActions.moneyTransfer.map((a) => {
|
|
103
|
-
return {
|
|
104
|
-
project: transaction.project,
|
|
105
|
-
name: factory.taskName.ConfirmMoneyTransfer,
|
|
106
|
-
status: factory.taskStatus.Ready,
|
|
107
|
-
runsAt: taskRunsAt,
|
|
108
|
-
remainingNumberOfTries: 10,
|
|
109
|
-
numberOfTried: 0,
|
|
110
|
-
executionResults: [],
|
|
111
|
-
data: a
|
|
112
|
-
};
|
|
113
|
-
}));
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
break;
|
|
117
|
-
case factory.transactionStatusType.Canceled:
|
|
118
|
-
case factory.transactionStatusType.Expired:
|
|
119
|
-
const voidMoneyTransferTaskAttributes = {
|
|
120
|
-
project: { typeOf: transaction.project.typeOf, id: transaction.project.id },
|
|
121
|
-
name: factory.taskName.VoidMoneyTransferTransaction,
|
|
122
|
-
status: factory.taskStatus.Ready,
|
|
123
|
-
runsAt: taskRunsAt,
|
|
124
|
-
remainingNumberOfTries: 10,
|
|
125
|
-
numberOfTried: 0,
|
|
126
|
-
executionResults: [],
|
|
127
|
-
data: {
|
|
128
|
-
project: { typeOf: transaction.project.typeOf, id: transaction.project.id },
|
|
129
|
-
purpose: { typeOf: transaction.typeOf, id: transaction.id }
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
taskAttributes.push(voidMoneyTransferTaskAttributes);
|
|
133
|
-
break;
|
|
134
|
-
default:
|
|
135
|
-
throw new factory.errors.NotImplemented(`Transaction status "${transaction.status}" not implemented.`);
|
|
136
|
-
}
|
|
137
|
-
return taskAttributes;
|
|
138
|
-
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import * as factory from '../../../factory';
|
|
2
|
-
export declare function createStartParams(params: factory.transaction.moneyTransfer.IStartParamsWithoutDetail, passport: factory.waiter.passport.IPassport | undefined, seller: Pick<factory.seller.ISeller, 'id' | 'name' | 'typeOf'>, amount: factory.monetaryAmount.IMonetaryAmount, fromLocation: factory.assetTransaction.moneyTransfer.IFromLocationBeforeStart, toLocation: factory.transaction.moneyTransfer.IToLocation, transactionNumber: string): factory.transaction.IStartParams<factory.transactionType.MoneyTransfer>;
|
|
@@ -1,55 +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 (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.createStartParams = createStartParams;
|
|
27
|
-
const factory = __importStar(require("../../../factory"));
|
|
28
|
-
function createStartParams(params, passport, seller, amount, fromLocation, toLocation, transactionNumber) {
|
|
29
|
-
// 取引ファクトリーで新しい進行中取引オブジェクトを作成
|
|
30
|
-
return {
|
|
31
|
-
project: params.project,
|
|
32
|
-
typeOf: factory.transactionType.MoneyTransfer,
|
|
33
|
-
agent: params.agent,
|
|
34
|
-
recipient: params.recipient,
|
|
35
|
-
seller: {
|
|
36
|
-
id: String(seller.id),
|
|
37
|
-
name: seller.name,
|
|
38
|
-
typeOf: seller.typeOf
|
|
39
|
-
},
|
|
40
|
-
object: {
|
|
41
|
-
amount: amount,
|
|
42
|
-
fromLocation: fromLocation,
|
|
43
|
-
toLocation: toLocation,
|
|
44
|
-
pendingTransaction: {
|
|
45
|
-
transactionNumber,
|
|
46
|
-
...(typeof params.object.pendingTransaction?.identifier === 'string')
|
|
47
|
-
? { identifier: params.object.pendingTransaction.identifier }
|
|
48
|
-
: undefined
|
|
49
|
-
},
|
|
50
|
-
...(passport !== undefined) ? { passport } : undefined,
|
|
51
|
-
...(typeof params.object.description === 'string') ? { description: params.object.description } : undefined
|
|
52
|
-
},
|
|
53
|
-
expires: params.expires
|
|
54
|
-
};
|
|
55
|
-
}
|