@asumano/worklip-typeorm-db 1.1.80 → 1.1.82
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/Section.d.ts +3 -0
- package/dist/entities/Section.js +20 -0
- package/dist/entities/ServiceOrder.d.ts +8 -0
- package/dist/entities/ServiceOrder.js +38 -0
- package/dist/entities/ServiceOrderStage.d.ts +50 -0
- package/dist/entities/ServiceOrderStage.js +240 -0
- package/dist/entities/WorkboardEvent.d.ts +36 -0
- package/dist/entities/WorkboardEvent.js +152 -0
- package/dist/entities/WorkboardStatus.d.ts +23 -0
- package/dist/entities/WorkboardStatus.js +179 -0
- package/dist/entities/Workshop.d.ts +2 -0
- package/dist/entities/Workshop.js +5 -0
- package/dist/entities.index.d.ts +3 -0
- package/dist/entities.index.js +10 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +5 -0
- package/dist/template.settings.d.ts +4 -0
- package/dist/template.settings.js +43 -1
- package/dist/visit.summary.d.ts +16 -3
- package/dist/workboard.rules.d.ts +135 -0
- package/dist/workboard.rules.js +185 -0
- package/package.json +1 -1
|
@@ -2,6 +2,7 @@ import { Workshop } from "./Workshop";
|
|
|
2
2
|
import { SectionItem } from "./SectionItem";
|
|
3
3
|
import { TemplateSection } from "./TemplateSection";
|
|
4
4
|
import { Associate } from "./Associate";
|
|
5
|
+
import { ServiceOrderStage } from "./ServiceOrderStage";
|
|
5
6
|
export declare class Section {
|
|
6
7
|
id: number;
|
|
7
8
|
code: string;
|
|
@@ -16,4 +17,6 @@ export declare class Section {
|
|
|
16
17
|
status: number;
|
|
17
18
|
section_items: SectionItem[];
|
|
18
19
|
template_sections: TemplateSection[];
|
|
20
|
+
associates: Associate[];
|
|
21
|
+
stages: ServiceOrderStage[];
|
|
19
22
|
}
|
package/dist/entities/Section.js
CHANGED
|
@@ -15,6 +15,7 @@ const Workshop_1 = require("./Workshop");
|
|
|
15
15
|
const SectionItem_1 = require("./SectionItem");
|
|
16
16
|
const TemplateSection_1 = require("./TemplateSection");
|
|
17
17
|
const Associate_1 = require("./Associate");
|
|
18
|
+
const ServiceOrderStage_1 = require("./ServiceOrderStage");
|
|
18
19
|
// DOC: Una sección del CATÁLOGO del taller. Antes se llamaba TemplateSection y colgaba de una
|
|
19
20
|
// plantilla; ahora vive sola y las plantillas la enlazan a través de TemplateSection, que
|
|
20
21
|
// pasó a ser el pivote.
|
|
@@ -130,6 +131,25 @@ __decorate([
|
|
|
130
131
|
(0, typeorm_1.OneToMany)(() => TemplateSection_1.TemplateSection, (templateSection) => templateSection.section),
|
|
131
132
|
__metadata("design:type", Array)
|
|
132
133
|
], Section.prototype, "template_sections", void 0);
|
|
134
|
+
__decorate([
|
|
135
|
+
(0, typeorm_1.ManyToMany)(() => Associate_1.Associate),
|
|
136
|
+
(0, typeorm_1.JoinTable)({
|
|
137
|
+
name: "section_associate",
|
|
138
|
+
joinColumn: {
|
|
139
|
+
name: "section",
|
|
140
|
+
referencedColumnName: "id",
|
|
141
|
+
},
|
|
142
|
+
inverseJoinColumn: {
|
|
143
|
+
name: "associate",
|
|
144
|
+
referencedColumnName: "id",
|
|
145
|
+
},
|
|
146
|
+
}),
|
|
147
|
+
__metadata("design:type", Array)
|
|
148
|
+
], Section.prototype, "associates", void 0);
|
|
149
|
+
__decorate([
|
|
150
|
+
(0, typeorm_1.OneToMany)(() => ServiceOrderStage_1.ServiceOrderStage, (stage) => stage.section),
|
|
151
|
+
__metadata("design:type", Array)
|
|
152
|
+
], Section.prototype, "stages", void 0);
|
|
133
153
|
exports.Section = Section = __decorate([
|
|
134
154
|
(0, typeorm_1.Entity)({
|
|
135
155
|
comment: "Catálogo de secciones del taller. Una sección puede estar en muchas plantillas.",
|
|
@@ -8,6 +8,9 @@ import { Reminder } from "./Reminder";
|
|
|
8
8
|
import { ServiceOrderApproval } from "./ServiceOrderApproval";
|
|
9
9
|
import { WhatsappLog } from "./WhatsappLog";
|
|
10
10
|
import { EmailLog } from "./EmailLog";
|
|
11
|
+
import { WorkboardStatus } from "./WorkboardStatus";
|
|
12
|
+
import { ServiceOrderStage } from "./ServiceOrderStage";
|
|
13
|
+
import { WorkboardEvent } from "./WorkboardEvent";
|
|
11
14
|
export declare class ServiceOrder {
|
|
12
15
|
id: number;
|
|
13
16
|
code: string;
|
|
@@ -25,6 +28,11 @@ export declare class ServiceOrder {
|
|
|
25
28
|
created: Date;
|
|
26
29
|
updated: Date | null;
|
|
27
30
|
status: number;
|
|
31
|
+
workboard_status: WorkboardStatus | null;
|
|
32
|
+
workboard_changed: Date | null;
|
|
33
|
+
promised_date: Date | null;
|
|
34
|
+
stages: ServiceOrderStage[];
|
|
35
|
+
workboard_events: WorkboardEvent[];
|
|
28
36
|
service_order_history: ServiceOrderHistory[];
|
|
29
37
|
media_files: MediaFile[];
|
|
30
38
|
reminders: Reminder[];
|
|
@@ -21,6 +21,9 @@ const Reminder_1 = require("./Reminder");
|
|
|
21
21
|
const ServiceOrderApproval_1 = require("./ServiceOrderApproval");
|
|
22
22
|
const WhatsappLog_1 = require("./WhatsappLog");
|
|
23
23
|
const EmailLog_1 = require("./EmailLog");
|
|
24
|
+
const WorkboardStatus_1 = require("./WorkboardStatus");
|
|
25
|
+
const ServiceOrderStage_1 = require("./ServiceOrderStage");
|
|
26
|
+
const WorkboardEvent_1 = require("./WorkboardEvent");
|
|
24
27
|
// DOC: El consecutivo es único por taller y año. Es la garantía de que dos visitas
|
|
25
28
|
// del mismo taller nunca compartan número, incluso si se crean a la vez.
|
|
26
29
|
let ServiceOrder = class ServiceOrder {
|
|
@@ -165,6 +168,41 @@ __decorate([
|
|
|
165
168
|
}),
|
|
166
169
|
__metadata("design:type", Number)
|
|
167
170
|
], ServiceOrder.prototype, "status", void 0);
|
|
171
|
+
__decorate([
|
|
172
|
+
(0, typeorm_1.ManyToOne)(() => WorkboardStatus_1.WorkboardStatus, (status) => status.service_orders, {
|
|
173
|
+
onDelete: "RESTRICT",
|
|
174
|
+
onUpdate: "NO ACTION",
|
|
175
|
+
nullable: true,
|
|
176
|
+
}),
|
|
177
|
+
(0, typeorm_1.JoinColumn)({ name: "workboard_status" }),
|
|
178
|
+
__metadata("design:type", Object)
|
|
179
|
+
], ServiceOrder.prototype, "workboard_status", void 0);
|
|
180
|
+
__decorate([
|
|
181
|
+
(0, typeorm_1.Column)({
|
|
182
|
+
type: "datetime",
|
|
183
|
+
default: null,
|
|
184
|
+
nullable: true,
|
|
185
|
+
comment: "Cuándo cambió de columna por última vez. Para mostrar el tiempo en la columna sin subconsulta.",
|
|
186
|
+
}),
|
|
187
|
+
__metadata("design:type", Object)
|
|
188
|
+
], ServiceOrder.prototype, "workboard_changed", void 0);
|
|
189
|
+
__decorate([
|
|
190
|
+
(0, typeorm_1.Column)({
|
|
191
|
+
type: "date",
|
|
192
|
+
default: null,
|
|
193
|
+
nullable: true,
|
|
194
|
+
comment: "Fecha de entrega prometida al cliente. NULL si no se prometió ninguna.",
|
|
195
|
+
}),
|
|
196
|
+
__metadata("design:type", Object)
|
|
197
|
+
], ServiceOrder.prototype, "promised_date", void 0);
|
|
198
|
+
__decorate([
|
|
199
|
+
(0, typeorm_1.OneToMany)(() => ServiceOrderStage_1.ServiceOrderStage, (stage) => stage.service_order),
|
|
200
|
+
__metadata("design:type", Array)
|
|
201
|
+
], ServiceOrder.prototype, "stages", void 0);
|
|
202
|
+
__decorate([
|
|
203
|
+
(0, typeorm_1.OneToMany)(() => WorkboardEvent_1.WorkboardEvent, (event) => event.service_order),
|
|
204
|
+
__metadata("design:type", Array)
|
|
205
|
+
], ServiceOrder.prototype, "workboard_events", void 0);
|
|
168
206
|
__decorate([
|
|
169
207
|
(0, typeorm_1.OneToMany)(() => ServiceOrderHistory_1.ServiceOrderHistory, (serviceOrderHistory) => serviceOrderHistory.service_order),
|
|
170
208
|
__metadata("design:type", Array)
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ServiceOrder } from "./ServiceOrder";
|
|
2
|
+
import { Section } from "./Section";
|
|
3
|
+
import { WorkboardStatus } from "./WorkboardStatus";
|
|
4
|
+
import { Associate } from "./Associate";
|
|
5
|
+
import { WorkboardEvent } from "./WorkboardEvent";
|
|
6
|
+
/**
|
|
7
|
+
* DOC: UNA ETAPA DE UNA VISITA. Es el corazón del tablero de trabajo.
|
|
8
|
+
*
|
|
9
|
+
* La unidad de trabajo NO es la visita: es la pareja (visita, etapa). Con un solo estado en la
|
|
10
|
+
* visita no se puede representar "bloqueada en pintura mientras avanza latonería", que en un
|
|
11
|
+
* taller de latonería es un martes normal. Con una fila por etapa, el trabajo en paralelo y el
|
|
12
|
+
* bloqueo dejan de ser casos especiales y pasan a ser el comportamiento de la tabla:
|
|
13
|
+
*
|
|
14
|
+
* · La columna "Desarme" del tablero son las filas de esa sección con `state = 2`.
|
|
15
|
+
* · La columna "Bloqueado" es una VISTA FILTRADA de las filas con `state = 3`, y cada una ya
|
|
16
|
+
* sabe a qué sección volver — porque la fila ES de esa sección. Por eso no hace falta
|
|
17
|
+
* guardar "qué sección la mandó a bloqueado".
|
|
18
|
+
*
|
|
19
|
+
* ── Una etapa es una sección O un estado ────────────────────────────────────
|
|
20
|
+
*
|
|
21
|
+
* Las etapas finales (Finalizado, Por entregar, Entregado) también llevan responsable y
|
|
22
|
+
* fechas, y no son secciones de la plantilla. De ahí las dos FK anulables con el CHECK:
|
|
23
|
+
* exactamente una va llena. Sin las filas de las finales no se podría medir cuánto tiempo pasa
|
|
24
|
+
* un carro listo sin que nadie llame al cliente, que es justo uno de los números que se buscan.
|
|
25
|
+
*
|
|
26
|
+
* Los `kind` 1, 2 y 3 NO llevan fila: los dos primeros se deducen de las secciones y el
|
|
27
|
+
* bloqueo es un ESTADO de una fila, no una fila aparte.
|
|
28
|
+
*/
|
|
29
|
+
export declare class ServiceOrderStage {
|
|
30
|
+
id: number;
|
|
31
|
+
service_order: ServiceOrder;
|
|
32
|
+
section: Section | null;
|
|
33
|
+
workboard_status: WorkboardStatus | null;
|
|
34
|
+
stage_name: string;
|
|
35
|
+
stage_order: number;
|
|
36
|
+
state: number;
|
|
37
|
+
assigned_associate: Associate | null;
|
|
38
|
+
taken_by: Associate | null;
|
|
39
|
+
taken_at: Date | null;
|
|
40
|
+
entered: Date | null;
|
|
41
|
+
finished: Date | null;
|
|
42
|
+
estimated_hours: number | null;
|
|
43
|
+
blocked_reason: string | null;
|
|
44
|
+
blocked_at: Date | null;
|
|
45
|
+
blocked_by: Associate | null;
|
|
46
|
+
details: any | null;
|
|
47
|
+
created: Date;
|
|
48
|
+
updated: Date | null;
|
|
49
|
+
events: WorkboardEvent[];
|
|
50
|
+
}
|
|
@@ -0,0 +1,240 @@
|
|
|
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.ServiceOrderStage = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
const ServiceOrder_1 = require("./ServiceOrder");
|
|
15
|
+
const Section_1 = require("./Section");
|
|
16
|
+
const WorkboardStatus_1 = require("./WorkboardStatus");
|
|
17
|
+
const Associate_1 = require("./Associate");
|
|
18
|
+
const WorkboardEvent_1 = require("./WorkboardEvent");
|
|
19
|
+
/**
|
|
20
|
+
* DOC: UNA ETAPA DE UNA VISITA. Es el corazón del tablero de trabajo.
|
|
21
|
+
*
|
|
22
|
+
* La unidad de trabajo NO es la visita: es la pareja (visita, etapa). Con un solo estado en la
|
|
23
|
+
* visita no se puede representar "bloqueada en pintura mientras avanza latonería", que en un
|
|
24
|
+
* taller de latonería es un martes normal. Con una fila por etapa, el trabajo en paralelo y el
|
|
25
|
+
* bloqueo dejan de ser casos especiales y pasan a ser el comportamiento de la tabla:
|
|
26
|
+
*
|
|
27
|
+
* · La columna "Desarme" del tablero son las filas de esa sección con `state = 2`.
|
|
28
|
+
* · La columna "Bloqueado" es una VISTA FILTRADA de las filas con `state = 3`, y cada una ya
|
|
29
|
+
* sabe a qué sección volver — porque la fila ES de esa sección. Por eso no hace falta
|
|
30
|
+
* guardar "qué sección la mandó a bloqueado".
|
|
31
|
+
*
|
|
32
|
+
* ── Una etapa es una sección O un estado ────────────────────────────────────
|
|
33
|
+
*
|
|
34
|
+
* Las etapas finales (Finalizado, Por entregar, Entregado) también llevan responsable y
|
|
35
|
+
* fechas, y no son secciones de la plantilla. De ahí las dos FK anulables con el CHECK:
|
|
36
|
+
* exactamente una va llena. Sin las filas de las finales no se podría medir cuánto tiempo pasa
|
|
37
|
+
* un carro listo sin que nadie llame al cliente, que es justo uno de los números que se buscan.
|
|
38
|
+
*
|
|
39
|
+
* Los `kind` 1, 2 y 3 NO llevan fila: los dos primeros se deducen de las secciones y el
|
|
40
|
+
* bloqueo es un ESTADO de una fila, no una fila aparte.
|
|
41
|
+
*/
|
|
42
|
+
let ServiceOrderStage = class ServiceOrderStage {
|
|
43
|
+
};
|
|
44
|
+
exports.ServiceOrderStage = ServiceOrderStage;
|
|
45
|
+
__decorate([
|
|
46
|
+
(0, typeorm_1.PrimaryGeneratedColumn)({
|
|
47
|
+
type: "int",
|
|
48
|
+
comment: "Número de identificación (ID) único de cada registro.",
|
|
49
|
+
}),
|
|
50
|
+
__metadata("design:type", Number)
|
|
51
|
+
], ServiceOrderStage.prototype, "id", void 0);
|
|
52
|
+
__decorate([
|
|
53
|
+
(0, typeorm_1.ManyToOne)(() => ServiceOrder_1.ServiceOrder, (serviceOrder) => serviceOrder.stages, {
|
|
54
|
+
onDelete: "CASCADE",
|
|
55
|
+
onUpdate: "NO ACTION",
|
|
56
|
+
}),
|
|
57
|
+
(0, typeorm_1.JoinColumn)({ name: "service_order" }),
|
|
58
|
+
__metadata("design:type", ServiceOrder_1.ServiceOrder)
|
|
59
|
+
], ServiceOrderStage.prototype, "service_order", void 0);
|
|
60
|
+
__decorate([
|
|
61
|
+
(0, typeorm_1.ManyToOne)(() => Section_1.Section, (section) => section.stages, {
|
|
62
|
+
onDelete: "RESTRICT",
|
|
63
|
+
onUpdate: "NO ACTION",
|
|
64
|
+
nullable: true,
|
|
65
|
+
}),
|
|
66
|
+
(0, typeorm_1.JoinColumn)({ name: "section" }),
|
|
67
|
+
__metadata("design:type", Object)
|
|
68
|
+
], ServiceOrderStage.prototype, "section", void 0);
|
|
69
|
+
__decorate([
|
|
70
|
+
(0, typeorm_1.ManyToOne)(() => WorkboardStatus_1.WorkboardStatus, (status) => status.stages, {
|
|
71
|
+
onDelete: "RESTRICT",
|
|
72
|
+
onUpdate: "NO ACTION",
|
|
73
|
+
nullable: true,
|
|
74
|
+
}),
|
|
75
|
+
(0, typeorm_1.JoinColumn)({ name: "workboard_status" }),
|
|
76
|
+
__metadata("design:type", Object)
|
|
77
|
+
], ServiceOrderStage.prototype, "workboard_status", void 0);
|
|
78
|
+
__decorate([
|
|
79
|
+
(0, typeorm_1.Column)({
|
|
80
|
+
length: 100,
|
|
81
|
+
type: "varchar",
|
|
82
|
+
comment: "Nombre de la etapa congelado en el momento en que se creó la visita.",
|
|
83
|
+
}),
|
|
84
|
+
__metadata("design:type", String)
|
|
85
|
+
], ServiceOrderStage.prototype, "stage_name", void 0);
|
|
86
|
+
__decorate([
|
|
87
|
+
(0, typeorm_1.Column)({
|
|
88
|
+
type: "int",
|
|
89
|
+
comment: "Orden de la etapa dentro de la visita. Las finales llevan 1000 + el orden del estado.",
|
|
90
|
+
}),
|
|
91
|
+
__metadata("design:type", Number)
|
|
92
|
+
], ServiceOrderStage.prototype, "stage_order", void 0);
|
|
93
|
+
__decorate([
|
|
94
|
+
(0, typeorm_1.Column)({
|
|
95
|
+
default: 0,
|
|
96
|
+
type: "int",
|
|
97
|
+
width: 1,
|
|
98
|
+
comment: "Estado del trabajo en esta etapa:\r\n0: No alcanzada. La visita todavía no llegó acá.\r\n1: Pendiente. Llegó y espera que alguien la tome.\r\n2: En proceso.\r\n3: Bloqueada. Con motivo obligatorio.\r\n4: Terminada.",
|
|
99
|
+
}),
|
|
100
|
+
__metadata("design:type", Number)
|
|
101
|
+
], ServiceOrderStage.prototype, "state", void 0);
|
|
102
|
+
__decorate([
|
|
103
|
+
(0, typeorm_1.ManyToOne)(() => Associate_1.Associate, {
|
|
104
|
+
onDelete: "RESTRICT",
|
|
105
|
+
onUpdate: "NO ACTION",
|
|
106
|
+
nullable: true,
|
|
107
|
+
}),
|
|
108
|
+
(0, typeorm_1.JoinColumn)({ name: "assigned_associate" }),
|
|
109
|
+
__metadata("design:type", Object)
|
|
110
|
+
], ServiceOrderStage.prototype, "assigned_associate", void 0);
|
|
111
|
+
__decorate([
|
|
112
|
+
(0, typeorm_1.ManyToOne)(() => Associate_1.Associate, {
|
|
113
|
+
onDelete: "RESTRICT",
|
|
114
|
+
onUpdate: "NO ACTION",
|
|
115
|
+
nullable: true,
|
|
116
|
+
}),
|
|
117
|
+
(0, typeorm_1.JoinColumn)({ name: "taken_by" }),
|
|
118
|
+
__metadata("design:type", Object)
|
|
119
|
+
], ServiceOrderStage.prototype, "taken_by", void 0);
|
|
120
|
+
__decorate([
|
|
121
|
+
(0, typeorm_1.Column)({
|
|
122
|
+
type: "datetime",
|
|
123
|
+
default: null,
|
|
124
|
+
nullable: true,
|
|
125
|
+
comment: "Cuándo la tomó. Contra `entered` da el tiempo que el carro esperó a que alguien lo mirara.",
|
|
126
|
+
}),
|
|
127
|
+
__metadata("design:type", Object)
|
|
128
|
+
], ServiceOrderStage.prototype, "taken_at", void 0);
|
|
129
|
+
__decorate([
|
|
130
|
+
(0, typeorm_1.Column)({
|
|
131
|
+
type: "datetime",
|
|
132
|
+
default: null,
|
|
133
|
+
nullable: true,
|
|
134
|
+
comment: "Cuándo la visita llegó a esta etapa. NULL mientras no la haya alcanzado.",
|
|
135
|
+
}),
|
|
136
|
+
__metadata("design:type", Object)
|
|
137
|
+
], ServiceOrderStage.prototype, "entered", void 0);
|
|
138
|
+
__decorate([
|
|
139
|
+
(0, typeorm_1.Column)({
|
|
140
|
+
type: "datetime",
|
|
141
|
+
default: null,
|
|
142
|
+
nullable: true,
|
|
143
|
+
comment: "Cuándo se cerró la etapa.",
|
|
144
|
+
}),
|
|
145
|
+
__metadata("design:type", Object)
|
|
146
|
+
], ServiceOrderStage.prototype, "finished", void 0);
|
|
147
|
+
__decorate([
|
|
148
|
+
(0, typeorm_1.Column)({
|
|
149
|
+
type: "decimal",
|
|
150
|
+
precision: 6,
|
|
151
|
+
scale: 2,
|
|
152
|
+
default: null,
|
|
153
|
+
nullable: true,
|
|
154
|
+
comment: "Horas que el jefe de taller y el empleado ACORDARON. No es lo que se le prometió al cliente.",
|
|
155
|
+
}),
|
|
156
|
+
__metadata("design:type", Object)
|
|
157
|
+
], ServiceOrderStage.prototype, "estimated_hours", void 0);
|
|
158
|
+
__decorate([
|
|
159
|
+
(0, typeorm_1.Column)({
|
|
160
|
+
length: 255,
|
|
161
|
+
type: "varchar",
|
|
162
|
+
default: null,
|
|
163
|
+
nullable: true,
|
|
164
|
+
comment: "Motivo del bloqueo vigente. Obligatorio al bloquear.",
|
|
165
|
+
}),
|
|
166
|
+
__metadata("design:type", Object)
|
|
167
|
+
], ServiceOrderStage.prototype, "blocked_reason", void 0);
|
|
168
|
+
__decorate([
|
|
169
|
+
(0, typeorm_1.Column)({
|
|
170
|
+
type: "datetime",
|
|
171
|
+
default: null,
|
|
172
|
+
nullable: true,
|
|
173
|
+
comment: "Cuándo se bloqueó.",
|
|
174
|
+
}),
|
|
175
|
+
__metadata("design:type", Object)
|
|
176
|
+
], ServiceOrderStage.prototype, "blocked_at", void 0);
|
|
177
|
+
__decorate([
|
|
178
|
+
(0, typeorm_1.ManyToOne)(() => Associate_1.Associate, {
|
|
179
|
+
onDelete: "RESTRICT",
|
|
180
|
+
onUpdate: "NO ACTION",
|
|
181
|
+
nullable: true,
|
|
182
|
+
}),
|
|
183
|
+
(0, typeorm_1.JoinColumn)({ name: "blocked_by" }),
|
|
184
|
+
__metadata("design:type", Object)
|
|
185
|
+
], ServiceOrderStage.prototype, "blocked_by", void 0);
|
|
186
|
+
__decorate([
|
|
187
|
+
(0, typeorm_1.Column)({
|
|
188
|
+
type: "json",
|
|
189
|
+
nullable: true,
|
|
190
|
+
default: null,
|
|
191
|
+
comment: "Campo de tipo JSON para lo que necesite la etapa.",
|
|
192
|
+
}),
|
|
193
|
+
__metadata("design:type", Object)
|
|
194
|
+
], ServiceOrderStage.prototype, "details", void 0);
|
|
195
|
+
__decorate([
|
|
196
|
+
(0, typeorm_1.Column)({
|
|
197
|
+
type: "datetime",
|
|
198
|
+
comment: "Fecha de creación del registro.",
|
|
199
|
+
default: () => "CURRENT_TIMESTAMP",
|
|
200
|
+
}),
|
|
201
|
+
__metadata("design:type", Date)
|
|
202
|
+
], ServiceOrderStage.prototype, "created", void 0);
|
|
203
|
+
__decorate([
|
|
204
|
+
(0, typeorm_1.Column)({
|
|
205
|
+
type: "datetime",
|
|
206
|
+
default: null,
|
|
207
|
+
nullable: true,
|
|
208
|
+
comment: "Fecha de actualización del registro.",
|
|
209
|
+
onUpdate: "CURRENT_TIMESTAMP",
|
|
210
|
+
}),
|
|
211
|
+
__metadata("design:type", Object)
|
|
212
|
+
], ServiceOrderStage.prototype, "updated", void 0);
|
|
213
|
+
__decorate([
|
|
214
|
+
(0, typeorm_1.OneToMany)(() => WorkboardEvent_1.WorkboardEvent, (event) => event.service_order_stage),
|
|
215
|
+
__metadata("design:type", Array)
|
|
216
|
+
], ServiceOrderStage.prototype, "events", void 0);
|
|
217
|
+
exports.ServiceOrderStage = ServiceOrderStage = __decorate([
|
|
218
|
+
(0, typeorm_1.Index)("IDX_service_order_stage_board", ["section", "state"])
|
|
219
|
+
// DOC: Para la carga por empleado, que agrupa por asignado y por estado.
|
|
220
|
+
,
|
|
221
|
+
(0, typeorm_1.Index)("IDX_service_order_stage_assigned", ["assigned_associate", "state"]),
|
|
222
|
+
(0, typeorm_1.Index)("IDX_service_order_stage_visit", ["service_order", "state"]),
|
|
223
|
+
(0, typeorm_1.Entity)({
|
|
224
|
+
comment: "Etapas por las que pasa una visita, con su estado, responsable y fechas.",
|
|
225
|
+
name: "service_order_stage",
|
|
226
|
+
})
|
|
227
|
+
// DOC: Los dos UNIQUE conviven bien PRECISAMENTE porque las columnas son anulables: MySQL
|
|
228
|
+
// trata cada NULL como distinto, así que el primero impide repetir una sección sin
|
|
229
|
+
// estorbarle a las filas de estado, y el segundo al contrario. Es el único sitio de este
|
|
230
|
+
// diseño donde el UNIQUE anulable juega a favor — en `company_feature` fue justo lo que
|
|
231
|
+
// no funcionó y por eso ahí la comprobación tuvo que irse al modelo.
|
|
232
|
+
,
|
|
233
|
+
(0, typeorm_1.Unique)("UQ_service_order_stage_section", ["service_order", "section"]),
|
|
234
|
+
(0, typeorm_1.Unique)("UQ_service_order_stage_status", ["service_order", "workboard_status"])
|
|
235
|
+
// DOC: MySQL 8.0.16 y superior lo hace cumplir (la base local está en 8.0.46). El API valida
|
|
236
|
+
// lo mismo de todos modos: una regla que solo vive en la base no da un mensaje de error
|
|
237
|
+
// que alguien pueda leer.
|
|
238
|
+
,
|
|
239
|
+
(0, typeorm_1.Check)("CK_service_order_stage_target", '(`section` IS NULL) <> (`workboard_status` IS NULL)')
|
|
240
|
+
], ServiceOrderStage);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ServiceOrder } from "./ServiceOrder";
|
|
2
|
+
import { ServiceOrderStage } from "./ServiceOrderStage";
|
|
3
|
+
import { WorkboardStatus } from "./WorkboardStatus";
|
|
4
|
+
import { Associate } from "./Associate";
|
|
5
|
+
/**
|
|
6
|
+
* DOC: El historial del tablero. Es lo que pinta la línea de tiempo del modal de la visita y
|
|
7
|
+
* de donde salen los reportes de tiempos.
|
|
8
|
+
*
|
|
9
|
+
* ── Por qué NO se reusa `service_order_history` ─────────────────────────────
|
|
10
|
+
*
|
|
11
|
+
* Esa tabla guarda el detalle en un `data` JSON, así que calcular "cuánto duró en pintura"
|
|
12
|
+
* obligaría a un `JSON_EXTRACT` sin índice sobre TODO el historial de ediciones de la visita
|
|
13
|
+
* —que incluye cada autoguardado del asesor—. Acá va tipado lo que se consulta, se filtra y se
|
|
14
|
+
* ordena, y el `data` queda para el resto: es el estilo de la casa, no una excepción.
|
|
15
|
+
*
|
|
16
|
+
* ── Lo que NO es negociable ─────────────────────────────────────────────────
|
|
17
|
+
*
|
|
18
|
+
* `data.source` dice de dónde vino el cambio: la pantalla, el celular o un lector de NFC.
|
|
19
|
+
* Hace falta porque atribuirle el trabajo al empleado asignado NO es lo mismo que haber
|
|
20
|
+
* identificado a la persona, y sin esa marca el reporte de estimado contra real trataría una
|
|
21
|
+
* atribución como si fuera una medición.
|
|
22
|
+
*/
|
|
23
|
+
export declare class WorkboardEvent {
|
|
24
|
+
id: number;
|
|
25
|
+
service_order: ServiceOrder;
|
|
26
|
+
service_order_stage: ServiceOrderStage | null;
|
|
27
|
+
event_type: number;
|
|
28
|
+
from_status: WorkboardStatus | null;
|
|
29
|
+
to_status: WorkboardStatus | null;
|
|
30
|
+
from_state: number | null;
|
|
31
|
+
to_state: number | null;
|
|
32
|
+
comment: string | null;
|
|
33
|
+
associate: Associate | null;
|
|
34
|
+
data: any | null;
|
|
35
|
+
created: Date;
|
|
36
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
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.WorkboardEvent = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
const ServiceOrder_1 = require("./ServiceOrder");
|
|
15
|
+
const ServiceOrderStage_1 = require("./ServiceOrderStage");
|
|
16
|
+
const WorkboardStatus_1 = require("./WorkboardStatus");
|
|
17
|
+
const Associate_1 = require("./Associate");
|
|
18
|
+
/**
|
|
19
|
+
* DOC: El historial del tablero. Es lo que pinta la línea de tiempo del modal de la visita y
|
|
20
|
+
* de donde salen los reportes de tiempos.
|
|
21
|
+
*
|
|
22
|
+
* ── Por qué NO se reusa `service_order_history` ─────────────────────────────
|
|
23
|
+
*
|
|
24
|
+
* Esa tabla guarda el detalle en un `data` JSON, así que calcular "cuánto duró en pintura"
|
|
25
|
+
* obligaría a un `JSON_EXTRACT` sin índice sobre TODO el historial de ediciones de la visita
|
|
26
|
+
* —que incluye cada autoguardado del asesor—. Acá va tipado lo que se consulta, se filtra y se
|
|
27
|
+
* ordena, y el `data` queda para el resto: es el estilo de la casa, no una excepción.
|
|
28
|
+
*
|
|
29
|
+
* ── Lo que NO es negociable ─────────────────────────────────────────────────
|
|
30
|
+
*
|
|
31
|
+
* `data.source` dice de dónde vino el cambio: la pantalla, el celular o un lector de NFC.
|
|
32
|
+
* Hace falta porque atribuirle el trabajo al empleado asignado NO es lo mismo que haber
|
|
33
|
+
* identificado a la persona, y sin esa marca el reporte de estimado contra real trataría una
|
|
34
|
+
* atribución como si fuera una medición.
|
|
35
|
+
*/
|
|
36
|
+
// DOC: La línea de tiempo lee por visita en orden cronológico.
|
|
37
|
+
let WorkboardEvent = class WorkboardEvent {
|
|
38
|
+
};
|
|
39
|
+
exports.WorkboardEvent = WorkboardEvent;
|
|
40
|
+
__decorate([
|
|
41
|
+
(0, typeorm_1.PrimaryGeneratedColumn)({
|
|
42
|
+
type: "int",
|
|
43
|
+
comment: "Número de identificación (ID) único de cada registro.",
|
|
44
|
+
}),
|
|
45
|
+
__metadata("design:type", Number)
|
|
46
|
+
], WorkboardEvent.prototype, "id", void 0);
|
|
47
|
+
__decorate([
|
|
48
|
+
(0, typeorm_1.ManyToOne)(() => ServiceOrder_1.ServiceOrder, (serviceOrder) => serviceOrder.workboard_events, {
|
|
49
|
+
onDelete: "CASCADE",
|
|
50
|
+
onUpdate: "NO ACTION",
|
|
51
|
+
}),
|
|
52
|
+
(0, typeorm_1.JoinColumn)({ name: "service_order" }),
|
|
53
|
+
__metadata("design:type", ServiceOrder_1.ServiceOrder)
|
|
54
|
+
], WorkboardEvent.prototype, "service_order", void 0);
|
|
55
|
+
__decorate([
|
|
56
|
+
(0, typeorm_1.ManyToOne)(() => ServiceOrderStage_1.ServiceOrderStage, (stage) => stage.events, {
|
|
57
|
+
onDelete: "SET NULL",
|
|
58
|
+
onUpdate: "NO ACTION",
|
|
59
|
+
nullable: true,
|
|
60
|
+
}),
|
|
61
|
+
(0, typeorm_1.JoinColumn)({ name: "service_order_stage" }),
|
|
62
|
+
__metadata("design:type", Object)
|
|
63
|
+
], WorkboardEvent.prototype, "service_order_stage", void 0);
|
|
64
|
+
__decorate([
|
|
65
|
+
(0, typeorm_1.Column)({
|
|
66
|
+
type: "int",
|
|
67
|
+
width: 1,
|
|
68
|
+
comment: "Qué pasó:\r\n1: Cambió el estado de la visita.\r\n2: Se tomó la etapa.\r\n3: Se terminó la etapa.\r\n4: Se bloqueó.\r\n5: Se desbloqueó.\r\n6: Cambió el responsable.\r\n7: Se retrocedió o se saltó una etapa.\r\n8: Se abrió una etapa en paralelo.",
|
|
69
|
+
}),
|
|
70
|
+
__metadata("design:type", Number)
|
|
71
|
+
], WorkboardEvent.prototype, "event_type", void 0);
|
|
72
|
+
__decorate([
|
|
73
|
+
(0, typeorm_1.ManyToOne)(() => WorkboardStatus_1.WorkboardStatus, {
|
|
74
|
+
onDelete: "SET NULL",
|
|
75
|
+
onUpdate: "NO ACTION",
|
|
76
|
+
nullable: true,
|
|
77
|
+
}),
|
|
78
|
+
(0, typeorm_1.JoinColumn)({ name: "from_status" }),
|
|
79
|
+
__metadata("design:type", Object)
|
|
80
|
+
], WorkboardEvent.prototype, "from_status", void 0);
|
|
81
|
+
__decorate([
|
|
82
|
+
(0, typeorm_1.ManyToOne)(() => WorkboardStatus_1.WorkboardStatus, {
|
|
83
|
+
onDelete: "SET NULL",
|
|
84
|
+
onUpdate: "NO ACTION",
|
|
85
|
+
nullable: true,
|
|
86
|
+
}),
|
|
87
|
+
(0, typeorm_1.JoinColumn)({ name: "to_status" }),
|
|
88
|
+
__metadata("design:type", Object)
|
|
89
|
+
], WorkboardEvent.prototype, "to_status", void 0);
|
|
90
|
+
__decorate([
|
|
91
|
+
(0, typeorm_1.Column)({
|
|
92
|
+
type: "int",
|
|
93
|
+
width: 1,
|
|
94
|
+
default: null,
|
|
95
|
+
nullable: true,
|
|
96
|
+
comment: "Estado del trabajo del que venía la etapa.",
|
|
97
|
+
}),
|
|
98
|
+
__metadata("design:type", Object)
|
|
99
|
+
], WorkboardEvent.prototype, "from_state", void 0);
|
|
100
|
+
__decorate([
|
|
101
|
+
(0, typeorm_1.Column)({
|
|
102
|
+
type: "int",
|
|
103
|
+
width: 1,
|
|
104
|
+
default: null,
|
|
105
|
+
nullable: true,
|
|
106
|
+
comment: "Estado del trabajo al que pasó la etapa.",
|
|
107
|
+
}),
|
|
108
|
+
__metadata("design:type", Object)
|
|
109
|
+
], WorkboardEvent.prototype, "to_state", void 0);
|
|
110
|
+
__decorate([
|
|
111
|
+
(0, typeorm_1.Column)({
|
|
112
|
+
length: 255,
|
|
113
|
+
type: "varchar",
|
|
114
|
+
default: null,
|
|
115
|
+
nullable: true,
|
|
116
|
+
comment: "Motivo escrito por el empleado. Obligatorio al bloquear, al retroceder y al saltar.",
|
|
117
|
+
}),
|
|
118
|
+
__metadata("design:type", Object)
|
|
119
|
+
], WorkboardEvent.prototype, "comment", void 0);
|
|
120
|
+
__decorate([
|
|
121
|
+
(0, typeorm_1.ManyToOne)(() => Associate_1.Associate, {
|
|
122
|
+
onDelete: "RESTRICT",
|
|
123
|
+
onUpdate: "NO ACTION",
|
|
124
|
+
nullable: true,
|
|
125
|
+
}),
|
|
126
|
+
(0, typeorm_1.JoinColumn)({ name: "associate" }),
|
|
127
|
+
__metadata("design:type", Object)
|
|
128
|
+
], WorkboardEvent.prototype, "associate", void 0);
|
|
129
|
+
__decorate([
|
|
130
|
+
(0, typeorm_1.Column)({
|
|
131
|
+
type: "json",
|
|
132
|
+
nullable: true,
|
|
133
|
+
default: null,
|
|
134
|
+
comment: "Campo de tipo JSON con el resto del detalle. Acá va `source` (pantalla, celular, lector).",
|
|
135
|
+
}),
|
|
136
|
+
__metadata("design:type", Object)
|
|
137
|
+
], WorkboardEvent.prototype, "data", void 0);
|
|
138
|
+
__decorate([
|
|
139
|
+
(0, typeorm_1.Column)({
|
|
140
|
+
type: "datetime",
|
|
141
|
+
comment: "Fecha en la que ocurrió el evento.",
|
|
142
|
+
default: () => "CURRENT_TIMESTAMP",
|
|
143
|
+
}),
|
|
144
|
+
__metadata("design:type", Date)
|
|
145
|
+
], WorkboardEvent.prototype, "created", void 0);
|
|
146
|
+
exports.WorkboardEvent = WorkboardEvent = __decorate([
|
|
147
|
+
(0, typeorm_1.Index)("IDX_workboard_event_timeline", ["service_order", "created"]),
|
|
148
|
+
(0, typeorm_1.Entity)({
|
|
149
|
+
comment: "Historial del tablero: qué pasó con cada etapa y con el estado de la visita.",
|
|
150
|
+
name: "workboard_event",
|
|
151
|
+
})
|
|
152
|
+
], WorkboardEvent);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Workshop } from "./Workshop";
|
|
2
|
+
import { Associate } from "./Associate";
|
|
3
|
+
import { ServiceOrder } from "./ServiceOrder";
|
|
4
|
+
import { ServiceOrderStage } from "./ServiceOrderStage";
|
|
5
|
+
export declare class WorkboardStatus {
|
|
6
|
+
id: number;
|
|
7
|
+
code: string;
|
|
8
|
+
workshop: Workshop;
|
|
9
|
+
name: string;
|
|
10
|
+
description: string | null;
|
|
11
|
+
color: string | null;
|
|
12
|
+
kind: number;
|
|
13
|
+
order: number;
|
|
14
|
+
is_system: boolean;
|
|
15
|
+
details: any | null;
|
|
16
|
+
created: Date;
|
|
17
|
+
created_by: Associate | null;
|
|
18
|
+
updated: Date | null;
|
|
19
|
+
updated_by: Associate | null;
|
|
20
|
+
status: number;
|
|
21
|
+
service_orders: ServiceOrder[];
|
|
22
|
+
stages: ServiceOrderStage[];
|
|
23
|
+
}
|