@asumano/worklip-typeorm-db 1.1.55 → 1.1.57
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.
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getServicesOrderForTheTable = getServicesOrderForTheTable;
|
|
4
|
+
// DOC: Columnas de la tabla de visitas que el front filtra por rango [desde, hasta]
|
|
5
|
+
// con matchMode "custom".
|
|
6
|
+
const DATE_RANGE_COLUMNS = ["created", "updated"];
|
|
7
|
+
// DOC: `price` estaba declarado con matchMode "custom" en el front pero no tenía
|
|
8
|
+
// rama acá, así que el filtro de precio no hacía nada. `progress_percentage`
|
|
9
|
+
// y `quotation_total` salen del resumen de la visita (ver la vista
|
|
10
|
+
// services_order).
|
|
11
|
+
const NUMBER_RANGE_COLUMNS = [
|
|
12
|
+
"price",
|
|
13
|
+
"history_count",
|
|
14
|
+
"reminder_count",
|
|
15
|
+
"progress_percentage",
|
|
16
|
+
"quotation_total",
|
|
17
|
+
];
|
|
4
18
|
async function getServicesOrderForTheTable(repository, { company, workshop, status, visible, lazyEvent }) {
|
|
5
19
|
try {
|
|
6
20
|
const queryBuilder = repository
|
|
@@ -46,23 +60,28 @@ async function getServicesOrderForTheTable(repository, { company, workshop, stat
|
|
|
46
60
|
switch (matchMode // DOC: Verificamos el modo de coincidencia del filtro.
|
|
47
61
|
) {
|
|
48
62
|
case "custom":
|
|
49
|
-
|
|
63
|
+
// DOC: Rangos [desde, hasta]. Los nombres de los parámetros llevan la
|
|
64
|
+
// columna (`${key}_from`) a propósito: antes todos usaban :from y
|
|
65
|
+
// :to, así que al aplicar DOS rangos a la vez (ej. precio y
|
|
66
|
+
// avance) el segundo le pisaba los valores al primero y el filtro
|
|
67
|
+
// devolvía cualquier cosa.
|
|
68
|
+
if (DATE_RANGE_COLUMNS.includes(key)) {
|
|
50
69
|
if (Array.isArray(value) && value.length === 2) {
|
|
51
70
|
const [from, to] = value;
|
|
52
71
|
if (from !== null && to === null) {
|
|
53
|
-
queryBuilder.andWhere(`${accessKey} >=
|
|
54
|
-
|
|
72
|
+
queryBuilder.andWhere(`${accessKey} >= :${key}_from`, {
|
|
73
|
+
[`${key}_from`]: new Date(from),
|
|
55
74
|
});
|
|
56
75
|
}
|
|
57
76
|
else if (from === null && to !== null) {
|
|
58
|
-
queryBuilder.andWhere(`${accessKey} <=
|
|
59
|
-
|
|
77
|
+
queryBuilder.andWhere(`${accessKey} <= :${key}_to`, {
|
|
78
|
+
[`${key}_to`]: new Date(to),
|
|
60
79
|
});
|
|
61
80
|
}
|
|
62
81
|
else if (from !== null && to !== null) {
|
|
63
|
-
queryBuilder.andWhere(`${accessKey} BETWEEN
|
|
64
|
-
|
|
65
|
-
|
|
82
|
+
queryBuilder.andWhere(`${accessKey} BETWEEN :${key}_from AND :${key}_to`, {
|
|
83
|
+
[`${key}_from`]: new Date(from),
|
|
84
|
+
[`${key}_to`]: new Date(to),
|
|
66
85
|
});
|
|
67
86
|
}
|
|
68
87
|
}
|
|
@@ -77,37 +96,24 @@ async function getServicesOrderForTheTable(repository, { company, workshop, stat
|
|
|
77
96
|
});
|
|
78
97
|
}
|
|
79
98
|
}
|
|
80
|
-
|
|
99
|
+
// DOC: Rangos numéricos. `price`, `progress_percentage` y
|
|
100
|
+
// `quotation_total` entran por acá igual que los conteos: el front
|
|
101
|
+
// manda [desde, hasta] con matchMode "custom".
|
|
102
|
+
if (NUMBER_RANGE_COLUMNS.includes(key)) {
|
|
81
103
|
if (Array.isArray(value) && value.length === 2) {
|
|
82
104
|
const [from, to] = value;
|
|
83
105
|
if (from !== null && to === null) {
|
|
84
|
-
queryBuilder.andWhere(`${accessKey} >=
|
|
85
|
-
|
|
86
|
-
else if (from === null && to !== null) {
|
|
87
|
-
queryBuilder.andWhere(`${accessKey} <= :to`, { to });
|
|
88
|
-
}
|
|
89
|
-
else if (from !== null && to !== null) {
|
|
90
|
-
queryBuilder.andWhere(`${accessKey} BETWEEN :from AND :to`, {
|
|
91
|
-
from,
|
|
92
|
-
to,
|
|
106
|
+
queryBuilder.andWhere(`${accessKey} >= :${key}_from`, {
|
|
107
|
+
[`${key}_from`]: from,
|
|
93
108
|
});
|
|
94
109
|
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
if (key === "reminder_count") {
|
|
98
|
-
if (Array.isArray(value) && value.length === 2) {
|
|
99
|
-
const [from, to] = value;
|
|
100
|
-
if (from !== null && to === null) {
|
|
101
|
-
queryBuilder.andWhere(`${accessKey} >= :from`, { from });
|
|
102
|
-
}
|
|
103
110
|
else if (from === null && to !== null) {
|
|
104
|
-
queryBuilder.andWhere(`${accessKey} <=
|
|
111
|
+
queryBuilder.andWhere(`${accessKey} <= :${key}_to`, {
|
|
112
|
+
[`${key}_to`]: to,
|
|
113
|
+
});
|
|
105
114
|
}
|
|
106
115
|
else if (from !== null && to !== null) {
|
|
107
|
-
queryBuilder.andWhere(`${accessKey} BETWEEN :from
|
|
108
|
-
from,
|
|
109
|
-
to,
|
|
110
|
-
});
|
|
116
|
+
queryBuilder.andWhere(`${accessKey} BETWEEN :${key}_from AND :${key}_to`, { [`${key}_from`]: from, [`${key}_to`]: to });
|
|
111
117
|
}
|
|
112
118
|
}
|
|
113
119
|
}
|
|
@@ -167,10 +173,9 @@ async function getServicesOrderForTheTable(repository, { company, workshop, stat
|
|
|
167
173
|
case "between": // DOC: Si el modo de coincidencia es "between".
|
|
168
174
|
if (Array.isArray(value) && value.length === 2) {
|
|
169
175
|
const [from, to] = value;
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
});
|
|
176
|
+
// DOC: Parámetros con el nombre de la columna, por lo mismo que en
|
|
177
|
+
// "custom": con :from/:to fijos, dos rangos a la vez se pisan.
|
|
178
|
+
queryBuilder.andWhere(`${accessKey} BETWEEN :${key}_from AND :${key}_to`, { [`${key}_from`]: from, [`${key}_to`]: to });
|
|
174
179
|
}
|
|
175
180
|
break;
|
|
176
181
|
}
|
|
@@ -12,6 +12,13 @@ export declare class ServicesOrder {
|
|
|
12
12
|
created: Date;
|
|
13
13
|
updated: Date;
|
|
14
14
|
status: number;
|
|
15
|
+
progress_percentage: number | null;
|
|
16
|
+
vehicle_health_percentage: number | null;
|
|
17
|
+
quotation_total: number | null;
|
|
18
|
+
quotation_pending_total: number | null;
|
|
19
|
+
quotation_items_pending: number | null;
|
|
20
|
+
items_bad: number | null;
|
|
21
|
+
items_not_marked: number | null;
|
|
15
22
|
workshop_id: number;
|
|
16
23
|
workshop_company: number;
|
|
17
24
|
workshop_name: string;
|
|
@@ -66,6 +66,34 @@ __decorate([
|
|
|
66
66
|
(0, typeorm_1.ViewColumn)(),
|
|
67
67
|
__metadata("design:type", Number)
|
|
68
68
|
], ServicesOrder.prototype, "status", void 0);
|
|
69
|
+
__decorate([
|
|
70
|
+
(0, typeorm_1.ViewColumn)(),
|
|
71
|
+
__metadata("design:type", Object)
|
|
72
|
+
], ServicesOrder.prototype, "progress_percentage", void 0);
|
|
73
|
+
__decorate([
|
|
74
|
+
(0, typeorm_1.ViewColumn)(),
|
|
75
|
+
__metadata("design:type", Object)
|
|
76
|
+
], ServicesOrder.prototype, "vehicle_health_percentage", void 0);
|
|
77
|
+
__decorate([
|
|
78
|
+
(0, typeorm_1.ViewColumn)(),
|
|
79
|
+
__metadata("design:type", Object)
|
|
80
|
+
], ServicesOrder.prototype, "quotation_total", void 0);
|
|
81
|
+
__decorate([
|
|
82
|
+
(0, typeorm_1.ViewColumn)(),
|
|
83
|
+
__metadata("design:type", Object)
|
|
84
|
+
], ServicesOrder.prototype, "quotation_pending_total", void 0);
|
|
85
|
+
__decorate([
|
|
86
|
+
(0, typeorm_1.ViewColumn)(),
|
|
87
|
+
__metadata("design:type", Object)
|
|
88
|
+
], ServicesOrder.prototype, "quotation_items_pending", void 0);
|
|
89
|
+
__decorate([
|
|
90
|
+
(0, typeorm_1.ViewColumn)(),
|
|
91
|
+
__metadata("design:type", Object)
|
|
92
|
+
], ServicesOrder.prototype, "items_bad", void 0);
|
|
93
|
+
__decorate([
|
|
94
|
+
(0, typeorm_1.ViewColumn)(),
|
|
95
|
+
__metadata("design:type", Object)
|
|
96
|
+
], ServicesOrder.prototype, "items_not_marked", void 0);
|
|
69
97
|
__decorate([
|
|
70
98
|
(0, typeorm_1.ViewColumn)(),
|
|
71
99
|
__metadata("design:type", Number)
|
package/dist/visit.summary.d.ts
CHANGED
|
@@ -74,7 +74,7 @@ export interface IPropsBuildVisitSummary {
|
|
|
74
74
|
isTaxIncluded: boolean;
|
|
75
75
|
}
|
|
76
76
|
export declare const buildVisitSummary: (data: IVisitData | null | undefined, { servicePrice, taxPercentage, isTaxIncluded }: IPropsBuildVisitSummary) => IVisitSummary;
|
|
77
|
-
export declare const getTaxConfig: (companyDetails: any
|
|
77
|
+
export declare const getTaxConfig: (companyDetails: any) => {
|
|
78
78
|
taxPercentage: number;
|
|
79
79
|
isTaxIncluded: boolean;
|
|
80
80
|
};
|
package/dist/visit.summary.js
CHANGED
|
@@ -124,13 +124,17 @@ const buildVisitSummary = (data, { servicePrice, taxPercentage, isTaxIncluded })
|
|
|
124
124
|
};
|
|
125
125
|
};
|
|
126
126
|
exports.buildVisitSummary = buildVisitSummary;
|
|
127
|
-
// DOC: Configuración de impuesto de la empresa dueña de la visita
|
|
128
|
-
//
|
|
129
|
-
|
|
127
|
+
// DOC: Configuración de impuesto de la empresa dueña de la visita. Si la empresa no
|
|
128
|
+
// definió una tarifa, NO se cobra impuesto.
|
|
129
|
+
//
|
|
130
|
+
// La tarifa del país NO se hereda a propósito: es solo una referencia que la
|
|
131
|
+
// pantalla de empresa muestra para que sepan cuánto poner al activarlo. Cobrarle
|
|
132
|
+
// impuesto a alguien que nunca se pronunció, y que además se moviera solo si el
|
|
133
|
+
// país cambia su tarifa, es un comportamiento que nadie pidió.
|
|
134
|
+
const getTaxConfig = (companyDetails) => {
|
|
130
135
|
const company = companyDetails || {};
|
|
131
|
-
const country = countryDetails || {};
|
|
132
136
|
return {
|
|
133
|
-
taxPercentage: Number(company.tax_percentage ??
|
|
137
|
+
taxPercentage: Number(company.tax_percentage ?? 0) || 0,
|
|
134
138
|
isTaxIncluded: company.is_tax_included ?? true,
|
|
135
139
|
};
|
|
136
140
|
};
|