test-entity-library-asm 2.7.14 → 2.7.16
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 -1
- package/dist/CustomRepository.js +186 -1
- package/dist/entities/DiscountCodeCompany.d.ts +2 -0
- package/dist/entities/DiscountCodeCompany.js +5 -0
- package/dist/entities/ServicePlan.d.ts +13 -0
- package/dist/entities/ServicePlan.js +67 -0
- package/dist/entities.views.routes.d.ts +1 -0
- package/dist/entities.views.routes.js +4 -2
- package/dist/interfaces.d.ts +6 -0
- package/package.json +1 -1
- package/src/CustomRepository.ts +228 -1
- package/src/entities/DiscountCodeCompany.ts +4 -0
- package/src/entities/ServicePlan.ts +39 -0
- package/src/entities.views.routes.ts +1 -0
- package/src/interfaces.ts +7 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DataSource, EntityTarget, Repository, ObjectLiteral } from 'typeorm';
|
|
2
|
-
import { IBasicLazyEvent, IPropsDiscountUserOrCompany, IPropsQueryVerifyLocal } from './interfaces';
|
|
2
|
+
import { IBasicCompany, IBasicLazyEvent, IPropsDiscountUserOrCompany, IPropsQueryVerifyLocal } from './interfaces';
|
|
3
3
|
export declare class CustomRepository<T extends ObjectLiteral> extends Repository<T> {
|
|
4
4
|
constructor(target: EntityTarget<T>, dataSource: DataSource);
|
|
5
5
|
getVerifyLocals({ status, lazyEvent }: IPropsQueryVerifyLocal): Promise<{
|
|
@@ -14,5 +14,9 @@ export declare class CustomRepository<T extends ObjectLiteral> extends Repositor
|
|
|
14
14
|
data: T[];
|
|
15
15
|
totalRecords: number;
|
|
16
16
|
}>;
|
|
17
|
+
getLocalsCompanyInformation({ company, status, visible, lazyEvent, }: IBasicCompany): Promise<false | {
|
|
18
|
+
data: T[];
|
|
19
|
+
totalRecords: number;
|
|
20
|
+
}>;
|
|
17
21
|
anyOtherRepository(args: any): Promise<void>;
|
|
18
22
|
}
|
package/dist/CustomRepository.js
CHANGED
|
@@ -184,7 +184,7 @@ var CustomRepository = /** @class */ (function (_super) {
|
|
|
184
184
|
// DOC: Filtro global
|
|
185
185
|
if (lazyEvent.filters['global'] && lazyEvent.filters['global'].value) {
|
|
186
186
|
globalValue = "%".concat(lazyEvent.filters['global'].value.toLowerCase(), "%");
|
|
187
|
-
queryBuilder.andWhere('LOWER(discount_code_user.local_name) LIKE :globalValue OR LOWER(partner_surname) LIKE :globalValue OR LOWER(discount_code_user.code) LIKE :globalValue OR LOWER(discount_code_user.discount) LIKE :globalValue OR LOWER(partner_name) LIKE :globalValue', {
|
|
187
|
+
queryBuilder.andWhere('(LOWER(discount_code_user.local_name) LIKE :globalValue OR LOWER(partner_surname) LIKE :globalValue OR LOWER(discount_code_user.code) LIKE :globalValue OR LOWER(discount_code_user.discount) LIKE :globalValue OR LOWER(partner_name) LIKE :globalValue)', {
|
|
188
188
|
globalValue: globalValue ||
|
|
189
189
|
(0, utils_1.getStatusBasic)(lazyEvent.filters['global'].value.toLowerCase()) ||
|
|
190
190
|
(0, utils_1.getSeverityNameDiscountType)(lazyEvent.filters['global'].value.toLowerCase()),
|
|
@@ -520,6 +520,191 @@ var CustomRepository = /** @class */ (function (_super) {
|
|
|
520
520
|
});
|
|
521
521
|
});
|
|
522
522
|
};
|
|
523
|
+
CustomRepository.prototype.getLocalsCompanyInformation = function (_a) {
|
|
524
|
+
return __awaiter(this, arguments, void 0, function (_b) {
|
|
525
|
+
var timezone_2, queryBuilder_2, globalValue, filters_2, order, _c, locals, totalRecords, error_2;
|
|
526
|
+
var company = _b.company, status = _b.status, visible = _b.visible, lazyEvent = _b.lazyEvent;
|
|
527
|
+
return __generator(this, function (_d) {
|
|
528
|
+
switch (_d.label) {
|
|
529
|
+
case 0:
|
|
530
|
+
_d.trys.push([0, 2, , 3]);
|
|
531
|
+
timezone_2 = (0, _1.getTimezoneOffset)((0, _1.getTimeZone)());
|
|
532
|
+
queryBuilder_2 = this
|
|
533
|
+
.createQueryBuilder('view_locals_companies')
|
|
534
|
+
.skip(lazyEvent.first)
|
|
535
|
+
.take(lazyEvent.rows);
|
|
536
|
+
// DOC: Filtro global
|
|
537
|
+
if (lazyEvent.filters['global'] && lazyEvent.filters['global'].value) {
|
|
538
|
+
globalValue = "%".concat(lazyEvent.filters['global'].value.toLowerCase(), "%");
|
|
539
|
+
queryBuilder_2.andWhere('(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)', {
|
|
540
|
+
globalValue: globalValue ||
|
|
541
|
+
(0, utils_1.getStatusBasic)(lazyEvent.filters['global'].value.toLowerCase()),
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
// DOC: Filtro por estado FILTRO POR DEFECTO
|
|
545
|
+
if (status !== null && status >= 0) {
|
|
546
|
+
queryBuilder_2.andWhere('view_locals_companies.status = :status', {
|
|
547
|
+
status: status,
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
// DOC: Filtro por company FILTRO POR DEFECTO
|
|
551
|
+
if (company !== null && company >= 0) {
|
|
552
|
+
queryBuilder_2.andWhere('view_locals_companies.company = :company', {
|
|
553
|
+
company: company,
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
if (visible !== null) {
|
|
557
|
+
queryBuilder_2.andWhere('view_locals_companies.visible = :visible', {
|
|
558
|
+
visible: visible,
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
filters_2 = lazyEvent.filters;
|
|
562
|
+
Object.keys(filters_2).forEach(function (key) {
|
|
563
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
564
|
+
var _l, _m;
|
|
565
|
+
var value = filters_2[key].value;
|
|
566
|
+
if ((Array.isArray(value) && value.length > 0) ||
|
|
567
|
+
(!Array.isArray(value) && value && key !== 'global')) {
|
|
568
|
+
var matchMode = filters_2[key].matchMode;
|
|
569
|
+
if (!Array.isArray(value) && value) {
|
|
570
|
+
value = filters_2[key].value.toLowerCase();
|
|
571
|
+
}
|
|
572
|
+
var accessKey = key.split('.').length > 1 ? "".concat(key) : "view_locals_companies.".concat(key);
|
|
573
|
+
switch (matchMode) {
|
|
574
|
+
case 'custom':
|
|
575
|
+
if (key === 'total_partners' && matchMode === 'custom') {
|
|
576
|
+
var _o = value || [null, null], from = _o[0], to = _o[1];
|
|
577
|
+
if (from !== null && to === null) {
|
|
578
|
+
queryBuilder_2.andWhere("view_locals_companies.".concat(key, " >= :from"), {
|
|
579
|
+
from: from,
|
|
580
|
+
});
|
|
581
|
+
}
|
|
582
|
+
else if (from === null && to !== null) {
|
|
583
|
+
queryBuilder_2.andWhere("view_locals_companies.".concat(key, " <= :to"), {
|
|
584
|
+
to: to,
|
|
585
|
+
});
|
|
586
|
+
}
|
|
587
|
+
else if (from !== null && to !== null) {
|
|
588
|
+
queryBuilder_2.andWhere("view_locals_companies.".concat(key, " BETWEEN :from AND :to"), { from: from, to: to });
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
break;
|
|
592
|
+
case 'contains':
|
|
593
|
+
queryBuilder_2.andWhere("".concat(accessKey, " LIKE :").concat(key), (_a = {},
|
|
594
|
+
_a[key] = "%".concat(value, "%"),
|
|
595
|
+
_a));
|
|
596
|
+
break;
|
|
597
|
+
case 'startsWith':
|
|
598
|
+
queryBuilder_2.andWhere("".concat(accessKey, " LIKE :").concat(key), (_b = {},
|
|
599
|
+
_b[key] = "".concat(value, "%"),
|
|
600
|
+
_b));
|
|
601
|
+
break;
|
|
602
|
+
case 'endsWith':
|
|
603
|
+
queryBuilder_2.andWhere("".concat(accessKey, " LIKE :").concat(key), (_c = {},
|
|
604
|
+
_c[key] = "".concat(value, "%"),
|
|
605
|
+
_c));
|
|
606
|
+
break;
|
|
607
|
+
case 'equals':
|
|
608
|
+
if (key === 'status') {
|
|
609
|
+
queryBuilder_2.andWhere('view_locals_companies.status = :status', {
|
|
610
|
+
status: (0, utils_1.getStatusBasic)((_l = filters_2[key].value) !== null && _l !== void 0 ? _l : ''),
|
|
611
|
+
});
|
|
612
|
+
}
|
|
613
|
+
else if (key === 'typeText') {
|
|
614
|
+
queryBuilder_2.andWhere('view_locals_companies.type = :type', {
|
|
615
|
+
type: (0, utils_1.getSeverityNameDiscountType)((_m = filters_2[key].value) !== null && _m !== void 0 ? _m : ''),
|
|
616
|
+
});
|
|
617
|
+
}
|
|
618
|
+
else if (key === 'has_square') {
|
|
619
|
+
var hasSI = filters_2[key].value.includes('SI');
|
|
620
|
+
var hasNO = filters_2[key].value.includes('NO');
|
|
621
|
+
var queryPlazolet = hasSI && hasNO
|
|
622
|
+
? ''
|
|
623
|
+
: hasSI
|
|
624
|
+
? 'view_locals_companies.has_square IS NOT NULL'
|
|
625
|
+
: hasNO
|
|
626
|
+
? 'view_locals_companies.has_square IS NULL'
|
|
627
|
+
: '';
|
|
628
|
+
if (queryPlazolet !== '') {
|
|
629
|
+
queryBuilder_2.andWhere(queryPlazolet);
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
else {
|
|
633
|
+
queryBuilder_2.andWhere("".concat(accessKey, " = :").concat(key), (_d = {},
|
|
634
|
+
_d[key] = value,
|
|
635
|
+
_d));
|
|
636
|
+
}
|
|
637
|
+
break;
|
|
638
|
+
case 'notContains':
|
|
639
|
+
queryBuilder_2.andWhere("".concat(accessKey, " NOT LIKE :").concat(key), (_e = {},
|
|
640
|
+
_e[key] = "%".concat(value, "%"),
|
|
641
|
+
_e));
|
|
642
|
+
break;
|
|
643
|
+
case 'notEquals':
|
|
644
|
+
queryBuilder_2.andWhere("".concat(accessKey, " != :").concat(key), (_f = {},
|
|
645
|
+
_f[key] = value,
|
|
646
|
+
_f));
|
|
647
|
+
break;
|
|
648
|
+
case 'dateIs':
|
|
649
|
+
queryBuilder_2.andWhere("".concat(key !== 'expiration' && key !== 'start'
|
|
650
|
+
? 'DATE(CONVERT_TZ('
|
|
651
|
+
: '', " ").concat(accessKey, " ").concat(key !== 'expiration' && key !== 'start'
|
|
652
|
+
? ", '+00:00', '".concat(timezone_2, "'))")
|
|
653
|
+
: '', " = :").concat(key), (_g = {},
|
|
654
|
+
_g[key] = value.split('T')[0],
|
|
655
|
+
_g));
|
|
656
|
+
break;
|
|
657
|
+
case 'dateIsNot':
|
|
658
|
+
queryBuilder_2.andWhere("".concat(key !== 'expiration' && key !== 'start'
|
|
659
|
+
? 'DATE(CONVERT_TZ('
|
|
660
|
+
: '', " ").concat(accessKey, " ").concat(key !== 'expiration' && key !== 'start'
|
|
661
|
+
? ", '+00:00', '".concat(timezone_2, "'))")
|
|
662
|
+
: '', " != :").concat(key), (_h = {},
|
|
663
|
+
_h[key] = value.split('T')[0],
|
|
664
|
+
_h));
|
|
665
|
+
break;
|
|
666
|
+
case 'dateBefore':
|
|
667
|
+
queryBuilder_2.andWhere("".concat(key !== 'expiration' && key !== 'start'
|
|
668
|
+
? 'DATE(CONVERT_TZ('
|
|
669
|
+
: '', " ").concat(accessKey, " ").concat(key !== 'expiration' && key !== 'start'
|
|
670
|
+
? ", '+00:00', '".concat(timezone_2, "'))")
|
|
671
|
+
: '', " < :").concat(key), (_j = {},
|
|
672
|
+
_j[key] = value.split('T')[0],
|
|
673
|
+
_j));
|
|
674
|
+
break;
|
|
675
|
+
case 'dateAfter':
|
|
676
|
+
queryBuilder_2.andWhere("".concat(key !== 'expiration' && key !== 'start'
|
|
677
|
+
? 'DATE(CONVERT_TZ('
|
|
678
|
+
: '', " ").concat(accessKey, " ").concat(key !== 'expiration' && key !== 'start'
|
|
679
|
+
? ", '+00:00', '".concat(timezone_2, "'))")
|
|
680
|
+
: '', " > :").concat(key), (_k = {},
|
|
681
|
+
_k[key] = value.split('T')[0],
|
|
682
|
+
_k));
|
|
683
|
+
break;
|
|
684
|
+
default:
|
|
685
|
+
break;
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
});
|
|
689
|
+
if (lazyEvent.sortField) {
|
|
690
|
+
order = lazyEvent.sortOrder === 1 ? 'ASC' : 'DESC';
|
|
691
|
+
queryBuilder_2.orderBy("view_locals_companies.".concat(lazyEvent.sortField), order);
|
|
692
|
+
}
|
|
693
|
+
return [4 /*yield*/, queryBuilder_2.getManyAndCount()];
|
|
694
|
+
case 1:
|
|
695
|
+
_c = _d.sent(), locals = _c[0], totalRecords = _c[1];
|
|
696
|
+
return [2 /*return*/, {
|
|
697
|
+
data: locals,
|
|
698
|
+
totalRecords: totalRecords,
|
|
699
|
+
}];
|
|
700
|
+
case 2:
|
|
701
|
+
error_2 = _d.sent();
|
|
702
|
+
return [2 /*return*/, false];
|
|
703
|
+
case 3: return [2 /*return*/];
|
|
704
|
+
}
|
|
705
|
+
});
|
|
706
|
+
});
|
|
707
|
+
};
|
|
523
708
|
CustomRepository.prototype.anyOtherRepository = function (args) {
|
|
524
709
|
return __awaiter(this, void 0, void 0, function () {
|
|
525
710
|
return __generator(this, function (_a) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CodeRedemptionHistoryCompany } from './CodeRedemptionHistoryCompany';
|
|
2
2
|
import { Master } from './Master';
|
|
3
|
+
import { ServicePlan } from './ServicePlan';
|
|
3
4
|
export declare class DiscountCodeCompany {
|
|
4
5
|
id: number;
|
|
5
6
|
code: string;
|
|
@@ -15,4 +16,5 @@ export declare class DiscountCodeCompany {
|
|
|
15
16
|
status: number;
|
|
16
17
|
updated_by: Master;
|
|
17
18
|
code_redemptions_history_company: CodeRedemptionHistoryCompany[];
|
|
19
|
+
servicePlans: ServicePlan[];
|
|
18
20
|
}
|
|
@@ -15,6 +15,7 @@ var dateTransformer_1 = require("../transformers/dateTransformer");
|
|
|
15
15
|
var jsonTransformer_1 = require("../transformers/jsonTransformer");
|
|
16
16
|
var CodeRedemptionHistoryCompany_1 = require("./CodeRedemptionHistoryCompany");
|
|
17
17
|
var Master_1 = require("./Master");
|
|
18
|
+
var ServicePlan_1 = require("./ServicePlan");
|
|
18
19
|
var DiscountCodeCompany = /** @class */ (function () {
|
|
19
20
|
function DiscountCodeCompany() {
|
|
20
21
|
}
|
|
@@ -115,6 +116,10 @@ var DiscountCodeCompany = /** @class */ (function () {
|
|
|
115
116
|
}),
|
|
116
117
|
__metadata("design:type", Array)
|
|
117
118
|
], DiscountCodeCompany.prototype, "code_redemptions_history_company", void 0);
|
|
119
|
+
__decorate([
|
|
120
|
+
(0, typeorm_1.OneToMany)(function () { return ServicePlan_1.ServicePlan; }, function (servicePlan) { return servicePlan.discount; }),
|
|
121
|
+
__metadata("design:type", Array)
|
|
122
|
+
], DiscountCodeCompany.prototype, "servicePlans", void 0);
|
|
118
123
|
DiscountCodeCompany = __decorate([
|
|
119
124
|
(0, typeorm_1.Entity)('discount_code_company', {
|
|
120
125
|
comment: 'Códigos de descuento para las empresas.',
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { DiscountCodeCompany } from './DiscountCodeCompany';
|
|
2
|
+
export declare class ServicePlan {
|
|
3
|
+
id_service_plan: number;
|
|
4
|
+
code: string;
|
|
5
|
+
description: string | null;
|
|
6
|
+
price: number | null;
|
|
7
|
+
currency: string | null;
|
|
8
|
+
status: number;
|
|
9
|
+
type: number;
|
|
10
|
+
time_periods: string | null;
|
|
11
|
+
assigned_discount: number | null;
|
|
12
|
+
discount: DiscountCodeCompany | null;
|
|
13
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
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.ServicePlan = void 0;
|
|
13
|
+
var typeorm_1 = require("typeorm");
|
|
14
|
+
var DiscountCodeCompany_1 = require("./DiscountCodeCompany"); // Asegúrate de ajustar el path al modelo correspondiente
|
|
15
|
+
var ServicePlan = /** @class */ (function () {
|
|
16
|
+
function ServicePlan() {
|
|
17
|
+
}
|
|
18
|
+
__decorate([
|
|
19
|
+
(0, typeorm_1.PrimaryGeneratedColumn)({ name: 'id_service_plan' }),
|
|
20
|
+
__metadata("design:type", Number)
|
|
21
|
+
], ServicePlan.prototype, "id_service_plan", void 0);
|
|
22
|
+
__decorate([
|
|
23
|
+
(0, typeorm_1.Column)({ type: 'varchar', length: 100 }),
|
|
24
|
+
__metadata("design:type", String)
|
|
25
|
+
], ServicePlan.prototype, "code", void 0);
|
|
26
|
+
__decorate([
|
|
27
|
+
(0, typeorm_1.Column)({ type: 'varchar', length: 450, nullable: true }),
|
|
28
|
+
__metadata("design:type", Object)
|
|
29
|
+
], ServicePlan.prototype, "description", void 0);
|
|
30
|
+
__decorate([
|
|
31
|
+
(0, typeorm_1.Column)({ type: 'float', nullable: true }),
|
|
32
|
+
__metadata("design:type", Object)
|
|
33
|
+
], ServicePlan.prototype, "price", void 0);
|
|
34
|
+
__decorate([
|
|
35
|
+
(0, typeorm_1.Column)({ type: 'varchar', length: 10, nullable: true }),
|
|
36
|
+
__metadata("design:type", Object)
|
|
37
|
+
], ServicePlan.prototype, "currency", void 0);
|
|
38
|
+
__decorate([
|
|
39
|
+
(0, typeorm_1.Column)({ type: 'int', default: 1 }),
|
|
40
|
+
__metadata("design:type", Number)
|
|
41
|
+
], ServicePlan.prototype, "status", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
(0, typeorm_1.Column)({ type: 'int' }),
|
|
44
|
+
__metadata("design:type", Number)
|
|
45
|
+
], ServicePlan.prototype, "type", void 0);
|
|
46
|
+
__decorate([
|
|
47
|
+
(0, typeorm_1.Column)({ type: 'text', nullable: true }),
|
|
48
|
+
__metadata("design:type", Object)
|
|
49
|
+
], ServicePlan.prototype, "time_periods", void 0);
|
|
50
|
+
__decorate([
|
|
51
|
+
(0, typeorm_1.Column)({ type: 'int', nullable: true }),
|
|
52
|
+
__metadata("design:type", Object)
|
|
53
|
+
], ServicePlan.prototype, "assigned_discount", void 0);
|
|
54
|
+
__decorate([
|
|
55
|
+
(0, typeorm_1.ManyToOne)(function () { return DiscountCodeCompany_1.DiscountCodeCompany; }, function (discount) { return discount.servicePlans; }, {
|
|
56
|
+
onDelete: 'CASCADE',
|
|
57
|
+
onUpdate: 'CASCADE',
|
|
58
|
+
}),
|
|
59
|
+
__metadata("design:type", Object)
|
|
60
|
+
], ServicePlan.prototype, "discount", void 0);
|
|
61
|
+
ServicePlan = __decorate([
|
|
62
|
+
(0, typeorm_1.Entity)('service_plan'),
|
|
63
|
+
(0, typeorm_1.Unique)(['code'])
|
|
64
|
+
], ServicePlan);
|
|
65
|
+
return ServicePlan;
|
|
66
|
+
}());
|
|
67
|
+
exports.ServicePlan = ServicePlan;
|
|
@@ -46,6 +46,7 @@ export { ReassignReview } from './entities/ReassignReview';
|
|
|
46
46
|
export { LocalPlan } from './entities/LocalPlan';
|
|
47
47
|
export { PartnerPermissionSection } from './entities/PartnerPermissionSection';
|
|
48
48
|
export { PartnerPlatform } from './entities/PartnerPlatform';
|
|
49
|
+
export { ServicePlan } from './entities/ServicePlan';
|
|
49
50
|
export { LocalsCompany } from './views/LocalsCompany';
|
|
50
51
|
export { VerifyLocals } from './views/VerifyLocals';
|
|
51
52
|
export { MasterNotifications } from './views/MasterNotifications';
|
|
@@ -14,8 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.
|
|
18
|
-
exports.CustomRepository = exports.DiscountsCodeUser = exports.Partners = exports.ViewLocalsCompanies = exports.MasterNotifications = void 0;
|
|
17
|
+
exports.LocalsCompany = exports.ServicePlan = exports.PartnerPlatform = exports.PartnerPermissionSection = exports.LocalPlan = exports.ReassignReview = exports.MasterNotification = exports.VerifyLocal = exports.PosSystem = exports.AuthenticationCredential = exports.BusinessType = exports.UserAddress = exports.User = exports.TypeMeasureIngredient = exports.TerminalSession = exports.Terminal = exports.Square = exports.RequestStatus = 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.PartnerPermission = 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.DiscountsCodeUser = exports.Partners = exports.ViewLocalsCompanies = exports.MasterNotifications = exports.VerifyLocals = 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");
|
|
@@ -112,6 +112,8 @@ var PartnerPermissionSection_1 = require("./entities/PartnerPermissionSection");
|
|
|
112
112
|
Object.defineProperty(exports, "PartnerPermissionSection", { enumerable: true, get: function () { return PartnerPermissionSection_1.PartnerPermissionSection; } });
|
|
113
113
|
var PartnerPlatform_1 = require("./entities/PartnerPlatform");
|
|
114
114
|
Object.defineProperty(exports, "PartnerPlatform", { enumerable: true, get: function () { return PartnerPlatform_1.PartnerPlatform; } });
|
|
115
|
+
var ServicePlan_1 = require("./entities/ServicePlan");
|
|
116
|
+
Object.defineProperty(exports, "ServicePlan", { enumerable: true, get: function () { return ServicePlan_1.ServicePlan; } });
|
|
115
117
|
var LocalsCompany_1 = require("./views/LocalsCompany");
|
|
116
118
|
Object.defineProperty(exports, "LocalsCompany", { enumerable: true, get: function () { return LocalsCompany_1.LocalsCompany; } });
|
|
117
119
|
var VerifyLocals_1 = require("./views/VerifyLocals");
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -23,6 +23,12 @@ export interface IBasicLazyEvent {
|
|
|
23
23
|
filters: any;
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
|
+
export interface IBasicCompany extends IBasicLazyEvent {
|
|
27
|
+
status: number | null;
|
|
28
|
+
company: number | null;
|
|
29
|
+
visible?: number | null;
|
|
30
|
+
owner?: number | null;
|
|
31
|
+
}
|
|
26
32
|
export interface IPropsQueryVerifyLocal {
|
|
27
33
|
status: number;
|
|
28
34
|
lazyEvent: {
|
package/package.json
CHANGED
package/src/CustomRepository.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DataSource, EntityTarget, Repository, ObjectLiteral } from 'typeorm'
|
|
2
2
|
import {
|
|
3
|
+
IBasicCompany,
|
|
3
4
|
IBasicLazyEvent,
|
|
4
5
|
IPropsDiscountUserOrCompany,
|
|
5
6
|
IPropsQueryVerifyLocal,
|
|
@@ -172,7 +173,7 @@ export class CustomRepository<T extends ObjectLiteral> extends Repository<T> {
|
|
|
172
173
|
if (lazyEvent.filters['global'] && lazyEvent.filters['global'].value) {
|
|
173
174
|
const globalValue = `%${lazyEvent.filters['global'].value.toLowerCase()}%`
|
|
174
175
|
queryBuilder.andWhere(
|
|
175
|
-
'LOWER(discount_code_user.local_name) LIKE :globalValue OR LOWER(partner_surname) LIKE :globalValue OR LOWER(discount_code_user.code) LIKE :globalValue OR LOWER(discount_code_user.discount) LIKE :globalValue OR LOWER(partner_name) LIKE :globalValue',
|
|
176
|
+
'(LOWER(discount_code_user.local_name) LIKE :globalValue OR LOWER(partner_surname) LIKE :globalValue OR LOWER(discount_code_user.code) LIKE :globalValue OR LOWER(discount_code_user.discount) LIKE :globalValue OR LOWER(partner_name) LIKE :globalValue)',
|
|
176
177
|
{
|
|
177
178
|
globalValue:
|
|
178
179
|
globalValue ||
|
|
@@ -596,6 +597,232 @@ export class CustomRepository<T extends ObjectLiteral> extends Repository<T> {
|
|
|
596
597
|
}
|
|
597
598
|
}
|
|
598
599
|
|
|
600
|
+
async getLocalsCompanyInformation({
|
|
601
|
+
company,
|
|
602
|
+
status,
|
|
603
|
+
visible,
|
|
604
|
+
lazyEvent,
|
|
605
|
+
}: IBasicCompany) {
|
|
606
|
+
try {
|
|
607
|
+
|
|
608
|
+
const timezone = getTimezoneOffset(getTimeZone())
|
|
609
|
+
|
|
610
|
+
const queryBuilder = this
|
|
611
|
+
.createQueryBuilder('view_locals_companies')
|
|
612
|
+
.skip(lazyEvent.first)
|
|
613
|
+
.take(lazyEvent.rows)
|
|
614
|
+
|
|
615
|
+
// DOC: Filtro global
|
|
616
|
+
if (lazyEvent.filters['global'] && lazyEvent.filters['global'].value) {
|
|
617
|
+
const globalValue = `%${lazyEvent.filters['global'].value.toLowerCase()}%`
|
|
618
|
+
queryBuilder.andWhere(
|
|
619
|
+
'(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)',
|
|
620
|
+
{
|
|
621
|
+
globalValue:
|
|
622
|
+
globalValue ||
|
|
623
|
+
getStatusBasic(lazyEvent.filters['global'].value.toLowerCase()),
|
|
624
|
+
}
|
|
625
|
+
)
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
// DOC: Filtro por estado FILTRO POR DEFECTO
|
|
629
|
+
if (status !== null && status >= 0) {
|
|
630
|
+
queryBuilder.andWhere('view_locals_companies.status = :status', {
|
|
631
|
+
status: status,
|
|
632
|
+
})
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
// DOC: Filtro por company FILTRO POR DEFECTO
|
|
636
|
+
if (company !== null && company >= 0) {
|
|
637
|
+
queryBuilder.andWhere('view_locals_companies.company = :company', {
|
|
638
|
+
company: company,
|
|
639
|
+
})
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
if (visible !== null) {
|
|
643
|
+
queryBuilder.andWhere('view_locals_companies.visible = :visible', {
|
|
644
|
+
visible: visible,
|
|
645
|
+
})
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
const filters = lazyEvent.filters
|
|
649
|
+
Object.keys(filters).forEach((key) => {
|
|
650
|
+
let value = filters[key].value
|
|
651
|
+
if (
|
|
652
|
+
(Array.isArray(value) && value.length > 0) ||
|
|
653
|
+
(!Array.isArray(value) && value && key !== 'global')
|
|
654
|
+
) {
|
|
655
|
+
const matchMode = filters[key].matchMode
|
|
656
|
+
if (!Array.isArray(value) && value) {
|
|
657
|
+
value = filters[key].value.toLowerCase()
|
|
658
|
+
}
|
|
659
|
+
const accessKey =
|
|
660
|
+
key.split('.').length > 1 ? `${key}` : `view_locals_companies.${key}`
|
|
661
|
+
|
|
662
|
+
switch (matchMode) {
|
|
663
|
+
case 'custom':
|
|
664
|
+
if (key === 'total_partners' && matchMode === 'custom') {
|
|
665
|
+
const [from, to] = value || [null, null]
|
|
666
|
+
|
|
667
|
+
if (from !== null && to === null) {
|
|
668
|
+
queryBuilder.andWhere(`view_locals_companies.${key} >= :from`, {
|
|
669
|
+
from,
|
|
670
|
+
})
|
|
671
|
+
} else if (from === null && to !== null) {
|
|
672
|
+
queryBuilder.andWhere(`view_locals_companies.${key} <= :to`, {
|
|
673
|
+
to,
|
|
674
|
+
})
|
|
675
|
+
} else if (from !== null && to !== null) {
|
|
676
|
+
queryBuilder.andWhere(
|
|
677
|
+
`view_locals_companies.${key} BETWEEN :from AND :to`,
|
|
678
|
+
{ from, to }
|
|
679
|
+
)
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
break
|
|
683
|
+
case 'contains':
|
|
684
|
+
queryBuilder.andWhere(`${accessKey} LIKE :${key}`, {
|
|
685
|
+
[key]: `%${value}%`,
|
|
686
|
+
})
|
|
687
|
+
break
|
|
688
|
+
case 'startsWith':
|
|
689
|
+
queryBuilder.andWhere(`${accessKey} LIKE :${key}`, {
|
|
690
|
+
[key]: `${value}%`,
|
|
691
|
+
})
|
|
692
|
+
break
|
|
693
|
+
case 'endsWith':
|
|
694
|
+
queryBuilder.andWhere(`${accessKey} LIKE :${key}`, {
|
|
695
|
+
[key]: `${value}%`,
|
|
696
|
+
})
|
|
697
|
+
break
|
|
698
|
+
case 'equals':
|
|
699
|
+
if (key === 'status') {
|
|
700
|
+
queryBuilder.andWhere('view_locals_companies.status = :status', {
|
|
701
|
+
status: getStatusBasic(filters[key].value ?? ''),
|
|
702
|
+
})
|
|
703
|
+
} else if (key === 'typeText') {
|
|
704
|
+
queryBuilder.andWhere('view_locals_companies.type = :type', {
|
|
705
|
+
type: getSeverityNameDiscountType(filters[key].value ?? ''),
|
|
706
|
+
})
|
|
707
|
+
} else if (key === 'has_square') {
|
|
708
|
+
const hasSI = filters[key].value.includes('SI')
|
|
709
|
+
const hasNO = filters[key].value.includes('NO')
|
|
710
|
+
|
|
711
|
+
const queryPlazolet =
|
|
712
|
+
hasSI && hasNO
|
|
713
|
+
? ''
|
|
714
|
+
: hasSI
|
|
715
|
+
? 'view_locals_companies.has_square IS NOT NULL'
|
|
716
|
+
: hasNO
|
|
717
|
+
? 'view_locals_companies.has_square IS NULL'
|
|
718
|
+
: ''
|
|
719
|
+
if (queryPlazolet !== '') {
|
|
720
|
+
queryBuilder.andWhere(queryPlazolet)
|
|
721
|
+
}
|
|
722
|
+
} else {
|
|
723
|
+
queryBuilder.andWhere(`${accessKey} = :${key}`, {
|
|
724
|
+
[key]: value,
|
|
725
|
+
})
|
|
726
|
+
}
|
|
727
|
+
break
|
|
728
|
+
case 'notContains':
|
|
729
|
+
queryBuilder.andWhere(`${accessKey} NOT LIKE :${key}`, {
|
|
730
|
+
[key]: `%${value}%`,
|
|
731
|
+
})
|
|
732
|
+
break
|
|
733
|
+
case 'notEquals':
|
|
734
|
+
queryBuilder.andWhere(`${accessKey} != :${key}`, {
|
|
735
|
+
[key]: value,
|
|
736
|
+
})
|
|
737
|
+
break
|
|
738
|
+
case 'dateIs':
|
|
739
|
+
queryBuilder.andWhere(
|
|
740
|
+
`${
|
|
741
|
+
key !== 'expiration' && key !== 'start'
|
|
742
|
+
? 'DATE(CONVERT_TZ('
|
|
743
|
+
: ''
|
|
744
|
+
} ${accessKey} ${
|
|
745
|
+
key !== 'expiration' && key !== 'start'
|
|
746
|
+
? `, '+00:00', '${timezone}'))`
|
|
747
|
+
: ''
|
|
748
|
+
} = :${key}`,
|
|
749
|
+
{
|
|
750
|
+
[key]: value.split('T')[0],
|
|
751
|
+
}
|
|
752
|
+
)
|
|
753
|
+
break
|
|
754
|
+
case 'dateIsNot':
|
|
755
|
+
queryBuilder.andWhere(
|
|
756
|
+
`${
|
|
757
|
+
key !== 'expiration' && key !== 'start'
|
|
758
|
+
? 'DATE(CONVERT_TZ('
|
|
759
|
+
: ''
|
|
760
|
+
} ${accessKey} ${
|
|
761
|
+
key !== 'expiration' && key !== 'start'
|
|
762
|
+
? `, '+00:00', '${timezone}'))`
|
|
763
|
+
: ''
|
|
764
|
+
} != :${key}`,
|
|
765
|
+
{
|
|
766
|
+
[key]: value.split('T')[0],
|
|
767
|
+
}
|
|
768
|
+
)
|
|
769
|
+
break
|
|
770
|
+
case 'dateBefore':
|
|
771
|
+
queryBuilder.andWhere(
|
|
772
|
+
`${
|
|
773
|
+
key !== 'expiration' && key !== 'start'
|
|
774
|
+
? 'DATE(CONVERT_TZ('
|
|
775
|
+
: ''
|
|
776
|
+
} ${accessKey} ${
|
|
777
|
+
key !== 'expiration' && key !== 'start'
|
|
778
|
+
? `, '+00:00', '${timezone}'))`
|
|
779
|
+
: ''
|
|
780
|
+
} < :${key}`,
|
|
781
|
+
{
|
|
782
|
+
[key]: value.split('T')[0],
|
|
783
|
+
}
|
|
784
|
+
)
|
|
785
|
+
break
|
|
786
|
+
case 'dateAfter':
|
|
787
|
+
queryBuilder.andWhere(
|
|
788
|
+
`${
|
|
789
|
+
key !== 'expiration' && key !== 'start'
|
|
790
|
+
? 'DATE(CONVERT_TZ('
|
|
791
|
+
: ''
|
|
792
|
+
} ${accessKey} ${
|
|
793
|
+
key !== 'expiration' && key !== 'start'
|
|
794
|
+
? `, '+00:00', '${timezone}'))`
|
|
795
|
+
: ''
|
|
796
|
+
} > :${key}`,
|
|
797
|
+
{
|
|
798
|
+
[key]: value.split('T')[0],
|
|
799
|
+
}
|
|
800
|
+
)
|
|
801
|
+
break
|
|
802
|
+
default:
|
|
803
|
+
break
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
})
|
|
807
|
+
|
|
808
|
+
if (lazyEvent.sortField) {
|
|
809
|
+
const order = lazyEvent.sortOrder === 1 ? 'ASC' : 'DESC'
|
|
810
|
+
queryBuilder.orderBy(
|
|
811
|
+
`view_locals_companies.${lazyEvent.sortField}`,
|
|
812
|
+
order
|
|
813
|
+
)
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
const [locals, totalRecords] = await queryBuilder.getManyAndCount()
|
|
817
|
+
return {
|
|
818
|
+
data: locals,
|
|
819
|
+
totalRecords,
|
|
820
|
+
}
|
|
821
|
+
} catch (error) {
|
|
822
|
+
return false
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
|
|
599
826
|
async anyOtherRepository(args: any) {
|
|
600
827
|
// Implementa otro método personalizado aquí
|
|
601
828
|
}
|
|
@@ -10,6 +10,7 @@ import { DateTransformer } from '../transformers/dateTransformer'
|
|
|
10
10
|
import { jsonTransformer } from '../transformers/jsonTransformer'
|
|
11
11
|
import { CodeRedemptionHistoryCompany } from './CodeRedemptionHistoryCompany'
|
|
12
12
|
import { Master } from './Master'
|
|
13
|
+
import { ServicePlan } from './ServicePlan'
|
|
13
14
|
|
|
14
15
|
@Entity('discount_code_company', {
|
|
15
16
|
comment: 'Códigos de descuento para las empresas.',
|
|
@@ -104,4 +105,7 @@ export class DiscountCodeCompany {
|
|
|
104
105
|
codeRedemptionHistoryCompany.discount_code_company
|
|
105
106
|
)
|
|
106
107
|
code_redemptions_history_company: CodeRedemptionHistoryCompany[]
|
|
108
|
+
|
|
109
|
+
@OneToMany(() => ServicePlan, (servicePlan) => servicePlan.discount)
|
|
110
|
+
servicePlans: ServicePlan[];
|
|
107
111
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Entity, PrimaryGeneratedColumn, Column, Unique, ManyToOne } from 'typeorm';
|
|
2
|
+
import { DiscountCodeCompany } from './DiscountCodeCompany'; // Asegúrate de ajustar el path al modelo correspondiente
|
|
3
|
+
|
|
4
|
+
@Entity('service_plan')
|
|
5
|
+
@Unique(['code'])
|
|
6
|
+
export class ServicePlan {
|
|
7
|
+
@PrimaryGeneratedColumn({ name: 'id_service_plan' })
|
|
8
|
+
id_service_plan: number;
|
|
9
|
+
|
|
10
|
+
@Column({ type: 'varchar', length: 100 })
|
|
11
|
+
code: string;
|
|
12
|
+
|
|
13
|
+
@Column({ type: 'varchar', length: 450, nullable: true })
|
|
14
|
+
description: string | null;
|
|
15
|
+
|
|
16
|
+
@Column({ type: 'float', nullable: true })
|
|
17
|
+
price: number | null;
|
|
18
|
+
|
|
19
|
+
@Column({ type: 'varchar', length: 10, nullable: true })
|
|
20
|
+
currency: string | null;
|
|
21
|
+
|
|
22
|
+
@Column({ type: 'int', default: 1 })
|
|
23
|
+
status: number;
|
|
24
|
+
|
|
25
|
+
@Column({ type: 'int' })
|
|
26
|
+
type: number;
|
|
27
|
+
|
|
28
|
+
@Column({ type: 'text', nullable: true })
|
|
29
|
+
time_periods: string | null;
|
|
30
|
+
|
|
31
|
+
@Column({ type: 'int', nullable: true })
|
|
32
|
+
assigned_discount: number | null;
|
|
33
|
+
|
|
34
|
+
@ManyToOne(() => DiscountCodeCompany, (discount) => discount.servicePlans, {
|
|
35
|
+
onDelete: 'CASCADE',
|
|
36
|
+
onUpdate: 'CASCADE',
|
|
37
|
+
})
|
|
38
|
+
discount: DiscountCodeCompany | null;
|
|
39
|
+
}
|
|
@@ -46,6 +46,7 @@ export { ReassignReview } from './entities/ReassignReview'
|
|
|
46
46
|
export { LocalPlan } from './entities/LocalPlan'
|
|
47
47
|
export { PartnerPermissionSection } from './entities/PartnerPermissionSection'
|
|
48
48
|
export { PartnerPlatform } from './entities/PartnerPlatform'
|
|
49
|
+
export { ServicePlan } from './entities/ServicePlan'
|
|
49
50
|
|
|
50
51
|
export { LocalsCompany } from './views/LocalsCompany'
|
|
51
52
|
export { VerifyLocals } from './views/VerifyLocals'
|
package/src/interfaces.ts
CHANGED
|
@@ -27,6 +27,13 @@ export interface IBasicLazyEvent {
|
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
export interface IBasicCompany extends IBasicLazyEvent {
|
|
31
|
+
status: number | null
|
|
32
|
+
company: number | null
|
|
33
|
+
visible?: number | null
|
|
34
|
+
owner?: number | null
|
|
35
|
+
}
|
|
36
|
+
|
|
30
37
|
export interface IPropsQueryVerifyLocal {
|
|
31
38
|
status: number
|
|
32
39
|
lazyEvent: {
|