@asumano/worklip-typeorm-db 1.1.110 → 1.1.112
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/ServiceOrderStage.d.ts +1 -0
- package/dist/entities/ServiceOrderStage.js +11 -2
- package/dist/entities/VehicleMeasurement.d.ts +4 -0
- package/dist/entities/VehicleMeasurement.js +38 -3
- package/dist/entities/WhatsappLine.d.ts +1 -0
- package/dist/entities/WhatsappLine.js +9 -0
- package/dist/entities/WorkshopEquipment.d.ts +1 -0
- package/dist/entities/WorkshopEquipment.js +21 -3
- package/dist/entities/WorkshopReportInbox.d.ts +1 -0
- package/dist/entities/WorkshopReportInbox.js +17 -2
- package/dist/entities/WorkshopUnknownDevice.d.ts +15 -0
- package/dist/entities/WorkshopUnknownDevice.js +83 -0
- package/dist/entities.index.d.ts +1 -0
- package/dist/entities.index.js +3 -1
- package/dist/rules/equipment.rules.d.ts +35 -1
- package/dist/rules/equipment.rules.js +134 -4
- package/dist/rules/payroll.rules.d.ts +2 -1
- package/dist/rules/payroll.rules.js +6 -1
- package/dist/rules/visit.history.rules.d.ts +9 -2
- package/dist/rules/visit.history.rules.js +29 -7
- package/package.json +1 -1
|
@@ -49,6 +49,7 @@ export declare class ServiceOrderStage {
|
|
|
49
49
|
pay_rate: string | null;
|
|
50
50
|
pay_amount: string | null;
|
|
51
51
|
income_hours: string | null;
|
|
52
|
+
income_unit: number | null;
|
|
52
53
|
income_rate: string | null;
|
|
53
54
|
income_amount: string | null;
|
|
54
55
|
payroll_updated_by: Associate | null;
|
|
@@ -241,10 +241,19 @@ __decorate([
|
|
|
241
241
|
scale: 2,
|
|
242
242
|
default: null,
|
|
243
243
|
nullable: true,
|
|
244
|
-
comment: "Horas que paga la aseguradora (
|
|
244
|
+
comment: "Horas o piezas que paga la aseguradora (según income_unit). NULL en particular: el ingreso se escribe directo.",
|
|
245
245
|
}),
|
|
246
246
|
__metadata("design:type", Object)
|
|
247
247
|
], ServiceOrderStage.prototype, "income_hours", void 0);
|
|
248
|
+
__decorate([
|
|
249
|
+
(0, typeorm_1.Column)({
|
|
250
|
+
type: "int",
|
|
251
|
+
default: null,
|
|
252
|
+
nullable: true,
|
|
253
|
+
comment: "Cómo paga la aseguradora la etapa.\n1: Por hora.\n3: Por pieza o trabajo.\nNULL: por hora (etapas de antes de sql/98).",
|
|
254
|
+
}),
|
|
255
|
+
__metadata("design:type", Object)
|
|
256
|
+
], ServiceOrderStage.prototype, "income_unit", void 0);
|
|
248
257
|
__decorate([
|
|
249
258
|
(0, typeorm_1.Column)({
|
|
250
259
|
type: "decimal",
|
|
@@ -252,7 +261,7 @@ __decorate([
|
|
|
252
261
|
scale: 2,
|
|
253
262
|
default: null,
|
|
254
263
|
nullable: true,
|
|
255
|
-
comment: "Valor hora de la aseguradora
|
|
264
|
+
comment: "Valor hora de la aseguradora (carrocería o pintura) o valor por pieza escrito a mano.",
|
|
256
265
|
}),
|
|
257
266
|
__metadata("design:type", Object)
|
|
258
267
|
], ServiceOrderStage.prototype, "income_rate", void 0);
|
|
@@ -25,6 +25,10 @@ export declare class VehicleMeasurement {
|
|
|
25
25
|
result: number | null;
|
|
26
26
|
data: any | null;
|
|
27
27
|
summary: string | null;
|
|
28
|
+
workshop_note: string | null;
|
|
29
|
+
client_note: string | null;
|
|
30
|
+
show_client: number;
|
|
31
|
+
health_pct: number | null;
|
|
28
32
|
files: any | null;
|
|
29
33
|
vin: string | null;
|
|
30
34
|
vin_check: number | null;
|
|
@@ -74,7 +74,7 @@ __decorate([
|
|
|
74
74
|
__metadata("design:type", Number)
|
|
75
75
|
], VehicleMeasurement.prototype, "moment", void 0);
|
|
76
76
|
__decorate([
|
|
77
|
-
(0, typeorm_1.Column)({ type: "int", comment: "Fuente:\r\n1: Foto.\r\n2: PDF.\r\n3: En vivo (adaptador OBD2).\r\n4:
|
|
77
|
+
(0, typeorm_1.Column)({ type: "int", comment: "Fuente:\r\n1: Foto.\r\n2: PDF.\r\n3: En vivo (adaptador OBD2).\r\n4: Escrita a mano (sin IA)." }),
|
|
78
78
|
__metadata("design:type", Number)
|
|
79
79
|
], VehicleMeasurement.prototype, "source", void 0);
|
|
80
80
|
__decorate([
|
|
@@ -94,18 +94,53 @@ __decorate([
|
|
|
94
94
|
type: "int",
|
|
95
95
|
nullable: true,
|
|
96
96
|
default: null,
|
|
97
|
-
comment: "Resultado:\r\n1: Bueno.\r\n2: Regular.\r\n3: Malo.\r\nNULL: sin evaluar.",
|
|
97
|
+
comment: "Resultado sugerido:\r\n1: Bueno.\r\n2: Regular.\r\n3: Malo.\r\n4: No aplica.\r\nNULL: sin evaluar.",
|
|
98
98
|
}),
|
|
99
99
|
__metadata("design:type", Object)
|
|
100
100
|
], VehicleMeasurement.prototype, "result", void 0);
|
|
101
101
|
__decorate([
|
|
102
|
-
(0, typeorm_1.Column)({
|
|
102
|
+
(0, typeorm_1.Column)({
|
|
103
|
+
type: "json",
|
|
104
|
+
nullable: true,
|
|
105
|
+
default: null,
|
|
106
|
+
comment: "Lectura con la forma del tipo de equipo. Solo las mediciones de antes de sql/96; las nuevas usan las observaciones.",
|
|
107
|
+
}),
|
|
103
108
|
__metadata("design:type", Object)
|
|
104
109
|
], VehicleMeasurement.prototype, "data", void 0);
|
|
105
110
|
__decorate([
|
|
106
111
|
(0, typeorm_1.Column)({ type: "varchar", length: 255, nullable: true, default: null, comment: "Resumen corto de la lectura." }),
|
|
107
112
|
__metadata("design:type", Object)
|
|
108
113
|
], VehicleMeasurement.prototype, "summary", void 0);
|
|
114
|
+
__decorate([
|
|
115
|
+
(0, typeorm_1.Column)({
|
|
116
|
+
type: "text",
|
|
117
|
+
nullable: true,
|
|
118
|
+
default: null,
|
|
119
|
+
comment: "Observación del taller: detallada, no la ve el cliente y entra al historial inteligente.",
|
|
120
|
+
}),
|
|
121
|
+
__metadata("design:type", Object)
|
|
122
|
+
], VehicleMeasurement.prototype, "workshop_note", void 0);
|
|
123
|
+
__decorate([
|
|
124
|
+
(0, typeorm_1.Column)({ type: "varchar", length: 150, nullable: true, default: null, comment: "Observación para el cliente: corta y en palabras sencillas." }),
|
|
125
|
+
__metadata("design:type", Object)
|
|
126
|
+
], VehicleMeasurement.prototype, "client_note", void 0);
|
|
127
|
+
__decorate([
|
|
128
|
+
(0, typeorm_1.Column)({
|
|
129
|
+
type: "int",
|
|
130
|
+
default: 0,
|
|
131
|
+
comment: "Mostrar al cliente:\r\n1: Sí (la observación para el cliente sale en su informe).\r\n0: No.",
|
|
132
|
+
}),
|
|
133
|
+
__metadata("design:type", Number)
|
|
134
|
+
], VehicleMeasurement.prototype, "show_client", void 0);
|
|
135
|
+
__decorate([
|
|
136
|
+
(0, typeorm_1.Column)({
|
|
137
|
+
type: "int",
|
|
138
|
+
nullable: true,
|
|
139
|
+
default: null,
|
|
140
|
+
comment: "Salud de la batería en % (solo probador de baterías): arma la gráfica del historial.",
|
|
141
|
+
}),
|
|
142
|
+
__metadata("design:type", Object)
|
|
143
|
+
], VehicleMeasurement.prototype, "health_pct", void 0);
|
|
109
144
|
__decorate([
|
|
110
145
|
(0, typeorm_1.Column)({ type: "json", nullable: true, default: null, comment: "Fotos y PDF de la medición (llaves de R2)." }),
|
|
111
146
|
__metadata("design:type", Object)
|
|
@@ -98,6 +98,15 @@ __decorate([
|
|
|
98
98
|
}),
|
|
99
99
|
__metadata("design:type", Object)
|
|
100
100
|
], WhatsappLine.prototype, "token_ref", void 0);
|
|
101
|
+
__decorate([
|
|
102
|
+
(0, typeorm_1.Column)({
|
|
103
|
+
type: "text",
|
|
104
|
+
nullable: true,
|
|
105
|
+
default: null,
|
|
106
|
+
comment: "Secreto de la app de Meta de la empresa, cifrado. Verifica la firma del webhook. Solo en el modo propio.",
|
|
107
|
+
}),
|
|
108
|
+
__metadata("design:type", Object)
|
|
109
|
+
], WhatsappLine.prototype, "app_secret_ref", void 0);
|
|
101
110
|
__decorate([
|
|
102
111
|
(0, typeorm_1.Column)({
|
|
103
112
|
type: "json",
|
|
@@ -15,7 +15,8 @@ const Associate_1 = require("./Associate");
|
|
|
15
15
|
const Company_1 = require("./Company");
|
|
16
16
|
const EquipmentType_1 = require("./EquipmentType");
|
|
17
17
|
const Workshop_1 = require("./Workshop");
|
|
18
|
-
// DOC: Los equipos que la sede registra (sql/81).
|
|
18
|
+
// DOC: Los equipos que la sede registra (sql/81). Desde sql/96 son obligatorios para medir y llevan serial:
|
|
19
|
+
// con él se reconoce el equipo en un reporte por correo.
|
|
19
20
|
let WorkshopEquipment = class WorkshopEquipment {
|
|
20
21
|
};
|
|
21
22
|
exports.WorkshopEquipment = WorkshopEquipment;
|
|
@@ -51,9 +52,25 @@ __decorate([
|
|
|
51
52
|
__metadata("design:type", Object)
|
|
52
53
|
], WorkshopEquipment.prototype, "model", void 0);
|
|
53
54
|
__decorate([
|
|
54
|
-
(0, typeorm_1.Column)({
|
|
55
|
+
(0, typeorm_1.Column)({
|
|
56
|
+
type: "varchar",
|
|
57
|
+
length: 60,
|
|
58
|
+
nullable: true,
|
|
59
|
+
default: null,
|
|
60
|
+
comment: "Número de serie del equipo, como lo escribió el taller. Obligatorio desde sql/96 (los de antes pueden no tenerlo).",
|
|
61
|
+
}),
|
|
55
62
|
__metadata("design:type", Object)
|
|
56
63
|
], WorkshopEquipment.prototype, "serial", void 0);
|
|
64
|
+
__decorate([
|
|
65
|
+
(0, typeorm_1.Column)({
|
|
66
|
+
type: "varchar",
|
|
67
|
+
length: 60,
|
|
68
|
+
nullable: true,
|
|
69
|
+
default: null,
|
|
70
|
+
comment: "El serial sin espacios ni símbolos, en mayúsculas: con él se reconoce el equipo en un reporte por correo.",
|
|
71
|
+
}),
|
|
72
|
+
__metadata("design:type", Object)
|
|
73
|
+
], WorkshopEquipment.prototype, "serial_key", void 0);
|
|
57
74
|
__decorate([
|
|
58
75
|
(0, typeorm_1.Column)({ type: "int", width: 1, default: 1, comment: "Estado:\r\n1: Activo.\r\n0: Inactivo (no se ofrece al medir)." }),
|
|
59
76
|
__metadata("design:type", Number)
|
|
@@ -79,5 +96,6 @@ __decorate([
|
|
|
79
96
|
], WorkshopEquipment.prototype, "updated", void 0);
|
|
80
97
|
exports.WorkshopEquipment = WorkshopEquipment = __decorate([
|
|
81
98
|
(0, typeorm_1.Entity)({ comment: "Equipos de cada sede: tipo, marca, modelo y serial.", name: "workshop_equipment" }),
|
|
82
|
-
(0, typeorm_1.Index)("IDX_workshop_equipment_workshop", ["workshop", "status"])
|
|
99
|
+
(0, typeorm_1.Index)("IDX_workshop_equipment_workshop", ["workshop", "status"]),
|
|
100
|
+
(0, typeorm_1.Unique)("UQ_workshop_equipment_serial", ["company", "serial_key"])
|
|
83
101
|
], WorkshopEquipment);
|
|
@@ -33,9 +33,23 @@ __decorate([
|
|
|
33
33
|
__metadata("design:type", Workshop_1.Workshop)
|
|
34
34
|
], WorkshopReportInbox.prototype, "workshop", void 0);
|
|
35
35
|
__decorate([
|
|
36
|
-
(0, typeorm_1.Column)({
|
|
36
|
+
(0, typeorm_1.Column)({
|
|
37
|
+
type: "varchar",
|
|
38
|
+
length: 64,
|
|
39
|
+
comment: "Parte local de la dirección (antes de la @), en minúsculas. Desde sql/96 es un código corto que el API genera al abrir la pestaña.",
|
|
40
|
+
}),
|
|
37
41
|
__metadata("design:type", String)
|
|
38
42
|
], WorkshopReportInbox.prototype, "address", void 0);
|
|
43
|
+
__decorate([
|
|
44
|
+
(0, typeorm_1.Column)({
|
|
45
|
+
type: "varchar",
|
|
46
|
+
length: 64,
|
|
47
|
+
nullable: true,
|
|
48
|
+
default: null,
|
|
49
|
+
comment: "La dirección larga de antes de sql/96: sigue recibiendo hasta que la sede cambie la dirección.",
|
|
50
|
+
}),
|
|
51
|
+
__metadata("design:type", Object)
|
|
52
|
+
], WorkshopReportInbox.prototype, "legacy_address", void 0);
|
|
39
53
|
__decorate([
|
|
40
54
|
(0, typeorm_1.Column)({ type: "int", width: 1, default: 1, comment: "Estado:\r\n1: Recibe reportes.\r\n0: Apagada (se ignoran)." }),
|
|
41
55
|
__metadata("design:type", Number)
|
|
@@ -61,5 +75,6 @@ __decorate([
|
|
|
61
75
|
exports.WorkshopReportInbox = WorkshopReportInbox = __decorate([
|
|
62
76
|
(0, typeorm_1.Entity)({ comment: "Dirección de correo de cada sede para recibir reportes de equipos.", name: "workshop_report_inbox" }),
|
|
63
77
|
(0, typeorm_1.Unique)("UQ_workshop_report_inbox_workshop", ["workshop"]),
|
|
64
|
-
(0, typeorm_1.Unique)("UQ_workshop_report_inbox_address", ["address"])
|
|
78
|
+
(0, typeorm_1.Unique)("UQ_workshop_report_inbox_address", ["address"]),
|
|
79
|
+
(0, typeorm_1.Unique)("UQ_workshop_report_inbox_legacy", ["legacy_address"])
|
|
65
80
|
], WorkshopReportInbox);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Company } from "./Company";
|
|
2
|
+
import { Workshop } from "./Workshop";
|
|
3
|
+
export declare class WorkshopUnknownDevice {
|
|
4
|
+
id: number;
|
|
5
|
+
company: Company;
|
|
6
|
+
workshop: Workshop;
|
|
7
|
+
serial: string;
|
|
8
|
+
serial_key: string;
|
|
9
|
+
sender: string | null;
|
|
10
|
+
subject: string | null;
|
|
11
|
+
reports: number;
|
|
12
|
+
status: number;
|
|
13
|
+
created: Date;
|
|
14
|
+
updated: Date | null;
|
|
15
|
+
}
|
|
@@ -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.WorkshopUnknownDevice = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
const Company_1 = require("./Company");
|
|
15
|
+
const Workshop_1 = require("./Workshop");
|
|
16
|
+
// DOC: Un equipo que mandó reportes por correo sin estar registrado en la sede (sql/96). El reporte NO se lee
|
|
17
|
+
// (ni gasta cupo): la sede decide si lo registra (desde ahí sus reportes entran) o lo ignora.
|
|
18
|
+
let WorkshopUnknownDevice = class WorkshopUnknownDevice {
|
|
19
|
+
};
|
|
20
|
+
exports.WorkshopUnknownDevice = WorkshopUnknownDevice;
|
|
21
|
+
__decorate([
|
|
22
|
+
(0, typeorm_1.PrimaryGeneratedColumn)({ type: "int", comment: "Número de identificación (ID) único de cada registro." }),
|
|
23
|
+
__metadata("design:type", Number)
|
|
24
|
+
], WorkshopUnknownDevice.prototype, "id", void 0);
|
|
25
|
+
__decorate([
|
|
26
|
+
(0, typeorm_1.ManyToOne)(() => Company_1.Company, { onDelete: "CASCADE", onUpdate: "NO ACTION" }),
|
|
27
|
+
(0, typeorm_1.JoinColumn)({ name: "company" }),
|
|
28
|
+
__metadata("design:type", Company_1.Company)
|
|
29
|
+
], WorkshopUnknownDevice.prototype, "company", void 0);
|
|
30
|
+
__decorate([
|
|
31
|
+
(0, typeorm_1.ManyToOne)(() => Workshop_1.Workshop, { onDelete: "CASCADE", onUpdate: "NO ACTION" }),
|
|
32
|
+
(0, typeorm_1.JoinColumn)({ name: "workshop" }),
|
|
33
|
+
__metadata("design:type", Workshop_1.Workshop)
|
|
34
|
+
], WorkshopUnknownDevice.prototype, "workshop", void 0);
|
|
35
|
+
__decorate([
|
|
36
|
+
(0, typeorm_1.Column)({ type: "varchar", length: 60, comment: "Serial tal como venía en el correo." }),
|
|
37
|
+
__metadata("design:type", String)
|
|
38
|
+
], WorkshopUnknownDevice.prototype, "serial", void 0);
|
|
39
|
+
__decorate([
|
|
40
|
+
(0, typeorm_1.Column)({ type: "varchar", length: 60, comment: "El serial sin espacios ni símbolos, en mayúsculas." }),
|
|
41
|
+
__metadata("design:type", String)
|
|
42
|
+
], WorkshopUnknownDevice.prototype, "serial_key", void 0);
|
|
43
|
+
__decorate([
|
|
44
|
+
(0, typeorm_1.Column)({ type: "varchar", length: 150, nullable: true, default: null, comment: "Remitente del último correo." }),
|
|
45
|
+
__metadata("design:type", Object)
|
|
46
|
+
], WorkshopUnknownDevice.prototype, "sender", void 0);
|
|
47
|
+
__decorate([
|
|
48
|
+
(0, typeorm_1.Column)({ type: "varchar", length: 200, nullable: true, default: null, comment: "Asunto del último correo." }),
|
|
49
|
+
__metadata("design:type", Object)
|
|
50
|
+
], WorkshopUnknownDevice.prototype, "subject", void 0);
|
|
51
|
+
__decorate([
|
|
52
|
+
(0, typeorm_1.Column)({ type: "int", default: 1, comment: "Cuántos reportes han llegado de este equipo sin estar registrado." }),
|
|
53
|
+
__metadata("design:type", Number)
|
|
54
|
+
], WorkshopUnknownDevice.prototype, "reports", void 0);
|
|
55
|
+
__decorate([
|
|
56
|
+
(0, typeorm_1.Column)({
|
|
57
|
+
type: "int",
|
|
58
|
+
default: 1,
|
|
59
|
+
comment: "Estado:\r\n1: Pendiente (se le pregunta a la sede).\r\n2: Registrado.\r\n3: Ignorado (no se vuelve a preguntar).",
|
|
60
|
+
}),
|
|
61
|
+
__metadata("design:type", Number)
|
|
62
|
+
], WorkshopUnknownDevice.prototype, "status", void 0);
|
|
63
|
+
__decorate([
|
|
64
|
+
(0, typeorm_1.Column)({ type: "datetime", default: () => "CURRENT_TIMESTAMP", comment: "Fecha de creación del registro (primer reporte)." }),
|
|
65
|
+
__metadata("design:type", Date)
|
|
66
|
+
], WorkshopUnknownDevice.prototype, "created", void 0);
|
|
67
|
+
__decorate([
|
|
68
|
+
(0, typeorm_1.Column)({
|
|
69
|
+
type: "datetime",
|
|
70
|
+
nullable: true,
|
|
71
|
+
default: null,
|
|
72
|
+
onUpdate: "CURRENT_TIMESTAMP",
|
|
73
|
+
comment: "Fecha de la última actualización del registro (último reporte).",
|
|
74
|
+
}),
|
|
75
|
+
__metadata("design:type", Object)
|
|
76
|
+
], WorkshopUnknownDevice.prototype, "updated", void 0);
|
|
77
|
+
exports.WorkshopUnknownDevice = WorkshopUnknownDevice = __decorate([
|
|
78
|
+
(0, typeorm_1.Entity)({
|
|
79
|
+
comment: "Equipos que mandaron reportes por correo sin estar registrados en la sede: la sede decide si los registra.",
|
|
80
|
+
name: "workshop_unknown_device",
|
|
81
|
+
}),
|
|
82
|
+
(0, typeorm_1.Unique)("UQ_workshop_unknown_device", ["workshop", "serial_key"])
|
|
83
|
+
], WorkshopUnknownDevice);
|
package/dist/entities.index.d.ts
CHANGED
|
@@ -134,6 +134,7 @@ export { WorkshopEquipment } from "./entities/WorkshopEquipment";
|
|
|
134
134
|
export { VehicleMeasurement } from "./entities/VehicleMeasurement";
|
|
135
135
|
export { ObdCode } from "./entities/ObdCode";
|
|
136
136
|
export { WorkshopReportInbox } from "./entities/WorkshopReportInbox";
|
|
137
|
+
export { WorkshopUnknownDevice } from "./entities/WorkshopUnknownDevice";
|
|
137
138
|
export { JobTitle } from "./entities/JobTitle";
|
|
138
139
|
export { AssociatePayRate } from "./entities/AssociatePayRate";
|
|
139
140
|
export { PayrollMonthDays } from "./entities/PayrollMonthDays";
|
package/dist/entities.index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AssociateSection = exports.AssociatePermission = exports.AssociateRole = exports.AssociatePlatform = exports.ClientSubscription = exports.ClientPlanLimit = exports.ClientPlan = exports.ClientDocumentDispute = exports.ReviewTaskEvent = exports.ReviewTask = exports.MasterNotification = exports.ClientSession = exports.ClientNotification = exports.ClientIdentity = exports.PypRuleVote = exports.PypRule = exports.VehicleVerification = exports.ClientVehicleInvite = exports.ClientVehicle = exports.CompanyVehicle = exports.CompanyClient = exports.Appointment = exports.DocumentType = exports.ReminderType = exports.Reminder = exports.ServiceOrderHistory = exports.ServiceOrder = exports.TemplateSection = exports.SectionItem = exports.Section = exports.Template = exports.Workshop = exports.GlobalTemplateSection = exports.GlobalSectionItem = exports.GlobalSection = exports.GlobalTemplate = exports.AssociateNotification = exports.AssociateSession = exports.MasterSession = exports.Associate = exports.Client = exports.Master = exports.VehicleReport = exports.Vehicle = exports.Brand = exports.Company = exports.City = exports.Region = exports.WhatsappLine = exports.Country = void 0;
|
|
4
4
|
exports.AssociateDailyStats = exports.WorkshopDailyStats = exports.WorkboardEvent = exports.ServiceOrderStage = exports.WorkboardStatus = exports.CompanyDiscount = exports.DiscountCode = exports.WorkshopDisplay = exports.WorkshopInsurer = exports.WorkshopOfferedService = exports.Insurer = exports.OfferedService = exports.WorkshopOutingRecipient = exports.ServiceOrderOuting = exports.ServiceOrderPart = exports.ServiceOrderObservation = exports.VisitResult = exports.ReminderTypeCompanyType = exports.PlanCompanyType = exports.WorkshopCompanyType = exports.CompanyCompanyType = exports.CompanyType = exports.PlanFeature = exports.CompanyFeature = exports.Feature = exports.UsageAlert = exports.SubscriptionAddonTemplate = exports.PaymentTransaction = exports.BillingInvoice = exports.EmailSuppression = exports.EmailLog = exports.WhatsappLog = exports.ServiceOrderApproval = exports.MediaFile = exports.BillingUsageSnapshot = exports.PaymentMethod = exports.SubscriptionAddon = exports.CompanySubscription = exports.SubscriptionPlan = exports.CountryHoliday = exports.CompanyVehicleType = exports.BrandVehicleType = exports.CompanyBrand = exports.VehicleType = exports.MasterSection = exports.MasterPermission = exports.MasterRole = exports.MasterPlatform = exports.MasterPasswordReset = exports.AssociatePasswordReset = void 0;
|
|
5
|
-
exports.PayrollMonthDays = exports.AssociatePayRate = exports.JobTitle = exports.WorkshopReportInbox = exports.ObdCode = exports.VehicleMeasurement = exports.WorkshopEquipment = exports.EquipmentType = exports.CompanyAiUsage = exports.CompanyQuotaAdjustment = exports.VisitSearchHistory = exports.VisitAiAnalysis = exports.VisitSearchPerson = exports.VisitItemSearch = exports.GlobalSectionItems = exports.GlobalSections = exports.GlobalTemplates = exports.SubscriptionAddonTemplates = exports.SubscriptionPlans = exports.Masters = exports.Companies = exports.WorkshopsByAssociate = exports.Workshops = exports.SectionItems = exports.Sections = exports.Templates = exports.Reminders = exports.Vehicles = exports.Clients = exports.ServicesOrderLite = exports.ServicesOrder = exports.Associates = exports.AssociateSectionFeature = exports.AttendanceMark = exports.WorkshopReader = exports.AssociateTag = exports.WorkshopTag = exports.MetricEvent = exports.StageMetric = void 0;
|
|
5
|
+
exports.PayrollMonthDays = exports.AssociatePayRate = exports.JobTitle = exports.WorkshopUnknownDevice = exports.WorkshopReportInbox = exports.ObdCode = exports.VehicleMeasurement = exports.WorkshopEquipment = exports.EquipmentType = exports.CompanyAiUsage = exports.CompanyQuotaAdjustment = exports.VisitSearchHistory = exports.VisitAiAnalysis = exports.VisitSearchPerson = exports.VisitItemSearch = exports.GlobalSectionItems = exports.GlobalSections = exports.GlobalTemplates = exports.SubscriptionAddonTemplates = exports.SubscriptionPlans = exports.Masters = exports.Companies = exports.WorkshopsByAssociate = exports.Workshops = exports.SectionItems = exports.Sections = exports.Templates = exports.Reminders = exports.Vehicles = exports.Clients = exports.ServicesOrderLite = exports.ServicesOrder = exports.Associates = exports.AssociateSectionFeature = exports.AttendanceMark = exports.WorkshopReader = exports.AssociateTag = exports.WorkshopTag = exports.MetricEvent = exports.StageMetric = void 0;
|
|
6
6
|
var Country_1 = require("./entities/Country");
|
|
7
7
|
Object.defineProperty(exports, "Country", { enumerable: true, get: function () { return Country_1.Country; } });
|
|
8
8
|
var WhatsappLine_1 = require("./entities/WhatsappLine");
|
|
@@ -302,6 +302,8 @@ var ObdCode_1 = require("./entities/ObdCode");
|
|
|
302
302
|
Object.defineProperty(exports, "ObdCode", { enumerable: true, get: function () { return ObdCode_1.ObdCode; } });
|
|
303
303
|
var WorkshopReportInbox_1 = require("./entities/WorkshopReportInbox");
|
|
304
304
|
Object.defineProperty(exports, "WorkshopReportInbox", { enumerable: true, get: function () { return WorkshopReportInbox_1.WorkshopReportInbox; } });
|
|
305
|
+
var WorkshopUnknownDevice_1 = require("./entities/WorkshopUnknownDevice");
|
|
306
|
+
Object.defineProperty(exports, "WorkshopUnknownDevice", { enumerable: true, get: function () { return WorkshopUnknownDevice_1.WorkshopUnknownDevice; } });
|
|
305
307
|
var JobTitle_1 = require("./entities/JobTitle");
|
|
306
308
|
Object.defineProperty(exports, "JobTitle", { enumerable: true, get: function () { return JobTitle_1.JobTitle; } });
|
|
307
309
|
var AssociatePayRate_1 = require("./entities/AssociatePayRate");
|
|
@@ -39,6 +39,7 @@ export declare const MEASUREMENT_RESULT: {
|
|
|
39
39
|
readonly GOOD: 1;
|
|
40
40
|
readonly REGULAR: 2;
|
|
41
41
|
readonly BAD: 3;
|
|
42
|
+
readonly NOT_APPLICABLE: 4;
|
|
42
43
|
};
|
|
43
44
|
export declare const VIN_CHECK: {
|
|
44
45
|
readonly MATCH: 1;
|
|
@@ -162,7 +163,29 @@ export declare const evaluateReading: (schema: number, reading: TReading) => IRe
|
|
|
162
163
|
* o medida (lo malo primero). `equipment` es el nombre del tipo de equipo, para encabezar.
|
|
163
164
|
*/
|
|
164
165
|
export declare const describeReading: (schema: number, reading: TReading, equipment?: string | null) => string;
|
|
165
|
-
export declare const resultToItemStatus: (result: number | null) => "GOOD" | "REGULAR" | "BAD" | null;
|
|
166
|
+
export declare const resultToItemStatus: (result: number | null) => "GOOD" | "REGULAR" | "BAD" | "NOT_APPLICABLE" | null;
|
|
167
|
+
export declare const MEASUREMENT_NOTE_LIMITS: {
|
|
168
|
+
readonly WORKSHOP: 2000;
|
|
169
|
+
readonly CLIENT: 150;
|
|
170
|
+
};
|
|
171
|
+
export interface IMeasurementNotes {
|
|
172
|
+
result: TMeasurementResult | null;
|
|
173
|
+
workshop_note: string | null;
|
|
174
|
+
client_note: string | null;
|
|
175
|
+
health_pct: number | null;
|
|
176
|
+
}
|
|
177
|
+
export interface IAiMeasurement extends IMeasurementNotes {
|
|
178
|
+
vin: string | null;
|
|
179
|
+
plate: string | null;
|
|
180
|
+
equipment: string | null;
|
|
181
|
+
}
|
|
182
|
+
export declare const isMeasurementResult: (value: unknown) => value is TMeasurementResult;
|
|
183
|
+
export declare const clipClientNote: (value: unknown) => string | null;
|
|
184
|
+
export declare const normalizeHealthPct: (value: unknown) => number | null;
|
|
185
|
+
export declare const normalizeMeasurementNotes: (raw: unknown, schema?: number | null) => IMeasurementNotes;
|
|
186
|
+
export declare const normalizeAiMeasurement: (raw: unknown, schema?: number | null) => IAiMeasurement;
|
|
187
|
+
export declare const isMeasurementNotesEmpty: (notes: IMeasurementNotes) => boolean;
|
|
188
|
+
export declare const measurementSummary: (notes: Pick<IMeasurementNotes, "client_note" | "workshop_note">) => string | null;
|
|
166
189
|
export interface IItemMeasurementSettings {
|
|
167
190
|
equipment_type: number;
|
|
168
191
|
required?: boolean;
|
|
@@ -203,6 +226,17 @@ export declare const REPORT_INBOX_LIMITS: {
|
|
|
203
226
|
readonly MAX_SENDERS: 20;
|
|
204
227
|
readonly ADDRESS_MAX: 64;
|
|
205
228
|
};
|
|
229
|
+
export declare const INBOX_CODE: {
|
|
230
|
+
readonly ALPHABET: "abcdefghjkmnpqrstuvwxyz23456789";
|
|
231
|
+
readonly LENGTH: 5;
|
|
232
|
+
};
|
|
233
|
+
export declare const buildShortInboxAddress: (bytes: ArrayLike<number>) => string;
|
|
234
|
+
export declare const isShortInboxAddress: (address: unknown) => boolean;
|
|
235
|
+
export declare const normalizeSerialKey: (value: unknown) => string | null;
|
|
236
|
+
export declare const extractDeviceSerials: (value: string) => string[];
|
|
237
|
+
export declare const REPORT_LINK_HOSTS_DEFAULT: readonly ["dbscar.com", "cnlaunch.com"];
|
|
238
|
+
export declare const isAllowedReportHost: (hostname: string, allowed: readonly string[]) => boolean;
|
|
239
|
+
export declare const extractReportLinks: (html: string | null | undefined, plain: string | null | undefined, allowed: readonly string[]) => string[];
|
|
206
240
|
export declare const buildInboxAddress: (workshopName: string, suffix: string) => string;
|
|
207
241
|
export declare const normalizeEmailAddress: (value: unknown) => string | null;
|
|
208
242
|
export declare const findPlateInText: (text: string, plates: string[]) => string | null;
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
* (formato de salida) y los fronts (pintan y editan antes de confirmar).
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.
|
|
8
|
+
exports.REPORT_INBOX_LIMITS = exports.readWorkshopCap = exports.equipmentReadingsLimit = exports.compareVin = exports.vinCheckDigitOk = exports.vinModelYears = exports.normalizeVin = exports.pendingMeasurementItems = exports.requiredMoments = exports.withItemMeasurement = exports.getItemMeasurement = exports.measurementSummary = exports.isMeasurementNotesEmpty = exports.normalizeAiMeasurement = exports.normalizeMeasurementNotes = exports.normalizeHealthPct = exports.clipClientNote = exports.isMeasurementResult = exports.MEASUREMENT_NOTE_LIMITS = exports.resultToItemStatus = exports.describeReading = exports.evaluateReading = exports.rangeDoubts = exports.isRangeInDoubt = exports.isMeasureOut = exports.isOutOfRange = exports.isReadingEmpty = exports.normalizeEnvelope = exports.normalizeReading = exports.extractObdCodes = exports.normalizeObdCode = exports.OBD_CODE_PATTERN = exports.BATTERY_VERDICT = exports.DTC_STATE = exports.SCANNER_SYSTEM_STATUS = exports.isMeasurementMoment = exports.isReadingSchema = exports.EQUIPMENT_READINGS_DEFAULTS = exports.MEASUREMENT_LIMITS = exports.MEASUREMENT_MOMENT_LABEL = exports.READING_SCHEMA_COLOR = exports.READING_SCHEMA_LABEL = exports.VIN_CHECK = exports.MEASUREMENT_RESULT = exports.MEASUREMENT_STATUS = exports.MEASUREMENT_ORIGIN = exports.MEASUREMENT_SOURCE = exports.MEASUREMENT_MODE = exports.MEASUREMENT_MOMENT = exports.READING_SCHEMA = void 0;
|
|
9
|
+
exports.extractVins = exports.findPlateInText = exports.normalizeEmailAddress = exports.buildInboxAddress = exports.extractReportLinks = exports.isAllowedReportHost = exports.REPORT_LINK_HOSTS_DEFAULT = exports.extractDeviceSerials = exports.normalizeSerialKey = exports.isShortInboxAddress = exports.buildShortInboxAddress = exports.INBOX_CODE = void 0;
|
|
9
10
|
// ── Números de la base ──────────────────────────────────────────────────────
|
|
10
11
|
// DOC: `equipment_type.reading_schema`: qué forma tiene la lectura.
|
|
11
12
|
exports.READING_SCHEMA = { SCANNER: 1, BATTERY: 2, ALIGNMENT: 3, MEASURES: 4 };
|
|
@@ -25,8 +26,8 @@ exports.MEASUREMENT_STATUS = {
|
|
|
25
26
|
FAILED: 4,
|
|
26
27
|
DISCARDED: 5,
|
|
27
28
|
};
|
|
28
|
-
// DOC: `vehicle_measurement.result`: mismos niveles que el estado del ítem.
|
|
29
|
-
exports.MEASUREMENT_RESULT = { GOOD: 1, REGULAR: 2, BAD: 3 };
|
|
29
|
+
// DOC: `vehicle_measurement.result`: mismos niveles que el estado del ítem (4 = No aplica, desde sql/96).
|
|
30
|
+
exports.MEASUREMENT_RESULT = { GOOD: 1, REGULAR: 2, BAD: 3, NOT_APPLICABLE: 4 };
|
|
30
31
|
// DOC: `vehicle_measurement.vin_check`.
|
|
31
32
|
exports.VIN_CHECK = { MATCH: 1, UNCOMPARED: 2, REVIEW: 3, MISMATCH: 4, INVALID: 5 };
|
|
32
33
|
exports.READING_SCHEMA_LABEL = {
|
|
@@ -392,8 +393,79 @@ const resultToItemStatus = (result) => result === exports.MEASUREMENT_RESULT.GOO
|
|
|
392
393
|
? "REGULAR"
|
|
393
394
|
: result === exports.MEASUREMENT_RESULT.BAD
|
|
394
395
|
? "BAD"
|
|
395
|
-
:
|
|
396
|
+
: result === exports.MEASUREMENT_RESULT.NOT_APPLICABLE
|
|
397
|
+
? "NOT_APPLICABLE"
|
|
398
|
+
: null;
|
|
396
399
|
exports.resultToItemStatus = resultToItemStatus;
|
|
400
|
+
// ── Observaciones (sql/96) ──────────────────────────────────────────────────
|
|
401
|
+
//
|
|
402
|
+
// DOC: La medición ya no llena un formulario por equipo: un estado sugerido y dos observaciones, la del
|
|
403
|
+
// TALLER (detallada, va al historial) y la del CLIENTE (corta, solo si se marca «Mostrar al cliente»).
|
|
404
|
+
// El probador de baterías guarda además la salud (%), que arma la gráfica del historial.
|
|
405
|
+
exports.MEASUREMENT_NOTE_LIMITS = { WORKSHOP: 2000, CLIENT: 150 };
|
|
406
|
+
const isMeasurementResult = (value) => Object.values(exports.MEASUREMENT_RESULT).includes(Number(value));
|
|
407
|
+
exports.isMeasurementResult = isMeasurementResult;
|
|
408
|
+
// DOC: Texto de varias líneas: respeta los saltos (la observación del taller va por renglones).
|
|
409
|
+
const noteText = (value, max) => {
|
|
410
|
+
if (value === null || value === undefined)
|
|
411
|
+
return null;
|
|
412
|
+
const clean = String(value)
|
|
413
|
+
.replace(/\r\n?/g, "\n")
|
|
414
|
+
.replace(/[ \t]+/g, " ")
|
|
415
|
+
.replace(/ *\n */g, "\n")
|
|
416
|
+
.replace(/\n{3,}/g, "\n\n")
|
|
417
|
+
.trim()
|
|
418
|
+
.slice(0, max)
|
|
419
|
+
.trim();
|
|
420
|
+
return clean || null;
|
|
421
|
+
};
|
|
422
|
+
// DOC: La del cliente es UNA línea; si la IA se pasa del tope se corta en la última palabra completa.
|
|
423
|
+
const clipClientNote = (value) => {
|
|
424
|
+
const clean = String(value ?? "").replace(/\s+/g, " ").trim();
|
|
425
|
+
if (!clean)
|
|
426
|
+
return null;
|
|
427
|
+
if (clean.length <= exports.MEASUREMENT_NOTE_LIMITS.CLIENT)
|
|
428
|
+
return clean;
|
|
429
|
+
const cut = clean.slice(0, exports.MEASUREMENT_NOTE_LIMITS.CLIENT - 1);
|
|
430
|
+
const space = cut.lastIndexOf(" ");
|
|
431
|
+
return `${(space > 80 ? cut.slice(0, space) : cut).replace(/[,;:.\s]+$/, "")}…`;
|
|
432
|
+
};
|
|
433
|
+
exports.clipClientNote = clipClientNote;
|
|
434
|
+
const normalizeHealthPct = (value) => {
|
|
435
|
+
const parsed = num(value);
|
|
436
|
+
return parsed === null || parsed < 0 || parsed > 100 ? null : Math.round(parsed);
|
|
437
|
+
};
|
|
438
|
+
exports.normalizeHealthPct = normalizeHealthPct;
|
|
439
|
+
// DOC: Lo que mande quien confirma o la IA, limpio. La salud solo existe en el probador de baterías.
|
|
440
|
+
const normalizeMeasurementNotes = (raw, schema) => {
|
|
441
|
+
const value = (raw ?? {});
|
|
442
|
+
return {
|
|
443
|
+
result: (0, exports.isMeasurementResult)(value.result) ? Number(value.result) : null,
|
|
444
|
+
workshop_note: noteText(value.workshop_note, exports.MEASUREMENT_NOTE_LIMITS.WORKSHOP),
|
|
445
|
+
client_note: (0, exports.clipClientNote)(value.client_note),
|
|
446
|
+
health_pct: schema === exports.READING_SCHEMA.BATTERY ? (0, exports.normalizeHealthPct)(value.health_pct) : null,
|
|
447
|
+
};
|
|
448
|
+
};
|
|
449
|
+
exports.normalizeMeasurementNotes = normalizeMeasurementNotes;
|
|
450
|
+
const normalizeAiMeasurement = (raw, schema) => {
|
|
451
|
+
const value = (raw ?? {});
|
|
452
|
+
return {
|
|
453
|
+
...(0, exports.normalizeMeasurementNotes)(raw, schema),
|
|
454
|
+
vin: (0, exports.normalizeVin)(value.vin),
|
|
455
|
+
plate: text(value.plate, 12),
|
|
456
|
+
equipment: text(value.equipment, 80),
|
|
457
|
+
};
|
|
458
|
+
};
|
|
459
|
+
exports.normalizeAiMeasurement = normalizeAiMeasurement;
|
|
460
|
+
const isMeasurementNotesEmpty = (notes) => !notes.workshop_note && !notes.client_note && notes.result === null && notes.health_pct === null;
|
|
461
|
+
exports.isMeasurementNotesEmpty = isMeasurementNotesEmpty;
|
|
462
|
+
// DOC: El texto corto de la etiqueta del ítem y de las listas: la del cliente o el primer renglón de la del taller.
|
|
463
|
+
const measurementSummary = (notes) => {
|
|
464
|
+
const source = notes.client_note || notes.workshop_note?.split("\n").find((line) => line.trim()) || "";
|
|
465
|
+
const line = source.replace(/\s+/g, " ").trim();
|
|
466
|
+
return line ? (line.length > 120 ? `${line.slice(0, 119).trim()}…` : line) : null;
|
|
467
|
+
};
|
|
468
|
+
exports.measurementSummary = measurementSummary;
|
|
397
469
|
const getItemMeasurement = (details) => {
|
|
398
470
|
const raw = details?.measurement;
|
|
399
471
|
const type = Number(raw?.equipment_type);
|
|
@@ -498,6 +570,64 @@ const readWorkshopCap = (settings) => {
|
|
|
498
570
|
exports.readWorkshopCap = readWorkshopCap;
|
|
499
571
|
// ── Reportes por correo (sql/82) ─────────────────────────────────────────────
|
|
500
572
|
exports.REPORT_INBOX_LIMITS = { MAX_SENDERS: 20, ADDRESS_MAX: 64 };
|
|
573
|
+
// DOC: Dirección CORTA (sql/96): un código sin letras que se confunden (0/o, 1/l/i), fácil de escribir en la
|
|
574
|
+
// tableta del equipo. Lo que la protege es la lista de remitentes y el serial del equipo, no el código.
|
|
575
|
+
exports.INBOX_CODE = { ALPHABET: "abcdefghjkmnpqrstuvwxyz23456789", LENGTH: 5 };
|
|
576
|
+
// DOC: `bytes` los pone quien llama (crypto en el API): la librería no depende de Node.
|
|
577
|
+
const buildShortInboxAddress = (bytes) => Array.from({ length: exports.INBOX_CODE.LENGTH }, (_, i) => exports.INBOX_CODE.ALPHABET[Number(bytes[i] ?? 0) % exports.INBOX_CODE.ALPHABET.length]).join("");
|
|
578
|
+
exports.buildShortInboxAddress = buildShortInboxAddress;
|
|
579
|
+
const isShortInboxAddress = (address) => typeof address === "string" && address.length === exports.INBOX_CODE.LENGTH && [...address].every((c) => exports.INBOX_CODE.ALPHABET.includes(c));
|
|
580
|
+
exports.isShortInboxAddress = isShortInboxAddress;
|
|
581
|
+
// ── Serial del equipo (sql/96) ──────────────────────────────────────────────
|
|
582
|
+
// DOC: El serial sin espacios ni símbolos, en mayúsculas. Menos de 4 caracteres no identifica nada.
|
|
583
|
+
const normalizeSerialKey = (value) => {
|
|
584
|
+
const key = String(value ?? "").toUpperCase().replace(/[^A-Z0-9]/g, "").slice(0, 60);
|
|
585
|
+
return key.length >= 4 ? key : null;
|
|
586
|
+
};
|
|
587
|
+
exports.normalizeSerialKey = normalizeSerialKey;
|
|
588
|
+
// DOC: Los seriales que traiga un correo: «SN:988770004090», «(SN: 988…)», «S/N 123», «Serial No. 123»,
|
|
589
|
+
// «N° de serie 123». Solo se usan para saber de qué equipo viene el reporte.
|
|
590
|
+
const extractDeviceSerials = (value) => {
|
|
591
|
+
const pattern = /(?:\bS\/?N\b|\bSERIAL(?:\s*(?:NO|NUMBER|N[º°O])\.?)?|\bN[º°O]?\.?\s*(?:DE\s+)?SERIE\b)\s*[:#.]?\s*([A-Z0-9][A-Z0-9-]{3,39})/gi;
|
|
592
|
+
const found = new Set();
|
|
593
|
+
for (const match of String(value ?? "").matchAll(pattern)) {
|
|
594
|
+
const key = (0, exports.normalizeSerialKey)(match[1]);
|
|
595
|
+
if (key)
|
|
596
|
+
found.add(key);
|
|
597
|
+
}
|
|
598
|
+
return [...found].slice(0, 5);
|
|
599
|
+
};
|
|
600
|
+
exports.extractDeviceSerials = extractDeviceSerials;
|
|
601
|
+
// ── Reportes que llegan como ENLACE (sql/96) ────────────────────────────────
|
|
602
|
+
// DOC: Los equipos Launch no adjuntan: mandan un enlace a su nube. Solo se descargan enlaces https de estos
|
|
603
|
+
// dominios (y sus subdominios); cualquier otro se ignora para que el servidor no abra lo que le pongan.
|
|
604
|
+
exports.REPORT_LINK_HOSTS_DEFAULT = ["dbscar.com", "cnlaunch.com"];
|
|
605
|
+
const isAllowedReportHost = (hostname, allowed) => {
|
|
606
|
+
const host = String(hostname ?? "").toLowerCase().replace(/\.$/, "");
|
|
607
|
+
return !!host && allowed.some((domain) => host === domain || host.endsWith(`.${domain}`));
|
|
608
|
+
};
|
|
609
|
+
exports.isAllowedReportHost = isAllowedReportHost;
|
|
610
|
+
// DOC: Los enlaces https de dominios permitidos en el HTML (href) y en el texto del correo. Máximo 5.
|
|
611
|
+
const extractReportLinks = (html, plain, allowed) => {
|
|
612
|
+
const candidates = [
|
|
613
|
+
...[...String(html ?? "").matchAll(/href\s*=\s*["']([^"']+)["']/gi)].map((match) => match[1]),
|
|
614
|
+
...(String(plain ?? "").match(/https:\/\/[^\s<>"')\]]+/gi) ?? []),
|
|
615
|
+
];
|
|
616
|
+
const links = new Set();
|
|
617
|
+
for (const candidate of candidates) {
|
|
618
|
+
try {
|
|
619
|
+
const url = new URL(candidate.replace(/&/g, "&").trim());
|
|
620
|
+
if (url.protocol === "https:" && !url.username && !url.password && (0, exports.isAllowedReportHost)(url.hostname, allowed)) {
|
|
621
|
+
links.add(url.toString());
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
catch {
|
|
625
|
+
// DOC: No es una URL: se ignora.
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
return [...links].slice(0, 5);
|
|
629
|
+
};
|
|
630
|
+
exports.extractReportLinks = extractReportLinks;
|
|
501
631
|
// DOC: Parte local de la dirección de la sede: el nombre sin tildes ni símbolos y un sufijo que no se adivina.
|
|
502
632
|
const buildInboxAddress = (workshopName, suffix) => {
|
|
503
633
|
const slug = String(workshopName ?? "")
|
|
@@ -47,13 +47,14 @@ export interface IStagePayValues {
|
|
|
47
47
|
*/
|
|
48
48
|
export declare const suggestStagePay: (rate: IAssociatePayRateShape | null | undefined, estimatedHours?: string | number | null | undefined) => IStagePayValues | null;
|
|
49
49
|
export interface IStagePayrollValues extends IStagePayValues {
|
|
50
|
+
income_unit: TPayUnit | null;
|
|
50
51
|
income_hours: number | null;
|
|
51
52
|
income_rate: number | null;
|
|
52
53
|
income_amount: number | null;
|
|
53
54
|
}
|
|
54
55
|
/**
|
|
55
56
|
* DOC: Valida y completa el pago y el ingreso de una etapa. Los totales los calcula siempre el servidor:
|
|
56
|
-
* pago = cantidad x valor; ingreso = horas x valor
|
|
57
|
+
* pago = cantidad x valor; ingreso = horas o piezas x valor o, sin cantidad (particular), el escrito a mano.
|
|
57
58
|
*/
|
|
58
59
|
export declare const resolveStagePayroll: (input: any) => IStagePayrollValues | {
|
|
59
60
|
error: "INVALID_PAYROLL";
|
|
@@ -99,14 +99,17 @@ const suggestStagePay = (rate, estimatedHours = null) => {
|
|
|
99
99
|
exports.suggestStagePay = suggestStagePay;
|
|
100
100
|
/**
|
|
101
101
|
* DOC: Valida y completa el pago y el ingreso de una etapa. Los totales los calcula siempre el servidor:
|
|
102
|
-
* pago = cantidad x valor; ingreso = horas x valor
|
|
102
|
+
* pago = cantidad x valor; ingreso = horas o piezas x valor o, sin cantidad (particular), el escrito a mano.
|
|
103
103
|
*/
|
|
104
104
|
const resolveStagePayroll = (input) => {
|
|
105
105
|
const invalid = { error: "INVALID_PAYROLL" };
|
|
106
106
|
const unitRaw = input?.pay_unit;
|
|
107
107
|
const hasUnit = !isEmpty(unitRaw);
|
|
108
|
+
const incomeUnitRaw = input?.income_unit;
|
|
108
109
|
if (hasUnit && !(0, exports.isPayUnit)(unitRaw, exports.STAGE_PAY_UNITS))
|
|
109
110
|
return invalid;
|
|
111
|
+
if (!isEmpty(incomeUnitRaw) && !(0, exports.isPayUnit)(incomeUnitRaw, exports.STAGE_PAY_UNITS))
|
|
112
|
+
return invalid;
|
|
110
113
|
const quantity = hasUnit ? (0, exports.normalizePayrollQuantity)(input?.pay_quantity) : null;
|
|
111
114
|
const rate = hasUnit ? (0, exports.normalizePayrollMoney)(input?.pay_rate) : null;
|
|
112
115
|
const incomeHours = (0, exports.normalizePayrollQuantity)(input?.income_hours);
|
|
@@ -120,6 +123,8 @@ const resolveStagePayroll = (input) => {
|
|
|
120
123
|
pay_quantity: quantity,
|
|
121
124
|
pay_rate: rate,
|
|
122
125
|
pay_amount: (0, exports.payrollLineAmount)(quantity, rate),
|
|
126
|
+
// DOC: Solo se guarda «por pieza»; por hora queda NULL, igual que las etapas de antes.
|
|
127
|
+
income_unit: Number(incomeUnitRaw) === exports.PAY_UNIT.PIECE ? exports.PAY_UNIT.PIECE : null,
|
|
123
128
|
income_hours: incomeHours,
|
|
124
129
|
income_rate: incomeRate,
|
|
125
130
|
income_amount: incomeByHours ?? incomeManual,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IVisitData, IVisitItem } from "./visit.summary";
|
|
1
|
+
import type { IVisitData, IVisitItem, TItemStatus } from "./visit.summary";
|
|
2
2
|
/**
|
|
3
3
|
* DOC: HISTORIAL INTELIGENTE (sql/69): los números de la base, el texto de búsqueda y la
|
|
4
4
|
* clasificación de lo que ya se le hizo o se le dijo a un vehículo.
|
|
@@ -85,7 +85,14 @@ export declare const quoteResponseOf: (item: Pick<IVisitItem, "costs">) => TQuot
|
|
|
85
85
|
* DOC: Una fila por ítem VISIBLE de la visita. Los ocultos no van: tampoco los vio el cliente, y el
|
|
86
86
|
* historial no puede decir «se le advirtió» de algo que no salió en su informe.
|
|
87
87
|
*/
|
|
88
|
-
export
|
|
88
|
+
export interface IVisitSearchMeasurement {
|
|
89
|
+
item_id: string | null;
|
|
90
|
+
equipment: string;
|
|
91
|
+
note: string | null;
|
|
92
|
+
status: TItemStatus;
|
|
93
|
+
}
|
|
94
|
+
export declare const MEASUREMENTS_SEARCH_SECTION = "Mediciones";
|
|
95
|
+
export declare const buildVisitSearchRows: (data: Pick<IVisitData, "sections"> | null | undefined, measurements?: IVisitSearchMeasurement[]) => IVisitSearchRow[];
|
|
89
96
|
export interface IWorkshopWarranty {
|
|
90
97
|
days: number;
|
|
91
98
|
km: number | null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.aiAnalysesLimit = exports.VEHICLE_HISTORY_DEFAULTS = exports.classifyHistoryItem = exports.HISTORY_CLASS_RANK = exports.HISTORY_CLASS = exports.checkWarranty = exports.normalizeWorkshopWarranty = exports.WARRANTY_LIMITS = exports.WARRANTY_DEFAULTS = exports.buildVisitSearchRows = exports.quoteResponseOf = exports.matchesReason = exports.matchesSearchTerms = exports.expandSearchTerms = exports.SEARCH_EQUIVALENCES = exports.normalizeSearchText = exports.AI_ANALYSIS_KIND = exports.SEARCH_PERSON_ROLE = exports.RESPONDER_ROLE = exports.RESPONDER_CHANNEL = exports.QUOTE_RESPONSE = exports.SEARCH_ITEM_STATUS = void 0;
|
|
3
|
+
exports.aiAnalysesLimit = exports.VEHICLE_HISTORY_DEFAULTS = exports.classifyHistoryItem = exports.HISTORY_CLASS_RANK = exports.HISTORY_CLASS = exports.checkWarranty = exports.normalizeWorkshopWarranty = exports.WARRANTY_LIMITS = exports.WARRANTY_DEFAULTS = exports.buildVisitSearchRows = exports.MEASUREMENTS_SEARCH_SECTION = exports.quoteResponseOf = exports.matchesReason = exports.matchesSearchTerms = exports.expandSearchTerms = exports.SEARCH_EQUIVALENCES = exports.normalizeSearchText = exports.AI_ANALYSIS_KIND = exports.SEARCH_PERSON_ROLE = exports.RESPONDER_ROLE = exports.RESPONDER_CHANNEL = exports.QUOTE_RESPONSE = exports.SEARCH_ITEM_STATUS = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* DOC: HISTORIAL INTELIGENTE (sql/69): los números de la base, el texto de búsqueda y la
|
|
6
6
|
* clasificación de lo que ya se le hizo o se le dijo a un vehículo.
|
|
@@ -156,12 +156,13 @@ const quoteResponseOf = (item) => {
|
|
|
156
156
|
return exports.QUOTE_RESPONSE.NO_ANSWER;
|
|
157
157
|
};
|
|
158
158
|
exports.quoteResponseOf = quoteResponseOf;
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
* historial no puede decir «se le advirtió» de algo que no salió en su informe.
|
|
162
|
-
*/
|
|
163
|
-
const buildVisitSearchRows = (data) => {
|
|
159
|
+
exports.MEASUREMENTS_SEARCH_SECTION = "Mediciones";
|
|
160
|
+
const buildVisitSearchRows = (data, measurements = []) => {
|
|
164
161
|
const rows = [];
|
|
162
|
+
const notesOf = (itemId) => measurements
|
|
163
|
+
.filter((row) => row.item_id === itemId && row.note)
|
|
164
|
+
.map((row) => `${row.equipment}: ${row.note}`);
|
|
165
|
+
const itemIds = new Set();
|
|
165
166
|
for (const section of data?.sections ?? []) {
|
|
166
167
|
for (const item of section?.items ?? []) {
|
|
167
168
|
if (!item || item.visible === false)
|
|
@@ -173,7 +174,8 @@ const buildVisitSearchRows = (data) => {
|
|
|
173
174
|
const sectionName = clip(section.name, TEXT_LIMIT.NAME) ?? "";
|
|
174
175
|
const itemName = clip(item.name, TEXT_LIMIT.NAME) ?? "";
|
|
175
176
|
const observation = clip(item.observation, TEXT_LIMIT.OBSERVATION);
|
|
176
|
-
const comments = clip(item.comments, TEXT_LIMIT.COMMENTS);
|
|
177
|
+
const comments = clip([item.comments, ...notesOf(item.id)].filter(Boolean).join("\n"), TEXT_LIMIT.COMMENTS);
|
|
178
|
+
itemIds.add(item.id);
|
|
177
179
|
rows.push({
|
|
178
180
|
section_name: sectionName,
|
|
179
181
|
item_name: itemName,
|
|
@@ -191,6 +193,26 @@ const buildVisitSearchRows = (data) => {
|
|
|
191
193
|
});
|
|
192
194
|
}
|
|
193
195
|
}
|
|
196
|
+
// DOC: Las sueltas (o las de un ítem oculto) quedan como su propio renglón.
|
|
197
|
+
for (const row of measurements.filter((m) => m.note && (!m.item_id || !itemIds.has(m.item_id)))) {
|
|
198
|
+
const itemName = clip(row.equipment, TEXT_LIMIT.NAME) ?? "";
|
|
199
|
+
const comments = clip(row.note, TEXT_LIMIT.COMMENTS);
|
|
200
|
+
rows.push({
|
|
201
|
+
section_name: exports.MEASUREMENTS_SEARCH_SECTION,
|
|
202
|
+
item_name: itemName,
|
|
203
|
+
observation: null,
|
|
204
|
+
comments,
|
|
205
|
+
search_text: (0, exports.normalizeSearchText)([exports.MEASUREMENTS_SEARCH_SECTION, itemName, comments].filter(Boolean).join(" ")).slice(0, TEXT_LIMIT.SEARCH),
|
|
206
|
+
item_status: row.status ? STATUS_TO_NUMBER[row.status] ?? null : null,
|
|
207
|
+
quote_total: 0,
|
|
208
|
+
quote_response: exports.QUOTE_RESPONSE.NONE,
|
|
209
|
+
responded_at: null,
|
|
210
|
+
responder_client: null,
|
|
211
|
+
responder_name: null,
|
|
212
|
+
responder_channel: null,
|
|
213
|
+
responder_role: null,
|
|
214
|
+
});
|
|
215
|
+
}
|
|
194
216
|
return rows;
|
|
195
217
|
};
|
|
196
218
|
exports.buildVisitSearchRows = buildVisitSearchRows;
|