@asumano/worklip-typeorm-db 1.1.107 → 1.1.108

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.
Files changed (34) hide show
  1. package/dist/entities/Associate.d.ts +4 -0
  2. package/dist/entities/Associate.js +29 -0
  3. package/dist/entities/GlobalTemplateSection.d.ts +1 -0
  4. package/dist/entities/GlobalTemplateSection.js +8 -0
  5. package/dist/entities/JobTitle.d.ts +11 -0
  6. package/dist/entities/JobTitle.js +84 -0
  7. package/dist/entities/ServiceOrder.d.ts +8 -0
  8. package/dist/entities/ServiceOrder.js +81 -0
  9. package/dist/entities/ServiceOrderApproval.d.ts +7 -0
  10. package/dist/entities/ServiceOrderApproval.js +63 -0
  11. package/dist/entities/ServiceOrderStage.d.ts +1 -0
  12. package/dist/entities/ServiceOrderStage.js +9 -0
  13. package/dist/entities/TemplateSection.d.ts +1 -0
  14. package/dist/entities/TemplateSection.js +8 -0
  15. package/dist/entities/VisitItemSearch.js +1 -1
  16. package/dist/entities.index.d.ts +1 -0
  17. package/dist/entities.index.js +3 -1
  18. package/dist/index.d.ts +3 -0
  19. package/dist/index.js +4 -0
  20. package/dist/rules/associate.profile.rules.d.ts +31 -0
  21. package/dist/rules/associate.profile.rules.js +71 -0
  22. package/dist/rules/badge.card.rules.d.ts +74 -0
  23. package/dist/rules/badge.card.rules.js +125 -0
  24. package/dist/rules/estimate.time.rules.d.ts +24 -0
  25. package/dist/rules/estimate.time.rules.js +56 -0
  26. package/dist/rules/outing.rules.d.ts +10 -13
  27. package/dist/rules/outing.rules.js +13 -24
  28. package/dist/rules/template.settings.d.ts +11 -1
  29. package/dist/rules/template.settings.js +52 -15
  30. package/dist/rules/visit.history.rules.d.ts +1 -0
  31. package/dist/rules/visit.history.rules.js +3 -1
  32. package/dist/rules/visit.summary.d.ts +69 -1
  33. package/dist/rules/visit.summary.js +128 -4
  34. package/package.json +1 -1
@@ -2,6 +2,7 @@ import { AssociatePasswordReset, AssociatePermission, Region } from "../entities
2
2
  import { AssociateSession } from "./AssociateSession";
3
3
  import { City } from "./City";
4
4
  import { Company } from "./Company";
5
+ import { JobTitle } from "./JobTitle";
5
6
  import { Reminder } from "./Reminder";
6
7
  import { ServiceOrderHistory } from "./ServiceOrderHistory";
7
8
  import { Workshop } from "./Workshop";
@@ -17,6 +18,9 @@ export declare class Associate {
17
18
  region: Region | null;
18
19
  city: City | null;
19
20
  address: string | null;
21
+ photo: string | null;
22
+ blood_type: number | null;
23
+ job_title: JobTitle | null;
20
24
  password: string;
21
25
  details: any | null;
22
26
  created: Date;
@@ -15,6 +15,7 @@ const entities_views_routes_1 = require("../entities.views.routes");
15
15
  const AssociateSession_1 = require("./AssociateSession");
16
16
  const City_1 = require("./City");
17
17
  const Company_1 = require("./Company");
18
+ const JobTitle_1 = require("./JobTitle");
18
19
  const Reminder_1 = require("./Reminder");
19
20
  const ServiceOrderHistory_1 = require("./ServiceOrderHistory");
20
21
  const Workshop_1 = require("./Workshop");
@@ -112,6 +113,34 @@ __decorate([
112
113
  }),
113
114
  __metadata("design:type", Object)
114
115
  ], Associate.prototype, "address", void 0);
116
+ __decorate([
117
+ (0, typeorm_1.Column)({
118
+ nullable: true,
119
+ default: null,
120
+ type: "varchar",
121
+ length: 255,
122
+ comment: "Llave en R2 de la foto sin fondo (PNG). NULL: sin foto, se muestran las iniciales.",
123
+ }),
124
+ __metadata("design:type", Object)
125
+ ], Associate.prototype, "photo", void 0);
126
+ __decorate([
127
+ (0, typeorm_1.Column)({
128
+ nullable: true,
129
+ default: null,
130
+ type: "int",
131
+ comment: "Tipo de sangre (dato sensible). 1: O+, 2: O-, 3: A+, 4: A-, 5: B+, 6: B-, 7: AB+, 8: AB-. NULL: sin dato.",
132
+ }),
133
+ __metadata("design:type", Object)
134
+ ], Associate.prototype, "blood_type", void 0);
135
+ __decorate([
136
+ (0, typeorm_1.ManyToOne)(() => JobTitle_1.JobTitle, {
137
+ nullable: true,
138
+ onDelete: "SET NULL",
139
+ onUpdate: "NO ACTION",
140
+ }),
141
+ (0, typeorm_1.JoinColumn)({ name: "job_title" }),
142
+ __metadata("design:type", Object)
143
+ ], Associate.prototype, "job_title", void 0);
115
144
  __decorate([
116
145
  (0, typeorm_1.Column)({
117
146
  type: "varchar",
@@ -11,4 +11,5 @@ export declare class GlobalTemplateSection {
11
11
  updated: Date | null;
12
12
  updated_by: Master | null;
13
13
  status: number;
14
+ outing_role: number;
14
15
  }
@@ -94,6 +94,14 @@ __decorate([
94
94
  }),
95
95
  __metadata("design:type", Number)
96
96
  ], GlobalTemplateSection.prototype, "status", void 0);
97
+ __decorate([
98
+ (0, typeorm_1.Column)({
99
+ default: 0,
100
+ type: "int",
101
+ comment: "Papel de la sección en la salida temporal DENTRO de esta plantilla global.\n0: Ninguno.\n1: Ingreso (su copia es el reingreso).\n2: Salida (su copia es la salida temporal).",
102
+ }),
103
+ __metadata("design:type", Number)
104
+ ], GlobalTemplateSection.prototype, "outing_role", void 0);
97
105
  exports.GlobalTemplateSection = GlobalTemplateSection = __decorate([
98
106
  (0, typeorm_1.Entity)({
99
107
  comment: "Enlace entre plantilla global y sección global.",
@@ -0,0 +1,11 @@
1
+ import { Associate } from "./Associate";
2
+ import { Company } from "./Company";
3
+ export declare class JobTitle {
4
+ id: number;
5
+ company: Company;
6
+ name: string;
7
+ status: number;
8
+ created_by: Associate | null;
9
+ created: Date;
10
+ updated: Date | null;
11
+ }
@@ -0,0 +1,84 @@
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.JobTitle = void 0;
13
+ const typeorm_1 = require("typeorm");
14
+ const Associate_1 = require("./Associate");
15
+ const Company_1 = require("./Company");
16
+ // DOC: Cargos de los empleados (sql/85). Por empresa y distintos de los roles de permisos.
17
+ let JobTitle = class JobTitle {
18
+ };
19
+ exports.JobTitle = JobTitle;
20
+ __decorate([
21
+ (0, typeorm_1.PrimaryGeneratedColumn)({
22
+ type: "int",
23
+ comment: "Número de identificación (ID) único de cada registro.",
24
+ }),
25
+ __metadata("design:type", Number)
26
+ ], JobTitle.prototype, "id", void 0);
27
+ __decorate([
28
+ (0, typeorm_1.ManyToOne)(() => Company_1.Company, {
29
+ onDelete: "CASCADE",
30
+ onUpdate: "NO ACTION",
31
+ }),
32
+ (0, typeorm_1.JoinColumn)({ name: "company" }),
33
+ __metadata("design:type", Company_1.Company)
34
+ ], JobTitle.prototype, "company", void 0);
35
+ __decorate([
36
+ (0, typeorm_1.Column)({
37
+ type: "varchar",
38
+ length: 60,
39
+ comment: "Nombre del cargo (Mecánico, Pintor...).",
40
+ }),
41
+ __metadata("design:type", String)
42
+ ], JobTitle.prototype, "name", void 0);
43
+ __decorate([
44
+ (0, typeorm_1.Column)({
45
+ default: 1,
46
+ type: "int",
47
+ comment: "1: activo, 0: inactivo (no se ofrece al editar usuarios).",
48
+ }),
49
+ __metadata("design:type", Number)
50
+ ], JobTitle.prototype, "status", void 0);
51
+ __decorate([
52
+ (0, typeorm_1.ManyToOne)(() => Associate_1.Associate, {
53
+ nullable: true,
54
+ onDelete: "SET NULL",
55
+ onUpdate: "NO ACTION",
56
+ }),
57
+ (0, typeorm_1.JoinColumn)({ name: "created_by" }),
58
+ __metadata("design:type", Object)
59
+ ], JobTitle.prototype, "created_by", void 0);
60
+ __decorate([
61
+ (0, typeorm_1.Column)({
62
+ type: "datetime",
63
+ comment: "Fecha de creación del registro.",
64
+ default: () => "CURRENT_TIMESTAMP",
65
+ }),
66
+ __metadata("design:type", Date)
67
+ ], JobTitle.prototype, "created", void 0);
68
+ __decorate([
69
+ (0, typeorm_1.Column)({
70
+ type: "datetime",
71
+ nullable: true,
72
+ default: null,
73
+ comment: "Fecha de actualización del registro.",
74
+ onUpdate: "CURRENT_TIMESTAMP",
75
+ }),
76
+ __metadata("design:type", Object)
77
+ ], JobTitle.prototype, "updated", void 0);
78
+ exports.JobTitle = JobTitle = __decorate([
79
+ (0, typeorm_1.Unique)("UQ_job_title_company_name", ["company", "name"]),
80
+ (0, typeorm_1.Index)("IDX_job_title_company_status", ["company", "status"]),
81
+ (0, typeorm_1.Entity)("job_title", {
82
+ comment: "Cargos de los empleados, por empresa.",
83
+ })
84
+ ], JobTitle);
@@ -39,6 +39,10 @@ export declare class ServiceOrder {
39
39
  workboard_status: WorkboardStatus | null;
40
40
  workboard_changed: Date | null;
41
41
  promised_date: Date | null;
42
+ estimated_hours: number | null;
43
+ estimated_unit: number | null;
44
+ initial_estimated_hours: number | null;
45
+ initial_estimated_unit: number | null;
42
46
  /**
43
47
  * DOC: LA CALIFICACIÓN DEL CLIENTE. La deja él mismo desde su informe público, cuando ya
44
48
  * recibió el vehículo, y solo si la plantilla de la visita la pide
@@ -60,6 +64,10 @@ export declare class ServiceOrder {
60
64
  reinspection_of: ServiceOrder | null;
61
65
  insurer: Insurer | null;
62
66
  claim_number: string | null;
67
+ deductible_type: number;
68
+ deductible_percent: number | null;
69
+ deductible_amount: number | null;
70
+ insurer_authorized_amount: number | null;
63
71
  outside_since: Date | null;
64
72
  stages: ServiceOrderStage[];
65
73
  workboard_events: WorkboardEvent[];
@@ -245,6 +245,46 @@ __decorate([
245
245
  }),
246
246
  __metadata("design:type", Object)
247
247
  ], ServiceOrder.prototype, "promised_date", void 0);
248
+ __decorate([
249
+ (0, typeorm_1.Column)({
250
+ type: "decimal",
251
+ precision: 8,
252
+ scale: 2,
253
+ default: null,
254
+ nullable: true,
255
+ comment: "Horas hábiles de trabajo estimadas para el vehículo. NULL: sin estimar.",
256
+ }),
257
+ __metadata("design:type", Object)
258
+ ], ServiceOrder.prototype, "estimated_hours", void 0);
259
+ __decorate([
260
+ (0, typeorm_1.Column)({
261
+ type: "int",
262
+ default: null,
263
+ nullable: true,
264
+ comment: "Unidad en que se escribió el tiempo estimado: 2 horas, 3 días, 4 semanas (TIME_UNIT).",
265
+ }),
266
+ __metadata("design:type", Object)
267
+ ], ServiceOrder.prototype, "estimated_unit", void 0);
268
+ __decorate([
269
+ (0, typeorm_1.Column)({
270
+ type: "decimal",
271
+ precision: 8,
272
+ scale: 2,
273
+ default: null,
274
+ nullable: true,
275
+ comment: "Horas hábiles estimadas AL CREAR la visita. No cambia al editar el estimado. NULL: se creó sin estimar.",
276
+ }),
277
+ __metadata("design:type", Object)
278
+ ], ServiceOrder.prototype, "initial_estimated_hours", void 0);
279
+ __decorate([
280
+ (0, typeorm_1.Column)({
281
+ type: "int",
282
+ default: null,
283
+ nullable: true,
284
+ comment: "Unidad del estimado inicial: 2 horas, 3 días, 4 semanas (TIME_UNIT).",
285
+ }),
286
+ __metadata("design:type", Object)
287
+ ], ServiceOrder.prototype, "initial_estimated_unit", void 0);
248
288
  __decorate([
249
289
  (0, typeorm_1.Column)({
250
290
  type: "tinyint",
@@ -320,6 +360,47 @@ __decorate([
320
360
  }),
321
361
  __metadata("design:type", Object)
322
362
  ], ServiceOrder.prototype, "claim_number", void 0);
363
+ __decorate([
364
+ (0, typeorm_1.Column)({
365
+ type: "int",
366
+ default: 0,
367
+ comment: "Deducible de la aseguradora.\n0: Sin deducible.\n1: Porcentaje de lo aprobado con un mínimo.\n2: Valor fijo.",
368
+ }),
369
+ __metadata("design:type", Number)
370
+ ], ServiceOrder.prototype, "deductible_type", void 0);
371
+ __decorate([
372
+ (0, typeorm_1.Column)({
373
+ type: "decimal",
374
+ precision: 5,
375
+ scale: 2,
376
+ default: null,
377
+ nullable: true,
378
+ comment: "Porcentaje del deducible (0-100) sobre lo aprobado por la aseguradora con IVA. Solo con deductible_type 1.",
379
+ }),
380
+ __metadata("design:type", Object)
381
+ ], ServiceOrder.prototype, "deductible_percent", void 0);
382
+ __decorate([
383
+ (0, typeorm_1.Column)({
384
+ type: "decimal",
385
+ precision: 14,
386
+ scale: 2,
387
+ default: null,
388
+ nullable: true,
389
+ comment: "Con deductible_type 1: el mínimo. Con 2: el valor fijo. En la moneda de la visita.",
390
+ }),
391
+ __metadata("design:type", Object)
392
+ ], ServiceOrder.prototype, "deductible_amount", void 0);
393
+ __decorate([
394
+ (0, typeorm_1.Column)({
395
+ type: "decimal",
396
+ precision: 14,
397
+ scale: 2,
398
+ default: null,
399
+ nullable: true,
400
+ comment: "Valor autorizado en la carta de la aseguradora, con IVA. Opcional: solo se compara con los ítems aprobados por ella; no cambia el total.",
401
+ }),
402
+ __metadata("design:type", Object)
403
+ ], ServiceOrder.prototype, "insurer_authorized_amount", void 0);
323
404
  __decorate([
324
405
  (0, typeorm_1.Column)({
325
406
  type: "datetime",
@@ -19,5 +19,12 @@ export declare class ServiceOrderApproval {
19
19
  client_role: string | null;
20
20
  ip: string | null;
21
21
  user_agent: string | null;
22
+ source: number;
23
+ insurer: number | null;
24
+ associate: number | null;
25
+ verification: number;
26
+ registered_method: number | null;
27
+ evidence: string | null;
28
+ note: string | null;
22
29
  created: Date;
23
30
  }
@@ -171,6 +171,69 @@ __decorate([
171
171
  }),
172
172
  __metadata("design:type", Object)
173
173
  ], ServiceOrderApproval.prototype, "user_agent", void 0);
174
+ __decorate([
175
+ (0, typeorm_1.Column)({
176
+ type: "int",
177
+ default: 1,
178
+ comment: "Quién aprobó: 1 el cliente, 2 la aseguradora (lo marcó el taller).",
179
+ }),
180
+ __metadata("design:type", Number)
181
+ ], ServiceOrderApproval.prototype, "source", void 0);
182
+ __decorate([
183
+ (0, typeorm_1.Column)({
184
+ type: "int",
185
+ default: null,
186
+ nullable: true,
187
+ comment: "Aseguradora que aprobó (solo source = 2).",
188
+ }),
189
+ __metadata("design:type", Object)
190
+ ], ServiceOrderApproval.prototype, "insurer", void 0);
191
+ __decorate([
192
+ (0, typeorm_1.Column)({
193
+ type: "int",
194
+ default: null,
195
+ nullable: true,
196
+ comment: "Empleado que marcó la aprobación: de la aseguradora (source = 2) o la registrada por el taller (verification = 5).",
197
+ }),
198
+ __metadata("design:type", Object)
199
+ ], ServiceOrderApproval.prototype, "associate", void 0);
200
+ __decorate([
201
+ (0, typeorm_1.Column)({
202
+ type: "int",
203
+ default: 0,
204
+ comment: "Cómo confirmó el cliente la aprobación:\n0: Sin verificación (rechazo, aseguradora o antes de sql/91).\n1: Documento.\n2: Código por correo.\n3: Sesión de la app (sin documento).\n4: Número de WhatsApp (verificado por Meta).\n5: Registrada por el taller (con evidencia y nota).",
205
+ }),
206
+ __metadata("design:type", Number)
207
+ ], ServiceOrderApproval.prototype, "verification", void 0);
208
+ __decorate([
209
+ (0, typeorm_1.Column)({
210
+ type: "int",
211
+ default: null,
212
+ nullable: true,
213
+ comment: "Cómo aprobó el cliente cuando lo registra el taller (verification = 5):\n1: Por llamada.\n2: En persona.\n3: Otro.\nNULL: no la registró el taller.",
214
+ }),
215
+ __metadata("design:type", Object)
216
+ ], ServiceOrderApproval.prototype, "registered_method", void 0);
217
+ __decorate([
218
+ (0, typeorm_1.Column)({
219
+ type: "varchar",
220
+ length: 255,
221
+ default: null,
222
+ nullable: true,
223
+ comment: "Llave en R2 de la evidencia (foto, audio, PDF o la firma en pantalla) de la aprobación registrada por el taller.",
224
+ }),
225
+ __metadata("design:type", Object)
226
+ ], ServiceOrderApproval.prototype, "evidence", void 0);
227
+ __decorate([
228
+ (0, typeorm_1.Column)({
229
+ type: "varchar",
230
+ length: 500,
231
+ default: null,
232
+ nullable: true,
233
+ comment: "Nota obligatoria del empleado al registrar la aprobación del cliente.",
234
+ }),
235
+ __metadata("design:type", Object)
236
+ ], ServiceOrderApproval.prototype, "note", void 0);
174
237
  __decorate([
175
238
  (0, typeorm_1.Column)({
176
239
  type: "datetime",
@@ -40,6 +40,7 @@ export declare class ServiceOrderStage {
40
40
  entered: Date | null;
41
41
  finished: Date | null;
42
42
  estimated_hours: number | null;
43
+ estimated_unit: number | null;
43
44
  blocked_reason: string | null;
44
45
  blocked_at: Date | null;
45
46
  blocked_by: Associate | null;
@@ -155,6 +155,15 @@ __decorate([
155
155
  }),
156
156
  __metadata("design:type", Object)
157
157
  ], ServiceOrderStage.prototype, "estimated_hours", void 0);
158
+ __decorate([
159
+ (0, typeorm_1.Column)({
160
+ type: "int",
161
+ default: null,
162
+ nullable: true,
163
+ comment: "Unidad en que se escribió el estimado: 1 minutos, 2 horas, 3 días (TIME_UNIT). Se guarda en horas.",
164
+ }),
165
+ __metadata("design:type", Object)
166
+ ], ServiceOrderStage.prototype, "estimated_unit", void 0);
158
167
  __decorate([
159
168
  (0, typeorm_1.Column)({
160
169
  length: 255,
@@ -11,4 +11,5 @@ export declare class TemplateSection {
11
11
  updated: Date | null;
12
12
  updated_by: Associate | null;
13
13
  status: number;
14
+ outing_role: number;
14
15
  }
@@ -108,6 +108,14 @@ __decorate([
108
108
  }),
109
109
  __metadata("design:type", Number)
110
110
  ], TemplateSection.prototype, "status", void 0);
111
+ __decorate([
112
+ (0, typeorm_1.Column)({
113
+ default: 0,
114
+ type: "int",
115
+ comment: "Papel de la sección en la salida temporal DENTRO de esta plantilla.\n0: Ninguno.\n1: Ingreso (su copia es el reingreso).\n2: Salida (su copia es la salida temporal).",
116
+ }),
117
+ __metadata("design:type", Number)
118
+ ], TemplateSection.prototype, "outing_role", void 0);
111
119
  exports.TemplateSection = TemplateSection = __decorate([
112
120
  (0, typeorm_1.Entity)({
113
121
  comment: "Enlace entre plantilla y sección: qué secciones lleva cada plantilla y en qué orden.",
@@ -112,7 +112,7 @@ __decorate([
112
112
  type: "int",
113
113
  nullable: true,
114
114
  default: null,
115
- comment: "Por dónde respondió:\r\n1: Enlace web.\r\n2: App del cliente.\r\n3: WhatsApp.",
115
+ comment: "Por dónde respondió:\r\n1: Enlace web.\r\n2: App del cliente.\r\n3: WhatsApp.\r\n4: Registrada por el taller.",
116
116
  }),
117
117
  __metadata("design:type", Object)
118
118
  ], VisitItemSearch.prototype, "responder_channel", void 0);
@@ -134,3 +134,4 @@ export { WorkshopEquipment } from "./entities/WorkshopEquipment";
134
134
  export { VehicleMeasurement } from "./entities/VehicleMeasurement";
135
135
  export { ObdCode } from "./entities/ObdCode";
136
136
  export { WorkshopReportInbox } from "./entities/WorkshopReportInbox";
137
+ export { JobTitle } from "./entities/JobTitle";
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AssociateSection = exports.AssociatePermission = exports.AssociateRole = exports.AssociatePlatform = exports.ClientSubscription = exports.ClientPlanLimit = exports.ClientPlan = exports.ClientDocumentDispute = exports.ReviewTaskEvent = exports.ReviewTask = exports.MasterNotification = exports.ClientSession = exports.ClientNotification = exports.ClientIdentity = exports.PypRuleVote = exports.PypRule = exports.VehicleVerification = exports.ClientVehicleInvite = exports.ClientVehicle = exports.CompanyVehicle = exports.CompanyClient = exports.Appointment = exports.DocumentType = exports.ReminderType = exports.Reminder = exports.ServiceOrderHistory = exports.ServiceOrder = exports.TemplateSection = exports.SectionItem = exports.Section = exports.Template = exports.Workshop = exports.GlobalTemplateSection = exports.GlobalSectionItem = exports.GlobalSection = exports.GlobalTemplate = exports.AssociateNotification = exports.AssociateSession = exports.MasterSession = exports.Associate = exports.Client = exports.Master = exports.VehicleReport = exports.Vehicle = exports.Brand = exports.Company = exports.City = exports.Region = exports.WhatsappLine = exports.Country = void 0;
4
4
  exports.AssociateDailyStats = exports.WorkshopDailyStats = exports.WorkboardEvent = exports.ServiceOrderStage = exports.WorkboardStatus = exports.CompanyDiscount = exports.DiscountCode = exports.WorkshopDisplay = exports.WorkshopInsurer = exports.WorkshopOfferedService = exports.Insurer = exports.OfferedService = exports.WorkshopOutingRecipient = exports.ServiceOrderOuting = exports.ServiceOrderPart = exports.ServiceOrderObservation = exports.VisitResult = exports.ReminderTypeCompanyType = exports.PlanCompanyType = exports.WorkshopCompanyType = exports.CompanyCompanyType = exports.CompanyType = exports.PlanFeature = exports.CompanyFeature = exports.Feature = exports.UsageAlert = exports.SubscriptionAddonTemplate = exports.PaymentTransaction = exports.BillingInvoice = exports.EmailSuppression = exports.EmailLog = exports.WhatsappLog = exports.ServiceOrderApproval = exports.MediaFile = exports.BillingUsageSnapshot = exports.PaymentMethod = exports.SubscriptionAddon = exports.CompanySubscription = exports.SubscriptionPlan = exports.CountryHoliday = exports.CompanyVehicleType = exports.BrandVehicleType = exports.CompanyBrand = exports.VehicleType = exports.MasterSection = exports.MasterPermission = exports.MasterRole = exports.MasterPlatform = exports.MasterPasswordReset = exports.AssociatePasswordReset = void 0;
5
- exports.WorkshopReportInbox = exports.ObdCode = exports.VehicleMeasurement = exports.WorkshopEquipment = exports.EquipmentType = exports.CompanyAiUsage = exports.CompanyQuotaAdjustment = exports.VisitSearchHistory = exports.VisitAiAnalysis = exports.VisitSearchPerson = exports.VisitItemSearch = exports.GlobalSectionItems = exports.GlobalSections = exports.GlobalTemplates = exports.SubscriptionAddonTemplates = exports.SubscriptionPlans = exports.Masters = exports.Companies = exports.WorkshopsByAssociate = exports.Workshops = exports.SectionItems = exports.Sections = exports.Templates = exports.Reminders = exports.Vehicles = exports.Clients = exports.ServicesOrderLite = exports.ServicesOrder = exports.Associates = exports.AssociateSectionFeature = exports.AttendanceMark = exports.WorkshopReader = exports.AssociateTag = exports.WorkshopTag = exports.MetricEvent = exports.StageMetric = void 0;
5
+ exports.JobTitle = exports.WorkshopReportInbox = exports.ObdCode = exports.VehicleMeasurement = exports.WorkshopEquipment = exports.EquipmentType = exports.CompanyAiUsage = exports.CompanyQuotaAdjustment = exports.VisitSearchHistory = exports.VisitAiAnalysis = exports.VisitSearchPerson = exports.VisitItemSearch = exports.GlobalSectionItems = exports.GlobalSections = exports.GlobalTemplates = exports.SubscriptionAddonTemplates = exports.SubscriptionPlans = exports.Masters = exports.Companies = exports.WorkshopsByAssociate = exports.Workshops = exports.SectionItems = exports.Sections = exports.Templates = exports.Reminders = exports.Vehicles = exports.Clients = exports.ServicesOrderLite = exports.ServicesOrder = exports.Associates = exports.AssociateSectionFeature = exports.AttendanceMark = exports.WorkshopReader = exports.AssociateTag = exports.WorkshopTag = exports.MetricEvent = exports.StageMetric = void 0;
6
6
  var Country_1 = require("./entities/Country");
7
7
  Object.defineProperty(exports, "Country", { enumerable: true, get: function () { return Country_1.Country; } });
8
8
  var WhatsappLine_1 = require("./entities/WhatsappLine");
@@ -302,3 +302,5 @@ var ObdCode_1 = require("./entities/ObdCode");
302
302
  Object.defineProperty(exports, "ObdCode", { enumerable: true, get: function () { return ObdCode_1.ObdCode; } });
303
303
  var WorkshopReportInbox_1 = require("./entities/WorkshopReportInbox");
304
304
  Object.defineProperty(exports, "WorkshopReportInbox", { enumerable: true, get: function () { return WorkshopReportInbox_1.WorkshopReportInbox; } });
305
+ var JobTitle_1 = require("./entities/JobTitle");
306
+ Object.defineProperty(exports, "JobTitle", { enumerable: true, get: function () { return JobTitle_1.JobTitle; } });
package/dist/index.d.ts CHANGED
@@ -30,3 +30,6 @@ export declare function showEntityName<T extends ObjectLiteral>(entity: EntityTa
30
30
  export declare function callStoredProcedureName(storedProcedure: any, elements: any): Promise<any>;
31
31
  export declare function getDataSource(): Promise<DataSource>;
32
32
  export declare function executeQuery(query: string, params?: any[]): Promise<any>;
33
+ export * from "./rules/associate.profile.rules";
34
+ export * from "./rules/badge.card.rules";
35
+ export * from "./rules/estimate.time.rules";
package/dist/index.js CHANGED
@@ -245,3 +245,7 @@ async function executeQuery(query, params = []) {
245
245
  const ds = await getDataSource();
246
246
  return ds.query(query, params);
247
247
  }
248
+ // Foto, sangre y cargo del empleado; carnés y colores de la sede; tiempos estimados (sql/85-86).
249
+ __exportStar(require("./rules/associate.profile.rules"), exports);
250
+ __exportStar(require("./rules/badge.card.rules"), exports);
251
+ __exportStar(require("./rules/estimate.time.rules"), exports);
@@ -0,0 +1,31 @@
1
+ /** DOC: `associate.blood_type`. Dato sensible: solo lo ven el empleado y quien administra usuarios. */
2
+ export declare const BLOOD_TYPE: {
3
+ readonly O_POS: 1;
4
+ readonly O_NEG: 2;
5
+ readonly A_POS: 3;
6
+ readonly A_NEG: 4;
7
+ readonly B_POS: 5;
8
+ readonly B_NEG: 6;
9
+ readonly AB_POS: 7;
10
+ readonly AB_NEG: 8;
11
+ };
12
+ export type TBloodType = (typeof BLOOD_TYPE)[keyof typeof BLOOD_TYPE];
13
+ export declare const BLOOD_TYPE_LABEL: Record<TBloodType, string>;
14
+ export declare const isBloodType: (value: unknown) => value is TBloodType;
15
+ export declare const bloodTypeLabel: (value: unknown) => string | null;
16
+ export declare const JOB_TITLE_STATUS: {
17
+ readonly INACTIVE: 0;
18
+ readonly ACTIVE: 1;
19
+ };
20
+ export declare const JOB_TITLE_NAME_MAX = 60;
21
+ /** DOC: Lo que ofrece «Agregar sugeridos» en una empresa que todavía no tiene cargos. */
22
+ export declare const SUGGESTED_JOB_TITLES: readonly ["Asesor de servicio", "Jefe de taller", "Mecánico", "Latonero", "Pintor", "Electricista", "Alistador", "Recepcionista"];
23
+ /** DOC: Nombre limpio (espacios colapsados) o `null` si no sirve. */
24
+ export declare const normalizeJobTitleName: (value: unknown) => string | null;
25
+ export declare const ASSOCIATE_PHOTO_SIZE = 512;
26
+ export declare const ASSOCIATE_PHOTO_MAX_BYTES: number;
27
+ export declare const associatePhotoPrefix: (companyCode: string, associateCode: string) => string;
28
+ /** DOC: La llave tiene que ser de la carpeta de ESE empleado y PNG; si no, se podría apuntar a otro archivo. */
29
+ export declare const isAssociatePhotoKey: (key: unknown, companyCode: string | null | undefined, associateCode: string | null | undefined) => key is string;
30
+ /** DOC: Iniciales del avatar: primera letra del nombre y del apellido. */
31
+ export declare const associateInitials: (name?: string | null, surname?: string | null) => string;
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ // DOC: Foto, tipo de sangre y cargo del empleado (sql/85). Módulo PURO: el API valida y los fronts pintan.
3
+ // import { BLOOD_TYPE } from "@asumano/worklip-typeorm-db/dist/rules/associate.profile.rules";
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.associateInitials = exports.isAssociatePhotoKey = exports.associatePhotoPrefix = exports.ASSOCIATE_PHOTO_MAX_BYTES = exports.ASSOCIATE_PHOTO_SIZE = exports.normalizeJobTitleName = exports.SUGGESTED_JOB_TITLES = exports.JOB_TITLE_NAME_MAX = exports.JOB_TITLE_STATUS = exports.bloodTypeLabel = exports.isBloodType = exports.BLOOD_TYPE_LABEL = exports.BLOOD_TYPE = void 0;
6
+ /** DOC: `associate.blood_type`. Dato sensible: solo lo ven el empleado y quien administra usuarios. */
7
+ exports.BLOOD_TYPE = {
8
+ O_POS: 1,
9
+ O_NEG: 2,
10
+ A_POS: 3,
11
+ A_NEG: 4,
12
+ B_POS: 5,
13
+ B_NEG: 6,
14
+ AB_POS: 7,
15
+ AB_NEG: 8,
16
+ };
17
+ exports.BLOOD_TYPE_LABEL = {
18
+ 1: "O+",
19
+ 2: "O-",
20
+ 3: "A+",
21
+ 4: "A-",
22
+ 5: "B+",
23
+ 6: "B-",
24
+ 7: "AB+",
25
+ 8: "AB-",
26
+ };
27
+ const isBloodType = (value) => Number.isInteger(value) && Number(value) >= 1 && Number(value) <= 8;
28
+ exports.isBloodType = isBloodType;
29
+ const bloodTypeLabel = (value) => (0, exports.isBloodType)(value) ? exports.BLOOD_TYPE_LABEL[value] : null;
30
+ exports.bloodTypeLabel = bloodTypeLabel;
31
+ exports.JOB_TITLE_STATUS = { INACTIVE: 0, ACTIVE: 1 };
32
+ exports.JOB_TITLE_NAME_MAX = 60;
33
+ /** DOC: Lo que ofrece «Agregar sugeridos» en una empresa que todavía no tiene cargos. */
34
+ exports.SUGGESTED_JOB_TITLES = [
35
+ "Asesor de servicio",
36
+ "Jefe de taller",
37
+ "Mecánico",
38
+ "Latonero",
39
+ "Pintor",
40
+ "Electricista",
41
+ "Alistador",
42
+ "Recepcionista",
43
+ ];
44
+ /** DOC: Nombre limpio (espacios colapsados) o `null` si no sirve. */
45
+ const normalizeJobTitleName = (value) => {
46
+ if (typeof value !== "string")
47
+ return null;
48
+ const name = value.replace(/\s+/g, " ").trim();
49
+ return name.length >= 2 && name.length <= exports.JOB_TITLE_NAME_MAX ? name : null;
50
+ };
51
+ exports.normalizeJobTitleName = normalizeJobTitleName;
52
+ // DOC: La foto llega ya recortada y sin fondo desde el navegador: PNG cuadrado de 512 px.
53
+ exports.ASSOCIATE_PHOTO_SIZE = 512;
54
+ exports.ASSOCIATE_PHOTO_MAX_BYTES = 1024 * 1024;
55
+ const associatePhotoPrefix = (companyCode, associateCode) => `companies/${companyCode}/associates/${associateCode}/`;
56
+ exports.associatePhotoPrefix = associatePhotoPrefix;
57
+ /** DOC: La llave tiene que ser de la carpeta de ESE empleado y PNG; si no, se podría apuntar a otro archivo. */
58
+ const isAssociatePhotoKey = (key, companyCode, associateCode) => typeof key === "string" &&
59
+ !!companyCode &&
60
+ !!associateCode &&
61
+ !key.includes("..") &&
62
+ key.startsWith((0, exports.associatePhotoPrefix)(companyCode, associateCode)) &&
63
+ key.toLowerCase().endsWith(".png");
64
+ exports.isAssociatePhotoKey = isAssociatePhotoKey;
65
+ /** DOC: Iniciales del avatar: primera letra del nombre y del apellido. */
66
+ const associateInitials = (name, surname) => {
67
+ const first = (name || "").trim().charAt(0);
68
+ const second = (surname || "").trim().charAt(0) || (name || "").trim().split(/\s+/)[1]?.charAt(0) || "";
69
+ return `${first}${second}`.toUpperCase() || "?";
70
+ };
71
+ exports.associateInitials = associateInitials;