@zauru-sdk/services 2.0.113 → 2.0.115
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.
|
@@ -228,7 +228,7 @@ export async function getLastInvoiceFormSubmission(session, filters = {}) {
|
|
|
228
228
|
/**
|
|
229
229
|
* getInvoiceFormSubmissionsByInvoiceId
|
|
230
230
|
*/
|
|
231
|
-
export async function getInvoiceFormSubmissionsByInvoiceId(session, invoice_id, filters = {}) {
|
|
231
|
+
export async function getInvoiceFormSubmissionsByInvoiceId(headersZauru, session, invoice_id, withFiles = false, filters = {}) {
|
|
232
232
|
return handlePossibleAxiosErrors(async () => {
|
|
233
233
|
const headers = await getGraphQLAPIHeaders(session);
|
|
234
234
|
const response = await httpGraphQLAPI.post("", {
|
|
@@ -239,7 +239,32 @@ export async function getInvoiceFormSubmissionsByInvoiceId(session, invoice_id,
|
|
|
239
239
|
if (response.data.errors) {
|
|
240
240
|
throw new Error(response.data.errors.map((x) => x.message).join(";"));
|
|
241
241
|
}
|
|
242
|
-
|
|
242
|
+
let registers = response?.data?.data?.submission_invoices;
|
|
243
|
+
if (withFiles) {
|
|
244
|
+
registers = await Promise.all(registers.map(async (register) => {
|
|
245
|
+
try {
|
|
246
|
+
const responseZauru = await httpZauru.get(`/settings/forms/form_submissions/${register.settings_form_submission.id}.json`, {
|
|
247
|
+
headers: headersZauru,
|
|
248
|
+
});
|
|
249
|
+
register.settings_form_submission.settings_form_submission_values =
|
|
250
|
+
register.settings_form_submission.settings_form_submission_values.map((x) => {
|
|
251
|
+
if (x.settings_form_field.field_type === "image" ||
|
|
252
|
+
x.settings_form_field.field_type === "file" ||
|
|
253
|
+
x.settings_form_field.field_type === "pdf") {
|
|
254
|
+
x.value = responseZauru.data[x.settings_form_field.print_var_name]
|
|
255
|
+
?.toString()
|
|
256
|
+
.replace(/\\u0026/g, "&");
|
|
257
|
+
}
|
|
258
|
+
return x;
|
|
259
|
+
});
|
|
260
|
+
return register;
|
|
261
|
+
}
|
|
262
|
+
catch (error) {
|
|
263
|
+
console.error(`Error al obtener el archivo del formulario ${register.settings_form_submission.id}`, error);
|
|
264
|
+
return register;
|
|
265
|
+
}
|
|
266
|
+
}));
|
|
267
|
+
}
|
|
243
268
|
// Filtrar los registros para obtener sólo los de la versión más alta.
|
|
244
269
|
const groupedByVersion = registers.reduce((acc, record) => {
|
|
245
270
|
const zid = record.settings_form_submission.zid;
|
|
@@ -60,7 +60,7 @@ export declare function getLastInvoiceFormSubmission(session: Session, filters?:
|
|
|
60
60
|
/**
|
|
61
61
|
* getInvoiceFormSubmissionsByInvoiceId
|
|
62
62
|
*/
|
|
63
|
-
export declare function getInvoiceFormSubmissionsByInvoiceId(session: Session, invoice_id: string, filters?: {
|
|
63
|
+
export declare function getInvoiceFormSubmissionsByInvoiceId(headersZauru: any, session: Session, invoice_id: string, withFiles?: boolean, filters?: {
|
|
64
64
|
formZid?: number;
|
|
65
65
|
}): Promise<AxiosUtilsResponse<SubmissionInvoicesGraphQL[]>>;
|
|
66
66
|
export declare const getFormSubmissionAPIZauru: (headers: any, id: number | string) => Promise<AxiosUtilsResponse<any>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zauru-sdk/services",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.115",
|
|
4
4
|
"description": "Servicios de consulta a Zauru",
|
|
5
5
|
"main": "./dist/esm/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"axios": "^1.6.7",
|
|
32
32
|
"chalk": "5.3.0"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "fe1283bd81104c388ac747ce55c6b6935bd850e3"
|
|
35
35
|
}
|