@zauru-sdk/services 1.0.6 → 1.0.8
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 +16 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +23 -0
- package/dist/zauru/zauru-bookings.server.d.ts +28 -0
- package/dist/zauru/zauru-bookings.server.js +80 -0
- package/dist/zauru/zauru-bundles.service.d.ts +28 -0
- package/dist/zauru/zauru-bundles.service.js +93 -0
- package/dist/zauru/zauru-cases.server.d.ts +6 -0
- package/dist/zauru/zauru-cases.server.js +23 -0
- package/dist/zauru/zauru-consolidated.server.d.ts +36 -0
- package/dist/zauru/zauru-consolidated.server.js +71 -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 +23 -0
- package/src/zauru/zauru-bookings.server.ts +134 -0
- package/src/zauru/zauru-bundles.service.ts +157 -0
- package/src/zauru/zauru-cases.server.ts +44 -0
- package/src/zauru/zauru-consolidated.server.ts +129 -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,129 @@
|
|
|
1
|
+
import type { Session } from "@remix-run/node";
|
|
2
|
+
import { formatDateToUTC, handlePossibleAxiosErrors } from "@zauru-sdk/common";
|
|
3
|
+
import {
|
|
4
|
+
AxiosUtilsResponse,
|
|
5
|
+
ConsolidateGraphQL,
|
|
6
|
+
GeneratePDFBody,
|
|
7
|
+
NewConsolidatedBody,
|
|
8
|
+
PDFResult,
|
|
9
|
+
} from "@zauru-sdk/types";
|
|
10
|
+
import httpZauru from "./httpZauru.server.js";
|
|
11
|
+
import { getGraphQLAPIHeaders, getVariablesByName } from "~/common.server.js";
|
|
12
|
+
import httpGraphQLAPI from "./httpGraphQL.server.js";
|
|
13
|
+
import { getConsolidatesBetweenDatesStringQuery } from "@zauru-sdk/graphql";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
*
|
|
17
|
+
* @param headers
|
|
18
|
+
* @returns
|
|
19
|
+
*/
|
|
20
|
+
export const createConsolidated = async (
|
|
21
|
+
headers: any,
|
|
22
|
+
body: NewConsolidatedBody
|
|
23
|
+
): Promise<AxiosUtilsResponse<{ id: number }>> => {
|
|
24
|
+
return handlePossibleAxiosErrors(async () => {
|
|
25
|
+
const response = await httpZauru.post<{ id: number }>(
|
|
26
|
+
`/purchases/consolidates/create_for_special_invoice.json`,
|
|
27
|
+
body,
|
|
28
|
+
{
|
|
29
|
+
headers,
|
|
30
|
+
}
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
return response.data;
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* generateConsolidatePDF
|
|
39
|
+
* @param headers
|
|
40
|
+
* @param body
|
|
41
|
+
*/
|
|
42
|
+
export const generateConsolidatePDF = async (
|
|
43
|
+
headers: any,
|
|
44
|
+
session: Session,
|
|
45
|
+
body: GeneratePDFBody
|
|
46
|
+
): Promise<AxiosUtilsResponse<{ status: number; zid: number }>> => {
|
|
47
|
+
return handlePossibleAxiosErrors(async () => {
|
|
48
|
+
const { consolidated_template_id } = await getVariablesByName(
|
|
49
|
+
headers,
|
|
50
|
+
session,
|
|
51
|
+
["consolidated_template_id"]
|
|
52
|
+
);
|
|
53
|
+
body.print_template = consolidated_template_id;
|
|
54
|
+
const response = await httpZauru.post<{ status: number; zid: number }>(
|
|
55
|
+
"/purchases/consolidates/gen_print_all.json",
|
|
56
|
+
body,
|
|
57
|
+
{ headers }
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
return response.data;
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* getConsolidatedPDFResult
|
|
66
|
+
* @param headers
|
|
67
|
+
* @param zid
|
|
68
|
+
* @returns
|
|
69
|
+
*/
|
|
70
|
+
export const getConsolidatedPDFResult = async (
|
|
71
|
+
headers: any,
|
|
72
|
+
zid: number | string
|
|
73
|
+
): Promise<AxiosUtilsResponse<PDFResult>> => {
|
|
74
|
+
return handlePossibleAxiosErrors(async () => {
|
|
75
|
+
const response = await httpZauru.get<PDFResult>(
|
|
76
|
+
"purchases/consolidates/check_print_all",
|
|
77
|
+
{
|
|
78
|
+
headers,
|
|
79
|
+
params: { zid },
|
|
80
|
+
}
|
|
81
|
+
);
|
|
82
|
+
return response.data;
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
*
|
|
88
|
+
* @param session
|
|
89
|
+
* @param dates
|
|
90
|
+
* @returns
|
|
91
|
+
*/
|
|
92
|
+
export const getConsolidatesBetweenDates = async (
|
|
93
|
+
session: Session,
|
|
94
|
+
dates: {
|
|
95
|
+
startDate: string;
|
|
96
|
+
endDate: string;
|
|
97
|
+
}
|
|
98
|
+
): Promise<AxiosUtilsResponse<ConsolidateGraphQL[]>> => {
|
|
99
|
+
return handlePossibleAxiosErrors(async () => {
|
|
100
|
+
const headers = await getGraphQLAPIHeaders(session);
|
|
101
|
+
const response = await httpGraphQLAPI.post<{
|
|
102
|
+
data: { consolidates: ConsolidateGraphQL[] };
|
|
103
|
+
errors?: {
|
|
104
|
+
message: string;
|
|
105
|
+
extensions: { path: string; code: string };
|
|
106
|
+
}[];
|
|
107
|
+
}>(
|
|
108
|
+
"",
|
|
109
|
+
{
|
|
110
|
+
query: getConsolidatesBetweenDatesStringQuery,
|
|
111
|
+
variables: {
|
|
112
|
+
startDate: formatDateToUTC(dates.startDate),
|
|
113
|
+
endDate: formatDateToUTC(dates.endDate),
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
{ headers }
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
if (response.data.errors) {
|
|
120
|
+
throw new Error(response.data.errors.map((x) => x.message).join(";"));
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (!response?.data?.data.consolidates) {
|
|
124
|
+
return [];
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return response.data?.data.consolidates;
|
|
128
|
+
});
|
|
129
|
+
};
|
|
@@ -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
|
+
}
|