@asumano/worklip-typeorm-db 1.1.81 → 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/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
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
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.WorkboardStatus = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
const Workshop_1 = require("./Workshop");
|
|
15
|
+
const Associate_1 = require("./Associate");
|
|
16
|
+
const ServiceOrder_1 = require("./ServiceOrder");
|
|
17
|
+
const ServiceOrderStage_1 = require("./ServiceOrderStage");
|
|
18
|
+
// DOC: Una columna del tablero de trabajo. Dueño el TALLER y no la empresa, igual que
|
|
19
|
+
// `section`: dos sedes de la misma empresa pueden tener flujos distintos.
|
|
20
|
+
//
|
|
21
|
+
// Estas filas NO dependen de que se haya comprado el tablero. Se siembran al crear el
|
|
22
|
+
// taller porque el estado de una visita es del producto base —un taller sin tablero
|
|
23
|
+
// igual tiene que poder bloquear una sección cuando no llegó un repuesto—, y lo que se
|
|
24
|
+
// vende son las PANTALLAS del tablero y poder editar este catálogo.
|
|
25
|
+
//
|
|
26
|
+
// Gracias a eso `service_order.workboard_status` siempre apunta a una fila real y hay un
|
|
27
|
+
// solo camino en el código. Si dependiera de la compra habría que dejar la columna en
|
|
28
|
+
// NULL, codificar los estados a mano en el front y hacer un backfill el día de la venta.
|
|
29
|
+
let WorkboardStatus = class WorkboardStatus {
|
|
30
|
+
};
|
|
31
|
+
exports.WorkboardStatus = WorkboardStatus;
|
|
32
|
+
__decorate([
|
|
33
|
+
(0, typeorm_1.PrimaryGeneratedColumn)({
|
|
34
|
+
type: "int",
|
|
35
|
+
comment: "Número de identificación (ID) único de cada registro.",
|
|
36
|
+
}),
|
|
37
|
+
__metadata("design:type", Number)
|
|
38
|
+
], WorkboardStatus.prototype, "id", void 0);
|
|
39
|
+
__decorate([
|
|
40
|
+
(0, typeorm_1.Column)({
|
|
41
|
+
length: 15,
|
|
42
|
+
type: "varchar",
|
|
43
|
+
unique: true,
|
|
44
|
+
comment: "Código único del estado.",
|
|
45
|
+
}),
|
|
46
|
+
__metadata("design:type", String)
|
|
47
|
+
], WorkboardStatus.prototype, "code", void 0);
|
|
48
|
+
__decorate([
|
|
49
|
+
(0, typeorm_1.ManyToOne)(() => Workshop_1.Workshop, (workshop) => workshop.workboard_statuses, {
|
|
50
|
+
onDelete: "CASCADE",
|
|
51
|
+
onUpdate: "NO ACTION",
|
|
52
|
+
}),
|
|
53
|
+
(0, typeorm_1.JoinColumn)({ name: "workshop" }),
|
|
54
|
+
__metadata("design:type", Workshop_1.Workshop)
|
|
55
|
+
], WorkboardStatus.prototype, "workshop", void 0);
|
|
56
|
+
__decorate([
|
|
57
|
+
(0, typeorm_1.Column)({
|
|
58
|
+
length: 100,
|
|
59
|
+
type: "varchar",
|
|
60
|
+
comment: "Nombre del estado, tal como lo ve el taller en la columna.",
|
|
61
|
+
}),
|
|
62
|
+
__metadata("design:type", String)
|
|
63
|
+
], WorkboardStatus.prototype, "name", void 0);
|
|
64
|
+
__decorate([
|
|
65
|
+
(0, typeorm_1.Column)({
|
|
66
|
+
length: 255,
|
|
67
|
+
type: "varchar",
|
|
68
|
+
default: null,
|
|
69
|
+
nullable: true,
|
|
70
|
+
comment: "Descripción del estado. NULL si no se escribió ninguna.",
|
|
71
|
+
}),
|
|
72
|
+
__metadata("design:type", Object)
|
|
73
|
+
], WorkboardStatus.prototype, "description", void 0);
|
|
74
|
+
__decorate([
|
|
75
|
+
(0, typeorm_1.Column)({
|
|
76
|
+
length: 7,
|
|
77
|
+
type: "varchar",
|
|
78
|
+
default: null,
|
|
79
|
+
nullable: true,
|
|
80
|
+
comment: "Color del punto de la columna en formato #RRGGBB. NULL usa el color derivado del kind.",
|
|
81
|
+
}),
|
|
82
|
+
__metadata("design:type", Object)
|
|
83
|
+
], WorkboardStatus.prototype, "color", void 0);
|
|
84
|
+
__decorate([
|
|
85
|
+
(0, typeorm_1.Column)({
|
|
86
|
+
default: 7,
|
|
87
|
+
type: "int",
|
|
88
|
+
width: 1,
|
|
89
|
+
comment: "Semántica de sistema del estado:\r\n1: Entrada. Acá nace la visita y acá se configura.\r\n2: En proceso. Cuenta tiempo de trabajo.\r\n3: Bloqueado. Exige motivo y no cuenta como trabajo.\r\n4: Trabajo terminado. Todas las etapas cerradas.\r\n5: Listo para entregar. Ya se le avisó al cliente.\r\n6: Entregado. Terminal, cierra la visita en el tablero.\r\n7: Personalizado. Lo que el taller invente entre medias.",
|
|
90
|
+
}),
|
|
91
|
+
__metadata("design:type", Number)
|
|
92
|
+
], WorkboardStatus.prototype, "kind", void 0);
|
|
93
|
+
__decorate([
|
|
94
|
+
(0, typeorm_1.Column)({
|
|
95
|
+
type: "int",
|
|
96
|
+
comment: "Orden de la columna en el tablero.",
|
|
97
|
+
}),
|
|
98
|
+
__metadata("design:type", Number)
|
|
99
|
+
], WorkboardStatus.prototype, "order", void 0);
|
|
100
|
+
__decorate([
|
|
101
|
+
(0, typeorm_1.Column)({
|
|
102
|
+
default: false,
|
|
103
|
+
type: "boolean",
|
|
104
|
+
comment: "¿Es uno de los estados sembrados? 1 no se puede borrar, solo renombrar y reordenar.",
|
|
105
|
+
}),
|
|
106
|
+
__metadata("design:type", Boolean)
|
|
107
|
+
], WorkboardStatus.prototype, "is_system", void 0);
|
|
108
|
+
__decorate([
|
|
109
|
+
(0, typeorm_1.Column)({
|
|
110
|
+
type: "json",
|
|
111
|
+
nullable: true,
|
|
112
|
+
default: null,
|
|
113
|
+
comment: "Campo de tipo JSON para la configuración propia del estado.",
|
|
114
|
+
}),
|
|
115
|
+
__metadata("design:type", Object)
|
|
116
|
+
], WorkboardStatus.prototype, "details", void 0);
|
|
117
|
+
__decorate([
|
|
118
|
+
(0, typeorm_1.Column)({
|
|
119
|
+
type: "datetime",
|
|
120
|
+
comment: "Fecha de creación del registro.",
|
|
121
|
+
default: () => "CURRENT_TIMESTAMP",
|
|
122
|
+
}),
|
|
123
|
+
__metadata("design:type", Date)
|
|
124
|
+
], WorkboardStatus.prototype, "created", void 0);
|
|
125
|
+
__decorate([
|
|
126
|
+
(0, typeorm_1.ManyToOne)(() => Associate_1.Associate, {
|
|
127
|
+
onDelete: "RESTRICT",
|
|
128
|
+
onUpdate: "NO ACTION",
|
|
129
|
+
nullable: true,
|
|
130
|
+
}),
|
|
131
|
+
(0, typeorm_1.JoinColumn)({ name: "created_by" }),
|
|
132
|
+
__metadata("design:type", Object)
|
|
133
|
+
], WorkboardStatus.prototype, "created_by", void 0);
|
|
134
|
+
__decorate([
|
|
135
|
+
(0, typeorm_1.Column)({
|
|
136
|
+
type: "datetime",
|
|
137
|
+
default: null,
|
|
138
|
+
nullable: true,
|
|
139
|
+
comment: "Fecha de actualización del registro.",
|
|
140
|
+
onUpdate: "CURRENT_TIMESTAMP",
|
|
141
|
+
}),
|
|
142
|
+
__metadata("design:type", Object)
|
|
143
|
+
], WorkboardStatus.prototype, "updated", void 0);
|
|
144
|
+
__decorate([
|
|
145
|
+
(0, typeorm_1.ManyToOne)(() => Associate_1.Associate, {
|
|
146
|
+
onDelete: "RESTRICT",
|
|
147
|
+
onUpdate: "NO ACTION",
|
|
148
|
+
nullable: true,
|
|
149
|
+
}),
|
|
150
|
+
(0, typeorm_1.JoinColumn)({ name: "updated_by" }),
|
|
151
|
+
__metadata("design:type", Object)
|
|
152
|
+
], WorkboardStatus.prototype, "updated_by", void 0);
|
|
153
|
+
__decorate([
|
|
154
|
+
(0, typeorm_1.Column)({
|
|
155
|
+
default: 1,
|
|
156
|
+
type: "int",
|
|
157
|
+
width: 1,
|
|
158
|
+
comment: "¿La columna se muestra en el tablero?\r\n0: Inactivo.\r\n1: Activo.\r\nEs lo que permite que un taller que no distinga Finalizado de Por entregar apague uno.",
|
|
159
|
+
}),
|
|
160
|
+
__metadata("design:type", Number)
|
|
161
|
+
], WorkboardStatus.prototype, "status", void 0);
|
|
162
|
+
__decorate([
|
|
163
|
+
(0, typeorm_1.OneToMany)(() => ServiceOrder_1.ServiceOrder, (serviceOrder) => serviceOrder.workboard_status),
|
|
164
|
+
__metadata("design:type", Array)
|
|
165
|
+
], WorkboardStatus.prototype, "service_orders", void 0);
|
|
166
|
+
__decorate([
|
|
167
|
+
(0, typeorm_1.OneToMany)(() => ServiceOrderStage_1.ServiceOrderStage, (stage) => stage.workboard_status),
|
|
168
|
+
__metadata("design:type", Array)
|
|
169
|
+
], WorkboardStatus.prototype, "stages", void 0);
|
|
170
|
+
exports.WorkboardStatus = WorkboardStatus = __decorate([
|
|
171
|
+
(0, typeorm_1.Index)("IDX_workboard_status_workshop", ["workshop", "status"]),
|
|
172
|
+
(0, typeorm_1.Entity)({
|
|
173
|
+
comment: "Catálogo de columnas del tablero de trabajo, por concesionario/taller.",
|
|
174
|
+
name: "workboard_status",
|
|
175
|
+
})
|
|
176
|
+
// DOC: El orden es único dentro del taller, el mismo invariante que en `template_section`.
|
|
177
|
+
,
|
|
178
|
+
(0, typeorm_1.Unique)("UQ_workboard_status_order", ["workshop", "order"])
|
|
179
|
+
], WorkboardStatus);
|
|
@@ -10,6 +10,7 @@ import { MediaFile } from "./MediaFile";
|
|
|
10
10
|
import { WhatsappLog } from "./WhatsappLog";
|
|
11
11
|
import { EmailLog } from "./EmailLog";
|
|
12
12
|
import { ServiceOrderApproval } from "./ServiceOrderApproval";
|
|
13
|
+
import { WorkboardStatus } from "./WorkboardStatus";
|
|
13
14
|
export declare class Workshop {
|
|
14
15
|
id: number;
|
|
15
16
|
code: string;
|
|
@@ -28,6 +29,7 @@ export declare class Workshop {
|
|
|
28
29
|
associates: Associate[];
|
|
29
30
|
templates: Template[];
|
|
30
31
|
sections: Section[];
|
|
32
|
+
workboard_statuses: WorkboardStatus[];
|
|
31
33
|
service_orders: ServiceOrder[];
|
|
32
34
|
reminders: Reminder[];
|
|
33
35
|
media_files: MediaFile[];
|
|
@@ -23,6 +23,7 @@ const MediaFile_1 = require("./MediaFile");
|
|
|
23
23
|
const WhatsappLog_1 = require("./WhatsappLog");
|
|
24
24
|
const EmailLog_1 = require("./EmailLog");
|
|
25
25
|
const ServiceOrderApproval_1 = require("./ServiceOrderApproval");
|
|
26
|
+
const WorkboardStatus_1 = require("./WorkboardStatus");
|
|
26
27
|
let Workshop = class Workshop {
|
|
27
28
|
};
|
|
28
29
|
exports.Workshop = Workshop;
|
|
@@ -157,6 +158,10 @@ __decorate([
|
|
|
157
158
|
(0, typeorm_1.OneToMany)(() => Section_1.Section, (section) => section.workshop),
|
|
158
159
|
__metadata("design:type", Array)
|
|
159
160
|
], Workshop.prototype, "sections", void 0);
|
|
161
|
+
__decorate([
|
|
162
|
+
(0, typeorm_1.OneToMany)(() => WorkboardStatus_1.WorkboardStatus, (status) => status.workshop),
|
|
163
|
+
__metadata("design:type", Array)
|
|
164
|
+
], Workshop.prototype, "workboard_statuses", void 0);
|
|
160
165
|
__decorate([
|
|
161
166
|
(0, typeorm_1.OneToMany)(() => ServiceOrder_1.ServiceOrder, (serviceOrder) => serviceOrder.workshop),
|
|
162
167
|
__metadata("design:type", Array)
|
package/dist/entities.index.d.ts
CHANGED
|
@@ -54,6 +54,9 @@ export { Feature } from "./entities/Feature";
|
|
|
54
54
|
export { CompanyFeature } from "./entities/CompanyFeature";
|
|
55
55
|
export { DiscountCode } from "./entities/DiscountCode";
|
|
56
56
|
export { CompanyDiscount } from "./entities/CompanyDiscount";
|
|
57
|
+
export { WorkboardStatus } from "./entities/WorkboardStatus";
|
|
58
|
+
export { ServiceOrderStage } from "./entities/ServiceOrderStage";
|
|
59
|
+
export { WorkboardEvent } from "./entities/WorkboardEvent";
|
|
57
60
|
export { Associates } from "./views/Associates";
|
|
58
61
|
export { ServicesOrder } from "./views/ServicesOrder";
|
|
59
62
|
export { Clients } from "./views/Clients";
|
package/dist/entities.index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
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 = exports.AssociateSection = exports.AssociatePermission = exports.AssociateRole = exports.AssociatePlatform = 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.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.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.ServicesOrder = exports.Associates = exports.CompanyDiscount = exports.DiscountCode = exports.CompanyFeature = exports.Feature = exports.UsageAlert = exports.SubscriptionAddonTemplate = void 0;
|
|
4
|
+
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.ServicesOrder = exports.Associates = exports.WorkboardEvent = exports.ServiceOrderStage = exports.WorkboardStatus = exports.CompanyDiscount = exports.DiscountCode = exports.CompanyFeature = exports.Feature = exports.UsageAlert = exports.SubscriptionAddonTemplate = 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");
|
|
@@ -118,6 +118,15 @@ var DiscountCode_1 = require("./entities/DiscountCode");
|
|
|
118
118
|
Object.defineProperty(exports, "DiscountCode", { enumerable: true, get: function () { return DiscountCode_1.DiscountCode; } });
|
|
119
119
|
var CompanyDiscount_1 = require("./entities/CompanyDiscount");
|
|
120
120
|
Object.defineProperty(exports, "CompanyDiscount", { enumerable: true, get: function () { return CompanyDiscount_1.CompanyDiscount; } });
|
|
121
|
+
// DOC: Tablero de trabajo. Las tres son del producto BASE, no de la funcionalidad WORKBOARD:
|
|
122
|
+
// lo que se vende son las pantallas del tablero, no el estado de una visita. Ver
|
|
123
|
+
// `workboard.rules.ts` para los `kind`, los estados y la regla del sapito.
|
|
124
|
+
var WorkboardStatus_1 = require("./entities/WorkboardStatus");
|
|
125
|
+
Object.defineProperty(exports, "WorkboardStatus", { enumerable: true, get: function () { return WorkboardStatus_1.WorkboardStatus; } });
|
|
126
|
+
var ServiceOrderStage_1 = require("./entities/ServiceOrderStage");
|
|
127
|
+
Object.defineProperty(exports, "ServiceOrderStage", { enumerable: true, get: function () { return ServiceOrderStage_1.ServiceOrderStage; } });
|
|
128
|
+
var WorkboardEvent_1 = require("./entities/WorkboardEvent");
|
|
129
|
+
Object.defineProperty(exports, "WorkboardEvent", { enumerable: true, get: function () { return WorkboardEvent_1.WorkboardEvent; } });
|
|
121
130
|
var Associates_1 = require("./views/Associates");
|
|
122
131
|
Object.defineProperty(exports, "Associates", { enumerable: true, get: function () { return Associates_1.Associates; } });
|
|
123
132
|
var ServicesOrder_1 = require("./views/ServicesOrder");
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export * from "./company.legal";
|
|
|
6
6
|
export * from "./template.settings";
|
|
7
7
|
export * from "./feature.scope";
|
|
8
8
|
export * from "./discount.rules";
|
|
9
|
+
export * from "./workboard.rules";
|
|
9
10
|
export declare function createDataBaseSource(): DataSource;
|
|
10
11
|
export declare function showEntityName<T extends ObjectLiteral>(entity: EntityTarget<T>): Promise<Repository<T>>;
|
|
11
12
|
export declare function callStoredProcedureName(storedProcedure: any, elements: any): Promise<any>;
|
package/dist/index.js
CHANGED
|
@@ -64,6 +64,11 @@ __exportStar(require("./feature.scope"), exports);
|
|
|
64
64
|
// DOC: Reglas de los codigos de descuento. El monto descontado es PLATA y lo calculan igual
|
|
65
65
|
// el panel (al simular), el portal (al mostrar la factura) y el API (al cobrar).
|
|
66
66
|
__exportStar(require("./discount.rules"), exports);
|
|
67
|
+
// DOC: Reglas del tablero de trabajo: la semántica de las columnas, los estados de una etapa
|
|
68
|
+
// y a dónde se puede mover un carro. El API las hace cumplir y el front pinta en gris el
|
|
69
|
+
// destino inválido, así que tienen que ser la MISMA implementación o la pantalla habilitaría
|
|
70
|
+
// un movimiento que el servidor rechaza.
|
|
71
|
+
__exportStar(require("./workboard.rules"), exports);
|
|
67
72
|
let connection = null;
|
|
68
73
|
// DOC: Inicialización en curso. Se memoriza la PROMESA y no el resultado porque el patrón
|
|
69
74
|
// "si no está inicializada, inicialízala" tiene una carrera en el arranque en frío: dos
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
export interface ITemplateSettings {
|
|
2
2
|
cost?: number | null;
|
|
3
|
+
estimated_days?: number | null;
|
|
3
4
|
}
|
|
4
5
|
export declare const getTemplateCost: (settings: ITemplateSettings | null | undefined) => number | null;
|
|
5
6
|
export declare const withTemplateCost: (settings: ITemplateSettings | null | undefined, cost: number | null) => ITemplateSettings | null;
|
|
7
|
+
export declare const getTemplateEstimatedDays: (settings: ITemplateSettings | null | undefined) => number | null;
|
|
8
|
+
export declare const templatePromisedDate: (settings: ITemplateSettings | null | undefined, createdAt: Date) => string | null;
|
|
9
|
+
export declare const withTemplateEstimatedDays: (settings: ITemplateSettings | null | undefined, days: number | null) => ITemplateSettings | null;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// DOC: Configuración de la plantilla (`template.settings`). Vive acá y no en cada repo
|
|
3
3
|
// porque el API la escribe y valida, y el portal la pinta: una sola forma para los dos.
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.withTemplateCost = exports.getTemplateCost = void 0;
|
|
5
|
+
exports.withTemplateEstimatedDays = exports.templatePromisedDate = exports.getTemplateEstimatedDays = exports.withTemplateCost = exports.getTemplateCost = void 0;
|
|
6
6
|
// DOC: Costo configurado de una plantilla, ya normalizado. Devuelve `null` cuando no hay
|
|
7
7
|
// costo, y NUNCA un negativo ni un NaN: es lo que se copia al precio de la visita.
|
|
8
8
|
const getTemplateCost = (settings) => {
|
|
@@ -27,3 +27,45 @@ const withTemplateCost = (settings, cost) => {
|
|
|
27
27
|
return Object.keys(next).length > 0 ? next : null;
|
|
28
28
|
};
|
|
29
29
|
exports.withTemplateCost = withTemplateCost;
|
|
30
|
+
// DOC: Días estimados de la plantilla, ya normalizados. Devuelve `null` cuando no hay ninguno,
|
|
31
|
+
// y NUNCA un negativo, un decimal ni un NaN: de acá sale una fecha, así que un 2.5 dejaría una
|
|
32
|
+
// promesa a mitad de día que después nadie sabe interpretar. Se redondea hacia arriba, que es
|
|
33
|
+
// el lado seguro para prometerle algo a un cliente.
|
|
34
|
+
const getTemplateEstimatedDays = (settings) => {
|
|
35
|
+
const days = settings?.estimated_days;
|
|
36
|
+
if (days === null || days === undefined)
|
|
37
|
+
return null;
|
|
38
|
+
const value = Number(days);
|
|
39
|
+
if (!Number.isFinite(value) || value < 0)
|
|
40
|
+
return null;
|
|
41
|
+
return Math.ceil(value);
|
|
42
|
+
};
|
|
43
|
+
exports.getTemplateEstimatedDays = getTemplateEstimatedDays;
|
|
44
|
+
// DOC: La fecha que se le promete al cliente, a partir de la de creación de la visita y los
|
|
45
|
+
// días de la plantilla. Devuelve "YYYY-MM-DD" porque la columna es `date`: construir un
|
|
46
|
+
// `Date` acá y dejar que cada lado le ponga su zona es exactamente cómo el 22 se convierte en
|
|
47
|
+
// el 21 en Colombia.
|
|
48
|
+
//
|
|
49
|
+
// Los días se cuentan CORRIDOS: saltarse domingos y festivos es una mejora del valor por
|
|
50
|
+
// defecto (`country_holiday` ya existe) y no cambia nada de lo guardado, porque la fecha se
|
|
51
|
+
// puede editar.
|
|
52
|
+
const templatePromisedDate = (settings, createdAt) => {
|
|
53
|
+
const days = (0, exports.getTemplateEstimatedDays)(settings);
|
|
54
|
+
if (days === null)
|
|
55
|
+
return null;
|
|
56
|
+
const promised = new Date(Date.UTC(createdAt.getUTCFullYear(), createdAt.getUTCMonth(), createdAt.getUTCDate() + days));
|
|
57
|
+
return promised.toISOString().slice(0, 10);
|
|
58
|
+
};
|
|
59
|
+
exports.templatePromisedDate = templatePromisedDate;
|
|
60
|
+
// DOC: Deja `settings` listo para guardar con los días indicados, conservando lo demás.
|
|
61
|
+
// `null` los borra; el objeto entero pasa a `null` si queda vacío, para no dejar `{}` en la
|
|
62
|
+
// base. Espejo exacto de `withTemplateCost`.
|
|
63
|
+
const withTemplateEstimatedDays = (settings, days) => {
|
|
64
|
+
const next = { ...(settings ?? {}) };
|
|
65
|
+
if (days === null)
|
|
66
|
+
delete next.estimated_days;
|
|
67
|
+
else
|
|
68
|
+
next.estimated_days = days;
|
|
69
|
+
return Object.keys(next).length > 0 ? next : null;
|
|
70
|
+
};
|
|
71
|
+
exports.withTemplateEstimatedDays = withTemplateEstimatedDays;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DOC: La semántica de sistema de una columna del tablero (`workboard_status.kind`).
|
|
3
|
+
*
|
|
4
|
+
* Existe para que el catálogo pueda ser editable SIN que el API se quede sin saber nada. El
|
|
5
|
+
* nombre, el color y el orden son del taller; el significado es del sistema, porque hay
|
|
6
|
+
* preguntas que alguien tiene que poder responder: ¿en qué columna nace una visita?, ¿cuál
|
|
7
|
+
* cuenta como trabajo?, ¿cuál la cierra? Es la misma separación que hace Jira entre el estado
|
|
8
|
+
* y su categoría.
|
|
9
|
+
*
|
|
10
|
+
* Los seis primeros se siembran al crear el taller y no se pueden borrar (`is_system`), solo
|
|
11
|
+
* renombrar, recolorear, reordenar y apagar.
|
|
12
|
+
*/
|
|
13
|
+
export declare const WORKBOARD_STATUS_KIND: {
|
|
14
|
+
/** Entrada. Acá nace la visita y acá se configuran sus etapas y su fecha prometida. */
|
|
15
|
+
readonly WAITING: 1;
|
|
16
|
+
/** En proceso. Hay trabajo abierto en alguna etapa. */
|
|
17
|
+
readonly IN_PROGRESS: 2;
|
|
18
|
+
/** Bloqueado. Exige motivo escrito y no cuenta como trabajo. */
|
|
19
|
+
readonly BLOCKED: 3;
|
|
20
|
+
/** Trabajo terminado. Todas las etapas cerradas; falta lavado, control de calidad o avisar. */
|
|
21
|
+
readonly FINISHED: 4;
|
|
22
|
+
/** Listo para entregar. Ya se le avisó al cliente y el carro espera que venga. */
|
|
23
|
+
readonly READY: 5;
|
|
24
|
+
/** Entregado. Terminal: cierra la visita en el tablero. */
|
|
25
|
+
readonly DELIVERED: 6;
|
|
26
|
+
/** Personalizado. Lo que el taller invente entre medias. Este sí se borra. */
|
|
27
|
+
readonly CUSTOM: 7;
|
|
28
|
+
};
|
|
29
|
+
export type TWorkboardStatusKind = (typeof WORKBOARD_STATUS_KIND)[keyof typeof WORKBOARD_STATUS_KIND];
|
|
30
|
+
/**
|
|
31
|
+
* DOC: Los `kind` que se siembran al crear un taller, en el orden en que quedan las columnas.
|
|
32
|
+
* `CUSTOM` no está: ese lo crea el taller.
|
|
33
|
+
*/
|
|
34
|
+
export declare const SEEDED_WORKBOARD_KINDS: readonly TWorkboardStatusKind[];
|
|
35
|
+
/**
|
|
36
|
+
* DOC: El estado del trabajo en una etapa (`service_order_stage.state`).
|
|
37
|
+
*
|
|
38
|
+
* `NOT_REACHED` importa: al crear la visita TODAS las etapas nacen así, y la primera pasa a
|
|
39
|
+
* `PENDING` cuando la visita sale del estado de entrada. Sin ese valor habría que preguntar
|
|
40
|
+
* "pendiente Y con fecha de llegada" para saber si la tarjeta está en el tablero, y esa
|
|
41
|
+
* condición de dos columnas es la que se escribe mal una vez y pinta una tarjeta fantasma en
|
|
42
|
+
* una columna que el carro todavía no alcanzó.
|
|
43
|
+
*/
|
|
44
|
+
export declare const STAGE_STATE: {
|
|
45
|
+
/** No alcanzada. La visita todavía no llegó acá. */
|
|
46
|
+
readonly NOT_REACHED: 0;
|
|
47
|
+
/** Pendiente. Llegó y espera que alguien la tome. */
|
|
48
|
+
readonly PENDING: 1;
|
|
49
|
+
/** En proceso. Alguien la está trabajando. */
|
|
50
|
+
readonly IN_PROGRESS: 2;
|
|
51
|
+
/** Bloqueada, con motivo obligatorio. */
|
|
52
|
+
readonly BLOCKED: 3;
|
|
53
|
+
/** Terminada. */
|
|
54
|
+
readonly DONE: 4;
|
|
55
|
+
};
|
|
56
|
+
export type TStageState = (typeof STAGE_STATE)[keyof typeof STAGE_STATE];
|
|
57
|
+
/** DOC: Los estados en los que la tarjeta SE PINTA en el tablero. */
|
|
58
|
+
export declare const VISIBLE_STAGE_STATES: readonly TStageState[];
|
|
59
|
+
/**
|
|
60
|
+
* DOC: Qué pasó, para `workboard_event.event_type`.
|
|
61
|
+
*/
|
|
62
|
+
export declare const WORKBOARD_EVENT_TYPE: {
|
|
63
|
+
readonly STATUS_CHANGED: 1;
|
|
64
|
+
readonly STAGE_TAKEN: 2;
|
|
65
|
+
readonly STAGE_FINISHED: 3;
|
|
66
|
+
readonly STAGE_BLOCKED: 4;
|
|
67
|
+
readonly STAGE_UNBLOCKED: 5;
|
|
68
|
+
readonly ASSIGNEE_CHANGED: 6;
|
|
69
|
+
readonly STAGE_MOVED_BACK: 7;
|
|
70
|
+
readonly STAGE_OPENED_PARALLEL: 8;
|
|
71
|
+
};
|
|
72
|
+
export type TWorkboardEventType = (typeof WORKBOARD_EVENT_TYPE)[keyof typeof WORKBOARD_EVENT_TYPE];
|
|
73
|
+
/**
|
|
74
|
+
* DOC: De dónde vino el cambio (`workboard_event.data.source`).
|
|
75
|
+
*
|
|
76
|
+
* No es decorativo: atribuirle el trabajo al empleado ASIGNADO cuando el toque vino de un
|
|
77
|
+
* lector NO es lo mismo que haber identificado a la persona. Sin esta marca, el reporte de
|
|
78
|
+
* estimado contra real trataría una atribución como si fuera una medición.
|
|
79
|
+
*/
|
|
80
|
+
export declare const WORKBOARD_SOURCE: {
|
|
81
|
+
readonly SCREEN: "screen";
|
|
82
|
+
readonly MOBILE: "mobile";
|
|
83
|
+
readonly READER: "reader";
|
|
84
|
+
};
|
|
85
|
+
export type TWorkboardSource = (typeof WORKBOARD_SOURCE)[keyof typeof WORKBOARD_SOURCE];
|
|
86
|
+
export declare const FINAL_STAGE_ORDER_OFFSET = 1000;
|
|
87
|
+
/** DOC: El `stage_order` con el que se guarda una etapa final, dado el orden de su estado. */
|
|
88
|
+
export declare const finalStageOrder: (statusOrder: number) => number;
|
|
89
|
+
/** DOC: ¿Esta etapa es una de las finales (Finalizado, Por entregar, Entregado)? */
|
|
90
|
+
export declare const isFinalStageOrder: (stageOrder: number) => boolean;
|
|
91
|
+
/**
|
|
92
|
+
* DOC: Lo mínimo que hace falta saber de una etapa para decidir si se puede mover. Se recibe
|
|
93
|
+
* así, y no la entidad completa, para que el front pueda llamar a esto con lo que ya tiene
|
|
94
|
+
* pintado en la tarjeta.
|
|
95
|
+
*/
|
|
96
|
+
export interface IStageMoveCandidate {
|
|
97
|
+
id: number;
|
|
98
|
+
stage_order: number;
|
|
99
|
+
state: TStageState | number;
|
|
100
|
+
}
|
|
101
|
+
export type TStageMoveDenial = "SAME_STAGE" | "STAGE_DONE" | "STAGE_BLOCKED" | "NOT_NEXT_STAGE" | "BACKWARDS_NOT_ALLOWED";
|
|
102
|
+
export interface IStageMoveVerdict {
|
|
103
|
+
allowed: boolean;
|
|
104
|
+
/** DOC: Por qué no. La clave la traduce cada lado; el API la manda, no manda el texto. */
|
|
105
|
+
reason?: TStageMoveDenial;
|
|
106
|
+
/** DOC: ¿El movimiento exige comentario obligatorio? Retroceder y saltar, sí. */
|
|
107
|
+
requiresComment: boolean;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* DOC: LA REGLA DEL SAPITO. ¿Se puede mover el trabajo de `from` a `to`?
|
|
111
|
+
*
|
|
112
|
+
* De una etapa solo se salta a la SIGUIENTE por orden — de Inventario a Cotización, no a
|
|
113
|
+
* Pintura. Con dos excepciones, las dos con permiso y comentario obligatorio:
|
|
114
|
+
*
|
|
115
|
+
* · Retroceder, porque latonería encuentra algo y hay que devolver a desarme. Si solo se
|
|
116
|
+
* avanzara, la única salida del mecánico sería bloquear en falso, y ahí se pierde la
|
|
117
|
+
* métrica de bloqueos.
|
|
118
|
+
* · Saltar hacia adelante, porque un carro que no necesita pintura no debería pasar por
|
|
119
|
+
* pintura para poder salir.
|
|
120
|
+
*
|
|
121
|
+
* El bloqueo NO pasa por acá: bloquear es cambiarle el `state` a la MISMA etapa, no moverse.
|
|
122
|
+
* Eso es lo que permite que un carro esté bloqueado en pintura mientras avanza en latonería.
|
|
123
|
+
*
|
|
124
|
+
* `allowBackwardsOrSkip` es el permiso ya resuelto (MOVE_BACK_VISIT_WORKBOARD). Va como dato y
|
|
125
|
+
* no se consulta acá porque esta función es pura: el permiso lo resuelve el middleware.
|
|
126
|
+
*/
|
|
127
|
+
export declare const canMoveStage: (from: IStageMoveCandidate, to: IStageMoveCandidate, stages: readonly IStageMoveCandidate[], allowBackwardsOrSkip: boolean) => IStageMoveVerdict;
|
|
128
|
+
/**
|
|
129
|
+
* DOC: La etapa que sigue después de cerrar `from`, o `null` si era la última.
|
|
130
|
+
*
|
|
131
|
+
* Nace en `PENDING` y no en `IN_PROGRESS` a propósito: "pendiente" significa que el carro ya
|
|
132
|
+
* llegó y está esperando que alguien lo tome. Es lo que hace medible el tiempo que un carro
|
|
133
|
+
* pasa parado, y evita arrancarle una etapa a un empleado que todavía no sabe que le llegó.
|
|
134
|
+
*/
|
|
135
|
+
export declare const nextStageAfter: <T extends IStageMoveCandidate>(from: IStageMoveCandidate, stages: readonly T[]) => T | null;
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// DOC: Reglas del tablero de trabajo. Vive acá y no en cada repo porque el API las hace
|
|
3
|
+
// cumplir y el front las usa para pintar en gris el destino inválido: si estuvieran duplicadas,
|
|
4
|
+
// la pantalla y el servidor podrían discrepar sobre a dónde se puede mover un carro — y el
|
|
5
|
+
// usuario vería un destino habilitado que el servidor rechaza.
|
|
6
|
+
//
|
|
7
|
+
// Es un módulo PURO: no toca la base de datos ni depende de TypeORM. Igual que
|
|
8
|
+
// `visit.summary.ts`, `template.settings.ts` y `discount.rules.ts`.
|
|
9
|
+
//
|
|
10
|
+
// ⚠️ Importarlo SIEMPRE desde el módulo hoja en los fronts:
|
|
11
|
+
// import { WORKBOARD_STATUS_KIND } from "@asumano/worklip-typeorm-db/dist/workboard.rules";
|
|
12
|
+
// Desde el barrel arrastra TypeORM, dotenv y `crypto` al navegador y rompe el build de
|
|
13
|
+
// producción. El typecheck NO lo detecta: solo `pnpm build`.
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.nextStageAfter = exports.canMoveStage = exports.isFinalStageOrder = exports.finalStageOrder = exports.FINAL_STAGE_ORDER_OFFSET = exports.WORKBOARD_SOURCE = exports.WORKBOARD_EVENT_TYPE = exports.VISIBLE_STAGE_STATES = exports.STAGE_STATE = exports.SEEDED_WORKBOARD_KINDS = exports.WORKBOARD_STATUS_KIND = void 0;
|
|
16
|
+
/**
|
|
17
|
+
* DOC: La semántica de sistema de una columna del tablero (`workboard_status.kind`).
|
|
18
|
+
*
|
|
19
|
+
* Existe para que el catálogo pueda ser editable SIN que el API se quede sin saber nada. El
|
|
20
|
+
* nombre, el color y el orden son del taller; el significado es del sistema, porque hay
|
|
21
|
+
* preguntas que alguien tiene que poder responder: ¿en qué columna nace una visita?, ¿cuál
|
|
22
|
+
* cuenta como trabajo?, ¿cuál la cierra? Es la misma separación que hace Jira entre el estado
|
|
23
|
+
* y su categoría.
|
|
24
|
+
*
|
|
25
|
+
* Los seis primeros se siembran al crear el taller y no se pueden borrar (`is_system`), solo
|
|
26
|
+
* renombrar, recolorear, reordenar y apagar.
|
|
27
|
+
*/
|
|
28
|
+
exports.WORKBOARD_STATUS_KIND = {
|
|
29
|
+
/** Entrada. Acá nace la visita y acá se configuran sus etapas y su fecha prometida. */
|
|
30
|
+
WAITING: 1,
|
|
31
|
+
/** En proceso. Hay trabajo abierto en alguna etapa. */
|
|
32
|
+
IN_PROGRESS: 2,
|
|
33
|
+
/** Bloqueado. Exige motivo escrito y no cuenta como trabajo. */
|
|
34
|
+
BLOCKED: 3,
|
|
35
|
+
/** Trabajo terminado. Todas las etapas cerradas; falta lavado, control de calidad o avisar. */
|
|
36
|
+
FINISHED: 4,
|
|
37
|
+
/** Listo para entregar. Ya se le avisó al cliente y el carro espera que venga. */
|
|
38
|
+
READY: 5,
|
|
39
|
+
/** Entregado. Terminal: cierra la visita en el tablero. */
|
|
40
|
+
DELIVERED: 6,
|
|
41
|
+
/** Personalizado. Lo que el taller invente entre medias. Este sí se borra. */
|
|
42
|
+
CUSTOM: 7,
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* DOC: Los `kind` que se siembran al crear un taller, en el orden en que quedan las columnas.
|
|
46
|
+
* `CUSTOM` no está: ese lo crea el taller.
|
|
47
|
+
*/
|
|
48
|
+
exports.SEEDED_WORKBOARD_KINDS = [
|
|
49
|
+
exports.WORKBOARD_STATUS_KIND.WAITING,
|
|
50
|
+
exports.WORKBOARD_STATUS_KIND.IN_PROGRESS,
|
|
51
|
+
exports.WORKBOARD_STATUS_KIND.BLOCKED,
|
|
52
|
+
exports.WORKBOARD_STATUS_KIND.FINISHED,
|
|
53
|
+
exports.WORKBOARD_STATUS_KIND.READY,
|
|
54
|
+
exports.WORKBOARD_STATUS_KIND.DELIVERED,
|
|
55
|
+
];
|
|
56
|
+
/**
|
|
57
|
+
* DOC: El estado del trabajo en una etapa (`service_order_stage.state`).
|
|
58
|
+
*
|
|
59
|
+
* `NOT_REACHED` importa: al crear la visita TODAS las etapas nacen así, y la primera pasa a
|
|
60
|
+
* `PENDING` cuando la visita sale del estado de entrada. Sin ese valor habría que preguntar
|
|
61
|
+
* "pendiente Y con fecha de llegada" para saber si la tarjeta está en el tablero, y esa
|
|
62
|
+
* condición de dos columnas es la que se escribe mal una vez y pinta una tarjeta fantasma en
|
|
63
|
+
* una columna que el carro todavía no alcanzó.
|
|
64
|
+
*/
|
|
65
|
+
exports.STAGE_STATE = {
|
|
66
|
+
/** No alcanzada. La visita todavía no llegó acá. */
|
|
67
|
+
NOT_REACHED: 0,
|
|
68
|
+
/** Pendiente. Llegó y espera que alguien la tome. */
|
|
69
|
+
PENDING: 1,
|
|
70
|
+
/** En proceso. Alguien la está trabajando. */
|
|
71
|
+
IN_PROGRESS: 2,
|
|
72
|
+
/** Bloqueada, con motivo obligatorio. */
|
|
73
|
+
BLOCKED: 3,
|
|
74
|
+
/** Terminada. */
|
|
75
|
+
DONE: 4,
|
|
76
|
+
};
|
|
77
|
+
/** DOC: Los estados en los que la tarjeta SE PINTA en el tablero. */
|
|
78
|
+
exports.VISIBLE_STAGE_STATES = [
|
|
79
|
+
exports.STAGE_STATE.PENDING,
|
|
80
|
+
exports.STAGE_STATE.IN_PROGRESS,
|
|
81
|
+
exports.STAGE_STATE.BLOCKED,
|
|
82
|
+
];
|
|
83
|
+
/**
|
|
84
|
+
* DOC: Qué pasó, para `workboard_event.event_type`.
|
|
85
|
+
*/
|
|
86
|
+
exports.WORKBOARD_EVENT_TYPE = {
|
|
87
|
+
STATUS_CHANGED: 1,
|
|
88
|
+
STAGE_TAKEN: 2,
|
|
89
|
+
STAGE_FINISHED: 3,
|
|
90
|
+
STAGE_BLOCKED: 4,
|
|
91
|
+
STAGE_UNBLOCKED: 5,
|
|
92
|
+
ASSIGNEE_CHANGED: 6,
|
|
93
|
+
STAGE_MOVED_BACK: 7,
|
|
94
|
+
STAGE_OPENED_PARALLEL: 8,
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* DOC: De dónde vino el cambio (`workboard_event.data.source`).
|
|
98
|
+
*
|
|
99
|
+
* No es decorativo: atribuirle el trabajo al empleado ASIGNADO cuando el toque vino de un
|
|
100
|
+
* lector NO es lo mismo que haber identificado a la persona. Sin esta marca, el reporte de
|
|
101
|
+
* estimado contra real trataría una atribución como si fuera una medición.
|
|
102
|
+
*/
|
|
103
|
+
exports.WORKBOARD_SOURCE = {
|
|
104
|
+
SCREEN: "screen",
|
|
105
|
+
MOBILE: "mobile",
|
|
106
|
+
READER: "reader",
|
|
107
|
+
};
|
|
108
|
+
// DOC: Las etapas finales guardan `stage_order` con este desplazamiento, para que queden
|
|
109
|
+
// siempre al final sin depender de cuántas secciones tenga la plantilla. Así el tablero
|
|
110
|
+
// ordena sus columnas con un solo ORDER BY.
|
|
111
|
+
exports.FINAL_STAGE_ORDER_OFFSET = 1000;
|
|
112
|
+
/** DOC: El `stage_order` con el que se guarda una etapa final, dado el orden de su estado. */
|
|
113
|
+
const finalStageOrder = (statusOrder) => exports.FINAL_STAGE_ORDER_OFFSET + statusOrder;
|
|
114
|
+
exports.finalStageOrder = finalStageOrder;
|
|
115
|
+
/** DOC: ¿Esta etapa es una de las finales (Finalizado, Por entregar, Entregado)? */
|
|
116
|
+
const isFinalStageOrder = (stageOrder) => stageOrder >= exports.FINAL_STAGE_ORDER_OFFSET;
|
|
117
|
+
exports.isFinalStageOrder = isFinalStageOrder;
|
|
118
|
+
/**
|
|
119
|
+
* DOC: LA REGLA DEL SAPITO. ¿Se puede mover el trabajo de `from` a `to`?
|
|
120
|
+
*
|
|
121
|
+
* De una etapa solo se salta a la SIGUIENTE por orden — de Inventario a Cotización, no a
|
|
122
|
+
* Pintura. Con dos excepciones, las dos con permiso y comentario obligatorio:
|
|
123
|
+
*
|
|
124
|
+
* · Retroceder, porque latonería encuentra algo y hay que devolver a desarme. Si solo se
|
|
125
|
+
* avanzara, la única salida del mecánico sería bloquear en falso, y ahí se pierde la
|
|
126
|
+
* métrica de bloqueos.
|
|
127
|
+
* · Saltar hacia adelante, porque un carro que no necesita pintura no debería pasar por
|
|
128
|
+
* pintura para poder salir.
|
|
129
|
+
*
|
|
130
|
+
* El bloqueo NO pasa por acá: bloquear es cambiarle el `state` a la MISMA etapa, no moverse.
|
|
131
|
+
* Eso es lo que permite que un carro esté bloqueado en pintura mientras avanza en latonería.
|
|
132
|
+
*
|
|
133
|
+
* `allowBackwardsOrSkip` es el permiso ya resuelto (MOVE_BACK_VISIT_WORKBOARD). Va como dato y
|
|
134
|
+
* no se consulta acá porque esta función es pura: el permiso lo resuelve el middleware.
|
|
135
|
+
*/
|
|
136
|
+
const canMoveStage = (from, to, stages, allowBackwardsOrSkip) => {
|
|
137
|
+
if (from.id === to.id) {
|
|
138
|
+
return { allowed: false, reason: "SAME_STAGE", requiresComment: false };
|
|
139
|
+
}
|
|
140
|
+
if (from.state === exports.STAGE_STATE.DONE) {
|
|
141
|
+
return { allowed: false, reason: "STAGE_DONE", requiresComment: false };
|
|
142
|
+
}
|
|
143
|
+
// DOC: De una etapa bloqueada no se avanza: primero se desbloquea. Si se pudiera, el motivo
|
|
144
|
+
// del bloqueo quedaría colgando sobre un trabajo que ya siguió y el reporte diría que
|
|
145
|
+
// el carro estuvo trancado en un sitio donde nunca estuvo.
|
|
146
|
+
if (from.state === exports.STAGE_STATE.BLOCKED) {
|
|
147
|
+
return { allowed: false, reason: "STAGE_BLOCKED", requiresComment: false };
|
|
148
|
+
}
|
|
149
|
+
// DOC: "La siguiente" es la de orden inmediatamente mayor ENTRE LAS QUE ESTA VISITA TIENE.
|
|
150
|
+
// No es `from.stage_order + 1`: la plantilla pudo saltarse órdenes, o una sección pudo
|
|
151
|
+
// quedar apagada en esta plantilla, y ahí el +1 apuntaría a una etapa que no existe.
|
|
152
|
+
const forward = stages
|
|
153
|
+
.filter((stage) => stage.stage_order > from.stage_order)
|
|
154
|
+
.sort((a, b) => a.stage_order - b.stage_order);
|
|
155
|
+
const next = forward[0];
|
|
156
|
+
if (next && next.id === to.id) {
|
|
157
|
+
return { allowed: true, requiresComment: false };
|
|
158
|
+
}
|
|
159
|
+
if (!allowBackwardsOrSkip) {
|
|
160
|
+
const backwards = to.stage_order < from.stage_order;
|
|
161
|
+
return {
|
|
162
|
+
allowed: false,
|
|
163
|
+
reason: backwards ? "BACKWARDS_NOT_ALLOWED" : "NOT_NEXT_STAGE",
|
|
164
|
+
requiresComment: false,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
// DOC: Con permiso se puede a cualquier otra, adelante o atrás, pero SIEMPRE explicando por
|
|
168
|
+
// qué: un salto sin motivo es un hueco en el historial que después nadie puede leer.
|
|
169
|
+
return { allowed: true, requiresComment: true };
|
|
170
|
+
};
|
|
171
|
+
exports.canMoveStage = canMoveStage;
|
|
172
|
+
/**
|
|
173
|
+
* DOC: La etapa que sigue después de cerrar `from`, o `null` si era la última.
|
|
174
|
+
*
|
|
175
|
+
* Nace en `PENDING` y no en `IN_PROGRESS` a propósito: "pendiente" significa que el carro ya
|
|
176
|
+
* llegó y está esperando que alguien lo tome. Es lo que hace medible el tiempo que un carro
|
|
177
|
+
* pasa parado, y evita arrancarle una etapa a un empleado que todavía no sabe que le llegó.
|
|
178
|
+
*/
|
|
179
|
+
const nextStageAfter = (from, stages) => {
|
|
180
|
+
const forward = stages
|
|
181
|
+
.filter((stage) => stage.stage_order > from.stage_order)
|
|
182
|
+
.sort((a, b) => a.stage_order - b.stage_order);
|
|
183
|
+
return forward[0] ?? null;
|
|
184
|
+
};
|
|
185
|
+
exports.nextStageAfter = nextStageAfter;
|