test-entity-library-asm 3.9.0 → 3.9.2

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.
@@ -81,6 +81,7 @@ export { PartnerNotifications } from "./views/PartnerNotifications";
81
81
  export { LocalTableZonesFilter } from "./views/LocalTableZonesFilter";
82
82
  export { LocalReserves } from "./views/LocalReserves";
83
83
  export { LocalsCompanyInformationForTheMap } from "./views/LocalsCompanyInformationForTheMap";
84
+ export { LocalsCompanyInformationForTheTable } from "./views/LocalsCompanyInformationForTheTable";
84
85
  export { getDiscountsCodeCompanyInformation } from "./filters/DiscountsCodeCompanyInformation";
85
86
  export { getDiscountsCodeUserInformation } from "./filters/DiscountsCodeUserInformation";
86
87
  export { getLocalsCompanyInformation } from "./filters/LocalsCompanyInformation";
@@ -15,7 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.ToppingImage = exports.ProductDate = exports.ProductSchedule = exports.CategoryDate = exports.Bank = exports.ServicePlan = exports.PartnerPlatform = exports.PartnerPlatformSection = exports.LocalPlan = exports.MasterNotification = exports.VerifyLocal = exports.PosSystem = exports.AuthenticationCredential = exports.BusinessType = exports.UserAddress = exports.User = exports.TypeMeasureIngredient = exports.Square = exports.RequestProductGroupComplement = exports.RequestProduct = exports.Request = exports.Region = exports.ProductTopping = exports.ProductIngredient = exports.ProductGroupComplement = exports.ProductGroup = exports.Product = exports.Plan = exports.PaymentMethod = exports.PartnerRole = exports.PartnerPlatformSectionPermission = exports.PartnerNotification = exports.Partner = exports.MasterRole = exports.MasterPermission = exports.Master = exports.LocalQualification = exports.Local = exports.DiscountCodeUser = exports.DiscountCodeCompany = exports.Day = exports.Country = exports.Configuration = exports.Company = exports.CodeRedemptionHistoryUser = exports.CodeRedemptionHistoryCompany = exports.City = exports.ScheduleCategory = exports.Category = exports.BusinessTypeProduct = void 0;
18
- exports.CustomRepository = exports.getLocalReservesInformation = exports.getVerifyLocalsInformation = exports.getLocalsCompanyInformation = exports.getDiscountsCodeUserInformation = exports.getDiscountsCodeCompanyInformation = exports.LocalsCompanyInformationForTheMap = exports.LocalReserves = exports.LocalTableZonesFilter = exports.PartnerNotifications = exports.DiscountsCodeUser = exports.Partners = exports.ViewLocalsCompanies = exports.MasterNotifications = exports.VerifyLocals = exports.LocalsCompany = exports.PartnerPlatformSectionPermissionAssociate = exports.VerificationCode = exports.LocalPaymentMethod = exports.ProductImage = exports.Gallery = exports.RequestLocalTable = exports.RequestInvoiceCategory = exports.RequestInvoice = exports.LocalTableReserve = exports.LocalReserveStatus = exports.LocalReserve = exports.LocalTableReservePayment = exports.DecorationReserve = exports.LocalDecorationReserve = exports.LocalTable = exports.LocalTableZone = exports.RequestPrint = exports.ReceiptConfig = exports.RequestLocalPayment = exports.UserPaymentMethod = exports.RequestLocalHistory = exports.RequestLocal = exports.PartnerSession = void 0;
18
+ exports.CustomRepository = exports.getLocalReservesInformation = exports.getVerifyLocalsInformation = exports.getLocalsCompanyInformation = exports.getDiscountsCodeUserInformation = exports.getDiscountsCodeCompanyInformation = exports.LocalsCompanyInformationForTheTable = exports.LocalsCompanyInformationForTheMap = exports.LocalReserves = exports.LocalTableZonesFilter = exports.PartnerNotifications = exports.DiscountsCodeUser = exports.Partners = exports.ViewLocalsCompanies = exports.MasterNotifications = exports.VerifyLocals = exports.LocalsCompany = exports.PartnerPlatformSectionPermissionAssociate = exports.VerificationCode = exports.LocalPaymentMethod = exports.ProductImage = exports.Gallery = exports.RequestLocalTable = exports.RequestInvoiceCategory = exports.RequestInvoice = exports.LocalTableReserve = exports.LocalReserveStatus = exports.LocalReserve = exports.LocalTableReservePayment = exports.DecorationReserve = exports.LocalDecorationReserve = exports.LocalTable = exports.LocalTableZone = exports.RequestPrint = exports.ReceiptConfig = exports.RequestLocalPayment = exports.UserPaymentMethod = exports.RequestLocalHistory = exports.RequestLocal = exports.PartnerSession = void 0;
19
19
  var BusinessTypeProduct_1 = require("./entities/BusinessTypeProduct");
20
20
  Object.defineProperty(exports, "BusinessTypeProduct", { enumerable: true, get: function () { return BusinessTypeProduct_1.BusinessTypeProduct; } });
21
21
  var Category_1 = require("./entities/Category");
@@ -182,6 +182,8 @@ var LocalReserves_1 = require("./views/LocalReserves");
182
182
  Object.defineProperty(exports, "LocalReserves", { enumerable: true, get: function () { return LocalReserves_1.LocalReserves; } });
183
183
  var LocalsCompanyInformationForTheMap_1 = require("./views/LocalsCompanyInformationForTheMap");
184
184
  Object.defineProperty(exports, "LocalsCompanyInformationForTheMap", { enumerable: true, get: function () { return LocalsCompanyInformationForTheMap_1.LocalsCompanyInformationForTheMap; } });
185
+ var LocalsCompanyInformationForTheTable_1 = require("./views/LocalsCompanyInformationForTheTable");
186
+ Object.defineProperty(exports, "LocalsCompanyInformationForTheTable", { enumerable: true, get: function () { return LocalsCompanyInformationForTheTable_1.LocalsCompanyInformationForTheTable; } });
185
187
  var DiscountsCodeCompanyInformation_1 = require("./filters/DiscountsCodeCompanyInformation");
186
188
  Object.defineProperty(exports, "getDiscountsCodeCompanyInformation", { enumerable: true, get: function () { return DiscountsCodeCompanyInformation_1.getDiscountsCodeCompanyInformation; } });
187
189
  var DiscountsCodeUserInformation_1 = require("./filters/DiscountsCodeUserInformation");
@@ -0,0 +1,6 @@
1
+ import { Repository } from "typeorm";
2
+ import { IBasicCompany } from "../interfaces";
3
+ export declare function getLocalsCompanyInformation(repository: Repository<any>, { company, status, visible, lazyEvent }: IBasicCompany): Promise<{
4
+ data: any[];
5
+ totalRecords: number;
6
+ }>;
@@ -0,0 +1,214 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.getLocalsCompanyInformation = void 0;
40
+ var __1 = require("..");
41
+ function getLocalsCompanyInformation(repository_1, _a) {
42
+ return __awaiter(this, arguments, void 0, function (repository, _b) {
43
+ var timezone_1, queryBuilder_1, globalValue, filters_1, sortOrder, _c, data, totalRecords, error_1;
44
+ var company = _b.company, status = _b.status, visible = _b.visible, lazyEvent = _b.lazyEvent;
45
+ return __generator(this, function (_d) {
46
+ switch (_d.label) {
47
+ case 0:
48
+ _d.trys.push([0, 2, , 3]);
49
+ timezone_1 = (0, __1.getTimezoneOffset)((0, __1.getTimeZone)());
50
+ queryBuilder_1 = repository
51
+ .createQueryBuilder("locals_company_information_for_the_table")
52
+ .skip(lazyEvent.first)
53
+ .take(lazyEvent.rows);
54
+ // DOC: Filtro global
55
+ if (lazyEvent.filters["global"] && lazyEvent.filters["global"].value) {
56
+ globalValue = "%".concat(lazyEvent.filters["global"].value.toLowerCase(), "%");
57
+ queryBuilder_1.andWhere("(LOWER(locals_company_information_for_the_table.name) LIKE :globalValue OR LOWER(locals_company_information_for_the_table.address) LIKE :globalValue OR LOWER(locals_company_information_for_the_table.partner_name) LIKE :globalValue OR LOWER(locals_company_information_for_the_table.partner_surname) LIKE :globalValue OR LOWER(locals_company_information_for_the_table.partner_full_name) LIKE :globalValue OR locals_company_information_for_the_table.partner_full_name LIKE :globalValue", { globalValue: globalValue });
58
+ }
59
+ // DOC: Filtro por estado FILTRO POR DEFECTO.
60
+ if (status !== null && status >= 0) {
61
+ queryBuilder_1.andWhere("locals_company_information_for_the_table.status = :status", {
62
+ status: status,
63
+ });
64
+ }
65
+ // DOC: Filtro por company FILTRO POR DEFECTO.
66
+ if (company !== null && company >= 0) {
67
+ queryBuilder_1.andWhere("locals_company_information_for_the_table.company = :company", {
68
+ company: company,
69
+ });
70
+ }
71
+ // DOC: Filtro por visible FILTRO POR DEFECTO.
72
+ if (visible !== null) {
73
+ queryBuilder_1.andWhere("locals_company_information_for_the_table.visible = :visible", {
74
+ visible: visible,
75
+ });
76
+ }
77
+ filters_1 = lazyEvent.filters;
78
+ Object.keys(filters_1).forEach(function (key) {
79
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
80
+ var value = filters_1[key].value; // DOC: Obtenemos el valor del filtro.
81
+ if ((Array.isArray(value) && value.length > 0) ||
82
+ (!Array.isArray(value) && value && key !== "global")) {
83
+ // DOC: Verificamos si el filtro tiene valor, si no es un filtro global y no es un array vacío.
84
+ var matchMode = filters_1[key].matchMode; // DOC: Obtenemos el modo de coincidencia del filtro.
85
+ if (!Array.isArray(value) && value) {
86
+ // DOC: Si el valor no es un array y tiene valor, lo convertimos a minúsculas.
87
+ value = filters_1[key].value.toLowerCase();
88
+ }
89
+ var accessKey = key.split(".").length > 1
90
+ ? "".concat(key)
91
+ : "locals_company_information_for_the_table.".concat(key); // DOC: Verificamos si el filtro es un campo anidado o no.
92
+ switch (matchMode // DOC: Verificamos el modo de coincidencia del filtro.
93
+ ) {
94
+ case "contains": // DOC: Si el modo de coincidencia es "contains".
95
+ queryBuilder_1.andWhere("LOWER(".concat(accessKey, ") LIKE :").concat(key), (_a = {},
96
+ _a[key] = "%".concat(value, "%"),
97
+ _a));
98
+ break;
99
+ case "equals": // DOC: Si el modo de coincidencia es "equals".
100
+ queryBuilder_1.andWhere("".concat(accessKey, " = :").concat(key), (_b = {}, _b[key] = value, _b));
101
+ break;
102
+ case "notEquals": // DOC: Si el modo de coincidencia es "notEquals".
103
+ queryBuilder_1.andWhere("".concat(accessKey, " != :").concat(key), (_c = {}, _c[key] = value, _c));
104
+ break;
105
+ case "startsWith": // DOC: Si el modo de coincidencia es "startsWith".
106
+ queryBuilder_1.andWhere("LOWER(".concat(accessKey, ") LIKE :").concat(key), (_d = {},
107
+ _d[key] = "".concat(value, "%"),
108
+ _d));
109
+ break;
110
+ case "endsWith": // DOC: Si el modo de coincidencia es "endsWith".
111
+ queryBuilder_1.andWhere("LOWER(".concat(accessKey, ") LIKE :").concat(key), (_e = {},
112
+ _e[key] = "%".concat(value),
113
+ _e));
114
+ break;
115
+ case "in": // DOC: Si el modo de coincidencia es "in".
116
+ if (Array.isArray(value)) {
117
+ queryBuilder_1.andWhere("".concat(accessKey, " IN (:...").concat(key, ")"), (_f = {},
118
+ _f[key] = value,
119
+ _f));
120
+ }
121
+ break;
122
+ case "notIn": // DOC: Si el modo de coincidencia es "notIn
123
+ if (Array.isArray(value)) {
124
+ queryBuilder_1.andWhere("".concat(accessKey, " NOT IN (:...").concat(key, ")"), (_g = {},
125
+ _g[key] = value,
126
+ _g));
127
+ }
128
+ break;
129
+ case "lt": // DOC: Si el modo de coincidencia es "lt" (less than).
130
+ queryBuilder_1.andWhere("".concat(accessKey, " < :").concat(key), (_h = {}, _h[key] = value, _h));
131
+ break;
132
+ case "lte": // DOC: Si el modo de coincidencia es "lte" (less than or equal).
133
+ queryBuilder_1.andWhere("".concat(accessKey, " <= :").concat(key), (_j = {}, _j[key] = value, _j));
134
+ break;
135
+ case "gt": // DOC: Si el modo de coincidencia es "gt" (greater than).
136
+ queryBuilder_1.andWhere("".concat(accessKey, " > :").concat(key), (_k = {}, _k[key] = value, _k));
137
+ break;
138
+ case "gte": // DOC: Si el modo de coincidencia es "gte" (greater than or equal).
139
+ queryBuilder_1.andWhere("".concat(accessKey, " >= :").concat(key), (_l = {}, _l[key] = value, _l));
140
+ break;
141
+ case "between": // DOC: Si el modo de coincidencia es "between".
142
+ if (Array.isArray(value) && value.length === 2) {
143
+ var from = value[0], to = value[1];
144
+ queryBuilder_1.andWhere("".concat(accessKey, " BETWEEN :from AND :to"), {
145
+ from: from,
146
+ to: to,
147
+ });
148
+ }
149
+ break;
150
+ case "dateIs": // DOC: Si el modo de coincidencia es "dateIs". Hay que tener en cuenta la zona horaria (timezone)
151
+ queryBuilder_1.andWhere("".concat(key !== "expiration" && key !== "start"
152
+ ? "DATE(CONVERT_TZ("
153
+ : "", " ").concat(accessKey, " ").concat(key !== "expiration" && key !== "start"
154
+ ? ", '+00:00', '".concat(timezone_1, "'))")
155
+ : "", " != :").concat(key), (_m = {},
156
+ _m[key] = value.split("T")[0],
157
+ _m));
158
+ break;
159
+ case "dateIsNot": // DOC: Si el modo de coincidencia es "dateIsNot". Hay que tener en cuenta la zona horaria (timezone)
160
+ queryBuilder_1.andWhere("".concat(key !== "expiration" && key !== "start"
161
+ ? "DATE(CONVERT_TZ("
162
+ : "", " ").concat(accessKey, " ").concat(key !== "expiration" && key !== "start"
163
+ ? ", '+00:00', '".concat(timezone_1, "'))")
164
+ : "", " = :").concat(key), (_o = {},
165
+ _o[key] = value.split("T")[0],
166
+ _o));
167
+ break;
168
+ case "dateBefore": // DOC: Si el modo de coincidencia es "dateBefore". Hay que tener en cuenta la zona horaria (timezone)
169
+ queryBuilder_1.andWhere("".concat(key !== "expiration" && key !== "start"
170
+ ? "DATE(CONVERT_TZ("
171
+ : "", " ").concat(accessKey, " ").concat(key !== "expiration" && key !== "start"
172
+ ? ", '+00:00', '".concat(timezone_1, "'))")
173
+ : "", " < :").concat(key), (_p = {},
174
+ _p[key] = value.split("T")[0],
175
+ _p));
176
+ break;
177
+ case "dateAfter": // DOC: Si el modo de coincidencia es "dateAfter". Hay que tener en cuenta la zona horaria (timezone)
178
+ queryBuilder_1.andWhere("".concat(key !== "expiration" && key !== "start"
179
+ ? "DATE(CONVERT_TZ("
180
+ : "", " ").concat(accessKey, " ").concat(key !== "expiration" && key !== "start"
181
+ ? ", '+00:00', '".concat(timezone_1, "'))")
182
+ : "", " > :").concat(key), (_q = {},
183
+ _q[key] = value.split("T")[0],
184
+ _q));
185
+ break;
186
+ default: // DOC: Si el modo de coincidencia no es ninguno de los anteriores.
187
+ break;
188
+ }
189
+ }
190
+ });
191
+ // DOC: Ordenamiento de los resultados.
192
+ if (lazyEvent.sortField) {
193
+ sortOrder = lazyEvent.sortOrder === 1 ? "ASC" : "DESC";
194
+ queryBuilder_1.addOrderBy("locals_company_information_for_the_table.".concat(lazyEvent.sortField), sortOrder);
195
+ }
196
+ return [4 /*yield*/, queryBuilder_1.getManyAndCount()];
197
+ case 1:
198
+ _c = _d.sent(), data = _c[0], totalRecords = _c[1];
199
+ return [2 /*return*/, {
200
+ data: data,
201
+ totalRecords: totalRecords,
202
+ }];
203
+ case 2:
204
+ error_1 = _d.sent();
205
+ return [2 /*return*/, {
206
+ data: [],
207
+ totalRecords: 0,
208
+ }];
209
+ case 3: return [2 /*return*/];
210
+ }
211
+ });
212
+ });
213
+ }
214
+ exports.getLocalsCompanyInformation = getLocalsCompanyInformation;
@@ -0,0 +1,91 @@
1
+ export declare class LocalsCompanyInformationForTheTable {
2
+ id: number;
3
+ company: number;
4
+ name: string;
5
+ city: number;
6
+ address: string;
7
+ latitude: number;
8
+ longitude: number;
9
+ details: any | null;
10
+ created: string;
11
+ updated: string;
12
+ updated_by: number;
13
+ square: number | null;
14
+ pos_system: number;
15
+ pos_system_settings: any | null;
16
+ status: number;
17
+ visible: number;
18
+ contact_details: any | null;
19
+ type_local: string;
20
+ company_id: number;
21
+ company_code: string;
22
+ company_name: string;
23
+ company_expiration: string | null;
24
+ company_partner: number;
25
+ company_contact_details: any | null;
26
+ company_profile: any | null;
27
+ company_legal_agent: string;
28
+ company_legal_information: any | null;
29
+ company_settings: any | null;
30
+ city_id: number;
31
+ city_name: string;
32
+ city_region: number;
33
+ city_status: number;
34
+ region_id: number;
35
+ region_name: string;
36
+ region_country: number;
37
+ region_status: number;
38
+ country_id: number;
39
+ country_code: string;
40
+ country_currency: string;
41
+ country_details: any | null;
42
+ country_legal_agent: string | null;
43
+ country_legal_information: any | null;
44
+ country_prefix: string;
45
+ country_status: number;
46
+ country_structure_phone: string;
47
+ partner_id: number;
48
+ partner_code: string;
49
+ partner_document: string | null;
50
+ partner_name: string;
51
+ partner_surname: string;
52
+ partner_full_name: string;
53
+ partner_phone: string | null;
54
+ partner_owner: number;
55
+ partner_email: string;
56
+ partner_city: string | null;
57
+ partner_address: string | null;
58
+ partner_profile: any | null;
59
+ partner_status: number;
60
+ partner_visible: number;
61
+ partner_created: string;
62
+ partner_updated: string;
63
+ square_id: number;
64
+ square_details: any | null;
65
+ square_email: string | null;
66
+ square_latitude: number | null;
67
+ square_longitude: number | null;
68
+ square_maximum_number_locals: number;
69
+ square_name: string;
70
+ square_phone: string | null;
71
+ square_status: number;
72
+ local_plan_id: number;
73
+ local_plan_type: string;
74
+ local_plan_price: number;
75
+ local_plan_start_date: string;
76
+ local_plan_end_date: string;
77
+ local_plan_settings: any | null;
78
+ local_plan_status: number;
79
+ plan_code: string;
80
+ plan_company: number;
81
+ plan_created: string;
82
+ plan_name: string;
83
+ plan_id: number;
84
+ plan_description: any | null;
85
+ plan_quantity_locals: number;
86
+ plan_expiration: string;
87
+ plan_status: number;
88
+ total_requests: number;
89
+ total_ratings: number;
90
+ average_rating: number;
91
+ }
@@ -0,0 +1,402 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.LocalsCompanyInformationForTheTable = void 0;
13
+ var typeorm_1 = require("typeorm");
14
+ var moment = require("moment-timezone");
15
+ var __1 = require("..");
16
+ var jsonTransformer = {
17
+ to: function (value) { return JSON.stringify(value); },
18
+ from: function (value) {
19
+ try {
20
+ return JSON.parse(value);
21
+ }
22
+ catch (error) {
23
+ console.log(error, "Transformer error");
24
+ return null;
25
+ }
26
+ },
27
+ };
28
+ var DateTransformer = {
29
+ to: function (value) {
30
+ return moment.utc(value).format("YYYY-MM-DD HH:mm:ss");
31
+ },
32
+ from: function (value) {
33
+ return moment.utc(value).tz((0, __1.getTimeZone)()).format("YYYY-MM-DD HH:mm:ss");
34
+ },
35
+ };
36
+ var LocalsCompanyInformationForTheTable = /** @class */ (function () {
37
+ function LocalsCompanyInformationForTheTable() {
38
+ }
39
+ __decorate([
40
+ (0, typeorm_1.ViewColumn)(),
41
+ __metadata("design:type", Number)
42
+ ], LocalsCompanyInformationForTheTable.prototype, "id", void 0);
43
+ __decorate([
44
+ (0, typeorm_1.ViewColumn)(),
45
+ __metadata("design:type", Number)
46
+ ], LocalsCompanyInformationForTheTable.prototype, "company", void 0);
47
+ __decorate([
48
+ (0, typeorm_1.ViewColumn)(),
49
+ __metadata("design:type", String)
50
+ ], LocalsCompanyInformationForTheTable.prototype, "name", void 0);
51
+ __decorate([
52
+ (0, typeorm_1.ViewColumn)(),
53
+ __metadata("design:type", Number)
54
+ ], LocalsCompanyInformationForTheTable.prototype, "city", void 0);
55
+ __decorate([
56
+ (0, typeorm_1.ViewColumn)(),
57
+ __metadata("design:type", String)
58
+ ], LocalsCompanyInformationForTheTable.prototype, "address", void 0);
59
+ __decorate([
60
+ (0, typeorm_1.ViewColumn)(),
61
+ __metadata("design:type", Number)
62
+ ], LocalsCompanyInformationForTheTable.prototype, "latitude", void 0);
63
+ __decorate([
64
+ (0, typeorm_1.ViewColumn)(),
65
+ __metadata("design:type", Number)
66
+ ], LocalsCompanyInformationForTheTable.prototype, "longitude", void 0);
67
+ __decorate([
68
+ (0, typeorm_1.ViewColumn)({ transformer: jsonTransformer }),
69
+ __metadata("design:type", Object)
70
+ ], LocalsCompanyInformationForTheTable.prototype, "details", void 0);
71
+ __decorate([
72
+ (0, typeorm_1.ViewColumn)({ transformer: DateTransformer }),
73
+ __metadata("design:type", String)
74
+ ], LocalsCompanyInformationForTheTable.prototype, "created", void 0);
75
+ __decorate([
76
+ (0, typeorm_1.ViewColumn)({ transformer: DateTransformer }),
77
+ __metadata("design:type", String)
78
+ ], LocalsCompanyInformationForTheTable.prototype, "updated", void 0);
79
+ __decorate([
80
+ (0, typeorm_1.ViewColumn)(),
81
+ __metadata("design:type", Number)
82
+ ], LocalsCompanyInformationForTheTable.prototype, "updated_by", void 0);
83
+ __decorate([
84
+ (0, typeorm_1.ViewColumn)(),
85
+ __metadata("design:type", Object)
86
+ ], LocalsCompanyInformationForTheTable.prototype, "square", void 0);
87
+ __decorate([
88
+ (0, typeorm_1.ViewColumn)(),
89
+ __metadata("design:type", Number)
90
+ ], LocalsCompanyInformationForTheTable.prototype, "pos_system", void 0);
91
+ __decorate([
92
+ (0, typeorm_1.ViewColumn)({ transformer: jsonTransformer }),
93
+ __metadata("design:type", Object)
94
+ ], LocalsCompanyInformationForTheTable.prototype, "pos_system_settings", void 0);
95
+ __decorate([
96
+ (0, typeorm_1.ViewColumn)(),
97
+ __metadata("design:type", Number)
98
+ ], LocalsCompanyInformationForTheTable.prototype, "status", void 0);
99
+ __decorate([
100
+ (0, typeorm_1.ViewColumn)(),
101
+ __metadata("design:type", Number)
102
+ ], LocalsCompanyInformationForTheTable.prototype, "visible", void 0);
103
+ __decorate([
104
+ (0, typeorm_1.ViewColumn)({ transformer: jsonTransformer }),
105
+ __metadata("design:type", Object)
106
+ ], LocalsCompanyInformationForTheTable.prototype, "contact_details", void 0);
107
+ __decorate([
108
+ (0, typeorm_1.ViewColumn)(),
109
+ __metadata("design:type", String)
110
+ ], LocalsCompanyInformationForTheTable.prototype, "type_local", void 0);
111
+ __decorate([
112
+ (0, typeorm_1.ViewColumn)(),
113
+ __metadata("design:type", Number)
114
+ ], LocalsCompanyInformationForTheTable.prototype, "company_id", void 0);
115
+ __decorate([
116
+ (0, typeorm_1.ViewColumn)(),
117
+ __metadata("design:type", String)
118
+ ], LocalsCompanyInformationForTheTable.prototype, "company_code", void 0);
119
+ __decorate([
120
+ (0, typeorm_1.ViewColumn)(),
121
+ __metadata("design:type", String)
122
+ ], LocalsCompanyInformationForTheTable.prototype, "company_name", void 0);
123
+ __decorate([
124
+ (0, typeorm_1.ViewColumn)({ transformer: DateTransformer }),
125
+ __metadata("design:type", Object)
126
+ ], LocalsCompanyInformationForTheTable.prototype, "company_expiration", void 0);
127
+ __decorate([
128
+ (0, typeorm_1.ViewColumn)(),
129
+ __metadata("design:type", Number)
130
+ ], LocalsCompanyInformationForTheTable.prototype, "company_partner", void 0);
131
+ __decorate([
132
+ (0, typeorm_1.ViewColumn)({ transformer: jsonTransformer }),
133
+ __metadata("design:type", Object)
134
+ ], LocalsCompanyInformationForTheTable.prototype, "company_contact_details", void 0);
135
+ __decorate([
136
+ (0, typeorm_1.ViewColumn)({ transformer: jsonTransformer }),
137
+ __metadata("design:type", Object)
138
+ ], LocalsCompanyInformationForTheTable.prototype, "company_profile", void 0);
139
+ __decorate([
140
+ (0, typeorm_1.ViewColumn)(),
141
+ __metadata("design:type", String)
142
+ ], LocalsCompanyInformationForTheTable.prototype, "company_legal_agent", void 0);
143
+ __decorate([
144
+ (0, typeorm_1.ViewColumn)({ transformer: jsonTransformer }),
145
+ __metadata("design:type", Object)
146
+ ], LocalsCompanyInformationForTheTable.prototype, "company_legal_information", void 0);
147
+ __decorate([
148
+ (0, typeorm_1.ViewColumn)({ transformer: jsonTransformer }),
149
+ __metadata("design:type", Object)
150
+ ], LocalsCompanyInformationForTheTable.prototype, "company_settings", void 0);
151
+ __decorate([
152
+ (0, typeorm_1.ViewColumn)(),
153
+ __metadata("design:type", Number)
154
+ ], LocalsCompanyInformationForTheTable.prototype, "city_id", void 0);
155
+ __decorate([
156
+ (0, typeorm_1.ViewColumn)(),
157
+ __metadata("design:type", String)
158
+ ], LocalsCompanyInformationForTheTable.prototype, "city_name", void 0);
159
+ __decorate([
160
+ (0, typeorm_1.ViewColumn)(),
161
+ __metadata("design:type", Number)
162
+ ], LocalsCompanyInformationForTheTable.prototype, "city_region", void 0);
163
+ __decorate([
164
+ (0, typeorm_1.ViewColumn)(),
165
+ __metadata("design:type", Number)
166
+ ], LocalsCompanyInformationForTheTable.prototype, "city_status", void 0);
167
+ __decorate([
168
+ (0, typeorm_1.ViewColumn)(),
169
+ __metadata("design:type", Number)
170
+ ], LocalsCompanyInformationForTheTable.prototype, "region_id", void 0);
171
+ __decorate([
172
+ (0, typeorm_1.ViewColumn)(),
173
+ __metadata("design:type", String)
174
+ ], LocalsCompanyInformationForTheTable.prototype, "region_name", void 0);
175
+ __decorate([
176
+ (0, typeorm_1.ViewColumn)(),
177
+ __metadata("design:type", Number)
178
+ ], LocalsCompanyInformationForTheTable.prototype, "region_country", void 0);
179
+ __decorate([
180
+ (0, typeorm_1.ViewColumn)(),
181
+ __metadata("design:type", Number)
182
+ ], LocalsCompanyInformationForTheTable.prototype, "region_status", void 0);
183
+ __decorate([
184
+ (0, typeorm_1.ViewColumn)(),
185
+ __metadata("design:type", Number)
186
+ ], LocalsCompanyInformationForTheTable.prototype, "country_id", void 0);
187
+ __decorate([
188
+ (0, typeorm_1.ViewColumn)(),
189
+ __metadata("design:type", String)
190
+ ], LocalsCompanyInformationForTheTable.prototype, "country_code", void 0);
191
+ __decorate([
192
+ (0, typeorm_1.ViewColumn)(),
193
+ __metadata("design:type", String)
194
+ ], LocalsCompanyInformationForTheTable.prototype, "country_currency", void 0);
195
+ __decorate([
196
+ (0, typeorm_1.ViewColumn)({ transformer: jsonTransformer }),
197
+ __metadata("design:type", Object)
198
+ ], LocalsCompanyInformationForTheTable.prototype, "country_details", void 0);
199
+ __decorate([
200
+ (0, typeorm_1.ViewColumn)({ transformer: DateTransformer }),
201
+ __metadata("design:type", Object)
202
+ ], LocalsCompanyInformationForTheTable.prototype, "country_legal_agent", void 0);
203
+ __decorate([
204
+ (0, typeorm_1.ViewColumn)({ transformer: jsonTransformer }),
205
+ __metadata("design:type", Object)
206
+ ], LocalsCompanyInformationForTheTable.prototype, "country_legal_information", void 0);
207
+ __decorate([
208
+ (0, typeorm_1.ViewColumn)(),
209
+ __metadata("design:type", String)
210
+ ], LocalsCompanyInformationForTheTable.prototype, "country_prefix", void 0);
211
+ __decorate([
212
+ (0, typeorm_1.ViewColumn)(),
213
+ __metadata("design:type", Number)
214
+ ], LocalsCompanyInformationForTheTable.prototype, "country_status", void 0);
215
+ __decorate([
216
+ (0, typeorm_1.ViewColumn)(),
217
+ __metadata("design:type", String)
218
+ ], LocalsCompanyInformationForTheTable.prototype, "country_structure_phone", void 0);
219
+ __decorate([
220
+ (0, typeorm_1.ViewColumn)(),
221
+ __metadata("design:type", Number)
222
+ ], LocalsCompanyInformationForTheTable.prototype, "partner_id", void 0);
223
+ __decorate([
224
+ (0, typeorm_1.ViewColumn)(),
225
+ __metadata("design:type", String)
226
+ ], LocalsCompanyInformationForTheTable.prototype, "partner_code", void 0);
227
+ __decorate([
228
+ (0, typeorm_1.ViewColumn)(),
229
+ __metadata("design:type", Object)
230
+ ], LocalsCompanyInformationForTheTable.prototype, "partner_document", void 0);
231
+ __decorate([
232
+ (0, typeorm_1.ViewColumn)(),
233
+ __metadata("design:type", String)
234
+ ], LocalsCompanyInformationForTheTable.prototype, "partner_name", void 0);
235
+ __decorate([
236
+ (0, typeorm_1.ViewColumn)(),
237
+ __metadata("design:type", String)
238
+ ], LocalsCompanyInformationForTheTable.prototype, "partner_surname", void 0);
239
+ __decorate([
240
+ (0, typeorm_1.ViewColumn)(),
241
+ __metadata("design:type", String)
242
+ ], LocalsCompanyInformationForTheTable.prototype, "partner_full_name", void 0);
243
+ __decorate([
244
+ (0, typeorm_1.ViewColumn)(),
245
+ __metadata("design:type", Object)
246
+ ], LocalsCompanyInformationForTheTable.prototype, "partner_phone", void 0);
247
+ __decorate([
248
+ (0, typeorm_1.ViewColumn)(),
249
+ __metadata("design:type", Number)
250
+ ], LocalsCompanyInformationForTheTable.prototype, "partner_owner", void 0);
251
+ __decorate([
252
+ (0, typeorm_1.ViewColumn)(),
253
+ __metadata("design:type", String)
254
+ ], LocalsCompanyInformationForTheTable.prototype, "partner_email", void 0);
255
+ __decorate([
256
+ (0, typeorm_1.ViewColumn)(),
257
+ __metadata("design:type", Object)
258
+ ], LocalsCompanyInformationForTheTable.prototype, "partner_city", void 0);
259
+ __decorate([
260
+ (0, typeorm_1.ViewColumn)(),
261
+ __metadata("design:type", Object)
262
+ ], LocalsCompanyInformationForTheTable.prototype, "partner_address", void 0);
263
+ __decorate([
264
+ (0, typeorm_1.ViewColumn)({ transformer: jsonTransformer }),
265
+ __metadata("design:type", Object)
266
+ ], LocalsCompanyInformationForTheTable.prototype, "partner_profile", void 0);
267
+ __decorate([
268
+ (0, typeorm_1.ViewColumn)(),
269
+ __metadata("design:type", Number)
270
+ ], LocalsCompanyInformationForTheTable.prototype, "partner_status", void 0);
271
+ __decorate([
272
+ (0, typeorm_1.ViewColumn)(),
273
+ __metadata("design:type", Number)
274
+ ], LocalsCompanyInformationForTheTable.prototype, "partner_visible", void 0);
275
+ __decorate([
276
+ (0, typeorm_1.ViewColumn)({ transformer: DateTransformer }),
277
+ __metadata("design:type", String)
278
+ ], LocalsCompanyInformationForTheTable.prototype, "partner_created", void 0);
279
+ __decorate([
280
+ (0, typeorm_1.ViewColumn)({ transformer: DateTransformer }),
281
+ __metadata("design:type", String)
282
+ ], LocalsCompanyInformationForTheTable.prototype, "partner_updated", void 0);
283
+ __decorate([
284
+ (0, typeorm_1.ViewColumn)(),
285
+ __metadata("design:type", Number)
286
+ ], LocalsCompanyInformationForTheTable.prototype, "square_id", void 0);
287
+ __decorate([
288
+ (0, typeorm_1.ViewColumn)({ transformer: jsonTransformer }),
289
+ __metadata("design:type", Object)
290
+ ], LocalsCompanyInformationForTheTable.prototype, "square_details", void 0);
291
+ __decorate([
292
+ (0, typeorm_1.ViewColumn)(),
293
+ __metadata("design:type", Object)
294
+ ], LocalsCompanyInformationForTheTable.prototype, "square_email", void 0);
295
+ __decorate([
296
+ (0, typeorm_1.ViewColumn)(),
297
+ __metadata("design:type", Object)
298
+ ], LocalsCompanyInformationForTheTable.prototype, "square_latitude", void 0);
299
+ __decorate([
300
+ (0, typeorm_1.ViewColumn)(),
301
+ __metadata("design:type", Object)
302
+ ], LocalsCompanyInformationForTheTable.prototype, "square_longitude", void 0);
303
+ __decorate([
304
+ (0, typeorm_1.ViewColumn)(),
305
+ __metadata("design:type", Number)
306
+ ], LocalsCompanyInformationForTheTable.prototype, "square_maximum_number_locals", void 0);
307
+ __decorate([
308
+ (0, typeorm_1.ViewColumn)(),
309
+ __metadata("design:type", String)
310
+ ], LocalsCompanyInformationForTheTable.prototype, "square_name", void 0);
311
+ __decorate([
312
+ (0, typeorm_1.ViewColumn)(),
313
+ __metadata("design:type", Object)
314
+ ], LocalsCompanyInformationForTheTable.prototype, "square_phone", void 0);
315
+ __decorate([
316
+ (0, typeorm_1.ViewColumn)(),
317
+ __metadata("design:type", Number)
318
+ ], LocalsCompanyInformationForTheTable.prototype, "square_status", void 0);
319
+ __decorate([
320
+ (0, typeorm_1.ViewColumn)(),
321
+ __metadata("design:type", Number)
322
+ ], LocalsCompanyInformationForTheTable.prototype, "local_plan_id", void 0);
323
+ __decorate([
324
+ (0, typeorm_1.ViewColumn)(),
325
+ __metadata("design:type", String)
326
+ ], LocalsCompanyInformationForTheTable.prototype, "local_plan_type", void 0);
327
+ __decorate([
328
+ (0, typeorm_1.ViewColumn)(),
329
+ __metadata("design:type", Number)
330
+ ], LocalsCompanyInformationForTheTable.prototype, "local_plan_price", void 0);
331
+ __decorate([
332
+ (0, typeorm_1.ViewColumn)({ transformer: DateTransformer }),
333
+ __metadata("design:type", String)
334
+ ], LocalsCompanyInformationForTheTable.prototype, "local_plan_start_date", void 0);
335
+ __decorate([
336
+ (0, typeorm_1.ViewColumn)({ transformer: DateTransformer }),
337
+ __metadata("design:type", String)
338
+ ], LocalsCompanyInformationForTheTable.prototype, "local_plan_end_date", void 0);
339
+ __decorate([
340
+ (0, typeorm_1.ViewColumn)({ transformer: jsonTransformer }),
341
+ __metadata("design:type", Object)
342
+ ], LocalsCompanyInformationForTheTable.prototype, "local_plan_settings", void 0);
343
+ __decorate([
344
+ (0, typeorm_1.ViewColumn)(),
345
+ __metadata("design:type", Number)
346
+ ], LocalsCompanyInformationForTheTable.prototype, "local_plan_status", void 0);
347
+ __decorate([
348
+ (0, typeorm_1.ViewColumn)(),
349
+ __metadata("design:type", String)
350
+ ], LocalsCompanyInformationForTheTable.prototype, "plan_code", void 0);
351
+ __decorate([
352
+ (0, typeorm_1.ViewColumn)(),
353
+ __metadata("design:type", Number)
354
+ ], LocalsCompanyInformationForTheTable.prototype, "plan_company", void 0);
355
+ __decorate([
356
+ (0, typeorm_1.ViewColumn)({ transformer: DateTransformer }),
357
+ __metadata("design:type", String)
358
+ ], LocalsCompanyInformationForTheTable.prototype, "plan_created", void 0);
359
+ __decorate([
360
+ (0, typeorm_1.ViewColumn)(),
361
+ __metadata("design:type", String)
362
+ ], LocalsCompanyInformationForTheTable.prototype, "plan_name", void 0);
363
+ __decorate([
364
+ (0, typeorm_1.ViewColumn)(),
365
+ __metadata("design:type", Number)
366
+ ], LocalsCompanyInformationForTheTable.prototype, "plan_id", void 0);
367
+ __decorate([
368
+ (0, typeorm_1.ViewColumn)({ transformer: jsonTransformer }),
369
+ __metadata("design:type", Object)
370
+ ], LocalsCompanyInformationForTheTable.prototype, "plan_description", void 0);
371
+ __decorate([
372
+ (0, typeorm_1.ViewColumn)(),
373
+ __metadata("design:type", Number)
374
+ ], LocalsCompanyInformationForTheTable.prototype, "plan_quantity_locals", void 0);
375
+ __decorate([
376
+ (0, typeorm_1.ViewColumn)({ transformer: DateTransformer }),
377
+ __metadata("design:type", String)
378
+ ], LocalsCompanyInformationForTheTable.prototype, "plan_expiration", void 0);
379
+ __decorate([
380
+ (0, typeorm_1.ViewColumn)(),
381
+ __metadata("design:type", Number)
382
+ ], LocalsCompanyInformationForTheTable.prototype, "plan_status", void 0);
383
+ __decorate([
384
+ (0, typeorm_1.ViewColumn)(),
385
+ __metadata("design:type", Number)
386
+ ], LocalsCompanyInformationForTheTable.prototype, "total_requests", void 0);
387
+ __decorate([
388
+ (0, typeorm_1.ViewColumn)(),
389
+ __metadata("design:type", Number)
390
+ ], LocalsCompanyInformationForTheTable.prototype, "total_ratings", void 0);
391
+ __decorate([
392
+ (0, typeorm_1.ViewColumn)(),
393
+ __metadata("design:type", Number)
394
+ ], LocalsCompanyInformationForTheTable.prototype, "average_rating", void 0);
395
+ LocalsCompanyInformationForTheTable = __decorate([
396
+ (0, typeorm_1.ViewEntity)({
397
+ name: "locals_company_information_for_the_table",
398
+ })
399
+ ], LocalsCompanyInformationForTheTable);
400
+ return LocalsCompanyInformationForTheTable;
401
+ }());
402
+ exports.LocalsCompanyInformationForTheTable = LocalsCompanyInformationForTheTable;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "test-entity-library-asm",
3
- "version": "3.9.0",
3
+ "version": "3.9.2",
4
4
  "description": "Entidades de ejemplo para una base de datos",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -82,6 +82,7 @@ export { PartnerNotifications } from "./views/PartnerNotifications";
82
82
  export { LocalTableZonesFilter } from "./views/LocalTableZonesFilter";
83
83
  export { LocalReserves } from "./views/LocalReserves";
84
84
  export { LocalsCompanyInformationForTheMap } from "./views/LocalsCompanyInformationForTheMap";
85
+ export { LocalsCompanyInformationForTheTable } from "./views/LocalsCompanyInformationForTheTable";
85
86
 
86
87
  export { getDiscountsCodeCompanyInformation } from "./filters/DiscountsCodeCompanyInformation";
87
88
  export { getDiscountsCodeUserInformation } from "./filters/DiscountsCodeUserInformation";
@@ -0,0 +1,230 @@
1
+ import { Repository } from "typeorm";
2
+ import { IBasicCompany } from "../interfaces";
3
+ import { getTimeZone, getTimezoneOffset } from "..";
4
+
5
+ export async function getLocalsCompanyInformation(
6
+ repository: Repository<any>,
7
+ { company, status, visible, lazyEvent }: IBasicCompany
8
+ ) {
9
+ try {
10
+ const timezone = getTimezoneOffset(getTimeZone());
11
+
12
+ const queryBuilder = repository
13
+ .createQueryBuilder("locals_company_information_for_the_table")
14
+ .skip(lazyEvent.first)
15
+ .take(lazyEvent.rows);
16
+
17
+ // DOC: Filtro global
18
+ if (lazyEvent.filters["global"] && lazyEvent.filters["global"].value) {
19
+ const globalValue = `%${lazyEvent.filters[
20
+ "global"
21
+ ].value.toLowerCase()}%`;
22
+ queryBuilder.andWhere(
23
+ "(LOWER(locals_company_information_for_the_table.name) LIKE :globalValue OR LOWER(locals_company_information_for_the_table.address) LIKE :globalValue OR LOWER(locals_company_information_for_the_table.partner_name) LIKE :globalValue OR LOWER(locals_company_information_for_the_table.partner_surname) LIKE :globalValue OR LOWER(locals_company_information_for_the_table.partner_full_name) LIKE :globalValue OR locals_company_information_for_the_table.partner_full_name LIKE :globalValue",
24
+ { globalValue }
25
+ );
26
+ }
27
+
28
+ // DOC: Filtro por estado FILTRO POR DEFECTO.
29
+ if (status !== null && status >= 0) {
30
+ queryBuilder.andWhere(
31
+ "locals_company_information_for_the_table.status = :status",
32
+ {
33
+ status,
34
+ }
35
+ );
36
+ }
37
+
38
+ // DOC: Filtro por company FILTRO POR DEFECTO.
39
+ if (company !== null && company >= 0) {
40
+ queryBuilder.andWhere(
41
+ "locals_company_information_for_the_table.company = :company",
42
+ {
43
+ company,
44
+ }
45
+ );
46
+ }
47
+
48
+ // DOC: Filtro por visible FILTRO POR DEFECTO.
49
+ if (visible !== null) {
50
+ queryBuilder.andWhere(
51
+ "locals_company_information_for_the_table.visible = :visible",
52
+ {
53
+ visible,
54
+ }
55
+ );
56
+ }
57
+
58
+ // DOC: Acá vienen los otros filtros, por las columnas de la tabla.
59
+ const filters = lazyEvent.filters;
60
+ Object.keys(filters).forEach((key) => {
61
+ let value = filters[key].value; // DOC: Obtenemos el valor del filtro.
62
+
63
+ if (
64
+ (Array.isArray(value) && value.length > 0) ||
65
+ (!Array.isArray(value) && value && key !== "global")
66
+ ) {
67
+ // DOC: Verificamos si el filtro tiene valor, si no es un filtro global y no es un array vacío.
68
+ const matchMode = filters[key].matchMode; // DOC: Obtenemos el modo de coincidencia del filtro.
69
+ if (!Array.isArray(value) && value) {
70
+ // DOC: Si el valor no es un array y tiene valor, lo convertimos a minúsculas.
71
+ value = filters[key].value.toLowerCase();
72
+ }
73
+
74
+ const accessKey =
75
+ key.split(".").length > 1
76
+ ? `${key}`
77
+ : `locals_company_information_for_the_table.${key}`; // DOC: Verificamos si el filtro es un campo anidado o no.
78
+
79
+ switch (
80
+ matchMode // DOC: Verificamos el modo de coincidencia del filtro.
81
+ ) {
82
+ case "contains": // DOC: Si el modo de coincidencia es "contains".
83
+ queryBuilder.andWhere(`LOWER(${accessKey}) LIKE :${key}`, {
84
+ [key]: `%${value}%`,
85
+ });
86
+ break;
87
+ case "equals": // DOC: Si el modo de coincidencia es "equals".
88
+ queryBuilder.andWhere(`${accessKey} = :${key}`, { [key]: value });
89
+ break;
90
+ case "notEquals": // DOC: Si el modo de coincidencia es "notEquals".
91
+ queryBuilder.andWhere(`${accessKey} != :${key}`, { [key]: value });
92
+ break;
93
+ case "startsWith": // DOC: Si el modo de coincidencia es "startsWith".
94
+ queryBuilder.andWhere(`LOWER(${accessKey}) LIKE :${key}`, {
95
+ [key]: `${value}%`,
96
+ });
97
+ break;
98
+ case "endsWith": // DOC: Si el modo de coincidencia es "endsWith".
99
+ queryBuilder.andWhere(`LOWER(${accessKey}) LIKE :${key}`, {
100
+ [key]: `%${value}`,
101
+ });
102
+ break;
103
+ case "in": // DOC: Si el modo de coincidencia es "in".
104
+ if (Array.isArray(value)) {
105
+ queryBuilder.andWhere(`${accessKey} IN (:...${key})`, {
106
+ [key]: value,
107
+ });
108
+ }
109
+ break;
110
+ case "notIn": // DOC: Si el modo de coincidencia es "notIn
111
+ if (Array.isArray(value)) {
112
+ queryBuilder.andWhere(`${accessKey} NOT IN (:...${key})`, {
113
+ [key]: value,
114
+ });
115
+ }
116
+ break;
117
+ case "lt": // DOC: Si el modo de coincidencia es "lt" (less than).
118
+ queryBuilder.andWhere(`${accessKey} < :${key}`, { [key]: value });
119
+ break;
120
+ case "lte": // DOC: Si el modo de coincidencia es "lte" (less than or equal).
121
+ queryBuilder.andWhere(`${accessKey} <= :${key}`, { [key]: value });
122
+ break;
123
+ case "gt": // DOC: Si el modo de coincidencia es "gt" (greater than).
124
+ queryBuilder.andWhere(`${accessKey} > :${key}`, { [key]: value });
125
+ break;
126
+ case "gte": // DOC: Si el modo de coincidencia es "gte" (greater than or equal).
127
+ queryBuilder.andWhere(`${accessKey} >= :${key}`, { [key]: value });
128
+ break;
129
+ case "between": // DOC: Si el modo de coincidencia es "between".
130
+ if (Array.isArray(value) && value.length === 2) {
131
+ const [from, to] = value;
132
+ queryBuilder.andWhere(`${accessKey} BETWEEN :from AND :to`, {
133
+ from,
134
+ to,
135
+ });
136
+ }
137
+ break;
138
+ case "dateIs": // DOC: Si el modo de coincidencia es "dateIs". Hay que tener en cuenta la zona horaria (timezone)
139
+ queryBuilder.andWhere(
140
+ `${
141
+ key !== "expiration" && key !== "start"
142
+ ? "DATE(CONVERT_TZ("
143
+ : ""
144
+ } ${accessKey} ${
145
+ key !== "expiration" && key !== "start"
146
+ ? `, '+00:00', '${timezone}'))`
147
+ : ""
148
+ } != :${key}`,
149
+ {
150
+ [key]: value.split("T")[0],
151
+ }
152
+ );
153
+ break;
154
+ case "dateIsNot": // DOC: Si el modo de coincidencia es "dateIsNot". Hay que tener en cuenta la zona horaria (timezone)
155
+ queryBuilder.andWhere(
156
+ `${
157
+ key !== "expiration" && key !== "start"
158
+ ? "DATE(CONVERT_TZ("
159
+ : ""
160
+ } ${accessKey} ${
161
+ key !== "expiration" && key !== "start"
162
+ ? `, '+00:00', '${timezone}'))`
163
+ : ""
164
+ } = :${key}`,
165
+ {
166
+ [key]: value.split("T")[0],
167
+ }
168
+ );
169
+ break;
170
+ case "dateBefore": // DOC: Si el modo de coincidencia es "dateBefore". Hay que tener en cuenta la zona horaria (timezone)
171
+ queryBuilder.andWhere(
172
+ `${
173
+ key !== "expiration" && key !== "start"
174
+ ? "DATE(CONVERT_TZ("
175
+ : ""
176
+ } ${accessKey} ${
177
+ key !== "expiration" && key !== "start"
178
+ ? `, '+00:00', '${timezone}'))`
179
+ : ""
180
+ } < :${key}`,
181
+ {
182
+ [key]: value.split("T")[0],
183
+ }
184
+ );
185
+ break;
186
+ case "dateAfter": // DOC: Si el modo de coincidencia es "dateAfter". Hay que tener en cuenta la zona horaria (timezone)
187
+ queryBuilder.andWhere(
188
+ `${
189
+ key !== "expiration" && key !== "start"
190
+ ? "DATE(CONVERT_TZ("
191
+ : ""
192
+ } ${accessKey} ${
193
+ key !== "expiration" && key !== "start"
194
+ ? `, '+00:00', '${timezone}'))`
195
+ : ""
196
+ } > :${key}`,
197
+ {
198
+ [key]: value.split("T")[0],
199
+ }
200
+ );
201
+ break;
202
+ default: // DOC: Si el modo de coincidencia no es ninguno de los anteriores.
203
+ break;
204
+ }
205
+ }
206
+ });
207
+
208
+ // DOC: Ordenamiento de los resultados.
209
+ if (lazyEvent.sortField) {
210
+ const sortOrder = lazyEvent.sortOrder === 1 ? "ASC" : "DESC";
211
+ queryBuilder.addOrderBy(
212
+ `locals_company_information_for_the_table.${lazyEvent.sortField}`,
213
+ sortOrder
214
+ );
215
+ }
216
+
217
+ // DOC: Ejecutamos la consulta y obtenemos los resultados.
218
+ const [data, totalRecords] = await queryBuilder.getManyAndCount();
219
+
220
+ return {
221
+ data,
222
+ totalRecords,
223
+ };
224
+ } catch (error) {
225
+ return {
226
+ data: [],
227
+ totalRecords: 0,
228
+ };
229
+ }
230
+ }
@@ -0,0 +1,296 @@
1
+ import { ViewColumn, ViewEntity } from "typeorm";
2
+ import moment = require("moment-timezone");
3
+ import { getTimeZone } from "..";
4
+
5
+ const jsonTransformer = {
6
+ to: (value: any) => JSON.stringify(value),
7
+ from: (value: string) => {
8
+ try {
9
+ return JSON.parse(value);
10
+ } catch (error) {
11
+ console.log(error, "Transformer error");
12
+ return null;
13
+ }
14
+ },
15
+ };
16
+
17
+ const DateTransformer = {
18
+ to(value: Date | string): string {
19
+ return moment.utc(value).format("YYYY-MM-DD HH:mm:ss");
20
+ },
21
+ from(value: string): string {
22
+ return moment.utc(value).tz(getTimeZone()).format("YYYY-MM-DD HH:mm:ss");
23
+ },
24
+ };
25
+
26
+ @ViewEntity({
27
+ name: "locals_company_information_for_the_table",
28
+ })
29
+ export class LocalsCompanyInformationForTheTable {
30
+ @ViewColumn()
31
+ id: number;
32
+
33
+ @ViewColumn()
34
+ company: number;
35
+
36
+ @ViewColumn()
37
+ name: string;
38
+
39
+ @ViewColumn()
40
+ city: number;
41
+
42
+ @ViewColumn()
43
+ address: string;
44
+
45
+ @ViewColumn()
46
+ latitude: number;
47
+
48
+ @ViewColumn()
49
+ longitude: number;
50
+
51
+ @ViewColumn({ transformer: jsonTransformer })
52
+ details: any | null;
53
+
54
+ @ViewColumn({ transformer: DateTransformer })
55
+ created: string;
56
+
57
+ @ViewColumn({ transformer: DateTransformer })
58
+ updated: string;
59
+
60
+ @ViewColumn()
61
+ updated_by: number;
62
+
63
+ @ViewColumn()
64
+ square: number | null;
65
+
66
+ @ViewColumn()
67
+ pos_system: number;
68
+
69
+ @ViewColumn({ transformer: jsonTransformer })
70
+ pos_system_settings: any | null;
71
+
72
+ @ViewColumn()
73
+ status: number;
74
+
75
+ @ViewColumn()
76
+ visible: number;
77
+
78
+ @ViewColumn({ transformer: jsonTransformer })
79
+ contact_details: any | null;
80
+
81
+ @ViewColumn()
82
+ type_local: string;
83
+
84
+ @ViewColumn()
85
+ company_id: number;
86
+
87
+ @ViewColumn()
88
+ company_code: string;
89
+
90
+ @ViewColumn()
91
+ company_name: string;
92
+
93
+ @ViewColumn({ transformer: DateTransformer })
94
+ company_expiration: string | null;
95
+
96
+ @ViewColumn()
97
+ company_partner: number;
98
+
99
+ @ViewColumn({ transformer: jsonTransformer })
100
+ company_contact_details: any | null;
101
+
102
+ @ViewColumn({ transformer: jsonTransformer })
103
+ company_profile: any | null;
104
+
105
+ @ViewColumn()
106
+ company_legal_agent: string;
107
+
108
+ @ViewColumn({ transformer: jsonTransformer })
109
+ company_legal_information: any | null;
110
+
111
+ @ViewColumn({ transformer: jsonTransformer })
112
+ company_settings: any | null;
113
+
114
+ @ViewColumn()
115
+ city_id: number;
116
+
117
+ @ViewColumn()
118
+ city_name: string;
119
+
120
+ @ViewColumn()
121
+ city_region: number;
122
+
123
+ @ViewColumn()
124
+ city_status: number;
125
+
126
+ @ViewColumn()
127
+ region_id: number;
128
+
129
+ @ViewColumn()
130
+ region_name: string;
131
+
132
+ @ViewColumn()
133
+ region_country: number;
134
+
135
+ @ViewColumn()
136
+ region_status: number;
137
+
138
+ @ViewColumn()
139
+ country_id: number;
140
+
141
+ @ViewColumn()
142
+ country_code: string;
143
+
144
+ @ViewColumn()
145
+ country_currency: string;
146
+
147
+ @ViewColumn({ transformer: jsonTransformer })
148
+ country_details: any | null;
149
+
150
+ @ViewColumn({ transformer: DateTransformer })
151
+ country_legal_agent: string | null;
152
+
153
+ @ViewColumn({ transformer: jsonTransformer })
154
+ country_legal_information: any | null;
155
+
156
+ @ViewColumn()
157
+ country_prefix: string;
158
+
159
+ @ViewColumn()
160
+ country_status: number;
161
+
162
+ @ViewColumn()
163
+ country_structure_phone: string;
164
+
165
+ @ViewColumn()
166
+ partner_id: number;
167
+
168
+ @ViewColumn()
169
+ partner_code: string;
170
+
171
+ @ViewColumn()
172
+ partner_document: string | null;
173
+
174
+ @ViewColumn()
175
+ partner_name: string;
176
+
177
+ @ViewColumn()
178
+ partner_surname: string;
179
+
180
+ @ViewColumn()
181
+ partner_full_name: string;
182
+
183
+ @ViewColumn()
184
+ partner_phone: string | null;
185
+
186
+ @ViewColumn()
187
+ partner_owner: number;
188
+
189
+ @ViewColumn()
190
+ partner_email: string;
191
+
192
+ @ViewColumn()
193
+ partner_city: string | null;
194
+
195
+ @ViewColumn()
196
+ partner_address: string | null;
197
+
198
+ @ViewColumn({ transformer: jsonTransformer })
199
+ partner_profile: any | null;
200
+
201
+ @ViewColumn()
202
+ partner_status: number;
203
+
204
+ @ViewColumn()
205
+ partner_visible: number;
206
+
207
+ @ViewColumn({ transformer: DateTransformer })
208
+ partner_created: string;
209
+
210
+ @ViewColumn({ transformer: DateTransformer })
211
+ partner_updated: string;
212
+
213
+ @ViewColumn()
214
+ square_id: number;
215
+
216
+ @ViewColumn({ transformer: jsonTransformer })
217
+ square_details: any | null;
218
+
219
+ @ViewColumn()
220
+ square_email: string | null;
221
+
222
+ @ViewColumn()
223
+ square_latitude: number | null;
224
+
225
+ @ViewColumn()
226
+ square_longitude: number | null;
227
+
228
+ @ViewColumn()
229
+ square_maximum_number_locals: number;
230
+
231
+ @ViewColumn()
232
+ square_name: string;
233
+
234
+ @ViewColumn()
235
+ square_phone: string | null;
236
+
237
+ @ViewColumn()
238
+ square_status: number;
239
+
240
+ @ViewColumn()
241
+ local_plan_id: number;
242
+
243
+ @ViewColumn()
244
+ local_plan_type: string;
245
+
246
+ @ViewColumn()
247
+ local_plan_price: number;
248
+
249
+ @ViewColumn({ transformer: DateTransformer })
250
+ local_plan_start_date: string;
251
+
252
+ @ViewColumn({ transformer: DateTransformer })
253
+ local_plan_end_date: string;
254
+
255
+ @ViewColumn({ transformer: jsonTransformer })
256
+ local_plan_settings: any | null;
257
+
258
+ @ViewColumn()
259
+ local_plan_status: number;
260
+
261
+ @ViewColumn()
262
+ plan_code: string;
263
+
264
+ @ViewColumn()
265
+ plan_company: number;
266
+
267
+ @ViewColumn({ transformer: DateTransformer })
268
+ plan_created: string;
269
+
270
+ @ViewColumn()
271
+ plan_name: string;
272
+
273
+ @ViewColumn()
274
+ plan_id: number;
275
+
276
+ @ViewColumn({ transformer: jsonTransformer })
277
+ plan_description: any | null;
278
+
279
+ @ViewColumn()
280
+ plan_quantity_locals: number;
281
+
282
+ @ViewColumn({ transformer: DateTransformer })
283
+ plan_expiration: string;
284
+
285
+ @ViewColumn()
286
+ plan_status: number;
287
+
288
+ @ViewColumn()
289
+ total_requests: number;
290
+
291
+ @ViewColumn()
292
+ total_ratings: number;
293
+
294
+ @ViewColumn()
295
+ average_rating: number;
296
+ }