@chevre/domain 21.34.0-alpha.8 → 21.34.0
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/example/src/chevre/migrateCheckMovieTicketRecipes.ts +127 -0
- package/example/src/chevre/migratePayTransactionRecipes.ts +251 -0
- package/example/src/chevre/transaction/processPlaceOrder.ts +0 -1
- package/lib/chevre/repo/action.d.ts +2 -1
- package/lib/chevre/repo/action.js +36 -0
- package/lib/chevre/repo/assetTransaction.d.ts +0 -10
- package/lib/chevre/repo/assetTransaction.js +20 -46
- package/lib/chevre/service/assetTransaction/pay/factory.js +11 -4
- package/lib/chevre/service/assetTransaction/pay.d.ts +0 -17
- package/lib/chevre/service/assetTransaction/pay.js +36 -67
- package/lib/chevre/service/assetTransaction/refund/potentialActions.d.ts +1 -0
- package/lib/chevre/service/assetTransaction/refund/potentialActions.js +10 -8
- package/lib/chevre/service/assetTransaction/refund.js +10 -0
- package/lib/chevre/service/offer/event/authorize.js +1 -1
- package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4coa.js +1 -16
- package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer.js +1 -1
- package/lib/chevre/service/offer/eventServiceByCOA/authorize.d.ts +7 -1
- package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +4 -2
- package/lib/chevre/service/offer/eventServiceByCOA/authorizeByAcceptAction.d.ts +30 -0
- package/lib/chevre/service/offer/eventServiceByCOA/authorizeByAcceptAction.js +96 -0
- package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +13 -3
- package/lib/chevre/service/offer/eventServiceByCOA/factory.d.ts +3 -0
- package/lib/chevre/service/offer/eventServiceByCOA/factory.js +1 -0
- package/lib/chevre/service/offer/eventServiceByCOA.d.ts +2 -5
- package/lib/chevre/service/offer/eventServiceByCOA.js +3 -10
- package/lib/chevre/service/payment/any/onRefund.js +10 -8
- package/lib/chevre/service/payment/any.d.ts +0 -1
- package/lib/chevre/service/payment/any.js +1 -1
- package/lib/chevre/service/payment/creditCard/authorize/handleAuthorizeError.d.ts +2 -0
- package/lib/chevre/service/payment/creditCard/authorize/handleAuthorizeError.js +56 -0
- package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard.d.ts +33 -0
- package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard.js +116 -0
- package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard3ds.d.ts +24 -0
- package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard3ds.js +59 -0
- package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard3dsResult2recipe.d.ts +13 -0
- package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard3dsResult2recipe.js +24 -0
- package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCardResult2recipe.d.ts +15 -0
- package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCardResult2recipe.js +29 -0
- package/lib/chevre/service/payment/creditCard/authorize.d.ts +18 -11
- package/lib/chevre/service/payment/creditCard/authorize.js +23 -141
- package/lib/chevre/service/payment/creditCard/voidTransaction.d.ts +2 -0
- package/lib/chevre/service/payment/creditCard/voidTransaction.js +17 -0
- package/lib/chevre/service/{assetTransaction/pay/potentialActions → payment/factory}/createPayObjectServiceOutput.d.ts +2 -2
- package/lib/chevre/service/{assetTransaction/pay/potentialActions → payment/factory}/createPayObjectServiceOutput.js +2 -2
- package/lib/chevre/service/payment/factory.d.ts +13 -0
- package/lib/chevre/service/{assetTransaction/pay/potentialActions.js → payment/factory.js} +30 -25
- package/lib/chevre/service/payment/movieTicket/authorize.d.ts +1 -1
- package/lib/chevre/service/payment/movieTicket/authorize.js +14 -3
- package/lib/chevre/service/payment/movieTicket/factory.d.ts +1 -1
- package/lib/chevre/service/payment/movieTicket/factory.js +5 -5
- package/lib/chevre/service/payment/movieTicket/validation.d.ts +1 -1
- package/lib/chevre/service/payment/movieTicket/validation.js +1 -5
- package/lib/chevre/service/payment.d.ts +16 -0
- package/lib/chevre/service/payment.js +82 -28
- package/package.json +4 -4
- package/example/src/chevre/transaction/acceptCOAOffer.ts +0 -78
- package/lib/chevre/service/assetTransaction/pay/potentialActions.d.ts +0 -10
- package/lib/chevre/service/offer/eventServiceByCOA/cancel.d.ts +0 -42
- package/lib/chevre/service/offer/eventServiceByCOA/cancel.js +0 -65
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as moment from 'moment';
|
|
3
|
+
import * as mongoose from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import { chevre } from '../../../lib/index';
|
|
6
|
+
|
|
7
|
+
// tslint:disable-next-line:max-func-body-length
|
|
8
|
+
async function main() {
|
|
9
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
10
|
+
|
|
11
|
+
const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
|
|
12
|
+
const cursor = actionRepo.getCursor(
|
|
13
|
+
{
|
|
14
|
+
// _id: { $eq: '665c886886e0ee8ff5f7b3c5' },
|
|
15
|
+
typeOf: { $eq: chevre.factory.actionType.CheckAction },
|
|
16
|
+
actionStatus: { $eq: chevre.factory.actionStatusType.CompletedActionStatus },
|
|
17
|
+
startDate: {
|
|
18
|
+
// $lte: moment()
|
|
19
|
+
// // tslint:disable-next-line:no-magic-numbers
|
|
20
|
+
// .add(-178, 'days'),
|
|
21
|
+
$gte: moment()
|
|
22
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
23
|
+
.add(-365, 'days')
|
|
24
|
+
},
|
|
25
|
+
'object.typeOf': { $exists: true, $eq: chevre.factory.service.paymentService.PaymentServiceType.MovieTicket }
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
__id: 1, startDate: 1, endDate: 1, result: 1, project: 1, typeOf: 1, actionStatus: 1, instrument: 1
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
console.log('actions found');
|
|
32
|
+
|
|
33
|
+
let i = 0;
|
|
34
|
+
let updateCount = 0;
|
|
35
|
+
let saveRecipeCount = 0;
|
|
36
|
+
await cursor.eachAsync(async (doc) => {
|
|
37
|
+
i += 1;
|
|
38
|
+
const checkAction = <Pick<
|
|
39
|
+
chevre.factory.action.check.paymentMethod.movieTicket.IAction,
|
|
40
|
+
'id' | 'startDate' | 'endDate' | 'result' | 'project' | 'typeOf' | 'actionStatus' | 'instrument'
|
|
41
|
+
>>doc.toObject();
|
|
42
|
+
const actionRecipe = await actionRepo.findRecipeByAction<chevre.factory.recipe.RecipeCategory.checkMovieTicket>({
|
|
43
|
+
project: { id: checkAction.project.id },
|
|
44
|
+
recipeFor: { id: checkAction.id }
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const purchaseNumberAuthInByCheckAction = (<any>checkAction.result)?.purchaseNumberAuthIn;
|
|
48
|
+
const purchaseNumberAuthResultByCheckAction = (<any>checkAction.result)?.purchaseNumberAuthResult;
|
|
49
|
+
|
|
50
|
+
if (actionRecipe !== null) {
|
|
51
|
+
console.log(
|
|
52
|
+
'actionRecipe already exists. step:',
|
|
53
|
+
actionRecipe.step.length, checkAction.project.id, checkAction.id, checkAction.startDate, i, updateCount, saveRecipeCount);
|
|
54
|
+
|
|
55
|
+
// optimize action.result
|
|
56
|
+
if (purchaseNumberAuthInByCheckAction !== undefined || purchaseNumberAuthResultByCheckAction !== undefined) {
|
|
57
|
+
const unsetResult = await actionRepo.unsetUnnecessaryFields({
|
|
58
|
+
filter: { _id: { $eq: checkAction.id } },
|
|
59
|
+
$unset: {
|
|
60
|
+
'result.purchaseNumberAuthIn': 1,
|
|
61
|
+
'result.purchaseNumberAuthResult': 1
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
updateCount += 1;
|
|
65
|
+
console.log(
|
|
66
|
+
'result unset. unsetResult:', unsetResult,
|
|
67
|
+
actionRecipe.step.length, checkAction.project.id, checkAction.id, checkAction.startDate, i);
|
|
68
|
+
}
|
|
69
|
+
} else {
|
|
70
|
+
console.log(
|
|
71
|
+
'creating recipe by alterTranResultByPayAction',
|
|
72
|
+
purchaseNumberAuthInByCheckAction?.stCd,
|
|
73
|
+
purchaseNumberAuthResultByCheckAction?.resultInfo.status,
|
|
74
|
+
checkAction.project.id, checkAction.id, checkAction.startDate, i);
|
|
75
|
+
if (purchaseNumberAuthInByCheckAction === undefined) {
|
|
76
|
+
throw new Error('purchaseNumberAuthInByCheckAction undefined');
|
|
77
|
+
}
|
|
78
|
+
if (purchaseNumberAuthResultByCheckAction === undefined) {
|
|
79
|
+
throw new Error('purchaseNumberAuthResultByCheckAction undefined');
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const recipe: chevre.factory.action.check.paymentMethod.movieTicket.IRecipe & {
|
|
83
|
+
recipeFor: { id: string; typeOf: chevre.factory.actionType };
|
|
84
|
+
dateCreated: Date;
|
|
85
|
+
dateModified: Date;
|
|
86
|
+
} = {
|
|
87
|
+
project: { id: checkAction.project.id, typeOf: chevre.factory.organizationType.Project },
|
|
88
|
+
typeOf: 'Recipe',
|
|
89
|
+
recipeCategory: chevre.factory.recipe.RecipeCategory.checkMovieTicket,
|
|
90
|
+
recipeFor: { id: checkAction.id, typeOf: checkAction.typeOf },
|
|
91
|
+
step: [{
|
|
92
|
+
typeOf: 'HowToSection',
|
|
93
|
+
itemListElement: [
|
|
94
|
+
{
|
|
95
|
+
typeOf: 'HowToStep',
|
|
96
|
+
identifier: chevre.factory.recipe.StepIdentifier.purchaseNumberAuth,
|
|
97
|
+
itemListElement: [{
|
|
98
|
+
typeOf: 'HowToDirection',
|
|
99
|
+
beforeMedia: purchaseNumberAuthInByCheckAction,
|
|
100
|
+
afterMedia: purchaseNumberAuthResultByCheckAction
|
|
101
|
+
}]
|
|
102
|
+
}
|
|
103
|
+
]
|
|
104
|
+
}],
|
|
105
|
+
dateCreated: moment(checkAction.endDate)
|
|
106
|
+
.toDate(),
|
|
107
|
+
dateModified: moment(checkAction.endDate)
|
|
108
|
+
.toDate()
|
|
109
|
+
};
|
|
110
|
+
console.log(
|
|
111
|
+
'saving recipe...',
|
|
112
|
+
checkAction.project.id, checkAction.id, checkAction.startDate, i);
|
|
113
|
+
// console.dir(recipe, { depth: null });
|
|
114
|
+
await actionRepo.saveRecipeWithDateCreated(recipe);
|
|
115
|
+
saveRecipeCount += 1;
|
|
116
|
+
console.log('recipe saved.', checkAction.project.id, checkAction.id, checkAction.startDate, i);
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
console.log(i, 'actions checked');
|
|
121
|
+
console.log(updateCount, 'actions updated');
|
|
122
|
+
console.log(saveRecipeCount, 'recipe saved');
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
main()
|
|
126
|
+
.then()
|
|
127
|
+
.catch(console.error);
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as moment from 'moment';
|
|
3
|
+
import * as mongoose from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import { chevre } from '../../../lib/index';
|
|
6
|
+
|
|
7
|
+
// tslint:disable-next-line:max-func-body-length
|
|
8
|
+
async function main() {
|
|
9
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
10
|
+
|
|
11
|
+
const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
|
|
12
|
+
const assetTransactionRepo = await chevre.repository.AssetTransaction.createInstance(mongoose.connection);
|
|
13
|
+
const cursor = assetTransactionRepo.getCursor(
|
|
14
|
+
{
|
|
15
|
+
// transactionNumber: { $eq: '792921546706869' },
|
|
16
|
+
typeOf: { $eq: chevre.factory.assetTransactionType.Pay },
|
|
17
|
+
status: { $eq: chevre.factory.transactionStatusType.Confirmed },
|
|
18
|
+
startDate: {
|
|
19
|
+
// $lte: moment()
|
|
20
|
+
// // tslint:disable-next-line:no-magic-numbers
|
|
21
|
+
// .add(-28, 'days'),
|
|
22
|
+
$gte: moment()
|
|
23
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
24
|
+
.add(-180, 'days')
|
|
25
|
+
},
|
|
26
|
+
'object.typeOf': { $exists: true, $eq: chevre.factory.service.paymentService.PaymentServiceType.CreditCard }
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
__id: 1, startDate: 1, object: 1, project: 1, typeOf: 1, status: 1, transactionNumber: 1
|
|
30
|
+
}
|
|
31
|
+
);
|
|
32
|
+
console.log('transactions found');
|
|
33
|
+
|
|
34
|
+
let i = 0;
|
|
35
|
+
let updateCount = 0;
|
|
36
|
+
let saveRecipeCount = 0;
|
|
37
|
+
let saveActionCount = 0;
|
|
38
|
+
// tslint:disable-next-line:max-func-body-length
|
|
39
|
+
await cursor.eachAsync(async (doc) => {
|
|
40
|
+
i += 1;
|
|
41
|
+
const payTransaction = <Pick<
|
|
42
|
+
chevre.factory.assetTransaction.pay.ITransaction,
|
|
43
|
+
'id' | 'startDate' | 'object' | 'project' | 'typeOf' | 'status' | 'transactionNumber'
|
|
44
|
+
>>doc.toObject();
|
|
45
|
+
let authorizeInvoiceAction: chevre.factory.action.authorize.invoice.IAction | undefined;
|
|
46
|
+
authorizeInvoiceAction = (<chevre.factory.action.authorize.invoice.IAction[]>await actionRepo.search(
|
|
47
|
+
{
|
|
48
|
+
limit: 1,
|
|
49
|
+
page: 1,
|
|
50
|
+
project: { id: { $eq: payTransaction.project.id } },
|
|
51
|
+
agent: {
|
|
52
|
+
id: { $in: [payTransaction.project.id] },
|
|
53
|
+
typeOf: { $in: [chevre.factory.organizationType.Project] }
|
|
54
|
+
},
|
|
55
|
+
object: {
|
|
56
|
+
typeOf: { $eq: 'Invoice' },
|
|
57
|
+
paymentMethodId: { $eq: payTransaction.transactionNumber }
|
|
58
|
+
},
|
|
59
|
+
typeOf: { $eq: chevre.factory.actionType.AuthorizeAction }
|
|
60
|
+
},
|
|
61
|
+
[],
|
|
62
|
+
[]
|
|
63
|
+
)).shift();
|
|
64
|
+
// authorizeInvoiceAction = undefined;
|
|
65
|
+
|
|
66
|
+
const entryTranArgs: chevre.factory.action.authorize.invoice.IEntryTranArgs = (<any>payTransaction.object).entryTranArgs;
|
|
67
|
+
const entryTranResult: chevre.factory.action.authorize.invoice.IEntryTranResult = (<any>payTransaction.object).entryTranResult;
|
|
68
|
+
const execTranArgs: chevre.factory.action.authorize.invoice.IExecTranArgs = (<any>payTransaction.object).execTranArgs;
|
|
69
|
+
const execTranResult: chevre.factory.action.authorize.invoice.IExecTranResult = (<any>payTransaction.object).execTranResult;
|
|
70
|
+
const secureTran2Result: chevre.factory.action.authorize.invoice.ISecureTran2Result =
|
|
71
|
+
(<any>payTransaction.object).secureTran2Result;
|
|
72
|
+
|
|
73
|
+
if (authorizeInvoiceAction !== undefined) {
|
|
74
|
+
console.log(
|
|
75
|
+
'authorizeInvoiceAction already exists. step:',
|
|
76
|
+
authorizeInvoiceAction.object.paymentMethodId,
|
|
77
|
+
payTransaction.project.id, payTransaction.transactionNumber, payTransaction.startDate, i
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
const actionRecipe = await actionRepo.findRecipeByAction<chevre.factory.recipe.RecipeCategory.checkMovieTicket>({
|
|
81
|
+
project: { id: authorizeInvoiceAction.project.id },
|
|
82
|
+
recipeFor: { id: authorizeInvoiceAction.id }
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
if (actionRecipe !== null) {
|
|
86
|
+
console.log(
|
|
87
|
+
'actionRecipe already exists. step:',
|
|
88
|
+
payTransaction.project.id, payTransaction.transactionNumber, payTransaction.startDate, i
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
// optimize payTransaction.object
|
|
92
|
+
let unsetResult: any;
|
|
93
|
+
if (secureTran2Result !== undefined) {
|
|
94
|
+
// unsetResult = await assetTransactionRepo.unsetUnnecessaryFields({
|
|
95
|
+
// filter: { _id: { $eq: payTransaction.id } },
|
|
96
|
+
// $unset: {
|
|
97
|
+
// 'object.secureTran2Result': 1
|
|
98
|
+
// }
|
|
99
|
+
// });
|
|
100
|
+
updateCount += 1;
|
|
101
|
+
} else if (entryTranArgs !== undefined && execTranResult !== undefined) {
|
|
102
|
+
if (typeof (<any>execTranResult).redirectUrl !== 'string') {
|
|
103
|
+
// unsetResult = await assetTransactionRepo.unsetUnnecessaryFields({
|
|
104
|
+
// filter: { _id: { $eq: payTransaction.id } },
|
|
105
|
+
// $unset: {
|
|
106
|
+
// 'object.entryTranArgs': 1,
|
|
107
|
+
// 'object.entryTranResult': 1,
|
|
108
|
+
// 'object.execTranArgs': 1,
|
|
109
|
+
// 'object.execTranResult': 1
|
|
110
|
+
// }
|
|
111
|
+
// });
|
|
112
|
+
updateCount += 1;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
console.log(
|
|
116
|
+
'result unset. unsetResult:', unsetResult,
|
|
117
|
+
actionRecipe.step.length,
|
|
118
|
+
payTransaction.project.id, payTransaction.transactionNumber, payTransaction.startDate, i
|
|
119
|
+
);
|
|
120
|
+
} else {
|
|
121
|
+
console.log(
|
|
122
|
+
'creating recipe...',
|
|
123
|
+
payTransaction.project.id, payTransaction.transactionNumber, payTransaction.startDate, i
|
|
124
|
+
);
|
|
125
|
+
if (entryTranArgs === undefined) {
|
|
126
|
+
throw new Error('entryTranArgs undefined');
|
|
127
|
+
}
|
|
128
|
+
if (entryTranResult === undefined) {
|
|
129
|
+
throw new Error('entryTranResult undefined');
|
|
130
|
+
}
|
|
131
|
+
if (execTranArgs === undefined) {
|
|
132
|
+
throw new Error('execTranArgs undefined');
|
|
133
|
+
}
|
|
134
|
+
if (execTranResult === undefined) {
|
|
135
|
+
throw new Error('execTranResult undefined');
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
let recipe: (chevre.factory.action.authorize.invoice.IAuthorizeInvoiceRecipe
|
|
139
|
+
| chevre.factory.action.authorize.invoice.IAuthorizeInvoice3dsRecipe) & {
|
|
140
|
+
recipeFor: { id: string; typeOf: chevre.factory.actionType };
|
|
141
|
+
dateCreated: Date;
|
|
142
|
+
dateModified: Date;
|
|
143
|
+
};
|
|
144
|
+
if (secureTran2Result !== undefined) {
|
|
145
|
+
recipe = {
|
|
146
|
+
project: { id: payTransaction.project.id, typeOf: chevre.factory.organizationType.Project },
|
|
147
|
+
typeOf: 'Recipe',
|
|
148
|
+
recipeCategory: chevre.factory.recipe.RecipeCategory.authorizeInvoice3ds,
|
|
149
|
+
recipeFor: { id: authorizeInvoiceAction.id, typeOf: authorizeInvoiceAction.typeOf },
|
|
150
|
+
step: [{
|
|
151
|
+
typeOf: 'HowToSection',
|
|
152
|
+
itemListElement: [
|
|
153
|
+
{
|
|
154
|
+
typeOf: 'HowToStep',
|
|
155
|
+
identifier: chevre.factory.recipe.StepIdentifier.secureTran2,
|
|
156
|
+
itemListElement: [{
|
|
157
|
+
typeOf: 'HowToDirection',
|
|
158
|
+
afterMedia: secureTran2Result
|
|
159
|
+
}]
|
|
160
|
+
}
|
|
161
|
+
]
|
|
162
|
+
}],
|
|
163
|
+
dateCreated: moment(authorizeInvoiceAction.endDate)
|
|
164
|
+
.toDate(),
|
|
165
|
+
dateModified: moment(authorizeInvoiceAction.endDate)
|
|
166
|
+
.toDate()
|
|
167
|
+
};
|
|
168
|
+
} else {
|
|
169
|
+
recipe = {
|
|
170
|
+
project: { id: payTransaction.project.id, typeOf: chevre.factory.organizationType.Project },
|
|
171
|
+
typeOf: 'Recipe',
|
|
172
|
+
recipeCategory: chevre.factory.recipe.RecipeCategory.authorizeInvoice,
|
|
173
|
+
recipeFor: { id: authorizeInvoiceAction.id, typeOf: authorizeInvoiceAction.typeOf },
|
|
174
|
+
step: [{
|
|
175
|
+
typeOf: 'HowToSection',
|
|
176
|
+
itemListElement: [
|
|
177
|
+
{
|
|
178
|
+
typeOf: 'HowToStep',
|
|
179
|
+
identifier: chevre.factory.recipe.StepIdentifier.entryTran,
|
|
180
|
+
itemListElement: [{
|
|
181
|
+
typeOf: 'HowToDirection',
|
|
182
|
+
beforeMedia: entryTranArgs,
|
|
183
|
+
afterMedia: entryTranResult
|
|
184
|
+
}]
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
typeOf: 'HowToStep',
|
|
188
|
+
identifier: chevre.factory.recipe.StepIdentifier.execTran,
|
|
189
|
+
itemListElement: [{
|
|
190
|
+
typeOf: 'HowToDirection',
|
|
191
|
+
beforeMedia: execTranArgs,
|
|
192
|
+
afterMedia: execTranResult
|
|
193
|
+
}]
|
|
194
|
+
}
|
|
195
|
+
]
|
|
196
|
+
}],
|
|
197
|
+
dateCreated: moment(authorizeInvoiceAction.endDate)
|
|
198
|
+
.toDate(),
|
|
199
|
+
dateModified: moment(authorizeInvoiceAction.endDate)
|
|
200
|
+
.toDate()
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
console.log(
|
|
204
|
+
'saving recipe...',
|
|
205
|
+
payTransaction.project.id, payTransaction.transactionNumber, payTransaction.startDate, i);
|
|
206
|
+
// tslint:disable-next-line:no-null-keyword
|
|
207
|
+
console.dir(recipe, { depth: null });
|
|
208
|
+
await actionRepo.saveRecipeWithDateCreated(recipe);
|
|
209
|
+
saveRecipeCount += 1;
|
|
210
|
+
console.log('recipe saved.', payTransaction.project.id, payTransaction.transactionNumber, payTransaction.startDate, i);
|
|
211
|
+
}
|
|
212
|
+
} else {
|
|
213
|
+
const creatingAction: Omit<chevre.factory.action.authorize.invoice.IAction, 'id'> = {
|
|
214
|
+
project: { id: payTransaction.project.id, typeOf: chevre.factory.organizationType.Project },
|
|
215
|
+
typeOf: chevre.factory.actionType.AuthorizeAction,
|
|
216
|
+
agent: { id: payTransaction.project.id, typeOf: chevre.factory.organizationType.Project },
|
|
217
|
+
object: {
|
|
218
|
+
typeOf: 'Invoice',
|
|
219
|
+
paymentMethodId: payTransaction.transactionNumber
|
|
220
|
+
},
|
|
221
|
+
startDate: moment(payTransaction.startDate)
|
|
222
|
+
.toDate(),
|
|
223
|
+
endDate: moment(payTransaction.startDate)
|
|
224
|
+
.toDate(),
|
|
225
|
+
actionStatus: chevre.factory.actionStatusType.CompletedActionStatus,
|
|
226
|
+
result: {},
|
|
227
|
+
sameAs: { id: payTransaction.id, typeOf: payTransaction.typeOf }
|
|
228
|
+
};
|
|
229
|
+
console.log(
|
|
230
|
+
'creating action...',
|
|
231
|
+
payTransaction.project.id, payTransaction.transactionNumber, payTransaction.startDate, i
|
|
232
|
+
);
|
|
233
|
+
// tslint:disable-next-line:no-null-keyword
|
|
234
|
+
console.dir(creatingAction, { depth: null });
|
|
235
|
+
const saveActionResult = await actionRepo.saveActionWithEndDate(creatingAction);
|
|
236
|
+
saveActionCount += 1;
|
|
237
|
+
console.log(
|
|
238
|
+
'action saved.', saveActionResult,
|
|
239
|
+
payTransaction.project.id, payTransaction.transactionNumber, payTransaction.startDate, i);
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
console.log(i, 'transactions checked');
|
|
244
|
+
console.log(updateCount, 'transactions updated');
|
|
245
|
+
console.log(saveRecipeCount, 'recipe saved');
|
|
246
|
+
console.log(saveActionCount, 'action saved');
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
main()
|
|
250
|
+
.then()
|
|
251
|
+
.catch(console.error);
|
|
@@ -220,7 +220,7 @@ export declare class MongoRepository {
|
|
|
220
220
|
updateAuthorizeEventOfferAction(params: {
|
|
221
221
|
id: string;
|
|
222
222
|
object: factory.action.authorize.offer.eventService.IObject<factory.service.webAPI.Identifier.COA>;
|
|
223
|
-
result: factory.action.authorize.offer.eventService.IResult
|
|
223
|
+
result: factory.action.authorize.offer.eventService.IResult;
|
|
224
224
|
}): Promise<factory.action.authorize.offer.eventService.IAction<factory.service.webAPI.Identifier.COA>>;
|
|
225
225
|
updateById(params: {
|
|
226
226
|
id: string;
|
|
@@ -303,6 +303,7 @@ export declare class MongoRepository {
|
|
|
303
303
|
saveRecipeWithDateCreated(savingRecipe: IRecipeAsDocument & {
|
|
304
304
|
dateModified: Date;
|
|
305
305
|
}): Promise<import("mongodb").UpdateResult>;
|
|
306
|
+
saveActionWithEndDate(savingAction: Omit<factory.action.authorize.invoice.IAction, 'id'>): Promise<import("mongodb").UpdateResult>;
|
|
306
307
|
findRecipeByAction<T extends factory.recipe.RecipeCategory>(params: {
|
|
307
308
|
project: {
|
|
308
309
|
id: string;
|
|
@@ -8,6 +8,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
11
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
23
|
exports.MongoRepository = void 0;
|
|
13
24
|
const factory = require("../factory");
|
|
@@ -1115,6 +1126,31 @@ class MongoRepository {
|
|
|
1115
1126
|
.exec();
|
|
1116
1127
|
});
|
|
1117
1128
|
}
|
|
1129
|
+
saveActionWithEndDate(savingAction) {
|
|
1130
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1131
|
+
const { typeOf, project, agent, object } = savingAction, updateFields = __rest(savingAction, ["typeOf", "project", "agent", "object"]);
|
|
1132
|
+
const filter = {
|
|
1133
|
+
'project.id': { $eq: project.id },
|
|
1134
|
+
'agent.id': { $exists: true, $eq: agent.id },
|
|
1135
|
+
'object.typeOf': { $exists: true, $eq: object.typeOf },
|
|
1136
|
+
'object.paymentMethodId': { $exists: true, $eq: object.paymentMethodId },
|
|
1137
|
+
typeOf: { $eq: typeOf }
|
|
1138
|
+
// 'sameAs.id': { $exists: true, $eq: sameAs.id }
|
|
1139
|
+
};
|
|
1140
|
+
const setOnInsert = { typeOf, project, agent, object };
|
|
1141
|
+
const setKeys = updateFields;
|
|
1142
|
+
const update = {
|
|
1143
|
+
$setOnInsert: setOnInsert,
|
|
1144
|
+
$set: setKeys
|
|
1145
|
+
};
|
|
1146
|
+
const options = {
|
|
1147
|
+
upsert: true,
|
|
1148
|
+
rawResult: true
|
|
1149
|
+
};
|
|
1150
|
+
return this.actionModel.updateOne(filter, update, options)
|
|
1151
|
+
.exec();
|
|
1152
|
+
});
|
|
1153
|
+
}
|
|
1118
1154
|
findRecipeByAction(params) {
|
|
1119
1155
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1120
1156
|
return this.actionRecipeModel.findOne({
|
|
@@ -101,9 +101,6 @@ export declare class MongoRepository {
|
|
|
101
101
|
* タスク未エクスポートの取引をひとつ取得してエクスポートを開始する
|
|
102
102
|
*/
|
|
103
103
|
startExportTasks<T extends factory.assetTransactionType>(params: {
|
|
104
|
-
project?: {
|
|
105
|
-
id: string;
|
|
106
|
-
};
|
|
107
104
|
typeOf?: {
|
|
108
105
|
$in: T[];
|
|
109
106
|
};
|
|
@@ -115,13 +112,6 @@ export declare class MongoRepository {
|
|
|
115
112
|
};
|
|
116
113
|
};
|
|
117
114
|
}): Promise<Pick<factory.assetTransaction.ITransaction<T>, 'id' | 'typeOf'> | null>;
|
|
118
|
-
/**
|
|
119
|
-
* タスクエクスポートリトライ
|
|
120
|
-
* @deprecated use reexportTasksByExportAction
|
|
121
|
-
*/
|
|
122
|
-
reexportTasksByExportationStatus(params: {
|
|
123
|
-
intervalInMinutes: number;
|
|
124
|
-
}): Promise<void>;
|
|
125
115
|
reexportTasksByExportAction(params: {
|
|
126
116
|
intervalInMinutes: number;
|
|
127
117
|
}): Promise<void>;
|
|
@@ -409,7 +409,7 @@ class MongoRepository {
|
|
|
409
409
|
* タスク未エクスポートの取引をひとつ取得してエクスポートを開始する
|
|
410
410
|
*/
|
|
411
411
|
startExportTasks(params) {
|
|
412
|
-
var _a
|
|
412
|
+
var _a;
|
|
413
413
|
return __awaiter(this, void 0, void 0, function* () {
|
|
414
414
|
switch (params.status) {
|
|
415
415
|
case factory.transactionStatusType.InProgress:
|
|
@@ -418,7 +418,13 @@ class MongoRepository {
|
|
|
418
418
|
// no op
|
|
419
419
|
}
|
|
420
420
|
const typeOfIn = (_a = params.typeOf) === null || _a === void 0 ? void 0 : _a.$in;
|
|
421
|
-
return this.transactionModel.findOneAndUpdate(Object.assign(Object.assign(Object.assign(
|
|
421
|
+
return this.transactionModel.findOneAndUpdate(Object.assign(Object.assign(Object.assign({}, (Array.isArray(typeOfIn)) ? { typeOf: { $in: typeOfIn } } : undefined), { status: { $eq: params.status },
|
|
422
|
+
// remove dependency on tasksExportationStatus(2024-06-13~)
|
|
423
|
+
// tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Unexported },
|
|
424
|
+
'tasksExportAction.actionStatus': {
|
|
425
|
+
$exists: true,
|
|
426
|
+
$eq: factory.actionStatusType.PotentialActionStatus
|
|
427
|
+
} }), (typeof params.id === 'string') ? { _id: { $eq: params.id } } : undefined), {
|
|
422
428
|
'tasksExportAction.actionStatus': factory.actionStatusType.ActiveActionStatus,
|
|
423
429
|
'tasksExportAction.agent': { name: params.tasksExportAction.agent.name },
|
|
424
430
|
'tasksExportAction.startDate': new Date(),
|
|
@@ -433,48 +439,6 @@ class MongoRepository {
|
|
|
433
439
|
.then((doc) => (doc === null) ? null : doc.toObject());
|
|
434
440
|
});
|
|
435
441
|
}
|
|
436
|
-
/**
|
|
437
|
-
* タスクエクスポートリトライ
|
|
438
|
-
* @deprecated use reexportTasksByExportAction
|
|
439
|
-
*/
|
|
440
|
-
reexportTasksByExportationStatus(params) {
|
|
441
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
442
|
-
const reexportingTransactions = yield this.transactionModel.find({
|
|
443
|
-
tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Exporting },
|
|
444
|
-
updatedAt: {
|
|
445
|
-
$lt: moment()
|
|
446
|
-
.add(-params.intervalInMinutes, 'minutes')
|
|
447
|
-
.toDate()
|
|
448
|
-
}
|
|
449
|
-
})
|
|
450
|
-
.select({
|
|
451
|
-
_id: 1,
|
|
452
|
-
typeOf: 1,
|
|
453
|
-
status: 1
|
|
454
|
-
})
|
|
455
|
-
.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
456
|
-
.exec();
|
|
457
|
-
if (reexportingTransactions.length > 0) {
|
|
458
|
-
for (const reexportingTransaction of reexportingTransactions) {
|
|
459
|
-
yield this.transactionModel.updateOne({
|
|
460
|
-
_id: { $eq: reexportingTransaction.id },
|
|
461
|
-
tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Exporting }
|
|
462
|
-
}, {
|
|
463
|
-
tasksExportAction: {
|
|
464
|
-
actionStatus: factory.actionStatusType.PotentialActionStatus
|
|
465
|
-
},
|
|
466
|
-
tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported
|
|
467
|
-
})
|
|
468
|
-
.exec();
|
|
469
|
-
assetTransaction_2.assetTransactionEventEmitter.emitAssetTransactionStatusChanged({
|
|
470
|
-
id: reexportingTransaction.id,
|
|
471
|
-
typeOf: reexportingTransaction.typeOf,
|
|
472
|
-
status: reexportingTransaction.status
|
|
473
|
-
});
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
});
|
|
477
|
-
}
|
|
478
442
|
reexportTasksByExportAction(params) {
|
|
479
443
|
return __awaiter(this, void 0, void 0, function* () {
|
|
480
444
|
const reexportingTransactions = yield this.transactionModel.find({
|
|
@@ -522,7 +486,12 @@ class MongoRepository {
|
|
|
522
486
|
return __awaiter(this, void 0, void 0, function* () {
|
|
523
487
|
const delayedTransactions = yield this.transactionModel.find({
|
|
524
488
|
status: { $in: params.status.$in },
|
|
525
|
-
|
|
489
|
+
// remove dependency on tasksExportationStatus(2024-06-13~)
|
|
490
|
+
// tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Unexported },
|
|
491
|
+
'tasksExportAction.actionStatus': {
|
|
492
|
+
$exists: true,
|
|
493
|
+
$eq: factory.actionStatusType.PotentialActionStatus
|
|
494
|
+
},
|
|
526
495
|
endDate: {
|
|
527
496
|
$exists: true,
|
|
528
497
|
$lt: moment(params.now)
|
|
@@ -558,7 +527,12 @@ class MongoRepository {
|
|
|
558
527
|
const endDate = new Date();
|
|
559
528
|
yield this.transactionModel.updateOne({
|
|
560
529
|
_id: { $eq: params.id },
|
|
561
|
-
|
|
530
|
+
// remove dependency on tasksExportationStatus(2024-06-13~)
|
|
531
|
+
// tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Exporting }
|
|
532
|
+
'tasksExportAction.actionStatus': {
|
|
533
|
+
$exists: true,
|
|
534
|
+
$eq: factory.actionStatusType.ActiveActionStatus
|
|
535
|
+
}
|
|
562
536
|
}, {
|
|
563
537
|
tasksExportationStatus: factory.transactionTasksExportationStatus.Exported,
|
|
564
538
|
tasksExportedAt: endDate,
|
|
@@ -19,6 +19,7 @@ function createStartParams(params) {
|
|
|
19
19
|
throw new factory.errors.ArgumentNull('object.paymentMethod.identifier');
|
|
20
20
|
}
|
|
21
21
|
let totalPaymentDue;
|
|
22
|
+
let accountId = (_c = params.object.paymentMethod) === null || _c === void 0 ? void 0 : _c.accountId;
|
|
22
23
|
switch (params.paymentServiceType) {
|
|
23
24
|
case factory.service.paymentService.PaymentServiceType.FaceToFace:
|
|
24
25
|
// 対面決済ではとりあえず問答無用にJPY
|
|
@@ -34,22 +35,27 @@ function createStartParams(params) {
|
|
|
34
35
|
currency: factory.priceCurrency.JPY,
|
|
35
36
|
value: params.amount
|
|
36
37
|
};
|
|
38
|
+
accountId = ''; // 強制的に空文字化(2024-06-14~)
|
|
37
39
|
break;
|
|
38
40
|
case factory.service.paymentService.PaymentServiceType.MovieTicket:
|
|
39
|
-
const specifiedMovieTickets = (
|
|
41
|
+
const specifiedMovieTickets = (_d = params.object.paymentMethod) === null || _d === void 0 ? void 0 : _d.movieTickets;
|
|
40
42
|
totalPaymentDue = {
|
|
41
43
|
typeOf: 'MonetaryAmount',
|
|
42
44
|
currency: factory.unitCode.C62,
|
|
43
45
|
value: (Array.isArray(specifiedMovieTickets)) ? specifiedMovieTickets.length : 0
|
|
44
46
|
};
|
|
45
47
|
// MovieTicketIFの決済取引において最大同時着券数を設定可能にする(2023-03-27~)
|
|
46
|
-
const totalPaymentDueMaxValue = (
|
|
48
|
+
const totalPaymentDueMaxValue = (_g = (_f = (_e = params.paymentService) === null || _e === void 0 ? void 0 : _e.availableChannel) === null || _f === void 0 ? void 0 : _f.totalPaymentDue) === null || _g === void 0 ? void 0 : _g.maxValue;
|
|
47
49
|
const totalPaymentDueValue = totalPaymentDue.value;
|
|
48
50
|
if (typeof totalPaymentDueValue === 'number' && typeof totalPaymentDueMaxValue === 'number') {
|
|
49
51
|
if (totalPaymentDueValue > totalPaymentDueMaxValue) {
|
|
50
52
|
throw new factory.errors.Argument('paymentMethod.movieTickets', `Number of movieTickets must be less than or equal to ${totalPaymentDueMaxValue}`);
|
|
51
53
|
}
|
|
52
54
|
}
|
|
55
|
+
// 強制的にidentifierで上書き(2024-06-14~)
|
|
56
|
+
accountId = (Array.isArray(specifiedMovieTickets) && specifiedMovieTickets.length > 0)
|
|
57
|
+
? specifiedMovieTickets[0].identifier // 決済カードidentifierは1つのみ許可の前提
|
|
58
|
+
: '';
|
|
53
59
|
break;
|
|
54
60
|
default:
|
|
55
61
|
// no op
|
|
@@ -57,7 +63,6 @@ function createStartParams(params) {
|
|
|
57
63
|
const informPaymentParams = createInformPaymentParams({
|
|
58
64
|
paymentService: params.paymentService
|
|
59
65
|
});
|
|
60
|
-
const accountId = (_g = params.object.paymentMethod) === null || _g === void 0 ? void 0 : _g.accountId;
|
|
61
66
|
// currencyはデフォルトでJPY
|
|
62
67
|
let paymentMethodCurrency = factory.priceCurrency.JPY;
|
|
63
68
|
if (params.paymentServiceType === factory.service.paymentService.PaymentServiceType.PaymentCard) {
|
|
@@ -84,7 +89,7 @@ function createStartParams(params) {
|
|
|
84
89
|
currency: paymentMethodCurrency,
|
|
85
90
|
value: params.amount
|
|
86
91
|
};
|
|
87
|
-
const paymentMethod = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ additionalProperty: (Array.isArray((_p = params.object.paymentMethod) === null || _p === void 0 ? void 0 : _p.additionalProperty))
|
|
92
|
+
const paymentMethod = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ additionalProperty: (Array.isArray((_p = params.object.paymentMethod) === null || _p === void 0 ? void 0 : _p.additionalProperty))
|
|
88
93
|
? (_q = params.object.paymentMethod) === null || _q === void 0 ? void 0 : _q.additionalProperty
|
|
89
94
|
: [], name: (typeof ((_r = params.object.paymentMethod) === null || _r === void 0 ? void 0 : _r.name) === 'string')
|
|
90
95
|
? params.object.paymentMethod.name
|
|
@@ -98,6 +103,8 @@ function createStartParams(params) {
|
|
|
98
103
|
? { creditCard: (_x = params.object.paymentMethod) === null || _x === void 0 ? void 0 : _x.creditCard }
|
|
99
104
|
: undefined), (Array.isArray((_y = params.object.paymentMethod) === null || _y === void 0 ? void 0 : _y.movieTickets))
|
|
100
105
|
? { movieTickets: (_z = params.object.paymentMethod) === null || _z === void 0 ? void 0 : _z.movieTickets }
|
|
106
|
+
: undefined), (params.paymentServiceType === factory.service.paymentService.PaymentServiceType.CreditCard)
|
|
107
|
+
? { paymentMethodId: params.transactionNumber } // 必要ないはずだが互換性維持対応(2024-06-14~)
|
|
101
108
|
: undefined);
|
|
102
109
|
const object = {
|
|
103
110
|
// パラメータから必要なもののみ取り込む
|