@zauru-sdk/services 1.0.6 → 1.0.7
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/CHANGELOG.md +8 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +20 -0
- package/dist/zauru/zauru-currencies.server.d.ts +6 -0
- package/dist/zauru/zauru-currencies.server.js +20 -0
- package/dist/zauru/zauru-deliveries.server.d.ts +22 -0
- package/dist/zauru/zauru-deliveries.server.js +44 -0
- package/dist/zauru/zauru-discharges.server.d.ts +26 -0
- package/dist/zauru/zauru-discharges.server.js +46 -0
- package/dist/zauru/zauru-employees.server.d.ts +6 -0
- package/dist/zauru/zauru-employees.server.js +23 -0
- package/dist/zauru/zauru-forms.server.d.ts +96 -0
- package/dist/zauru/zauru-forms.server.js +343 -0
- package/dist/zauru/zauru-invoices.server.d.ts +26 -0
- package/dist/zauru/zauru-invoices.server.js +94 -0
- package/dist/zauru/zauru-items.server.d.ts +91 -0
- package/dist/zauru/zauru-items.server.js +238 -0
- package/dist/zauru/zauru-lote-record.server.d.ts +8 -0
- package/dist/zauru/zauru-lote-record.server.js +26 -0
- package/dist/zauru/zauru-lotes.server.d.ts +91 -0
- package/dist/zauru/zauru-lotes.server.js +294 -0
- package/dist/zauru/zauru-motivos-rechazo.server.d.ts +9 -0
- package/dist/zauru/zauru-motivos-rechazo.server.js +49 -0
- package/dist/zauru/zauru-payees.server.d.ts +97 -0
- package/dist/zauru/zauru-payees.server.js +227 -0
- package/dist/zauru/zauru-payment-terms.server.d.ts +20 -0
- package/dist/zauru/zauru-payment-terms.server.js +65 -0
- package/dist/zauru/zauru-price-lists.server.d.ts +22 -0
- package/dist/zauru/zauru-price-lists.server.js +40 -0
- package/dist/zauru/zauru-purchase-orders.server.d.ts +160 -0
- package/dist/zauru/zauru-purchase-orders.server.js +414 -0
- package/dist/zauru/zauru-receptions.server.d.ts +33 -0
- package/dist/zauru/zauru-receptions.server.js +94 -0
- package/dist/zauru/zauru-shipments.server.d.ts +20 -0
- package/dist/zauru/zauru-shipments.server.js +53 -0
- package/dist/zauru/zauru-suggested-prices.server.d.ts +30 -0
- package/dist/zauru/zauru-suggested-prices.server.js +83 -0
- package/dist/zauru/zauru-tags.server.d.ts +7 -0
- package/dist/zauru/zauru-tags.server.js +13 -0
- package/dist/zauru/zauru-templates.server.d.ts +7 -0
- package/dist/zauru/zauru-templates.server.js +15 -0
- package/dist/zauru/zauru-web-app-tables.server.d.ts +48 -0
- package/dist/zauru/zauru-web-app-tables.server.js +120 -0
- package/package.json +6 -6
- package/src/index.ts +20 -0
- package/src/zauru/zauru-currencies.server.ts +39 -0
- package/src/zauru/zauru-deliveries.server.ts +70 -0
- package/src/zauru/zauru-discharges.server.ts +90 -0
- package/src/zauru/zauru-employees.server.ts +43 -0
- package/src/zauru/zauru-forms.server.ts +618 -0
- package/src/zauru/zauru-invoices.server.ts +142 -0
- package/src/zauru/zauru-items.server.ts +427 -0
- package/src/zauru/zauru-lote-record.server.ts +77 -0
- package/src/zauru/zauru-lotes.server.ts +484 -0
- package/src/zauru/zauru-motivos-rechazo.server.ts +121 -0
- package/src/zauru/zauru-payees.server.ts +398 -0
- package/src/zauru/zauru-payment-terms.server.ts +126 -0
- package/src/zauru/zauru-price-lists.server.ts +68 -0
- package/src/zauru/zauru-purchase-orders.server.ts +701 -0
- package/src/zauru/zauru-receptions.server.ts +148 -0
- package/src/zauru/zauru-shipments.server.ts +88 -0
- package/src/zauru/zauru-suggested-prices.server.ts +134 -0
- package/src/zauru/zauru-tags.server.ts +22 -0
- package/src/zauru/zauru-templates.server.ts +24 -0
- package/src/zauru/zauru-web-app-tables.server.ts +200 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { handlePossibleAxiosErrors } from "@zauru-sdk/common";
|
|
2
|
+
import httpZauru from "./httpZauru.server.js";
|
|
3
|
+
import { getGraphQLAPIHeaders } from "~/common.server.js";
|
|
4
|
+
import httpGraphQLAPI from "./httpGraphQL.server.js";
|
|
5
|
+
import { getSuggestedPricesStringQuery } from "@zauru-sdk/graphql";
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* @param headers
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
export const getSuggestedPricesExportJSON = async (headers) => {
|
|
12
|
+
return handlePossibleAxiosErrors(async () => {
|
|
13
|
+
const response = await httpZauru.get(`/sales/suggested_prices/export.json`, {
|
|
14
|
+
headers,
|
|
15
|
+
});
|
|
16
|
+
return response.data;
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* getSuggestedPrices
|
|
21
|
+
* @param session
|
|
22
|
+
* @param id
|
|
23
|
+
*/
|
|
24
|
+
export async function getSuggestedPrices(session, config) {
|
|
25
|
+
return handlePossibleAxiosErrors(async () => {
|
|
26
|
+
const { notNullPriceList = false, withItems = false, withItemCategories = false, } = config;
|
|
27
|
+
const headers = await getGraphQLAPIHeaders(session);
|
|
28
|
+
const response = await httpGraphQLAPI.post("", {
|
|
29
|
+
query: getSuggestedPricesStringQuery({
|
|
30
|
+
notNullPriceList,
|
|
31
|
+
withItems,
|
|
32
|
+
withItemCategories,
|
|
33
|
+
}),
|
|
34
|
+
}, { headers });
|
|
35
|
+
if (response.data.errors) {
|
|
36
|
+
throw new Error(response.data.errors.map((x) => x.message).join(";"));
|
|
37
|
+
}
|
|
38
|
+
return response?.data?.data?.suggested_prices ?? [];
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* createSuggestedPrice
|
|
43
|
+
* @param headers
|
|
44
|
+
* @param body
|
|
45
|
+
*/
|
|
46
|
+
export async function createSuggestedPrice(headers, body) {
|
|
47
|
+
return handlePossibleAxiosErrors(async () => {
|
|
48
|
+
const response = await httpZauru.post(`/sales/suggested_prices.json`, { suggested_price: body }, { headers });
|
|
49
|
+
return response.data;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
//No existe actualizar
|
|
53
|
+
// /**
|
|
54
|
+
// * updateSuggestedPrice
|
|
55
|
+
// * @param headers
|
|
56
|
+
// * @param body
|
|
57
|
+
// */
|
|
58
|
+
// export async function updateSuggestedPrice(
|
|
59
|
+
// headers: any,
|
|
60
|
+
// body: Partial<SuggestedPriceGraphQL>
|
|
61
|
+
// ): Promise<AxiosUtilsResponse<SuggestedPriceGraphQL>> {
|
|
62
|
+
// return handlePossibleAxiosErrors(async () => {
|
|
63
|
+
// const response = await httpZauru.patch<SuggestedPriceGraphQL>(
|
|
64
|
+
// `/sales/suggested_prices.json`,
|
|
65
|
+
// { suggested_price: body },
|
|
66
|
+
// { headers }
|
|
67
|
+
// );
|
|
68
|
+
// return response.data;
|
|
69
|
+
// });
|
|
70
|
+
// }
|
|
71
|
+
/**
|
|
72
|
+
* deleteSuggestedPrice
|
|
73
|
+
* @param headers
|
|
74
|
+
* @param body
|
|
75
|
+
*/
|
|
76
|
+
export async function deleteSuggestedPrice(headers, id) {
|
|
77
|
+
return handlePossibleAxiosErrors(async () => {
|
|
78
|
+
await httpZauru.delete(`/sales/suggested_prices/${id}?destroy=true`, {
|
|
79
|
+
headers,
|
|
80
|
+
});
|
|
81
|
+
return true;
|
|
82
|
+
});
|
|
83
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { handlePossibleAxiosErrors } from "@zauru-sdk/common";
|
|
2
|
+
import httpZauru from "./httpZauru.server.js";
|
|
3
|
+
/**
|
|
4
|
+
* createTag
|
|
5
|
+
* @param headers
|
|
6
|
+
* @param body
|
|
7
|
+
*/
|
|
8
|
+
export async function createTag(headers, body) {
|
|
9
|
+
return handlePossibleAxiosErrors(async () => {
|
|
10
|
+
const response = await httpZauru.post(`/settings/tags.json`, { tag: body }, { headers });
|
|
11
|
+
return response.data;
|
|
12
|
+
});
|
|
13
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { handlePossibleAxiosErrors } from "@zauru-sdk/common";
|
|
2
|
+
import httpZauru from "./httpZauru.server.js";
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param headers
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
export const getReceptionTemplate = async (headers, id) => {
|
|
9
|
+
return handlePossibleAxiosErrors(async () => {
|
|
10
|
+
const response = await httpZauru.get(`/settings/templates/print_templates/${id}/preview_with_vars`, {
|
|
11
|
+
headers,
|
|
12
|
+
});
|
|
13
|
+
return response.data;
|
|
14
|
+
});
|
|
15
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { Session } from "@remix-run/node";
|
|
2
|
+
import { AxiosUtilsResponse, WebAppRowGraphQL, WebAppTableCreateBody, WebAppTableGraphQL, WebAppTableUpdateResponse } from "@zauru-sdk/types";
|
|
3
|
+
/**
|
|
4
|
+
* getWebAppRow
|
|
5
|
+
* @param headers
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
export declare function getWebAppRow<T>(session: Session, id: number): Promise<AxiosUtilsResponse<T>>;
|
|
9
|
+
/**
|
|
10
|
+
* getWebAppTableRegisters Function for get all web app table registers
|
|
11
|
+
* @param headers
|
|
12
|
+
* @param webapp_table_id web app table id
|
|
13
|
+
* @returns
|
|
14
|
+
*/
|
|
15
|
+
export declare function getWebAppTableRegisters<T>(session: Session, webapp_table_id: string): Promise<AxiosUtilsResponse<WebAppRowGraphQL<T>[]>>;
|
|
16
|
+
/**
|
|
17
|
+
* deleteWebAppTableRegister Function for delete a web app table register
|
|
18
|
+
* @param headers
|
|
19
|
+
* @param id_web_app_table
|
|
20
|
+
* @param id_register
|
|
21
|
+
* @returns
|
|
22
|
+
*/
|
|
23
|
+
export declare function deleteWebAppTableRegister(headers: any, id_web_app_table: string, id_register: number): Promise<WebAppTableUpdateResponse>;
|
|
24
|
+
/**
|
|
25
|
+
* createWebAppTableRegister function for create a new web app table register
|
|
26
|
+
* @param headers
|
|
27
|
+
* @param body
|
|
28
|
+
* @param id_web_app_table
|
|
29
|
+
* @returns
|
|
30
|
+
*/
|
|
31
|
+
export declare function createWebAppTableRegister<T>(headers: any, id_web_app_table: string, body: T, extraBody?: {
|
|
32
|
+
temp_purchase_order_id: string;
|
|
33
|
+
}): Promise<WebAppTableUpdateResponse>;
|
|
34
|
+
/**
|
|
35
|
+
* updateWebAppTableRegister Function for update a web app table register
|
|
36
|
+
* @param headers
|
|
37
|
+
* @param id_web_app_table
|
|
38
|
+
* @param id_register
|
|
39
|
+
* @returns
|
|
40
|
+
*/
|
|
41
|
+
export declare function updateWebAppTableRegister<T>(headers: any, id_web_app_table: string, id_register: number | string, body: Partial<T>): Promise<WebAppTableUpdateResponse>;
|
|
42
|
+
/**
|
|
43
|
+
*
|
|
44
|
+
* @param headers
|
|
45
|
+
* @param body
|
|
46
|
+
* @returns
|
|
47
|
+
*/
|
|
48
|
+
export declare function createWebAppTable(headers: any, body: WebAppTableCreateBody): Promise<AxiosUtilsResponse<WebAppTableGraphQL>>;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { handlePossibleAxiosErrors } from "@zauru-sdk/common";
|
|
2
|
+
import { getGraphQLAPIHeaders } from "~/common.server.js";
|
|
3
|
+
import httpGraphQLAPI from "./httpGraphQL.server.js";
|
|
4
|
+
import { getWebAppRowStringQuery, getWebAppRowsByWebAppTableIdStringQuery, } from "@zauru-sdk/graphql";
|
|
5
|
+
import httpZauru from "./httpZauru.server.js";
|
|
6
|
+
/**
|
|
7
|
+
* getWebAppRow
|
|
8
|
+
* @param headers
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
export async function getWebAppRow(session, id) {
|
|
12
|
+
return handlePossibleAxiosErrors(async () => {
|
|
13
|
+
const headers = await getGraphQLAPIHeaders(session);
|
|
14
|
+
const response = await httpGraphQLAPI.post("", {
|
|
15
|
+
query: getWebAppRowStringQuery,
|
|
16
|
+
variables: {
|
|
17
|
+
id,
|
|
18
|
+
},
|
|
19
|
+
}, { headers });
|
|
20
|
+
return response.data?.data?.webapp_rows[0]?.data;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* getWebAppTableRegisters Function for get all web app table registers
|
|
25
|
+
* @param headers
|
|
26
|
+
* @param webapp_table_id web app table id
|
|
27
|
+
* @returns
|
|
28
|
+
*/
|
|
29
|
+
export async function getWebAppTableRegisters(session, webapp_table_id) {
|
|
30
|
+
return handlePossibleAxiosErrors(async () => {
|
|
31
|
+
const headers = await getGraphQLAPIHeaders(session);
|
|
32
|
+
const response = await httpGraphQLAPI.post("", {
|
|
33
|
+
query: getWebAppRowsByWebAppTableIdStringQuery,
|
|
34
|
+
variables: {
|
|
35
|
+
webapp_table_id,
|
|
36
|
+
},
|
|
37
|
+
}, { headers });
|
|
38
|
+
if (response.data.errors) {
|
|
39
|
+
throw new Error(response.data.errors.map((x) => x.message).join(";"));
|
|
40
|
+
}
|
|
41
|
+
if (!response?.data?.data.webapp_rows) {
|
|
42
|
+
return [];
|
|
43
|
+
}
|
|
44
|
+
return response.data?.data?.webapp_rows;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* deleteWebAppTableRegister Function for delete a web app table register
|
|
49
|
+
* @param headers
|
|
50
|
+
* @param id_web_app_table
|
|
51
|
+
* @param id_register
|
|
52
|
+
* @returns
|
|
53
|
+
*/
|
|
54
|
+
export async function deleteWebAppTableRegister(headers, id_web_app_table, id_register) {
|
|
55
|
+
const response = await httpZauru(`/apps/webapp_tables/${id_web_app_table}/webapp_rows/${id_register}.json`, {
|
|
56
|
+
method: "DELETE",
|
|
57
|
+
headers: headers,
|
|
58
|
+
});
|
|
59
|
+
return response.data;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* createWebAppTableRegister function for create a new web app table register
|
|
63
|
+
* @param headers
|
|
64
|
+
* @param body
|
|
65
|
+
* @param id_web_app_table
|
|
66
|
+
* @returns
|
|
67
|
+
*/
|
|
68
|
+
export async function createWebAppTableRegister(headers, id_web_app_table, body, extraBody) {
|
|
69
|
+
const requestBody = {
|
|
70
|
+
webapp_row: { data: body },
|
|
71
|
+
...(extraBody ?? {}),
|
|
72
|
+
};
|
|
73
|
+
const response = await httpZauru(`/apps/webapp_tables/${id_web_app_table}/webapp_rows.json`, {
|
|
74
|
+
method: "POST",
|
|
75
|
+
headers: headers,
|
|
76
|
+
data: requestBody,
|
|
77
|
+
});
|
|
78
|
+
return response.data;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* updateWebAppTableRegister Function for update a web app table register
|
|
82
|
+
* @param headers
|
|
83
|
+
* @param id_web_app_table
|
|
84
|
+
* @param id_register
|
|
85
|
+
* @returns
|
|
86
|
+
*/
|
|
87
|
+
export async function updateWebAppTableRegister(headers, id_web_app_table, id_register, body) {
|
|
88
|
+
const requestBody = { webapp_row: { data: body } };
|
|
89
|
+
const response = await httpZauru(`/apps/webapp_tables/${id_web_app_table}/webapp_rows/${id_register}.json`, {
|
|
90
|
+
method: "PATCH",
|
|
91
|
+
headers: headers,
|
|
92
|
+
data: requestBody,
|
|
93
|
+
});
|
|
94
|
+
return response.data;
|
|
95
|
+
}
|
|
96
|
+
//============================== WEB APP TABLE
|
|
97
|
+
/**
|
|
98
|
+
*
|
|
99
|
+
* @param headers
|
|
100
|
+
* @param body
|
|
101
|
+
* @returns
|
|
102
|
+
*/
|
|
103
|
+
export async function createWebAppTable(headers, body) {
|
|
104
|
+
try {
|
|
105
|
+
const response = await httpZauru.post(`/apps/webapp_tables.json`, { webapp_table: body }, {
|
|
106
|
+
headers,
|
|
107
|
+
});
|
|
108
|
+
return {
|
|
109
|
+
data: response.data,
|
|
110
|
+
error: false,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
return {
|
|
115
|
+
msg: error,
|
|
116
|
+
error: true,
|
|
117
|
+
userMsg: `Ocurrió un error al intentar crear la web app table ${body.name}`,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zauru-sdk/services",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.7",
|
|
4
|
+
"description": "Servicios de consulta a Zauru",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"type": "module",
|
|
@@ -19,15 +19,15 @@
|
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@remix-run/node": "^2.8.1",
|
|
22
|
-
"@zauru-sdk/common": "^1.0.
|
|
22
|
+
"@zauru-sdk/common": "^1.0.7",
|
|
23
23
|
"@zauru-sdk/config": "^1.0.4",
|
|
24
|
-
"@zauru-sdk/graphql": "^1.0.
|
|
25
|
-
"@zauru-sdk/types": "^1.0.
|
|
24
|
+
"@zauru-sdk/graphql": "^1.0.7",
|
|
25
|
+
"@zauru-sdk/types": "^1.0.7",
|
|
26
26
|
"axios": "^1.6.7",
|
|
27
27
|
"chalk": "5.3.0"
|
|
28
28
|
},
|
|
29
29
|
"engines": {
|
|
30
30
|
"node": ">=18.0.0"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "8078893206a171382f3783914ceec8959cdda945"
|
|
33
33
|
}
|
package/src/index.ts
CHANGED
|
@@ -9,5 +9,25 @@ export * from "./zauru/httpZauru.server.js";
|
|
|
9
9
|
|
|
10
10
|
export * from "./zauru/zauru-agencies.server.js";
|
|
11
11
|
export * from "./zauru/zauru-automatic-numbers.server.js";
|
|
12
|
+
export * from "./zauru/zauru-currencies.server.js";
|
|
13
|
+
export * from "./zauru/zauru-deliveries.server.js";
|
|
14
|
+
export * from "./zauru/zauru-discharges.server.js";
|
|
15
|
+
export * from "./zauru/zauru-employees.server.js";
|
|
16
|
+
export * from "./zauru/zauru-forms.server.js";
|
|
17
|
+
export * from "./zauru/zauru-invoices.server.js";
|
|
18
|
+
export * from "./zauru/zauru-items.server.js";
|
|
19
|
+
export * from "./zauru/zauru-lote-record.server.js";
|
|
20
|
+
export * from "./zauru/zauru-lotes.server.js";
|
|
21
|
+
export * from "./zauru/zauru-motivos-rechazo.server.js";
|
|
22
|
+
export * from "./zauru/zauru-payees.server.js";
|
|
23
|
+
export * from "./zauru/zauru-payment-terms.server.js";
|
|
24
|
+
export * from "./zauru/zauru-price-lists.server.js";
|
|
25
|
+
export * from "./zauru/zauru-purchase-orders.server.js";
|
|
12
26
|
export * from "./zauru/zauru-profiles.server.js";
|
|
27
|
+
export * from "./zauru/zauru-receptions.server.js";
|
|
28
|
+
export * from "./zauru/zauru-shipments.server.js";
|
|
29
|
+
export * from "./zauru/zauru-suggested-prices.server.js";
|
|
30
|
+
export * from "./zauru/zauru-tags.server.js";
|
|
31
|
+
export * from "./zauru/zauru-templates.server.js";
|
|
32
|
+
export * from "./zauru/zauru-web-app-tables.server.js";
|
|
13
33
|
export * from "./zauru/zauru-variables.server.js";
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Session } from "@remix-run/node";
|
|
2
|
+
import { handlePossibleAxiosErrors } from "@zauru-sdk/common";
|
|
3
|
+
import { AxiosUtilsResponse, CurrencyGraphQL } from "@zauru-sdk/types";
|
|
4
|
+
import { getGraphQLAPIHeaders } from "~/common.server.js";
|
|
5
|
+
import httpGraphQLAPI from "./httpGraphQL.server.js";
|
|
6
|
+
import { getCurrenciesStringQuery } from "@zauru-sdk/graphql";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* getCurrencies
|
|
10
|
+
*/
|
|
11
|
+
export async function getCurrencies(
|
|
12
|
+
session: Session
|
|
13
|
+
): Promise<AxiosUtilsResponse<CurrencyGraphQL[]>> {
|
|
14
|
+
return handlePossibleAxiosErrors(async () => {
|
|
15
|
+
const headers = await getGraphQLAPIHeaders(session);
|
|
16
|
+
|
|
17
|
+
const response = await httpGraphQLAPI.post<{
|
|
18
|
+
data: { currencies: CurrencyGraphQL[] };
|
|
19
|
+
errors?: {
|
|
20
|
+
message: string;
|
|
21
|
+
extensions: { path: string; code: string };
|
|
22
|
+
}[];
|
|
23
|
+
}>(
|
|
24
|
+
"",
|
|
25
|
+
{
|
|
26
|
+
query: getCurrenciesStringQuery,
|
|
27
|
+
},
|
|
28
|
+
{ headers }
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
if (response.data.errors) {
|
|
32
|
+
throw new Error(response.data.errors.map((x) => x.message).join(";"));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const registers = response?.data?.data?.currencies;
|
|
36
|
+
|
|
37
|
+
return registers;
|
|
38
|
+
});
|
|
39
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { handlePossibleAxiosErrors } from "@zauru-sdk/common";
|
|
2
|
+
import {
|
|
3
|
+
AxiosUtilsResponse,
|
|
4
|
+
DataTablesFilterBody,
|
|
5
|
+
HTMLDataTableDeliveries,
|
|
6
|
+
ShipmentGraphQL,
|
|
7
|
+
} from "@zauru-sdk/types";
|
|
8
|
+
import httpZauru from "./httpZauru.server.js";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* getDelivery
|
|
12
|
+
* @param headers
|
|
13
|
+
* @param body
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
export async function getDelivery(
|
|
17
|
+
headers: any,
|
|
18
|
+
idDelivery: string
|
|
19
|
+
): Promise<AxiosUtilsResponse<ShipmentGraphQL>> {
|
|
20
|
+
return handlePossibleAxiosErrors(async () => {
|
|
21
|
+
const response = await httpZauru.get<ShipmentGraphQL>(
|
|
22
|
+
`/inventories/deliveries/${idDelivery}.json`,
|
|
23
|
+
{
|
|
24
|
+
headers,
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
return response.data;
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* GET DELIVERIES DATA TABLES
|
|
33
|
+
* @param headers
|
|
34
|
+
* @param body
|
|
35
|
+
* @returns
|
|
36
|
+
*/
|
|
37
|
+
export async function getDeliveriesDataTables(
|
|
38
|
+
headers: any,
|
|
39
|
+
body: DataTablesFilterBody
|
|
40
|
+
): Promise<AxiosUtilsResponse<HTMLDataTableDeliveries>> {
|
|
41
|
+
return handlePossibleAxiosErrors(async () => {
|
|
42
|
+
const response = await httpZauru.post<HTMLDataTableDeliveries>(
|
|
43
|
+
`/inventories/deliveries/datatables.json`,
|
|
44
|
+
body,
|
|
45
|
+
{
|
|
46
|
+
headers,
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
return response.data;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* deleteDelivery
|
|
55
|
+
* @param headers
|
|
56
|
+
* @param id
|
|
57
|
+
* @returns
|
|
58
|
+
*/
|
|
59
|
+
export async function deleteDelivery(
|
|
60
|
+
headers: any,
|
|
61
|
+
id: string | number
|
|
62
|
+
): Promise<AxiosUtilsResponse<boolean>> {
|
|
63
|
+
return handlePossibleAxiosErrors(async () => {
|
|
64
|
+
await httpZauru.delete(`/inventories/deliveries/${id}.json?destroy=true`, {
|
|
65
|
+
headers,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
return true;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { Session } from "@remix-run/node";
|
|
2
|
+
import {
|
|
3
|
+
AxiosUtilsResponse,
|
|
4
|
+
GeneratePDFBody,
|
|
5
|
+
NewDischargeBody,
|
|
6
|
+
PDFResult,
|
|
7
|
+
} from "@zauru-sdk/types";
|
|
8
|
+
import { getVariablesByName } from "~/common.server.js";
|
|
9
|
+
import { handlePossibleAxiosErrors } from "@zauru-sdk/common";
|
|
10
|
+
import httpZauru from "./httpZauru.server.js";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @param headers
|
|
15
|
+
* @returns
|
|
16
|
+
*/
|
|
17
|
+
export const createDischarge = async (
|
|
18
|
+
session: Session,
|
|
19
|
+
headers: any,
|
|
20
|
+
body: NewDischargeBody
|
|
21
|
+
): Promise<AxiosUtilsResponse<{ id: number }>> => {
|
|
22
|
+
return handlePossibleAxiosErrors(async () => {
|
|
23
|
+
const { id_check_discharge_method } = await getVariablesByName(
|
|
24
|
+
headers,
|
|
25
|
+
session,
|
|
26
|
+
["id_check_discharge_method"]
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
body.discharge.discharge_method_id = id_check_discharge_method;
|
|
30
|
+
|
|
31
|
+
const response = await httpZauru.post<{ id: number }>(
|
|
32
|
+
`/purchases/discharges.json`,
|
|
33
|
+
body,
|
|
34
|
+
{
|
|
35
|
+
headers,
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
return response.data;
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* generateDischargePDF
|
|
45
|
+
* @param headers
|
|
46
|
+
* @param body
|
|
47
|
+
*/
|
|
48
|
+
export const generateDischargePDF = async (
|
|
49
|
+
headers: any,
|
|
50
|
+
session: Session,
|
|
51
|
+
body: GeneratePDFBody
|
|
52
|
+
): Promise<AxiosUtilsResponse<{ status: number; zid: number }>> => {
|
|
53
|
+
return handlePossibleAxiosErrors(async () => {
|
|
54
|
+
const { consolidated_template_id } = await getVariablesByName(
|
|
55
|
+
headers,
|
|
56
|
+
session,
|
|
57
|
+
["consolidated_template_id"]
|
|
58
|
+
);
|
|
59
|
+
body.print_template = consolidated_template_id;
|
|
60
|
+
const response = await httpZauru.post<{ status: number; zid: number }>(
|
|
61
|
+
"/purchases/consolidates/gen_print_all.json",
|
|
62
|
+
body,
|
|
63
|
+
{ headers }
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
return response.data;
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* getDischargePDFResult
|
|
72
|
+
* @param headers
|
|
73
|
+
* @param zid
|
|
74
|
+
* @returns
|
|
75
|
+
*/
|
|
76
|
+
export const getDischargePDFResult = async (
|
|
77
|
+
headers: any,
|
|
78
|
+
zid: number | string
|
|
79
|
+
): Promise<AxiosUtilsResponse<PDFResult>> => {
|
|
80
|
+
return handlePossibleAxiosErrors(async () => {
|
|
81
|
+
const response = await httpZauru.get<PDFResult>(
|
|
82
|
+
"purchases/consolidates/check_print_all",
|
|
83
|
+
{
|
|
84
|
+
headers,
|
|
85
|
+
params: { zid },
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
return response.data;
|
|
89
|
+
});
|
|
90
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { Session } from "@remix-run/node";
|
|
2
|
+
import { handlePossibleAxiosErrors } from "@zauru-sdk/common";
|
|
3
|
+
import { AxiosUtilsResponse, EmployeeGraphQL } from "@zauru-sdk/types";
|
|
4
|
+
import { getGraphQLAPIHeaders } from "~/common.server.js";
|
|
5
|
+
import httpGraphQLAPI from "./httpGraphQL.server.js";
|
|
6
|
+
import { getEmployeesByAgencyIdStringQuery } from "@zauru-sdk/graphql";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* getEmployeesByAgencyId
|
|
10
|
+
*/
|
|
11
|
+
export async function getEmployeesByAgencyId(
|
|
12
|
+
session: Session,
|
|
13
|
+
id: number | string
|
|
14
|
+
): Promise<AxiosUtilsResponse<EmployeeGraphQL[]>> {
|
|
15
|
+
return handlePossibleAxiosErrors(async () => {
|
|
16
|
+
const headers = await getGraphQLAPIHeaders(session);
|
|
17
|
+
|
|
18
|
+
const response = await httpGraphQLAPI.post<{
|
|
19
|
+
data: { employees: EmployeeGraphQL[] };
|
|
20
|
+
errors?: {
|
|
21
|
+
message: string;
|
|
22
|
+
extensions: { path: string; code: string };
|
|
23
|
+
}[];
|
|
24
|
+
}>(
|
|
25
|
+
"",
|
|
26
|
+
{
|
|
27
|
+
query: getEmployeesByAgencyIdStringQuery,
|
|
28
|
+
variables: {
|
|
29
|
+
id,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
{ headers }
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
if (response.data.errors) {
|
|
36
|
+
throw new Error(response.data.errors.map((x) => x.message).join(";"));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const registers = response?.data?.data?.employees;
|
|
40
|
+
|
|
41
|
+
return registers;
|
|
42
|
+
});
|
|
43
|
+
}
|