@chevre/domain 28.0.0-alpha.34 → 28.0.0-alpha.36
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 +40 -0
- package/lib/chevre/repo/adminAccountTitle.js +213 -0
- package/lib/chevre/repo/adminAccountTitleCategory.d.ts +4 -0
- package/lib/chevre/repo/adminAccountTitleCategory.js +4 -0
- package/lib/chevre/repo/adminAccountTitleSet.d.ts +42 -0
- package/lib/chevre/repo/adminAccountTitleSet.js +149 -0
- package/lib/chevre/repository.d.ts +10 -5
- package/lib/chevre/repository.js +24 -13
- package/package.json +1 -1
- package/lib/chevre/repo/accountTitle.d.ts +0 -13
- package/lib/chevre/repo/accountTitle.js +0 -24
|
@@ -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' | '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<{
|
|
37
|
+
id: string;
|
|
38
|
+
}>;
|
|
39
|
+
}
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,213 @@
|
|
|
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
|
+
return { id: doc.id };
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
exports.AdminAccountTitleRepo = AdminAccountTitleRepo;
|
|
@@ -29,5 +29,9 @@ export declare class AdminAccountTitleCategoryRepo {
|
|
|
29
29
|
projectId: string;
|
|
30
30
|
codeValue: string;
|
|
31
31
|
}): Promise<void>;
|
|
32
|
+
unsetUnnecessaryFields(params: {
|
|
33
|
+
filter: any;
|
|
34
|
+
$unset: any;
|
|
35
|
+
}): Promise<import("mongoose").UpdateWriteOpResult>;
|
|
32
36
|
}
|
|
33
37
|
export {};
|
|
@@ -121,5 +121,9 @@ class AdminAccountTitleCategoryRepo {
|
|
|
121
121
|
}
|
|
122
122
|
});
|
|
123
123
|
}
|
|
124
|
+
async unsetUnnecessaryFields(params) {
|
|
125
|
+
return this.accountTitleModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
|
|
126
|
+
.exec();
|
|
127
|
+
}
|
|
124
128
|
}
|
|
125
129
|
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' | '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<{
|
|
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;
|
|
@@ -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,7 +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
24
|
import type { AdminAccountTitleCategoryRepo } from './repo/adminAccountTitleCategory';
|
|
25
|
+
import type { AdminAccountTitleSetRepo } from './repo/adminAccountTitleSet';
|
|
25
26
|
import type { AdminAccountingReportRepo } from './repo/adminAccountingReport';
|
|
26
27
|
import type { AdminAcceptedOfferRepo } from './repo/adminAcceptedOffer';
|
|
27
28
|
import type { AdminActionRepo } from './repo/adminAction';
|
|
@@ -130,10 +131,6 @@ export type AccountingReport = AccountingReportRepo;
|
|
|
130
131
|
export declare namespace AccountingReport {
|
|
131
132
|
function createInstance(...params: ConstructorParameters<typeof AccountingReportRepo>): Promise<AccountingReportRepo>;
|
|
132
133
|
}
|
|
133
|
-
export type AccountTitle = AccountTitleRepo;
|
|
134
|
-
export declare namespace AccountTitle {
|
|
135
|
-
function createInstance(...params: ConstructorParameters<typeof AccountTitleRepo>): Promise<AccountTitleRepo>;
|
|
136
|
-
}
|
|
137
134
|
export declare namespace action {
|
|
138
135
|
type AcceptCOAOffer = AcceptCOAOfferActionRepo;
|
|
139
136
|
namespace AcceptCOAOffer {
|
|
@@ -200,10 +197,18 @@ export type AdditionalProperty = AdditionalPropertyRepo;
|
|
|
200
197
|
export declare namespace AdditionalProperty {
|
|
201
198
|
function createInstance(...params: ConstructorParameters<typeof AdditionalPropertyRepo>): Promise<AdditionalPropertyRepo>;
|
|
202
199
|
}
|
|
200
|
+
export type AdminAccountTitle = AdminAccountTitleRepo;
|
|
201
|
+
export declare namespace AdminAccountTitle {
|
|
202
|
+
function createInstance(...params: ConstructorParameters<typeof AdminAccountTitleRepo>): Promise<AdminAccountTitleRepo>;
|
|
203
|
+
}
|
|
203
204
|
export type AdminAccountTitleCategory = AdminAccountTitleCategoryRepo;
|
|
204
205
|
export declare namespace AdminAccountTitleCategory {
|
|
205
206
|
function createInstance(...params: ConstructorParameters<typeof AdminAccountTitleCategoryRepo>): Promise<AdminAccountTitleCategoryRepo>;
|
|
206
207
|
}
|
|
208
|
+
export type AdminAccountTitleSet = AdminAccountTitleSetRepo;
|
|
209
|
+
export declare namespace AdminAccountTitleSet {
|
|
210
|
+
function createInstance(...params: ConstructorParameters<typeof AdminAccountTitleSetRepo>): Promise<AdminAccountTitleSetRepo>;
|
|
211
|
+
}
|
|
207
212
|
export type AdminAccountingReport = AdminAccountingReportRepo;
|
|
208
213
|
export declare namespace AdminAccountingReport {
|
|
209
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 = exports.MerchantReturnPolicy = 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,17 @@ 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
217
|
var AdminAccountTitleCategory;
|
|
218
218
|
(function (AdminAccountTitleCategory) {
|
|
219
219
|
let repo;
|
|
@@ -225,6 +225,17 @@ var AdminAccountTitleCategory;
|
|
|
225
225
|
}
|
|
226
226
|
AdminAccountTitleCategory.createInstance = createInstance;
|
|
227
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 = {}));
|
|
228
239
|
var AdminAccountingReport;
|
|
229
240
|
(function (AdminAccountingReport) {
|
|
230
241
|
let repo;
|
package/package.json
CHANGED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Connection } from 'mongoose';
|
|
2
|
-
import { IModel } from './mongoose/schemas/accountTitle';
|
|
3
|
-
/**
|
|
4
|
-
* 科目リポジトリ
|
|
5
|
-
*/
|
|
6
|
-
export declare class AccountTitleRepo {
|
|
7
|
-
readonly accountTitleModel: IModel;
|
|
8
|
-
constructor(connection: Connection);
|
|
9
|
-
unsetUnnecessaryFields(params: {
|
|
10
|
-
filter: any;
|
|
11
|
-
$unset: any;
|
|
12
|
-
}): Promise<import("mongoose").UpdateWriteOpResult>;
|
|
13
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AccountTitleRepo = void 0;
|
|
4
|
-
// import { factory } from '../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
|
-
// public getCursor(conditions: any, projection: any) { // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
15
|
-
// return this.accountTitleModel.find(conditions, projection)
|
|
16
|
-
// .sort({ codeValue: factory.sortType.Descending })
|
|
17
|
-
// .cursor();
|
|
18
|
-
// }
|
|
19
|
-
async unsetUnnecessaryFields(params) {
|
|
20
|
-
return this.accountTitleModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
|
|
21
|
-
.exec();
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
exports.AccountTitleRepo = AccountTitleRepo;
|