@zauru-sdk/services 1.0.80 → 1.0.82

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/index.js CHANGED
@@ -37,7 +37,9 @@ __exportStar(require("./zauru/zauru-lote-record.js"), exports);
37
37
  __exportStar(require("./zauru/zauru-lotes.js"), exports);
38
38
  __exportStar(require("./zauru/zauru-motivos-rechazo.js"), exports);
39
39
  __exportStar(require("./zauru/zauru-payees.js"), exports);
40
+ __exportStar(require("./zauru/zauru-payments.js"), exports);
40
41
  __exportStar(require("./zauru/zauru-payment-terms.js"), exports);
42
+ __exportStar(require("./zauru/zauru-payment-method.js"), exports);
41
43
  __exportStar(require("./zauru/zauru-price-lists.js"), exports);
42
44
  __exportStar(require("./zauru/zauru-print-templates.js"), exports);
43
45
  __exportStar(require("./zauru/zauru-purchase-orders.js"), exports);
@@ -46,12 +46,13 @@ exports.getInvoicesByAgencyId = getInvoicesByAgencyId;
46
46
  * @param body
47
47
  * @returns
48
48
  */
49
- async function createInvoice(headers, body) {
49
+ async function createInvoice(headers, body, sujetaAImpuestos = true) {
50
50
  return (0, common_1.handlePossibleAxiosErrors)(async () => {
51
51
  const sendBody = {
52
52
  ...body,
53
53
  invoice_details_attributes: (0, common_1.arrayToObject)(body.invoice_details),
54
54
  tag_ids: ["", ...(body.tagging_invoices?.map((x) => x.tag_id) ?? [])],
55
+ taxable: sujetaAImpuestos,
55
56
  };
56
57
  if (sendBody.deleted_invoice_details)
57
58
  delete sendBody.deleted_invoice_details;
@@ -61,7 +62,6 @@ async function createInvoice(headers, body) {
61
62
  delete sendBody.invoice_details;
62
63
  if (sendBody.tagging_invoices)
63
64
  delete sendBody.tagging_invoices;
64
- console.log("ENVIANDO: ", JSON.stringify(sendBody));
65
65
  const response = await httpZauru_js_1.default.post(`/sales/unpaid_invoices.json`, { invoice: sendBody }, { headers });
66
66
  return response.data;
67
67
  });
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getPaymentMethods = void 0;
7
+ const common_1 = require("@zauru-sdk/common");
8
+ const common_js_1 = require("../common.js");
9
+ const httpGraphQL_js_1 = __importDefault(require("./httpGraphQL.js"));
10
+ const graphql_1 = require("@zauru-sdk/graphql");
11
+ /**
12
+ * getPaymentTerms
13
+ */
14
+ /**
15
+ * getPaymentTerms
16
+ */
17
+ async function getPaymentMethods(session, config = {
18
+ onlyActives: true,
19
+ }) {
20
+ return (0, common_1.handlePossibleAxiosErrors)(async () => {
21
+ const headers = await (0, common_js_1.getGraphQLAPIHeaders)(session);
22
+ console.log((0, graphql_1.getPaymentMethodsStringQuery)({
23
+ onlyActives: config.onlyActives,
24
+ }));
25
+ const response = await httpGraphQL_js_1.default.post("", {
26
+ query: (0, graphql_1.getPaymentMethodsStringQuery)({
27
+ onlyActives: config.onlyActives,
28
+ }),
29
+ }, { headers });
30
+ if (response.data.errors) {
31
+ throw new Error(response.data.errors.map((x) => x.message).join(";"));
32
+ }
33
+ const registers = response?.data?.data?.payment_methods;
34
+ return registers;
35
+ });
36
+ }
37
+ exports.getPaymentMethods = getPaymentMethods;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.createPayment = void 0;
7
+ const common_1 = require("@zauru-sdk/common");
8
+ const httpZauru_js_1 = __importDefault(require("./httpZauru.js"));
9
+ /**
10
+ * createInvoice
11
+ * @param headers
12
+ * @param body
13
+ * @returns
14
+ */
15
+ async function createPayment(headers, body) {
16
+ return (0, common_1.handlePossibleAxiosErrors)(async () => {
17
+ const sendBody = {
18
+ ...body,
19
+ payment_details_attributes: (0, common_1.arrayToObject)(body.payment_details),
20
+ tag_ids: ["", ...(body.tagging_payments?.map((x) => x.tag_id) ?? [])],
21
+ };
22
+ if (sendBody.deleted_payment_details)
23
+ delete sendBody.deleted_payment_details;
24
+ if (sendBody.__rvfInternalFormId)
25
+ delete sendBody.__rvfInternalFormId;
26
+ if (sendBody.payment_details)
27
+ delete sendBody.payment_details;
28
+ if (sendBody.tagging_payment)
29
+ delete sendBody.tagging_payment;
30
+ const response = await httpZauru_js_1.default.post(`/sales/payments.json`, { payment: sendBody }, { headers });
31
+ return response.data;
32
+ });
33
+ }
34
+ exports.createPayment = createPayment;
package/dist/esm/index.js CHANGED
@@ -21,7 +21,9 @@ export * from "./zauru/zauru-lote-record.js";
21
21
  export * from "./zauru/zauru-lotes.js";
22
22
  export * from "./zauru/zauru-motivos-rechazo.js";
23
23
  export * from "./zauru/zauru-payees.js";
24
+ export * from "./zauru/zauru-payments.js";
24
25
  export * from "./zauru/zauru-payment-terms.js";
26
+ export * from "./zauru/zauru-payment-method.js";
25
27
  export * from "./zauru/zauru-price-lists.js";
26
28
  export * from "./zauru/zauru-print-templates.js";
27
29
  export * from "./zauru/zauru-purchase-orders.js";
@@ -39,12 +39,13 @@ export async function getInvoicesByAgencyId(session, id) {
39
39
  * @param body
40
40
  * @returns
41
41
  */
42
- export async function createInvoice(headers, body) {
42
+ export async function createInvoice(headers, body, sujetaAImpuestos = true) {
43
43
  return handlePossibleAxiosErrors(async () => {
44
44
  const sendBody = {
45
45
  ...body,
46
46
  invoice_details_attributes: arrayToObject(body.invoice_details),
47
47
  tag_ids: ["", ...(body.tagging_invoices?.map((x) => x.tag_id) ?? [])],
48
+ taxable: sujetaAImpuestos,
48
49
  };
49
50
  if (sendBody.deleted_invoice_details)
50
51
  delete sendBody.deleted_invoice_details;
@@ -54,7 +55,6 @@ export async function createInvoice(headers, body) {
54
55
  delete sendBody.invoice_details;
55
56
  if (sendBody.tagging_invoices)
56
57
  delete sendBody.tagging_invoices;
57
- console.log("ENVIANDO: ", JSON.stringify(sendBody));
58
58
  const response = await httpZauru.post(`/sales/unpaid_invoices.json`, { invoice: sendBody }, { headers });
59
59
  return response.data;
60
60
  });
@@ -0,0 +1,30 @@
1
+ import { handlePossibleAxiosErrors } from "@zauru-sdk/common";
2
+ import { getGraphQLAPIHeaders } from "../common.js";
3
+ import httpGraphQLAPI from "./httpGraphQL.js";
4
+ import { getPaymentMethodsStringQuery } from "@zauru-sdk/graphql";
5
+ /**
6
+ * getPaymentTerms
7
+ */
8
+ /**
9
+ * getPaymentTerms
10
+ */
11
+ export async function getPaymentMethods(session, config = {
12
+ onlyActives: true,
13
+ }) {
14
+ return handlePossibleAxiosErrors(async () => {
15
+ const headers = await getGraphQLAPIHeaders(session);
16
+ console.log(getPaymentMethodsStringQuery({
17
+ onlyActives: config.onlyActives,
18
+ }));
19
+ const response = await httpGraphQLAPI.post("", {
20
+ query: getPaymentMethodsStringQuery({
21
+ onlyActives: config.onlyActives,
22
+ }),
23
+ }, { headers });
24
+ if (response.data.errors) {
25
+ throw new Error(response.data.errors.map((x) => x.message).join(";"));
26
+ }
27
+ const registers = response?.data?.data?.payment_methods;
28
+ return registers;
29
+ });
30
+ }
@@ -0,0 +1,27 @@
1
+ import { arrayToObject, handlePossibleAxiosErrors } from "@zauru-sdk/common";
2
+ import httpZauru from "./httpZauru.js";
3
+ /**
4
+ * createInvoice
5
+ * @param headers
6
+ * @param body
7
+ * @returns
8
+ */
9
+ export async function createPayment(headers, body) {
10
+ return handlePossibleAxiosErrors(async () => {
11
+ const sendBody = {
12
+ ...body,
13
+ payment_details_attributes: arrayToObject(body.payment_details),
14
+ tag_ids: ["", ...(body.tagging_payments?.map((x) => x.tag_id) ?? [])],
15
+ };
16
+ if (sendBody.deleted_payment_details)
17
+ delete sendBody.deleted_payment_details;
18
+ if (sendBody.__rvfInternalFormId)
19
+ delete sendBody.__rvfInternalFormId;
20
+ if (sendBody.payment_details)
21
+ delete sendBody.payment_details;
22
+ if (sendBody.tagging_payment)
23
+ delete sendBody.tagging_payment;
24
+ const response = await httpZauru.post(`/sales/payments.json`, { payment: sendBody }, { headers });
25
+ return response.data;
26
+ });
27
+ }
package/dist/index.d.ts CHANGED
@@ -21,7 +21,9 @@ export * from "./zauru/zauru-lote-record.js";
21
21
  export * from "./zauru/zauru-lotes.js";
22
22
  export * from "./zauru/zauru-motivos-rechazo.js";
23
23
  export * from "./zauru/zauru-payees.js";
24
+ export * from "./zauru/zauru-payments.js";
24
25
  export * from "./zauru/zauru-payment-terms.js";
26
+ export * from "./zauru/zauru-payment-method.js";
25
27
  export * from "./zauru/zauru-price-lists.js";
26
28
  export * from "./zauru/zauru-print-templates.js";
27
29
  export * from "./zauru/zauru-purchase-orders.js";
@@ -10,7 +10,7 @@ export declare function getInvoicesByAgencyId(session: Session, id: string | nul
10
10
  * @param body
11
11
  * @returns
12
12
  */
13
- export declare function createInvoice(headers: any, body: Partial<InvoiceGraphQL>): Promise<AxiosUtilsResponse<InvoiceGraphQL>>;
13
+ export declare function createInvoice(headers: any, body: Partial<InvoiceGraphQL>, sujetaAImpuestos?: boolean): Promise<AxiosUtilsResponse<InvoiceGraphQL>>;
14
14
  /**
15
15
  * createInvoiceOrder
16
16
  * @param headers
@@ -0,0 +1,11 @@
1
+ import type { Session } from "@remix-run/node";
2
+ import { AxiosUtilsResponse, PaymentMethodGraphQL } from "@zauru-sdk/types";
3
+ /**
4
+ * getPaymentTerms
5
+ */
6
+ /**
7
+ * getPaymentTerms
8
+ */
9
+ export declare function getPaymentMethods(session: Session, config?: {
10
+ onlyActives: boolean;
11
+ }): Promise<AxiosUtilsResponse<PaymentMethodGraphQL[]>>;
@@ -0,0 +1,8 @@
1
+ import { AxiosUtilsResponse, PaymentGraphQL } from "@zauru-sdk/types";
2
+ /**
3
+ * createInvoice
4
+ * @param headers
5
+ * @param body
6
+ * @returns
7
+ */
8
+ export declare function createPayment(headers: any, body: Partial<PaymentGraphQL>): Promise<AxiosUtilsResponse<PaymentGraphQL>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zauru-sdk/services",
3
- "version": "1.0.80",
3
+ "version": "1.0.82",
4
4
  "description": "Servicios de consulta a Zauru",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",
@@ -25,12 +25,12 @@
25
25
  },
26
26
  "dependencies": {
27
27
  "@remix-run/node": "^2.8.1",
28
- "@zauru-sdk/common": "^1.0.80",
28
+ "@zauru-sdk/common": "^1.0.82",
29
29
  "@zauru-sdk/config": "^1.0.60",
30
- "@zauru-sdk/graphql": "^1.0.79",
31
- "@zauru-sdk/types": "^1.0.76",
30
+ "@zauru-sdk/graphql": "^1.0.81",
31
+ "@zauru-sdk/types": "^1.0.82",
32
32
  "axios": "^1.6.7",
33
33
  "chalk": "5.3.0"
34
34
  },
35
- "gitHead": "3da2a589e254d04992e8c76924142f4b5f7c54b6"
35
+ "gitHead": "c48744ed8b74b9e9bcab1e20e2a71391b15d281f"
36
36
  }