@chevre/domain 20.4.0-alpha.3 → 20.4.0-alpha.30

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.
Files changed (79) hide show
  1. package/example/src/chevre/aggregateEventReservation.ts +1 -1
  2. package/example/src/chevre/createManyEventsIfNotExist.ts +10 -10
  3. package/example/src/chevre/deleteMovieTicketCategoryChargePriceSpecs.ts +21 -0
  4. package/example/src/chevre/migrateMoneyTransferPendingTransactionIdentifier.ts +96 -0
  5. package/example/src/chevre/reIndex.ts +25 -0
  6. package/example/src/chevre/searchEventTicketOffers.ts +7 -4
  7. package/example/src/chevre/searchOfferCatalogs.ts +14 -16
  8. package/example/src/chevre/searchOffersByCatalog.ts +2 -1
  9. package/example/src/chevre/searchTasks.ts +22 -0
  10. package/example/src/chevre/unsetUnnecessaryFields.ts +21 -0
  11. package/lib/chevre/repo/account.d.ts +4 -10
  12. package/lib/chevre/repo/account.js +72 -60
  13. package/lib/chevre/repo/assetTransaction.d.ts +1 -0
  14. package/lib/chevre/repo/assetTransaction.js +5 -0
  15. package/lib/chevre/repo/code.d.ts +0 -7
  16. package/lib/chevre/repo/code.js +0 -17
  17. package/lib/chevre/repo/event.d.ts +5 -4
  18. package/lib/chevre/repo/event.js +12 -30
  19. package/lib/chevre/repo/mongoose/model/comments.d.ts +1 -1
  20. package/lib/chevre/repo/mongoose/model/comments.js +1 -1
  21. package/lib/chevre/repo/mongoose/model/offer.js +19 -9
  22. package/lib/chevre/repo/mongoose/model/priceSpecification.js +19 -52
  23. package/lib/chevre/repo/offer.d.ts +17 -2
  24. package/lib/chevre/repo/offer.js +77 -44
  25. package/lib/chevre/repo/offerCatalog.d.ts +3 -5
  26. package/lib/chevre/repo/offerCatalog.js +78 -37
  27. package/lib/chevre/repo/priceSpecification.d.ts +11 -0
  28. package/lib/chevre/repo/priceSpecification.js +44 -66
  29. package/lib/chevre/repo/serviceOutput.d.ts +4 -0
  30. package/lib/chevre/repo/serviceOutput.js +6 -0
  31. package/lib/chevre/repo/task.js +13 -9
  32. package/lib/chevre/repository.d.ts +6 -0
  33. package/lib/chevre/repository.js +8 -1
  34. package/lib/chevre/service/account.d.ts +0 -8
  35. package/lib/chevre/service/account.js +16 -10
  36. package/lib/chevre/service/accountTransaction/deposit.js +2 -1
  37. package/lib/chevre/service/accountTransaction/factory.js +25 -20
  38. package/lib/chevre/service/accountTransaction/transfer.js +4 -2
  39. package/lib/chevre/service/accountTransaction/withdraw.js +2 -1
  40. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +46 -83
  41. package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +3 -1
  42. package/lib/chevre/service/assetTransaction/moneyTransfer.js +19 -11
  43. package/lib/chevre/service/assetTransaction/pay.js +19 -14
  44. package/lib/chevre/service/assetTransaction/registerService/factory.js +9 -4
  45. package/lib/chevre/service/assetTransaction/reserve.js +2 -15
  46. package/lib/chevre/service/assetTransaction.d.ts +1 -1
  47. package/lib/chevre/service/code.d.ts +0 -8
  48. package/lib/chevre/service/code.js +1 -38
  49. package/lib/chevre/service/delivery.js +12 -3
  50. package/lib/chevre/service/event.js +0 -3
  51. package/lib/chevre/service/moneyTransfer.d.ts +1 -1
  52. package/lib/chevre/service/moneyTransfer.js +7 -8
  53. package/lib/chevre/service/offer/event/authorize.js +3 -4
  54. package/lib/chevre/service/offer/event/factory.js +1 -1
  55. package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +6 -7
  56. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +164 -314
  57. package/lib/chevre/service/offer/factory.d.ts +6 -1
  58. package/lib/chevre/service/offer/factory.js +42 -24
  59. package/lib/chevre/service/offer/moneyTransfer/authorize.js +0 -1
  60. package/lib/chevre/service/offer/moneyTransfer/returnMoneyTransfer.js +0 -1
  61. package/lib/chevre/service/offer/product/searchProductOffers.js +5 -1
  62. package/lib/chevre/service/payment/any/factory.js +29 -2
  63. package/lib/chevre/service/payment/any.js +11 -4
  64. package/lib/chevre/service/payment/movieTicket.d.ts +7 -2
  65. package/lib/chevre/service/payment/movieTicket.js +17 -8
  66. package/lib/chevre/service/payment/paymentCard.d.ts +6 -2
  67. package/lib/chevre/service/payment/paymentCard.js +16 -8
  68. package/lib/chevre/service/permit.d.ts +5 -1
  69. package/lib/chevre/service/permit.js +18 -11
  70. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +25 -53
  71. package/lib/chevre/service/transaction/moneyTransfer.js +0 -1
  72. package/lib/chevre/settings.d.ts +4 -0
  73. package/lib/chevre/settings.js +8 -2
  74. package/package.json +3 -3
  75. package/example/src/chevre/migrateAccountTitleAdditionalProperties.ts +0 -157
  76. package/example/src/chevre/migrateProjectSubscription.ts +0 -51
  77. package/example/src/chevre/migrateSection.ts +0 -105
  78. package/lib/chevre/service/task/deleteAuthorization.d.ts +0 -6
  79. package/lib/chevre/service/task/deleteAuthorization.js +0 -29
@@ -16,7 +16,7 @@ async function main() {
16
16
 
17
17
  // const now = new Date();
18
18
  await chevre.service.aggregation.event.aggregateScreeningEvent({
19
- id: 'alb35u7m4'
19
+ id: 'blaqxj0ak'
20
20
  })({
21
21
  event: new chevre.repository.Event(mongoose.connection),
22
22
  eventAvailability: new chevre.repository.itemAvailability.ScreeningEvent(client),
@@ -31,16 +31,16 @@ async function main() {
31
31
  .toDate(),
32
32
  endDate: moment('2023-02-01T06:00:00.000Z')
33
33
  .toDate(),
34
- workPerformed: {
35
- typeOf: chevre.factory.creativeWorkType.Movie,
36
- identifier: '1622100',
37
- id: '5bfb841d5a78d7948369980a',
38
- name: {
39
- en: 'Pet',
40
- ja: 'ペット'
41
- },
42
- duration: 'PT2H3M'
43
- },
34
+ // workPerformed: {
35
+ // typeOf: chevre.factory.creativeWorkType.Movie,
36
+ // identifier: '1622100',
37
+ // id: '5bfb841d5a78d7948369980a',
38
+ // name: {
39
+ // en: 'Pet',
40
+ // ja: 'ペット'
41
+ // },
42
+ // duration: 'PT2H3M'
43
+ // },
44
44
  location: {
45
45
  typeOf: chevre.factory.placeType.ScreeningRoom,
46
46
  branchCode: '10',
@@ -0,0 +1,21 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+
4
+ import { chevre } from '../../../lib/index';
5
+
6
+ const project = { id: process.env.PROJECT_ID };
7
+
8
+ async function main() {
9
+ await mongoose.connect(<string>process.env.MONGOLAB_URI);
10
+
11
+ const priceSpecificationRepo = new chevre.repository.PriceSpecification(mongoose.connection);
12
+
13
+ const result = await priceSpecificationRepo.deleteUnnecessaryMovieTicketTypeChargePriceSpecs({
14
+ project: { id: project.id }
15
+ });
16
+ console.log('deleted', result);
17
+ }
18
+
19
+ main()
20
+ .then()
21
+ .catch(console.error);
@@ -0,0 +1,96 @@
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
+ const project = { id: String(process.env.PROJECT_ID) };
8
+
9
+ // tslint:disable-next-line:max-func-body-length
10
+ async function main() {
11
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
12
+
13
+ const accountTransactionRepo = new chevre.repository.AccountTransaction(mongoose.connection);
14
+ const assetTransactionRepo = new chevre.repository.AssetTransaction(mongoose.connection);
15
+
16
+ const cursor = assetTransactionRepo.getCursor(
17
+ {
18
+ 'project.id': { $eq: project.id },
19
+ typeOf: { $eq: chevre.factory.assetTransactionType.MoneyTransfer },
20
+ startDate: {
21
+ $gte: moment('2023-02-17T15:00:00Z')
22
+ .toDate()
23
+ }
24
+ // _id: { $eq: 'al6aff83w' }
25
+ },
26
+ {
27
+ // _id: 1,
28
+ }
29
+ );
30
+ console.log('assetTransactions found');
31
+
32
+ let i = 0;
33
+ let updateCount = 0;
34
+ // tslint:disable-next-line:max-func-body-length
35
+ await cursor.eachAsync(async (doc) => {
36
+ i += 1;
37
+ const moneyTransferTransaction: chevre.factory.assetTransaction.moneyTransfer.ITransaction = doc.toObject();
38
+
39
+ const description = moneyTransferTransaction.object.description;
40
+ if (description !== '鑑賞' && description !== '受け取り') {
41
+ console.log(
42
+ 'no operation needed',
43
+ description,
44
+ moneyTransferTransaction.project.id,
45
+ moneyTransferTransaction.transactionNumber,
46
+ moneyTransferTransaction.startDate
47
+ );
48
+ } else {
49
+ const pendingTransactionIdentifier = moneyTransferTransaction.object.pendingTransaction?.identifier;
50
+ if (typeof pendingTransactionIdentifier === 'string' && pendingTransactionIdentifier.length > 0) {
51
+ console.log(
52
+ 'pendingTransactionIdentifier found',
53
+ description,
54
+ moneyTransferTransaction.project.id,
55
+ moneyTransferTransaction.transactionNumber,
56
+ moneyTransferTransaction.startDate
57
+ );
58
+ } else {
59
+ // 口座取引からidentifierを取得
60
+ const accountTransaction =
61
+ await accountTransactionRepo.findByTransactionNumber({ transactionNumber: moneyTransferTransaction.transactionNumber });
62
+ console.log(
63
+ 'updating identifier...',
64
+ accountTransaction.identifier,
65
+ description,
66
+ moneyTransferTransaction.project.id,
67
+ moneyTransferTransaction.transactionNumber,
68
+ moneyTransferTransaction.startDate
69
+ );
70
+ if (typeof accountTransaction.identifier === 'string') {
71
+ await assetTransactionRepo.findByIdAndUpdate({
72
+ id: moneyTransferTransaction.id,
73
+ update: {
74
+ 'object.pendingTransaction.identifier': accountTransaction.identifier
75
+ }
76
+ });
77
+ }
78
+ console.log(
79
+ 'ientifier updated',
80
+ accountTransaction.identifier,
81
+ description,
82
+ moneyTransferTransaction.project.id,
83
+ moneyTransferTransaction.transactionNumber,
84
+ moneyTransferTransaction.startDate
85
+ );
86
+ updateCount += 1;
87
+ }
88
+ }
89
+ });
90
+ console.log(i, 'assetTransactions checked');
91
+ console.log(updateCount, 'assetTransactions updated');
92
+ }
93
+
94
+ main()
95
+ .then()
96
+ .catch(console.error);
@@ -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 priceSpecificationRepo = new chevre.repository.PriceSpecification(mongoose.connection);
10
+ const result = await priceSpecificationRepo.reIndex();
11
+ console.log(result);
12
+ }
13
+
14
+ main()
15
+ .then()
16
+ .catch(console.error);
17
+ // setInterval(
18
+ // () => {
19
+ // main()
20
+ // .then()
21
+ // .catch(console.error);
22
+ // },
23
+ // // tslint:disable-next-line:no-magic-numbers
24
+ // 60000
25
+ // );
@@ -22,11 +22,13 @@ async function main() {
22
22
  const productRepo = new chevre.repository.Product(mongoose.connection);
23
23
 
24
24
  const { ticketOffers } = await chevre.service.offer.event.searchEventTicketOffers({
25
- event: { id: 'al9ew43f5' },
25
+ event: { id: 'ale6qiedi' },
26
26
  onlyValid: true,
27
- sort: true,
28
- validateOfferRateLimit: true
29
- // ...(typeof sellerId === 'string') ? { seller: { id: sellerId } } : undefined,
27
+ sort: false,
28
+ validateOfferRateLimit: true,
29
+ addSortIndex: true,
30
+ limit: 100,
31
+ page: 1
30
32
  // ...(typeof availableAtId === 'string') ? { store: { id: availableAtId } } : undefined
31
33
  })({
32
34
  event: eventRepo,
@@ -35,6 +37,7 @@ async function main() {
35
37
  priceSpecification: priceSpecificationRepo,
36
38
  product: productRepo
37
39
  });
40
+ console.log(ticketOffers.map((o) => o.sortIndex));
38
41
  console.log(ticketOffers.length);
39
42
  }
40
43
 
@@ -1,28 +1,26 @@
1
1
  // tslint:disable:no-console
2
- // import * as redis from 'redis';
3
2
  import * as mongoose from 'mongoose';
4
3
 
5
4
  import { chevre } from '../../../lib/index';
6
5
 
6
+ const PROJECT_ID = process.env.PROJECT_ID;
7
+
7
8
  async function main() {
8
9
  await mongoose.connect(<string>process.env.MONGOLAB_URI);
9
10
 
10
- const offerCatalogRepo = new chevre.repository.OfferCatalog(mongoose.connection);
11
+ const catalogRepo = new chevre.repository.OfferCatalog(mongoose.connection);
11
12
 
12
- const catalogs = await offerCatalogRepo.search({
13
- limit: 100,
14
- page: 1,
15
- // id: { $in: ['0001'] },
16
- itemListElement: {
17
- id: {
18
- $all: ['901', '3001']
19
- // $in: ['1001'],
20
- // $nin: ['1005']
21
- }
22
- },
23
- itemOffered: { typeOf: { $eq: chevre.factory.product.ProductType.EventService } }
24
- });
25
- console.log(catalogs);
13
+ console.log('searching...');
14
+ const catalogs = await catalogRepo.search(
15
+ {
16
+ project: { id: { $eq: PROJECT_ID } },
17
+ identifier: { $eq: '0001' },
18
+ sort: { identifier: chevre.factory.sortType.Descending },
19
+ limit: 2,
20
+ page: 1
21
+ }
22
+ );
23
+ console.log('catalogs found', catalogs.map((catalog) => `${catalog.identifier} ${catalog.numberOfItems}`));
26
24
  console.log(catalogs.length);
27
25
  }
28
26
 
@@ -9,13 +9,14 @@ async function main() {
9
9
 
10
10
  const offerRepo = new chevre.repository.Offer(mongoose.connection);
11
11
 
12
- const offers = await offerRepo.findOffersByOfferCatalogId({
12
+ const { offers } = await offerRepo.findOffersByOfferCatalogId({
13
13
  ids: ['al96nqj7z', 'xxx', '1001'],
14
14
  // ids: ['xx', 'xxx'],
15
15
  offerCatalog: {
16
16
  id: '0001'
17
17
  // id: 'xxx'
18
18
  },
19
+ excludeAppliesToMovieTicket: false,
19
20
  sort: true
20
21
  });
21
22
  console.log(offers.map((o) => o.id));
@@ -0,0 +1,22 @@
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);
@@ -0,0 +1,21 @@
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 offerRepo = new chevre.repository.Offer(mongoose.connection);
10
+
11
+ let updateResult: any;
12
+ updateResult = await offerRepo.unsetUnnecessaryFields({
13
+ filter: { 'category.project': { $exists: true } },
14
+ $unset: { 'category.project': 1 }
15
+ });
16
+ console.log('offers unset', updateResult);
17
+ }
18
+
19
+ main()
20
+ .then()
21
+ .catch(console.error);
@@ -45,16 +45,6 @@ export declare class MongoRepository {
45
45
  /**
46
46
  * 口座を解約する
47
47
  */
48
- close(params: {
49
- /**
50
- * 口座番号
51
- */
52
- accountNumber: string;
53
- /**
54
- * 解約日時
55
- */
56
- closeDate: Date;
57
- }): Promise<void>;
58
48
  /**
59
49
  * 口座番号で検索する
60
50
  */
@@ -134,4 +124,8 @@ export declare class MongoRepository {
134
124
  * 口座を検索する
135
125
  */
136
126
  search(params: factory.account.ISearchConditions): Promise<factory.account.IAccount[]>;
127
+ unsetUnnecessaryFields(params: {
128
+ filter: any;
129
+ $unset: any;
130
+ }): Promise<import("mongoose").UpdateWriteOpResult>;
137
131
  }
@@ -10,11 +10,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.MongoRepository = exports.modelName = void 0;
13
- const createDebug = require("debug");
14
13
  const account_1 = require("./mongoose/model/account");
15
14
  Object.defineProperty(exports, "modelName", { enumerable: true, get: function () { return account_1.modelName; } });
16
15
  const factory = require("../factory");
17
- const debug = createDebug('chevre-domain:repository');
18
16
  /**
19
17
  * 口座リポジトリ
20
18
  */
@@ -93,11 +91,11 @@ class MongoRepository {
93
91
  }
94
92
  // tslint:disable-next-line:no-single-line-block-comment
95
93
  /* istanbul ignore else */
96
- if (Array.isArray(params.statuses) && params.statuses.length > 0) {
97
- andConditions.push({
98
- status: { $in: params.statuses }
99
- });
100
- }
94
+ // if (Array.isArray(params.statuses) && params.statuses.length > 0) {
95
+ // andConditions.push({
96
+ // status: { $in: params.statuses }
97
+ // });
98
+ // }
101
99
  const nameRegex = (_d = params.name) === null || _d === void 0 ? void 0 : _d.$regex;
102
100
  // tslint:disable-next-line:no-single-line-block-comment
103
101
  /* istanbul ignore else */
@@ -159,8 +157,8 @@ class MongoRepository {
159
157
  balance: p.initialBalance,
160
158
  availableBalance: p.initialBalance,
161
159
  pendingTransactions: [],
162
- openDate: p.openDate,
163
- status: factory.account.AccountStatusType.Opened
160
+ openDate: p.openDate
161
+ // status: factory.account.AccountStatusType.Opened
164
162
  };
165
163
  });
166
164
  // const doc = await this.accountModel.create(account);
@@ -179,39 +177,47 @@ class MongoRepository {
179
177
  /**
180
178
  * 口座を解約する
181
179
  */
182
- close(params) {
183
- return __awaiter(this, void 0, void 0, function* () {
184
- debug('closing account...');
185
- const doc = yield this.accountModel.findOneAndUpdate({
186
- accountNumber: params.accountNumber,
187
- pendingTransactions: { $size: 0 },
188
- status: factory.account.AccountStatusType.Opened
189
- }, {
190
- closeDate: params.closeDate,
191
- status: factory.account.AccountStatusType.Closed
192
- }, {
193
- new: true
194
- })
195
- .exec();
196
- // NotFoundであれば口座状態確認
197
- if (doc === null) {
198
- const account = yield this.findByAccountNumber({
199
- accountNumber: params.accountNumber
200
- });
201
- if (account.status === factory.account.AccountStatusType.Closed) {
202
- // すでに口座解約済の場合
203
- return;
204
- }
205
- else if (Array.isArray(account.pendingTransactions) && account.pendingTransactions.length > 0) {
206
- // 進行中取引が存在する場合の場合
207
- throw new factory.errors.Argument('accountNumber', 'Pending transactions exist');
208
- }
209
- else {
210
- throw new factory.errors.NotFound(this.accountModel.modelName);
211
- }
212
- }
213
- });
214
- }
180
+ // public async close(params: {
181
+ // /**
182
+ // * 口座番号
183
+ // */
184
+ // accountNumber: string;
185
+ // /**
186
+ // * 解約日時
187
+ // */
188
+ // closeDate: Date;
189
+ // }) {
190
+ // const doc = await this.accountModel.findOneAndUpdate(
191
+ // {
192
+ // accountNumber: params.accountNumber,
193
+ // pendingTransactions: { $size: 0 },
194
+ // status: factory.account.AccountStatusType.Opened
195
+ // },
196
+ // {
197
+ // closeDate: params.closeDate,
198
+ // status: factory.account.AccountStatusType.Closed
199
+ // },
200
+ // {
201
+ // new: true
202
+ // }
203
+ // )
204
+ // .exec();
205
+ // // NotFoundであれば口座状態確認
206
+ // if (doc === null) {
207
+ // const account = await this.findByAccountNumber({
208
+ // accountNumber: params.accountNumber
209
+ // });
210
+ // if (account.status === factory.account.AccountStatusType.Closed) {
211
+ // // すでに口座解約済の場合
212
+ // return;
213
+ // } else if (Array.isArray(account.pendingTransactions) && account.pendingTransactions.length > 0) {
214
+ // // 進行中取引が存在する場合の場合
215
+ // throw new factory.errors.Argument('accountNumber', 'Pending transactions exist');
216
+ // } else {
217
+ // throw new factory.errors.NotFound(this.accountModel.modelName);
218
+ // }
219
+ // }
220
+ // }
215
221
  /**
216
222
  * 口座番号で検索する
217
223
  */
@@ -233,7 +239,7 @@ class MongoRepository {
233
239
  */
234
240
  authorizeAmount(params) {
235
241
  return __awaiter(this, void 0, void 0, function* () {
236
- const doc = yield this.accountModel.findOneAndUpdate(Object.assign({ accountNumber: params.accountNumber, status: factory.account.AccountStatusType.Opened }, (params.force === true) ? undefined : { availableBalance: { $gte: params.amount } } // 利用可能金額確認
242
+ const doc = yield this.accountModel.findOneAndUpdate(Object.assign({ accountNumber: params.accountNumber }, (params.force === true) ? undefined : { availableBalance: { $gte: params.amount } } // 利用可能金額確認
237
243
  ), {
238
244
  $inc: { availableBalance: -params.amount },
239
245
  $push: { pendingTransactions: params.transaction } // 進行中取引追加
@@ -244,11 +250,11 @@ class MongoRepository {
244
250
  const account = yield this.findByAccountNumber({
245
251
  accountNumber: params.accountNumber
246
252
  });
247
- if (account.status === factory.account.AccountStatusType.Closed) {
248
- // 口座解約済の場合
249
- throw new factory.errors.Argument('accountNumber', 'Account already closed');
250
- }
251
- else if (typeof account.availableBalance === 'number' && account.availableBalance < params.amount) {
253
+ // if (account.status === factory.account.AccountStatusType.Closed) {
254
+ // // 口座解約済の場合
255
+ // throw new factory.errors.Argument('accountNumber', 'Account already closed');
256
+ // } else
257
+ if (typeof account.availableBalance === 'number' && account.availableBalance < params.amount) {
252
258
  // 残高不足の場合
253
259
  throw new factory.errors.Argument('accountNumber', 'Insufficient balance');
254
260
  }
@@ -264,22 +270,22 @@ class MongoRepository {
264
270
  startTransaction(params) {
265
271
  return __awaiter(this, void 0, void 0, function* () {
266
272
  const doc = yield this.accountModel.findOneAndUpdate({
267
- accountNumber: params.accountNumber,
268
- status: factory.account.AccountStatusType.Opened // 開いている口座
273
+ accountNumber: params.accountNumber
274
+ // status: factory.account.AccountStatusType.Opened // 開いている口座
269
275
  }, { $push: { pendingTransactions: params.transaction } })
270
276
  .exec();
271
277
  // NotFoundであれば口座状態確認
272
278
  if (doc === null) {
273
- const account = yield this.findByAccountNumber({
274
- accountNumber: params.accountNumber
275
- });
276
- if (account.status === factory.account.AccountStatusType.Closed) {
277
- // 口座解約済の場合
278
- throw new factory.errors.Argument('accountNumber', 'Account already closed');
279
- }
280
- else {
281
- throw new factory.errors.NotFound(this.accountModel.modelName);
282
- }
279
+ // const account = await this.findByAccountNumber({
280
+ // accountNumber: params.accountNumber
281
+ // });
282
+ // if (account.status === factory.account.AccountStatusType.Closed) {
283
+ // // 口座解約済の場合
284
+ // throw new factory.errors.Argument('accountNumber', 'Account already closed');
285
+ // } else {
286
+ // throw new factory.errors.NotFound(this.accountModel.modelName);
287
+ // }
288
+ throw new factory.errors.NotFound(this.accountModel.modelName);
283
289
  }
284
290
  });
285
291
  }
@@ -419,5 +425,11 @@ class MongoRepository {
419
425
  .then((docs) => docs.map((doc) => doc.toObject()));
420
426
  });
421
427
  }
428
+ unsetUnnecessaryFields(params) {
429
+ return __awaiter(this, void 0, void 0, function* () {
430
+ return this.accountModel.updateMany(params.filter, { $unset: params.$unset })
431
+ .exec();
432
+ });
433
+ }
422
434
  }
423
435
  exports.MongoRepository = MongoRepository;
@@ -144,6 +144,7 @@ export declare class MongoRepository {
144
144
  findByIdAndDelete(params: {
145
145
  id: string;
146
146
  }): Promise<void>;
147
+ getCursor(conditions: any, projection: any): import("mongoose").QueryCursor<any>;
147
148
  aggregateAssetTransaction(params: {
148
149
  project?: {
149
150
  id?: {
@@ -536,6 +536,11 @@ class MongoRepository {
536
536
  .exec();
537
537
  });
538
538
  }
539
+ getCursor(conditions, projection) {
540
+ return this.transactionModel.find(conditions, projection)
541
+ .sort({ startDate: factory.sortType.Ascending })
542
+ .cursor();
543
+ }
539
544
  aggregateAssetTransaction(params) {
540
545
  return __awaiter(this, void 0, void 0, function* () {
541
546
  const statuses = yield Promise.all([
@@ -35,13 +35,6 @@ export declare class MongoRepository {
35
35
  }): Promise<IObject>;
36
36
  count(params: factory.authorization.ISearchConditions): Promise<number>;
37
37
  search(params: factory.authorization.ISearchConditions): Promise<factory.authorization.IAuthorization[]>;
38
- deleteByCode(params: {
39
- code: string;
40
- }): Promise<{
41
- n?: number;
42
- ok?: number;
43
- deletedCount?: number;
44
- } | null>;
45
38
  /**
46
39
  * 有効期限を一定期間過ぎた承認を削除する
47
40
  */
@@ -204,23 +204,6 @@ class MongoRepository {
204
204
  .then((docs) => docs.map((doc) => doc.toObject()));
205
205
  });
206
206
  }
207
- deleteByCode(params) {
208
- return __awaiter(this, void 0, void 0, function* () {
209
- return this.authorizationModel.deleteOne({
210
- code: { $exists: true, $eq: params.code }
211
- })
212
- .exec()
213
- .then((result) => {
214
- return {
215
- n: result === null || result === void 0 ? void 0 : result.n,
216
- // opTime: result.opTime,
217
- ok: result === null || result === void 0 ? void 0 : result.ok,
218
- // operationTime,
219
- deletedCount: result === null || result === void 0 ? void 0 : result.deletedCount
220
- };
221
- });
222
- });
223
- }
224
207
  /**
225
208
  * 有効期限を一定期間過ぎた承認を削除する
226
209
  */
@@ -10,7 +10,7 @@ export interface IUpdateAggregateReservationParams {
10
10
  $set: {
11
11
  updatedAt: Date;
12
12
  aggregateReservation: factory.event.screeningEvent.IAggregateReservation;
13
- aggregateOffer: factory.event.screeningEvent.IAggregateOffer;
13
+ aggregateOffer?: factory.event.screeningEvent.IAggregateOffer;
14
14
  maximumAttendeeCapacity?: number;
15
15
  remainingAttendeeCapacity?: number;
16
16
  checkInCount?: number;
@@ -141,9 +141,10 @@ export declare class MongoRepository {
141
141
  }, update: IUpdateAggregateReservationParams | IUpdateAggregateUseActionsParams): Promise<factory.event.IEvent<T>>;
142
142
  bulkWrite(bulkWriteOps: any[]): Promise<BulkWriteOpResultObject>;
143
143
  getCursor(conditions: any, projection: any): import("mongoose").QueryCursor<any>;
144
- deleteUnnecessaryProjectAttributesById(params: {
145
- id: string;
146
- }): Promise<void>;
144
+ unsetUnnecessaryFields(params: {
145
+ filter: any;
146
+ $unset: any;
147
+ }): Promise<import("mongoose").UpdateWriteOpResult>;
147
148
  aggregateEvent(params: {
148
149
  project?: {
149
150
  id?: {