@asumano/worklip-typeorm-db 1.1.52 → 1.1.54
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/entities/Master.d.ts +2 -0
- package/dist/entities/Master.js +16 -0
- package/dist/entities/MasterPermission.d.ts +11 -0
- package/dist/entities/MasterPermission.js +79 -0
- package/dist/entities/MasterPlatform.d.ts +10 -0
- package/dist/entities/MasterPlatform.js +83 -0
- package/dist/entities/MasterRole.d.ts +8 -0
- package/dist/entities/MasterRole.js +70 -0
- package/dist/entities/MasterSection.d.ts +10 -0
- package/dist/entities/MasterSection.js +73 -0
- package/dist/entities.index.d.ts +4 -0
- package/dist/entities.index.js +10 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -0
- package/dist/visit.summary.d.ts +81 -0
- package/dist/visit.summary.js +170 -0
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { City } from "./City";
|
|
2
|
+
import { MasterPermission } from "./MasterPermission";
|
|
2
3
|
import { MasterSession } from "./MasterSession";
|
|
3
4
|
export declare class Master {
|
|
4
5
|
id: number;
|
|
@@ -17,4 +18,5 @@ export declare class Master {
|
|
|
17
18
|
status: number;
|
|
18
19
|
visible: number;
|
|
19
20
|
master_sessions: MasterSession[];
|
|
21
|
+
permissions: MasterPermission[];
|
|
20
22
|
}
|
package/dist/entities/Master.js
CHANGED
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.Master = void 0;
|
|
13
13
|
const typeorm_1 = require("typeorm");
|
|
14
14
|
const City_1 = require("./City");
|
|
15
|
+
const MasterPermission_1 = require("./MasterPermission");
|
|
15
16
|
const MasterSession_1 = require("./MasterSession");
|
|
16
17
|
let Master = class Master {
|
|
17
18
|
};
|
|
@@ -146,6 +147,21 @@ __decorate([
|
|
|
146
147
|
(0, typeorm_1.OneToMany)(() => MasterSession_1.MasterSession, (masterSession) => masterSession.master),
|
|
147
148
|
__metadata("design:type", Array)
|
|
148
149
|
], Master.prototype, "master_sessions", void 0);
|
|
150
|
+
__decorate([
|
|
151
|
+
(0, typeorm_1.ManyToMany)(() => MasterPermission_1.MasterPermission, (permission) => permission.masters),
|
|
152
|
+
(0, typeorm_1.JoinTable)({
|
|
153
|
+
name: "master_assigned_permission",
|
|
154
|
+
joinColumn: {
|
|
155
|
+
name: "master",
|
|
156
|
+
referencedColumnName: "id",
|
|
157
|
+
},
|
|
158
|
+
inverseJoinColumn: {
|
|
159
|
+
name: "permission",
|
|
160
|
+
referencedColumnName: "id",
|
|
161
|
+
},
|
|
162
|
+
}),
|
|
163
|
+
__metadata("design:type", Array)
|
|
164
|
+
], Master.prototype, "permissions", void 0);
|
|
149
165
|
exports.Master = Master = __decorate([
|
|
150
166
|
(0, typeorm_1.Entity)({
|
|
151
167
|
comment: "Usuarios tipo administrador de la plataforma.",
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Master, MasterRole, MasterSection } from "../entities.views.routes";
|
|
2
|
+
export declare class MasterPermission {
|
|
3
|
+
id: number;
|
|
4
|
+
section: MasterSection;
|
|
5
|
+
name: string;
|
|
6
|
+
label: string;
|
|
7
|
+
icon: string;
|
|
8
|
+
status: number;
|
|
9
|
+
roles: MasterRole[];
|
|
10
|
+
masters: Master[];
|
|
11
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
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.MasterPermission = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
const entities_views_routes_1 = require("../entities.views.routes");
|
|
15
|
+
// DOC: Espejo de AssociatePermission para la plataforma administrativa.
|
|
16
|
+
// `name` es el string que valida el backend (convención ACCIÓN_SECCIÓN,
|
|
17
|
+
// p. ej. VIEW_COMPANY / CREATE_COMPANY) y el que consume el front desde
|
|
18
|
+
// global/permissions.ts.
|
|
19
|
+
let MasterPermission = class MasterPermission {
|
|
20
|
+
};
|
|
21
|
+
exports.MasterPermission = MasterPermission;
|
|
22
|
+
__decorate([
|
|
23
|
+
(0, typeorm_1.PrimaryGeneratedColumn)({
|
|
24
|
+
type: "int",
|
|
25
|
+
comment: "Número de identificación (ID) único de cada registro.",
|
|
26
|
+
}),
|
|
27
|
+
__metadata("design:type", Number)
|
|
28
|
+
], MasterPermission.prototype, "id", void 0);
|
|
29
|
+
__decorate([
|
|
30
|
+
(0, typeorm_1.ManyToOne)(() => entities_views_routes_1.MasterSection, (section) => section.permissions, {
|
|
31
|
+
onDelete: "CASCADE",
|
|
32
|
+
onUpdate: "NO ACTION",
|
|
33
|
+
}),
|
|
34
|
+
(0, typeorm_1.JoinColumn)({ name: "section" }),
|
|
35
|
+
__metadata("design:type", entities_views_routes_1.MasterSection)
|
|
36
|
+
], MasterPermission.prototype, "section", void 0);
|
|
37
|
+
__decorate([
|
|
38
|
+
(0, typeorm_1.Column)({ length: 50, type: "varchar", comment: "Nombre del permiso." }),
|
|
39
|
+
__metadata("design:type", String)
|
|
40
|
+
], MasterPermission.prototype, "name", void 0);
|
|
41
|
+
__decorate([
|
|
42
|
+
(0, typeorm_1.Column)({
|
|
43
|
+
length: 100,
|
|
44
|
+
type: "varchar",
|
|
45
|
+
comment: "Nombre que se va a mostrar en la página.",
|
|
46
|
+
}),
|
|
47
|
+
__metadata("design:type", String)
|
|
48
|
+
], MasterPermission.prototype, "label", void 0);
|
|
49
|
+
__decorate([
|
|
50
|
+
(0, typeorm_1.Column)({
|
|
51
|
+
length: 30,
|
|
52
|
+
type: "varchar",
|
|
53
|
+
comment: "Icono que se va a mostrar en la página.",
|
|
54
|
+
}),
|
|
55
|
+
__metadata("design:type", String)
|
|
56
|
+
], MasterPermission.prototype, "icon", void 0);
|
|
57
|
+
__decorate([
|
|
58
|
+
(0, typeorm_1.Column)({
|
|
59
|
+
default: 1,
|
|
60
|
+
type: "int",
|
|
61
|
+
width: 1,
|
|
62
|
+
comment: "Estado del registro.\r\n1: Activo.\r\n0: Inactivo.",
|
|
63
|
+
}),
|
|
64
|
+
__metadata("design:type", Number)
|
|
65
|
+
], MasterPermission.prototype, "status", void 0);
|
|
66
|
+
__decorate([
|
|
67
|
+
(0, typeorm_1.ManyToMany)(() => entities_views_routes_1.MasterRole, (role) => role.permissions),
|
|
68
|
+
__metadata("design:type", Array)
|
|
69
|
+
], MasterPermission.prototype, "roles", void 0);
|
|
70
|
+
__decorate([
|
|
71
|
+
(0, typeorm_1.ManyToMany)(() => entities_views_routes_1.Master, (master) => master.permissions),
|
|
72
|
+
__metadata("design:type", Array)
|
|
73
|
+
], MasterPermission.prototype, "masters", void 0);
|
|
74
|
+
exports.MasterPermission = MasterPermission = __decorate([
|
|
75
|
+
(0, typeorm_1.Entity)({
|
|
76
|
+
comment: "Permisos que va a tener el administrador.",
|
|
77
|
+
name: "master_permission",
|
|
78
|
+
})
|
|
79
|
+
], MasterPermission);
|
|
@@ -0,0 +1,83 @@
|
|
|
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.MasterPlatform = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
const entities_views_routes_1 = require("../entities.views.routes");
|
|
15
|
+
// DOC: Espejo de AssociatePlatform para la PLATAFORMA ADMINISTRATIVA. Se
|
|
16
|
+
// mantienen tablas separadas (master_*) en vez de reutilizar las de
|
|
17
|
+
// asociados porque son dos universos distintos: los permisos del operativo
|
|
18
|
+
// (visitas, talleres, plantillas) no tienen sentido para un administrador,
|
|
19
|
+
// y mezclarlos obligaría a filtrar por tipo de usuario en cada consulta.
|
|
20
|
+
let MasterPlatform = class MasterPlatform {
|
|
21
|
+
};
|
|
22
|
+
exports.MasterPlatform = MasterPlatform;
|
|
23
|
+
__decorate([
|
|
24
|
+
(0, typeorm_1.PrimaryGeneratedColumn)({
|
|
25
|
+
type: "int",
|
|
26
|
+
comment: "Número de identificación (ID) único de cada registro.",
|
|
27
|
+
}),
|
|
28
|
+
__metadata("design:type", Number)
|
|
29
|
+
], MasterPlatform.prototype, "id", void 0);
|
|
30
|
+
__decorate([
|
|
31
|
+
(0, typeorm_1.Column)({ length: 50, type: "varchar", comment: "Nombre de la plataforma." }),
|
|
32
|
+
__metadata("design:type", String)
|
|
33
|
+
], MasterPlatform.prototype, "name", void 0);
|
|
34
|
+
__decorate([
|
|
35
|
+
(0, typeorm_1.Column)({
|
|
36
|
+
length: 50,
|
|
37
|
+
type: "varchar",
|
|
38
|
+
comment: "Nombre que se va a mostrar en la página.",
|
|
39
|
+
}),
|
|
40
|
+
__metadata("design:type", String)
|
|
41
|
+
], MasterPlatform.prototype, "label", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
(0, typeorm_1.Column)({
|
|
44
|
+
length: 30,
|
|
45
|
+
type: "varchar",
|
|
46
|
+
comment: "Icono que se va a mostrar en la página.",
|
|
47
|
+
}),
|
|
48
|
+
__metadata("design:type", String)
|
|
49
|
+
], MasterPlatform.prototype, "icon", void 0);
|
|
50
|
+
__decorate([
|
|
51
|
+
(0, typeorm_1.Column)({
|
|
52
|
+
default: 1,
|
|
53
|
+
type: "int",
|
|
54
|
+
width: 1,
|
|
55
|
+
comment: "Estado del registro.\r\n1: Activo.\r\n0: Inactivo.",
|
|
56
|
+
}),
|
|
57
|
+
__metadata("design:type", Number)
|
|
58
|
+
], MasterPlatform.prototype, "status", void 0);
|
|
59
|
+
__decorate([
|
|
60
|
+
(0, typeorm_1.OneToMany)(() => entities_views_routes_1.MasterRole, (role) => role.platform),
|
|
61
|
+
__metadata("design:type", Array)
|
|
62
|
+
], MasterPlatform.prototype, "roles", void 0);
|
|
63
|
+
__decorate([
|
|
64
|
+
(0, typeorm_1.ManyToMany)(() => entities_views_routes_1.MasterSection, (section) => section.platforms),
|
|
65
|
+
(0, typeorm_1.JoinTable)({
|
|
66
|
+
name: "master_platform_section",
|
|
67
|
+
joinColumn: {
|
|
68
|
+
name: "platform",
|
|
69
|
+
referencedColumnName: "id",
|
|
70
|
+
},
|
|
71
|
+
inverseJoinColumn: {
|
|
72
|
+
name: "section",
|
|
73
|
+
referencedColumnName: "id",
|
|
74
|
+
},
|
|
75
|
+
}),
|
|
76
|
+
__metadata("design:type", Array)
|
|
77
|
+
], MasterPlatform.prototype, "sections", void 0);
|
|
78
|
+
exports.MasterPlatform = MasterPlatform = __decorate([
|
|
79
|
+
(0, typeorm_1.Entity)({
|
|
80
|
+
comment: "Plataformas que va a tener el administrador.",
|
|
81
|
+
name: "master_platform",
|
|
82
|
+
})
|
|
83
|
+
], MasterPlatform);
|
|
@@ -0,0 +1,70 @@
|
|
|
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.MasterRole = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
const entities_views_routes_1 = require("../entities.views.routes");
|
|
15
|
+
// DOC: Espejo de AssociateRole para la plataforma administrativa. El rol es una
|
|
16
|
+
// PLANTILLA de permisos: al crear un administrador se copian los permisos
|
|
17
|
+
// del rol a master_assigned_permission, que es lo que de verdad valida el
|
|
18
|
+
// backend (igual que en asociados).
|
|
19
|
+
let MasterRole = class MasterRole {
|
|
20
|
+
};
|
|
21
|
+
exports.MasterRole = MasterRole;
|
|
22
|
+
__decorate([
|
|
23
|
+
(0, typeorm_1.PrimaryGeneratedColumn)({
|
|
24
|
+
type: "int",
|
|
25
|
+
comment: "Número de identificación (ID) único de cada registro.",
|
|
26
|
+
}),
|
|
27
|
+
__metadata("design:type", Number)
|
|
28
|
+
], MasterRole.prototype, "id", void 0);
|
|
29
|
+
__decorate([
|
|
30
|
+
(0, typeorm_1.ManyToOne)(() => entities_views_routes_1.MasterPlatform, (platform) => platform.roles, {
|
|
31
|
+
onDelete: "CASCADE",
|
|
32
|
+
onUpdate: "NO ACTION",
|
|
33
|
+
}),
|
|
34
|
+
(0, typeorm_1.JoinColumn)({ name: "platform" }),
|
|
35
|
+
__metadata("design:type", entities_views_routes_1.MasterPlatform)
|
|
36
|
+
], MasterRole.prototype, "platform", void 0);
|
|
37
|
+
__decorate([
|
|
38
|
+
(0, typeorm_1.Column)({ length: 50, type: "varchar", comment: "Nombre del rol." }),
|
|
39
|
+
__metadata("design:type", String)
|
|
40
|
+
], MasterRole.prototype, "name", void 0);
|
|
41
|
+
__decorate([
|
|
42
|
+
(0, typeorm_1.Column)({
|
|
43
|
+
default: 1,
|
|
44
|
+
type: "int",
|
|
45
|
+
width: 1,
|
|
46
|
+
comment: "Estado del registro.\r\n1: Activo.\r\n0: Inactivo.",
|
|
47
|
+
}),
|
|
48
|
+
__metadata("design:type", Number)
|
|
49
|
+
], MasterRole.prototype, "status", void 0);
|
|
50
|
+
__decorate([
|
|
51
|
+
(0, typeorm_1.ManyToMany)(() => entities_views_routes_1.MasterPermission, (permission) => permission.roles),
|
|
52
|
+
(0, typeorm_1.JoinTable)({
|
|
53
|
+
name: "master_role_permission",
|
|
54
|
+
joinColumn: {
|
|
55
|
+
name: "role",
|
|
56
|
+
referencedColumnName: "id",
|
|
57
|
+
},
|
|
58
|
+
inverseJoinColumn: {
|
|
59
|
+
name: "permission",
|
|
60
|
+
referencedColumnName: "id",
|
|
61
|
+
},
|
|
62
|
+
}),
|
|
63
|
+
__metadata("design:type", Array)
|
|
64
|
+
], MasterRole.prototype, "permissions", void 0);
|
|
65
|
+
exports.MasterRole = MasterRole = __decorate([
|
|
66
|
+
(0, typeorm_1.Entity)({
|
|
67
|
+
comment: "Roles que va a tener el administrador.",
|
|
68
|
+
name: "master_role",
|
|
69
|
+
})
|
|
70
|
+
], MasterRole);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { MasterPermission, MasterPlatform } from "../entities.views.routes";
|
|
2
|
+
export declare class MasterSection {
|
|
3
|
+
id: number;
|
|
4
|
+
name: string;
|
|
5
|
+
label: string;
|
|
6
|
+
icon: string;
|
|
7
|
+
status: number;
|
|
8
|
+
platforms: MasterPlatform[];
|
|
9
|
+
permissions: MasterPermission[];
|
|
10
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
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.MasterSection = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
const entities_views_routes_1 = require("../entities.views.routes");
|
|
15
|
+
// DOC: Espejo de AssociateSection para la plataforma administrativa.
|
|
16
|
+
// Sección = agrupación de permisos (p. ej. EMPRESAS, PLANES, ADMINISTRADORES).
|
|
17
|
+
//
|
|
18
|
+
// Nota: el @JoinTable de la relación con plataformas vive en MasterPlatform
|
|
19
|
+
// (lado dueño). En AssociateSection está declarado en AMBOS lados, lo cual
|
|
20
|
+
// es redundante; aquí se deja solo en uno.
|
|
21
|
+
let MasterSection = class MasterSection {
|
|
22
|
+
};
|
|
23
|
+
exports.MasterSection = MasterSection;
|
|
24
|
+
__decorate([
|
|
25
|
+
(0, typeorm_1.PrimaryGeneratedColumn)({
|
|
26
|
+
type: "int",
|
|
27
|
+
comment: "Número de identificación (ID) único de cada registro.",
|
|
28
|
+
}),
|
|
29
|
+
__metadata("design:type", Number)
|
|
30
|
+
], MasterSection.prototype, "id", void 0);
|
|
31
|
+
__decorate([
|
|
32
|
+
(0, typeorm_1.Column)({ length: 50, type: "varchar", comment: "Nombre de la sección." }),
|
|
33
|
+
__metadata("design:type", String)
|
|
34
|
+
], MasterSection.prototype, "name", void 0);
|
|
35
|
+
__decorate([
|
|
36
|
+
(0, typeorm_1.Column)({
|
|
37
|
+
length: 100,
|
|
38
|
+
type: "varchar",
|
|
39
|
+
comment: "Nombre que se va a mostrar en la página.",
|
|
40
|
+
}),
|
|
41
|
+
__metadata("design:type", String)
|
|
42
|
+
], MasterSection.prototype, "label", void 0);
|
|
43
|
+
__decorate([
|
|
44
|
+
(0, typeorm_1.Column)({
|
|
45
|
+
length: 30,
|
|
46
|
+
type: "varchar",
|
|
47
|
+
comment: "Icono que se va a mostrar en la página.",
|
|
48
|
+
}),
|
|
49
|
+
__metadata("design:type", String)
|
|
50
|
+
], MasterSection.prototype, "icon", void 0);
|
|
51
|
+
__decorate([
|
|
52
|
+
(0, typeorm_1.Column)({
|
|
53
|
+
default: 1,
|
|
54
|
+
type: "int",
|
|
55
|
+
width: 1,
|
|
56
|
+
comment: "Estado del registro.\r\n1: Activo.\r\n0: Inactivo.",
|
|
57
|
+
}),
|
|
58
|
+
__metadata("design:type", Number)
|
|
59
|
+
], MasterSection.prototype, "status", void 0);
|
|
60
|
+
__decorate([
|
|
61
|
+
(0, typeorm_1.ManyToMany)(() => entities_views_routes_1.MasterPlatform, (platform) => platform.sections),
|
|
62
|
+
__metadata("design:type", Array)
|
|
63
|
+
], MasterSection.prototype, "platforms", void 0);
|
|
64
|
+
__decorate([
|
|
65
|
+
(0, typeorm_1.OneToMany)(() => entities_views_routes_1.MasterPermission, (permission) => permission.section),
|
|
66
|
+
__metadata("design:type", Array)
|
|
67
|
+
], MasterSection.prototype, "permissions", void 0);
|
|
68
|
+
exports.MasterSection = MasterSection = __decorate([
|
|
69
|
+
(0, typeorm_1.Entity)({
|
|
70
|
+
comment: "Secciones que va a tener el administrador.",
|
|
71
|
+
name: "master_section",
|
|
72
|
+
})
|
|
73
|
+
], MasterSection);
|
package/dist/entities.index.d.ts
CHANGED
|
@@ -24,6 +24,10 @@ export { AssociateRole } from "./entities/AssociateRole";
|
|
|
24
24
|
export { AssociatePermission } from "./entities/AssociatePermission";
|
|
25
25
|
export { AssociateSection } from "./entities/AssociateSection";
|
|
26
26
|
export { AssociatePasswordReset } from "./entities/AssociatePasswordReset";
|
|
27
|
+
export { MasterPlatform } from "./entities/MasterPlatform";
|
|
28
|
+
export { MasterRole } from "./entities/MasterRole";
|
|
29
|
+
export { MasterPermission } from "./entities/MasterPermission";
|
|
30
|
+
export { MasterSection } from "./entities/MasterSection";
|
|
27
31
|
export { VehicleType } from "./entities/VehicleType";
|
|
28
32
|
export { CompanyBrand } from "./entities/CompanyBrand";
|
|
29
33
|
export { CountryHoliday } from "./entities/CountryHoliday";
|
package/dist/entities.index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.WorkshopsByAssociate = exports.Workshops = void 0;
|
|
3
|
+
exports.Vehicles = exports.Clients = exports.ServicesOrder = exports.Associates = exports.UsageAlert = exports.SubscriptionAddonTemplate = exports.PaymentTransaction = exports.BillingInvoice = exports.EmailLog = exports.WhatsappLog = exports.ServiceOrderApproval = exports.MediaFile = exports.BillingUsageSnapshot = exports.PaymentMethod = exports.SubscriptionAddon = exports.CompanySubscription = exports.SubscriptionPlan = exports.CountryHoliday = exports.CompanyBrand = exports.VehicleType = exports.MasterSection = exports.MasterPermission = exports.MasterRole = exports.MasterPlatform = exports.AssociatePasswordReset = exports.AssociateSection = exports.AssociatePermission = exports.AssociateRole = exports.AssociatePlatform = exports.Reminder = exports.ServiceOrderHistory = exports.ServiceOrder = exports.TemplateSectionItem = exports.TemplateSection = exports.Template = exports.Workshop = exports.GlobalTemplateSectionItem = exports.GlobalTemplateSection = exports.GlobalTemplate = exports.AssociateSession = exports.MasterSession = exports.Associate = exports.Client = exports.Master = exports.Vehicle = exports.Brand = exports.Company = exports.City = exports.Region = exports.Country = void 0;
|
|
4
|
+
exports.WorkshopsByAssociate = exports.Workshops = exports.TemplateSectionItems = exports.TemplateSections = exports.Templates = exports.Reminders = void 0;
|
|
5
5
|
var Country_1 = require("./entities/Country");
|
|
6
6
|
Object.defineProperty(exports, "Country", { enumerable: true, get: function () { return Country_1.Country; } });
|
|
7
7
|
var Region_1 = require("./entities/Region");
|
|
@@ -54,6 +54,14 @@ var AssociateSection_1 = require("./entities/AssociateSection");
|
|
|
54
54
|
Object.defineProperty(exports, "AssociateSection", { enumerable: true, get: function () { return AssociateSection_1.AssociateSection; } });
|
|
55
55
|
var AssociatePasswordReset_1 = require("./entities/AssociatePasswordReset");
|
|
56
56
|
Object.defineProperty(exports, "AssociatePasswordReset", { enumerable: true, get: function () { return AssociatePasswordReset_1.AssociatePasswordReset; } });
|
|
57
|
+
var MasterPlatform_1 = require("./entities/MasterPlatform");
|
|
58
|
+
Object.defineProperty(exports, "MasterPlatform", { enumerable: true, get: function () { return MasterPlatform_1.MasterPlatform; } });
|
|
59
|
+
var MasterRole_1 = require("./entities/MasterRole");
|
|
60
|
+
Object.defineProperty(exports, "MasterRole", { enumerable: true, get: function () { return MasterRole_1.MasterRole; } });
|
|
61
|
+
var MasterPermission_1 = require("./entities/MasterPermission");
|
|
62
|
+
Object.defineProperty(exports, "MasterPermission", { enumerable: true, get: function () { return MasterPermission_1.MasterPermission; } });
|
|
63
|
+
var MasterSection_1 = require("./entities/MasterSection");
|
|
64
|
+
Object.defineProperty(exports, "MasterSection", { enumerable: true, get: function () { return MasterSection_1.MasterSection; } });
|
|
57
65
|
var VehicleType_1 = require("./entities/VehicleType");
|
|
58
66
|
Object.defineProperty(exports, "VehicleType", { enumerable: true, get: function () { return VehicleType_1.VehicleType; } });
|
|
59
67
|
var CompanyBrand_1 = require("./entities/CompanyBrand");
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DataSource, EntityTarget, ObjectLiteral, Repository } from "typeorm";
|
|
2
2
|
import { IBasicFilter } from "./types";
|
|
3
3
|
export * from "./entities.views.routes";
|
|
4
|
+
export * from "./visit.summary";
|
|
4
5
|
export declare function createDataBaseSource(): DataSource;
|
|
5
6
|
export declare function showEntityName<T extends ObjectLiteral>(entity: EntityTarget<T>): Promise<Repository<T>>;
|
|
6
7
|
export declare function callStoredProcedureName(storedProcedure: any, elements: any): Promise<any>;
|
package/dist/index.js
CHANGED
|
@@ -48,6 +48,9 @@ const typeorm_1 = require("typeorm");
|
|
|
48
48
|
const EntitiesViewsRoutes = __importStar(require("./entities.index"));
|
|
49
49
|
const entities_views_routes_1 = require("./entities.views.routes");
|
|
50
50
|
__exportStar(require("./entities.views.routes"), exports);
|
|
51
|
+
// DOC: Cálculo del resumen de la visita. Lo consumen el front (en vivo) y el API
|
|
52
|
+
// (al guardar), y tiene que ser la MISMA implementación en los dos.
|
|
53
|
+
__exportStar(require("./visit.summary"), exports);
|
|
51
54
|
let connection = null;
|
|
52
55
|
// DOC: Función para crear la conexión de la base de datos.
|
|
53
56
|
function createDataBaseSource() {
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
export type TItemStatus = "GOOD" | "REGULAR" | "BAD" | "NOT_APPLICABLE" | null;
|
|
2
|
+
export type TSummaryStatus = Exclude<TItemStatus, null> | "PENDING";
|
|
3
|
+
export type TCostApproval = "PENDING" | "APPROVED" | "REJECTED";
|
|
4
|
+
export interface IVisitCosts {
|
|
5
|
+
labor_cost: number;
|
|
6
|
+
replacement_cost: number;
|
|
7
|
+
total: number;
|
|
8
|
+
approval?: TCostApproval;
|
|
9
|
+
responded_at?: number | null;
|
|
10
|
+
}
|
|
11
|
+
export interface IVisitEvidence {
|
|
12
|
+
id: string;
|
|
13
|
+
type: "image" | "video";
|
|
14
|
+
key: string;
|
|
15
|
+
thumbnailKey?: string;
|
|
16
|
+
visible: boolean;
|
|
17
|
+
createdAt: number;
|
|
18
|
+
capturedAt?: number | null;
|
|
19
|
+
}
|
|
20
|
+
export interface IVisitItem {
|
|
21
|
+
id: string;
|
|
22
|
+
template_item_id: number | null;
|
|
23
|
+
custom_item: boolean;
|
|
24
|
+
name: string;
|
|
25
|
+
observation: string;
|
|
26
|
+
visible: boolean;
|
|
27
|
+
status: TItemStatus;
|
|
28
|
+
comments: string;
|
|
29
|
+
appointment_reminder?: string | Date | null;
|
|
30
|
+
costs: IVisitCosts | null;
|
|
31
|
+
evidence: IVisitEvidence[];
|
|
32
|
+
order: number;
|
|
33
|
+
}
|
|
34
|
+
export interface IVisitSection {
|
|
35
|
+
id: number;
|
|
36
|
+
name: string;
|
|
37
|
+
order: number;
|
|
38
|
+
items: IVisitItem[];
|
|
39
|
+
}
|
|
40
|
+
export interface IVisitData {
|
|
41
|
+
sections: IVisitSection[];
|
|
42
|
+
summary?: IVisitSummary;
|
|
43
|
+
}
|
|
44
|
+
export interface IVisitQuotationSummary {
|
|
45
|
+
servicePrice: number;
|
|
46
|
+
laborTotal: number;
|
|
47
|
+
replacementTotal: number;
|
|
48
|
+
quotedTotal: number;
|
|
49
|
+
approvedTotal: number;
|
|
50
|
+
rejectedTotal: number;
|
|
51
|
+
pendingTotal: number;
|
|
52
|
+
subtotal: number;
|
|
53
|
+
taxTotal: number;
|
|
54
|
+
totalToPay: number;
|
|
55
|
+
taxPercentage: number;
|
|
56
|
+
isTaxIncluded: boolean;
|
|
57
|
+
itemsQuoted: number;
|
|
58
|
+
itemsApproved: number;
|
|
59
|
+
itemsRejected: number;
|
|
60
|
+
itemsPending: number;
|
|
61
|
+
}
|
|
62
|
+
export interface IVisitSummary {
|
|
63
|
+
itemsTotal: number;
|
|
64
|
+
itemsReviewed: number;
|
|
65
|
+
progressPercentage: number;
|
|
66
|
+
statusCounts: Record<TSummaryStatus, number>;
|
|
67
|
+
vehicleHealthPercentage: number | null;
|
|
68
|
+
evidenceCount: number;
|
|
69
|
+
quotation: IVisitQuotationSummary;
|
|
70
|
+
}
|
|
71
|
+
export interface IPropsBuildVisitSummary {
|
|
72
|
+
servicePrice: number;
|
|
73
|
+
taxPercentage: number;
|
|
74
|
+
isTaxIncluded: boolean;
|
|
75
|
+
}
|
|
76
|
+
export declare const buildVisitSummary: (data: IVisitData | null | undefined, { servicePrice, taxPercentage, isTaxIncluded }: IPropsBuildVisitSummary) => IVisitSummary;
|
|
77
|
+
export declare const getTaxConfig: (companyDetails: any, countryDetails?: any) => {
|
|
78
|
+
taxPercentage: number;
|
|
79
|
+
isTaxIncluded: boolean;
|
|
80
|
+
};
|
|
81
|
+
export declare const preserveClientApprovals: (storedData: IVisitData | null | undefined, incomingData: IVisitData) => IVisitData;
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// DOC: Cálculo del resumen de una visita a partir de su JSON (service_order.data):
|
|
3
|
+
// avance de la revisión, conteo por estado, salud del vehículo y cotización.
|
|
4
|
+
//
|
|
5
|
+
// Vive en la librería compartida porque la necesitan los dos lados y tiene que dar
|
|
6
|
+
// EXACTAMENTE el mismo resultado: el front la usa para pintar en vivo mientras se
|
|
7
|
+
// edita la visita, y el API para recalcular y guardar el resumen en cada guardado.
|
|
8
|
+
// Si estuviera duplicada, el número que ve el usuario y el que queda guardado
|
|
9
|
+
// podrían desviarse.
|
|
10
|
+
//
|
|
11
|
+
// Es una función pura sobre el JSON: no toca la base de datos ni depende de TypeORM.
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.preserveClientApprovals = exports.getTaxConfig = exports.buildVisitSummary = void 0;
|
|
14
|
+
// DOC: Peso de cada estado para la "salud del vehículo". NOT_APPLICABLE y los
|
|
15
|
+
// ítems sin marcar quedan fuera del promedio.
|
|
16
|
+
const HEALTH_WEIGHT = {
|
|
17
|
+
GOOD: 100,
|
|
18
|
+
REGULAR: 50,
|
|
19
|
+
BAD: 0,
|
|
20
|
+
};
|
|
21
|
+
const round2 = (value) => Math.round(value * 100) / 100;
|
|
22
|
+
const buildVisitSummary = (data, { servicePrice, taxPercentage, isTaxIncluded }) => {
|
|
23
|
+
const statusCounts = {
|
|
24
|
+
GOOD: 0,
|
|
25
|
+
REGULAR: 0,
|
|
26
|
+
BAD: 0,
|
|
27
|
+
NOT_APPLICABLE: 0,
|
|
28
|
+
PENDING: 0,
|
|
29
|
+
};
|
|
30
|
+
let itemsTotal = 0;
|
|
31
|
+
let evidenceCount = 0;
|
|
32
|
+
let healthSum = 0;
|
|
33
|
+
let healthCount = 0;
|
|
34
|
+
let laborTotal = 0;
|
|
35
|
+
let replacementTotal = 0;
|
|
36
|
+
let approvedTotal = 0;
|
|
37
|
+
let rejectedTotal = 0;
|
|
38
|
+
let pendingTotal = 0;
|
|
39
|
+
let itemsQuoted = 0;
|
|
40
|
+
let itemsApproved = 0;
|
|
41
|
+
let itemsRejected = 0;
|
|
42
|
+
let itemsPending = 0;
|
|
43
|
+
for (const section of data?.sections ?? []) {
|
|
44
|
+
for (const item of section.items ?? []) {
|
|
45
|
+
// DOC: Un ítem oculto no va en el informe del cliente, así que no pide
|
|
46
|
+
// revisión ni se le cotiza nada.
|
|
47
|
+
if (item.visible === false)
|
|
48
|
+
continue;
|
|
49
|
+
itemsTotal++;
|
|
50
|
+
statusCounts[item.status ?? "PENDING"]++;
|
|
51
|
+
if (item.status && item.status in HEALTH_WEIGHT) {
|
|
52
|
+
healthSum += HEALTH_WEIGHT[item.status];
|
|
53
|
+
healthCount++;
|
|
54
|
+
}
|
|
55
|
+
evidenceCount += (item.evidence ?? []).filter((file) => file.visible !== false).length;
|
|
56
|
+
if (!item.costs)
|
|
57
|
+
continue;
|
|
58
|
+
const total = Number(item.costs.total) || 0;
|
|
59
|
+
itemsQuoted++;
|
|
60
|
+
laborTotal += Number(item.costs.labor_cost) || 0;
|
|
61
|
+
replacementTotal += Number(item.costs.replacement_cost) || 0;
|
|
62
|
+
const approval = item.costs.approval ?? "PENDING";
|
|
63
|
+
if (approval === "APPROVED") {
|
|
64
|
+
itemsApproved++;
|
|
65
|
+
approvedTotal += total;
|
|
66
|
+
}
|
|
67
|
+
else if (approval === "REJECTED") {
|
|
68
|
+
itemsRejected++;
|
|
69
|
+
rejectedTotal += total;
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
itemsPending++;
|
|
73
|
+
pendingTotal += total;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const itemsReviewed = itemsTotal - statusCounts.PENDING;
|
|
78
|
+
// DOC: Lo que efectivamente se va a cobrar: el servicio fijo de la visita más
|
|
79
|
+
// las reparaciones que el cliente aprobó. Lo pendiente y lo rechazado no entran.
|
|
80
|
+
const chargeable = round2((Number(servicePrice) || 0) + approvedTotal);
|
|
81
|
+
const rate = (Number(taxPercentage) || 0) / 100;
|
|
82
|
+
let subtotal = chargeable;
|
|
83
|
+
let taxTotal = 0;
|
|
84
|
+
let totalToPay = chargeable;
|
|
85
|
+
if (rate > 0) {
|
|
86
|
+
if (isTaxIncluded) {
|
|
87
|
+
// DOC: Los valores digitados ya traen el impuesto: se desglosa hacia atrás.
|
|
88
|
+
// El impuesto se calcula como total - base para que la suma cuadre
|
|
89
|
+
// exacto con el total.
|
|
90
|
+
subtotal = round2(chargeable / (1 + rate));
|
|
91
|
+
taxTotal = round2(chargeable - subtotal);
|
|
92
|
+
totalToPay = chargeable;
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
taxTotal = round2(chargeable * rate);
|
|
96
|
+
totalToPay = round2(chargeable + taxTotal);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
itemsTotal,
|
|
101
|
+
itemsReviewed,
|
|
102
|
+
progressPercentage: itemsTotal === 0 ? 0 : Math.round((itemsReviewed / itemsTotal) * 100),
|
|
103
|
+
statusCounts,
|
|
104
|
+
vehicleHealthPercentage: healthCount === 0 ? null : Math.round(healthSum / healthCount),
|
|
105
|
+
evidenceCount,
|
|
106
|
+
quotation: {
|
|
107
|
+
servicePrice: round2(Number(servicePrice) || 0),
|
|
108
|
+
laborTotal: round2(laborTotal),
|
|
109
|
+
replacementTotal: round2(replacementTotal),
|
|
110
|
+
quotedTotal: round2(approvedTotal + rejectedTotal + pendingTotal),
|
|
111
|
+
approvedTotal: round2(approvedTotal),
|
|
112
|
+
rejectedTotal: round2(rejectedTotal),
|
|
113
|
+
pendingTotal: round2(pendingTotal),
|
|
114
|
+
subtotal,
|
|
115
|
+
taxTotal,
|
|
116
|
+
totalToPay,
|
|
117
|
+
taxPercentage: Number(taxPercentage) || 0,
|
|
118
|
+
isTaxIncluded,
|
|
119
|
+
itemsQuoted,
|
|
120
|
+
itemsApproved,
|
|
121
|
+
itemsRejected,
|
|
122
|
+
itemsPending,
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
exports.buildVisitSummary = buildVisitSummary;
|
|
127
|
+
// DOC: Configuración de impuesto de la empresa dueña de la visita, con la tarifa
|
|
128
|
+
// del país como respaldo. Si no hay tarifa, no se aplica impuesto.
|
|
129
|
+
const getTaxConfig = (companyDetails, countryDetails) => {
|
|
130
|
+
const company = companyDetails || {};
|
|
131
|
+
const country = countryDetails || {};
|
|
132
|
+
return {
|
|
133
|
+
taxPercentage: Number(company.tax_percentage ?? country.tax_percentage ?? 0) || 0,
|
|
134
|
+
isTaxIncluded: company.is_tax_included ?? true,
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
exports.getTaxConfig = getTaxConfig;
|
|
138
|
+
// DOC: La respuesta del cliente (aprobar/rechazar) es SUYA, no del formulario del
|
|
139
|
+
// asesor. El asesor autoguarda todo el `data` cada pocos segundos con la copia que
|
|
140
|
+
// tenía cargada, así que si no se protegen estos campos, un autoguardado borraría
|
|
141
|
+
// una aprobación que llegó en el intermedio.
|
|
142
|
+
//
|
|
143
|
+
// Regla: se conserva la respuesta guardada en la base de datos, salvo que el
|
|
144
|
+
// asesor haya cambiado el valor cotizado — ahí vuelve a PENDING, porque nadie
|
|
145
|
+
// puede quedar avalando un monto distinto al que aceptó.
|
|
146
|
+
const preserveClientApprovals = (storedData, incomingData) => {
|
|
147
|
+
const storedCosts = new Map();
|
|
148
|
+
for (const section of storedData?.sections ?? []) {
|
|
149
|
+
for (const item of section.items ?? []) {
|
|
150
|
+
if (item.costs)
|
|
151
|
+
storedCosts.set(item.id, item.costs);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
if (storedCosts.size === 0)
|
|
155
|
+
return incomingData;
|
|
156
|
+
for (const section of incomingData?.sections ?? []) {
|
|
157
|
+
for (const item of section.items ?? []) {
|
|
158
|
+
if (!item.costs)
|
|
159
|
+
continue;
|
|
160
|
+
const stored = storedCosts.get(item.id);
|
|
161
|
+
if (!stored)
|
|
162
|
+
continue;
|
|
163
|
+
const hasChanged = (Number(item.costs.total) || 0) !== (Number(stored.total) || 0);
|
|
164
|
+
item.costs.approval = hasChanged ? "PENDING" : (stored.approval ?? "PENDING");
|
|
165
|
+
item.costs.responded_at = hasChanged ? null : (stored.responded_at ?? null);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return incomingData;
|
|
169
|
+
};
|
|
170
|
+
exports.preserveClientApprovals = preserveClientApprovals;
|