@zauru-sdk/utils 1.0.49 → 1.0.52

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 (78) hide show
  1. package/dist/cjs/index.js +40 -0
  2. package/dist/cjs/zauru/4pinos-receptions-form-history.utils.js +80 -0
  3. package/dist/cjs/zauru/automatic-number.utils.js +28 -0
  4. package/dist/cjs/zauru/bitacora-edicion-masiva.utils.js +56 -0
  5. package/dist/cjs/zauru/bundles.utils.js +168 -0
  6. package/dist/cjs/zauru/cases.utils.js +21 -0
  7. package/dist/cjs/zauru/consolidated-history.utils.js +58 -0
  8. package/dist/cjs/zauru/costos-items.utils.js +617 -0
  9. package/dist/cjs/zauru/deliveries.utils.js +50 -0
  10. package/dist/cjs/zauru/discharges-histsory.utils.js +52 -0
  11. package/dist/cjs/zauru/employees.utils.js +44 -0
  12. package/dist/cjs/zauru/form.utils.js +160 -0
  13. package/dist/cjs/zauru/invoices.utils.js +85 -0
  14. package/dist/cjs/zauru/items.utils.js +126 -0
  15. package/dist/cjs/zauru/lotes.utils.js +313 -0
  16. package/dist/cjs/zauru/motivos-rechazo.utils.js +23 -0
  17. package/dist/cjs/zauru/payees.utils.js +136 -0
  18. package/dist/cjs/zauru/profiles.utils.js +41 -0
  19. package/dist/cjs/zauru/providers.utils.js +40 -0
  20. package/dist/cjs/zauru/purchase-orders.utils.js +390 -0
  21. package/dist/cjs/zauru/shipments.utils.js +95 -0
  22. package/dist/cjs/zauru/specialItem.utils.js +69 -0
  23. package/dist/cjs/zauru/templates.utils.js +102 -0
  24. package/dist/cjs/zauru/tiposMuestra.utils.js +69 -0
  25. package/dist/cjs/zauru/webapp-tables.utils.js +20 -0
  26. package/package.json +13 -10
  27. package/CHANGELOG.md +0 -248
  28. package/src/index.ts +0 -24
  29. package/src/zauru/4pinos-receptions-form-history.utils.ts +0 -142
  30. package/src/zauru/automatic-number.utils.ts +0 -38
  31. package/src/zauru/bitacora-edicion-masiva.utils.ts +0 -99
  32. package/src/zauru/bundles.utils.ts +0 -251
  33. package/src/zauru/cases.utils.ts +0 -31
  34. package/src/zauru/consolidated-history.utils.ts +0 -102
  35. package/src/zauru/costos-items.utils.ts +0 -871
  36. package/src/zauru/deliveries.utils.ts +0 -77
  37. package/src/zauru/discharges-histsory.utils.ts +0 -105
  38. package/src/zauru/employees.utils.ts +0 -59
  39. package/src/zauru/form.utils.ts +0 -243
  40. package/src/zauru/invoices.utils.ts +0 -114
  41. package/src/zauru/items.utils.ts +0 -221
  42. package/src/zauru/lotes.utils.ts +0 -411
  43. package/src/zauru/motivos-rechazo.utils.ts +0 -47
  44. package/src/zauru/payees.utils.ts +0 -213
  45. package/src/zauru/profiles.utils.ts +0 -44
  46. package/src/zauru/providers.utils.ts +0 -67
  47. package/src/zauru/purchase-orders.utils.ts +0 -594
  48. package/src/zauru/shipments.utils.ts +0 -139
  49. package/src/zauru/specialItem.utils.ts +0 -136
  50. package/src/zauru/templates.utils.ts +0 -199
  51. package/src/zauru/tiposMuestra.utils.ts +0 -136
  52. package/src/zauru/webapp-tables.utils.ts +0 -36
  53. package/tsconfig.json +0 -24
  54. /package/dist/{index.js → esm/index.js} +0 -0
  55. /package/dist/{zauru → esm/zauru}/4pinos-receptions-form-history.utils.js +0 -0
  56. /package/dist/{zauru → esm/zauru}/automatic-number.utils.js +0 -0
  57. /package/dist/{zauru → esm/zauru}/bitacora-edicion-masiva.utils.js +0 -0
  58. /package/dist/{zauru → esm/zauru}/bundles.utils.js +0 -0
  59. /package/dist/{zauru → esm/zauru}/cases.utils.js +0 -0
  60. /package/dist/{zauru → esm/zauru}/consolidated-history.utils.js +0 -0
  61. /package/dist/{zauru → esm/zauru}/costos-items.utils.js +0 -0
  62. /package/dist/{zauru → esm/zauru}/deliveries.utils.js +0 -0
  63. /package/dist/{zauru → esm/zauru}/discharges-histsory.utils.js +0 -0
  64. /package/dist/{zauru → esm/zauru}/employees.utils.js +0 -0
  65. /package/dist/{zauru → esm/zauru}/form.utils.js +0 -0
  66. /package/dist/{zauru → esm/zauru}/invoices.utils.js +0 -0
  67. /package/dist/{zauru → esm/zauru}/items.utils.js +0 -0
  68. /package/dist/{zauru → esm/zauru}/lotes.utils.js +0 -0
  69. /package/dist/{zauru → esm/zauru}/motivos-rechazo.utils.js +0 -0
  70. /package/dist/{zauru → esm/zauru}/payees.utils.js +0 -0
  71. /package/dist/{zauru → esm/zauru}/profiles.utils.js +0 -0
  72. /package/dist/{zauru → esm/zauru}/providers.utils.js +0 -0
  73. /package/dist/{zauru → esm/zauru}/purchase-orders.utils.js +0 -0
  74. /package/dist/{zauru → esm/zauru}/shipments.utils.js +0 -0
  75. /package/dist/{zauru → esm/zauru}/specialItem.utils.js +0 -0
  76. /package/dist/{zauru → esm/zauru}/templates.utils.js +0 -0
  77. /package/dist/{zauru → esm/zauru}/tiposMuestra.utils.js +0 -0
  78. /package/dist/{zauru → esm/zauru}/webapp-tables.utils.js +0 -0
@@ -0,0 +1,52 @@
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;
@@ -0,0 +1,44 @@
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;
@@ -0,0 +1,160 @@
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;
@@ -0,0 +1,85 @@
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?.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;
@@ -0,0 +1,126 @@
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;