@asumano/worklip-typeorm-db 1.1.108 → 1.1.110
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/Associate.d.ts +1 -0
- package/dist/entities/Associate.js +9 -0
- package/dist/entities/AssociatePayRate.d.ts +10 -0
- package/dist/entities/AssociatePayRate.js +79 -0
- package/dist/entities/GlobalSection.d.ts +1 -0
- package/dist/entities/GlobalSection.js +8 -0
- package/dist/entities/Master.d.ts +1 -0
- package/dist/entities/Master.js +9 -0
- package/dist/entities/PayrollMonthDays.d.ts +10 -0
- package/dist/entities/PayrollMonthDays.js +83 -0
- package/dist/entities/Section.d.ts +1 -0
- package/dist/entities/Section.js +8 -0
- package/dist/entities/ServiceOrderStage.d.ts +9 -0
- package/dist/entities/ServiceOrderStage.js +93 -0
- package/dist/entities/WorkshopInsurer.d.ts +4 -0
- package/dist/entities/WorkshopInsurer.js +40 -0
- package/dist/entities.index.d.ts +2 -0
- package/dist/entities.index.js +5 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/rules/feature.codes.d.ts +1 -0
- package/dist/rules/feature.codes.js +2 -0
- package/dist/rules/payroll.rules.d.ts +79 -0
- package/dist/rules/payroll.rules.js +159 -0
- package/package.json +1 -1
|
@@ -55,6 +55,15 @@ __decorate([
|
|
|
55
55
|
}),
|
|
56
56
|
__metadata("design:type", String)
|
|
57
57
|
], Associate.prototype, "document", void 0);
|
|
58
|
+
__decorate([
|
|
59
|
+
(0, typeorm_1.Column)({
|
|
60
|
+
type: "varchar",
|
|
61
|
+
length: 10,
|
|
62
|
+
default: "C.C",
|
|
63
|
+
comment: "Código del tipo de documento (document_type.code del país: C.C, C.E, PASAPORTE...).",
|
|
64
|
+
}),
|
|
65
|
+
__metadata("design:type", String)
|
|
66
|
+
], Associate.prototype, "document_type", void 0);
|
|
58
67
|
__decorate([
|
|
59
68
|
(0, typeorm_1.Column)({ length: 50, type: "varchar", comment: "Nombre del usuario." }),
|
|
60
69
|
__metadata("design:type", String)
|
|
@@ -0,0 +1,79 @@
|
|
|
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.AssociatePayRate = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
const Associate_1 = require("./Associate");
|
|
15
|
+
// DOC: Tarifa de nómina del empleado (sql/93, funcionalidad PAYROLL). Tabla aparte del usuario para que
|
|
16
|
+
// el sueldo no viaje en ninguna consulta de `associate`: solo la lee quien tiene MANAGE_PAYROLL.
|
|
17
|
+
let AssociatePayRate = class AssociatePayRate {
|
|
18
|
+
};
|
|
19
|
+
exports.AssociatePayRate = AssociatePayRate;
|
|
20
|
+
__decorate([
|
|
21
|
+
(0, typeorm_1.PrimaryColumn)({ type: "int", name: "associate" }),
|
|
22
|
+
__metadata("design:type", Number)
|
|
23
|
+
], AssociatePayRate.prototype, "associate_id", void 0);
|
|
24
|
+
__decorate([
|
|
25
|
+
(0, typeorm_1.OneToOne)(() => Associate_1.Associate, {
|
|
26
|
+
onDelete: "CASCADE",
|
|
27
|
+
onUpdate: "NO ACTION",
|
|
28
|
+
}),
|
|
29
|
+
(0, typeorm_1.JoinColumn)({ name: "associate" }),
|
|
30
|
+
__metadata("design:type", Associate_1.Associate)
|
|
31
|
+
], AssociatePayRate.prototype, "associate", void 0);
|
|
32
|
+
__decorate([
|
|
33
|
+
(0, typeorm_1.Column)({
|
|
34
|
+
type: "int",
|
|
35
|
+
comment: "Cómo se le paga.\n1: Por hora.\n2: Por día (no sale de las visitas: se cuentan los días trabajados).\n3: Por pieza o trabajo.",
|
|
36
|
+
}),
|
|
37
|
+
__metadata("design:type", Number)
|
|
38
|
+
], AssociatePayRate.prototype, "pay_unit", void 0);
|
|
39
|
+
__decorate([
|
|
40
|
+
(0, typeorm_1.Column)({
|
|
41
|
+
type: "decimal",
|
|
42
|
+
precision: 14,
|
|
43
|
+
scale: 2,
|
|
44
|
+
comment: "Valor por unidad, en la moneda del país de la empresa.",
|
|
45
|
+
}),
|
|
46
|
+
__metadata("design:type", String)
|
|
47
|
+
], AssociatePayRate.prototype, "amount", void 0);
|
|
48
|
+
__decorate([
|
|
49
|
+
(0, typeorm_1.ManyToOne)(() => Associate_1.Associate, {
|
|
50
|
+
onDelete: "SET NULL",
|
|
51
|
+
onUpdate: "NO ACTION",
|
|
52
|
+
nullable: true,
|
|
53
|
+
}),
|
|
54
|
+
(0, typeorm_1.JoinColumn)({ name: "updated_by" }),
|
|
55
|
+
__metadata("design:type", Object)
|
|
56
|
+
], AssociatePayRate.prototype, "updated_by", void 0);
|
|
57
|
+
__decorate([
|
|
58
|
+
(0, typeorm_1.Column)({
|
|
59
|
+
type: "datetime",
|
|
60
|
+
comment: "Fecha de creación del registro.",
|
|
61
|
+
default: () => "CURRENT_TIMESTAMP",
|
|
62
|
+
}),
|
|
63
|
+
__metadata("design:type", Date)
|
|
64
|
+
], AssociatePayRate.prototype, "created", void 0);
|
|
65
|
+
__decorate([
|
|
66
|
+
(0, typeorm_1.Column)({
|
|
67
|
+
type: "datetime",
|
|
68
|
+
nullable: true,
|
|
69
|
+
default: null,
|
|
70
|
+
comment: "Fecha de actualización del registro.",
|
|
71
|
+
onUpdate: "CURRENT_TIMESTAMP",
|
|
72
|
+
}),
|
|
73
|
+
__metadata("design:type", Object)
|
|
74
|
+
], AssociatePayRate.prototype, "updated", void 0);
|
|
75
|
+
exports.AssociatePayRate = AssociatePayRate = __decorate([
|
|
76
|
+
(0, typeorm_1.Entity)("associate_pay_rate", {
|
|
77
|
+
comment: "Tarifa de nómina de cada empleado (funcionalidad PAYROLL). Solo informativa.",
|
|
78
|
+
})
|
|
79
|
+
], AssociatePayRate);
|
|
@@ -97,6 +97,14 @@ __decorate([
|
|
|
97
97
|
(0, typeorm_1.JoinColumn)({ name: "updated_by" }),
|
|
98
98
|
__metadata("design:type", Object)
|
|
99
99
|
], GlobalSection.prototype, "updated_by", void 0);
|
|
100
|
+
__decorate([
|
|
101
|
+
(0, typeorm_1.Column)({
|
|
102
|
+
default: 1,
|
|
103
|
+
type: "int",
|
|
104
|
+
comment: "Tipo de mano de obra (se copia a la sección del taller).\n1: Carrocería / mecánica (valor hora).\n2: Pintura (valor hora de pintura, si la aseguradora tiene otro).",
|
|
105
|
+
}),
|
|
106
|
+
__metadata("design:type", Number)
|
|
107
|
+
], GlobalSection.prototype, "labor_type", void 0);
|
|
100
108
|
__decorate([
|
|
101
109
|
(0, typeorm_1.Column)({
|
|
102
110
|
default: 1,
|
package/dist/entities/Master.js
CHANGED
|
@@ -43,6 +43,15 @@ __decorate([
|
|
|
43
43
|
}),
|
|
44
44
|
__metadata("design:type", String)
|
|
45
45
|
], Master.prototype, "document", void 0);
|
|
46
|
+
__decorate([
|
|
47
|
+
(0, typeorm_1.Column)({
|
|
48
|
+
type: "varchar",
|
|
49
|
+
length: 10,
|
|
50
|
+
default: "C.C",
|
|
51
|
+
comment: "Código del tipo de documento (document_type.code de Colombia: C.C, C.E, PASAPORTE...).",
|
|
52
|
+
}),
|
|
53
|
+
__metadata("design:type", String)
|
|
54
|
+
], Master.prototype, "document_type", void 0);
|
|
46
55
|
__decorate([
|
|
47
56
|
(0, typeorm_1.Column)({ length: 50, type: "varchar", comment: "Nombre del administrador." }),
|
|
48
57
|
__metadata("design:type", String)
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.PayrollMonthDays = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
const Associate_1 = require("./Associate");
|
|
15
|
+
// DOC: Días trabajados en el mes, escritos a mano en el reporte de nómina (sql/93), para el que gana por día.
|
|
16
|
+
// Si existe, reemplaza el conteo de la asistencia.
|
|
17
|
+
let PayrollMonthDays = class PayrollMonthDays {
|
|
18
|
+
};
|
|
19
|
+
exports.PayrollMonthDays = PayrollMonthDays;
|
|
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
|
+
], PayrollMonthDays.prototype, "id", void 0);
|
|
27
|
+
__decorate([
|
|
28
|
+
(0, typeorm_1.ManyToOne)(() => Associate_1.Associate, {
|
|
29
|
+
onDelete: "CASCADE",
|
|
30
|
+
onUpdate: "NO ACTION",
|
|
31
|
+
}),
|
|
32
|
+
(0, typeorm_1.JoinColumn)({ name: "associate" }),
|
|
33
|
+
__metadata("design:type", Associate_1.Associate)
|
|
34
|
+
], PayrollMonthDays.prototype, "associate", void 0);
|
|
35
|
+
__decorate([
|
|
36
|
+
(0, typeorm_1.Column)({
|
|
37
|
+
type: "date",
|
|
38
|
+
comment: "Mes, guardado como su primer día (AAAA-MM-01).",
|
|
39
|
+
}),
|
|
40
|
+
__metadata("design:type", String)
|
|
41
|
+
], PayrollMonthDays.prototype, "month", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
(0, typeorm_1.Column)({
|
|
44
|
+
type: "decimal",
|
|
45
|
+
precision: 4,
|
|
46
|
+
scale: 1,
|
|
47
|
+
comment: "Días trabajados en el mes. Reemplaza el conteo de la asistencia.",
|
|
48
|
+
}),
|
|
49
|
+
__metadata("design:type", String)
|
|
50
|
+
], PayrollMonthDays.prototype, "days", void 0);
|
|
51
|
+
__decorate([
|
|
52
|
+
(0, typeorm_1.ManyToOne)(() => Associate_1.Associate, {
|
|
53
|
+
onDelete: "SET NULL",
|
|
54
|
+
onUpdate: "NO ACTION",
|
|
55
|
+
nullable: true,
|
|
56
|
+
}),
|
|
57
|
+
(0, typeorm_1.JoinColumn)({ name: "updated_by" }),
|
|
58
|
+
__metadata("design:type", Object)
|
|
59
|
+
], PayrollMonthDays.prototype, "updated_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
|
+
], PayrollMonthDays.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
|
+
], PayrollMonthDays.prototype, "updated", void 0);
|
|
78
|
+
exports.PayrollMonthDays = PayrollMonthDays = __decorate([
|
|
79
|
+
(0, typeorm_1.Unique)("UQ_payroll_month_days", ["associate", "month"]),
|
|
80
|
+
(0, typeorm_1.Entity)("payroll_month_days", {
|
|
81
|
+
comment: "Días trabajados por mes de los empleados que ganan por día, escritos en el reporte de nómina.",
|
|
82
|
+
})
|
|
83
|
+
], PayrollMonthDays);
|
package/dist/entities/Section.js
CHANGED
|
@@ -114,6 +114,14 @@ __decorate([
|
|
|
114
114
|
(0, typeorm_1.JoinColumn)({ name: "updated_by" }),
|
|
115
115
|
__metadata("design:type", Object)
|
|
116
116
|
], Section.prototype, "updated_by", void 0);
|
|
117
|
+
__decorate([
|
|
118
|
+
(0, typeorm_1.Column)({
|
|
119
|
+
default: 1,
|
|
120
|
+
type: "int",
|
|
121
|
+
comment: "Tipo de mano de obra, para el valor hora de la aseguradora.\n1: Carrocería / mecánica (valor hora).\n2: Pintura (valor hora de pintura, si la aseguradora tiene otro).",
|
|
122
|
+
}),
|
|
123
|
+
__metadata("design:type", Number)
|
|
124
|
+
], Section.prototype, "labor_type", void 0);
|
|
117
125
|
__decorate([
|
|
118
126
|
(0, typeorm_1.Column)({
|
|
119
127
|
default: 1,
|
|
@@ -44,6 +44,15 @@ export declare class ServiceOrderStage {
|
|
|
44
44
|
blocked_reason: string | null;
|
|
45
45
|
blocked_at: Date | null;
|
|
46
46
|
blocked_by: Associate | null;
|
|
47
|
+
pay_unit: number | null;
|
|
48
|
+
pay_quantity: string | null;
|
|
49
|
+
pay_rate: string | null;
|
|
50
|
+
pay_amount: string | null;
|
|
51
|
+
income_hours: string | null;
|
|
52
|
+
income_rate: string | null;
|
|
53
|
+
income_amount: string | null;
|
|
54
|
+
payroll_updated_by: Associate | null;
|
|
55
|
+
payroll_updated: Date | null;
|
|
47
56
|
details: any | null;
|
|
48
57
|
created: Date;
|
|
49
58
|
updated: Date | null;
|
|
@@ -192,6 +192,99 @@ __decorate([
|
|
|
192
192
|
(0, typeorm_1.JoinColumn)({ name: "blocked_by" }),
|
|
193
193
|
__metadata("design:type", Object)
|
|
194
194
|
], ServiceOrderStage.prototype, "blocked_by", void 0);
|
|
195
|
+
__decorate([
|
|
196
|
+
(0, typeorm_1.Column)({
|
|
197
|
+
type: "int",
|
|
198
|
+
default: null,
|
|
199
|
+
nullable: true,
|
|
200
|
+
comment: "Cómo se paga esta etapa al responsable.\n1: Por hora.\n3: Por pieza o trabajo.\nNULL: sin pago (el 2, por día, no va en las etapas).",
|
|
201
|
+
}),
|
|
202
|
+
__metadata("design:type", Object)
|
|
203
|
+
], ServiceOrderStage.prototype, "pay_unit", void 0);
|
|
204
|
+
__decorate([
|
|
205
|
+
(0, typeorm_1.Column)({
|
|
206
|
+
type: "decimal",
|
|
207
|
+
precision: 8,
|
|
208
|
+
scale: 2,
|
|
209
|
+
default: null,
|
|
210
|
+
nullable: true,
|
|
211
|
+
comment: "Horas o piezas que se le pagan al responsable.",
|
|
212
|
+
}),
|
|
213
|
+
__metadata("design:type", Object)
|
|
214
|
+
], ServiceOrderStage.prototype, "pay_quantity", void 0);
|
|
215
|
+
__decorate([
|
|
216
|
+
(0, typeorm_1.Column)({
|
|
217
|
+
type: "decimal",
|
|
218
|
+
precision: 14,
|
|
219
|
+
scale: 2,
|
|
220
|
+
default: null,
|
|
221
|
+
nullable: true,
|
|
222
|
+
comment: "Valor por hora o por pieza (cargado de la tarifa del empleado o escrito).",
|
|
223
|
+
}),
|
|
224
|
+
__metadata("design:type", Object)
|
|
225
|
+
], ServiceOrderStage.prototype, "pay_rate", void 0);
|
|
226
|
+
__decorate([
|
|
227
|
+
(0, typeorm_1.Column)({
|
|
228
|
+
type: "decimal",
|
|
229
|
+
precision: 14,
|
|
230
|
+
scale: 2,
|
|
231
|
+
default: null,
|
|
232
|
+
nullable: true,
|
|
233
|
+
comment: "Pago al responsable = pay_quantity x pay_rate (costo de la etapa).",
|
|
234
|
+
}),
|
|
235
|
+
__metadata("design:type", Object)
|
|
236
|
+
], ServiceOrderStage.prototype, "pay_amount", void 0);
|
|
237
|
+
__decorate([
|
|
238
|
+
(0, typeorm_1.Column)({
|
|
239
|
+
type: "decimal",
|
|
240
|
+
precision: 8,
|
|
241
|
+
scale: 2,
|
|
242
|
+
default: null,
|
|
243
|
+
nullable: true,
|
|
244
|
+
comment: "Horas que paga la aseguradora (baremo). NULL en particular: el ingreso se escribe directo.",
|
|
245
|
+
}),
|
|
246
|
+
__metadata("design:type", Object)
|
|
247
|
+
], ServiceOrderStage.prototype, "income_hours", void 0);
|
|
248
|
+
__decorate([
|
|
249
|
+
(0, typeorm_1.Column)({
|
|
250
|
+
type: "decimal",
|
|
251
|
+
precision: 14,
|
|
252
|
+
scale: 2,
|
|
253
|
+
default: null,
|
|
254
|
+
nullable: true,
|
|
255
|
+
comment: "Valor hora de la aseguradora usado (carrocería o pintura).",
|
|
256
|
+
}),
|
|
257
|
+
__metadata("design:type", Object)
|
|
258
|
+
], ServiceOrderStage.prototype, "income_rate", void 0);
|
|
259
|
+
__decorate([
|
|
260
|
+
(0, typeorm_1.Column)({
|
|
261
|
+
type: "decimal",
|
|
262
|
+
precision: 14,
|
|
263
|
+
scale: 2,
|
|
264
|
+
default: null,
|
|
265
|
+
nullable: true,
|
|
266
|
+
comment: "Ingreso de la etapa = income_hours x income_rate, o escrito a mano en particular.",
|
|
267
|
+
}),
|
|
268
|
+
__metadata("design:type", Object)
|
|
269
|
+
], ServiceOrderStage.prototype, "income_amount", void 0);
|
|
270
|
+
__decorate([
|
|
271
|
+
(0, typeorm_1.ManyToOne)(() => Associate_1.Associate, {
|
|
272
|
+
onDelete: "SET NULL",
|
|
273
|
+
onUpdate: "NO ACTION",
|
|
274
|
+
nullable: true,
|
|
275
|
+
}),
|
|
276
|
+
(0, typeorm_1.JoinColumn)({ name: "payroll_updated_by" }),
|
|
277
|
+
__metadata("design:type", Object)
|
|
278
|
+
], ServiceOrderStage.prototype, "payroll_updated_by", void 0);
|
|
279
|
+
__decorate([
|
|
280
|
+
(0, typeorm_1.Column)({
|
|
281
|
+
type: "datetime",
|
|
282
|
+
default: null,
|
|
283
|
+
nullable: true,
|
|
284
|
+
comment: "Cuándo se cambió el pago o el ingreso.",
|
|
285
|
+
}),
|
|
286
|
+
__metadata("design:type", Object)
|
|
287
|
+
], ServiceOrderStage.prototype, "payroll_updated", void 0);
|
|
195
288
|
__decorate([
|
|
196
289
|
(0, typeorm_1.Column)({
|
|
197
290
|
type: "json",
|
|
@@ -59,6 +59,46 @@ __decorate([
|
|
|
59
59
|
(0, typeorm_1.JoinColumn)({ name: "created_by" }),
|
|
60
60
|
__metadata("design:type", Object)
|
|
61
61
|
], WorkshopInsurer.prototype, "created_by", void 0);
|
|
62
|
+
__decorate([
|
|
63
|
+
(0, typeorm_1.Column)({
|
|
64
|
+
type: "decimal",
|
|
65
|
+
precision: 14,
|
|
66
|
+
scale: 2,
|
|
67
|
+
nullable: true,
|
|
68
|
+
default: null,
|
|
69
|
+
comment: "Valor hora que paga la aseguradora (carrocería / mecánica). NULL: sin tarifa.",
|
|
70
|
+
}),
|
|
71
|
+
__metadata("design:type", Object)
|
|
72
|
+
], WorkshopInsurer.prototype, "hour_rate", void 0);
|
|
73
|
+
__decorate([
|
|
74
|
+
(0, typeorm_1.Column)({
|
|
75
|
+
type: "decimal",
|
|
76
|
+
precision: 14,
|
|
77
|
+
scale: 2,
|
|
78
|
+
nullable: true,
|
|
79
|
+
default: null,
|
|
80
|
+
comment: "Valor hora de pintura si es distinto. NULL: se usa hour_rate.",
|
|
81
|
+
}),
|
|
82
|
+
__metadata("design:type", Object)
|
|
83
|
+
], WorkshopInsurer.prototype, "paint_hour_rate", void 0);
|
|
84
|
+
__decorate([
|
|
85
|
+
(0, typeorm_1.ManyToOne)(() => Associate_1.Associate, {
|
|
86
|
+
onDelete: "SET NULL",
|
|
87
|
+
onUpdate: "NO ACTION",
|
|
88
|
+
nullable: true,
|
|
89
|
+
}),
|
|
90
|
+
(0, typeorm_1.JoinColumn)({ name: "rates_updated_by" }),
|
|
91
|
+
__metadata("design:type", Object)
|
|
92
|
+
], WorkshopInsurer.prototype, "rates_updated_by", void 0);
|
|
93
|
+
__decorate([
|
|
94
|
+
(0, typeorm_1.Column)({
|
|
95
|
+
type: "datetime",
|
|
96
|
+
nullable: true,
|
|
97
|
+
default: null,
|
|
98
|
+
comment: "Cuándo se cambiaron las tarifas.",
|
|
99
|
+
}),
|
|
100
|
+
__metadata("design:type", Object)
|
|
101
|
+
], WorkshopInsurer.prototype, "rates_updated", void 0);
|
|
62
102
|
exports.WorkshopInsurer = WorkshopInsurer = __decorate([
|
|
63
103
|
(0, typeorm_1.Entity)("workshop_insurer", {
|
|
64
104
|
comment: "Aseguradoras con convenio de cada sede.",
|
package/dist/entities.index.d.ts
CHANGED
|
@@ -135,3 +135,5 @@ export { VehicleMeasurement } from "./entities/VehicleMeasurement";
|
|
|
135
135
|
export { ObdCode } from "./entities/ObdCode";
|
|
136
136
|
export { WorkshopReportInbox } from "./entities/WorkshopReportInbox";
|
|
137
137
|
export { JobTitle } from "./entities/JobTitle";
|
|
138
|
+
export { AssociatePayRate } from "./entities/AssociatePayRate";
|
|
139
|
+
export { PayrollMonthDays } from "./entities/PayrollMonthDays";
|
package/dist/entities.index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AssociateSection = exports.AssociatePermission = exports.AssociateRole = exports.AssociatePlatform = exports.ClientSubscription = exports.ClientPlanLimit = exports.ClientPlan = exports.ClientDocumentDispute = exports.ReviewTaskEvent = exports.ReviewTask = exports.MasterNotification = exports.ClientSession = exports.ClientNotification = exports.ClientIdentity = exports.PypRuleVote = exports.PypRule = exports.VehicleVerification = exports.ClientVehicleInvite = exports.ClientVehicle = exports.CompanyVehicle = exports.CompanyClient = exports.Appointment = exports.DocumentType = exports.ReminderType = exports.Reminder = exports.ServiceOrderHistory = exports.ServiceOrder = exports.TemplateSection = exports.SectionItem = exports.Section = exports.Template = exports.Workshop = exports.GlobalTemplateSection = exports.GlobalSectionItem = exports.GlobalSection = exports.GlobalTemplate = exports.AssociateNotification = exports.AssociateSession = exports.MasterSession = exports.Associate = exports.Client = exports.Master = exports.VehicleReport = exports.Vehicle = exports.Brand = exports.Company = exports.City = exports.Region = exports.WhatsappLine = exports.Country = void 0;
|
|
4
4
|
exports.AssociateDailyStats = exports.WorkshopDailyStats = exports.WorkboardEvent = exports.ServiceOrderStage = exports.WorkboardStatus = exports.CompanyDiscount = exports.DiscountCode = exports.WorkshopDisplay = exports.WorkshopInsurer = exports.WorkshopOfferedService = exports.Insurer = exports.OfferedService = exports.WorkshopOutingRecipient = exports.ServiceOrderOuting = exports.ServiceOrderPart = exports.ServiceOrderObservation = exports.VisitResult = exports.ReminderTypeCompanyType = exports.PlanCompanyType = exports.WorkshopCompanyType = exports.CompanyCompanyType = exports.CompanyType = exports.PlanFeature = exports.CompanyFeature = exports.Feature = exports.UsageAlert = exports.SubscriptionAddonTemplate = exports.PaymentTransaction = exports.BillingInvoice = exports.EmailSuppression = exports.EmailLog = exports.WhatsappLog = exports.ServiceOrderApproval = exports.MediaFile = exports.BillingUsageSnapshot = exports.PaymentMethod = exports.SubscriptionAddon = exports.CompanySubscription = exports.SubscriptionPlan = exports.CountryHoliday = exports.CompanyVehicleType = exports.BrandVehicleType = exports.CompanyBrand = exports.VehicleType = exports.MasterSection = exports.MasterPermission = exports.MasterRole = exports.MasterPlatform = exports.MasterPasswordReset = exports.AssociatePasswordReset = void 0;
|
|
5
|
-
exports.JobTitle = exports.WorkshopReportInbox = exports.ObdCode = exports.VehicleMeasurement = exports.WorkshopEquipment = exports.EquipmentType = exports.CompanyAiUsage = exports.CompanyQuotaAdjustment = exports.VisitSearchHistory = exports.VisitAiAnalysis = exports.VisitSearchPerson = exports.VisitItemSearch = exports.GlobalSectionItems = exports.GlobalSections = exports.GlobalTemplates = exports.SubscriptionAddonTemplates = exports.SubscriptionPlans = exports.Masters = exports.Companies = exports.WorkshopsByAssociate = exports.Workshops = exports.SectionItems = exports.Sections = exports.Templates = exports.Reminders = exports.Vehicles = exports.Clients = exports.ServicesOrderLite = exports.ServicesOrder = exports.Associates = exports.AssociateSectionFeature = exports.AttendanceMark = exports.WorkshopReader = exports.AssociateTag = exports.WorkshopTag = exports.MetricEvent = exports.StageMetric = void 0;
|
|
5
|
+
exports.PayrollMonthDays = exports.AssociatePayRate = exports.JobTitle = exports.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");
|
|
@@ -304,3 +304,7 @@ var WorkshopReportInbox_1 = require("./entities/WorkshopReportInbox");
|
|
|
304
304
|
Object.defineProperty(exports, "WorkshopReportInbox", { enumerable: true, get: function () { return WorkshopReportInbox_1.WorkshopReportInbox; } });
|
|
305
305
|
var JobTitle_1 = require("./entities/JobTitle");
|
|
306
306
|
Object.defineProperty(exports, "JobTitle", { enumerable: true, get: function () { return JobTitle_1.JobTitle; } });
|
|
307
|
+
var AssociatePayRate_1 = require("./entities/AssociatePayRate");
|
|
308
|
+
Object.defineProperty(exports, "AssociatePayRate", { enumerable: true, get: function () { return AssociatePayRate_1.AssociatePayRate; } });
|
|
309
|
+
var PayrollMonthDays_1 = require("./entities/PayrollMonthDays");
|
|
310
|
+
Object.defineProperty(exports, "PayrollMonthDays", { enumerable: true, get: function () { return PayrollMonthDays_1.PayrollMonthDays; } });
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -249,3 +249,5 @@ async function executeQuery(query, params = []) {
|
|
|
249
249
|
__exportStar(require("./rules/associate.profile.rules"), exports);
|
|
250
250
|
__exportStar(require("./rules/badge.card.rules"), exports);
|
|
251
251
|
__exportStar(require("./rules/estimate.time.rules"), exports);
|
|
252
|
+
// Nómina y rentabilidad (sql/93).
|
|
253
|
+
__exportStar(require("./rules/payroll.rules"), exports);
|
|
@@ -19,6 +19,7 @@ export declare const FEATURE_CODE: {
|
|
|
19
19
|
readonly ATTENDANCE: "ATTENDANCE";
|
|
20
20
|
readonly VEHICLE_HISTORY: "VEHICLE_HISTORY";
|
|
21
21
|
readonly EQUIPMENT_READINGS: "EQUIPMENT_READINGS";
|
|
22
|
+
readonly PAYROLL: "PAYROLL";
|
|
22
23
|
};
|
|
23
24
|
export type TFeatureCode = (typeof FEATURE_CODE)[keyof typeof FEATURE_CODE];
|
|
24
25
|
export declare const FEATURE_CODES: TFeatureCode[];
|
|
@@ -32,6 +32,8 @@ exports.FEATURE_CODE = {
|
|
|
32
32
|
VEHICLE_HISTORY: "VEHICLE_HISTORY",
|
|
33
33
|
// DOC: Mediciones de equipos del taller (sql/81). Por sede, con su cupo de lecturas con IA (complemento 12).
|
|
34
34
|
EQUIPMENT_READINGS: "EQUIPMENT_READINGS",
|
|
35
|
+
// DOC: Nómina y rentabilidad (sql/93). De EMPRESA: tarifas, pago e ingreso por etapa y el reporte del mes.
|
|
36
|
+
PAYROLL: "PAYROLL",
|
|
35
37
|
};
|
|
36
38
|
exports.FEATURE_CODES = Object.values(exports.FEATURE_CODE);
|
|
37
39
|
const isFeatureCode = (code) => exports.FEATURE_CODES.includes(code);
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
export declare const PAY_UNIT: {
|
|
2
|
+
readonly HOUR: 1;
|
|
3
|
+
readonly DAY: 2;
|
|
4
|
+
readonly PIECE: 3;
|
|
5
|
+
};
|
|
6
|
+
export type TPayUnit = (typeof PAY_UNIT)[keyof typeof PAY_UNIT];
|
|
7
|
+
export declare const PAY_UNITS: readonly TPayUnit[];
|
|
8
|
+
export declare const STAGE_PAY_UNITS: readonly TPayUnit[];
|
|
9
|
+
export declare const LABOR_TYPE: {
|
|
10
|
+
readonly BODY: 1;
|
|
11
|
+
readonly PAINT: 2;
|
|
12
|
+
};
|
|
13
|
+
export type TLaborType = (typeof LABOR_TYPE)[keyof typeof LABOR_TYPE];
|
|
14
|
+
export declare const LABOR_TYPES: readonly TLaborType[];
|
|
15
|
+
export declare const MAX_PAYROLL_MONEY = 999999999999.99;
|
|
16
|
+
export declare const MAX_PAYROLL_QUANTITY = 9999;
|
|
17
|
+
export declare const MAX_MONTH_DAYS = 31;
|
|
18
|
+
export declare const isPayUnit: (value: unknown, allowed?: readonly TPayUnit[]) => value is TPayUnit;
|
|
19
|
+
export declare const isLaborType: (value: unknown) => value is TLaborType;
|
|
20
|
+
/** DOC: Plata: vacío = null; negativo, texto o más del tope = false. A dos decimales. */
|
|
21
|
+
export declare const normalizePayrollMoney: (value: unknown) => number | null | false;
|
|
22
|
+
/** DOC: Horas o piezas: vacío = null; cero, negativo o más del tope = false. A dos decimales. */
|
|
23
|
+
export declare const normalizePayrollQuantity: (value: unknown) => number | null | false;
|
|
24
|
+
/** DOC: Días del mes para el que gana por día: de 0 a 31, con un decimal (medio día). */
|
|
25
|
+
export declare const normalizeMonthDays: (value: unknown) => number | null | false;
|
|
26
|
+
/** DOC: Cantidad x valor; null si falta alguno. */
|
|
27
|
+
export declare const payrollLineAmount: (quantity: unknown, rate: unknown) => number | null;
|
|
28
|
+
export interface IInsurerRates {
|
|
29
|
+
hour_rate: string | number | null;
|
|
30
|
+
paint_hour_rate: string | number | null;
|
|
31
|
+
}
|
|
32
|
+
/** DOC: El valor hora de la aseguradora para la sección: el de pintura solo si la sección es de pintura y lo tiene. */
|
|
33
|
+
export declare const insurerHourRateFor: (rates: IInsurerRates | null | undefined, laborType: unknown) => number | null;
|
|
34
|
+
export interface IAssociatePayRateShape {
|
|
35
|
+
pay_unit: number;
|
|
36
|
+
amount: string | number;
|
|
37
|
+
}
|
|
38
|
+
export interface IStagePayValues {
|
|
39
|
+
pay_unit: TPayUnit | null;
|
|
40
|
+
pay_quantity: number | null;
|
|
41
|
+
pay_rate: number | null;
|
|
42
|
+
pay_amount: number | null;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* DOC: Lo que se carga en la etapa al escoger al responsable. Por hora trae como cantidad las horas
|
|
46
|
+
* estimadas de la etapa; por pieza deja la cantidad para escribirla. Por día no carga nada.
|
|
47
|
+
*/
|
|
48
|
+
export declare const suggestStagePay: (rate: IAssociatePayRateShape | null | undefined, estimatedHours?: string | number | null | undefined) => IStagePayValues | null;
|
|
49
|
+
export interface IStagePayrollValues extends IStagePayValues {
|
|
50
|
+
income_hours: number | null;
|
|
51
|
+
income_rate: number | null;
|
|
52
|
+
income_amount: number | null;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* DOC: Valida y completa el pago y el ingreso de una etapa. Los totales los calcula siempre el servidor:
|
|
56
|
+
* pago = cantidad x valor; ingreso = horas x valor hora o, sin horas (particular), el escrito a mano.
|
|
57
|
+
*/
|
|
58
|
+
export declare const resolveStagePayroll: (input: any) => IStagePayrollValues | {
|
|
59
|
+
error: "INVALID_PAYROLL";
|
|
60
|
+
};
|
|
61
|
+
/** DOC: ¿Trae algo la etapa? Sirve para no escribir filas vacías al crear la visita. */
|
|
62
|
+
export declare const hasStagePayroll: (values: IStagePayrollValues) => boolean;
|
|
63
|
+
/** DOC: A quién se le acredita la etapa: al responsable; si no hay, a quien la tomó. */
|
|
64
|
+
export declare const creditedAssociateId: (stage: {
|
|
65
|
+
assigned_associate?: {
|
|
66
|
+
id: number;
|
|
67
|
+
} | number | null;
|
|
68
|
+
taken_by?: {
|
|
69
|
+
id: number;
|
|
70
|
+
} | number | null;
|
|
71
|
+
}) => number | null;
|
|
72
|
+
/** DOC: Mes «AAAA-MM». Devuelve el primer día del mes y el del siguiente (fin exclusivo), o null. */
|
|
73
|
+
export declare const payrollMonthRange: (month: unknown) => {
|
|
74
|
+
month: string;
|
|
75
|
+
start: string;
|
|
76
|
+
end: string;
|
|
77
|
+
} | null;
|
|
78
|
+
/** DOC: Pago del que gana por día: días x valor. */
|
|
79
|
+
export declare const payForDays: (days: unknown, rate: unknown) => number | null;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// DOC: Nómina y rentabilidad (sql/93, funcionalidad PAYROLL). Solo informativa: no paga nada.
|
|
3
|
+
// En los fronts se importa por ruta profunda:
|
|
4
|
+
// import { PAY_UNIT } from "@asumano/worklip-typeorm-db/dist/rules/payroll.rules";
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.payForDays = exports.payrollMonthRange = exports.creditedAssociateId = exports.hasStagePayroll = exports.resolveStagePayroll = exports.suggestStagePay = exports.insurerHourRateFor = exports.payrollLineAmount = exports.normalizeMonthDays = exports.normalizePayrollQuantity = exports.normalizePayrollMoney = exports.isLaborType = exports.isPayUnit = exports.MAX_MONTH_DAYS = exports.MAX_PAYROLL_QUANTITY = exports.MAX_PAYROLL_MONEY = exports.LABOR_TYPES = exports.LABOR_TYPE = exports.STAGE_PAY_UNITS = exports.PAY_UNITS = exports.PAY_UNIT = void 0;
|
|
7
|
+
// DOC: Cómo se le paga al empleado (associate_pay_rate.pay_unit). El 2 no va en las etapas.
|
|
8
|
+
exports.PAY_UNIT = { HOUR: 1, DAY: 2, PIECE: 3 };
|
|
9
|
+
exports.PAY_UNITS = [1, 2, 3];
|
|
10
|
+
exports.STAGE_PAY_UNITS = [1, 3];
|
|
11
|
+
// DOC: Con qué valor hora de la aseguradora se cobra la sección (section.labor_type).
|
|
12
|
+
exports.LABOR_TYPE = { BODY: 1, PAINT: 2 };
|
|
13
|
+
exports.LABOR_TYPES = [1, 2];
|
|
14
|
+
// DOC: Topes de las columnas: decimal(14,2) para plata y decimal(8,2) para horas o piezas (un tope sensato).
|
|
15
|
+
exports.MAX_PAYROLL_MONEY = 999999999999.99;
|
|
16
|
+
exports.MAX_PAYROLL_QUANTITY = 9999;
|
|
17
|
+
exports.MAX_MONTH_DAYS = 31;
|
|
18
|
+
const isPayUnit = (value, allowed = exports.PAY_UNITS) => allowed.includes(Number(value)) && Number.isInteger(Number(value));
|
|
19
|
+
exports.isPayUnit = isPayUnit;
|
|
20
|
+
const isLaborType = (value) => exports.LABOR_TYPES.includes(Number(value)) && Number.isInteger(Number(value));
|
|
21
|
+
exports.isLaborType = isLaborType;
|
|
22
|
+
const round2 = (value) => Math.round(value * 100) / 100;
|
|
23
|
+
const isEmpty = (value) => value === null || value === undefined || value === "";
|
|
24
|
+
const toNumber = (value) => {
|
|
25
|
+
if (isEmpty(value))
|
|
26
|
+
return null;
|
|
27
|
+
const parsed = typeof value === "number" ? value : Number(String(value).trim());
|
|
28
|
+
return Number.isFinite(parsed) ? parsed : NaN;
|
|
29
|
+
};
|
|
30
|
+
/** DOC: Plata: vacío = null; negativo, texto o más del tope = false. A dos decimales. */
|
|
31
|
+
const normalizePayrollMoney = (value) => {
|
|
32
|
+
const parsed = toNumber(value);
|
|
33
|
+
if (parsed === null)
|
|
34
|
+
return null;
|
|
35
|
+
if (Number.isNaN(parsed) || parsed < 0 || parsed > exports.MAX_PAYROLL_MONEY)
|
|
36
|
+
return false;
|
|
37
|
+
return round2(parsed);
|
|
38
|
+
};
|
|
39
|
+
exports.normalizePayrollMoney = normalizePayrollMoney;
|
|
40
|
+
/** DOC: Horas o piezas: vacío = null; cero, negativo o más del tope = false. A dos decimales. */
|
|
41
|
+
const normalizePayrollQuantity = (value) => {
|
|
42
|
+
const parsed = toNumber(value);
|
|
43
|
+
if (parsed === null)
|
|
44
|
+
return null;
|
|
45
|
+
if (Number.isNaN(parsed) || parsed <= 0 || parsed > exports.MAX_PAYROLL_QUANTITY)
|
|
46
|
+
return false;
|
|
47
|
+
return round2(parsed);
|
|
48
|
+
};
|
|
49
|
+
exports.normalizePayrollQuantity = normalizePayrollQuantity;
|
|
50
|
+
/** DOC: Días del mes para el que gana por día: de 0 a 31, con un decimal (medio día). */
|
|
51
|
+
const normalizeMonthDays = (value) => {
|
|
52
|
+
const parsed = toNumber(value);
|
|
53
|
+
if (parsed === null)
|
|
54
|
+
return null;
|
|
55
|
+
if (Number.isNaN(parsed) || parsed < 0 || parsed > exports.MAX_MONTH_DAYS)
|
|
56
|
+
return false;
|
|
57
|
+
return Math.round(parsed * 10) / 10;
|
|
58
|
+
};
|
|
59
|
+
exports.normalizeMonthDays = normalizeMonthDays;
|
|
60
|
+
/** DOC: Cantidad x valor; null si falta alguno. */
|
|
61
|
+
const payrollLineAmount = (quantity, rate) => {
|
|
62
|
+
const q = toNumber(quantity);
|
|
63
|
+
const r = toNumber(rate);
|
|
64
|
+
if (q === null || r === null || Number.isNaN(q) || Number.isNaN(r))
|
|
65
|
+
return null;
|
|
66
|
+
return round2(q * r);
|
|
67
|
+
};
|
|
68
|
+
exports.payrollLineAmount = payrollLineAmount;
|
|
69
|
+
/** DOC: El valor hora de la aseguradora para la sección: el de pintura solo si la sección es de pintura y lo tiene. */
|
|
70
|
+
const insurerHourRateFor = (rates, laborType) => {
|
|
71
|
+
if (!rates)
|
|
72
|
+
return null;
|
|
73
|
+
const paint = toNumber(rates.paint_hour_rate);
|
|
74
|
+
const general = toNumber(rates.hour_rate);
|
|
75
|
+
if (Number(laborType) === exports.LABOR_TYPE.PAINT && paint !== null && !Number.isNaN(paint))
|
|
76
|
+
return paint;
|
|
77
|
+
return general === null || Number.isNaN(general) ? null : general;
|
|
78
|
+
};
|
|
79
|
+
exports.insurerHourRateFor = insurerHourRateFor;
|
|
80
|
+
/**
|
|
81
|
+
* DOC: Lo que se carga en la etapa al escoger al responsable. Por hora trae como cantidad las horas
|
|
82
|
+
* estimadas de la etapa; por pieza deja la cantidad para escribirla. Por día no carga nada.
|
|
83
|
+
*/
|
|
84
|
+
const suggestStagePay = (rate, estimatedHours = null) => {
|
|
85
|
+
if (!rate || !(0, exports.isPayUnit)(rate.pay_unit, exports.STAGE_PAY_UNITS))
|
|
86
|
+
return null;
|
|
87
|
+
const amount = toNumber(rate.amount);
|
|
88
|
+
if (amount === null || Number.isNaN(amount))
|
|
89
|
+
return null;
|
|
90
|
+
const hours = rate.pay_unit === exports.PAY_UNIT.HOUR ? (0, exports.normalizePayrollQuantity)(estimatedHours) : null;
|
|
91
|
+
const quantity = hours === false ? null : hours;
|
|
92
|
+
return {
|
|
93
|
+
pay_unit: rate.pay_unit,
|
|
94
|
+
pay_quantity: quantity,
|
|
95
|
+
pay_rate: round2(amount),
|
|
96
|
+
pay_amount: (0, exports.payrollLineAmount)(quantity, amount),
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
exports.suggestStagePay = suggestStagePay;
|
|
100
|
+
/**
|
|
101
|
+
* DOC: Valida y completa el pago y el ingreso de una etapa. Los totales los calcula siempre el servidor:
|
|
102
|
+
* pago = cantidad x valor; ingreso = horas x valor hora o, sin horas (particular), el escrito a mano.
|
|
103
|
+
*/
|
|
104
|
+
const resolveStagePayroll = (input) => {
|
|
105
|
+
const invalid = { error: "INVALID_PAYROLL" };
|
|
106
|
+
const unitRaw = input?.pay_unit;
|
|
107
|
+
const hasUnit = !isEmpty(unitRaw);
|
|
108
|
+
if (hasUnit && !(0, exports.isPayUnit)(unitRaw, exports.STAGE_PAY_UNITS))
|
|
109
|
+
return invalid;
|
|
110
|
+
const quantity = hasUnit ? (0, exports.normalizePayrollQuantity)(input?.pay_quantity) : null;
|
|
111
|
+
const rate = hasUnit ? (0, exports.normalizePayrollMoney)(input?.pay_rate) : null;
|
|
112
|
+
const incomeHours = (0, exports.normalizePayrollQuantity)(input?.income_hours);
|
|
113
|
+
const incomeRate = (0, exports.normalizePayrollMoney)(input?.income_rate);
|
|
114
|
+
const incomeManual = (0, exports.normalizePayrollMoney)(input?.income_amount);
|
|
115
|
+
if ([quantity, rate, incomeHours, incomeRate, incomeManual].includes(false))
|
|
116
|
+
return invalid;
|
|
117
|
+
const incomeByHours = (0, exports.payrollLineAmount)(incomeHours, incomeRate);
|
|
118
|
+
return {
|
|
119
|
+
pay_unit: hasUnit ? Number(unitRaw) : null,
|
|
120
|
+
pay_quantity: quantity,
|
|
121
|
+
pay_rate: rate,
|
|
122
|
+
pay_amount: (0, exports.payrollLineAmount)(quantity, rate),
|
|
123
|
+
income_hours: incomeHours,
|
|
124
|
+
income_rate: incomeRate,
|
|
125
|
+
income_amount: incomeByHours ?? incomeManual,
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
exports.resolveStagePayroll = resolveStagePayroll;
|
|
129
|
+
/** DOC: ¿Trae algo la etapa? Sirve para no escribir filas vacías al crear la visita. */
|
|
130
|
+
const hasStagePayroll = (values) => values.pay_unit !== null || values.income_amount !== null || values.income_hours !== null || values.income_rate !== null;
|
|
131
|
+
exports.hasStagePayroll = hasStagePayroll;
|
|
132
|
+
/** DOC: A quién se le acredita la etapa: al responsable; si no hay, a quien la tomó. */
|
|
133
|
+
const creditedAssociateId = (stage) => {
|
|
134
|
+
const id = (value) => value === null || value === undefined ? null : typeof value === "number" ? value : value.id ?? null;
|
|
135
|
+
return id(stage.assigned_associate) ?? id(stage.taken_by);
|
|
136
|
+
};
|
|
137
|
+
exports.creditedAssociateId = creditedAssociateId;
|
|
138
|
+
/** DOC: Mes «AAAA-MM». Devuelve el primer día del mes y el del siguiente (fin exclusivo), o null. */
|
|
139
|
+
const payrollMonthRange = (month) => {
|
|
140
|
+
const match = /^(\d{4})-(\d{2})$/.exec(String(month ?? ""));
|
|
141
|
+
if (!match)
|
|
142
|
+
return null;
|
|
143
|
+
const year = Number(match[1]);
|
|
144
|
+
const index = Number(match[2]);
|
|
145
|
+
if (year < 2000 || year > 2100 || index < 1 || index > 12)
|
|
146
|
+
return null;
|
|
147
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
148
|
+
const nextYear = index === 12 ? year + 1 : year;
|
|
149
|
+
const nextMonth = index === 12 ? 1 : index + 1;
|
|
150
|
+
return {
|
|
151
|
+
month: `${year}-${pad(index)}`,
|
|
152
|
+
start: `${year}-${pad(index)}-01`,
|
|
153
|
+
end: `${nextYear}-${pad(nextMonth)}-01`,
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
exports.payrollMonthRange = payrollMonthRange;
|
|
157
|
+
/** DOC: Pago del que gana por día: días x valor. */
|
|
158
|
+
const payForDays = (days, rate) => (0, exports.payrollLineAmount)(days, rate);
|
|
159
|
+
exports.payForDays = payForDays;
|