@zauru-sdk/services 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.
- package/dist/cjs/common.js +235 -0
- package/dist/cjs/index.js +50 -0
- package/dist/cjs/sessions/sessions.js +18 -0
- package/dist/cjs/sessions/upstash.js +59 -0
- package/dist/cjs/zauru/httpGraphQL.js +42 -0
- package/dist/cjs/zauru/httpOauth.js +42 -0
- package/dist/cjs/zauru/httpZauru.js +42 -0
- package/dist/cjs/zauru/zauru-agencies.js +27 -0
- package/dist/cjs/zauru/zauru-automatic-numbers.js +28 -0
- package/dist/cjs/zauru/zauru-bookings.js +90 -0
- package/dist/cjs/zauru/zauru-bundles.js +104 -0
- package/dist/cjs/zauru/zauru-cases.js +30 -0
- package/dist/cjs/zauru/zauru-consolidated.js +81 -0
- package/dist/cjs/zauru/zauru-currencies.js +27 -0
- package/dist/cjs/zauru/zauru-deliveries.js +53 -0
- package/dist/cjs/zauru/zauru-discharges.js +55 -0
- package/dist/cjs/zauru/zauru-employees.js +30 -0
- package/dist/cjs/zauru/zauru-forms.js +363 -0
- package/dist/cjs/zauru/zauru-invoices.js +104 -0
- package/dist/cjs/zauru/zauru-items.js +293 -0
- package/dist/cjs/zauru/zauru-lote-record.js +33 -0
- package/dist/cjs/zauru/zauru-lotes.js +312 -0
- package/dist/cjs/zauru/zauru-motivos-rechazo.js +57 -0
- package/dist/cjs/zauru/zauru-payees.js +247 -0
- package/dist/cjs/zauru/zauru-payment-terms.js +75 -0
- package/dist/cjs/zauru/zauru-price-lists.js +49 -0
- package/dist/cjs/zauru/zauru-profiles.js +80 -0
- package/dist/cjs/zauru/zauru-purchase-orders.js +438 -0
- package/dist/cjs/zauru/zauru-receptions.js +104 -0
- package/dist/cjs/zauru/zauru-shipments.js +62 -0
- package/dist/cjs/zauru/zauru-suggested-prices.js +94 -0
- package/dist/cjs/zauru/zauru-tags.js +20 -0
- package/dist/cjs/zauru/zauru-templates.js +22 -0
- package/dist/cjs/zauru/zauru-variables.js +56 -0
- package/dist/cjs/zauru/zauru-web-app-tables.js +167 -0
- package/package.json +12 -9
- package/CHANGELOG.md +0 -232
- package/src/common.ts +0 -343
- package/src/index.ts +0 -37
- package/src/sessions/sessions.ts +0 -17
- package/src/sessions/upstash.ts +0 -55
- package/src/zauru/httpGraphQL.ts +0 -55
- package/src/zauru/httpOauth.ts +0 -55
- package/src/zauru/httpZauru.ts +0 -56
- package/src/zauru/zauru-agencies.ts +0 -32
- package/src/zauru/zauru-automatic-numbers.ts +0 -35
- package/src/zauru/zauru-bookings.ts +0 -134
- package/src/zauru/zauru-bundles.ts +0 -157
- package/src/zauru/zauru-cases.ts +0 -44
- package/src/zauru/zauru-consolidated.ts +0 -129
- package/src/zauru/zauru-currencies.ts +0 -39
- package/src/zauru/zauru-deliveries.ts +0 -70
- package/src/zauru/zauru-discharges.ts +0 -90
- package/src/zauru/zauru-employees.ts +0 -43
- package/src/zauru/zauru-forms.ts +0 -618
- package/src/zauru/zauru-invoices.ts +0 -142
- package/src/zauru/zauru-items.ts +0 -481
- package/src/zauru/zauru-lote-record.ts +0 -77
- package/src/zauru/zauru-lotes.ts +0 -484
- package/src/zauru/zauru-motivos-rechazo.ts +0 -121
- package/src/zauru/zauru-payees.ts +0 -402
- package/src/zauru/zauru-payment-terms.ts +0 -126
- package/src/zauru/zauru-price-lists.ts +0 -68
- package/src/zauru/zauru-profiles.ts +0 -106
- package/src/zauru/zauru-purchase-orders.ts +0 -701
- package/src/zauru/zauru-receptions.ts +0 -148
- package/src/zauru/zauru-shipments.ts +0 -88
- package/src/zauru/zauru-suggested-prices.ts +0 -137
- package/src/zauru/zauru-tags.ts +0 -22
- package/src/zauru/zauru-templates.ts +0 -24
- package/src/zauru/zauru-variables.ts +0 -67
- package/src/zauru/zauru-web-app-tables.ts +0 -256
- package/tsconfig.json +0 -24
- /package/dist/{common.js → esm/common.js} +0 -0
- /package/dist/{index.js → esm/index.js} +0 -0
- /package/dist/{sessions → esm/sessions}/sessions.js +0 -0
- /package/dist/{sessions → esm/sessions}/upstash.js +0 -0
- /package/dist/{zauru → esm/zauru}/httpGraphQL.js +0 -0
- /package/dist/{zauru → esm/zauru}/httpOauth.js +0 -0
- /package/dist/{zauru → esm/zauru}/httpZauru.js +0 -0
- /package/dist/{zauru → esm/zauru}/zauru-agencies.js +0 -0
- /package/dist/{zauru → esm/zauru}/zauru-automatic-numbers.js +0 -0
- /package/dist/{zauru → esm/zauru}/zauru-bookings.js +0 -0
- /package/dist/{zauru → esm/zauru}/zauru-bundles.js +0 -0
- /package/dist/{zauru → esm/zauru}/zauru-cases.js +0 -0
- /package/dist/{zauru → esm/zauru}/zauru-consolidated.js +0 -0
- /package/dist/{zauru → esm/zauru}/zauru-currencies.js +0 -0
- /package/dist/{zauru → esm/zauru}/zauru-deliveries.js +0 -0
- /package/dist/{zauru → esm/zauru}/zauru-discharges.js +0 -0
- /package/dist/{zauru → esm/zauru}/zauru-employees.js +0 -0
- /package/dist/{zauru → esm/zauru}/zauru-forms.js +0 -0
- /package/dist/{zauru → esm/zauru}/zauru-invoices.js +0 -0
- /package/dist/{zauru → esm/zauru}/zauru-items.js +0 -0
- /package/dist/{zauru → esm/zauru}/zauru-lote-record.js +0 -0
- /package/dist/{zauru → esm/zauru}/zauru-lotes.js +0 -0
- /package/dist/{zauru → esm/zauru}/zauru-motivos-rechazo.js +0 -0
- /package/dist/{zauru → esm/zauru}/zauru-payees.js +0 -0
- /package/dist/{zauru → esm/zauru}/zauru-payment-terms.js +0 -0
- /package/dist/{zauru → esm/zauru}/zauru-price-lists.js +0 -0
- /package/dist/{zauru → esm/zauru}/zauru-profiles.js +0 -0
- /package/dist/{zauru → esm/zauru}/zauru-purchase-orders.js +0 -0
- /package/dist/{zauru → esm/zauru}/zauru-receptions.js +0 -0
- /package/dist/{zauru → esm/zauru}/zauru-shipments.js +0 -0
- /package/dist/{zauru → esm/zauru}/zauru-suggested-prices.js +0 -0
- /package/dist/{zauru → esm/zauru}/zauru-tags.js +0 -0
- /package/dist/{zauru → esm/zauru}/zauru-templates.js +0 -0
- /package/dist/{zauru → esm/zauru}/zauru-variables.js +0 -0
- /package/dist/{zauru → esm/zauru}/zauru-web-app-tables.js +0 -0
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import { arrayToObject, handlePossibleAxiosErrors } from "@zauru-sdk/common";
|
|
2
|
-
import {
|
|
3
|
-
AxiosUtilsResponse,
|
|
4
|
-
InsertBookingBody,
|
|
5
|
-
ShipmentGraphQL,
|
|
6
|
-
} from "@zauru-sdk/types";
|
|
7
|
-
import httpZauru from "./httpZauru.js";
|
|
8
|
-
import { getGraphQLAPIHeaders } from "../common.js";
|
|
9
|
-
import { Session } from "@remix-run/node";
|
|
10
|
-
import httpGraphQLAPI from "./httpGraphQL.js";
|
|
11
|
-
import { getShipmentsStringQuery } from "@zauru-sdk/graphql";
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* insertBookings
|
|
15
|
-
* @param headers
|
|
16
|
-
* @param body
|
|
17
|
-
* @returns
|
|
18
|
-
*/
|
|
19
|
-
export const insertBookings = async (
|
|
20
|
-
headers: any,
|
|
21
|
-
body: Partial<InsertBookingBody>,
|
|
22
|
-
temp_purchase_order_id?: string
|
|
23
|
-
): Promise<AxiosUtilsResponse<ShipmentGraphQL>> => {
|
|
24
|
-
return handlePossibleAxiosErrors(async () => {
|
|
25
|
-
const sendBody: any = {
|
|
26
|
-
shipment: {
|
|
27
|
-
...body,
|
|
28
|
-
movements_attributes: arrayToObject(body.movements),
|
|
29
|
-
},
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
delete sendBody.shipment.movements;
|
|
33
|
-
|
|
34
|
-
if (temp_purchase_order_id) {
|
|
35
|
-
sendBody[`temp_purchase_order_id`] = `${temp_purchase_order_id}`;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const response = await httpZauru.post<ShipmentGraphQL>(
|
|
39
|
-
`/inventories/bookings.json`,
|
|
40
|
-
sendBody,
|
|
41
|
-
{
|
|
42
|
-
headers,
|
|
43
|
-
}
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
return response.data;
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* getDeliveryByBooking
|
|
52
|
-
* @param headers
|
|
53
|
-
* @param shipment_id
|
|
54
|
-
* @returns
|
|
55
|
-
*/
|
|
56
|
-
export const getDeliveryByBooking = async (
|
|
57
|
-
headers: any,
|
|
58
|
-
shipment_id: number
|
|
59
|
-
) => {
|
|
60
|
-
return handlePossibleAxiosErrors(async () => {
|
|
61
|
-
if (!shipment_id) {
|
|
62
|
-
throw new Error("No hay un shipment_id, en getDeliveryByBooking");
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const response = await httpZauru.get<any>(
|
|
66
|
-
`/inventories/bookings/${shipment_id}/deliver.json`,
|
|
67
|
-
{
|
|
68
|
-
headers,
|
|
69
|
-
data: {
|
|
70
|
-
id: shipment_id,
|
|
71
|
-
},
|
|
72
|
-
}
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
return response.data;
|
|
76
|
-
});
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* getBookings
|
|
81
|
-
* @param headers
|
|
82
|
-
* @returns
|
|
83
|
-
*/
|
|
84
|
-
export const getBookings = async (
|
|
85
|
-
session: Session,
|
|
86
|
-
wheres: string[] = []
|
|
87
|
-
): Promise<AxiosUtilsResponse<ShipmentGraphQL[]>> => {
|
|
88
|
-
return handlePossibleAxiosErrors(async () => {
|
|
89
|
-
const headers = await getGraphQLAPIHeaders(session);
|
|
90
|
-
|
|
91
|
-
const response = await httpGraphQLAPI.post<{
|
|
92
|
-
data: { shipments: ShipmentGraphQL[] };
|
|
93
|
-
errors?: {
|
|
94
|
-
message: string;
|
|
95
|
-
extensions: { path: string; code: string };
|
|
96
|
-
}[];
|
|
97
|
-
}>(
|
|
98
|
-
"",
|
|
99
|
-
{
|
|
100
|
-
query: getShipmentsStringQuery([...wheres, "delivered: {_eq: false}"]),
|
|
101
|
-
},
|
|
102
|
-
{ headers }
|
|
103
|
-
);
|
|
104
|
-
|
|
105
|
-
if (response.data.errors) {
|
|
106
|
-
throw new Error(response.data.errors.map((x) => x.message).join(";"));
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
const registers = response?.data?.data?.shipments;
|
|
110
|
-
|
|
111
|
-
return registers;
|
|
112
|
-
});
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* getBookings
|
|
117
|
-
* @param headers
|
|
118
|
-
* @returns
|
|
119
|
-
*/
|
|
120
|
-
export const getBooking = async (
|
|
121
|
-
headers: any,
|
|
122
|
-
booking_id: string
|
|
123
|
-
): Promise<AxiosUtilsResponse<ShipmentGraphQL>> => {
|
|
124
|
-
return handlePossibleAxiosErrors(async () => {
|
|
125
|
-
const response = await httpZauru.get<any>(
|
|
126
|
-
`/inventories/bookings/${booking_id}.json`,
|
|
127
|
-
{
|
|
128
|
-
headers,
|
|
129
|
-
}
|
|
130
|
-
);
|
|
131
|
-
|
|
132
|
-
return response.data;
|
|
133
|
-
});
|
|
134
|
-
};
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import type { Session } from "@remix-run/node";
|
|
2
|
-
import { arrayToObject, handlePossibleAxiosErrors } from "@zauru-sdk/common";
|
|
3
|
-
import { AxiosUtilsResponse, BundleGraphQL } from "@zauru-sdk/types";
|
|
4
|
-
import { getGraphQLAPIHeaders } from "../common.js";
|
|
5
|
-
import httpGraphQLAPI from "./httpGraphQL.js";
|
|
6
|
-
import {
|
|
7
|
-
getBundleByNameStringQuery,
|
|
8
|
-
getBundlesByItemCategoryIdStringQuery,
|
|
9
|
-
} from "@zauru-sdk/graphql";
|
|
10
|
-
import httpZauru from "./httpZauru.js";
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* getBundlesByItemCategoryId
|
|
14
|
-
*/
|
|
15
|
-
export async function getBundlesByItemCategoryId(
|
|
16
|
-
session: Session,
|
|
17
|
-
id: string
|
|
18
|
-
): Promise<AxiosUtilsResponse<BundleGraphQL[]>> {
|
|
19
|
-
return handlePossibleAxiosErrors(async () => {
|
|
20
|
-
const headers = await getGraphQLAPIHeaders(session);
|
|
21
|
-
|
|
22
|
-
const response = await httpGraphQLAPI.post<{
|
|
23
|
-
data: { bundles: BundleGraphQL[] };
|
|
24
|
-
errors?: {
|
|
25
|
-
message: string;
|
|
26
|
-
extensions: { path: string; code: string };
|
|
27
|
-
}[];
|
|
28
|
-
}>(
|
|
29
|
-
"",
|
|
30
|
-
{
|
|
31
|
-
query: getBundlesByItemCategoryIdStringQuery,
|
|
32
|
-
variables: {
|
|
33
|
-
id,
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
{ headers }
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
if (response.data.errors) {
|
|
40
|
-
throw new Error(response.data.errors.map((x) => x.message).join(";"));
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const registers = response?.data?.data?.bundles;
|
|
44
|
-
|
|
45
|
-
return registers;
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* getBundleByName
|
|
51
|
-
*/
|
|
52
|
-
export async function getBundleByName(
|
|
53
|
-
session: Session,
|
|
54
|
-
name: string
|
|
55
|
-
): Promise<AxiosUtilsResponse<BundleGraphQL>> {
|
|
56
|
-
return handlePossibleAxiosErrors(async () => {
|
|
57
|
-
const headers = await getGraphQLAPIHeaders(session);
|
|
58
|
-
|
|
59
|
-
const response = await httpGraphQLAPI.post<{
|
|
60
|
-
data: { bundles: BundleGraphQL[] };
|
|
61
|
-
errors?: {
|
|
62
|
-
message: string;
|
|
63
|
-
extensions: { path: string; code: string };
|
|
64
|
-
}[];
|
|
65
|
-
}>(
|
|
66
|
-
"",
|
|
67
|
-
{
|
|
68
|
-
query: getBundleByNameStringQuery,
|
|
69
|
-
variables: {
|
|
70
|
-
name,
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
{ headers }
|
|
74
|
-
);
|
|
75
|
-
|
|
76
|
-
if (response.data.errors) {
|
|
77
|
-
throw new Error(response.data.errors.map((x) => x.message).join(";"));
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (!response?.data?.data?.bundles[0]) {
|
|
81
|
-
throw new Error(
|
|
82
|
-
`No se encontró ningún bundle con el nombre: ${name} asociado`
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const register = response?.data?.data?.bundles[0];
|
|
87
|
-
|
|
88
|
-
return register;
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* createBundle
|
|
94
|
-
* @param headers
|
|
95
|
-
* @param body
|
|
96
|
-
*/
|
|
97
|
-
export async function createBundle(
|
|
98
|
-
headers: any,
|
|
99
|
-
body: Partial<BundleGraphQL>
|
|
100
|
-
): Promise<AxiosUtilsResponse<BundleGraphQL>> {
|
|
101
|
-
return handlePossibleAxiosErrors(async () => {
|
|
102
|
-
const sendBody = {
|
|
103
|
-
...body,
|
|
104
|
-
bundle_details_attributes: arrayToObject(body.bundle_details, {
|
|
105
|
-
withOutId: true,
|
|
106
|
-
}),
|
|
107
|
-
};
|
|
108
|
-
delete sendBody.bundle_details;
|
|
109
|
-
const response = await httpZauru.post<BundleGraphQL>(
|
|
110
|
-
`/inventories/bundles.json`,
|
|
111
|
-
sendBody,
|
|
112
|
-
{ headers }
|
|
113
|
-
);
|
|
114
|
-
return response.data;
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* updateBundle
|
|
120
|
-
* @param headers
|
|
121
|
-
* @param body
|
|
122
|
-
*/
|
|
123
|
-
export async function updateBundle(
|
|
124
|
-
headers: any,
|
|
125
|
-
body: Partial<BundleGraphQL>
|
|
126
|
-
): Promise<AxiosUtilsResponse<BundleGraphQL>> {
|
|
127
|
-
return handlePossibleAxiosErrors(async () => {
|
|
128
|
-
const sendBody = {
|
|
129
|
-
...body,
|
|
130
|
-
bundle_details_attributes: arrayToObject(body.bundle_details),
|
|
131
|
-
};
|
|
132
|
-
delete sendBody.bundle_details;
|
|
133
|
-
const response = await httpZauru.patch<BundleGraphQL>(
|
|
134
|
-
`/inventories/bundles/${body.id}.json`,
|
|
135
|
-
sendBody,
|
|
136
|
-
{ headers }
|
|
137
|
-
);
|
|
138
|
-
return response.data;
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* deleteBundle
|
|
144
|
-
* @param headers
|
|
145
|
-
* @param body
|
|
146
|
-
*/
|
|
147
|
-
export async function deleteBundle(
|
|
148
|
-
headers: any,
|
|
149
|
-
id: string | number
|
|
150
|
-
): Promise<AxiosUtilsResponse<boolean>> {
|
|
151
|
-
return handlePossibleAxiosErrors(async () => {
|
|
152
|
-
await httpZauru.delete<any>(`/inventories/bundles/${id}?destroy=true`, {
|
|
153
|
-
headers,
|
|
154
|
-
});
|
|
155
|
-
return true;
|
|
156
|
-
});
|
|
157
|
-
}
|
package/src/zauru/zauru-cases.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import type { Session } from "@remix-run/node";
|
|
2
|
-
import { handlePossibleAxiosErrors } from "@zauru-sdk/common";
|
|
3
|
-
import { AxiosUtilsResponse, CaseGraphQL } from "@zauru-sdk/types";
|
|
4
|
-
import { getGraphQLAPIHeaders } from "../common.js";
|
|
5
|
-
import httpGraphQLAPI from "./httpGraphQL.js";
|
|
6
|
-
import { getCasesByResponsibleIdStringQuery } from "@zauru-sdk/graphql";
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* getCasesByResponsibleId
|
|
10
|
-
*/
|
|
11
|
-
export async function getCasesByResponsibleId(
|
|
12
|
-
session: Session,
|
|
13
|
-
responsible_id: string,
|
|
14
|
-
wheres: string[] = []
|
|
15
|
-
): Promise<AxiosUtilsResponse<CaseGraphQL[]>> {
|
|
16
|
-
return handlePossibleAxiosErrors(async () => {
|
|
17
|
-
const headers = await getGraphQLAPIHeaders(session);
|
|
18
|
-
|
|
19
|
-
const response = await httpGraphQLAPI.post<{
|
|
20
|
-
data: { cases: CaseGraphQL[] };
|
|
21
|
-
errors?: {
|
|
22
|
-
message: string;
|
|
23
|
-
extensions: { path: string; code: string };
|
|
24
|
-
}[];
|
|
25
|
-
}>(
|
|
26
|
-
"",
|
|
27
|
-
{
|
|
28
|
-
query: getCasesByResponsibleIdStringQuery(wheres),
|
|
29
|
-
variables: {
|
|
30
|
-
responsible_id,
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
{ headers }
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
if (response.data.errors) {
|
|
37
|
-
throw new Error(response.data.errors.map((x) => x.message).join(";"));
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const registers = response?.data?.data?.cases;
|
|
41
|
-
|
|
42
|
-
return registers;
|
|
43
|
-
});
|
|
44
|
-
}
|
|
@@ -1,129 +0,0 @@
|
|
|
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.js";
|
|
11
|
-
import { getGraphQLAPIHeaders, getVariablesByName } from "../common.js";
|
|
12
|
-
import httpGraphQLAPI from "./httpGraphQL.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
|
-
};
|
|
@@ -1,39 +0,0 @@
|
|
|
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.js";
|
|
5
|
-
import httpGraphQLAPI from "./httpGraphQL.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
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
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.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
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
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.js";
|
|
9
|
-
import { handlePossibleAxiosErrors } from "@zauru-sdk/common";
|
|
10
|
-
import httpZauru from "./httpZauru.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
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
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.js";
|
|
5
|
-
import httpGraphQLAPI from "./httpGraphQL.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
|
-
}
|