@zauru-sdk/utils 1.0.116 → 1.0.119
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/esm/zauru/costos-items.utils.js +3 -2
- package/package.json +8 -9
- package/dist/cjs/index.js +0 -41
- package/dist/cjs/zauru/4pinos-reception-register.utils.js +0 -450
- package/dist/cjs/zauru/4pinos-receptions-form-history.utils.js +0 -102
- package/dist/cjs/zauru/automatic-number.utils.js +0 -28
- package/dist/cjs/zauru/bitacora-edicion-masiva.utils.js +0 -56
- package/dist/cjs/zauru/bundles.utils.js +0 -168
- package/dist/cjs/zauru/cases.utils.js +0 -21
- package/dist/cjs/zauru/consolidated-history.utils.js +0 -58
- package/dist/cjs/zauru/costos-items.utils.js +0 -617
- package/dist/cjs/zauru/deliveries.utils.js +0 -50
- package/dist/cjs/zauru/discharges-histsory.utils.js +0 -52
- package/dist/cjs/zauru/employees.utils.js +0 -44
- package/dist/cjs/zauru/form.utils.js +0 -160
- package/dist/cjs/zauru/invoices.utils.js +0 -85
- package/dist/cjs/zauru/items.utils.js +0 -126
- package/dist/cjs/zauru/lotes.utils.js +0 -287
- package/dist/cjs/zauru/motivos-rechazo.utils.js +0 -23
- package/dist/cjs/zauru/payees.utils.js +0 -136
- package/dist/cjs/zauru/profiles.utils.js +0 -41
- package/dist/cjs/zauru/providers.utils.js +0 -40
- package/dist/cjs/zauru/purchase-orders.utils.js +0 -393
- package/dist/cjs/zauru/shipments.utils.js +0 -95
- package/dist/cjs/zauru/specialItem.utils.js +0 -69
- package/dist/cjs/zauru/templates.utils.js +0 -102
- package/dist/cjs/zauru/tiposMuestra.utils.js +0 -69
- package/dist/cjs/zauru/webapp-tables.utils.js +0 -20
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.updateDischargeHistory = exports.createDischargeHistory = exports.getDischargeHistories = void 0;
|
|
4
|
-
const common_1 = require("@zauru-sdk/common");
|
|
5
|
-
const services_1 = require("@zauru-sdk/services");
|
|
6
|
-
/**
|
|
7
|
-
* Get getDischargeHistories from the web app table.
|
|
8
|
-
* @param headers Request headers.
|
|
9
|
-
* @param session Session object.
|
|
10
|
-
* @returns A Promise of AxiosUtilsResponse<DischargeHistory[]>.
|
|
11
|
-
*/
|
|
12
|
-
const getDischargeHistories = (headers, session) => {
|
|
13
|
-
return (0, common_1.handlePossibleAxiosErrors)(async () => {
|
|
14
|
-
const { discharge_history_web_app_table_id } = await (0, services_1.getVariablesByName)(headers, session, ["discharge_history_web_app_table_id"]);
|
|
15
|
-
const response = await (0, services_1.getWebAppTableRegisters)(session, discharge_history_web_app_table_id);
|
|
16
|
-
if (response.error) {
|
|
17
|
-
throw new Error(`Ocurrió un error al consultar el historial de discharges: ${response.userMsg}`);
|
|
18
|
-
}
|
|
19
|
-
const history = response?.data ?? [];
|
|
20
|
-
return history;
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
exports.getDischargeHistories = getDischargeHistories;
|
|
24
|
-
/**
|
|
25
|
-
* Create a template in the web app table.
|
|
26
|
-
* @param headers Request headers.
|
|
27
|
-
* @param session Session object.
|
|
28
|
-
* @param body DischargeHistory data to be created.
|
|
29
|
-
* @returns A Promise of AxiosUtilsResponse<DischargeHistory>.
|
|
30
|
-
*/
|
|
31
|
-
const createDischargeHistory = (headers, session, body) => {
|
|
32
|
-
return (0, common_1.handlePossibleAxiosErrors)(async () => {
|
|
33
|
-
const { discharge_history_web_app_table_id } = await (0, services_1.getVariablesByName)(headers, session, ["discharge_history_web_app_table_id"]);
|
|
34
|
-
const response = await (0, services_1.createWebAppTableRegister)(headers, discharge_history_web_app_table_id, body);
|
|
35
|
-
return response;
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
exports.createDischargeHistory = createDischargeHistory;
|
|
39
|
-
/**
|
|
40
|
-
* Put updateDischargeHistory from the web app table.
|
|
41
|
-
* @param headers Request headers.
|
|
42
|
-
* @param session Session object.
|
|
43
|
-
* @returns A Promise of AxiosUtilsResponse<DischargeHistory[]>.
|
|
44
|
-
*/
|
|
45
|
-
const updateDischargeHistory = (headers, session, body, id_registro) => {
|
|
46
|
-
return (0, common_1.handlePossibleAxiosErrors)(async () => {
|
|
47
|
-
const { discharge_history_web_app_table_id } = await (0, services_1.getVariablesByName)(headers, session, ["discharge_history_web_app_table_id"]);
|
|
48
|
-
const response = await (0, services_1.updateWebAppTableRegister)(headers, discharge_history_web_app_table_id, id_registro, { ...body });
|
|
49
|
-
return response;
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
exports.updateDischargeHistory = updateDischargeHistory;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getEmployeesByCurrentAgency = exports.getEmployeesByLabAgency = void 0;
|
|
4
|
-
const common_1 = require("@zauru-sdk/common");
|
|
5
|
-
const services_1 = require("@zauru-sdk/services");
|
|
6
|
-
/**
|
|
7
|
-
*
|
|
8
|
-
* @param headers
|
|
9
|
-
* @param session
|
|
10
|
-
* @returns
|
|
11
|
-
*/
|
|
12
|
-
const getEmployeesByLabAgency = async (headers, session) => {
|
|
13
|
-
return (0, common_1.handlePossibleAxiosErrors)(async () => {
|
|
14
|
-
const { lab_agency_id } = await (0, services_1.getVariablesByName)(headers, session, [
|
|
15
|
-
"lab_agency_id",
|
|
16
|
-
]);
|
|
17
|
-
const response = await (0, services_1.getEmployeesByAgencyId)(session, lab_agency_id);
|
|
18
|
-
if (response.error) {
|
|
19
|
-
const msg = `Ocurrió un error al consultar los empleados por agencia de laboratorio: ${response.userMsg}`;
|
|
20
|
-
console.error(msg);
|
|
21
|
-
throw new Error(msg);
|
|
22
|
-
}
|
|
23
|
-
return response?.data ?? [];
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
exports.getEmployeesByLabAgency = getEmployeesByLabAgency;
|
|
27
|
-
/**
|
|
28
|
-
*
|
|
29
|
-
* @param headers
|
|
30
|
-
* @param session
|
|
31
|
-
* @returns
|
|
32
|
-
*/
|
|
33
|
-
const getEmployeesByCurrentAgency = async (session) => {
|
|
34
|
-
return (0, common_1.handlePossibleAxiosErrors)(async () => {
|
|
35
|
-
const response = await (0, services_1.getEmployeesByAgencyId)(session, session.get("agency_id"));
|
|
36
|
-
if (response.error) {
|
|
37
|
-
const msg = `Ocurrió un error al consultar los empleados por la agencia actual: ${response.userMsg}`;
|
|
38
|
-
console.error(msg);
|
|
39
|
-
throw new Error(msg);
|
|
40
|
-
}
|
|
41
|
-
return response?.data ?? [];
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
exports.getEmployeesByCurrentAgency = getEmployeesByCurrentAgency;
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getMuestrasByInvoiceId = exports.getLastMuestra = exports.createRespuestaFormSubmission = exports.transformResultadosFormData = exports.transformFormSubmitObject = void 0;
|
|
4
|
-
const common_1 = require("@zauru-sdk/common");
|
|
5
|
-
const services_1 = require("@zauru-sdk/services");
|
|
6
|
-
function transformFormSubmitObject(input) {
|
|
7
|
-
const form_submission_values = [];
|
|
8
|
-
// Itera sobre las propiedades del objeto
|
|
9
|
-
for (const key in input) {
|
|
10
|
-
// Utiliza una expresión regular para detectar claves que coinciden con el patrón 'word_number'
|
|
11
|
-
const match = key.match(/^(.+?)_(\d+)$/);
|
|
12
|
-
if (match) {
|
|
13
|
-
const [, , form_field_id] = match;
|
|
14
|
-
let newObj = {
|
|
15
|
-
form_field_id,
|
|
16
|
-
groups_path: "[]",
|
|
17
|
-
};
|
|
18
|
-
if (input[key] instanceof File) {
|
|
19
|
-
const fileType = input[key].type;
|
|
20
|
-
newObj["value"] = "";
|
|
21
|
-
if (input[key]?.size > 0) {
|
|
22
|
-
// Verifica si el archivo es una imagen
|
|
23
|
-
if (fileType.startsWith("image/")) {
|
|
24
|
-
newObj["image"] = input[key];
|
|
25
|
-
}
|
|
26
|
-
// Verifica si el archivo es un PDF
|
|
27
|
-
else if (fileType === "application/pdf") {
|
|
28
|
-
newObj["pdf"] = input[key];
|
|
29
|
-
}
|
|
30
|
-
// Cualquier otro tipo de archivo
|
|
31
|
-
else {
|
|
32
|
-
newObj["file"] = input[key];
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
newObj["value"] = input[key];
|
|
38
|
-
}
|
|
39
|
-
form_submission_values.push(newObj);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return {
|
|
43
|
-
form_submission_values_attributes: (0, common_1.arrayToObject)(form_submission_values),
|
|
44
|
-
form_id: input.form_id,
|
|
45
|
-
document_id: input.document_id,
|
|
46
|
-
zid: input.zid,
|
|
47
|
-
document_type: input.document_type,
|
|
48
|
-
reference: input.reference,
|
|
49
|
-
id_number: input.id_number ?? "",
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
exports.transformFormSubmitObject = transformFormSubmitObject;
|
|
53
|
-
function transformResultadosFormData(input, document_id) {
|
|
54
|
-
const resultMap = {};
|
|
55
|
-
for (const [key, value] of Object.entries(input)) {
|
|
56
|
-
const parts = key.split("_");
|
|
57
|
-
if (parts.length === 3 &&
|
|
58
|
-
(parts[2] === "zid" || parts[2] === "reference")) {
|
|
59
|
-
const [index, item_id, specialField] = parts;
|
|
60
|
-
const compositeKey = `${index}_${item_id}`;
|
|
61
|
-
if (!resultMap[compositeKey]) {
|
|
62
|
-
resultMap[compositeKey] = {
|
|
63
|
-
index: parseInt(index),
|
|
64
|
-
item_id: parseInt(item_id),
|
|
65
|
-
document_id,
|
|
66
|
-
fields: [],
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
if (specialField === "zid") {
|
|
70
|
-
resultMap[compositeKey].zid = value;
|
|
71
|
-
}
|
|
72
|
-
else if (specialField === "reference") {
|
|
73
|
-
resultMap[compositeKey].reference = value;
|
|
74
|
-
}
|
|
75
|
-
continue;
|
|
76
|
-
}
|
|
77
|
-
if (parts.length !== 4)
|
|
78
|
-
continue;
|
|
79
|
-
if (parts.some((part) => isNaN(parseInt(part, 10))))
|
|
80
|
-
continue;
|
|
81
|
-
const [index, item_id, form_id, field_id] = parts.map((part) => parseInt(part, 10));
|
|
82
|
-
const compositeKey = `${index}_${item_id}`;
|
|
83
|
-
if (!resultMap[compositeKey]) {
|
|
84
|
-
resultMap[compositeKey] = {
|
|
85
|
-
index,
|
|
86
|
-
item_id,
|
|
87
|
-
form_id,
|
|
88
|
-
document_id,
|
|
89
|
-
fields: [],
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
resultMap[compositeKey].fields.push({ [field_id]: value });
|
|
93
|
-
resultMap[compositeKey].form_id = form_id;
|
|
94
|
-
}
|
|
95
|
-
return Object.values(resultMap);
|
|
96
|
-
}
|
|
97
|
-
exports.transformResultadosFormData = transformResultadosFormData;
|
|
98
|
-
/**
|
|
99
|
-
*
|
|
100
|
-
* @param data
|
|
101
|
-
* @returns
|
|
102
|
-
*/
|
|
103
|
-
const createRespuestaFormSubmission = (headers, data) => {
|
|
104
|
-
return (0, common_1.handlePossibleAxiosErrors)(async () => {
|
|
105
|
-
const form_submission_values = [];
|
|
106
|
-
for (const value of data.fields) {
|
|
107
|
-
const form_field_id = Object.keys(value)[0];
|
|
108
|
-
const associatedValue = value[form_field_id];
|
|
109
|
-
form_submission_values.push({
|
|
110
|
-
form_field_id,
|
|
111
|
-
value: associatedValue,
|
|
112
|
-
groups_path: "[]",
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
const sendBody = {
|
|
116
|
-
form_id: data.form_id,
|
|
117
|
-
reference: `${data.index}_${data.item_id};${data?.reference}`,
|
|
118
|
-
document_type: "invoice",
|
|
119
|
-
document_id: data.document_id,
|
|
120
|
-
form_submission_values_attributes: (0, common_1.arrayToObject)(form_submission_values),
|
|
121
|
-
zid: data.zid,
|
|
122
|
-
};
|
|
123
|
-
const response = await (0, services_1.createFormSubmission)(headers, sendBody);
|
|
124
|
-
if (response.error) {
|
|
125
|
-
throw new Error(`Ocurrió un error al intentar crear la respuesta de formulario: ${data}`);
|
|
126
|
-
}
|
|
127
|
-
return true;
|
|
128
|
-
});
|
|
129
|
-
};
|
|
130
|
-
exports.createRespuestaFormSubmission = createRespuestaFormSubmission;
|
|
131
|
-
/**
|
|
132
|
-
*
|
|
133
|
-
* @param headers
|
|
134
|
-
* @param session
|
|
135
|
-
* @returns
|
|
136
|
-
*/
|
|
137
|
-
const getLastMuestra = (headers, session) => {
|
|
138
|
-
return (0, common_1.handlePossibleAxiosErrors)(async () => {
|
|
139
|
-
const { lab_muestras_form_zid } = await (0, services_1.getVariablesByName)(headers, session, ["lab_muestras_form_zid"]);
|
|
140
|
-
const response = await (0, services_1.getLastInvoiceFormSubmission)(session, {
|
|
141
|
-
formZid: Number(lab_muestras_form_zid),
|
|
142
|
-
});
|
|
143
|
-
if (response.error || !response.data) {
|
|
144
|
-
throw new Error(`Ocurrió un error al intentar obtener la última muestra registrada: ${response.userMsg}`);
|
|
145
|
-
}
|
|
146
|
-
return response.data;
|
|
147
|
-
});
|
|
148
|
-
};
|
|
149
|
-
exports.getLastMuestra = getLastMuestra;
|
|
150
|
-
const getMuestrasByInvoiceId = (headers, session, invoice_id) => {
|
|
151
|
-
return (0, common_1.handlePossibleAxiosErrors)(async () => {
|
|
152
|
-
const { lab_muestras_form_zid } = await (0, services_1.getVariablesByName)(headers, session, ["lab_muestras_form_zid"]);
|
|
153
|
-
const response = await (0, services_1.getInvoiceFormSubmissionsByInvoiceId)(session, invoice_id, { formZid: Number(lab_muestras_form_zid) });
|
|
154
|
-
if (response.error || !response.data) {
|
|
155
|
-
throw new Error(`Ocurrió un error al intentar obtener las muestras de la remisión: ${response.userMsg}`);
|
|
156
|
-
}
|
|
157
|
-
return response.data;
|
|
158
|
-
});
|
|
159
|
-
};
|
|
160
|
-
exports.getMuestrasByInvoiceId = getMuestrasByInvoiceId;
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.makeInvoiceDetailsWithPrice = exports.createNewLabInvoiceOrder = exports.getInvoicesByLabAgency = void 0;
|
|
4
|
-
const common_1 = require("@zauru-sdk/common");
|
|
5
|
-
const services_1 = require("@zauru-sdk/services");
|
|
6
|
-
/**
|
|
7
|
-
*
|
|
8
|
-
* @param headers
|
|
9
|
-
* @param session
|
|
10
|
-
* @returns
|
|
11
|
-
*/
|
|
12
|
-
const getInvoicesByLabAgency = async (headers, session) => {
|
|
13
|
-
return (0, common_1.handlePossibleAxiosErrors)(async () => {
|
|
14
|
-
const { lab_agency_id } = await (0, services_1.getVariablesByName)(headers, session, [
|
|
15
|
-
"lab_agency_id",
|
|
16
|
-
]);
|
|
17
|
-
const response = await (0, services_1.getInvoicesByAgencyId)(session, lab_agency_id);
|
|
18
|
-
if (response.error) {
|
|
19
|
-
const msg = `Ocurrió un error al consultar las órdenes/facturas por agencia de laboratorio: ${response.userMsg}`;
|
|
20
|
-
console.error(msg);
|
|
21
|
-
throw new Error(msg);
|
|
22
|
-
}
|
|
23
|
-
return response?.data ?? [];
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
exports.getInvoicesByLabAgency = getInvoicesByLabAgency;
|
|
27
|
-
/**
|
|
28
|
-
* createNewLabInvoiceOrder
|
|
29
|
-
* @param headers
|
|
30
|
-
* @param session
|
|
31
|
-
* @returns
|
|
32
|
-
*/
|
|
33
|
-
const createNewLabInvoiceOrder = async (headers, session, body) => {
|
|
34
|
-
return (0, common_1.handlePossibleAxiosErrors)(async () => {
|
|
35
|
-
const { lab_agency_id, laboratory_proyect_id } = await (0, services_1.getVariablesByName)(headers, session, ["lab_agency_id", "laboratory_proyect_id"]);
|
|
36
|
-
const sendBody = {
|
|
37
|
-
...body,
|
|
38
|
-
agency_id: Number(lab_agency_id),
|
|
39
|
-
tagging_invoices: [
|
|
40
|
-
{ tag_id: Number(laboratory_proyect_id), id: 0, invoice_id: 0 },
|
|
41
|
-
],
|
|
42
|
-
};
|
|
43
|
-
const bundleResponse = await (0, services_1.createInvoiceOrder)(headers, sendBody);
|
|
44
|
-
if (bundleResponse.error) {
|
|
45
|
-
const msg = `Ocurrió un error al intentar crear (invoice-order): ${bundleResponse.userMsg}`;
|
|
46
|
-
console.error(msg);
|
|
47
|
-
throw new Error(msg);
|
|
48
|
-
}
|
|
49
|
-
return true;
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
exports.createNewLabInvoiceOrder = createNewLabInvoiceOrder;
|
|
53
|
-
/**
|
|
54
|
-
* makeInvoiceDetailsWithPrice
|
|
55
|
-
* @param invoice_details
|
|
56
|
-
* @returns
|
|
57
|
-
*/
|
|
58
|
-
const makeInvoiceDetailsWithPrice = (invoice_details, deleted_invoice_details = []) => {
|
|
59
|
-
return [
|
|
60
|
-
...invoice_details.map((x) => {
|
|
61
|
-
//Si trae una B al inicio, es un bundleID, de lo contrario, es un item_id
|
|
62
|
-
const bundle_id = x.item_id?.toString()?.startsWith("B")
|
|
63
|
-
? Number(x.item_id.replace("B", ""))
|
|
64
|
-
: undefined;
|
|
65
|
-
const item_id = !bundle_id ? Number(x.item_id) : undefined;
|
|
66
|
-
const id = isNaN(x.id) ? undefined : x.id;
|
|
67
|
-
return {
|
|
68
|
-
id,
|
|
69
|
-
bundle_id,
|
|
70
|
-
item_id,
|
|
71
|
-
quantity: Number(x.quantity),
|
|
72
|
-
//unit_price: Number(x.price),
|
|
73
|
-
//price: Number(x.total),
|
|
74
|
-
_destroy: false,
|
|
75
|
-
};
|
|
76
|
-
}),
|
|
77
|
-
...deleted_invoice_details.map((x) => {
|
|
78
|
-
return {
|
|
79
|
-
id: x.id,
|
|
80
|
-
_destroy: true,
|
|
81
|
-
};
|
|
82
|
-
}),
|
|
83
|
-
];
|
|
84
|
-
};
|
|
85
|
-
exports.makeInvoiceDetailsWithPrice = makeInvoiceDetailsWithPrice;
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createNewLaboratoryItem = exports.createNewLaboratoryItemCategory = exports.getLabItemCategories = exports.getItemServicesByLabCategory = exports.getItemsByLabCategory = exports.getItemsByReceptionCategory = void 0;
|
|
4
|
-
const common_1 = require("@zauru-sdk/common");
|
|
5
|
-
const services_1 = require("@zauru-sdk/services");
|
|
6
|
-
/**
|
|
7
|
-
*
|
|
8
|
-
* @param headers
|
|
9
|
-
* @param session
|
|
10
|
-
* @returns
|
|
11
|
-
*/
|
|
12
|
-
const getItemsByReceptionCategory = async (headers, session) => {
|
|
13
|
-
return (0, common_1.handlePossibleAxiosErrors)(async () => {
|
|
14
|
-
const { recepciones_item_category_id } = await (0, services_1.getVariablesByName)(headers, session, ["recepciones_item_category_id"]);
|
|
15
|
-
const response = await (0, services_1.getItemsByCategoryId)(session, recepciones_item_category_id);
|
|
16
|
-
if (response.error) {
|
|
17
|
-
throw new Error(`Ocurrió un error al consultar los items por categoría de recepción: ${response.userMsg}`);
|
|
18
|
-
}
|
|
19
|
-
return response?.data ?? [];
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
exports.getItemsByReceptionCategory = getItemsByReceptionCategory;
|
|
23
|
-
/**
|
|
24
|
-
*
|
|
25
|
-
* @param headers
|
|
26
|
-
* @param session
|
|
27
|
-
* @returns
|
|
28
|
-
*/
|
|
29
|
-
const getItemsByLabCategory = async (headers, session) => {
|
|
30
|
-
return (0, common_1.handlePossibleAxiosErrors)(async () => {
|
|
31
|
-
const { lab_super_category_item_id, lab_agency_id } = await (0, services_1.getVariablesByName)(headers, session, [
|
|
32
|
-
"lab_super_category_item_id",
|
|
33
|
-
"lab_agency_id",
|
|
34
|
-
]);
|
|
35
|
-
const response = await (0, services_1.getItemsBySuperCategoryId)(session, lab_super_category_item_id, lab_agency_id);
|
|
36
|
-
if (response.error) {
|
|
37
|
-
throw new Error(`Ocurrió un error al consultar los items por categoría de laboratorio: ${response.userMsg}`);
|
|
38
|
-
}
|
|
39
|
-
return response?.data ?? [];
|
|
40
|
-
});
|
|
41
|
-
};
|
|
42
|
-
exports.getItemsByLabCategory = getItemsByLabCategory;
|
|
43
|
-
/**
|
|
44
|
-
*
|
|
45
|
-
* @param headers
|
|
46
|
-
* @param session
|
|
47
|
-
* @returns
|
|
48
|
-
*/
|
|
49
|
-
const getItemServicesByLabCategory = async (headers, session) => {
|
|
50
|
-
return (0, common_1.handlePossibleAxiosErrors)(async () => {
|
|
51
|
-
const { lab_services_item_category_id } = await (0, services_1.getVariablesByName)(headers, session, ["lab_services_item_category_id"]);
|
|
52
|
-
const response = await (0, services_1.getItemsByCategoryId)(session, lab_services_item_category_id);
|
|
53
|
-
if (response.error) {
|
|
54
|
-
throw new Error(`Ocurrió un error al consultar los items-servicios por categoría de laboratorio: ${response.userMsg}`);
|
|
55
|
-
}
|
|
56
|
-
return response?.data ?? [];
|
|
57
|
-
});
|
|
58
|
-
};
|
|
59
|
-
exports.getItemServicesByLabCategory = getItemServicesByLabCategory;
|
|
60
|
-
/**
|
|
61
|
-
* getLabItemCategories
|
|
62
|
-
* @param session
|
|
63
|
-
* @param headers
|
|
64
|
-
* @returns
|
|
65
|
-
*/
|
|
66
|
-
const getLabItemCategories = (headers, session) => {
|
|
67
|
-
return (0, common_1.handlePossibleAxiosErrors)(async () => {
|
|
68
|
-
const { lab_super_category_item_id } = await (0, services_1.getVariablesByName)(headers, session, ["lab_super_category_item_id"]);
|
|
69
|
-
const response = await (0, services_1.getItemCategoriesBySuperCategoryId)(session, lab_super_category_item_id);
|
|
70
|
-
if (response.error || !response.data) {
|
|
71
|
-
throw new Error(response.userMsg);
|
|
72
|
-
}
|
|
73
|
-
return response.data;
|
|
74
|
-
});
|
|
75
|
-
};
|
|
76
|
-
exports.getLabItemCategories = getLabItemCategories;
|
|
77
|
-
/**
|
|
78
|
-
* createNewLaboratoryClient
|
|
79
|
-
* @param session
|
|
80
|
-
* @param headers
|
|
81
|
-
* @param body
|
|
82
|
-
* @returns
|
|
83
|
-
*/
|
|
84
|
-
const createNewLaboratoryItemCategory = (session, headers, body) => {
|
|
85
|
-
return (0, common_1.handlePossibleAxiosErrors)(async () => {
|
|
86
|
-
const { lab_super_category_item_id } = await (0, services_1.getVariablesByName)(headers, session, ["lab_super_category_item_id"]);
|
|
87
|
-
const sendBody = {
|
|
88
|
-
...body,
|
|
89
|
-
item_super_category_id: Number(lab_super_category_item_id),
|
|
90
|
-
color: "#ff0000",
|
|
91
|
-
};
|
|
92
|
-
const createResponse = await (0, services_1.createItemCategory)(headers, sendBody);
|
|
93
|
-
if (!createResponse.data) {
|
|
94
|
-
throw new Error(`Ocurrió un error al intentar crear el item category: ${createResponse.userMsg}`);
|
|
95
|
-
}
|
|
96
|
-
return true;
|
|
97
|
-
});
|
|
98
|
-
};
|
|
99
|
-
exports.createNewLaboratoryItemCategory = createNewLaboratoryItemCategory;
|
|
100
|
-
/**
|
|
101
|
-
* createNewLaboratoryItem
|
|
102
|
-
* @param session
|
|
103
|
-
* @param headers
|
|
104
|
-
* @param body
|
|
105
|
-
* @returns
|
|
106
|
-
*/
|
|
107
|
-
const createNewLaboratoryItem = (headers, body) => {
|
|
108
|
-
return (0, common_1.handlePossibleAxiosErrors)(async () => {
|
|
109
|
-
const sendBody = {
|
|
110
|
-
active: true,
|
|
111
|
-
sellable: true,
|
|
112
|
-
quotable: true,
|
|
113
|
-
ecommerce: false,
|
|
114
|
-
purchasable: true,
|
|
115
|
-
weight: 0,
|
|
116
|
-
color: "#cccccc",
|
|
117
|
-
...body,
|
|
118
|
-
};
|
|
119
|
-
const createResponse = await (0, services_1.createItem)(headers, sendBody);
|
|
120
|
-
if (!createResponse.data || createResponse.error) {
|
|
121
|
-
throw new Error(`Ocurrió un error al intentar crear el item: ${createResponse.userMsg}`);
|
|
122
|
-
}
|
|
123
|
-
return createResponse.data;
|
|
124
|
-
});
|
|
125
|
-
};
|
|
126
|
-
exports.createNewLaboratoryItem = createNewLaboratoryItem;
|