@chevre/domain 20.8.0 → 20.9.0-alpha.1

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.
@@ -0,0 +1,25 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+
4
+ import { chevre } from '../../../lib/index';
5
+
6
+ async function main() {
7
+ await mongoose.connect(<string>process.env.MONGOLAB_URI);
8
+
9
+ const transactionRepo = new chevre.repository.Transaction(mongoose.connection);
10
+
11
+ const transactions = await transactionRepo.search({
12
+ limit: 100,
13
+ page: 1,
14
+ typeOf: chevre.factory.transactionType.PlaceOrder,
15
+ result: { order: { confirmationNumber: { $eq: '96275' } } },
16
+ inclusion: ['result'],
17
+ exclusion: []
18
+ });
19
+ console.log(transactions);
20
+ console.log(transactions.length);
21
+ }
22
+
23
+ main()
24
+ .then(console.log)
25
+ .catch(console.error);
@@ -17,7 +17,6 @@ export declare class MongoRepository {
17
17
  findById(params: {
18
18
  id: string;
19
19
  }, projection?: any): Promise<IOwnershipInfo>;
20
- count(params: factory.ownershipInfo.ISearchConditions): Promise<number>;
21
20
  /**
22
21
  * 所有権を検索する
23
22
  */
@@ -277,14 +277,12 @@ class MongoRepository {
277
277
  return doc.toObject();
278
278
  });
279
279
  }
280
- count(params) {
281
- return __awaiter(this, void 0, void 0, function* () {
282
- const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
283
- return this.ownershipInfoModel.countDocuments((conditions.length > 0) ? { $and: conditions } : {})
284
- .setOptions({ maxTimeMS: 10000 })
285
- .exec();
286
- });
287
- }
280
+ // public async count(params: factory.ownershipInfo.ISearchConditions): Promise<number> {
281
+ // const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
282
+ // return this.ownershipInfoModel.countDocuments((conditions.length > 0) ? { $and: conditions } : {})
283
+ // .setOptions({ maxTimeMS: 10000 })
284
+ // .exec();
285
+ // }
288
286
  /**
289
287
  * 所有権を検索する
290
288
  */
@@ -145,7 +145,10 @@ export declare class MongoRepository {
145
145
  /**
146
146
  * 取引を検索する
147
147
  */
148
- search<T extends factory.transactionType>(params: factory.transaction.ISearchConditions<T>): Promise<factory.transaction.ITransaction<T>[]>;
148
+ search<T extends factory.transactionType>(params: factory.transaction.ISearchConditions<T> & {
149
+ inclusion: string[];
150
+ exclusion: string[];
151
+ }): Promise<factory.transaction.ITransaction<T>[]>;
149
152
  /**
150
153
  * 特定の取引を更新する(汎用)
151
154
  */
@@ -571,8 +571,26 @@ class MongoRepository {
571
571
  search(params) {
572
572
  return __awaiter(this, void 0, void 0, function* () {
573
573
  const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
574
+ let projection = {};
575
+ if (Array.isArray(params.inclusion) && params.inclusion.length > 0) {
576
+ params.inclusion.forEach((field) => {
577
+ projection[field] = 1;
578
+ });
579
+ }
580
+ else {
581
+ projection = {
582
+ __v: 0,
583
+ createdAt: 0,
584
+ updatedAt: 0
585
+ };
586
+ if (Array.isArray(params.exclusion) && params.exclusion.length > 0) {
587
+ params.exclusion.forEach((field) => {
588
+ projection[field] = 0;
589
+ });
590
+ }
591
+ }
574
592
  const query = this.transactionModel.find((conditions.length > 0) ? { $and: conditions } : {})
575
- .select({ __v: 0, createdAt: 0, updatedAt: 0 });
593
+ .select(projection);
576
594
  if (typeof params.limit === 'number') {
577
595
  const page = (typeof params.page === 'number') ? params.page : 1;
578
596
  query.limit(params.limit)
@@ -48,6 +48,7 @@ function createAppliesToMovieTicket(params) {
48
48
  }
49
49
  return { movieTicketTypeChargePriceSpec, appliesToMovieTicket };
50
50
  }
51
+ // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
51
52
  function createPriceComponent(params) {
52
53
  var _a, _b, _c, _d, _e, _f, _g;
53
54
  const acceptedOffer = params.acceptedOffer;
@@ -97,11 +98,15 @@ function createPriceComponent(params) {
97
98
  eligibleMonetaryAmount = availableUnitPriceOffer.eligibleMonetaryAmount;
98
99
  }
99
100
  }
101
+ const accountsReceivable = (ticketInfo.mvtkSalesPrice > 0) ? ticketInfo.mvtkSalesPrice : ticketInfo.stdPrice;
100
102
  const unitPriceSpec = Object.assign({ typeOf: factory.priceSpecificationType.UnitPriceSpecification, name: { ja: ticketInfo.ticketName, en: ticketInfo.ticketNameEng }, price: Number(ticketInfo.stdPrice), priceCurrency: factory.priceCurrency.JPY, referenceQuantity: {
101
103
  typeOf: 'QuantitativeValue',
102
104
  unitCode: factory.unitCode.C62,
103
105
  value: 1
104
- }, valueAddedTaxIncluded: true }, (appliesToMovieTicket !== undefined || appliesToMovieTicket4surfrock !== undefined)
106
+ }, valueAddedTaxIncluded: true, accounting: {
107
+ typeOf: 'Accounting',
108
+ accountsReceivable
109
+ } }, (appliesToMovieTicket !== undefined || appliesToMovieTicket4surfrock !== undefined)
105
110
  ? {
106
111
  appliesToMovieTicket: [
107
112
  ...(appliesToMovieTicket !== undefined) ? [appliesToMovieTicket] : [],
@@ -120,10 +125,80 @@ function createPriceComponent(params) {
120
125
  default:
121
126
  unitPriceSpec.referenceQuantity.value = 1;
122
127
  }
128
+ // 区分加算料金
129
+ const categoryCodeChargeSpecs = [];
130
+ if (ticketInfo.addPrice > 0) {
131
+ categoryCodeChargeSpecs.push({
132
+ name: {
133
+ en: factory.priceSpecificationType.CategoryCodeChargeSpecification,
134
+ ja: '加算単価'
135
+ },
136
+ price: ticketInfo.addPrice,
137
+ priceCurrency: factory.priceCurrency.JPY,
138
+ typeOf: factory.priceSpecificationType.CategoryCodeChargeSpecification,
139
+ appliesToCategoryCode: [],
140
+ valueAddedTaxIncluded: true
141
+ });
142
+ }
143
+ if (ticketInfo.spseatAdd1 > 0) {
144
+ categoryCodeChargeSpecs.push({
145
+ name: {
146
+ en: factory.priceSpecificationType.CategoryCodeChargeSpecification,
147
+ ja: '特別席加算額1'
148
+ },
149
+ price: ticketInfo.spseatAdd1,
150
+ priceCurrency: factory.priceCurrency.JPY,
151
+ typeOf: factory.priceSpecificationType.CategoryCodeChargeSpecification,
152
+ appliesToCategoryCode: [],
153
+ valueAddedTaxIncluded: true
154
+ });
155
+ }
156
+ if (ticketInfo.spseatAdd2 > 0) {
157
+ categoryCodeChargeSpecs.push({
158
+ name: {
159
+ en: factory.priceSpecificationType.CategoryCodeChargeSpecification,
160
+ ja: '特別席加算額2'
161
+ },
162
+ price: ticketInfo.spseatAdd2,
163
+ priceCurrency: factory.priceCurrency.JPY,
164
+ typeOf: factory.priceSpecificationType.CategoryCodeChargeSpecification,
165
+ appliesToCategoryCode: [],
166
+ valueAddedTaxIncluded: true
167
+ });
168
+ }
169
+ // アドオン単価仕様
170
+ let addOnUnitPriceSpec;
171
+ if (ticketInfo.addGlasses > 0) {
172
+ addOnUnitPriceSpec = {
173
+ typeOf: factory.priceSpecificationType.UnitPriceSpecification,
174
+ name: { ja: 'メガネ', en: 'Glasses' },
175
+ price: Number(ticketInfo.addGlasses),
176
+ priceCurrency: factory.priceCurrency.JPY,
177
+ referenceQuantity: {
178
+ typeOf: 'QuantitativeValue',
179
+ unitCode: factory.unitCode.C62,
180
+ value: 1
181
+ },
182
+ valueAddedTaxIncluded: true,
183
+ appliesToAddOn: [{
184
+ typeOf: factory.offerType.Offer,
185
+ // id?: string;
186
+ // identifier?: string;
187
+ itemOffered: {
188
+ // id: '',
189
+ // name :'',
190
+ productID: '',
191
+ typeOf: factory.product.ProductType.Product
192
+ }
193
+ }]
194
+ };
195
+ }
123
196
  const priceComponent = [
124
197
  unitPriceSpec,
125
198
  ...(movieTicketTypeChargePriceSpec !== undefined) ? [movieTicketTypeChargePriceSpec] : [],
126
- ...(surfrockChargePriceSpec !== undefined) ? [surfrockChargePriceSpec] : []
199
+ ...(surfrockChargePriceSpec !== undefined) ? [surfrockChargePriceSpec] : [],
200
+ ...categoryCodeChargeSpecs,
201
+ ...(addOnUnitPriceSpec !== undefined) ? [addOnUnitPriceSpec] : []
127
202
  ];
128
203
  return { priceComponent, eligibleMonetaryAmount };
129
204
  }
@@ -25,7 +25,9 @@ function findPlaceOrderTransaction(params) {
25
25
  confirmationNumber: { $eq: params.confirmationNumber },
26
26
  orderNumbers: [params.orderNumber]
27
27
  }
28
- }
28
+ },
29
+ inclusion: [],
30
+ exclusion: []
29
31
  });
30
32
  const placeOrderTransaction = placeOrderTransactions.shift();
31
33
  if (placeOrderTransaction === undefined) {
@@ -33,7 +33,9 @@ function returnOrder(params) {
33
33
  project: { id: { $eq: order.project.id } },
34
34
  typeOf: factory.transactionType.ReturnOrder,
35
35
  statuses: [factory.transactionStatusType.Confirmed],
36
- object: { order: { orderNumbers: [orderNumber] } }
36
+ object: { order: { orderNumbers: [orderNumber] } },
37
+ inclusion: [],
38
+ exclusion: []
37
39
  });
38
40
  const returnOrderTransaction = returnOrderTransactions.shift();
39
41
  if (returnOrderTransaction === undefined) {
@@ -222,7 +222,9 @@ function createSellerFlowTransactionResult(measuredFrom, measuredThrough, seller
222
222
  seller: { ids: [sellerId] },
223
223
  startFrom: measuredFrom,
224
224
  startThrough: measuredThrough,
225
- endThrough: new Date()
225
+ endThrough: new Date(),
226
+ inclusion: [],
227
+ exclusion: []
226
228
  });
227
229
  const numberOfStartedAndConfirmed = startedAndEndedTransactions.filter((transaction) => transaction.status === factory.transactionStatusType.Confirmed).length;
228
230
  const numberOfStartedAndExpired = startedAndEndedTransactions.filter((transaction) => transaction.status === factory.transactionStatusType.Expired).length;
@@ -230,7 +232,9 @@ function createSellerFlowTransactionResult(measuredFrom, measuredThrough, seller
230
232
  typeOf: factory.transactionType.PlaceOrder,
231
233
  seller: { ids: [sellerId] },
232
234
  endFrom: measuredFrom,
233
- endThrough: measuredThrough
235
+ endThrough: measuredThrough,
236
+ inclusion: [],
237
+ exclusion: []
234
238
  });
235
239
  debug(endedTransactions.length, 'endedTransactions found.');
236
240
  const confirmedTransactions = endedTransactions.filter((transaction) => transaction.status === factory.transactionStatusType.Confirmed);
@@ -54,7 +54,9 @@ function returnPayTransaction(params) {
54
54
  limit: 1,
55
55
  page: 1,
56
56
  typeOf: factory.transactionType.ReturnOrder,
57
- object: { order: { orderNumbers: [orderNumber] } }
57
+ object: { order: { orderNumbers: [orderNumber] } },
58
+ inclusion: [],
59
+ exclusion: []
58
60
  });
59
61
  const returnOrderTransaction = returnOrderTransactions.shift();
60
62
  if (returnOrderTransaction === undefined) {
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  ],
11
11
  "dependencies": {
12
12
  "@chevre/factory": "4.302.0",
13
- "@cinerino/sdk": "3.149.0",
13
+ "@cinerino/sdk": "3.150.0",
14
14
  "@motionpicture/coa-service": "9.2.0",
15
15
  "@motionpicture/gmo-service": "5.2.0",
16
16
  "@sendgrid/mail": "6.4.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.8.0"
123
+ "version": "20.9.0-alpha.1"
124
124
  }
@@ -1,22 +0,0 @@
1
- // tslint:disable:no-console
2
- import * as mongoose from 'mongoose';
3
-
4
- import { chevre } from '../../../lib/index';
5
-
6
- async function main() {
7
- await mongoose.connect(<string>process.env.MONGOLAB_URI);
8
-
9
- const taskRepo = new chevre.repository.Task(mongoose.connection);
10
-
11
- const tasks = await taskRepo.search({
12
- limit: 100,
13
- page: 1,
14
- id: { $eq: '63b7a54d8ba861284895937f' }
15
- });
16
- console.log(tasks);
17
- console.log(tasks.length);
18
- }
19
-
20
- main()
21
- .then(console.log)
22
- .catch(console.error);