@asumano/worklip-typeorm-db 1.1.93 → 1.1.95
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/booking.rules.d.ts +147 -0
- package/dist/booking.rules.js +305 -0
- package/dist/entities/Appointment.d.ts +38 -0
- package/dist/entities/Appointment.js +203 -0
- package/dist/entities/Reminder.js +1 -1
- package/dist/entities/ServiceOrder.d.ts +17 -0
- package/dist/entities/ServiceOrder.js +38 -0
- package/dist/entities.index.d.ts +1 -0
- package/dist/entities.index.js +6 -2
- package/dist/feature.codes.d.ts +1 -0
- package/dist/feature.codes.js +3 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +4 -0
- package/dist/template.settings.d.ts +6 -0
- package/dist/template.settings.js +18 -1
- package/dist/views/ServicesOrder.d.ts +4 -0
- package/dist/views/ServicesOrder.js +16 -0
- package/dist/workshop.schedule.d.ts +4 -0
- package/dist/workshop.schedule.js +12 -1
- package/package.json +1 -1
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { type IWorkshopSchedule } from "./workshop.schedule";
|
|
2
|
+
/**
|
|
3
|
+
* DOC: LAS REGLAS DE LA AGENDA DE CITAS. Módulo puro, sin TypeORM.
|
|
4
|
+
*
|
|
5
|
+
* Las comparten el API (que graba la cita y rechaza la que no cabe), el portal (que pinta los
|
|
6
|
+
* días libres) y el chatbot (que los lista en WhatsApp). Dos copias de «¿queda cupo?» se
|
|
7
|
+
* desvían, y la pantalla acabaría ofreciendo un día que el servidor rechaza.
|
|
8
|
+
*
|
|
9
|
+
* Tres decisiones que sostienen el módulo:
|
|
10
|
+
*
|
|
11
|
+
* · **El cliente escoge día y FRANJA (mañana/tarde), no hora exacta.** Una agenda de franjas
|
|
12
|
+
* de media hora no cabe en una lista de WhatsApp (diez filas), y ningún jefe de taller sabe
|
|
13
|
+
* si a las 10:40 va a haber bahía libre. Sabe cuántos carros aguanta el día.
|
|
14
|
+
* · **El cupo cuenta CARROS, no tiempo.** Cinco cambios de aceite y una latonería pesan lo
|
|
15
|
+
* mismo. Es la simplificación a propósito: `template.settings` NO tiene duración en horas y
|
|
16
|
+
* no se le va a agregar hasta que esto duela de verdad.
|
|
17
|
+
* · **Las franjas salen del horario que el taller YA configuró** (`workshop.details.schedule`),
|
|
18
|
+
* con sus festivos y sus cierres propios. Acá no se inventa ningún calendario.
|
|
19
|
+
*
|
|
20
|
+
* ⚠️ Los fronts lo importan por ruta hoja (`.../dist/booking.rules`), nunca desde el índice.
|
|
21
|
+
*/
|
|
22
|
+
export declare const APPOINTMENT_SLOT: {
|
|
23
|
+
readonly MORNING: 1;
|
|
24
|
+
readonly AFTERNOON: 2;
|
|
25
|
+
};
|
|
26
|
+
export type TAppointmentSlot = (typeof APPOINTMENT_SLOT)[keyof typeof APPOINTMENT_SLOT];
|
|
27
|
+
export declare const APPOINTMENT_SLOTS: TAppointmentSlot[];
|
|
28
|
+
export declare const APPOINTMENT_SLOT_LABEL: Record<number, string>;
|
|
29
|
+
/**
|
|
30
|
+
* DOC: Estado de la cita (`appointment.status`).
|
|
31
|
+
*
|
|
32
|
+
* Las dos cancelaciones van separadas porque no son el mismo hecho: la del taller obliga a
|
|
33
|
+
* avisarle al cliente y la del cliente no, y mezcladas no se puede medir cuál de las dos pasa.
|
|
34
|
+
*/
|
|
35
|
+
export declare const APPOINTMENT_STATUS: {
|
|
36
|
+
readonly REQUESTED: 1;
|
|
37
|
+
readonly CONFIRMED: 2;
|
|
38
|
+
readonly CANCELLED_BY_CLIENT: 3;
|
|
39
|
+
readonly CANCELLED_BY_WORKSHOP: 4;
|
|
40
|
+
readonly NO_SHOW: 5;
|
|
41
|
+
readonly ATTENDED: 6;
|
|
42
|
+
};
|
|
43
|
+
export type TAppointmentStatus = (typeof APPOINTMENT_STATUS)[keyof typeof APPOINTMENT_STATUS];
|
|
44
|
+
export declare const BLOCKING_APPOINTMENT_STATUS: number[];
|
|
45
|
+
export declare const APPOINTMENT_SOURCE: {
|
|
46
|
+
readonly CHATBOT: 1;
|
|
47
|
+
readonly WEB: 2;
|
|
48
|
+
readonly WORKSHOP: 3;
|
|
49
|
+
readonly EMAIL: 4;
|
|
50
|
+
};
|
|
51
|
+
export type TAppointmentSource = (typeof APPOINTMENT_SOURCE)[keyof typeof APPOINTMENT_SOURCE];
|
|
52
|
+
export interface IWorkshopBooking {
|
|
53
|
+
enabled: boolean;
|
|
54
|
+
max_per_day: number;
|
|
55
|
+
max_per_slot: number;
|
|
56
|
+
lead_hours: number;
|
|
57
|
+
horizon_days: number;
|
|
58
|
+
allow_client_cancel: boolean;
|
|
59
|
+
cancel_hours: number;
|
|
60
|
+
phone: string | null;
|
|
61
|
+
}
|
|
62
|
+
export declare const DEFAULT_WORKSHOP_BOOKING: IWorkshopBooking;
|
|
63
|
+
export declare const MAX_HORIZON_DAYS = 120;
|
|
64
|
+
/**
|
|
65
|
+
* DOC: La agenda guardada, normalizada. Devuelve `null` cuando no hay ninguna o está apagada,
|
|
66
|
+
* y quien llama lo trata como «este taller no recibe citas».
|
|
67
|
+
*
|
|
68
|
+
* Los números malos caen al valor por defecto en vez de tumbar la agenda entera: el json lo
|
|
69
|
+
* escribe un formulario, y un campo en blanco no puede dejar al taller sin citas.
|
|
70
|
+
*/
|
|
71
|
+
export declare const getWorkshopBooking: (details: unknown) => IWorkshopBooking | null;
|
|
72
|
+
export declare const withWorkshopBooking: (details: any, booking: IWorkshopBooking | null) => any;
|
|
73
|
+
export declare const isAppointmentSlot: (slot: unknown) => slot is TAppointmentSlot;
|
|
74
|
+
/**
|
|
75
|
+
* DOC: A qué minuto abre esa franja ese día, o `null` si el taller está cerrado.
|
|
76
|
+
*
|
|
77
|
+
* Sin horario configurado se responde la hora de entrada de siempre (8 a.m. / 2 p.m.): no
|
|
78
|
+
* saber cuándo abre el taller no es lo mismo que estar cerrado, que es la misma línea que ya
|
|
79
|
+
* traza `isOpenAt`.
|
|
80
|
+
*/
|
|
81
|
+
export declare const slotOpensAt: (schedule: IWorkshopSchedule | null, day: string, slot: TAppointmentSlot, holidays?: Set<string>) => number | null;
|
|
82
|
+
export type TTakenSlots = Record<string, Record<string, number>>;
|
|
83
|
+
export declare const shiftDay: (day: string, days: number) => string;
|
|
84
|
+
export declare const daysBetween: (from: string, to: string) => number;
|
|
85
|
+
export type TBookingReason = "DISABLED" | "BAD_DAY" | "PAST" | "TOO_FAR" | "CLOSED" | "TOO_SOON" | "FULL";
|
|
86
|
+
export interface IBookingContext {
|
|
87
|
+
booking: IWorkshopBooking | null;
|
|
88
|
+
schedule: IWorkshopSchedule | null;
|
|
89
|
+
holidays?: Set<string>;
|
|
90
|
+
taken?: TTakenSlots;
|
|
91
|
+
/** DOC: Hoy en la zona del TALLER ("YYYY-MM-DD"). Sale de `dayIn(zona)`. */
|
|
92
|
+
today: string;
|
|
93
|
+
/** DOC: Minutos transcurridos del día de hoy, también en la zona del taller. */
|
|
94
|
+
nowMinutes?: number;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* DOC: El corazón del módulo: ¿se puede meter una cita ese día en esa franja?
|
|
98
|
+
*
|
|
99
|
+
* Devuelve el motivo del NO, o `null` con los cupos que quedan. Lo usan `canBook` (para UNA
|
|
100
|
+
* fecha) y `availableDays` (recorriendo el horizonte): una sola implementación, porque si el
|
|
101
|
+
* listado y la validación se separan, la pantalla ofrece días que el servidor rechaza.
|
|
102
|
+
*/
|
|
103
|
+
export declare const evaluateSlot: (day: string, slot: TAppointmentSlot, context: IBookingContext) => {
|
|
104
|
+
reason: TBookingReason | null;
|
|
105
|
+
left: number;
|
|
106
|
+
};
|
|
107
|
+
export declare const canBook: (day: string, slot: TAppointmentSlot, context: IBookingContext) => {
|
|
108
|
+
ok: boolean;
|
|
109
|
+
reason: TBookingReason | null;
|
|
110
|
+
};
|
|
111
|
+
export interface IBookingDay {
|
|
112
|
+
day: string;
|
|
113
|
+
slots: {
|
|
114
|
+
slot: TAppointmentSlot;
|
|
115
|
+
left: number;
|
|
116
|
+
}[];
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* DOC: Los días con cupo, del horizonte completo. Es lo que pinta la pantalla y lo que el
|
|
120
|
+
* chatbot recorta a diez filas.
|
|
121
|
+
*
|
|
122
|
+
* ⚠️ Esto NO reserva nada: entre que se pinta la lista y el cliente toca un día, otro puede
|
|
123
|
+
* haberse llevado el último cupo. La garantía la da el API contando y grabando en la MISMA
|
|
124
|
+
* transacción con bloqueo — es el bug clásico de toda agenda.
|
|
125
|
+
*/
|
|
126
|
+
export declare const availableDays: (context: IBookingContext) => IBookingDay[];
|
|
127
|
+
/**
|
|
128
|
+
* DOC: ¿El cliente puede cancelar o mover esta cita él mismo?
|
|
129
|
+
*
|
|
130
|
+
* Es del taller la decisión: uno querrá que el cliente se organice solo y otro que llame. Con
|
|
131
|
+
* `cancel_hours` de por medio, porque una cancelación media hora antes ya le costó el cupo.
|
|
132
|
+
*/
|
|
133
|
+
export declare const canClientCancel: (booking: IWorkshopBooking | null, day: string, slot: TAppointmentSlot, context: Pick<IBookingContext, "schedule" | "holidays" | "today" | "nowMinutes">) => boolean;
|
|
134
|
+
/**
|
|
135
|
+
* DOC: ¿Esta cita alcanza a llevar aviso la víspera?
|
|
136
|
+
*
|
|
137
|
+
* El job corre una vez al día por la mañana, así que una cita para HOY o MAÑANA nunca lo
|
|
138
|
+
* alcanza: el aviso saldría después de la cita. Esas nacen ya marcadas como avisadas —el
|
|
139
|
+
* mensaje de confirmación cumple ese papel— y se decide al CONFIRMAR, no dentro del job: si
|
|
140
|
+
* lo decidiera el job, el comportamiento dependería de a qué horas alcanzó a correr.
|
|
141
|
+
*/
|
|
142
|
+
export declare const needsDayBeforeNotice: (day: string, today: string) => boolean;
|
|
143
|
+
export declare const minutesOfDay: (date: Date) => number;
|
|
144
|
+
export declare const workshopBookingContext: (details: unknown) => {
|
|
145
|
+
booking: IWorkshopBooking | null;
|
|
146
|
+
schedule: IWorkshopSchedule | null;
|
|
147
|
+
};
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.workshopBookingContext = exports.minutesOfDay = exports.needsDayBeforeNotice = exports.canClientCancel = exports.availableDays = exports.canBook = exports.evaluateSlot = exports.daysBetween = exports.shiftDay = exports.slotOpensAt = exports.isAppointmentSlot = exports.withWorkshopBooking = exports.getWorkshopBooking = exports.MAX_HORIZON_DAYS = exports.DEFAULT_WORKSHOP_BOOKING = exports.APPOINTMENT_SOURCE = exports.BLOCKING_APPOINTMENT_STATUS = exports.APPOINTMENT_STATUS = exports.APPOINTMENT_SLOT_LABEL = exports.APPOINTMENT_SLOTS = exports.APPOINTMENT_SLOT = void 0;
|
|
4
|
+
const workshop_schedule_1 = require("./workshop.schedule");
|
|
5
|
+
/**
|
|
6
|
+
* DOC: LAS REGLAS DE LA AGENDA DE CITAS. Módulo puro, sin TypeORM.
|
|
7
|
+
*
|
|
8
|
+
* Las comparten el API (que graba la cita y rechaza la que no cabe), el portal (que pinta los
|
|
9
|
+
* días libres) y el chatbot (que los lista en WhatsApp). Dos copias de «¿queda cupo?» se
|
|
10
|
+
* desvían, y la pantalla acabaría ofreciendo un día que el servidor rechaza.
|
|
11
|
+
*
|
|
12
|
+
* Tres decisiones que sostienen el módulo:
|
|
13
|
+
*
|
|
14
|
+
* · **El cliente escoge día y FRANJA (mañana/tarde), no hora exacta.** Una agenda de franjas
|
|
15
|
+
* de media hora no cabe en una lista de WhatsApp (diez filas), y ningún jefe de taller sabe
|
|
16
|
+
* si a las 10:40 va a haber bahía libre. Sabe cuántos carros aguanta el día.
|
|
17
|
+
* · **El cupo cuenta CARROS, no tiempo.** Cinco cambios de aceite y una latonería pesan lo
|
|
18
|
+
* mismo. Es la simplificación a propósito: `template.settings` NO tiene duración en horas y
|
|
19
|
+
* no se le va a agregar hasta que esto duela de verdad.
|
|
20
|
+
* · **Las franjas salen del horario que el taller YA configuró** (`workshop.details.schedule`),
|
|
21
|
+
* con sus festivos y sus cierres propios. Acá no se inventa ningún calendario.
|
|
22
|
+
*
|
|
23
|
+
* ⚠️ Los fronts lo importan por ruta hoja (`.../dist/booking.rules`), nunca desde el índice.
|
|
24
|
+
*/
|
|
25
|
+
// DOC: La franja del día. Son dos y no más porque es lo que cabe en tres botones de WhatsApp.
|
|
26
|
+
exports.APPOINTMENT_SLOT = {
|
|
27
|
+
MORNING: 1,
|
|
28
|
+
AFTERNOON: 2,
|
|
29
|
+
};
|
|
30
|
+
exports.APPOINTMENT_SLOTS = [
|
|
31
|
+
exports.APPOINTMENT_SLOT.MORNING,
|
|
32
|
+
exports.APPOINTMENT_SLOT.AFTERNOON,
|
|
33
|
+
];
|
|
34
|
+
exports.APPOINTMENT_SLOT_LABEL = {
|
|
35
|
+
[exports.APPOINTMENT_SLOT.MORNING]: "En la mañana",
|
|
36
|
+
[exports.APPOINTMENT_SLOT.AFTERNOON]: "En la tarde",
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* DOC: Estado de la cita (`appointment.status`).
|
|
40
|
+
*
|
|
41
|
+
* Las dos cancelaciones van separadas porque no son el mismo hecho: la del taller obliga a
|
|
42
|
+
* avisarle al cliente y la del cliente no, y mezcladas no se puede medir cuál de las dos pasa.
|
|
43
|
+
*/
|
|
44
|
+
exports.APPOINTMENT_STATUS = {
|
|
45
|
+
// DOC: Pedida y esperando al taller. Hoy no la produce nadie —la cita del cliente queda en
|
|
46
|
+
// firme si hay cupo—, y existe para el día que un taller quiera aprobar una por una.
|
|
47
|
+
REQUESTED: 1,
|
|
48
|
+
CONFIRMED: 2,
|
|
49
|
+
CANCELLED_BY_CLIENT: 3,
|
|
50
|
+
CANCELLED_BY_WORKSHOP: 4,
|
|
51
|
+
// DOC: No llegó. Es lo que separa «el taller tuvo el cupo bloqueado en balde» de una
|
|
52
|
+
// cancelación a tiempo, y sin el dato no hay cómo frenar al que nunca aparece.
|
|
53
|
+
NO_SHOW: 5,
|
|
54
|
+
// DOC: Llegó y se le abrió la visita. `appointment.service_order` apunta a cuál.
|
|
55
|
+
ATTENDED: 6,
|
|
56
|
+
};
|
|
57
|
+
// DOC: Los estados que OCUPAN cupo. Una cancelada libera el puesto; una atendida no, porque
|
|
58
|
+
// el carro sí ocupó el día.
|
|
59
|
+
exports.BLOCKING_APPOINTMENT_STATUS = [
|
|
60
|
+
exports.APPOINTMENT_STATUS.REQUESTED,
|
|
61
|
+
exports.APPOINTMENT_STATUS.CONFIRMED,
|
|
62
|
+
exports.APPOINTMENT_STATUS.NO_SHOW,
|
|
63
|
+
exports.APPOINTMENT_STATUS.ATTENDED,
|
|
64
|
+
];
|
|
65
|
+
// DOC: Por dónde entró la cita. Sin esto nunca se sabe si el canal que se construyó sirvió.
|
|
66
|
+
exports.APPOINTMENT_SOURCE = {
|
|
67
|
+
CHATBOT: 1,
|
|
68
|
+
// DOC: El enlace público del cliente (`/book/:code`), que funciona SIN chatbot comprado.
|
|
69
|
+
WEB: 2,
|
|
70
|
+
WORKSHOP: 3,
|
|
71
|
+
// DOC: Entró por el botón del correo del recordatorio. Va aparte de WEB para poder medir
|
|
72
|
+
// si ese botón vale lo que costó.
|
|
73
|
+
EMAIL: 4,
|
|
74
|
+
};
|
|
75
|
+
// DOC: Ocho carros al día, cuatro por franja, con un día de anticipación y un mes de horizonte.
|
|
76
|
+
// Es un punto de partida razonable para un taller mediano; nada lo aplica solo.
|
|
77
|
+
exports.DEFAULT_WORKSHOP_BOOKING = {
|
|
78
|
+
enabled: false,
|
|
79
|
+
max_per_day: 8,
|
|
80
|
+
max_per_slot: 4,
|
|
81
|
+
lead_hours: 24,
|
|
82
|
+
horizon_days: 30,
|
|
83
|
+
allow_client_cancel: true,
|
|
84
|
+
cancel_hours: 4,
|
|
85
|
+
phone: null,
|
|
86
|
+
};
|
|
87
|
+
// DOC: Tope duro del horizonte. Una agenda abierta a dos años no es una agenda, y el recorrido
|
|
88
|
+
// de `availableDays` es O(días).
|
|
89
|
+
exports.MAX_HORIZON_DAYS = 120;
|
|
90
|
+
/**
|
|
91
|
+
* DOC: Un número del formulario, o el valor por defecto.
|
|
92
|
+
*
|
|
93
|
+
* ⚠️ El campo VACÍO se ataja antes de `Number`: `Number("")` es 0, no NaN, y sin esto un cupo
|
|
94
|
+
* en blanco se guardaba como «cero carros al día» y dejaba al taller sin agenda en silencio.
|
|
95
|
+
*
|
|
96
|
+
* Por debajo de `min` también cae al valor por defecto y no se recorta: «cero carros al día»
|
|
97
|
+
* con la agenda ENCENDIDA es una contradicción, y la forma de no recibir citas es apagarla.
|
|
98
|
+
* Por encima de `max` sí se recorta, que es un tope nuestro y no un error de quien escribe.
|
|
99
|
+
*/
|
|
100
|
+
const bounded = (value, fallback, { min = 0, max = Number.MAX_SAFE_INTEGER } = {}) => {
|
|
101
|
+
if (value === null || value === undefined || value === "")
|
|
102
|
+
return fallback;
|
|
103
|
+
const number = Math.floor(Number(value));
|
|
104
|
+
if (!Number.isFinite(number) || number < min)
|
|
105
|
+
return fallback;
|
|
106
|
+
return Math.min(number, max);
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* DOC: La agenda guardada, normalizada. Devuelve `null` cuando no hay ninguna o está apagada,
|
|
110
|
+
* y quien llama lo trata como «este taller no recibe citas».
|
|
111
|
+
*
|
|
112
|
+
* Los números malos caen al valor por defecto en vez de tumbar la agenda entera: el json lo
|
|
113
|
+
* escribe un formulario, y un campo en blanco no puede dejar al taller sin citas.
|
|
114
|
+
*/
|
|
115
|
+
const getWorkshopBooking = (details) => {
|
|
116
|
+
const raw = details?.booking;
|
|
117
|
+
if (!raw || raw.enabled !== true)
|
|
118
|
+
return null;
|
|
119
|
+
const phone = String(raw.phone ?? "").trim();
|
|
120
|
+
return {
|
|
121
|
+
enabled: true,
|
|
122
|
+
// DOC: Los cupos y el horizonte van con `min: 1`; las horas de antelación admiten 0, que
|
|
123
|
+
// es «agenda para cuando quiera» y es una configuración legítima.
|
|
124
|
+
max_per_day: bounded(raw.max_per_day, exports.DEFAULT_WORKSHOP_BOOKING.max_per_day, {
|
|
125
|
+
min: 1,
|
|
126
|
+
}),
|
|
127
|
+
max_per_slot: bounded(raw.max_per_slot, exports.DEFAULT_WORKSHOP_BOOKING.max_per_slot, { min: 1 }),
|
|
128
|
+
lead_hours: bounded(raw.lead_hours, exports.DEFAULT_WORKSHOP_BOOKING.lead_hours),
|
|
129
|
+
horizon_days: bounded(raw.horizon_days, exports.DEFAULT_WORKSHOP_BOOKING.horizon_days, { min: 1, max: exports.MAX_HORIZON_DAYS }),
|
|
130
|
+
allow_client_cancel: raw.allow_client_cancel !== false,
|
|
131
|
+
cancel_hours: bounded(raw.cancel_hours, exports.DEFAULT_WORKSHOP_BOOKING.cancel_hours),
|
|
132
|
+
phone: phone || null,
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
exports.getWorkshopBooking = getWorkshopBooking;
|
|
136
|
+
// DOC: Deja `details` listo para guardar con la agenda indicada, conservando lo demás. Espejo
|
|
137
|
+
// de `withWorkshopSchedule`.
|
|
138
|
+
const withWorkshopBooking = (details, booking) => {
|
|
139
|
+
const next = { ...(details ?? {}) };
|
|
140
|
+
if (booking === null)
|
|
141
|
+
delete next.booking;
|
|
142
|
+
else
|
|
143
|
+
next.booking = booking;
|
|
144
|
+
return next;
|
|
145
|
+
};
|
|
146
|
+
exports.withWorkshopBooking = withWorkshopBooking;
|
|
147
|
+
// DOC: El corte entre mañana y tarde. Un tramo que cruza el mediodía (de 8 a 6 de corrido) abre
|
|
148
|
+
// las DOS franjas, y por eso se compara por solape y no por la hora de inicio.
|
|
149
|
+
const NOON_MINUTES = 12 * 60;
|
|
150
|
+
const SLOT_BOUNDS = {
|
|
151
|
+
[exports.APPOINTMENT_SLOT.MORNING]: { from: 0, to: NOON_MINUTES },
|
|
152
|
+
[exports.APPOINTMENT_SLOT.AFTERNOON]: { from: NOON_MINUTES, to: 24 * 60 },
|
|
153
|
+
};
|
|
154
|
+
const isAppointmentSlot = (slot) => exports.APPOINTMENT_SLOTS.includes(Number(slot));
|
|
155
|
+
exports.isAppointmentSlot = isAppointmentSlot;
|
|
156
|
+
/**
|
|
157
|
+
* DOC: A qué minuto abre esa franja ese día, o `null` si el taller está cerrado.
|
|
158
|
+
*
|
|
159
|
+
* Sin horario configurado se responde la hora de entrada de siempre (8 a.m. / 2 p.m.): no
|
|
160
|
+
* saber cuándo abre el taller no es lo mismo que estar cerrado, que es la misma línea que ya
|
|
161
|
+
* traza `isOpenAt`.
|
|
162
|
+
*/
|
|
163
|
+
const slotOpensAt = (schedule, day, slot, holidays = new Set()) => {
|
|
164
|
+
const bounds = SLOT_BOUNDS[Number(slot)];
|
|
165
|
+
if (!bounds)
|
|
166
|
+
return null;
|
|
167
|
+
if (!schedule)
|
|
168
|
+
return slot === exports.APPOINTMENT_SLOT.MORNING ? 8 * 60 : 14 * 60;
|
|
169
|
+
const open = (0, workshop_schedule_1.openRangesOnDay)(schedule, day, holidays)
|
|
170
|
+
.filter((range) => range.to > bounds.from && range.from < bounds.to)
|
|
171
|
+
.map((range) => Math.max(range.from, bounds.from));
|
|
172
|
+
return open.length ? Math.min(...open) : null;
|
|
173
|
+
};
|
|
174
|
+
exports.slotOpensAt = slotOpensAt;
|
|
175
|
+
const takenOn = (taken, day, slot) => {
|
|
176
|
+
const ofDay = taken[day] ?? {};
|
|
177
|
+
if (slot === undefined) {
|
|
178
|
+
return exports.APPOINTMENT_SLOTS.reduce((total, each) => total + (Number(ofDay[String(each)]) || 0), 0);
|
|
179
|
+
}
|
|
180
|
+
return Number(ofDay[String(slot)]) || 0;
|
|
181
|
+
};
|
|
182
|
+
const DAY_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
|
|
183
|
+
// DOC: Suma días a un "YYYY-MM-DD" con aritmética de UTC. Nunca con `new Date(day)` y getters
|
|
184
|
+
// locales: eso corre la fecha un día en Colombia, que es el bug de zona de siempre.
|
|
185
|
+
const shiftDay = (day, days) => {
|
|
186
|
+
const [year, month, date] = day.split("-").map(Number);
|
|
187
|
+
const shifted = new Date(Date.UTC(year, month - 1, date + days));
|
|
188
|
+
return shifted.toISOString().slice(0, 10);
|
|
189
|
+
};
|
|
190
|
+
exports.shiftDay = shiftDay;
|
|
191
|
+
// DOC: Cuántos días hay de `from` a `to`. Negativo si `to` ya pasó.
|
|
192
|
+
const daysBetween = (from, to) => {
|
|
193
|
+
const [fy, fm, fd] = from.split("-").map(Number);
|
|
194
|
+
const [ty, tm, td] = to.split("-").map(Number);
|
|
195
|
+
return Math.round((Date.UTC(ty, tm - 1, td) - Date.UTC(fy, fm - 1, fd)) / 86400000);
|
|
196
|
+
};
|
|
197
|
+
exports.daysBetween = daysBetween;
|
|
198
|
+
/**
|
|
199
|
+
* DOC: El corazón del módulo: ¿se puede meter una cita ese día en esa franja?
|
|
200
|
+
*
|
|
201
|
+
* Devuelve el motivo del NO, o `null` con los cupos que quedan. Lo usan `canBook` (para UNA
|
|
202
|
+
* fecha) y `availableDays` (recorriendo el horizonte): una sola implementación, porque si el
|
|
203
|
+
* listado y la validación se separan, la pantalla ofrece días que el servidor rechaza.
|
|
204
|
+
*/
|
|
205
|
+
const evaluateSlot = (day, slot, context) => {
|
|
206
|
+
const { booking, schedule, today } = context;
|
|
207
|
+
const holidays = context.holidays ?? new Set();
|
|
208
|
+
const taken = context.taken ?? {};
|
|
209
|
+
if (!booking)
|
|
210
|
+
return { reason: "DISABLED", left: 0 };
|
|
211
|
+
if (!DAY_PATTERN.test(day) || !(0, exports.isAppointmentSlot)(slot)) {
|
|
212
|
+
return { reason: "BAD_DAY", left: 0 };
|
|
213
|
+
}
|
|
214
|
+
const offset = (0, exports.daysBetween)(today, day);
|
|
215
|
+
if (offset < 0)
|
|
216
|
+
return { reason: "PAST", left: 0 };
|
|
217
|
+
if (offset > booking.horizon_days)
|
|
218
|
+
return { reason: "TOO_FAR", left: 0 };
|
|
219
|
+
const opensAt = (0, exports.slotOpensAt)(schedule, day, slot, holidays);
|
|
220
|
+
if (opensAt === null)
|
|
221
|
+
return { reason: "CLOSED", left: 0 };
|
|
222
|
+
// DOC: La antelación se mide en tiempo de RELOJ hasta que abre la franja, no en horas
|
|
223
|
+
// hábiles: «avíseme con 24 horas» es lo que el taller tiene en la cabeza.
|
|
224
|
+
const minutesAhead = offset * 24 * 60 + opensAt - (context.nowMinutes ?? 0);
|
|
225
|
+
if (minutesAhead < booking.lead_hours * 60) {
|
|
226
|
+
return { reason: "TOO_SOON", left: 0 };
|
|
227
|
+
}
|
|
228
|
+
const left = Math.min(booking.max_per_day - takenOn(taken, day), booking.max_per_slot - takenOn(taken, day, slot));
|
|
229
|
+
if (left <= 0)
|
|
230
|
+
return { reason: "FULL", left: 0 };
|
|
231
|
+
return { reason: null, left };
|
|
232
|
+
};
|
|
233
|
+
exports.evaluateSlot = evaluateSlot;
|
|
234
|
+
// DOC: ¿Cabe esta cita? Es lo que el API pregunta ANTES de grabar, y dentro de la misma
|
|
235
|
+
// transacción: ver el aviso de doble reserva en `availableDays`.
|
|
236
|
+
const canBook = (day, slot, context) => {
|
|
237
|
+
const { reason } = (0, exports.evaluateSlot)(day, slot, context);
|
|
238
|
+
return { ok: reason === null, reason };
|
|
239
|
+
};
|
|
240
|
+
exports.canBook = canBook;
|
|
241
|
+
/**
|
|
242
|
+
* DOC: Los días con cupo, del horizonte completo. Es lo que pinta la pantalla y lo que el
|
|
243
|
+
* chatbot recorta a diez filas.
|
|
244
|
+
*
|
|
245
|
+
* ⚠️ Esto NO reserva nada: entre que se pinta la lista y el cliente toca un día, otro puede
|
|
246
|
+
* haberse llevado el último cupo. La garantía la da el API contando y grabando en la MISMA
|
|
247
|
+
* transacción con bloqueo — es el bug clásico de toda agenda.
|
|
248
|
+
*/
|
|
249
|
+
const availableDays = (context) => {
|
|
250
|
+
const { booking } = context;
|
|
251
|
+
if (!booking)
|
|
252
|
+
return [];
|
|
253
|
+
const days = [];
|
|
254
|
+
for (let offset = 0; offset <= booking.horizon_days; offset += 1) {
|
|
255
|
+
const day = (0, exports.shiftDay)(context.today, offset);
|
|
256
|
+
const slots = exports.APPOINTMENT_SLOTS.map((slot) => ({
|
|
257
|
+
slot,
|
|
258
|
+
...(0, exports.evaluateSlot)(day, slot, context),
|
|
259
|
+
}))
|
|
260
|
+
.filter((each) => each.reason === null)
|
|
261
|
+
.map(({ slot, left }) => ({ slot, left }));
|
|
262
|
+
if (slots.length)
|
|
263
|
+
days.push({ day, slots });
|
|
264
|
+
}
|
|
265
|
+
return days;
|
|
266
|
+
};
|
|
267
|
+
exports.availableDays = availableDays;
|
|
268
|
+
/**
|
|
269
|
+
* DOC: ¿El cliente puede cancelar o mover esta cita él mismo?
|
|
270
|
+
*
|
|
271
|
+
* Es del taller la decisión: uno querrá que el cliente se organice solo y otro que llame. Con
|
|
272
|
+
* `cancel_hours` de por medio, porque una cancelación media hora antes ya le costó el cupo.
|
|
273
|
+
*/
|
|
274
|
+
const canClientCancel = (booking, day, slot, context) => {
|
|
275
|
+
if (!booking?.allow_client_cancel)
|
|
276
|
+
return false;
|
|
277
|
+
const opensAt = (0, exports.slotOpensAt)(context.schedule, day, slot, context.holidays ?? new Set());
|
|
278
|
+
if (opensAt === null)
|
|
279
|
+
return false;
|
|
280
|
+
const minutesAhead = (0, exports.daysBetween)(context.today, day) * 24 * 60 +
|
|
281
|
+
opensAt -
|
|
282
|
+
(context.nowMinutes ?? 0);
|
|
283
|
+
return minutesAhead >= booking.cancel_hours * 60;
|
|
284
|
+
};
|
|
285
|
+
exports.canClientCancel = canClientCancel;
|
|
286
|
+
/**
|
|
287
|
+
* DOC: ¿Esta cita alcanza a llevar aviso la víspera?
|
|
288
|
+
*
|
|
289
|
+
* El job corre una vez al día por la mañana, así que una cita para HOY o MAÑANA nunca lo
|
|
290
|
+
* alcanza: el aviso saldría después de la cita. Esas nacen ya marcadas como avisadas —el
|
|
291
|
+
* mensaje de confirmación cumple ese papel— y se decide al CONFIRMAR, no dentro del job: si
|
|
292
|
+
* lo decidiera el job, el comportamiento dependería de a qué horas alcanzó a correr.
|
|
293
|
+
*/
|
|
294
|
+
const needsDayBeforeNotice = (day, today) => (0, exports.daysBetween)(today, day) > 1;
|
|
295
|
+
exports.needsDayBeforeNotice = needsDayBeforeNotice;
|
|
296
|
+
// DOC: Los minutos del día de una hora de pared, para `nowMinutes`.
|
|
297
|
+
const minutesOfDay = (date) => date.getHours() * 60 + date.getMinutes();
|
|
298
|
+
exports.minutesOfDay = minutesOfDay;
|
|
299
|
+
// DOC: La agenda y el horario de un taller, leídos de su `details`. Atajo para no repetir las
|
|
300
|
+
// dos lecturas en cada modelo que las necesita.
|
|
301
|
+
const workshopBookingContext = (details) => ({
|
|
302
|
+
booking: (0, exports.getWorkshopBooking)(details),
|
|
303
|
+
schedule: (0, workshop_schedule_1.getWorkshopSchedule)(details),
|
|
304
|
+
});
|
|
305
|
+
exports.workshopBookingContext = workshopBookingContext;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Associate } from "./Associate";
|
|
2
|
+
import { Client } from "./Client";
|
|
3
|
+
import { Reminder } from "./Reminder";
|
|
4
|
+
import { ServiceOrder } from "./ServiceOrder";
|
|
5
|
+
import { Template } from "./Template";
|
|
6
|
+
import { Vehicle } from "./Vehicle";
|
|
7
|
+
import { Workshop } from "./Workshop";
|
|
8
|
+
/**
|
|
9
|
+
* DOC: LA CITA: lo que el cliente agenda antes de traer el carro.
|
|
10
|
+
*
|
|
11
|
+
* Es tabla propia y NO un estado de `service_order` por tres razones que cuestan plata:
|
|
12
|
+
* la visita consume cupo del plan (quien agenda y no viene le quemaría una visita del ciclo
|
|
13
|
+
* al taller), quema el consecutivo `visit_number` —único por taller y año— y nace metida en
|
|
14
|
+
* el tablero, el informe público, el PDF y la factura.
|
|
15
|
+
*
|
|
16
|
+
* La cita es una PROMESA; la visita es el TRABAJO. Cuando el carro llega se crea la visita
|
|
17
|
+
* DESDE la cita y se enlazan por `service_order`: ahí, y solo ahí, se consume el cupo.
|
|
18
|
+
*/
|
|
19
|
+
export declare class Appointment {
|
|
20
|
+
id: number;
|
|
21
|
+
code: string;
|
|
22
|
+
workshop: Workshop;
|
|
23
|
+
client: Client;
|
|
24
|
+
vehicle: Vehicle | null;
|
|
25
|
+
template: Template | null;
|
|
26
|
+
reminder: Reminder | null;
|
|
27
|
+
service_order: ServiceOrder | null;
|
|
28
|
+
appointment_date: string;
|
|
29
|
+
slot: number;
|
|
30
|
+
status: number;
|
|
31
|
+
source: number;
|
|
32
|
+
client_notes: string | null;
|
|
33
|
+
details: any | null;
|
|
34
|
+
created: Date;
|
|
35
|
+
created_by: Associate | null;
|
|
36
|
+
updated: Date | null;
|
|
37
|
+
updated_by: Associate | null;
|
|
38
|
+
}
|
|
@@ -0,0 +1,203 @@
|
|
|
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.Appointment = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
const Associate_1 = require("./Associate");
|
|
15
|
+
const Client_1 = require("./Client");
|
|
16
|
+
const Reminder_1 = require("./Reminder");
|
|
17
|
+
const ServiceOrder_1 = require("./ServiceOrder");
|
|
18
|
+
const Template_1 = require("./Template");
|
|
19
|
+
const Vehicle_1 = require("./Vehicle");
|
|
20
|
+
const Workshop_1 = require("./Workshop");
|
|
21
|
+
/**
|
|
22
|
+
* DOC: LA CITA: lo que el cliente agenda antes de traer el carro.
|
|
23
|
+
*
|
|
24
|
+
* Es tabla propia y NO un estado de `service_order` por tres razones que cuestan plata:
|
|
25
|
+
* la visita consume cupo del plan (quien agenda y no viene le quemaría una visita del ciclo
|
|
26
|
+
* al taller), quema el consecutivo `visit_number` —único por taller y año— y nace metida en
|
|
27
|
+
* el tablero, el informe público, el PDF y la factura.
|
|
28
|
+
*
|
|
29
|
+
* La cita es una PROMESA; la visita es el TRABAJO. Cuando el carro llega se crea la visita
|
|
30
|
+
* DESDE la cita y se enlazan por `service_order`: ahí, y solo ahí, se consume el cupo.
|
|
31
|
+
*/
|
|
32
|
+
// DOC: El conteo de cupo corre en CADA agendamiento y filtra por taller y fecha. Sin esto es
|
|
33
|
+
// un scan completo de la tabla en cada intento.
|
|
34
|
+
let Appointment = class Appointment {
|
|
35
|
+
};
|
|
36
|
+
exports.Appointment = Appointment;
|
|
37
|
+
__decorate([
|
|
38
|
+
(0, typeorm_1.PrimaryGeneratedColumn)({
|
|
39
|
+
type: "int",
|
|
40
|
+
comment: "Número de identificación (ID) único de cada registro.",
|
|
41
|
+
}),
|
|
42
|
+
__metadata("design:type", Number)
|
|
43
|
+
], Appointment.prototype, "id", void 0);
|
|
44
|
+
__decorate([
|
|
45
|
+
(0, typeorm_1.Column)({
|
|
46
|
+
length: 15,
|
|
47
|
+
type: "varchar",
|
|
48
|
+
unique: true,
|
|
49
|
+
comment: "Código único de la cita. Es la llave del enlace público del cliente.",
|
|
50
|
+
}),
|
|
51
|
+
__metadata("design:type", String)
|
|
52
|
+
], Appointment.prototype, "code", void 0);
|
|
53
|
+
__decorate([
|
|
54
|
+
(0, typeorm_1.ManyToOne)(() => Workshop_1.Workshop, {
|
|
55
|
+
onDelete: "CASCADE",
|
|
56
|
+
onUpdate: "NO ACTION",
|
|
57
|
+
}),
|
|
58
|
+
(0, typeorm_1.JoinColumn)({ name: "workshop" }),
|
|
59
|
+
__metadata("design:type", Workshop_1.Workshop)
|
|
60
|
+
], Appointment.prototype, "workshop", void 0);
|
|
61
|
+
__decorate([
|
|
62
|
+
(0, typeorm_1.ManyToOne)(() => Client_1.Client, {
|
|
63
|
+
onDelete: "RESTRICT",
|
|
64
|
+
onUpdate: "NO ACTION",
|
|
65
|
+
}),
|
|
66
|
+
(0, typeorm_1.JoinColumn)({ name: "client" }),
|
|
67
|
+
__metadata("design:type", Client_1.Client)
|
|
68
|
+
], Appointment.prototype, "client", void 0);
|
|
69
|
+
__decorate([
|
|
70
|
+
(0, typeorm_1.ManyToOne)(() => Vehicle_1.Vehicle, {
|
|
71
|
+
onDelete: "RESTRICT",
|
|
72
|
+
onUpdate: "NO ACTION",
|
|
73
|
+
nullable: true,
|
|
74
|
+
}),
|
|
75
|
+
(0, typeorm_1.JoinColumn)({ name: "vehicle" }),
|
|
76
|
+
__metadata("design:type", Object)
|
|
77
|
+
], Appointment.prototype, "vehicle", void 0);
|
|
78
|
+
__decorate([
|
|
79
|
+
(0, typeorm_1.ManyToOne)(() => Template_1.Template, {
|
|
80
|
+
onDelete: "RESTRICT",
|
|
81
|
+
onUpdate: "NO ACTION",
|
|
82
|
+
nullable: true,
|
|
83
|
+
}),
|
|
84
|
+
(0, typeorm_1.JoinColumn)({ name: "template" }),
|
|
85
|
+
__metadata("design:type", Object)
|
|
86
|
+
], Appointment.prototype, "template", void 0);
|
|
87
|
+
__decorate([
|
|
88
|
+
(0, typeorm_1.ManyToOne)(() => Reminder_1.Reminder, {
|
|
89
|
+
onDelete: "SET NULL",
|
|
90
|
+
onUpdate: "NO ACTION",
|
|
91
|
+
nullable: true,
|
|
92
|
+
}),
|
|
93
|
+
(0, typeorm_1.JoinColumn)({ name: "reminder" }),
|
|
94
|
+
__metadata("design:type", Object)
|
|
95
|
+
], Appointment.prototype, "reminder", void 0);
|
|
96
|
+
__decorate([
|
|
97
|
+
(0, typeorm_1.ManyToOne)(() => ServiceOrder_1.ServiceOrder, {
|
|
98
|
+
onDelete: "SET NULL",
|
|
99
|
+
onUpdate: "NO ACTION",
|
|
100
|
+
nullable: true,
|
|
101
|
+
}),
|
|
102
|
+
(0, typeorm_1.JoinColumn)({ name: "service_order" }),
|
|
103
|
+
__metadata("design:type", Object)
|
|
104
|
+
], Appointment.prototype, "service_order", void 0);
|
|
105
|
+
__decorate([
|
|
106
|
+
(0, typeorm_1.Column)({
|
|
107
|
+
type: "date",
|
|
108
|
+
comment: "Día de la cita.",
|
|
109
|
+
}),
|
|
110
|
+
__metadata("design:type", String)
|
|
111
|
+
], Appointment.prototype, "appointment_date", void 0);
|
|
112
|
+
__decorate([
|
|
113
|
+
(0, typeorm_1.Column)({
|
|
114
|
+
default: 1,
|
|
115
|
+
type: "int",
|
|
116
|
+
width: 1,
|
|
117
|
+
comment: "Franja del día:\n1. Mañana.\n2. Tarde.",
|
|
118
|
+
}),
|
|
119
|
+
__metadata("design:type", Number)
|
|
120
|
+
], Appointment.prototype, "slot", void 0);
|
|
121
|
+
__decorate([
|
|
122
|
+
(0, typeorm_1.Column)({
|
|
123
|
+
default: 2,
|
|
124
|
+
type: "int",
|
|
125
|
+
width: 1,
|
|
126
|
+
comment: "Estado de la cita:\n1. Solicitada: pedida y esperando al taller.\n2. Confirmada: en firme, ocupa cupo.\n3. Cancelada por el cliente.\n4. Cancelada por el taller.\n5. No asistió: el cupo se bloqueó en balde.\n6. Atendida: llegó y se le abrió la visita (service_order).",
|
|
127
|
+
}),
|
|
128
|
+
__metadata("design:type", Number)
|
|
129
|
+
], Appointment.prototype, "status", void 0);
|
|
130
|
+
__decorate([
|
|
131
|
+
(0, typeorm_1.Column)({
|
|
132
|
+
default: 3,
|
|
133
|
+
type: "int",
|
|
134
|
+
width: 1,
|
|
135
|
+
comment: "Por dónde entró la cita:\n1. Chatbot de WhatsApp.\n2. Enlace público del cliente.\n3. El taller la creó.\n4. Botón del correo del recordatorio.",
|
|
136
|
+
}),
|
|
137
|
+
__metadata("design:type", Number)
|
|
138
|
+
], Appointment.prototype, "source", void 0);
|
|
139
|
+
__decorate([
|
|
140
|
+
(0, typeorm_1.Column)({
|
|
141
|
+
length: 255,
|
|
142
|
+
type: "varchar",
|
|
143
|
+
default: null,
|
|
144
|
+
nullable: true,
|
|
145
|
+
comment: "Lo que el cliente escribió al agendar.",
|
|
146
|
+
}),
|
|
147
|
+
__metadata("design:type", Object)
|
|
148
|
+
], Appointment.prototype, "client_notes", void 0);
|
|
149
|
+
__decorate([
|
|
150
|
+
(0, typeorm_1.Column)({
|
|
151
|
+
type: "json",
|
|
152
|
+
nullable: true,
|
|
153
|
+
default: null,
|
|
154
|
+
comment: "Campo de tipo JSON para lo que la cita necesite (hoy: reminded, plate_hint).",
|
|
155
|
+
}),
|
|
156
|
+
__metadata("design:type", Object)
|
|
157
|
+
], Appointment.prototype, "details", void 0);
|
|
158
|
+
__decorate([
|
|
159
|
+
(0, typeorm_1.Column)({
|
|
160
|
+
type: "datetime",
|
|
161
|
+
comment: "Fecha de creación del registro.",
|
|
162
|
+
default: () => "CURRENT_TIMESTAMP",
|
|
163
|
+
}),
|
|
164
|
+
__metadata("design:type", Date)
|
|
165
|
+
], Appointment.prototype, "created", void 0);
|
|
166
|
+
__decorate([
|
|
167
|
+
(0, typeorm_1.ManyToOne)(() => Associate_1.Associate, {
|
|
168
|
+
onDelete: "RESTRICT",
|
|
169
|
+
onUpdate: "NO ACTION",
|
|
170
|
+
nullable: true,
|
|
171
|
+
}),
|
|
172
|
+
(0, typeorm_1.JoinColumn)({ name: "created_by" }),
|
|
173
|
+
__metadata("design:type", Object)
|
|
174
|
+
], Appointment.prototype, "created_by", void 0);
|
|
175
|
+
__decorate([
|
|
176
|
+
(0, typeorm_1.Column)({
|
|
177
|
+
type: "datetime",
|
|
178
|
+
default: null,
|
|
179
|
+
nullable: true,
|
|
180
|
+
comment: "Fecha de actualización del registro.",
|
|
181
|
+
onUpdate: "CURRENT_TIMESTAMP",
|
|
182
|
+
}),
|
|
183
|
+
__metadata("design:type", Object)
|
|
184
|
+
], Appointment.prototype, "updated", void 0);
|
|
185
|
+
__decorate([
|
|
186
|
+
(0, typeorm_1.ManyToOne)(() => Associate_1.Associate, {
|
|
187
|
+
onDelete: "RESTRICT",
|
|
188
|
+
onUpdate: "NO ACTION",
|
|
189
|
+
nullable: true,
|
|
190
|
+
}),
|
|
191
|
+
(0, typeorm_1.JoinColumn)({ name: "updated_by" }),
|
|
192
|
+
__metadata("design:type", Object)
|
|
193
|
+
], Appointment.prototype, "updated_by", void 0);
|
|
194
|
+
exports.Appointment = Appointment = __decorate([
|
|
195
|
+
(0, typeorm_1.Index)("IDX_appointment_workshop_date", ["workshop", "appointment_date"])
|
|
196
|
+
// DOC: Para la pantalla del cliente y el chatbot: «mis citas», que van por cliente y fecha.
|
|
197
|
+
,
|
|
198
|
+
(0, typeorm_1.Index)("IDX_appointment_client_date", ["client", "appointment_date"]),
|
|
199
|
+
(0, typeorm_1.Entity)({
|
|
200
|
+
comment: "Citas que los clientes agendan en el concesionario/taller.",
|
|
201
|
+
name: "appointment",
|
|
202
|
+
})
|
|
203
|
+
], Appointment);
|
|
@@ -132,7 +132,7 @@ __decorate([
|
|
|
132
132
|
default: 1,
|
|
133
133
|
type: "int",
|
|
134
134
|
width: 1,
|
|
135
|
-
comment: "Estado en el que se encuentra el recordatorio:\n1. Pendiente.\n2. Entregado\n3. Cancelado.\n4. Con error: el sistema no pudo entregarlo y reintentarlo daría lo mismo (el cliente no autorizó el envío, no tiene datos de contacto o el recordatorio no tiene vehículo). El motivo queda en details.notification.",
|
|
135
|
+
comment: "Estado en el que se encuentra el recordatorio:\n1. Pendiente.\n2. Entregado\n3. Cancelado.\n4. Con error: el sistema no pudo entregarlo y reintentarlo daría lo mismo (el cliente no autorizó el envío, no tiene datos de contacto o el recordatorio no tiene vehículo). El motivo queda en details.notification.\n5. Agendado: el cliente ya agendó una cita por este recordatorio, así que no se le avisa. Vuelve a 1 si la cita se cancela y la fecha no ha pasado.",
|
|
136
136
|
}),
|
|
137
137
|
__metadata("design:type", Number)
|
|
138
138
|
], Reminder.prototype, "status", void 0);
|
|
@@ -33,6 +33,23 @@ export declare class ServiceOrder {
|
|
|
33
33
|
workboard_status: WorkboardStatus | null;
|
|
34
34
|
workboard_changed: Date | null;
|
|
35
35
|
promised_date: Date | null;
|
|
36
|
+
/**
|
|
37
|
+
* DOC: LA CALIFICACIÓN DEL CLIENTE. La deja él mismo desde su informe público, cuando ya
|
|
38
|
+
* recibió el vehículo, y solo si la plantilla de la visita la pide
|
|
39
|
+
* (`template.settings.satisfaction`).
|
|
40
|
+
*
|
|
41
|
+
* Son columnas y no una llave dentro de `data` —donde vive el árbol de la visita— porque
|
|
42
|
+
* esto se mira AGREGADO: el promedio del taller, del mes, la tasa de respuesta. Un AVG sobre
|
|
43
|
+
* una columna no obliga a leer el JSON completo de cada visita, y ordenar y filtrar la tabla
|
|
44
|
+
* de visitas por la nota es un rango como cualquier otro.
|
|
45
|
+
*
|
|
46
|
+
* Y no una tabla aparte porque es 1 a 1 con la visita y siempre se lee junto con ella: un
|
|
47
|
+
* LEFT JOIN en la vista y en cada promedio, a cambio de nada.
|
|
48
|
+
*/
|
|
49
|
+
satisfaction_score: number | null;
|
|
50
|
+
satisfaction_comment: string | null;
|
|
51
|
+
satisfaction_date: Date | null;
|
|
52
|
+
satisfaction_asked: Date | null;
|
|
36
53
|
stages: ServiceOrderStage[];
|
|
37
54
|
workboard_events: WorkboardEvent[];
|
|
38
55
|
service_order_history: ServiceOrderHistory[];
|
|
@@ -205,6 +205,44 @@ __decorate([
|
|
|
205
205
|
}),
|
|
206
206
|
__metadata("design:type", Object)
|
|
207
207
|
], ServiceOrder.prototype, "promised_date", void 0);
|
|
208
|
+
__decorate([
|
|
209
|
+
(0, typeorm_1.Column)({
|
|
210
|
+
type: "tinyint",
|
|
211
|
+
unsigned: true,
|
|
212
|
+
nullable: true,
|
|
213
|
+
default: null,
|
|
214
|
+
comment: "Calificación del cliente, de 1 a 5. NULL: todavía no calificó.",
|
|
215
|
+
}),
|
|
216
|
+
__metadata("design:type", Object)
|
|
217
|
+
], ServiceOrder.prototype, "satisfaction_score", void 0);
|
|
218
|
+
__decorate([
|
|
219
|
+
(0, typeorm_1.Column)({
|
|
220
|
+
length: 500,
|
|
221
|
+
type: "varchar",
|
|
222
|
+
nullable: true,
|
|
223
|
+
default: null,
|
|
224
|
+
comment: "Comentario que dejó el cliente al calificar. Opcional.",
|
|
225
|
+
}),
|
|
226
|
+
__metadata("design:type", Object)
|
|
227
|
+
], ServiceOrder.prototype, "satisfaction_comment", void 0);
|
|
228
|
+
__decorate([
|
|
229
|
+
(0, typeorm_1.Column)({
|
|
230
|
+
type: "datetime",
|
|
231
|
+
nullable: true,
|
|
232
|
+
default: null,
|
|
233
|
+
comment: "Cuándo calificó el cliente. NULL: todavía no lo ha hecho.",
|
|
234
|
+
}),
|
|
235
|
+
__metadata("design:type", Object)
|
|
236
|
+
], ServiceOrder.prototype, "satisfaction_date", void 0);
|
|
237
|
+
__decorate([
|
|
238
|
+
(0, typeorm_1.Column)({
|
|
239
|
+
type: "datetime",
|
|
240
|
+
nullable: true,
|
|
241
|
+
default: null,
|
|
242
|
+
comment: "Cuándo se le pidió al cliente que calificara. NULL: todavía no se le ha pedido.",
|
|
243
|
+
}),
|
|
244
|
+
__metadata("design:type", Object)
|
|
245
|
+
], ServiceOrder.prototype, "satisfaction_asked", void 0);
|
|
208
246
|
__decorate([
|
|
209
247
|
(0, typeorm_1.OneToMany)(() => ServiceOrderStage_1.ServiceOrderStage, (stage) => stage.service_order),
|
|
210
248
|
__metadata("design:type", Array)
|
package/dist/entities.index.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export { TemplateSection } from "./entities/TemplateSection";
|
|
|
22
22
|
export { ServiceOrder } from "./entities/ServiceOrder";
|
|
23
23
|
export { ServiceOrderHistory } from "./entities/ServiceOrderHistory";
|
|
24
24
|
export { Reminder } from "./entities/Reminder";
|
|
25
|
+
export { Appointment } from "./entities/Appointment";
|
|
25
26
|
export { AssociatePlatform } from "./entities/AssociatePlatform";
|
|
26
27
|
export { AssociateRole } from "./entities/AssociateRole";
|
|
27
28
|
export { AssociatePermission } from "./entities/AssociatePermission";
|
package/dist/entities.index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.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.WorkshopReader = exports.AssociateTag = exports.WorkshopTag = exports.WorkboardEvent = exports.ServiceOrderStage = exports.WorkboardStatus = exports.CompanyDiscount = exports.DiscountCode = exports.PlanFeature = exports.CompanyFeature = exports.Feature = exports.UsageAlert = exports.SubscriptionAddonTemplate = exports.PaymentTransaction = void 0;
|
|
3
|
+
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.Appointment = 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.WhatsappLine = 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.WorkshopReader = exports.AssociateTag = exports.WorkshopTag = exports.WorkboardEvent = exports.ServiceOrderStage = exports.WorkboardStatus = exports.CompanyDiscount = exports.DiscountCode = exports.PlanFeature = exports.CompanyFeature = exports.Feature = exports.UsageAlert = exports.SubscriptionAddonTemplate = exports.PaymentTransaction = exports.BillingInvoice = 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 WhatsappLine_1 = require("./entities/WhatsappLine");
|
|
@@ -52,6 +52,10 @@ var ServiceOrderHistory_1 = require("./entities/ServiceOrderHistory");
|
|
|
52
52
|
Object.defineProperty(exports, "ServiceOrderHistory", { enumerable: true, get: function () { return ServiceOrderHistory_1.ServiceOrderHistory; } });
|
|
53
53
|
var Reminder_1 = require("./entities/Reminder");
|
|
54
54
|
Object.defineProperty(exports, "Reminder", { enumerable: true, get: function () { return Reminder_1.Reminder; } });
|
|
55
|
+
// DOC: La CITA que el cliente agenda antes de traer el carro. Tabla propia y no un estado de
|
|
56
|
+
// la visita: la visita consume cupo del plan y quema consecutivo. Ver la entidad.
|
|
57
|
+
var Appointment_1 = require("./entities/Appointment");
|
|
58
|
+
Object.defineProperty(exports, "Appointment", { enumerable: true, get: function () { return Appointment_1.Appointment; } });
|
|
55
59
|
var AssociatePlatform_1 = require("./entities/AssociatePlatform");
|
|
56
60
|
Object.defineProperty(exports, "AssociatePlatform", { enumerable: true, get: function () { return AssociatePlatform_1.AssociatePlatform; } });
|
|
57
61
|
var AssociateRole_1 = require("./entities/AssociateRole");
|
package/dist/feature.codes.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export declare const FEATURE_CODE: {
|
|
|
15
15
|
readonly WORKBOARD: "WORKBOARD";
|
|
16
16
|
readonly WHATSAPP_CHATBOT: "WHATSAPP_CHATBOT";
|
|
17
17
|
readonly NFC_TAGS: "NFC_TAGS";
|
|
18
|
+
readonly APPOINTMENTS: "APPOINTMENTS";
|
|
18
19
|
};
|
|
19
20
|
export type TFeatureCode = (typeof FEATURE_CODE)[keyof typeof FEATURE_CODE];
|
|
20
21
|
export declare const FEATURE_CODES: TFeatureCode[];
|
package/dist/feature.codes.js
CHANGED
|
@@ -22,6 +22,9 @@ exports.FEATURE_CODE = {
|
|
|
22
22
|
// DOC: Las etiquetas NFC. Va APARTE del tablero y no adentro: se vende sola, y el chip es
|
|
23
23
|
// hardware que el taller puede comprarnos o traer por su cuenta.
|
|
24
24
|
NFC_TAGS: "NFC_TAGS",
|
|
25
|
+
// DOC: La agenda de citas. Va aparte del chatbot porque funciona SIN él —por el enlace
|
|
26
|
+
// público y el botón del correo—, y dentro del chatbot la opción solo sale con las DOS.
|
|
27
|
+
APPOINTMENTS: "APPOINTMENTS",
|
|
25
28
|
};
|
|
26
29
|
exports.FEATURE_CODES = Object.values(exports.FEATURE_CODE);
|
|
27
30
|
const isFeatureCode = (code) => exports.FEATURE_CODES.includes(code);
|
package/dist/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export * from "./discount.rules";
|
|
|
11
11
|
export * from "./workboard.rules";
|
|
12
12
|
export * from "./timezone";
|
|
13
13
|
export * from "./workshop.schedule";
|
|
14
|
+
export * from "./booking.rules";
|
|
14
15
|
export declare function createDataBaseSource(): DataSource;
|
|
15
16
|
export declare function showEntityName<T extends ObjectLiteral>(entity: EntityTarget<T>): Promise<Repository<T>>;
|
|
16
17
|
export declare function callStoredProcedureName(storedProcedure: any, elements: any): Promise<any>;
|
package/dist/index.js
CHANGED
|
@@ -89,6 +89,10 @@ __exportStar(require("./timezone"), exports);
|
|
|
89
89
|
// resolve entry for package "crypto"». El typecheck no lo detecta —los tipos resuelven igual—,
|
|
90
90
|
// así que el error solo aparece al empaquetar. Vale para todos los módulos puros de arriba.
|
|
91
91
|
__exportStar(require("./workshop.schedule"), exports);
|
|
92
|
+
// DOC: Las reglas de la agenda de citas: qué días tienen cupo y si esta cita cabe. Las usan el
|
|
93
|
+
// API al grabar, el portal al pintar los días libres y el chatbot al listarlos; separadas, la
|
|
94
|
+
// pantalla ofrecería un día que el servidor rechaza. Se apoya en el horario de arriba.
|
|
95
|
+
__exportStar(require("./booking.rules"), exports);
|
|
92
96
|
let connection = null;
|
|
93
97
|
// DOC: Inicialización en curso. Se memoriza la PROMESA y no el resultado porque el patrón
|
|
94
98
|
// "si no está inicializada, inicialízala" tiene una carrera en el arranque en frío: dos
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
export interface ITemplateSettings {
|
|
2
2
|
cost?: number | null;
|
|
3
3
|
estimated_days?: number | null;
|
|
4
|
+
satisfaction?: ITemplateSatisfactionSettings | null;
|
|
5
|
+
}
|
|
6
|
+
export interface ITemplateSatisfactionSettings {
|
|
7
|
+
enabled: boolean;
|
|
4
8
|
}
|
|
5
9
|
export declare const getTemplateCost: (settings: ITemplateSettings | null | undefined) => number | null;
|
|
6
10
|
export declare const withTemplateCost: (settings: ITemplateSettings | null | undefined, cost: number | null) => ITemplateSettings | null;
|
|
7
11
|
export declare const getTemplateEstimatedDays: (settings: ITemplateSettings | null | undefined) => number | null;
|
|
8
12
|
export declare const templatePromisedDate: (settings: ITemplateSettings | null | undefined, createdAt: Date) => string | null;
|
|
9
13
|
export declare const withTemplateEstimatedDays: (settings: ITemplateSettings | null | undefined, days: number | null) => ITemplateSettings | null;
|
|
14
|
+
export declare const isSatisfactionEnabled: (settings: ITemplateSettings | null | undefined) => boolean;
|
|
15
|
+
export declare const withSatisfactionSettings: (settings: ITemplateSettings | null | undefined, enabled: boolean) => 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.withTemplateEstimatedDays = exports.templatePromisedDate = exports.getTemplateEstimatedDays = exports.withTemplateCost = exports.getTemplateCost = void 0;
|
|
5
|
+
exports.withSatisfactionSettings = exports.isSatisfactionEnabled = 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) => {
|
|
@@ -69,3 +69,20 @@ const withTemplateEstimatedDays = (settings, days) => {
|
|
|
69
69
|
return Object.keys(next).length > 0 ? next : null;
|
|
70
70
|
};
|
|
71
71
|
exports.withTemplateEstimatedDays = withTemplateEstimatedDays;
|
|
72
|
+
// DOC: ¿Esta plantilla pide calificación? Se lee con un ayudante y no con `settings?.
|
|
73
|
+
// satisfaction?.enabled` suelto porque lo preguntan el API —al armar el informe y al validar
|
|
74
|
+
// el endpoint público— y el portal, y una de esas tres copias se iba a leer distinto.
|
|
75
|
+
const isSatisfactionEnabled = (settings) => settings?.satisfaction?.enabled === true;
|
|
76
|
+
exports.isSatisfactionEnabled = isSatisfactionEnabled;
|
|
77
|
+
// DOC: Deja `settings` listo para guardar con la calificación prendida o apagada, sin pisar el
|
|
78
|
+
// costo, los días ni lo que venga después. Apagada NO se guarda como `{enabled: false}`: se
|
|
79
|
+
// borra la llave, porque ausente ya significa que no. Espejo de `withTemplateCost`.
|
|
80
|
+
const withSatisfactionSettings = (settings, enabled) => {
|
|
81
|
+
const next = { ...(settings ?? {}) };
|
|
82
|
+
if (enabled)
|
|
83
|
+
next.satisfaction = { enabled: true };
|
|
84
|
+
else
|
|
85
|
+
delete next.satisfaction;
|
|
86
|
+
return Object.keys(next).length > 0 ? next : null;
|
|
87
|
+
};
|
|
88
|
+
exports.withSatisfactionSettings = withSatisfactionSettings;
|
|
@@ -60,6 +60,10 @@ export declare class ServicesOrder {
|
|
|
60
60
|
template_created: Date;
|
|
61
61
|
template_updated: Date;
|
|
62
62
|
template_status: number;
|
|
63
|
+
satisfaction_score: number | null;
|
|
64
|
+
satisfaction_comment: string | null;
|
|
65
|
+
satisfaction_date: Date | null;
|
|
66
|
+
satisfaction_asked: Date | null;
|
|
63
67
|
history_count: number;
|
|
64
68
|
reminder_count: number;
|
|
65
69
|
}
|
|
@@ -258,6 +258,22 @@ __decorate([
|
|
|
258
258
|
(0, typeorm_1.ViewColumn)(),
|
|
259
259
|
__metadata("design:type", Number)
|
|
260
260
|
], ServicesOrder.prototype, "template_status", void 0);
|
|
261
|
+
__decorate([
|
|
262
|
+
(0, typeorm_1.ViewColumn)(),
|
|
263
|
+
__metadata("design:type", Object)
|
|
264
|
+
], ServicesOrder.prototype, "satisfaction_score", void 0);
|
|
265
|
+
__decorate([
|
|
266
|
+
(0, typeorm_1.ViewColumn)(),
|
|
267
|
+
__metadata("design:type", Object)
|
|
268
|
+
], ServicesOrder.prototype, "satisfaction_comment", void 0);
|
|
269
|
+
__decorate([
|
|
270
|
+
(0, typeorm_1.ViewColumn)(),
|
|
271
|
+
__metadata("design:type", Object)
|
|
272
|
+
], ServicesOrder.prototype, "satisfaction_date", void 0);
|
|
273
|
+
__decorate([
|
|
274
|
+
(0, typeorm_1.ViewColumn)(),
|
|
275
|
+
__metadata("design:type", Object)
|
|
276
|
+
], ServicesOrder.prototype, "satisfaction_asked", void 0);
|
|
261
277
|
__decorate([
|
|
262
278
|
(0, typeorm_1.ViewColumn)(),
|
|
263
279
|
__metadata("design:type", Number)
|
|
@@ -67,6 +67,10 @@ export declare const DEFAULT_WORKSHOP_SCHEDULE: IWorkshopSchedule;
|
|
|
67
67
|
export declare const getWorkshopSchedule: (details: unknown) => IWorkshopSchedule | null;
|
|
68
68
|
export declare const withWorkshopSchedule: (details: any, schedule: IWorkshopSchedule | null) => any;
|
|
69
69
|
export declare const localDay: (date: Date) => string;
|
|
70
|
+
export declare const openRangesOnDay: (schedule: IWorkshopSchedule | null, day: string, holidays?: Set<string>) => {
|
|
71
|
+
from: number;
|
|
72
|
+
to: number;
|
|
73
|
+
}[];
|
|
70
74
|
/**
|
|
71
75
|
* DOC: ¿El taller está abierto en ese instante?
|
|
72
76
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.businessDaysForHours = exports.businessMinutesBetween = exports.isOpenAt = exports.localDay = exports.withWorkshopSchedule = exports.getWorkshopSchedule = exports.DEFAULT_WORKSHOP_SCHEDULE = void 0;
|
|
3
|
+
exports.businessDaysForHours = exports.businessMinutesBetween = exports.isOpenAt = exports.openRangesOnDay = exports.localDay = exports.withWorkshopSchedule = exports.getWorkshopSchedule = exports.DEFAULT_WORKSHOP_SCHEDULE = void 0;
|
|
4
4
|
const timezone_1 = require("./timezone");
|
|
5
5
|
// DOC: Lunes a viernes de 8 a 12 y de 2 a 6, sábado de 8 a 12. Es el horario de taller más
|
|
6
6
|
// común en Colombia y sirve como punto de partida del formulario; nada lo aplica solo.
|
|
@@ -118,6 +118,17 @@ const rangesOf = (schedule, date, holidays) => {
|
|
|
118
118
|
}))
|
|
119
119
|
.sort((a, b) => a.from - b.from);
|
|
120
120
|
};
|
|
121
|
+
// DOC: Los tramos abiertos de un día "YYYY-MM-DD". Es `rangesOf` para quien razona por día del
|
|
122
|
+
// calendario y no por instante: la agenda de citas mira días, no momentos.
|
|
123
|
+
const openRangesOnDay = (schedule, day, holidays = new Set()) => {
|
|
124
|
+
if (!schedule)
|
|
125
|
+
return [];
|
|
126
|
+
const [year, month, date] = String(day).split("-").map(Number);
|
|
127
|
+
if (!year || !month || !date)
|
|
128
|
+
return [];
|
|
129
|
+
return rangesOf(schedule, new Date(year, month - 1, date), holidays);
|
|
130
|
+
};
|
|
131
|
+
exports.openRangesOnDay = openRangesOnDay;
|
|
121
132
|
/**
|
|
122
133
|
* DOC: ¿El taller está abierto en ese instante?
|
|
123
134
|
*
|