@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.
Files changed (77) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/index.d.ts +23 -0
  3. package/dist/index.js +23 -0
  4. package/dist/zauru/zauru-bookings.server.d.ts +28 -0
  5. package/dist/zauru/zauru-bookings.server.js +80 -0
  6. package/dist/zauru/zauru-bundles.service.d.ts +28 -0
  7. package/dist/zauru/zauru-bundles.service.js +93 -0
  8. package/dist/zauru/zauru-cases.server.d.ts +6 -0
  9. package/dist/zauru/zauru-cases.server.js +23 -0
  10. package/dist/zauru/zauru-consolidated.server.d.ts +36 -0
  11. package/dist/zauru/zauru-consolidated.server.js +71 -0
  12. package/dist/zauru/zauru-currencies.server.d.ts +6 -0
  13. package/dist/zauru/zauru-currencies.server.js +20 -0
  14. package/dist/zauru/zauru-deliveries.server.d.ts +22 -0
  15. package/dist/zauru/zauru-deliveries.server.js +44 -0
  16. package/dist/zauru/zauru-discharges.server.d.ts +26 -0
  17. package/dist/zauru/zauru-discharges.server.js +46 -0
  18. package/dist/zauru/zauru-employees.server.d.ts +6 -0
  19. package/dist/zauru/zauru-employees.server.js +23 -0
  20. package/dist/zauru/zauru-forms.server.d.ts +96 -0
  21. package/dist/zauru/zauru-forms.server.js +343 -0
  22. package/dist/zauru/zauru-invoices.server.d.ts +26 -0
  23. package/dist/zauru/zauru-invoices.server.js +94 -0
  24. package/dist/zauru/zauru-items.server.d.ts +91 -0
  25. package/dist/zauru/zauru-items.server.js +238 -0
  26. package/dist/zauru/zauru-lote-record.server.d.ts +8 -0
  27. package/dist/zauru/zauru-lote-record.server.js +26 -0
  28. package/dist/zauru/zauru-lotes.server.d.ts +91 -0
  29. package/dist/zauru/zauru-lotes.server.js +294 -0
  30. package/dist/zauru/zauru-motivos-rechazo.server.d.ts +9 -0
  31. package/dist/zauru/zauru-motivos-rechazo.server.js +49 -0
  32. package/dist/zauru/zauru-payees.server.d.ts +97 -0
  33. package/dist/zauru/zauru-payees.server.js +227 -0
  34. package/dist/zauru/zauru-payment-terms.server.d.ts +20 -0
  35. package/dist/zauru/zauru-payment-terms.server.js +65 -0
  36. package/dist/zauru/zauru-price-lists.server.d.ts +22 -0
  37. package/dist/zauru/zauru-price-lists.server.js +40 -0
  38. package/dist/zauru/zauru-purchase-orders.server.d.ts +160 -0
  39. package/dist/zauru/zauru-purchase-orders.server.js +414 -0
  40. package/dist/zauru/zauru-receptions.server.d.ts +33 -0
  41. package/dist/zauru/zauru-receptions.server.js +94 -0
  42. package/dist/zauru/zauru-shipments.server.d.ts +20 -0
  43. package/dist/zauru/zauru-shipments.server.js +53 -0
  44. package/dist/zauru/zauru-suggested-prices.server.d.ts +30 -0
  45. package/dist/zauru/zauru-suggested-prices.server.js +83 -0
  46. package/dist/zauru/zauru-tags.server.d.ts +7 -0
  47. package/dist/zauru/zauru-tags.server.js +13 -0
  48. package/dist/zauru/zauru-templates.server.d.ts +7 -0
  49. package/dist/zauru/zauru-templates.server.js +15 -0
  50. package/dist/zauru/zauru-web-app-tables.server.d.ts +48 -0
  51. package/dist/zauru/zauru-web-app-tables.server.js +120 -0
  52. package/package.json +6 -6
  53. package/src/index.ts +23 -0
  54. package/src/zauru/zauru-bookings.server.ts +134 -0
  55. package/src/zauru/zauru-bundles.service.ts +157 -0
  56. package/src/zauru/zauru-cases.server.ts +44 -0
  57. package/src/zauru/zauru-consolidated.server.ts +129 -0
  58. package/src/zauru/zauru-currencies.server.ts +39 -0
  59. package/src/zauru/zauru-deliveries.server.ts +70 -0
  60. package/src/zauru/zauru-discharges.server.ts +90 -0
  61. package/src/zauru/zauru-employees.server.ts +43 -0
  62. package/src/zauru/zauru-forms.server.ts +618 -0
  63. package/src/zauru/zauru-invoices.server.ts +142 -0
  64. package/src/zauru/zauru-items.server.ts +427 -0
  65. package/src/zauru/zauru-lote-record.server.ts +77 -0
  66. package/src/zauru/zauru-lotes.server.ts +484 -0
  67. package/src/zauru/zauru-motivos-rechazo.server.ts +121 -0
  68. package/src/zauru/zauru-payees.server.ts +398 -0
  69. package/src/zauru/zauru-payment-terms.server.ts +126 -0
  70. package/src/zauru/zauru-price-lists.server.ts +68 -0
  71. package/src/zauru/zauru-purchase-orders.server.ts +701 -0
  72. package/src/zauru/zauru-receptions.server.ts +148 -0
  73. package/src/zauru/zauru-shipments.server.ts +88 -0
  74. package/src/zauru/zauru-suggested-prices.server.ts +134 -0
  75. package/src/zauru/zauru-tags.server.ts +22 -0
  76. package/src/zauru/zauru-templates.server.ts +24 -0
  77. package/src/zauru/zauru-web-app-tables.server.ts +200 -0
package/CHANGELOG.md CHANGED
@@ -3,6 +3,22 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.0.8](https://github.com/intuitiva/zauru-typescript-sdk/compare/v1.0.7...v1.0.8) (2024-03-16)
7
+
8
+ **Note:** Version bump only for package @zauru-sdk/services
9
+
10
+
11
+
12
+
13
+
14
+ ## [1.0.7](https://github.com/intuitiva/zauru-typescript-sdk/compare/v1.0.6...v1.0.7) (2024-03-16)
15
+
16
+ **Note:** Version bump only for package @zauru-sdk/services
17
+
18
+
19
+
20
+
21
+
6
22
  ## [1.0.6](https://github.com/intuitiva/zauru-typescript-sdk/compare/v1.0.5...v1.0.6) (2024-03-16)
7
23
 
8
24
  **Note:** Version bump only for package @zauru-sdk/services
package/dist/index.d.ts CHANGED
@@ -6,5 +6,28 @@ export * from "./zauru/httpOauth.server.js";
6
6
  export * from "./zauru/httpZauru.server.js";
7
7
  export * from "./zauru/zauru-agencies.server.js";
8
8
  export * from "./zauru/zauru-automatic-numbers.server.js";
9
+ export * from "./zauru/zauru-bookings.server.js";
10
+ export * from "./zauru/zauru-bundles.service.js";
11
+ export * from "./zauru/zauru-cases.server.js";
12
+ export * from "./zauru/zauru-consolidated.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";
9
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";
10
33
  export * from "./zauru/zauru-variables.server.js";
package/dist/index.js CHANGED
@@ -6,5 +6,28 @@ export * from "./zauru/httpOauth.server.js";
6
6
  export * from "./zauru/httpZauru.server.js";
7
7
  export * from "./zauru/zauru-agencies.server.js";
8
8
  export * from "./zauru/zauru-automatic-numbers.server.js";
9
+ export * from "./zauru/zauru-bookings.server.js";
10
+ export * from "./zauru/zauru-bundles.service.js";
11
+ export * from "./zauru/zauru-cases.server.js";
12
+ export * from "./zauru/zauru-consolidated.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";
9
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";
10
33
  export * from "./zauru/zauru-variables.server.js";
@@ -0,0 +1,28 @@
1
+ import { AxiosUtilsResponse, InsertBookingBody, ShipmentGraphQL } from "@zauru-sdk/types";
2
+ import { Session } from "@remix-run/node";
3
+ /**
4
+ * insertBookings
5
+ * @param headers
6
+ * @param body
7
+ * @returns
8
+ */
9
+ export declare const insertBookings: (headers: any, body: Partial<InsertBookingBody>, temp_purchase_order_id?: string) => Promise<AxiosUtilsResponse<ShipmentGraphQL>>;
10
+ /**
11
+ * getDeliveryByBooking
12
+ * @param headers
13
+ * @param shipment_id
14
+ * @returns
15
+ */
16
+ export declare const getDeliveryByBooking: (headers: any, shipment_id: number) => Promise<AxiosUtilsResponse<any>>;
17
+ /**
18
+ * getBookings
19
+ * @param headers
20
+ * @returns
21
+ */
22
+ export declare const getBookings: (session: Session, wheres?: string[]) => Promise<AxiosUtilsResponse<ShipmentGraphQL[]>>;
23
+ /**
24
+ * getBookings
25
+ * @param headers
26
+ * @returns
27
+ */
28
+ export declare const getBooking: (headers: any, booking_id: string) => Promise<AxiosUtilsResponse<ShipmentGraphQL>>;
@@ -0,0 +1,80 @@
1
+ import { arrayToObject, 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 { getShipmentsStringQuery } from "@zauru-sdk/graphql";
6
+ /**
7
+ * insertBookings
8
+ * @param headers
9
+ * @param body
10
+ * @returns
11
+ */
12
+ export const insertBookings = async (headers, body, temp_purchase_order_id) => {
13
+ return handlePossibleAxiosErrors(async () => {
14
+ const sendBody = {
15
+ shipment: {
16
+ ...body,
17
+ movements_attributes: arrayToObject(body.movements),
18
+ },
19
+ };
20
+ delete sendBody.shipment.movements;
21
+ if (temp_purchase_order_id) {
22
+ sendBody[`temp_purchase_order_id`] = `${temp_purchase_order_id}`;
23
+ }
24
+ const response = await httpZauru.post(`/inventories/bookings.json`, sendBody, {
25
+ headers,
26
+ });
27
+ return response.data;
28
+ });
29
+ };
30
+ /**
31
+ * getDeliveryByBooking
32
+ * @param headers
33
+ * @param shipment_id
34
+ * @returns
35
+ */
36
+ export const getDeliveryByBooking = async (headers, shipment_id) => {
37
+ return handlePossibleAxiosErrors(async () => {
38
+ if (!shipment_id) {
39
+ throw new Error("No hay un shipment_id, en getDeliveryByBooking");
40
+ }
41
+ const response = await httpZauru.get(`/inventories/bookings/${shipment_id}/deliver.json`, {
42
+ headers,
43
+ data: {
44
+ id: shipment_id,
45
+ },
46
+ });
47
+ return response.data;
48
+ });
49
+ };
50
+ /**
51
+ * getBookings
52
+ * @param headers
53
+ * @returns
54
+ */
55
+ export const getBookings = async (session, wheres = []) => {
56
+ return handlePossibleAxiosErrors(async () => {
57
+ const headers = await getGraphQLAPIHeaders(session);
58
+ const response = await httpGraphQLAPI.post("", {
59
+ query: getShipmentsStringQuery([...wheres, "delivered: {_eq: false}"]),
60
+ }, { headers });
61
+ if (response.data.errors) {
62
+ throw new Error(response.data.errors.map((x) => x.message).join(";"));
63
+ }
64
+ const registers = response?.data?.data?.shipments;
65
+ return registers;
66
+ });
67
+ };
68
+ /**
69
+ * getBookings
70
+ * @param headers
71
+ * @returns
72
+ */
73
+ export const getBooking = async (headers, booking_id) => {
74
+ return handlePossibleAxiosErrors(async () => {
75
+ const response = await httpZauru.get(`/inventories/bookings/${booking_id}.json`, {
76
+ headers,
77
+ });
78
+ return response.data;
79
+ });
80
+ };
@@ -0,0 +1,28 @@
1
+ import type { Session } from "@remix-run/node";
2
+ import { AxiosUtilsResponse, BundleGraphQL } from "@zauru-sdk/types";
3
+ /**
4
+ * getBundlesByItemCategoryId
5
+ */
6
+ export declare function getBundlesByItemCategoryId(session: Session, id: string): Promise<AxiosUtilsResponse<BundleGraphQL[]>>;
7
+ /**
8
+ * getBundleByName
9
+ */
10
+ export declare function getBundleByName(session: Session, name: string): Promise<AxiosUtilsResponse<BundleGraphQL>>;
11
+ /**
12
+ * createBundle
13
+ * @param headers
14
+ * @param body
15
+ */
16
+ export declare function createBundle(headers: any, body: Partial<BundleGraphQL>): Promise<AxiosUtilsResponse<BundleGraphQL>>;
17
+ /**
18
+ * updateBundle
19
+ * @param headers
20
+ * @param body
21
+ */
22
+ export declare function updateBundle(headers: any, body: Partial<BundleGraphQL>): Promise<AxiosUtilsResponse<BundleGraphQL>>;
23
+ /**
24
+ * deleteBundle
25
+ * @param headers
26
+ * @param body
27
+ */
28
+ export declare function deleteBundle(headers: any, id: string | number): Promise<AxiosUtilsResponse<boolean>>;
@@ -0,0 +1,93 @@
1
+ import { arrayToObject, handlePossibleAxiosErrors } from "@zauru-sdk/common";
2
+ import { getGraphQLAPIHeaders } from "~/common.server.js";
3
+ import httpGraphQLAPI from "./httpGraphQL.server.js";
4
+ import { getBundleByNameStringQuery, getBundlesByItemCategoryIdStringQuery, } from "@zauru-sdk/graphql";
5
+ import httpZauru from "./httpZauru.server.js";
6
+ /**
7
+ * getBundlesByItemCategoryId
8
+ */
9
+ export async function getBundlesByItemCategoryId(session, id) {
10
+ return handlePossibleAxiosErrors(async () => {
11
+ const headers = await getGraphQLAPIHeaders(session);
12
+ const response = await httpGraphQLAPI.post("", {
13
+ query: getBundlesByItemCategoryIdStringQuery,
14
+ variables: {
15
+ id,
16
+ },
17
+ }, { headers });
18
+ if (response.data.errors) {
19
+ throw new Error(response.data.errors.map((x) => x.message).join(";"));
20
+ }
21
+ const registers = response?.data?.data?.bundles;
22
+ return registers;
23
+ });
24
+ }
25
+ /**
26
+ * getBundleByName
27
+ */
28
+ export async function getBundleByName(session, name) {
29
+ return handlePossibleAxiosErrors(async () => {
30
+ const headers = await getGraphQLAPIHeaders(session);
31
+ const response = await httpGraphQLAPI.post("", {
32
+ query: getBundleByNameStringQuery,
33
+ variables: {
34
+ name,
35
+ },
36
+ }, { headers });
37
+ if (response.data.errors) {
38
+ throw new Error(response.data.errors.map((x) => x.message).join(";"));
39
+ }
40
+ if (!response?.data?.data?.bundles[0]) {
41
+ throw new Error(`No se encontró ningún bundle con el nombre: ${name} asociado`);
42
+ }
43
+ const register = response?.data?.data?.bundles[0];
44
+ return register;
45
+ });
46
+ }
47
+ /**
48
+ * createBundle
49
+ * @param headers
50
+ * @param body
51
+ */
52
+ export async function createBundle(headers, body) {
53
+ return handlePossibleAxiosErrors(async () => {
54
+ const sendBody = {
55
+ ...body,
56
+ bundle_details_attributes: arrayToObject(body.bundle_details, {
57
+ withOutId: true,
58
+ }),
59
+ };
60
+ delete sendBody.bundle_details;
61
+ const response = await httpZauru.post(`/inventories/bundles.json`, sendBody, { headers });
62
+ return response.data;
63
+ });
64
+ }
65
+ /**
66
+ * updateBundle
67
+ * @param headers
68
+ * @param body
69
+ */
70
+ export async function updateBundle(headers, body) {
71
+ return handlePossibleAxiosErrors(async () => {
72
+ const sendBody = {
73
+ ...body,
74
+ bundle_details_attributes: arrayToObject(body.bundle_details),
75
+ };
76
+ delete sendBody.bundle_details;
77
+ const response = await httpZauru.patch(`/inventories/bundles/${body.id}.json`, sendBody, { headers });
78
+ return response.data;
79
+ });
80
+ }
81
+ /**
82
+ * deleteBundle
83
+ * @param headers
84
+ * @param body
85
+ */
86
+ export async function deleteBundle(headers, id) {
87
+ return handlePossibleAxiosErrors(async () => {
88
+ await httpZauru.delete(`/inventories/bundles/${id}?destroy=true`, {
89
+ headers,
90
+ });
91
+ return true;
92
+ });
93
+ }
@@ -0,0 +1,6 @@
1
+ import type { Session } from "@remix-run/node";
2
+ import { AxiosUtilsResponse, CaseGraphQL } from "@zauru-sdk/types";
3
+ /**
4
+ * getCasesByResponsibleId
5
+ */
6
+ export declare function getCasesByResponsibleId(session: Session, responsible_id: string, wheres?: string[]): Promise<AxiosUtilsResponse<CaseGraphQL[]>>;
@@ -0,0 +1,23 @@
1
+ import { handlePossibleAxiosErrors } from "@zauru-sdk/common";
2
+ import { getGraphQLAPIHeaders } from "~/common.server.js";
3
+ import httpGraphQLAPI from "./httpGraphQL.server.js";
4
+ import { getCasesByResponsibleIdStringQuery } from "@zauru-sdk/graphql";
5
+ /**
6
+ * getCasesByResponsibleId
7
+ */
8
+ export async function getCasesByResponsibleId(session, responsible_id, wheres = []) {
9
+ return handlePossibleAxiosErrors(async () => {
10
+ const headers = await getGraphQLAPIHeaders(session);
11
+ const response = await httpGraphQLAPI.post("", {
12
+ query: getCasesByResponsibleIdStringQuery(wheres),
13
+ variables: {
14
+ responsible_id,
15
+ },
16
+ }, { headers });
17
+ if (response.data.errors) {
18
+ throw new Error(response.data.errors.map((x) => x.message).join(";"));
19
+ }
20
+ const registers = response?.data?.data?.cases;
21
+ return registers;
22
+ });
23
+ }
@@ -0,0 +1,36 @@
1
+ import type { Session } from "@remix-run/node";
2
+ import { AxiosUtilsResponse, ConsolidateGraphQL, GeneratePDFBody, NewConsolidatedBody, PDFResult } from "@zauru-sdk/types";
3
+ /**
4
+ *
5
+ * @param headers
6
+ * @returns
7
+ */
8
+ export declare const createConsolidated: (headers: any, body: NewConsolidatedBody) => Promise<AxiosUtilsResponse<{
9
+ id: number;
10
+ }>>;
11
+ /**
12
+ * generateConsolidatePDF
13
+ * @param headers
14
+ * @param body
15
+ */
16
+ export declare const generateConsolidatePDF: (headers: any, session: Session, body: GeneratePDFBody) => Promise<AxiosUtilsResponse<{
17
+ status: number;
18
+ zid: number;
19
+ }>>;
20
+ /**
21
+ * getConsolidatedPDFResult
22
+ * @param headers
23
+ * @param zid
24
+ * @returns
25
+ */
26
+ export declare const getConsolidatedPDFResult: (headers: any, zid: number | string) => Promise<AxiosUtilsResponse<PDFResult>>;
27
+ /**
28
+ *
29
+ * @param session
30
+ * @param dates
31
+ * @returns
32
+ */
33
+ export declare const getConsolidatesBetweenDates: (session: Session, dates: {
34
+ startDate: string;
35
+ endDate: string;
36
+ }) => Promise<AxiosUtilsResponse<ConsolidateGraphQL[]>>;
@@ -0,0 +1,71 @@
1
+ import { formatDateToUTC, handlePossibleAxiosErrors } from "@zauru-sdk/common";
2
+ import httpZauru from "./httpZauru.server.js";
3
+ import { getGraphQLAPIHeaders, getVariablesByName } from "~/common.server.js";
4
+ import httpGraphQLAPI from "./httpGraphQL.server.js";
5
+ import { getConsolidatesBetweenDatesStringQuery } from "@zauru-sdk/graphql";
6
+ /**
7
+ *
8
+ * @param headers
9
+ * @returns
10
+ */
11
+ export const createConsolidated = async (headers, body) => {
12
+ return handlePossibleAxiosErrors(async () => {
13
+ const response = await httpZauru.post(`/purchases/consolidates/create_for_special_invoice.json`, body, {
14
+ headers,
15
+ });
16
+ return response.data;
17
+ });
18
+ };
19
+ /**
20
+ * generateConsolidatePDF
21
+ * @param headers
22
+ * @param body
23
+ */
24
+ export const generateConsolidatePDF = async (headers, session, body) => {
25
+ return handlePossibleAxiosErrors(async () => {
26
+ const { consolidated_template_id } = await getVariablesByName(headers, session, ["consolidated_template_id"]);
27
+ body.print_template = consolidated_template_id;
28
+ const response = await httpZauru.post("/purchases/consolidates/gen_print_all.json", body, { headers });
29
+ return response.data;
30
+ });
31
+ };
32
+ /**
33
+ * getConsolidatedPDFResult
34
+ * @param headers
35
+ * @param zid
36
+ * @returns
37
+ */
38
+ export const getConsolidatedPDFResult = async (headers, zid) => {
39
+ return handlePossibleAxiosErrors(async () => {
40
+ const response = await httpZauru.get("purchases/consolidates/check_print_all", {
41
+ headers,
42
+ params: { zid },
43
+ });
44
+ return response.data;
45
+ });
46
+ };
47
+ /**
48
+ *
49
+ * @param session
50
+ * @param dates
51
+ * @returns
52
+ */
53
+ export const getConsolidatesBetweenDates = async (session, dates) => {
54
+ return handlePossibleAxiosErrors(async () => {
55
+ const headers = await getGraphQLAPIHeaders(session);
56
+ const response = await httpGraphQLAPI.post("", {
57
+ query: getConsolidatesBetweenDatesStringQuery,
58
+ variables: {
59
+ startDate: formatDateToUTC(dates.startDate),
60
+ endDate: formatDateToUTC(dates.endDate),
61
+ },
62
+ }, { headers });
63
+ if (response.data.errors) {
64
+ throw new Error(response.data.errors.map((x) => x.message).join(";"));
65
+ }
66
+ if (!response?.data?.data.consolidates) {
67
+ return [];
68
+ }
69
+ return response.data?.data.consolidates;
70
+ });
71
+ };
@@ -0,0 +1,6 @@
1
+ import type { Session } from "@remix-run/node";
2
+ import { AxiosUtilsResponse, CurrencyGraphQL } from "@zauru-sdk/types";
3
+ /**
4
+ * getCurrencies
5
+ */
6
+ export declare function getCurrencies(session: Session): Promise<AxiosUtilsResponse<CurrencyGraphQL[]>>;
@@ -0,0 +1,20 @@
1
+ import { handlePossibleAxiosErrors } from "@zauru-sdk/common";
2
+ import { getGraphQLAPIHeaders } from "~/common.server.js";
3
+ import httpGraphQLAPI from "./httpGraphQL.server.js";
4
+ import { getCurrenciesStringQuery } from "@zauru-sdk/graphql";
5
+ /**
6
+ * getCurrencies
7
+ */
8
+ export async function getCurrencies(session) {
9
+ return handlePossibleAxiosErrors(async () => {
10
+ const headers = await getGraphQLAPIHeaders(session);
11
+ const response = await httpGraphQLAPI.post("", {
12
+ query: getCurrenciesStringQuery,
13
+ }, { headers });
14
+ if (response.data.errors) {
15
+ throw new Error(response.data.errors.map((x) => x.message).join(";"));
16
+ }
17
+ const registers = response?.data?.data?.currencies;
18
+ return registers;
19
+ });
20
+ }
@@ -0,0 +1,22 @@
1
+ import { AxiosUtilsResponse, DataTablesFilterBody, HTMLDataTableDeliveries, ShipmentGraphQL } from "@zauru-sdk/types";
2
+ /**
3
+ * getDelivery
4
+ * @param headers
5
+ * @param body
6
+ * @returns
7
+ */
8
+ export declare function getDelivery(headers: any, idDelivery: string): Promise<AxiosUtilsResponse<ShipmentGraphQL>>;
9
+ /**
10
+ * GET DELIVERIES DATA TABLES
11
+ * @param headers
12
+ * @param body
13
+ * @returns
14
+ */
15
+ export declare function getDeliveriesDataTables(headers: any, body: DataTablesFilterBody): Promise<AxiosUtilsResponse<HTMLDataTableDeliveries>>;
16
+ /**
17
+ * deleteDelivery
18
+ * @param headers
19
+ * @param id
20
+ * @returns
21
+ */
22
+ export declare function deleteDelivery(headers: any, id: string | number): Promise<AxiosUtilsResponse<boolean>>;
@@ -0,0 +1,44 @@
1
+ import { handlePossibleAxiosErrors } from "@zauru-sdk/common";
2
+ import httpZauru from "./httpZauru.server.js";
3
+ /**
4
+ * getDelivery
5
+ * @param headers
6
+ * @param body
7
+ * @returns
8
+ */
9
+ export async function getDelivery(headers, idDelivery) {
10
+ return handlePossibleAxiosErrors(async () => {
11
+ const response = await httpZauru.get(`/inventories/deliveries/${idDelivery}.json`, {
12
+ headers,
13
+ });
14
+ return response.data;
15
+ });
16
+ }
17
+ /**
18
+ * GET DELIVERIES DATA TABLES
19
+ * @param headers
20
+ * @param body
21
+ * @returns
22
+ */
23
+ export async function getDeliveriesDataTables(headers, body) {
24
+ return handlePossibleAxiosErrors(async () => {
25
+ const response = await httpZauru.post(`/inventories/deliveries/datatables.json`, body, {
26
+ headers,
27
+ });
28
+ return response.data;
29
+ });
30
+ }
31
+ /**
32
+ * deleteDelivery
33
+ * @param headers
34
+ * @param id
35
+ * @returns
36
+ */
37
+ export async function deleteDelivery(headers, id) {
38
+ return handlePossibleAxiosErrors(async () => {
39
+ await httpZauru.delete(`/inventories/deliveries/${id}.json?destroy=true`, {
40
+ headers,
41
+ });
42
+ return true;
43
+ });
44
+ }
@@ -0,0 +1,26 @@
1
+ import type { Session } from "@remix-run/node";
2
+ import { AxiosUtilsResponse, GeneratePDFBody, NewDischargeBody, PDFResult } from "@zauru-sdk/types";
3
+ /**
4
+ *
5
+ * @param headers
6
+ * @returns
7
+ */
8
+ export declare const createDischarge: (session: Session, headers: any, body: NewDischargeBody) => Promise<AxiosUtilsResponse<{
9
+ id: number;
10
+ }>>;
11
+ /**
12
+ * generateDischargePDF
13
+ * @param headers
14
+ * @param body
15
+ */
16
+ export declare const generateDischargePDF: (headers: any, session: Session, body: GeneratePDFBody) => Promise<AxiosUtilsResponse<{
17
+ status: number;
18
+ zid: number;
19
+ }>>;
20
+ /**
21
+ * getDischargePDFResult
22
+ * @param headers
23
+ * @param zid
24
+ * @returns
25
+ */
26
+ export declare const getDischargePDFResult: (headers: any, zid: number | string) => Promise<AxiosUtilsResponse<PDFResult>>;
@@ -0,0 +1,46 @@
1
+ import { getVariablesByName } from "~/common.server.js";
2
+ import { handlePossibleAxiosErrors } from "@zauru-sdk/common";
3
+ import httpZauru from "./httpZauru.server.js";
4
+ /**
5
+ *
6
+ * @param headers
7
+ * @returns
8
+ */
9
+ export const createDischarge = async (session, headers, body) => {
10
+ return handlePossibleAxiosErrors(async () => {
11
+ const { id_check_discharge_method } = await getVariablesByName(headers, session, ["id_check_discharge_method"]);
12
+ body.discharge.discharge_method_id = id_check_discharge_method;
13
+ const response = await httpZauru.post(`/purchases/discharges.json`, body, {
14
+ headers,
15
+ });
16
+ return response.data;
17
+ });
18
+ };
19
+ /**
20
+ * generateDischargePDF
21
+ * @param headers
22
+ * @param body
23
+ */
24
+ export const generateDischargePDF = async (headers, session, body) => {
25
+ return handlePossibleAxiosErrors(async () => {
26
+ const { consolidated_template_id } = await getVariablesByName(headers, session, ["consolidated_template_id"]);
27
+ body.print_template = consolidated_template_id;
28
+ const response = await httpZauru.post("/purchases/consolidates/gen_print_all.json", body, { headers });
29
+ return response.data;
30
+ });
31
+ };
32
+ /**
33
+ * getDischargePDFResult
34
+ * @param headers
35
+ * @param zid
36
+ * @returns
37
+ */
38
+ export const getDischargePDFResult = async (headers, zid) => {
39
+ return handlePossibleAxiosErrors(async () => {
40
+ const response = await httpZauru.get("purchases/consolidates/check_print_all", {
41
+ headers,
42
+ params: { zid },
43
+ });
44
+ return response.data;
45
+ });
46
+ };
@@ -0,0 +1,6 @@
1
+ import type { Session } from "@remix-run/node";
2
+ import { AxiosUtilsResponse, EmployeeGraphQL } from "@zauru-sdk/types";
3
+ /**
4
+ * getEmployeesByAgencyId
5
+ */
6
+ export declare function getEmployeesByAgencyId(session: Session, id: number | string): Promise<AxiosUtilsResponse<EmployeeGraphQL[]>>;
@@ -0,0 +1,23 @@
1
+ import { handlePossibleAxiosErrors } from "@zauru-sdk/common";
2
+ import { getGraphQLAPIHeaders } from "~/common.server.js";
3
+ import httpGraphQLAPI from "./httpGraphQL.server.js";
4
+ import { getEmployeesByAgencyIdStringQuery } from "@zauru-sdk/graphql";
5
+ /**
6
+ * getEmployeesByAgencyId
7
+ */
8
+ export async function getEmployeesByAgencyId(session, id) {
9
+ return handlePossibleAxiosErrors(async () => {
10
+ const headers = await getGraphQLAPIHeaders(session);
11
+ const response = await httpGraphQLAPI.post("", {
12
+ query: getEmployeesByAgencyIdStringQuery,
13
+ variables: {
14
+ id,
15
+ },
16
+ }, { headers });
17
+ if (response.data.errors) {
18
+ throw new Error(response.data.errors.map((x) => x.message).join(";"));
19
+ }
20
+ const registers = response?.data?.data?.employees;
21
+ return registers;
22
+ });
23
+ }