test-entity-library-asm 2.8.16 → 2.8.17
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/CustomRepository.d.ts +5 -5
- package/dist/CustomRepository.js +357 -318
- package/dist/entities/MasterNotification.js +1 -1
- package/dist/filters/LocalsCompanyInformation.d.ts +6 -0
- package/dist/filters/LocalsCompanyInformation.js +227 -0
- package/dist/views/VerifyLocals.d.ts +1 -0
- package/dist/views/VerifyLocals.js +4 -0
- package/package.json +1 -1
- package/src/CustomRepository.ts +521 -511
- package/src/entities/MasterNotification.ts +1 -1
- package/src/filters/LocalsCompanyInformation.ts +229 -0
- package/src/views/VerifyLocals.ts +3 -0
|
@@ -62,7 +62,7 @@ export class MasterNotification {
|
|
|
62
62
|
@Column({
|
|
63
63
|
default: 1,
|
|
64
64
|
comment:
|
|
65
|
-
"Estado
|
|
65
|
+
"Estado de la notificación: \r\n0. Inactiva. \r\n1. Activa.\r\n2. Reasignada.",
|
|
66
66
|
})
|
|
67
67
|
status: number;
|
|
68
68
|
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import { Repository } from "typeorm";
|
|
2
|
+
import { getTimeZone, getTimezoneOffset } from "..";
|
|
3
|
+
import { IBasicCompany } from "../interfaces";
|
|
4
|
+
import { getSeverityNameDiscountType, getStatusBasic } from "../utils";
|
|
5
|
+
|
|
6
|
+
export async function getLocalsCompanyInformation(
|
|
7
|
+
repository: Repository<any>,
|
|
8
|
+
{ company, status, visible, lazyEvent }: IBasicCompany
|
|
9
|
+
) {
|
|
10
|
+
try {
|
|
11
|
+
const timezone = getTimezoneOffset(getTimeZone());
|
|
12
|
+
|
|
13
|
+
const queryBuilder = repository
|
|
14
|
+
.createQueryBuilder("view_locals_companies")
|
|
15
|
+
.skip(lazyEvent.first)
|
|
16
|
+
.take(lazyEvent.rows);
|
|
17
|
+
|
|
18
|
+
// DOC: Filtro global
|
|
19
|
+
if (lazyEvent.filters["global"] && lazyEvent.filters["global"].value) {
|
|
20
|
+
const globalValue = `%${lazyEvent.filters[
|
|
21
|
+
"global"
|
|
22
|
+
].value.toLowerCase()}%`;
|
|
23
|
+
queryBuilder.andWhere(
|
|
24
|
+
"(LOWER(view_locals_companies.name_local) LIKE :globalValue OR LOWER(view_locals_companies.country_name) LIKE :globalValue OR LOWER(view_locals_companies.city_name) LIKE :globalValue OR LOWER(view_locals_companies.address) LIKE :globalValue OR LOWER(view_locals_companies.cellphone) LIKE :globalValue OR LOWER(view_locals_companies.email) LIKE :globalValue OR LOWER(view_locals_companies.pos_system_name) LIKE :globalValue OR LOWER(view_locals_companies.created_local) LIKE :globalValue OR LOWER(view_locals_companies.updated_local) LIKE :globalValue)",
|
|
25
|
+
{
|
|
26
|
+
globalValue:
|
|
27
|
+
globalValue ||
|
|
28
|
+
getStatusBasic(lazyEvent.filters["global"].value.toLowerCase()),
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// DOC: Filtro por estado FILTRO POR DEFECTO
|
|
34
|
+
if (status !== null && status >= 0) {
|
|
35
|
+
queryBuilder.andWhere("view_locals_companies.status = :status", {
|
|
36
|
+
status: status,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// DOC: Filtro por company FILTRO POR DEFECTO
|
|
41
|
+
if (company !== null && company >= 0) {
|
|
42
|
+
queryBuilder.andWhere("view_locals_companies.company = :company", {
|
|
43
|
+
company: company,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (visible !== null) {
|
|
48
|
+
queryBuilder.andWhere("view_locals_companies.visible = :visible", {
|
|
49
|
+
visible: visible,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const filters = lazyEvent.filters;
|
|
54
|
+
Object.keys(filters).forEach((key) => {
|
|
55
|
+
let value = filters[key].value;
|
|
56
|
+
if (
|
|
57
|
+
(Array.isArray(value) && value.length > 0) ||
|
|
58
|
+
(!Array.isArray(value) && value && key !== "global")
|
|
59
|
+
) {
|
|
60
|
+
const matchMode = filters[key].matchMode;
|
|
61
|
+
if (!Array.isArray(value) && value) {
|
|
62
|
+
value = filters[key].value.toLowerCase();
|
|
63
|
+
}
|
|
64
|
+
const accessKey =
|
|
65
|
+
key.split(".").length > 1 ? `${key}` : `view_locals_companies.${key}`;
|
|
66
|
+
|
|
67
|
+
switch (matchMode) {
|
|
68
|
+
case "custom":
|
|
69
|
+
if (key === "total_partners" && matchMode === "custom") {
|
|
70
|
+
const [from, to] = value || [null, null];
|
|
71
|
+
|
|
72
|
+
if (from !== null && to === null) {
|
|
73
|
+
queryBuilder.andWhere(`view_locals_companies.${key} >= :from`, {
|
|
74
|
+
from,
|
|
75
|
+
});
|
|
76
|
+
} else if (from === null && to !== null) {
|
|
77
|
+
queryBuilder.andWhere(`view_locals_companies.${key} <= :to`, {
|
|
78
|
+
to,
|
|
79
|
+
});
|
|
80
|
+
} else if (from !== null && to !== null) {
|
|
81
|
+
queryBuilder.andWhere(
|
|
82
|
+
`view_locals_companies.${key} BETWEEN :from AND :to`,
|
|
83
|
+
{ from, to }
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
break;
|
|
88
|
+
case "contains":
|
|
89
|
+
queryBuilder.andWhere(`${accessKey} LIKE :${key}`, {
|
|
90
|
+
[key]: `%${value}%`,
|
|
91
|
+
});
|
|
92
|
+
break;
|
|
93
|
+
case "startsWith":
|
|
94
|
+
queryBuilder.andWhere(`${accessKey} LIKE :${key}`, {
|
|
95
|
+
[key]: `${value}%`,
|
|
96
|
+
});
|
|
97
|
+
break;
|
|
98
|
+
case "endsWith":
|
|
99
|
+
queryBuilder.andWhere(`${accessKey} LIKE :${key}`, {
|
|
100
|
+
[key]: `${value}%`,
|
|
101
|
+
});
|
|
102
|
+
break;
|
|
103
|
+
case "equals":
|
|
104
|
+
if (key === "status") {
|
|
105
|
+
queryBuilder.andWhere("view_locals_companies.status = :status", {
|
|
106
|
+
status: getStatusBasic(filters[key].value ?? ""),
|
|
107
|
+
});
|
|
108
|
+
} else if (key === "typeText") {
|
|
109
|
+
queryBuilder.andWhere("view_locals_companies.type = :type", {
|
|
110
|
+
type: getSeverityNameDiscountType(filters[key].value ?? ""),
|
|
111
|
+
});
|
|
112
|
+
} else if (key === "has_square") {
|
|
113
|
+
const hasSI = filters[key].value.includes("SI");
|
|
114
|
+
const hasNO = filters[key].value.includes("NO");
|
|
115
|
+
|
|
116
|
+
const queryPlazolet =
|
|
117
|
+
hasSI && hasNO
|
|
118
|
+
? ""
|
|
119
|
+
: hasSI
|
|
120
|
+
? "view_locals_companies.has_square IS NOT NULL"
|
|
121
|
+
: hasNO
|
|
122
|
+
? "view_locals_companies.has_square IS NULL"
|
|
123
|
+
: "";
|
|
124
|
+
if (queryPlazolet !== "") {
|
|
125
|
+
queryBuilder.andWhere(queryPlazolet);
|
|
126
|
+
}
|
|
127
|
+
} else {
|
|
128
|
+
queryBuilder.andWhere(`${accessKey} = :${key}`, {
|
|
129
|
+
[key]: value,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
break;
|
|
133
|
+
case "notContains":
|
|
134
|
+
queryBuilder.andWhere(`${accessKey} NOT LIKE :${key}`, {
|
|
135
|
+
[key]: `%${value}%`,
|
|
136
|
+
});
|
|
137
|
+
break;
|
|
138
|
+
case "notEquals":
|
|
139
|
+
queryBuilder.andWhere(`${accessKey} != :${key}`, {
|
|
140
|
+
[key]: value,
|
|
141
|
+
});
|
|
142
|
+
break;
|
|
143
|
+
case "dateIs":
|
|
144
|
+
queryBuilder.andWhere(
|
|
145
|
+
`${
|
|
146
|
+
key !== "expiration" && key !== "start"
|
|
147
|
+
? "DATE(CONVERT_TZ("
|
|
148
|
+
: ""
|
|
149
|
+
} ${accessKey} ${
|
|
150
|
+
key !== "expiration" && key !== "start"
|
|
151
|
+
? `, '+00:00', '${timezone}'))`
|
|
152
|
+
: ""
|
|
153
|
+
} = :${key}`,
|
|
154
|
+
{
|
|
155
|
+
[key]: value.split("T")[0],
|
|
156
|
+
}
|
|
157
|
+
);
|
|
158
|
+
break;
|
|
159
|
+
case "dateIsNot":
|
|
160
|
+
queryBuilder.andWhere(
|
|
161
|
+
`${
|
|
162
|
+
key !== "expiration" && key !== "start"
|
|
163
|
+
? "DATE(CONVERT_TZ("
|
|
164
|
+
: ""
|
|
165
|
+
} ${accessKey} ${
|
|
166
|
+
key !== "expiration" && key !== "start"
|
|
167
|
+
? `, '+00:00', '${timezone}'))`
|
|
168
|
+
: ""
|
|
169
|
+
} != :${key}`,
|
|
170
|
+
{
|
|
171
|
+
[key]: value.split("T")[0],
|
|
172
|
+
}
|
|
173
|
+
);
|
|
174
|
+
break;
|
|
175
|
+
case "dateBefore":
|
|
176
|
+
queryBuilder.andWhere(
|
|
177
|
+
`${
|
|
178
|
+
key !== "expiration" && key !== "start"
|
|
179
|
+
? "DATE(CONVERT_TZ("
|
|
180
|
+
: ""
|
|
181
|
+
} ${accessKey} ${
|
|
182
|
+
key !== "expiration" && key !== "start"
|
|
183
|
+
? `, '+00:00', '${timezone}'))`
|
|
184
|
+
: ""
|
|
185
|
+
} < :${key}`,
|
|
186
|
+
{
|
|
187
|
+
[key]: value.split("T")[0],
|
|
188
|
+
}
|
|
189
|
+
);
|
|
190
|
+
break;
|
|
191
|
+
case "dateAfter":
|
|
192
|
+
queryBuilder.andWhere(
|
|
193
|
+
`${
|
|
194
|
+
key !== "expiration" && key !== "start"
|
|
195
|
+
? "DATE(CONVERT_TZ("
|
|
196
|
+
: ""
|
|
197
|
+
} ${accessKey} ${
|
|
198
|
+
key !== "expiration" && key !== "start"
|
|
199
|
+
? `, '+00:00', '${timezone}'))`
|
|
200
|
+
: ""
|
|
201
|
+
} > :${key}`,
|
|
202
|
+
{
|
|
203
|
+
[key]: value.split("T")[0],
|
|
204
|
+
}
|
|
205
|
+
);
|
|
206
|
+
break;
|
|
207
|
+
default:
|
|
208
|
+
break;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
if (lazyEvent.sortField) {
|
|
214
|
+
const order = lazyEvent.sortOrder === 1 ? "ASC" : "DESC";
|
|
215
|
+
queryBuilder.orderBy(
|
|
216
|
+
`view_locals_companies.${lazyEvent.sortField}`,
|
|
217
|
+
order
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
const [locals, totalRecords] = await queryBuilder.getManyAndCount();
|
|
222
|
+
return {
|
|
223
|
+
data: locals,
|
|
224
|
+
totalRecords,
|
|
225
|
+
};
|
|
226
|
+
} catch (error) {
|
|
227
|
+
return false;
|
|
228
|
+
}
|
|
229
|
+
}
|