@chevre/domain 20.0.0-alpha.1 → 20.0.0-alpha.2
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/checkOffersAppliesToMovieTicket.ts +1 -1
- package/example/src/chevre/processRegisterMembership.ts +0 -18
- package/example/src/chevre/processRegisterPaymentCard.ts +0 -18
- package/lib/chevre/repo/offer.js +0 -11
- package/lib/chevre/service/assetTransaction/pay/potentialActions.js +11 -7
- package/lib/chevre/service/assetTransaction/reserve/factory/price.js +6 -4
- package/lib/chevre/service/offer/product/factory.js +39 -3
- package/package.json +2 -2
|
@@ -33,7 +33,7 @@ async function main() {
|
|
|
33
33
|
let updateCount = 0;
|
|
34
34
|
await cursor.eachAsync(async (doc) => {
|
|
35
35
|
i += 1;
|
|
36
|
-
const offer = <chevre.factory.
|
|
36
|
+
const offer = <chevre.factory.unitPriceOffer.IUnitPriceOffer>doc.toObject();
|
|
37
37
|
const applieToMovieTicket = offer.priceSpecification?.appliesToMovieTicket;
|
|
38
38
|
if (Array.isArray(applieToMovieTicket)) {
|
|
39
39
|
console.log('is Array', offer.project.id, offer.id, i);
|
|
@@ -35,24 +35,6 @@ async function main() {
|
|
|
35
35
|
const product = products[0];
|
|
36
36
|
console.log(product);
|
|
37
37
|
|
|
38
|
-
// オファーカタログ検索
|
|
39
|
-
// const offerCatalog = await offerRepo.findOfferCatalogById({ id: product.hasOfferCatalog.id });
|
|
40
|
-
// console.log(offerCatalog);
|
|
41
|
-
|
|
42
|
-
// オファー検索
|
|
43
|
-
// const offers = await offerRepo.offerModel.find(
|
|
44
|
-
// { _id: { $in: (offerCatalog.itemListElement).map((e) => e.id) } },
|
|
45
|
-
// {
|
|
46
|
-
// __v: 0,
|
|
47
|
-
// createdAt: 0,
|
|
48
|
-
// updatedAt: 0
|
|
49
|
-
// }
|
|
50
|
-
// )
|
|
51
|
-
// .exec()
|
|
52
|
-
// .then((docs) => docs.map((doc) => doc.toObject()));
|
|
53
|
-
// console.log(offers);
|
|
54
|
-
// console.log(offers.length, 'offers found');
|
|
55
|
-
|
|
56
38
|
const identifier = `CIN${(new Date()).valueOf()}`;
|
|
57
39
|
const transaction = await chevre.service.assetTransaction.registerService.start({
|
|
58
40
|
project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
|
|
@@ -35,24 +35,6 @@ async function main() {
|
|
|
35
35
|
const product = products[0];
|
|
36
36
|
console.log(product);
|
|
37
37
|
|
|
38
|
-
// オファーカタログ検索
|
|
39
|
-
// const offerCatalog = await offerRepo.findOfferCatalogById({ id: product.hasOfferCatalog.id });
|
|
40
|
-
// console.log(offerCatalog);
|
|
41
|
-
|
|
42
|
-
// オファー検索
|
|
43
|
-
// const offers = await offerRepo.offerModel.find(
|
|
44
|
-
// { _id: { $in: (offerCatalog.itemListElement).map((e) => e.id) } },
|
|
45
|
-
// {
|
|
46
|
-
// __v: 0,
|
|
47
|
-
// createdAt: 0,
|
|
48
|
-
// updatedAt: 0
|
|
49
|
-
// }
|
|
50
|
-
// )
|
|
51
|
-
// .exec()
|
|
52
|
-
// .then((docs) => docs.map((doc) => doc.toObject()));
|
|
53
|
-
// console.log(offers);
|
|
54
|
-
// console.log(offers.length, 'offers found');
|
|
55
|
-
|
|
56
38
|
const transactionNumber = `CIN${(new Date()).valueOf()}`;
|
|
57
39
|
const identifier = transactionNumber;
|
|
58
40
|
const accessCode = '123';
|
package/lib/chevre/repo/offer.js
CHANGED
|
@@ -310,17 +310,6 @@ class MongoRepository {
|
|
|
310
310
|
: [];
|
|
311
311
|
let offers = [];
|
|
312
312
|
if (sortedOfferIds.length > 0) {
|
|
313
|
-
// offers = await this.offerModel.find(
|
|
314
|
-
// { _id: { $in: sortedOfferIds } },
|
|
315
|
-
// {
|
|
316
|
-
// __v: 0,
|
|
317
|
-
// createdAt: 0,
|
|
318
|
-
// updatedAt: 0
|
|
319
|
-
// }
|
|
320
|
-
// )
|
|
321
|
-
// .setOptions({ maxTimeMS: 10000 })
|
|
322
|
-
// .exec()
|
|
323
|
-
// .then((docs) => docs.map((doc) => doc.toObject()));
|
|
324
313
|
offers = yield this.search({ id: { $in: sortedOfferIds } });
|
|
325
314
|
// sorting
|
|
326
315
|
offers = offers.sort((a, b) => sortedOfferIds.indexOf(String(a.id)) - sortedOfferIds.indexOf(String(b.id)));
|
|
@@ -182,16 +182,20 @@ function movieTicket2reservation4invoice(movieTicket, order, paymentMethodType)
|
|
|
182
182
|
if (Array.isArray(priceComponent)) {
|
|
183
183
|
reservationPrice = priceComponent.reduce((a, b) => a + Number(b.price), 0);
|
|
184
184
|
priceComponents4invoice = priceComponent.map((component) => {
|
|
185
|
-
var _a
|
|
185
|
+
var _a;
|
|
186
|
+
const accounting = (typeof ((_a = component.accounting) === null || _a === void 0 ? void 0 : _a.accountsReceivable) === 'number')
|
|
187
|
+
? { accountsReceivable: component.accounting.accountsReceivable }
|
|
188
|
+
: undefined;
|
|
186
189
|
if (component.typeOf === factory.priceSpecificationType.UnitPriceSpecification) {
|
|
187
|
-
|
|
188
|
-
?
|
|
189
|
-
|
|
190
|
+
const appliesToAddOn = (Array.isArray(component.appliesToAddOn))
|
|
191
|
+
? component.appliesToAddOn.map((addOn) => {
|
|
192
|
+
return { typeOf: addOn.typeOf };
|
|
193
|
+
})
|
|
194
|
+
: undefined;
|
|
195
|
+
return Object.assign(Object.assign({ typeOf: component.typeOf, price: component.price, referenceQuantity: component.referenceQuantity }, (Array.isArray(appliesToAddOn)) ? { appliesToAddOn } : undefined), (typeof (accounting === null || accounting === void 0 ? void 0 : accounting.accountsReceivable) === 'number') ? { accounting } : undefined);
|
|
190
196
|
}
|
|
191
197
|
else {
|
|
192
|
-
return Object.assign({ typeOf: component.typeOf, price: component.price }, (typeof (
|
|
193
|
-
? { accounting: { accountsReceivable: component.accounting.accountsReceivable } }
|
|
194
|
-
: undefined);
|
|
198
|
+
return Object.assign({ typeOf: component.typeOf, price: component.price }, (typeof (accounting === null || accounting === void 0 ? void 0 : accounting.accountsReceivable) === 'number') ? { accounting } : undefined);
|
|
195
199
|
}
|
|
196
200
|
});
|
|
197
201
|
}
|
|
@@ -52,7 +52,7 @@ function createUnitPriceSpecsAppliedToAddOn(params) {
|
|
|
52
52
|
id: acceptedAddOn.itemOffered.id,
|
|
53
53
|
name: acceptedAddOn.itemOffered.name,
|
|
54
54
|
productID: acceptedAddOn.itemOffered.productID,
|
|
55
|
-
project: acceptedAddOn.itemOffered.project,
|
|
55
|
+
// project: acceptedAddOn.itemOffered.project,
|
|
56
56
|
typeOf: acceptedAddOn.itemOffered.typeOf
|
|
57
57
|
};
|
|
58
58
|
const appliesToAddOn = {
|
|
@@ -103,7 +103,7 @@ function createPriceSpecsByEventOffer(params) {
|
|
|
103
103
|
name: priceSpec.name,
|
|
104
104
|
price: priceSpec.price,
|
|
105
105
|
priceCurrency: priceSpec.priceCurrency,
|
|
106
|
-
project: priceSpec.project,
|
|
106
|
+
// project: priceSpec.project,
|
|
107
107
|
typeOf: priceSpec.typeOf,
|
|
108
108
|
appliesToVideoFormat: priceSpec.appliesToVideoFormat,
|
|
109
109
|
valueAddedTaxIncluded: priceSpec.valueAddedTaxIncluded,
|
|
@@ -116,7 +116,7 @@ function createPriceSpecsByEventOffer(params) {
|
|
|
116
116
|
name: priceSpec.name,
|
|
117
117
|
price: priceSpec.price,
|
|
118
118
|
priceCurrency: priceSpec.priceCurrency,
|
|
119
|
-
project: priceSpec.project,
|
|
119
|
+
// project: priceSpec.project,
|
|
120
120
|
typeOf: priceSpec.typeOf,
|
|
121
121
|
appliesToCategoryCode: priceSpec.appliesToCategoryCode,
|
|
122
122
|
valueAddedTaxIncluded: priceSpec.valueAddedTaxIncluded
|
|
@@ -194,5 +194,7 @@ function eventOfferUnitPriceSpec2reservationUnitPriceSpec(params) {
|
|
|
194
194
|
}
|
|
195
195
|
: undefined);
|
|
196
196
|
}
|
|
197
|
-
return Object.assign(Object.assign({ name: priceSpec.name, price: priceSpec.price, priceCurrency: priceSpec.priceCurrency,
|
|
197
|
+
return Object.assign(Object.assign({ name: priceSpec.name, price: priceSpec.price, priceCurrency: priceSpec.priceCurrency,
|
|
198
|
+
// project: priceSpec.project,
|
|
199
|
+
referenceQuantity: priceSpec.referenceQuantity, typeOf: priceSpec.typeOf, valueAddedTaxIncluded: priceSpec.valueAddedTaxIncluded }, (Array.isArray(appliesToMovieTicket)) ? { appliesToMovieTicket } : undefined), (typeof (accounting4reservation === null || accounting4reservation === void 0 ? void 0 : accounting4reservation.typeOf) === 'string') ? { accounting: accounting4reservation } : undefined);
|
|
198
200
|
}
|
|
@@ -82,8 +82,7 @@ function responseBody2resultAcceptedOffer(params) {
|
|
|
82
82
|
let acceptedOffers = [];
|
|
83
83
|
if (Array.isArray(params.responseBody.object)) {
|
|
84
84
|
acceptedOffers = params.responseBody.object.map((responseBodyObject) => {
|
|
85
|
-
var _a, _b, _c;
|
|
86
|
-
// const productTypeOf = responseBodyObject.itemOffered?.serviceOutput?.issuedThrough?.typeOf;
|
|
85
|
+
var _a, _b, _c, _d;
|
|
87
86
|
const serviceOutputIdentifier = (_b = (_a = responseBodyObject.itemOffered) === null || _a === void 0 ? void 0 : _a.serviceOutput) === null || _b === void 0 ? void 0 : _b.identifier;
|
|
88
87
|
if (serviceOutputIdentifier !== undefined && typeof serviceOutputIdentifier !== 'string') {
|
|
89
88
|
// 基本的にありえないフロー↓
|
|
@@ -96,13 +95,50 @@ function responseBody2resultAcceptedOffer(params) {
|
|
|
96
95
|
if (offer === undefined) {
|
|
97
96
|
throw new factory.errors.ServiceUnavailable(`Offer ${responseBodyObject.id} from registerService not found`);
|
|
98
97
|
}
|
|
98
|
+
if (typeof ((_d = offer.priceSpecification) === null || _d === void 0 ? void 0 : _d.typeOf) !== 'string') {
|
|
99
|
+
throw new factory.errors.NotFound('acceptedOffer.priceSpecification');
|
|
100
|
+
}
|
|
101
|
+
const priceSpecification = {
|
|
102
|
+
typeOf: offer.priceSpecification.typeOf,
|
|
103
|
+
valueAddedTaxIncluded: offer.priceSpecification.valueAddedTaxIncluded,
|
|
104
|
+
priceCurrency: offer.priceSpecification.priceCurrency,
|
|
105
|
+
priceComponent: offer.priceSpecification.priceComponent.map((component) => {
|
|
106
|
+
var _a, _b;
|
|
107
|
+
if (component.typeOf === factory.priceSpecificationType.UnitPriceSpecification) {
|
|
108
|
+
// tslint:disable-next-line:no-unnecessary-local-variable
|
|
109
|
+
const unitPriceComponent = Object.assign(Object.assign(Object.assign({ accounting: component.accounting, name: component.name, price: component.price, priceCurrency: component.priceCurrency, referenceQuantity: component.referenceQuantity, typeOf: component.typeOf, valueAddedTaxIncluded: component.valueAddedTaxIncluded }, (Array.isArray(component.appliesToAddOn))
|
|
110
|
+
? { appliesToAddOn: component.appliesToAddOn }
|
|
111
|
+
: undefined), (Array.isArray(component.appliesToMovieTicket))
|
|
112
|
+
? { appliesToMovieTicket: component.appliesToMovieTicket }
|
|
113
|
+
: undefined), (typeof ((_a = component.accounting) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string')
|
|
114
|
+
? {
|
|
115
|
+
accounting: Object.assign(Object.assign({ typeOf: component.accounting.typeOf }, (typeof component.accounting.accountsReceivable === 'number')
|
|
116
|
+
? { accountsReceivable: component.accounting.accountsReceivable }
|
|
117
|
+
: undefined), (typeof ((_b = component.accounting.operatingRevenue) === null || _b === void 0 ? void 0 : _b.typeOf) === 'string')
|
|
118
|
+
? {
|
|
119
|
+
operatingRevenue: {
|
|
120
|
+
project: component.accounting.operatingRevenue.project,
|
|
121
|
+
typeOf: component.accounting.operatingRevenue.typeOf,
|
|
122
|
+
codeValue: component.accounting.operatingRevenue.codeValue
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
: undefined)
|
|
126
|
+
}
|
|
127
|
+
: undefined);
|
|
128
|
+
return unitPriceComponent;
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
return component;
|
|
132
|
+
}
|
|
133
|
+
})
|
|
134
|
+
};
|
|
99
135
|
return {
|
|
100
136
|
project: { typeOf: params.project.typeOf, id: params.project.id },
|
|
101
137
|
typeOf: responseBodyObject.typeOf,
|
|
102
138
|
id: offer.id,
|
|
103
139
|
name: offer.name,
|
|
104
140
|
itemOffered,
|
|
105
|
-
priceSpecification
|
|
141
|
+
priceSpecification,
|
|
106
142
|
priceCurrency: offer.priceCurrency,
|
|
107
143
|
seller: offer.seller
|
|
108
144
|
};
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@chevre/factory": "4.
|
|
12
|
+
"@chevre/factory": "4.274.0-alpha.0",
|
|
13
13
|
"@cinerino/sdk": "3.130.0-alpha.1",
|
|
14
14
|
"@motionpicture/coa-service": "9.2.0",
|
|
15
15
|
"@motionpicture/gmo-service": "5.2.0",
|
|
@@ -120,5 +120,5 @@
|
|
|
120
120
|
"postversion": "git push origin --tags",
|
|
121
121
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
122
122
|
},
|
|
123
|
-
"version": "20.0.0-alpha.
|
|
123
|
+
"version": "20.0.0-alpha.2"
|
|
124
124
|
}
|