@chevre/domain 28.0.0-alpha.9 → 28.1.0-alpha.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/lib/chevre/emailMessageBuilder.d.ts +9 -5
- package/lib/chevre/emailMessageBuilder.js +12 -11
- package/lib/chevre/factory/event.d.ts +1 -1
- package/lib/chevre/factory/event.js +1 -5
- package/lib/chevre/repo/acceptedOffer.d.ts +6 -5
- package/lib/chevre/repo/acceptedOffer.js +14 -9
- package/lib/chevre/repo/acceptedOfferInReserve.d.ts +6 -8
- package/lib/chevre/repo/acceptedOfferInReserve.js +13 -7
- package/lib/chevre/repo/action/unknown2actionError.d.ts +1 -0
- package/lib/chevre/repo/action/unknown2actionError.js +29 -1
- package/lib/chevre/repo/adminAcceptedOffer.d.ts +36 -12
- package/lib/chevre/repo/adminAcceptedOffer.js +40 -10
- package/lib/chevre/repo/adminAccountTitle.d.ts +49 -0
- package/lib/chevre/repo/adminAccountTitle.js +212 -0
- package/lib/chevre/repo/adminAccountTitleCategory.d.ts +37 -0
- package/lib/chevre/repo/adminAccountTitleCategory.js +127 -0
- package/lib/chevre/repo/adminAccountTitleSet.d.ts +42 -0
- package/lib/chevre/repo/adminAccountTitleSet.js +149 -0
- package/lib/chevre/repo/adminEvent.d.ts +1 -1
- package/lib/chevre/repo/adminEventSeries.d.ts +0 -22
- package/lib/chevre/repo/adminEventSeries.js +35 -31
- package/lib/chevre/repo/{paymentServiceChannel.d.ts → adminPaymentServiceChannel.d.ts} +13 -11
- package/lib/chevre/repo/{paymentServiceChannel.js → adminPaymentServiceChannel.js} +20 -19
- package/lib/chevre/repo/adminTask.d.ts +2 -2
- package/lib/chevre/repo/adminTransaction.d.ts +15 -15
- package/lib/chevre/repo/categoryCode.js +0 -21
- package/lib/chevre/repo/emailMessage.d.ts +3 -1
- package/lib/chevre/repo/emailMessage.js +20 -13
- package/lib/chevre/repo/eventSeries.d.ts +2 -2
- package/lib/chevre/repo/eventSeries.js +19 -12
- package/lib/chevre/repo/factory/acceptedOffer/reserveTransaction2itemOffered.d.ts +1 -1
- package/lib/chevre/repo/issuer.d.ts +2 -6
- package/lib/chevre/repo/memberProgram.d.ts +1 -38
- package/lib/chevre/repo/memberProgram.js +1 -62
- package/lib/chevre/repo/mongoose/schemas/accountTitle.d.ts +1 -1
- package/lib/chevre/repo/mongoose/schemas/accountTitle.js +22 -26
- package/lib/chevre/repo/mongoose/schemas/civicStructure.d.ts +1 -0
- package/lib/chevre/repo/mongoose/schemas/event.js +0 -13
- package/lib/chevre/repo/mongoose/schemas/eventSeries.js +1 -18
- package/lib/chevre/repo/mongoose/schemas/issuer.d.ts +1 -3
- package/lib/chevre/repo/mongoose/schemas/issuer.js +0 -10
- package/lib/chevre/repo/mongoose/schemas/message.d.ts +5 -1
- package/lib/chevre/repo/mongoose/schemas/offerCatalog.d.ts +0 -1
- package/lib/chevre/repo/mongoose/schemas/offerCatalog.js +3 -12
- package/lib/chevre/repo/mongoose/schemas/offerCatalogItem.d.ts +1 -2
- package/lib/chevre/repo/mongoose/schemas/offerCatalogItem.js +6 -15
- package/lib/chevre/repo/mongoose/schemas/order.d.ts +22 -1
- package/lib/chevre/repo/mongoose/schemas/paymentServiceChannel.d.ts +1 -1
- package/lib/chevre/repo/mongoose/schemas/place.js +0 -9
- package/lib/chevre/repo/mongoose/schemas/project.d.ts +1 -2
- package/lib/chevre/repo/mongoose/schemas/project.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/seller.d.ts +3 -1
- package/lib/chevre/repo/mongoose/schemas/seller.js +0 -2
- package/lib/chevre/repo/offerCatalog.d.ts +0 -2
- package/lib/chevre/repo/offerCatalogItem.d.ts +13 -20
- package/lib/chevre/repo/offerCatalogItem.js +8 -86
- package/lib/chevre/repo/order.d.ts +2 -2
- package/lib/chevre/repo/order.js +0 -31
- package/lib/chevre/repo/orderInTransaction.d.ts +5 -25
- package/lib/chevre/repo/place/movieTheater.d.ts +3 -1
- package/lib/chevre/repo/place/movieTheater.js +3 -1
- package/lib/chevre/repo/place/{hasPOS.d.ts → pos.d.ts} +13 -20
- package/lib/chevre/repo/place/{hasPOS.js → pos.js} +66 -29
- package/lib/chevre/repo/place/screeningRoom.d.ts +2 -2
- package/lib/chevre/repo/priceSpecification.d.ts +8 -8
- package/lib/chevre/repo/project.d.ts +14 -20
- package/lib/chevre/repo/project.js +28 -44
- package/lib/chevre/repo/projectMakesOffer.js +2 -2
- package/lib/chevre/repo/role.d.ts +1 -1
- package/lib/chevre/repo/role.js +1 -30
- package/lib/chevre/repo/seller.d.ts +11 -4
- package/lib/chevre/repo/seller.js +31 -58
- package/lib/chevre/repo/sellerPaymentAccepted.d.ts +14 -21
- package/lib/chevre/repo/sellerPaymentAccepted.js +65 -38
- package/lib/chevre/repo/task.d.ts +3 -3
- package/lib/chevre/repository.d.ts +25 -15
- package/lib/chevre/repository.js +52 -30
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +2 -1
- package/lib/chevre/service/aggregation.d.ts +0 -2
- package/lib/chevre/service/aggregation.js +1 -3
- package/lib/chevre/service/assetTransaction/pay/start/preStart/fixPaymentService.d.ts +1 -1
- package/lib/chevre/service/assetTransaction/pay/start/preStart/fixPaymentService.js +1 -15
- package/lib/chevre/service/assetTransaction/pay/start/preStart/validateSeller.d.ts +1 -1
- package/lib/chevre/service/assetTransaction/pay/start/preStart/validateSeller.js +9 -3
- package/lib/chevre/service/assetTransaction/pay/start.js +3 -3
- package/lib/chevre/service/assetTransaction/reserve/start.js +2 -1
- package/lib/chevre/service/delivery/reservation/factory.d.ts +1 -1
- package/lib/chevre/service/event/saveScreeningEventSeries.js +1 -2
- package/lib/chevre/service/event/saveScreeningEvents.js +4 -4
- package/lib/chevre/service/notification/sendEmailMessage.d.ts +2 -0
- package/lib/chevre/service/notification/sendEmailMessage.js +23 -6
- package/lib/chevre/service/offer/any.d.ts +1 -1
- package/lib/chevre/service/offer/event/authorize/factory.d.ts +3 -3
- package/lib/chevre/service/offer/event/authorize/factory.js +1 -8
- package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.d.ts +1 -1
- package/lib/chevre/service/offer/event/issueEventOfferTicket.js +0 -11
- package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +1 -4
- package/lib/chevre/service/offer/event/searchEventTicketOffers.js +9 -13
- package/lib/chevre/service/offer/event/searchOfferAppliesToMovieTicket.js +2 -8
- package/lib/chevre/service/offer/event/searchOfferCatalogItems.js +2 -2
- package/lib/chevre/service/offer/event/searchOffersByIds.js +3 -9
- package/lib/chevre/service/offer/eventServiceByCOA/authorize/factory.d.ts +1 -1
- package/lib/chevre/service/offer/eventServiceByCOA/authorize/factory.js +0 -7
- package/lib/chevre/service/offer/onEventChanged.js +9 -18
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts +4 -6
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.js +23 -4
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/createSendEmailMessageTaskIfNotExist.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/processOrder.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.d.ts +1 -1
- package/lib/chevre/service/order/placeOrder/factory/orderedItem.d.ts +1 -1
- package/lib/chevre/service/order/placeOrder/factory.d.ts +1 -1
- package/lib/chevre/service/order/sendOrder.js +2 -14
- package/lib/chevre/service/payment/creditCard/getGMOInfoFromSeller.js +1 -1
- package/lib/chevre/service/payment/factory/createPayObjectServiceOutput.d.ts +3 -3
- package/lib/chevre/service/payment/movieTicket/checkMovieTicket.js +1 -1
- package/lib/chevre/service/payment/movieTicket/payMovieTicket/payActionParams2seatInfoSyncIn.js +1 -1
- package/lib/chevre/service/payment/movieTicket/validation.js +1 -1
- package/lib/chevre/service/project.d.ts +3 -3
- package/lib/chevre/service/project.js +1 -1
- package/lib/chevre/service/task/onResourceDeleted.js +8 -8
- package/lib/chevre/service/task/onResourceUpdated/onAggregateOfferUpdated.js +8 -8
- package/lib/chevre/service/task/onResourceUpdated/onHasPOSUpdated.d.ts +7 -3
- package/lib/chevre/service/task/onResourceUpdated/onHasPOSUpdated.js +51 -50
- package/lib/chevre/service/task/onResourceUpdated/onOfferCatalogUpdated.js +1 -1
- package/lib/chevre/service/task/onResourceUpdated/syncOfferCatalog.js +1 -1
- package/lib/chevre/service/task/onResourceUpdated.js +10 -47
- package/lib/chevre/service/task/sendEmailMessage.js +3 -1
- package/lib/chevre/service/task/syncResourcesFromCOA.js +2 -2
- package/lib/chevre/service/transaction/placeOrder/confirm/potentialActions/sendEmailMessage.d.ts +6 -3
- package/lib/chevre/service/transaction/placeOrder/confirm/potentialActions/sendEmailMessage.js +2 -15
- package/lib/chevre/service/transaction/placeOrder/confirm/potentialActions.d.ts +6 -4
- package/lib/chevre/service/transaction/placeOrder/confirm/potentialActions.js +3 -7
- package/lib/chevre/service/transaction/placeOrder/confirm/prepareUnitPriceOfferConditions.d.ts +1 -1
- package/lib/chevre/service/transaction/placeOrder/confirm/validation/validateInvoiceReferencesOrder.d.ts +1 -1
- package/lib/chevre/service/transaction/placeOrder/confirm/validation/validateMovieTicket.d.ts +1 -1
- package/lib/chevre/service/transaction/placeOrder/confirm/validation.d.ts +4 -2
- package/lib/chevre/service/transaction/placeOrder/confirm/validation.js +7 -1
- package/lib/chevre/service/transaction/placeOrder/confirm.d.ts +5 -2
- package/lib/chevre/service/transaction/placeOrder/confirm.js +7 -12
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.d.ts +6 -3
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.js +8 -9
- package/lib/chevre/service/transaction/returnOrder/potentialActions/sendEmailMessage.d.ts +6 -3
- package/lib/chevre/service/transaction/returnOrder/potentialActions/sendEmailMessage.js +2 -7
- package/lib/chevre/service/transaction/returnOrder/potentialActions.d.ts +6 -3
- package/lib/chevre/service/transaction/returnOrder/potentialActions.js +4 -3
- package/lib/chevre/service/transaction/returnOrder/preStart/factory.d.ts +1 -1
- package/lib/chevre/service/transaction/returnOrder.d.ts +0 -2
- package/lib/chevre/service/transaction/returnOrder.js +6 -6
- package/package.json +2 -2
- package/lib/chevre/repo/accountTitle.d.ts +0 -28
- package/lib/chevre/repo/accountTitle.js +0 -30
- package/lib/chevre/service/aggregation/project.d.ts +0 -17
- package/lib/chevre/service/aggregation/project.js +0 -98
- package/lib/chevre/service/delivery/factory.d.ts +0 -16
- package/lib/chevre/service/delivery/factory.js +0 -124
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AdminAccountTitleRepo = void 0;
|
|
4
|
+
const factory_1 = require("../factory");
|
|
5
|
+
const accountTitle_1 = require("./mongoose/schemas/accountTitle");
|
|
6
|
+
function createMatchStages(params) {
|
|
7
|
+
const matchStages = [];
|
|
8
|
+
const projectIdEq = params.project?.id?.$eq;
|
|
9
|
+
if (typeof projectIdEq === 'string') {
|
|
10
|
+
matchStages.push({
|
|
11
|
+
$match: { 'project.id': { $eq: projectIdEq } }
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
const nameRegex = params.name;
|
|
15
|
+
if (typeof nameRegex === 'string') {
|
|
16
|
+
matchStages.push({
|
|
17
|
+
$match: { 'hasCategoryCode.hasCategoryCode.name': { $exists: true, $regex: new RegExp(nameRegex) } }
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
if (typeof params.codeValue === 'string') {
|
|
21
|
+
matchStages.push({
|
|
22
|
+
$match: { 'hasCategoryCode.hasCategoryCode.codeValue': { $exists: true, $regex: new RegExp(params.codeValue) } }
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
const codeValueEq = params.codeValue?.$eq;
|
|
27
|
+
if (typeof codeValueEq === 'string') {
|
|
28
|
+
matchStages.push({
|
|
29
|
+
$match: { 'hasCategoryCode.hasCategoryCode.codeValue': { $exists: true, $eq: codeValueEq } }
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const inCodeSetCodeValue = params.inCodeSet?.codeValue;
|
|
34
|
+
if (typeof inCodeSetCodeValue === 'string') {
|
|
35
|
+
matchStages.push({
|
|
36
|
+
$match: { 'hasCategoryCode.codeValue': { $exists: true, $regex: new RegExp(inCodeSetCodeValue) } }
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
const inCodeSetCodeValueEq = inCodeSetCodeValue?.$eq;
|
|
41
|
+
if (typeof inCodeSetCodeValueEq === 'string') {
|
|
42
|
+
matchStages.push({
|
|
43
|
+
$match: { 'hasCategoryCode.codeValue': { $exists: true, $eq: inCodeSetCodeValueEq } }
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const accountTitleCategoryCode = params.inCodeSet?.inCodeSet?.codeValue;
|
|
48
|
+
if (typeof accountTitleCategoryCode === 'string') {
|
|
49
|
+
matchStages.push({
|
|
50
|
+
$match: { codeValue: { $exists: true, $regex: new RegExp(accountTitleCategoryCode) } }
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
const accountTitleCategoryCodeEq = accountTitleCategoryCode?.$eq;
|
|
55
|
+
if (typeof accountTitleCategoryCodeEq === 'string') {
|
|
56
|
+
matchStages.push({
|
|
57
|
+
$match: { codeValue: { $exists: true, $eq: accountTitleCategoryCodeEq } }
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const additionalPropertyElemMatch = params.additionalProperty?.$elemMatch;
|
|
62
|
+
if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
|
|
63
|
+
matchStages.push({
|
|
64
|
+
$match: { 'hasCategoryCode.hasCategoryCode.additionalProperty': { $exists: true, $elemMatch: additionalPropertyElemMatch } }
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
return matchStages;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* 細目管理リポジトリ
|
|
71
|
+
*/
|
|
72
|
+
class AdminAccountTitleRepo {
|
|
73
|
+
accountTitleModel;
|
|
74
|
+
constructor(connection) {
|
|
75
|
+
this.accountTitleModel = connection.model(accountTitle_1.modelName, (0, accountTitle_1.createSchema)());
|
|
76
|
+
}
|
|
77
|
+
async addAccountTitle(params) {
|
|
78
|
+
const { codeValue, name, project, inCodeSet, additionalProperty } = params;
|
|
79
|
+
// 科目の存在確認
|
|
80
|
+
const categoryDoc = await this.accountTitleModel.findOne({
|
|
81
|
+
'project.id': { $eq: project.id },
|
|
82
|
+
codeValue: { $eq: inCodeSet.inCodeSet.codeValue },
|
|
83
|
+
'hasCategoryCode.codeValue': { $eq: inCodeSet.codeValue }
|
|
84
|
+
}, { _id: 1 })
|
|
85
|
+
.exec();
|
|
86
|
+
if (categoryDoc === null) {
|
|
87
|
+
throw new factory_1.factory.errors.NotFound('AccountTitleSet');
|
|
88
|
+
}
|
|
89
|
+
const newAccountTitle = {
|
|
90
|
+
typeOf: 'AccountTitle',
|
|
91
|
+
codeValue,
|
|
92
|
+
additionalProperty: (Array.isArray(additionalProperty)) ? additionalProperty : [],
|
|
93
|
+
...(typeof name === 'string') && { name }
|
|
94
|
+
};
|
|
95
|
+
// プロジェクト内での細目コード重複確認(インデックスは保証できない)
|
|
96
|
+
const existingAccountTitle = await this.accountTitleModel.findOne({
|
|
97
|
+
'project.id': { $eq: project.id },
|
|
98
|
+
// codeValue: { $eq: accountTitleCategory.codeValue },
|
|
99
|
+
// 'hasCategoryCode.codeValue': {
|
|
100
|
+
// $exists: true,
|
|
101
|
+
// $eq: accountTitleSet.codeValue
|
|
102
|
+
// },
|
|
103
|
+
'hasCategoryCode.hasCategoryCode.codeValue': { $exists: true, $eq: codeValue }
|
|
104
|
+
}, { _id: 1 })
|
|
105
|
+
.exec();
|
|
106
|
+
if (existingAccountTitle !== null) {
|
|
107
|
+
throw new factory_1.factory.errors.AlreadyInUse(accountTitle_1.modelName, ['codeValue'], 'codeValue duplicated');
|
|
108
|
+
}
|
|
109
|
+
const doc = await this.accountTitleModel.findOneAndUpdate({
|
|
110
|
+
'project.id': { $eq: project.id },
|
|
111
|
+
codeValue: { $eq: inCodeSet.inCodeSet.codeValue },
|
|
112
|
+
'hasCategoryCode.codeValue': { $eq: inCodeSet.codeValue },
|
|
113
|
+
'hasCategoryCode.hasCategoryCode.codeValue': { $ne: codeValue }
|
|
114
|
+
}, {
|
|
115
|
+
$push: {
|
|
116
|
+
'hasCategoryCode.$[accountTitleSet].hasCategoryCode': newAccountTitle
|
|
117
|
+
}
|
|
118
|
+
}, {
|
|
119
|
+
new: true,
|
|
120
|
+
arrayFilters: [
|
|
121
|
+
{ 'accountTitleSet.codeValue': inCodeSet.codeValue }
|
|
122
|
+
],
|
|
123
|
+
projection: { _id: 1 }
|
|
124
|
+
})
|
|
125
|
+
.exec();
|
|
126
|
+
// 存在しなければ細目コード重複
|
|
127
|
+
if (doc === null) {
|
|
128
|
+
throw new factory_1.factory.errors.AlreadyInUse(accountTitle_1.modelName, ['hasCategoryCode.hasCategoryCode.codeValue']);
|
|
129
|
+
}
|
|
130
|
+
return { id: doc.id };
|
|
131
|
+
}
|
|
132
|
+
async updateAccountTitle(params) {
|
|
133
|
+
const { codeValue, name, project, inCodeSet, additionalProperty } = params;
|
|
134
|
+
const doc = await this.accountTitleModel.findOneAndUpdate({
|
|
135
|
+
'project.id': { $eq: project.id },
|
|
136
|
+
codeValue: { $eq: inCodeSet.inCodeSet.codeValue },
|
|
137
|
+
'hasCategoryCode.codeValue': { $eq: inCodeSet.codeValue },
|
|
138
|
+
'hasCategoryCode.hasCategoryCode.codeValue': codeValue
|
|
139
|
+
}, {
|
|
140
|
+
// 'hasCategoryCode.$[accountTitleSet].hasCategoryCode.$[accountTitle].codeValue': accountTitle.codeValue,
|
|
141
|
+
...(typeof name === 'string')
|
|
142
|
+
&& { 'hasCategoryCode.$[accountTitleSet].hasCategoryCode.$[accountTitle].name': name },
|
|
143
|
+
...(Array.isArray(additionalProperty))
|
|
144
|
+
&& { 'hasCategoryCode.$[accountTitleSet].hasCategoryCode.$[accountTitle].additionalProperty': additionalProperty }
|
|
145
|
+
}, {
|
|
146
|
+
new: true,
|
|
147
|
+
arrayFilters: [
|
|
148
|
+
{ 'accountTitleSet.codeValue': inCodeSet.codeValue },
|
|
149
|
+
{ 'accountTitle.codeValue': codeValue }
|
|
150
|
+
],
|
|
151
|
+
projection: { _id: 1 }
|
|
152
|
+
})
|
|
153
|
+
.exec();
|
|
154
|
+
if (doc === null) {
|
|
155
|
+
throw new factory_1.factory.errors.NotFound(accountTitle_1.modelName);
|
|
156
|
+
}
|
|
157
|
+
return { id: doc.id };
|
|
158
|
+
}
|
|
159
|
+
async findAccountTitles(params) {
|
|
160
|
+
const aggregate = this.accountTitleModel.aggregate([
|
|
161
|
+
{ $unwind: '$hasCategoryCode' },
|
|
162
|
+
{ $unwind: '$hasCategoryCode.hasCategoryCode' },
|
|
163
|
+
...createMatchStages(params),
|
|
164
|
+
{
|
|
165
|
+
$project: {
|
|
166
|
+
_id: 0,
|
|
167
|
+
codeValue: '$hasCategoryCode.hasCategoryCode.codeValue',
|
|
168
|
+
name: '$hasCategoryCode.hasCategoryCode.name',
|
|
169
|
+
inCodeSet: {
|
|
170
|
+
codeValue: '$hasCategoryCode.codeValue',
|
|
171
|
+
name: '$hasCategoryCode.name',
|
|
172
|
+
inCodeSet: {
|
|
173
|
+
codeValue: '$codeValue',
|
|
174
|
+
name: '$name'
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
additionalProperty: '$hasCategoryCode.hasCategoryCode.additionalProperty'
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
]);
|
|
181
|
+
if (typeof params.limit === 'number' && typeof params.page === 'number') {
|
|
182
|
+
aggregate.skip(params.limit * (params.page - 1))
|
|
183
|
+
.limit(params.limit);
|
|
184
|
+
}
|
|
185
|
+
return aggregate.exec();
|
|
186
|
+
}
|
|
187
|
+
async deleteAccountTitleByCodeValue(params) {
|
|
188
|
+
const { projectId, codeValue, accountTitleCategoryCode, accountTitleSetCode } = params;
|
|
189
|
+
const doc = await this.accountTitleModel.findOneAndUpdate({
|
|
190
|
+
'project.id': { $eq: projectId },
|
|
191
|
+
codeValue: { $eq: accountTitleCategoryCode },
|
|
192
|
+
'hasCategoryCode.codeValue': { $exists: true, $eq: accountTitleSetCode },
|
|
193
|
+
'hasCategoryCode.hasCategoryCode.codeValue': { $exists: true, $eq: codeValue }
|
|
194
|
+
}, {
|
|
195
|
+
$pull: {
|
|
196
|
+
'hasCategoryCode.$[accountTitleSet].hasCategoryCode': { codeValue }
|
|
197
|
+
}
|
|
198
|
+
}, {
|
|
199
|
+
new: true,
|
|
200
|
+
arrayFilters: [
|
|
201
|
+
{ 'accountTitleSet.codeValue': accountTitleSetCode }
|
|
202
|
+
],
|
|
203
|
+
projection: { _id: 1 }
|
|
204
|
+
})
|
|
205
|
+
.exec();
|
|
206
|
+
if (doc === null) {
|
|
207
|
+
throw new factory_1.factory.errors.NotFound(accountTitle_1.modelName);
|
|
208
|
+
}
|
|
209
|
+
return { id: doc.id };
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
exports.AdminAccountTitleRepo = AdminAccountTitleRepo;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Connection } from 'mongoose';
|
|
2
|
+
import { factory } from '../factory';
|
|
3
|
+
type IFindParams = Pick<factory.accountTitle.ISearchConditions, 'codeValue' | 'limit' | 'name' | 'page' | 'project' | 'sort'>;
|
|
4
|
+
/**
|
|
5
|
+
* 科目分類管理リポジトリ
|
|
6
|
+
*/
|
|
7
|
+
export declare class AdminAccountTitleCategoryRepo {
|
|
8
|
+
private readonly accountTitleModel;
|
|
9
|
+
constructor(connection: Connection);
|
|
10
|
+
findAccountTitleCategorAsNotification(params: {
|
|
11
|
+
id: string;
|
|
12
|
+
projectId: string;
|
|
13
|
+
}): Promise<Pick<factory.accountTitle.IAccountTitle, 'codeValue' | 'hasCategoryCode' | 'name' | 'project' | 'typeOf'> & {
|
|
14
|
+
id: string;
|
|
15
|
+
}>;
|
|
16
|
+
deleteAccountTitleCategoriesByProject(params: {
|
|
17
|
+
project: {
|
|
18
|
+
id: string;
|
|
19
|
+
};
|
|
20
|
+
}): Promise<void>;
|
|
21
|
+
addAccountTitleCategory(params: Pick<factory.accountTitle.IAccountTitle, 'codeValue' | 'name' | 'project'>): Promise<{
|
|
22
|
+
id: string;
|
|
23
|
+
}>;
|
|
24
|
+
updateAccountTitleCategory(params: Pick<factory.accountTitle.IAccountTitle, 'codeValue' | 'name' | 'project'>): Promise<{
|
|
25
|
+
id: string;
|
|
26
|
+
}>;
|
|
27
|
+
findAccountTitleCategories(params: IFindParams): Promise<Pick<factory.accountTitle.IAccountTitle, 'codeValue' | 'name'>[]>;
|
|
28
|
+
deleteAccountTitleCategoryByCodeValue(params: {
|
|
29
|
+
projectId: string;
|
|
30
|
+
codeValue: string;
|
|
31
|
+
}): Promise<void>;
|
|
32
|
+
unsetUnnecessaryFields(params: {
|
|
33
|
+
filter: any;
|
|
34
|
+
$unset: any;
|
|
35
|
+
}): Promise<import("mongoose").UpdateWriteOpResult>;
|
|
36
|
+
}
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AdminAccountTitleCategoryRepo = void 0;
|
|
4
|
+
const factory_1 = require("../factory");
|
|
5
|
+
const settings_1 = require("../settings");
|
|
6
|
+
const accountTitle_1 = require("./mongoose/schemas/accountTitle");
|
|
7
|
+
function createFilterQueries(params) {
|
|
8
|
+
const conditions = [];
|
|
9
|
+
const projectIdEq = params.project?.id?.$eq;
|
|
10
|
+
if (typeof projectIdEq === 'string') {
|
|
11
|
+
conditions.push({ 'project.id': { $eq: projectIdEq } });
|
|
12
|
+
}
|
|
13
|
+
if (typeof params.codeValue === 'string') {
|
|
14
|
+
conditions.push({ codeValue: { $exists: true, $regex: new RegExp(params.codeValue) } });
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
const codeValueEq = params.codeValue?.$eq;
|
|
18
|
+
if (typeof codeValueEq === 'string') {
|
|
19
|
+
conditions.push({ codeValue: { $exists: true, $eq: codeValueEq } });
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const nameRegex = params.name;
|
|
23
|
+
if (typeof nameRegex === 'string') {
|
|
24
|
+
conditions.push({ name: { $exists: true, $regex: new RegExp(nameRegex) } });
|
|
25
|
+
}
|
|
26
|
+
return conditions;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* 科目分類管理リポジトリ
|
|
30
|
+
*/
|
|
31
|
+
class AdminAccountTitleCategoryRepo {
|
|
32
|
+
accountTitleModel;
|
|
33
|
+
constructor(connection) {
|
|
34
|
+
this.accountTitleModel = connection.model(accountTitle_1.modelName, (0, accountTitle_1.createSchema)());
|
|
35
|
+
}
|
|
36
|
+
async findAccountTitleCategorAsNotification(params) {
|
|
37
|
+
const { id, projectId } = params;
|
|
38
|
+
const doc = await this.accountTitleModel.findOne({
|
|
39
|
+
_id: { $eq: id },
|
|
40
|
+
'project.id': { $eq: projectId }
|
|
41
|
+
}, {
|
|
42
|
+
_id: 0,
|
|
43
|
+
id: { $toString: '$_id' },
|
|
44
|
+
codeValue: 1,
|
|
45
|
+
hasCategoryCode: 1,
|
|
46
|
+
name: 1,
|
|
47
|
+
project: 1,
|
|
48
|
+
typeOf: 1
|
|
49
|
+
})
|
|
50
|
+
.lean()
|
|
51
|
+
.exec();
|
|
52
|
+
if (doc === null) {
|
|
53
|
+
throw new factory_1.factory.errors.NotFound('AccountTitleCategory');
|
|
54
|
+
}
|
|
55
|
+
return doc;
|
|
56
|
+
}
|
|
57
|
+
async deleteAccountTitleCategoriesByProject(params) {
|
|
58
|
+
await this.accountTitleModel.deleteMany({
|
|
59
|
+
'project.id': { $exists: true, $eq: params.project.id }
|
|
60
|
+
})
|
|
61
|
+
.exec();
|
|
62
|
+
}
|
|
63
|
+
async addAccountTitleCategory(params) {
|
|
64
|
+
const { codeValue, name, project } = params;
|
|
65
|
+
const creatingAccountTitle = {
|
|
66
|
+
codeValue,
|
|
67
|
+
hasCategoryCode: [],
|
|
68
|
+
name,
|
|
69
|
+
project,
|
|
70
|
+
typeOf: 'AccountTitle'
|
|
71
|
+
};
|
|
72
|
+
const doc = await this.accountTitleModel.create(creatingAccountTitle);
|
|
73
|
+
return { id: doc.id };
|
|
74
|
+
}
|
|
75
|
+
async updateAccountTitleCategory(params) {
|
|
76
|
+
const { codeValue, name, project } = params;
|
|
77
|
+
const doc = await this.accountTitleModel.findOneAndUpdate({
|
|
78
|
+
'project.id': { $eq: project.id },
|
|
79
|
+
codeValue: { $eq: codeValue }
|
|
80
|
+
}, {
|
|
81
|
+
$set: { name }
|
|
82
|
+
}, {
|
|
83
|
+
new: true,
|
|
84
|
+
projection: { _id: 1 }
|
|
85
|
+
})
|
|
86
|
+
.exec();
|
|
87
|
+
if (doc === null) {
|
|
88
|
+
throw new factory_1.factory.errors.NotFound(accountTitle_1.modelName);
|
|
89
|
+
}
|
|
90
|
+
return { id: doc.id };
|
|
91
|
+
}
|
|
92
|
+
async findAccountTitleCategories(params) {
|
|
93
|
+
const query = this.accountTitleModel.find({ $and: createFilterQueries(params) }, {
|
|
94
|
+
_id: 0,
|
|
95
|
+
codeValue: 1,
|
|
96
|
+
name: 1,
|
|
97
|
+
});
|
|
98
|
+
if (typeof params.limit === 'number' && typeof params.page === 'number') {
|
|
99
|
+
query.limit(params.limit)
|
|
100
|
+
.skip(params.limit * (params.page - 1));
|
|
101
|
+
}
|
|
102
|
+
if (typeof params.sort?.codeValue === 'number') {
|
|
103
|
+
query.sort({ codeValue: params.sort.codeValue });
|
|
104
|
+
}
|
|
105
|
+
return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
106
|
+
.lean()
|
|
107
|
+
.exec();
|
|
108
|
+
}
|
|
109
|
+
async deleteAccountTitleCategoryByCodeValue(params) {
|
|
110
|
+
const { projectId, codeValue } = params;
|
|
111
|
+
await this.accountTitleModel.findOneAndDelete({
|
|
112
|
+
'project.id': { $eq: projectId },
|
|
113
|
+
codeValue: { $eq: codeValue }
|
|
114
|
+
})
|
|
115
|
+
.exec()
|
|
116
|
+
.then((doc) => {
|
|
117
|
+
if (doc === null) {
|
|
118
|
+
throw new factory_1.factory.errors.NotFound(accountTitle_1.modelName);
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
async unsetUnnecessaryFields(params) {
|
|
123
|
+
return this.accountTitleModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
|
|
124
|
+
.exec();
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
exports.AdminAccountTitleCategoryRepo = AdminAccountTitleCategoryRepo;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { Connection } from 'mongoose';
|
|
2
|
+
import { factory } from '../factory';
|
|
3
|
+
type IFindParams = Pick<factory.accountTitle.ISearchConditions, 'codeValue' | 'limit' | 'name' | 'page' | 'project'> & {
|
|
4
|
+
inCodeSet?: {
|
|
5
|
+
codeValue?: string | {
|
|
6
|
+
$eq?: string;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
type IAccountTitleSetAsFindResult = Pick<factory.accountTitle.IAccountTitle, 'codeValue' | 'name'> & {
|
|
11
|
+
inCodeSet: Pick<factory.accountTitle.IAccountTitle, 'codeValue' | 'name'>;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* 科目管理リポジトリ
|
|
15
|
+
*/
|
|
16
|
+
export declare class AdminAccountTitleSetRepo {
|
|
17
|
+
private readonly accountTitleModel;
|
|
18
|
+
constructor(connection: Connection);
|
|
19
|
+
addAccountTitleSet(params: Pick<factory.accountTitle.IAccountTitle, 'codeValue' | 'name' | 'project'> & {
|
|
20
|
+
inCodeSet: {
|
|
21
|
+
codeValue: string;
|
|
22
|
+
};
|
|
23
|
+
}): Promise<{
|
|
24
|
+
id: string;
|
|
25
|
+
}>;
|
|
26
|
+
updateAccountTitleSet(params: Pick<factory.accountTitle.IAccountTitle, 'codeValue' | 'name' | 'project'> & {
|
|
27
|
+
inCodeSet: {
|
|
28
|
+
codeValue: string;
|
|
29
|
+
};
|
|
30
|
+
}): Promise<{
|
|
31
|
+
id: string;
|
|
32
|
+
}>;
|
|
33
|
+
findAccountTitleSets(params: IFindParams): Promise<IAccountTitleSetAsFindResult[]>;
|
|
34
|
+
deleteAccountTitleSetByCodeValue(params: {
|
|
35
|
+
projectId: string;
|
|
36
|
+
accountTitleCategoryCode: string;
|
|
37
|
+
codeValue: string;
|
|
38
|
+
}): Promise<{
|
|
39
|
+
id: string;
|
|
40
|
+
}>;
|
|
41
|
+
}
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AdminAccountTitleSetRepo = void 0;
|
|
4
|
+
const factory_1 = require("../factory");
|
|
5
|
+
const accountTitle_1 = require("./mongoose/schemas/accountTitle");
|
|
6
|
+
function createMatchStages(params) {
|
|
7
|
+
const matchStages = [];
|
|
8
|
+
if (typeof params.project?.id?.$eq === 'string') {
|
|
9
|
+
matchStages.push({ $match: { 'project.id': { $eq: params.project.id.$eq } } });
|
|
10
|
+
}
|
|
11
|
+
if (typeof params.codeValue === 'string') {
|
|
12
|
+
matchStages.push({
|
|
13
|
+
$match: { 'hasCategoryCode.codeValue': { $exists: true, $regex: new RegExp(params.codeValue) } }
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
else if (params.codeValue !== undefined && params.codeValue !== null) {
|
|
17
|
+
if (typeof params.codeValue.$eq === 'string') {
|
|
18
|
+
matchStages.push({
|
|
19
|
+
$match: { 'hasCategoryCode.codeValue': { $exists: true, $eq: params.codeValue.$eq } }
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
if (params.inCodeSet !== undefined) {
|
|
24
|
+
if (typeof params.inCodeSet.codeValue === 'string') {
|
|
25
|
+
matchStages.push({
|
|
26
|
+
$match: { codeValue: { $exists: true, $regex: new RegExp(params.inCodeSet.codeValue) } }
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
else if (params.inCodeSet.codeValue !== undefined && params.inCodeSet.codeValue !== null) {
|
|
30
|
+
if (typeof params.inCodeSet.codeValue.$eq === 'string') {
|
|
31
|
+
matchStages.push({
|
|
32
|
+
$match: { codeValue: { $exists: true, $eq: params.inCodeSet.codeValue.$eq } }
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const nameRegex = params.name;
|
|
38
|
+
if (typeof nameRegex === 'string') {
|
|
39
|
+
matchStages.push({
|
|
40
|
+
$match: { 'hasCategoryCode.name': { $exists: true, $regex: new RegExp(nameRegex) } }
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return matchStages;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* 科目管理リポジトリ
|
|
47
|
+
*/
|
|
48
|
+
class AdminAccountTitleSetRepo {
|
|
49
|
+
accountTitleModel;
|
|
50
|
+
constructor(connection) {
|
|
51
|
+
this.accountTitleModel = connection.model(accountTitle_1.modelName, (0, accountTitle_1.createSchema)());
|
|
52
|
+
}
|
|
53
|
+
async addAccountTitleSet(params) {
|
|
54
|
+
const { codeValue, name, project, inCodeSet } = params;
|
|
55
|
+
// 科目分類の存在確認
|
|
56
|
+
const categoryDoc = await this.accountTitleModel.findOne({
|
|
57
|
+
'project.id': { $eq: project.id },
|
|
58
|
+
codeValue: { $eq: inCodeSet.codeValue }
|
|
59
|
+
}, { _id: 1 })
|
|
60
|
+
.exec();
|
|
61
|
+
if (categoryDoc === null) {
|
|
62
|
+
throw new factory_1.factory.errors.NotFound(accountTitle_1.modelName);
|
|
63
|
+
}
|
|
64
|
+
const newAccountTitleSet = {
|
|
65
|
+
typeOf: 'AccountTitle',
|
|
66
|
+
codeValue,
|
|
67
|
+
hasCategoryCode: [],
|
|
68
|
+
...(name !== undefined) && { name }
|
|
69
|
+
};
|
|
70
|
+
const doc = await this.accountTitleModel.findOneAndUpdate({
|
|
71
|
+
'project.id': { $eq: project.id },
|
|
72
|
+
codeValue: { $eq: inCodeSet.codeValue },
|
|
73
|
+
'hasCategoryCode.codeValue': { $ne: codeValue }
|
|
74
|
+
}, {
|
|
75
|
+
$push: { hasCategoryCode: newAccountTitleSet }
|
|
76
|
+
}, {
|
|
77
|
+
new: true,
|
|
78
|
+
projection: { _id: 1 }
|
|
79
|
+
})
|
|
80
|
+
.exec();
|
|
81
|
+
// 存在しなければ科目コード重複
|
|
82
|
+
if (doc === null) {
|
|
83
|
+
throw new factory_1.factory.errors.AlreadyInUse(accountTitle_1.modelName, ['hasCategoryCode.codeValue']);
|
|
84
|
+
}
|
|
85
|
+
return { id: doc.id };
|
|
86
|
+
}
|
|
87
|
+
async updateAccountTitleSet(params) {
|
|
88
|
+
const { codeValue, name, project, inCodeSet } = params;
|
|
89
|
+
const doc = await this.accountTitleModel.findOneAndUpdate({
|
|
90
|
+
'project.id': { $eq: project.id },
|
|
91
|
+
codeValue: { $eq: inCodeSet.codeValue },
|
|
92
|
+
'hasCategoryCode.codeValue': { $eq: codeValue }
|
|
93
|
+
}, {
|
|
94
|
+
'hasCategoryCode.$[accountTitleSet].name': name,
|
|
95
|
+
}, {
|
|
96
|
+
new: true,
|
|
97
|
+
arrayFilters: [
|
|
98
|
+
{ 'accountTitleSet.codeValue': codeValue }
|
|
99
|
+
],
|
|
100
|
+
projection: { _id: 1 }
|
|
101
|
+
})
|
|
102
|
+
.exec();
|
|
103
|
+
if (doc === null) {
|
|
104
|
+
throw new factory_1.factory.errors.NotFound(accountTitle_1.modelName);
|
|
105
|
+
}
|
|
106
|
+
return { id: doc.id };
|
|
107
|
+
}
|
|
108
|
+
async findAccountTitleSets(params) {
|
|
109
|
+
const aggregate = this.accountTitleModel.aggregate([
|
|
110
|
+
{ $unwind: '$hasCategoryCode' },
|
|
111
|
+
...createMatchStages(params),
|
|
112
|
+
{
|
|
113
|
+
$project: {
|
|
114
|
+
_id: 0,
|
|
115
|
+
codeValue: '$hasCategoryCode.codeValue',
|
|
116
|
+
name: '$hasCategoryCode.name',
|
|
117
|
+
inCodeSet: {
|
|
118
|
+
codeValue: '$codeValue',
|
|
119
|
+
name: '$name'
|
|
120
|
+
},
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
]);
|
|
124
|
+
if (typeof params.limit === 'number' && typeof params.page === 'number') {
|
|
125
|
+
aggregate.skip(params.limit * (params.page - 1))
|
|
126
|
+
.limit(params.limit);
|
|
127
|
+
}
|
|
128
|
+
return aggregate.exec();
|
|
129
|
+
}
|
|
130
|
+
async deleteAccountTitleSetByCodeValue(params) {
|
|
131
|
+
const { projectId, accountTitleCategoryCode, codeValue } = params;
|
|
132
|
+
const doc = await this.accountTitleModel.findOneAndUpdate({
|
|
133
|
+
'project.id': { $eq: projectId },
|
|
134
|
+
codeValue: { $eq: accountTitleCategoryCode },
|
|
135
|
+
'hasCategoryCode.codeValue': { $exists: true, $eq: codeValue }
|
|
136
|
+
}, {
|
|
137
|
+
$pull: { hasCategoryCode: { codeValue } }
|
|
138
|
+
}, {
|
|
139
|
+
new: true,
|
|
140
|
+
projection: { _id: 1 }
|
|
141
|
+
})
|
|
142
|
+
.exec();
|
|
143
|
+
if (doc === null) {
|
|
144
|
+
throw new factory_1.factory.errors.NotFound(accountTitle_1.modelName);
|
|
145
|
+
}
|
|
146
|
+
return { id: doc.id };
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
exports.AdminAccountTitleSetRepo = AdminAccountTitleSetRepo;
|
|
@@ -100,7 +100,7 @@ export declare class AdminEventRepo {
|
|
|
100
100
|
project: {
|
|
101
101
|
id: string;
|
|
102
102
|
};
|
|
103
|
-
superEventFromDB: Pick<factory.eventSeries.IEvent, 'additionalProperty' | 'alternativeHeadline' | 'description' | 'dubLanguage' | 'endDate' | 'headline' | 'id' | 'kanaName' | 'location' | 'name' | '
|
|
103
|
+
superEventFromDB: Pick<factory.eventSeries.IEvent, 'additionalProperty' | 'alternativeHeadline' | 'description' | 'dubLanguage' | 'endDate' | 'headline' | 'id' | 'kanaName' | 'location' | 'name' | 'startDate' | 'subtitleLanguage' | 'typeOf' | 'workPerformed'>;
|
|
104
104
|
startDate: {
|
|
105
105
|
$gte: Date;
|
|
106
106
|
};
|
|
@@ -40,28 +40,6 @@ export declare class AdminEventSeriesRepo {
|
|
|
40
40
|
};
|
|
41
41
|
id: string;
|
|
42
42
|
}): Promise<void>;
|
|
43
|
-
/**
|
|
44
|
-
* 既存施設コンテンツの最大バージョンを集計する
|
|
45
|
-
*/
|
|
46
|
-
aggregateMaxVersion(params: {
|
|
47
|
-
project: {
|
|
48
|
-
id: {
|
|
49
|
-
$eq: string;
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
workPerformed: {
|
|
53
|
-
identifier: {
|
|
54
|
-
$eq: string;
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
|
-
location: {
|
|
58
|
-
branchCode: {
|
|
59
|
-
$in: string[];
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
}): Promise<{
|
|
63
|
-
maxVersion: string;
|
|
64
|
-
}>;
|
|
65
43
|
getCursor(conditions: FilterQuery<any>, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, Record<string, never>, factory.eventSeries.IAttributes & {
|
|
66
44
|
_id: string;
|
|
67
45
|
}, import("./mongoose/virtuals").IVirtuals, {}> & factory.eventSeries.IAttributes & {
|