@chevre/domain 28.0.0-alpha.33 → 28.0.0-alpha.35
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/repo/adminAccountTitle.d.ts +38 -0
- package/lib/chevre/repo/adminAccountTitle.js +212 -0
- package/lib/chevre/repo/adminAccountTitleCategory.d.ts +37 -0
- package/lib/chevre/repo/adminAccountTitleCategory.js +129 -0
- package/lib/chevre/repo/adminAccountTitleSet.d.ts +40 -0
- package/lib/chevre/repo/adminAccountTitleSet.js +148 -0
- package/lib/chevre/repo/mongoose/schemas/accountTitle.js +15 -16
- package/lib/chevre/repository.d.ts +15 -5
- package/lib/chevre/repository.js +35 -13
- package/lib/chevre/service/project.d.ts +3 -3
- package/lib/chevre/service/project.js +1 -1
- package/lib/chevre/service/task/onResourceUpdated.js +5 -22
- package/package.json +1 -1
- package/lib/chevre/repo/accountTitle.d.ts +0 -27
- package/lib/chevre/repo/accountTitle.js +0 -30
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Connection } from 'mongoose';
|
|
2
|
+
import { factory } from '../factory';
|
|
3
|
+
type IFindParams = Pick<factory.accountTitle.ISearchConditions, 'codeValue' | 'limit' | 'name' | 'page' | 'project' | 'sort' | 'additionalProperty' | 'inCodeSet'>;
|
|
4
|
+
/**
|
|
5
|
+
* 細目管理リポジトリ
|
|
6
|
+
*/
|
|
7
|
+
export declare class AdminAccountTitleRepo {
|
|
8
|
+
private readonly accountTitleModel;
|
|
9
|
+
constructor(connection: Connection);
|
|
10
|
+
addAccountTitle(params: Pick<factory.accountTitle.IAccountTitle, 'codeValue' | 'name' | 'project' | 'additionalProperty'> & {
|
|
11
|
+
inCodeSet: {
|
|
12
|
+
codeValue: string;
|
|
13
|
+
inCodeSet: {
|
|
14
|
+
codeValue: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
}): Promise<{
|
|
18
|
+
id: string;
|
|
19
|
+
}>;
|
|
20
|
+
updateAccountTitle(params: Pick<factory.accountTitle.IAccountTitle, 'codeValue' | 'name' | 'project' | 'additionalProperty'> & {
|
|
21
|
+
inCodeSet: {
|
|
22
|
+
codeValue: string;
|
|
23
|
+
inCodeSet: {
|
|
24
|
+
codeValue: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
}): Promise<{
|
|
28
|
+
id: string;
|
|
29
|
+
}>;
|
|
30
|
+
findAccountTitles(params: IFindParams): Promise<Pick<factory.accountTitle.IAccountTitle, 'codeValue' | 'name' | 'project' | 'typeOf'>[]>;
|
|
31
|
+
deleteAccountTitleByCodeValue(params: {
|
|
32
|
+
projectId: string;
|
|
33
|
+
codeValue: string;
|
|
34
|
+
accountTitleCategoryCode: string;
|
|
35
|
+
accountTitleSetCode: string;
|
|
36
|
+
}): Promise<void>;
|
|
37
|
+
}
|
|
38
|
+
export {};
|
|
@@ -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': 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
|
+
inDefinedTermSet: '$hasCategoryCode.inDefinedTermSet'
|
|
177
|
+
},
|
|
178
|
+
additionalProperty: '$hasCategoryCode.hasCategoryCode.additionalProperty'
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
]);
|
|
182
|
+
if (typeof params.limit === 'number' && typeof params.page === 'number') {
|
|
183
|
+
aggregate.skip(params.limit * (params.page - 1))
|
|
184
|
+
.limit(params.limit);
|
|
185
|
+
}
|
|
186
|
+
return aggregate.exec();
|
|
187
|
+
}
|
|
188
|
+
async deleteAccountTitleByCodeValue(params) {
|
|
189
|
+
const { projectId, codeValue, accountTitleCategoryCode, accountTitleSetCode } = params;
|
|
190
|
+
const doc = await this.accountTitleModel.findOneAndUpdate({
|
|
191
|
+
'project.id': { $eq: projectId },
|
|
192
|
+
codeValue: { $eq: accountTitleCategoryCode },
|
|
193
|
+
'hasCategoryCode.codeValue': { $exists: true, $eq: accountTitleSetCode },
|
|
194
|
+
'hasCategoryCode.hasCategoryCode.codeValue': { $exists: true, $eq: codeValue }
|
|
195
|
+
}, {
|
|
196
|
+
$pull: {
|
|
197
|
+
'hasCategoryCode.$[accountTitleSet].hasCategoryCode': { codeValue }
|
|
198
|
+
}
|
|
199
|
+
}, {
|
|
200
|
+
new: true,
|
|
201
|
+
arrayFilters: [
|
|
202
|
+
{ 'accountTitleSet.codeValue': accountTitleSetCode }
|
|
203
|
+
],
|
|
204
|
+
projection: { _id: 1 }
|
|
205
|
+
})
|
|
206
|
+
.exec();
|
|
207
|
+
if (doc === null) {
|
|
208
|
+
throw new factory_1.factory.errors.NotFound(accountTitle_1.modelName);
|
|
209
|
+
}
|
|
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' | 'project' | 'typeOf'>[]>;
|
|
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,129 @@
|
|
|
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
|
+
project: 1,
|
|
98
|
+
typeOf: 1
|
|
99
|
+
});
|
|
100
|
+
if (typeof params.limit === 'number' && typeof params.page === 'number') {
|
|
101
|
+
query.limit(params.limit)
|
|
102
|
+
.skip(params.limit * (params.page - 1));
|
|
103
|
+
}
|
|
104
|
+
if (typeof params.sort?.codeValue === 'number') {
|
|
105
|
+
query.sort({ params: params.sort.codeValue });
|
|
106
|
+
}
|
|
107
|
+
return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
108
|
+
.lean()
|
|
109
|
+
.exec();
|
|
110
|
+
}
|
|
111
|
+
async deleteAccountTitleCategoryByCodeValue(params) {
|
|
112
|
+
const { projectId, codeValue } = params;
|
|
113
|
+
await this.accountTitleModel.findOneAndDelete({
|
|
114
|
+
'project.id': { $eq: projectId },
|
|
115
|
+
codeValue: { $eq: codeValue }
|
|
116
|
+
})
|
|
117
|
+
.exec()
|
|
118
|
+
.then((doc) => {
|
|
119
|
+
if (doc === null) {
|
|
120
|
+
throw new factory_1.factory.errors.NotFound(accountTitle_1.modelName);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
async unsetUnnecessaryFields(params) {
|
|
125
|
+
return this.accountTitleModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
|
|
126
|
+
.exec();
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
exports.AdminAccountTitleCategoryRepo = AdminAccountTitleCategoryRepo;
|
|
@@ -0,0 +1,40 @@
|
|
|
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
|
+
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<void>;
|
|
39
|
+
}
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,148 @@
|
|
|
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
|
+
}
|
|
147
|
+
}
|
|
148
|
+
exports.AdminAccountTitleSetRepo = AdminAccountTitleSetRepo;
|
|
@@ -95,24 +95,23 @@ const indexes = [
|
|
|
95
95
|
'hasCategoryCode.codeValue': { $exists: true }
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
|
-
]
|
|
98
|
+
],
|
|
99
|
+
// 'hasCategoryCode.hasCategoryCode.codeValue': null のインデックスが作成されてうまくいかない
|
|
100
|
+
// [
|
|
101
|
+
// {
|
|
102
|
+
// 'project.id': 1,
|
|
103
|
+
// 'hasCategoryCode.hasCategoryCode.codeValue': 1
|
|
104
|
+
// },
|
|
105
|
+
// {
|
|
106
|
+
// name: 'uniqueAccountTitleCode',
|
|
107
|
+
// unique: true,
|
|
108
|
+
// partialFilterExpression: {
|
|
109
|
+
// 'hasCategoryCode.hasCategoryCode.codeValue': { $exists: true }
|
|
110
|
+
// }
|
|
111
|
+
// }
|
|
112
|
+
// ]
|
|
99
113
|
];
|
|
100
114
|
exports.indexes = indexes;
|
|
101
|
-
// 'hasCategoryCode.hasCategoryCode.codeValue': null のインデックスは作成されてうまくいかないので保留
|
|
102
|
-
// schema.index(
|
|
103
|
-
// {
|
|
104
|
-
// 'project.id': 1,
|
|
105
|
-
// 'hasCategoryCode.hasCategoryCode.codeValue': 1
|
|
106
|
-
// },
|
|
107
|
-
// {
|
|
108
|
-
// name: 'uniqueHasCategoryCodeHasCategoryCodeCodeValue',
|
|
109
|
-
// unique: true,
|
|
110
|
-
// partialFilterExpression: {
|
|
111
|
-
// 'project.id': { $exists: true },
|
|
112
|
-
// 'hasCategoryCode.hasCategoryCode.codeValue': { $exists: true }
|
|
113
|
-
// }
|
|
114
|
-
// }
|
|
115
|
-
// );
|
|
116
115
|
/**
|
|
117
116
|
* 勘定科目スキーマ
|
|
118
117
|
*/
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { AcceptedOfferRepo } from './repo/acceptedOffer';
|
|
5
5
|
import type { AccountingReportRepo } from './repo/accountingReport';
|
|
6
|
-
import type { AccountTitleRepo } from './repo/accountTitle';
|
|
7
6
|
import type { AcceptCOAOfferActionRepo } from './repo/action/acceptCOAOffer';
|
|
8
7
|
import type { AcceptPayActionRepo } from './repo/action/acceptPay';
|
|
9
8
|
import type { AuthorizeInvoiceActionRepo } from './repo/action/authorizeInvoice';
|
|
@@ -21,6 +20,9 @@ import type { OrderActionRepo } from './repo/action/order';
|
|
|
21
20
|
import type { ConfirmActionRepo } from './repo/action/confirm';
|
|
22
21
|
import type { AsyncActionRepo } from './repo/asyncAction';
|
|
23
22
|
import type { AdditionalPropertyRepo } from './repo/additionalProperty';
|
|
23
|
+
import type { AdminAccountTitleRepo } from './repo/adminAccountTitle';
|
|
24
|
+
import type { AdminAccountTitleCategoryRepo } from './repo/adminAccountTitleCategory';
|
|
25
|
+
import type { AdminAccountTitleSetRepo } from './repo/adminAccountTitleSet';
|
|
24
26
|
import type { AdminAccountingReportRepo } from './repo/adminAccountingReport';
|
|
25
27
|
import type { AdminAcceptedOfferRepo } from './repo/adminAcceptedOffer';
|
|
26
28
|
import type { AdminActionRepo } from './repo/adminAction';
|
|
@@ -129,10 +131,6 @@ export type AccountingReport = AccountingReportRepo;
|
|
|
129
131
|
export declare namespace AccountingReport {
|
|
130
132
|
function createInstance(...params: ConstructorParameters<typeof AccountingReportRepo>): Promise<AccountingReportRepo>;
|
|
131
133
|
}
|
|
132
|
-
export type AccountTitle = AccountTitleRepo;
|
|
133
|
-
export declare namespace AccountTitle {
|
|
134
|
-
function createInstance(...params: ConstructorParameters<typeof AccountTitleRepo>): Promise<AccountTitleRepo>;
|
|
135
|
-
}
|
|
136
134
|
export declare namespace action {
|
|
137
135
|
type AcceptCOAOffer = AcceptCOAOfferActionRepo;
|
|
138
136
|
namespace AcceptCOAOffer {
|
|
@@ -199,6 +197,18 @@ export type AdditionalProperty = AdditionalPropertyRepo;
|
|
|
199
197
|
export declare namespace AdditionalProperty {
|
|
200
198
|
function createInstance(...params: ConstructorParameters<typeof AdditionalPropertyRepo>): Promise<AdditionalPropertyRepo>;
|
|
201
199
|
}
|
|
200
|
+
export type AdminAccountTitle = AdminAccountTitleRepo;
|
|
201
|
+
export declare namespace AdminAccountTitle {
|
|
202
|
+
function createInstance(...params: ConstructorParameters<typeof AdminAccountTitleRepo>): Promise<AdminAccountTitleRepo>;
|
|
203
|
+
}
|
|
204
|
+
export type AdminAccountTitleCategory = AdminAccountTitleCategoryRepo;
|
|
205
|
+
export declare namespace AdminAccountTitleCategory {
|
|
206
|
+
function createInstance(...params: ConstructorParameters<typeof AdminAccountTitleCategoryRepo>): Promise<AdminAccountTitleCategoryRepo>;
|
|
207
|
+
}
|
|
208
|
+
export type AdminAccountTitleSet = AdminAccountTitleSetRepo;
|
|
209
|
+
export declare namespace AdminAccountTitleSet {
|
|
210
|
+
function createInstance(...params: ConstructorParameters<typeof AdminAccountTitleSetRepo>): Promise<AdminAccountTitleSetRepo>;
|
|
211
|
+
}
|
|
202
212
|
export type AdminAccountingReport = AdminAccountingReportRepo;
|
|
203
213
|
export declare namespace AdminAccountingReport {
|
|
204
214
|
function createInstance(...params: ConstructorParameters<typeof AdminAccountingReportRepo>): Promise<AdminAccountingReportRepo>;
|
package/lib/chevre/repository.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.WebSite = exports.rateLimit = exports.TransactionProcess = exports.TransactionNumber = exports.transaction = exports.Transaction = exports.Ticket = exports.AsyncAction = exports.TaskDelayed = exports.Task = exports.ScheduledTask = exports.StockHolder = exports.setting = exports.Setting = exports.ServiceAvailableHour = exports.SellerReturnPolicy = exports.SellerPaymentAccepted = exports.SellerMakesOffer = exports.Seller = exports.Schedule = exports.Role = exports.ReserveInterface = exports.Reservation = exports.ProjectMakesOffer = exports.Project = exports.ProductHasOfferCatalog = exports.Product = exports.PriceSpecification = exports.PotentialAction = exports.place = exports.Person = exports.PendingReservation = exports.PaymentServiceProvider = exports.PaymentService = exports.Passport = exports.OrderNumber = exports.OrderInTransaction = exports.Order = exports.Offer = exports.OfferItemCondition = exports.OfferCatalogItem = exports.OfferCatalog = exports.NoteAboutOrder = exports.Note = exports.MovieTicketType = exports.Message = void 0;
|
|
3
|
+
exports.Member = exports.Issuer = exports.IdentityProvider = exports.Identity = exports.EventSeries = exports.EventSellerMakesOffer = exports.EventOffer = exports.Event = exports.EmailMessage = exports.CustomerType = exports.Customer = exports.Credentials = exports.CreativeWork = exports.ConfirmationNumber = exports.Authorization = exports.CategoryCode = exports.assetTransaction = exports.AssetTransaction = exports.Aggregation = exports.AggregateReservation = exports.AggregateOrder = exports.AggregateOffer = exports.AggregateEvent = exports.AggregateAssetTransaction = exports.AggregateTransaction = exports.AggregateTask = exports.AggregateScheduledTask = exports.AggregateUseAction = exports.AggregateCheckMovieTicketAction = exports.AggregateAction = exports.AdminTransaction = exports.AdminTask = exports.AdminScheduledTask = exports.AdminPendingReservation = exports.AdminPaymentServiceChannel = exports.AdminEventSeries = exports.AdminEvent = exports.AdminAsyncAction = exports.AdminAssetTransaction = exports.AdminCheckMovieTicketAction = exports.AdminAction = exports.AdminAcceptedOffer = exports.AdminAccountingReport = exports.AdminAccountTitleSet = exports.AdminAccountTitleCategory = exports.AdminAccountTitle = exports.AdditionalProperty = exports.action = exports.AccountingReport = exports.AcceptedOffer = void 0;
|
|
4
|
+
exports.WebSite = exports.rateLimit = exports.TransactionProcess = exports.TransactionNumber = exports.transaction = exports.Transaction = exports.Ticket = exports.AsyncAction = exports.TaskDelayed = exports.Task = exports.ScheduledTask = exports.StockHolder = exports.setting = exports.Setting = exports.ServiceAvailableHour = exports.SellerReturnPolicy = exports.SellerPaymentAccepted = exports.SellerMakesOffer = exports.Seller = exports.Schedule = exports.Role = exports.ReserveInterface = exports.Reservation = exports.ProjectMakesOffer = exports.Project = exports.ProductHasOfferCatalog = exports.Product = exports.PriceSpecification = exports.PotentialAction = exports.place = exports.Person = exports.PendingReservation = exports.PaymentServiceProvider = exports.PaymentService = exports.Passport = exports.OrderNumber = exports.OrderInTransaction = exports.Order = exports.Offer = exports.OfferItemCondition = exports.OfferCatalogItem = exports.OfferCatalog = exports.NoteAboutOrder = exports.Note = exports.MovieTicketType = exports.Message = exports.MerchantReturnPolicy = exports.MemberProgram = void 0;
|
|
5
5
|
var AcceptedOffer;
|
|
6
6
|
(function (AcceptedOffer) {
|
|
7
7
|
let repo;
|
|
@@ -24,17 +24,6 @@ var AccountingReport;
|
|
|
24
24
|
}
|
|
25
25
|
AccountingReport.createInstance = createInstance;
|
|
26
26
|
})(AccountingReport || (exports.AccountingReport = AccountingReport = {}));
|
|
27
|
-
var AccountTitle;
|
|
28
|
-
(function (AccountTitle) {
|
|
29
|
-
let repo;
|
|
30
|
-
async function createInstance(...params) {
|
|
31
|
-
if (repo === undefined) {
|
|
32
|
-
repo = (await import('./repo/accountTitle.js')).AccountTitleRepo;
|
|
33
|
-
}
|
|
34
|
-
return new repo(...params);
|
|
35
|
-
}
|
|
36
|
-
AccountTitle.createInstance = createInstance;
|
|
37
|
-
})(AccountTitle || (exports.AccountTitle = AccountTitle = {}));
|
|
38
27
|
var action;
|
|
39
28
|
(function (action) {
|
|
40
29
|
let AcceptCOAOffer;
|
|
@@ -214,6 +203,39 @@ var AdditionalProperty;
|
|
|
214
203
|
}
|
|
215
204
|
AdditionalProperty.createInstance = createInstance;
|
|
216
205
|
})(AdditionalProperty || (exports.AdditionalProperty = AdditionalProperty = {}));
|
|
206
|
+
var AdminAccountTitle;
|
|
207
|
+
(function (AdminAccountTitle) {
|
|
208
|
+
let repo;
|
|
209
|
+
async function createInstance(...params) {
|
|
210
|
+
if (repo === undefined) {
|
|
211
|
+
repo = (await import('./repo/adminAccountTitle.js')).AdminAccountTitleRepo;
|
|
212
|
+
}
|
|
213
|
+
return new repo(...params);
|
|
214
|
+
}
|
|
215
|
+
AdminAccountTitle.createInstance = createInstance;
|
|
216
|
+
})(AdminAccountTitle || (exports.AdminAccountTitle = AdminAccountTitle = {}));
|
|
217
|
+
var AdminAccountTitleCategory;
|
|
218
|
+
(function (AdminAccountTitleCategory) {
|
|
219
|
+
let repo;
|
|
220
|
+
async function createInstance(...params) {
|
|
221
|
+
if (repo === undefined) {
|
|
222
|
+
repo = (await import('./repo/adminAccountTitleCategory.js')).AdminAccountTitleCategoryRepo;
|
|
223
|
+
}
|
|
224
|
+
return new repo(...params);
|
|
225
|
+
}
|
|
226
|
+
AdminAccountTitleCategory.createInstance = createInstance;
|
|
227
|
+
})(AdminAccountTitleCategory || (exports.AdminAccountTitleCategory = AdminAccountTitleCategory = {}));
|
|
228
|
+
var AdminAccountTitleSet;
|
|
229
|
+
(function (AdminAccountTitleSet) {
|
|
230
|
+
let repo;
|
|
231
|
+
async function createInstance(...params) {
|
|
232
|
+
if (repo === undefined) {
|
|
233
|
+
repo = (await import('./repo/adminAccountTitleSet.js')).AdminAccountTitleSetRepo;
|
|
234
|
+
}
|
|
235
|
+
return new repo(...params);
|
|
236
|
+
}
|
|
237
|
+
AdminAccountTitleSet.createInstance = createInstance;
|
|
238
|
+
})(AdminAccountTitleSet || (exports.AdminAccountTitleSet = AdminAccountTitleSet = {}));
|
|
217
239
|
var AdminAccountingReport;
|
|
218
240
|
(function (AdminAccountingReport) {
|
|
219
241
|
let repo;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* プロジェクトサービス
|
|
3
3
|
*/
|
|
4
|
-
import type {
|
|
4
|
+
import type { AdminAccountTitleCategoryRepo } from '../repo/adminAccountTitleCategory';
|
|
5
5
|
import type { AssetTransactionRepo } from '../repo/assetTransaction';
|
|
6
6
|
import type { CategoryCodeRepo } from '../repo/categoryCode';
|
|
7
7
|
import type { CreativeWorkRepo } from '../repo/creativeWork';
|
|
@@ -20,7 +20,7 @@ import type { SellerRepo } from '../repo/seller';
|
|
|
20
20
|
export declare function deleteProject(params: {
|
|
21
21
|
id: string;
|
|
22
22
|
}): (repos: {
|
|
23
|
-
|
|
23
|
+
adminAccountTitleCategory: AdminAccountTitleCategoryRepo;
|
|
24
24
|
categoryCode: CategoryCodeRepo;
|
|
25
25
|
creativeWork: CreativeWorkRepo;
|
|
26
26
|
adminEvent: AdminEventRepo;
|
|
@@ -40,7 +40,7 @@ export declare function deleteProject(params: {
|
|
|
40
40
|
export declare function cleanUpDatabaseByProject(params: {
|
|
41
41
|
id: string;
|
|
42
42
|
}): (repos: {
|
|
43
|
-
|
|
43
|
+
adminAccountTitleCategory: AdminAccountTitleCategoryRepo;
|
|
44
44
|
assetTransaction: AssetTransactionRepo;
|
|
45
45
|
categoryCode: CategoryCodeRepo;
|
|
46
46
|
creativeWork: CreativeWorkRepo;
|
|
@@ -12,7 +12,7 @@ function deleteProject(params) {
|
|
|
12
12
|
function cleanUpDatabaseByProject(params) {
|
|
13
13
|
return async (repos) => {
|
|
14
14
|
// プロジェクトに所属する全データをリポジトリから削除する
|
|
15
|
-
await repos.
|
|
15
|
+
await repos.adminAccountTitleCategory.deleteAccountTitleCategoriesByProject({ project: { id: params.id } });
|
|
16
16
|
await repos.assetTransaction.deleteByProject({ project: { id: params.id } });
|
|
17
17
|
await repos.categoryCode.deleteCategoryCodesByProject({ project: { id: params.id } });
|
|
18
18
|
await repos.movieTicketType.deleteMovieTicketTypesByProject({ project: { id: params.id } });
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.call = call;
|
|
4
4
|
const factory_1 = require("../../factory");
|
|
5
|
-
const
|
|
5
|
+
const adminAccountTitleCategory_1 = require("../../repo/adminAccountTitleCategory");
|
|
6
6
|
const aggregateOffer_1 = require("../../repo/aggregateOffer");
|
|
7
7
|
const categoryCode_1 = require("../../repo/categoryCode");
|
|
8
8
|
const creativeWork_1 = require("../../repo/creativeWork");
|
|
@@ -32,7 +32,7 @@ function call(params) {
|
|
|
32
32
|
return async ({ connection }) => {
|
|
33
33
|
const { data } = params;
|
|
34
34
|
await onResourceUpdated(data)({
|
|
35
|
-
|
|
35
|
+
adminAccountTitleCategory: new adminAccountTitleCategory_1.AdminAccountTitleCategoryRepo(connection),
|
|
36
36
|
aggregateOffer: new aggregateOffer_1.AggregateOfferRepo(connection),
|
|
37
37
|
categoryCode: new categoryCode_1.CategoryCodeRepo(connection),
|
|
38
38
|
creativeWork: new creativeWork_1.CreativeWorkRepo(connection),
|
|
@@ -576,26 +576,9 @@ function createInformAccountTitleTasks(params, setting) {
|
|
|
576
576
|
}
|
|
577
577
|
// const informResources = settings.onResourceUpdated.informResource;
|
|
578
578
|
const informResources = setting?.onResourceUpdated?.informResource;
|
|
579
|
-
const accountTitle = await repos.
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
}, {
|
|
583
|
-
_id: 0,
|
|
584
|
-
id: { $toString: '$_id' },
|
|
585
|
-
additionalProperty: 1,
|
|
586
|
-
codeValue: 1,
|
|
587
|
-
hasCategoryCode: 1,
|
|
588
|
-
name: 1,
|
|
589
|
-
project: 1,
|
|
590
|
-
typeOf: 1
|
|
591
|
-
})
|
|
592
|
-
.lean()
|
|
593
|
-
.exec()
|
|
594
|
-
.then((doc) => {
|
|
595
|
-
if (doc === null) {
|
|
596
|
-
throw new factory_1.factory.errors.NotFound(params.typeOf);
|
|
597
|
-
}
|
|
598
|
-
return doc;
|
|
579
|
+
const accountTitle = await repos.adminAccountTitleCategory.findAccountTitleCategorAsNotification({
|
|
580
|
+
id: params.ids[0],
|
|
581
|
+
projectId: params.project.id
|
|
599
582
|
});
|
|
600
583
|
const accountTitles4inform = [accountTitle];
|
|
601
584
|
if (accountTitles4inform.length > 0) {
|
package/package.json
CHANGED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { Connection } from 'mongoose';
|
|
2
|
-
import { IDocType, IModel } from './mongoose/schemas/accountTitle';
|
|
3
|
-
/**
|
|
4
|
-
* 科目リポジトリ
|
|
5
|
-
*/
|
|
6
|
-
export declare class AccountTitleRepo {
|
|
7
|
-
readonly accountTitleModel: IModel;
|
|
8
|
-
constructor(connection: Connection);
|
|
9
|
-
deleteByProject(params: {
|
|
10
|
-
project: {
|
|
11
|
-
id: string;
|
|
12
|
-
};
|
|
13
|
-
}): Promise<void>;
|
|
14
|
-
getCursor(conditions: any, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, Record<string, never>, IDocType, import("./mongoose/virtuals").IVirtuals, {}> & IDocType & {
|
|
15
|
-
_id: import("mongoose").Types.ObjectId;
|
|
16
|
-
} & {
|
|
17
|
-
__v: number;
|
|
18
|
-
}, import("mongoose").QueryOptions<IDocType>, (import("mongoose").Document<unknown, Record<string, never>, IDocType, import("./mongoose/virtuals").IVirtuals, {}> & IDocType & {
|
|
19
|
-
_id: import("mongoose").Types.ObjectId;
|
|
20
|
-
} & {
|
|
21
|
-
__v: number;
|
|
22
|
-
}) | null>;
|
|
23
|
-
unsetUnnecessaryFields(params: {
|
|
24
|
-
filter: any;
|
|
25
|
-
$unset: any;
|
|
26
|
-
}): Promise<import("mongoose").UpdateWriteOpResult>;
|
|
27
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AccountTitleRepo = void 0;
|
|
4
|
-
const factory_1 = require("../factory");
|
|
5
|
-
const accountTitle_1 = require("./mongoose/schemas/accountTitle");
|
|
6
|
-
/**
|
|
7
|
-
* 科目リポジトリ
|
|
8
|
-
*/
|
|
9
|
-
class AccountTitleRepo {
|
|
10
|
-
accountTitleModel;
|
|
11
|
-
constructor(connection) {
|
|
12
|
-
this.accountTitleModel = connection.model(accountTitle_1.modelName, (0, accountTitle_1.createSchema)());
|
|
13
|
-
}
|
|
14
|
-
async deleteByProject(params) {
|
|
15
|
-
await this.accountTitleModel.deleteMany({
|
|
16
|
-
'project.id': { $exists: true, $eq: params.project.id }
|
|
17
|
-
})
|
|
18
|
-
.exec();
|
|
19
|
-
}
|
|
20
|
-
getCursor(conditions, projection) {
|
|
21
|
-
return this.accountTitleModel.find(conditions, projection)
|
|
22
|
-
.sort({ codeValue: factory_1.factory.sortType.Descending })
|
|
23
|
-
.cursor();
|
|
24
|
-
}
|
|
25
|
-
async unsetUnnecessaryFields(params) {
|
|
26
|
-
return this.accountTitleModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
|
|
27
|
-
.exec();
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
exports.AccountTitleRepo = AccountTitleRepo;
|