@provis/provis-common-be-module 2.6.46 → 2.6.48
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/dist/class/main.repository.d.ts +2 -2
- package/dist/class/main.repository.js +47 -3
- package/dist/constants/insurance.js +6 -0
- package/dist/constants/invoice/tax.d.ts +7 -0
- package/dist/constants/invoice/tax.js +9 -0
- package/dist/constants/product/cargo/deductible.json +7 -0
- package/dist/constants/product/property/property.js +2 -2
- package/dist/constants/source.d.ts +8 -1
- package/dist/constants/source.js +4 -0
- package/dist/constants/user.d.ts +16 -0
- package/dist/constants/user.js +16 -0
- package/dist/helpers/excelDateToJs.d.ts +2 -0
- package/dist/helpers/excelDateToJs.js +18 -0
- package/dist/interface/find.all.count.interface.d.ts +2 -0
- package/dist/interface/search.conditions.interface.d.ts +2 -0
- package/dist/interface/search.query.interface.d.ts +1 -1
- package/dist/interface/search.summary.interface.d.ts +2 -0
- package/dist/interface/subquery.in.interface.d.ts +9 -0
- package/dist/interface/subquery.in.interface.js +2 -0
- package/package.json +1 -1
|
@@ -16,8 +16,8 @@ export declare class MainRepository<T> extends Repository<T> {
|
|
|
16
16
|
orderDirection: 'ASC' | 'DESC';
|
|
17
17
|
};
|
|
18
18
|
searchBracket(searchOr: any[], searchValues: (value: any) => Promise<ISearchQuery[]>): Promise<ISearchQuery[][]>;
|
|
19
|
-
summaryField({ fieldToSum, search, additionalSearchOr, relations, }: ISearchSummary): Promise<any>;
|
|
20
|
-
findAllAndCount({ search, additionalSearchOr, relations, sortBy, offset, maxCount, }: IFindAllCount): Promise<[number, T[]]>;
|
|
19
|
+
summaryField({ fieldToSum, search, additionalSearchOr, relations, subqueryIns, }: ISearchSummary): Promise<any>;
|
|
20
|
+
findAllAndCount({ search, additionalSearchOr, relations, subqueryIns, sortBy, offset, maxCount, }: IFindAllCount): Promise<[number, T[]]>;
|
|
21
21
|
private applySearchConditions;
|
|
22
22
|
private generateRawCount;
|
|
23
23
|
private generateRawOrder;
|
|
@@ -116,7 +116,7 @@ class MainRepository extends typeorm_1.Repository {
|
|
|
116
116
|
return result;
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
|
-
summaryField({ fieldToSum, search, additionalSearchOr, relations, }) {
|
|
119
|
+
summaryField({ fieldToSum, search, additionalSearchOr, relations, subqueryIns, }) {
|
|
120
120
|
return __awaiter(this, void 0, void 0, function* () {
|
|
121
121
|
let query = this.createQueryBuilder()
|
|
122
122
|
.select([
|
|
@@ -128,11 +128,12 @@ class MainRepository extends typeorm_1.Repository {
|
|
|
128
128
|
search,
|
|
129
129
|
additionalSearchOr,
|
|
130
130
|
relations,
|
|
131
|
+
subqueryIns,
|
|
131
132
|
});
|
|
132
133
|
return query.getRawOne();
|
|
133
134
|
});
|
|
134
135
|
}
|
|
135
|
-
findAllAndCount({ search, additionalSearchOr, relations, sortBy, offset = 1, maxCount = 50, }) {
|
|
136
|
+
findAllAndCount({ search, additionalSearchOr, relations, subqueryIns, sortBy, offset = 1, maxCount = 50, }) {
|
|
136
137
|
return __awaiter(this, void 0, void 0, function* () {
|
|
137
138
|
const skipItems = ((offset < 1 ? 1 : offset) - 1) * maxCount;
|
|
138
139
|
let query = this.createQueryBuilder().select(this.selectFieldOnFindAllAndCount());
|
|
@@ -141,6 +142,7 @@ class MainRepository extends typeorm_1.Repository {
|
|
|
141
142
|
search,
|
|
142
143
|
additionalSearchOr,
|
|
143
144
|
relations,
|
|
145
|
+
subqueryIns,
|
|
144
146
|
});
|
|
145
147
|
const { orderBy, orderDirection } = this.getOrderData(sortBy);
|
|
146
148
|
return [
|
|
@@ -153,7 +155,7 @@ class MainRepository extends typeorm_1.Repository {
|
|
|
153
155
|
];
|
|
154
156
|
});
|
|
155
157
|
}
|
|
156
|
-
applySearchConditions({ query, search, additionalSearchOr, relations, }) {
|
|
158
|
+
applySearchConditions({ query, search, additionalSearchOr, relations, subqueryIns, }) {
|
|
157
159
|
const modelName = this.modelName();
|
|
158
160
|
if (search && search.length > 0) {
|
|
159
161
|
let index = 0;
|
|
@@ -242,6 +244,48 @@ class MainRepository extends typeorm_1.Repository {
|
|
|
242
244
|
}
|
|
243
245
|
});
|
|
244
246
|
}
|
|
247
|
+
if (subqueryIns && subqueryIns.length > 0) {
|
|
248
|
+
subqueryIns.forEach((sub) => {
|
|
249
|
+
const alias = sub.subqueryAlias || sub.subqueryTable;
|
|
250
|
+
query = query.andWhere((qb) => {
|
|
251
|
+
var _a, _b;
|
|
252
|
+
const subQuery = qb.subQuery()
|
|
253
|
+
.select(`${alias}.${sub.subquerySelectColumn}`)
|
|
254
|
+
.from(sub.subqueryTable, alias);
|
|
255
|
+
let subIdx = 0;
|
|
256
|
+
(_a = sub.searchs) === null || _a === void 0 ? void 0 : _a.forEach((s) => {
|
|
257
|
+
if (s) {
|
|
258
|
+
if (subIdx === 0) {
|
|
259
|
+
subQuery.where(`${alias}.${s.query}`, { [s.key]: s.value });
|
|
260
|
+
}
|
|
261
|
+
else {
|
|
262
|
+
subQuery.andWhere(`${alias}.${s.query}`, { [s.key]: s.value });
|
|
263
|
+
}
|
|
264
|
+
subIdx++;
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
(_b = sub.additionalSearchOr) === null || _b === void 0 ? void 0 : _b.forEach((group) => {
|
|
268
|
+
if (group) {
|
|
269
|
+
subQuery.andWhere(new typeorm_1.Brackets((sqb) => {
|
|
270
|
+
let orIdx = 0;
|
|
271
|
+
group.forEach((s) => {
|
|
272
|
+
if (s) {
|
|
273
|
+
if (orIdx === 0) {
|
|
274
|
+
sqb.where(`${alias}.${s.query}`, { [s.key]: s.value });
|
|
275
|
+
}
|
|
276
|
+
else {
|
|
277
|
+
sqb.orWhere(`${alias}.${s.query}`, { [s.key]: s.value });
|
|
278
|
+
}
|
|
279
|
+
orIdx++;
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
}));
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
return `${modelName}.${sub.column} IN ${subQuery.getQuery()}`;
|
|
286
|
+
});
|
|
287
|
+
});
|
|
288
|
+
}
|
|
245
289
|
return query;
|
|
246
290
|
}
|
|
247
291
|
generateRawCount(query) {
|
|
@@ -960,6 +960,12 @@ const insurance = [
|
|
|
960
960
|
"insuranceCode": "PMS-INS-0165",
|
|
961
961
|
"insuranceName": "PT Asuransi Etiqa Internasional",
|
|
962
962
|
"createdDate": "2023-08-23 11:44:41.619062"
|
|
963
|
+
},
|
|
964
|
+
{
|
|
965
|
+
"id": 272,
|
|
966
|
+
"insuranceCode": "PMS-INS-0167",
|
|
967
|
+
"insuranceName": "Hydor AS",
|
|
968
|
+
"createdDate": "2023-08-23 11:44:41.619062"
|
|
963
969
|
}
|
|
964
970
|
];
|
|
965
971
|
exports.default = insurance;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tax = {
|
|
4
|
+
BROKERAGE_VAT_DEFAULT_PERCENTAGE: 2.2,
|
|
5
|
+
BROKERAGE_VAT_DEFAULT_CALCULATE_TYPE: 'p',
|
|
6
|
+
BROKERAGE_PPH_DEFAULT_PERCENTAGE: 2,
|
|
7
|
+
BROKERAGE_PPH_DEFAULT_CALCULATE_TYPE: 'p',
|
|
8
|
+
};
|
|
9
|
+
exports.default = tax;
|
|
@@ -320,5 +320,12 @@
|
|
|
320
320
|
"en": "0,5% of claim minimum IDR 2,000,000 for each and every loss",
|
|
321
321
|
"id": "0,5% of claim minimum IDR 2,000,000 for each and every loss"
|
|
322
322
|
}
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
"code": "DEDUC-047",
|
|
326
|
+
"desc": {
|
|
327
|
+
"en": "0,5% of Claim Amount for each and every loss",
|
|
328
|
+
"id": "0,5% of Claim Amount for each and every loss"
|
|
329
|
+
}
|
|
323
330
|
}
|
|
324
331
|
]
|
|
@@ -117,8 +117,8 @@ const additionalCoverage = [
|
|
|
117
117
|
{
|
|
118
118
|
code: 'EQ',
|
|
119
119
|
desc: {
|
|
120
|
-
en: 'Earthquake, Volcanic Eruption,
|
|
121
|
-
id: 'Gempa Bumi, Letusan Gunung Berapi,
|
|
120
|
+
en: 'Earthquake, Volcanic Eruption, Tsunami',
|
|
121
|
+
id: 'Gempa Bumi, Letusan Gunung Berapi, Tsunami',
|
|
122
122
|
},
|
|
123
123
|
insuredPerils: {
|
|
124
124
|
true: {
|
|
@@ -9,6 +9,13 @@ declare const source: {
|
|
|
9
9
|
SOURCE_UPLOAD_BUNDLE: string;
|
|
10
10
|
SOURCE_UPLOAD: string;
|
|
11
11
|
SOURCE_POLISMALL_CARGO: string;
|
|
12
|
-
|
|
12
|
+
SOURCE_PPNP: string;
|
|
13
|
+
LIST: {
|
|
14
|
+
code: string;
|
|
15
|
+
desc: {
|
|
16
|
+
en: string;
|
|
17
|
+
id: string;
|
|
18
|
+
};
|
|
19
|
+
}[];
|
|
13
20
|
};
|
|
14
21
|
export default source;
|
package/dist/constants/source.js
CHANGED
|
@@ -12,6 +12,7 @@ const source = {
|
|
|
12
12
|
SOURCE_UPLOAD_BUNDLE: 'UPLOAD-BUNDLE',
|
|
13
13
|
SOURCE_UPLOAD: 'UPLOAD',
|
|
14
14
|
SOURCE_POLISMALL_CARGO: 'polismall-cargo',
|
|
15
|
+
SOURCE_PPNP: 'PPNP',
|
|
15
16
|
LIST: [],
|
|
16
17
|
};
|
|
17
18
|
source.LIST.push({
|
|
@@ -44,5 +45,8 @@ source.LIST.push({
|
|
|
44
45
|
}, {
|
|
45
46
|
code: source.SOURCE_POLISMALL_CARGO,
|
|
46
47
|
desc: { en: 'Polismall Cargo', id: 'Polismall Cargo' }
|
|
48
|
+
}, {
|
|
49
|
+
code: source.SOURCE_PPNP,
|
|
50
|
+
desc: { en: 'PPNP', id: 'PPNP' }
|
|
47
51
|
});
|
|
48
52
|
exports.default = source;
|
package/dist/constants/user.d.ts
CHANGED
|
@@ -15,5 +15,21 @@ declare const user: {
|
|
|
15
15
|
};
|
|
16
16
|
};
|
|
17
17
|
};
|
|
18
|
+
USER_STATUS: {
|
|
19
|
+
ACTIVE: {
|
|
20
|
+
value: boolean;
|
|
21
|
+
desc: {
|
|
22
|
+
en: string;
|
|
23
|
+
id: string;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
NON_ACTIVE: {
|
|
27
|
+
value: boolean;
|
|
28
|
+
desc: {
|
|
29
|
+
en: string;
|
|
30
|
+
id: string;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
};
|
|
18
34
|
};
|
|
19
35
|
export default user;
|
package/dist/constants/user.js
CHANGED
|
@@ -17,5 +17,21 @@ const user = {
|
|
|
17
17
|
},
|
|
18
18
|
},
|
|
19
19
|
},
|
|
20
|
+
USER_STATUS: {
|
|
21
|
+
ACTIVE: {
|
|
22
|
+
value: true,
|
|
23
|
+
desc: {
|
|
24
|
+
en: 'Active',
|
|
25
|
+
id: 'Aktif',
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
NON_ACTIVE: {
|
|
29
|
+
value: false,
|
|
30
|
+
desc: {
|
|
31
|
+
en: 'Non-Active',
|
|
32
|
+
id: 'Non-Aktif',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
20
36
|
};
|
|
21
37
|
exports.default = user;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ISO_DATE_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
|
|
4
|
+
const EXCEL_EPOCH_MS = Date.UTC(1899, 11, 30);
|
|
5
|
+
const MS_PER_DAY = 86400000;
|
|
6
|
+
exports.default = (value) => {
|
|
7
|
+
if (value === null || value === undefined || value === '') {
|
|
8
|
+
return new Date(NaN);
|
|
9
|
+
}
|
|
10
|
+
if (typeof value === 'string' && ISO_DATE_PATTERN.test(value)) {
|
|
11
|
+
return new Date(`${value}T00:00:00Z`);
|
|
12
|
+
}
|
|
13
|
+
const serial = Number(value);
|
|
14
|
+
if (!Number.isFinite(serial)) {
|
|
15
|
+
return new Date(NaN);
|
|
16
|
+
}
|
|
17
|
+
return new Date(EXCEL_EPOCH_MS + Math.round(serial * MS_PER_DAY));
|
|
18
|
+
};
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import IMultiJoin from "./multi.join.interface";
|
|
2
2
|
import ISearchQuery from "./search.query.interface";
|
|
3
|
+
import ISubqueryIn from "./subquery.in.interface";
|
|
3
4
|
export default interface IFindAllCount {
|
|
4
5
|
search: ISearchQuery[];
|
|
5
6
|
additionalSearchOr?: ISearchQuery[][];
|
|
6
7
|
sortBy?: string;
|
|
7
8
|
relations?: IMultiJoin[];
|
|
9
|
+
subqueryIns?: ISubqueryIn[];
|
|
8
10
|
maxCount?: number;
|
|
9
11
|
offset?: number;
|
|
10
12
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import IMultiJoin from "./multi.join.interface";
|
|
2
2
|
import ISearchQuery from "./search.query.interface";
|
|
3
|
+
import ISubqueryIn from "./subquery.in.interface";
|
|
3
4
|
export default interface ISearchConditions {
|
|
4
5
|
query: any;
|
|
5
6
|
search?: ISearchQuery[];
|
|
6
7
|
additionalSearchOr?: ISearchQuery[][];
|
|
7
8
|
relations?: IMultiJoin[];
|
|
9
|
+
subqueryIns?: ISubqueryIn[];
|
|
8
10
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import IMultiJoin from "./multi.join.interface";
|
|
2
2
|
import ISearchQuery from "./search.query.interface";
|
|
3
|
+
import ISubqueryIn from "./subquery.in.interface";
|
|
3
4
|
import ISummaryField from "./summary.field.interface";
|
|
4
5
|
export default interface ISearchSummary {
|
|
5
6
|
fieldToSum: ISummaryField[];
|
|
6
7
|
search: ISearchQuery[];
|
|
7
8
|
additionalSearchOr?: ISearchQuery[][];
|
|
8
9
|
relations?: IMultiJoin[];
|
|
10
|
+
subqueryIns?: ISubqueryIn[];
|
|
9
11
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import ISearchQuery from "./search.query.interface";
|
|
2
|
+
export default interface ISubqueryIn {
|
|
3
|
+
column: string;
|
|
4
|
+
subqueryTable: string;
|
|
5
|
+
subqueryAlias?: string;
|
|
6
|
+
subquerySelectColumn: string;
|
|
7
|
+
searchs?: ISearchQuery[];
|
|
8
|
+
additionalSearchOr?: ISearchQuery[][];
|
|
9
|
+
}
|