@zauru-sdk/services 1.0.68 → 1.0.69

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.
@@ -168,10 +168,12 @@ exports.getMyAgencyLotStocks = getMyAgencyLotStocks;
168
168
  * @returns
169
169
  */
170
170
  async function updateLote(headers, lot_id, updatedData) {
171
- const response = await httpZauru_js_1.default.patch(`/inventories/lots/${lot_id}.json`, updatedData, {
172
- headers,
171
+ return (0, common_1.handlePossibleAxiosErrors)(async () => {
172
+ const response = await httpZauru_js_1.default.patch(`/inventories/lots/${lot_id}.json`, updatedData, {
173
+ headers,
174
+ });
175
+ return response.data;
173
176
  });
174
- return response.data;
175
177
  }
176
178
  exports.updateLote = updateLote;
177
179
  /**
@@ -3,9 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getPurchasesOrderByIdNumber = exports.deletePurchaseOrder = exports.getGraphQLPurchaseOrderBetweenDates = exports.getPurchaseOrder = exports.getLast100Receptions = exports.updateReceivedPurchaseOrder = exports.updatePurchaseOrder = exports.enablePurchase = exports.getPurchase = exports.getPurchasesList = exports.getPurchasesListDataTables = exports.getNewPurchaseOrderInfo = exports.receivePurchaseOrder = exports.receiveLotPurchaseOrder = exports.createNewAuthorizedPurchaseOrder = exports.createNewPurchaseOrder = exports.markAsReceivePartialPurchaseOrder = exports.markAsReceivePurchaseOrder = void 0;
6
+ exports.getPurchasesOrderByIdNumber = exports.deletePurchaseOrder = exports.getGraphQLPurchaseOrderBetweenDates = exports.getPurchaseOrder = exports.getLast100Receptions = exports.updateReceivedPurchaseOrder = exports.updatePurchaseOrder = exports.enablePurchase = exports.getPurchase = exports.getPurchasesList = exports.getPurchasesListDataTables = exports.getNewPurchaseOrderInfo = exports.receivePurchaseOrder = exports.receiveLotPurchaseOrder = exports.createNewAuthorizedPurchaseOrder = exports.createNewPurchaseOrder = exports.markAsReceivePurchaseOrder = void 0;
7
7
  const common_1 = require("@zauru-sdk/common");
8
- const zauru_receptions_js_1 = require("./zauru-receptions.js");
9
8
  const httpZauru_js_1 = __importDefault(require("./httpZauru.js"));
10
9
  const common_js_1 = require("../common.js");
11
10
  const httpGraphQL_js_1 = __importDefault(require("./httpGraphQL.js"));
@@ -31,25 +30,6 @@ const markAsReceivePurchaseOrder = (headers, body) => {
31
30
  });
32
31
  };
33
32
  exports.markAsReceivePurchaseOrder = markAsReceivePurchaseOrder;
34
- /**
35
- * markAsReceivePartialPurchaseOrder
36
- * @param headers
37
- * @param body
38
- * @returns
39
- */
40
- const markAsReceivePartialPurchaseOrder = (headers, session, body) => {
41
- return (0, common_1.handlePossibleAxiosErrors)(async () => {
42
- const sendBody = { ...body };
43
- if (sendBody.fechaVencimiento) {
44
- await (0, zauru_receptions_js_1.createNewLotPurchaseOrderReception)(headers, session, sendBody);
45
- }
46
- else {
47
- await (0, zauru_receptions_js_1.createNewPurchaseOrderReception)(headers, session, body);
48
- }
49
- return true;
50
- });
51
- };
52
- exports.markAsReceivePartialPurchaseOrder = markAsReceivePartialPurchaseOrder;
53
33
  /**
54
34
  *
55
35
  * @param headers
@@ -365,24 +345,24 @@ const getGraphQLPurchaseOrderBetweenDates = (session, dates, config = {
365
345
  itemId: config.itemId,
366
346
  payeeCategoryId: config.payeeCategoryId,
367
347
  betweenIssueDate: config.betweenIssueDate,
348
+ id_number: config.id_number,
368
349
  });
369
350
  const variables = {
370
- ...(config.lotItemIdExclusion
371
- ? { lotItemIdExclusion: config.lotItemIdExclusion }
372
- : {}),
373
- ...(config.poDetailTagId ? { poDetailTagId: config.poDetailTagId } : {}),
374
351
  startDate: (0, common_1.formatDateToUTC)(dates.startDate),
375
352
  endDate: (0, common_1.formatDateToUTC)(dates.endDate),
376
353
  };
377
- const response = await httpGraphQL_js_1.default.post("", {
354
+ const graphQLBody = {
378
355
  query,
379
- variables,
380
- }, { headers });
356
+ };
357
+ if (!config.id_number) {
358
+ graphQLBody.variables = variables;
359
+ }
360
+ const response = await httpGraphQL_js_1.default.post("", graphQLBody, { headers });
381
361
  if (response.data.errors) {
382
362
  throw new Error(response.data.errors.map((x) => x.message).join(";"));
383
363
  }
384
364
  //============ Aplicación de filtros
385
- let responseData = [];
365
+ let responseData = response.data.data.purchase_orders;
386
366
  if (config.withShipmentToMyAgency) {
387
367
  responseData = response.data?.data?.purchase_orders.filter((x) => x.shipment_purchase_orders.some((y) => y.shipment.agency_to_id?.toString() == session.get("agency_id")));
388
368
  }
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createNewLotPurchaseOrderReception = exports.createNewPurchaseOrderReception = exports.deleteReception = exports.createNewReception = void 0;
6
+ exports.createNewPurchaseOrderReception = exports.deleteReception = exports.createNewReception = void 0;
7
7
  const common_1 = require("@zauru-sdk/common");
8
8
  const httpZauru_js_1 = __importDefault(require("./httpZauru.js"));
9
9
  /**
@@ -48,16 +48,25 @@ async function createNewPurchaseOrderReception(headers, session, body) {
48
48
  memo: "LABORATORIO - Recibido parcialmente desde WebApp",
49
49
  purchase_order_id: body.id,
50
50
  needs_transit: false,
51
- agency_id: session.get("agency_id"),
52
- entity_id: session.get("selectedEntity"),
53
51
  received_at: (0, common_1.getDatePickerCurrentDate)(),
54
52
  invoice_number: "",
53
+ agency_id: session.get("agency_id"),
54
+ entity_id: session.get("selectedEntity"),
55
55
  reception_details_attributes: (0, common_1.arrayToObject)(body?.purchase_order_details?.map((x) => {
56
- return {
56
+ const temp = {
57
57
  item_id: x.item_id,
58
58
  purchase_order_detail_id: x.id,
59
- quantity: x.delivered_quantity,
60
59
  };
60
+ if (x.expire_date) {
61
+ temp.lot_delivered_quantity = [`${x.delivered_quantity}`];
62
+ temp.lot_name = [body.id_number];
63
+ temp.lot_expire = [x.expire_date];
64
+ temp.lot_description = [body.id_number];
65
+ }
66
+ else {
67
+ temp.quantity = x.delivered_quantity;
68
+ }
69
+ return temp;
61
70
  })),
62
71
  },
63
72
  purchase_order_id: body.id,
@@ -69,36 +78,3 @@ async function createNewPurchaseOrderReception(headers, session, body) {
69
78
  });
70
79
  }
71
80
  exports.createNewPurchaseOrderReception = createNewPurchaseOrderReception;
72
- /**
73
- *
74
- * @param headers
75
- * @param poId
76
- * @returns
77
- */
78
- async function createNewLotPurchaseOrderReception(headers, session, body) {
79
- return (0, common_1.handlePossibleAxiosErrors)(async () => {
80
- const sendBody = {
81
- memo: "LABORATORIO - Recibido parcialmente desde WebApp",
82
- purchase_order_id: body.id,
83
- needs_transit: false,
84
- received_at: (0, common_1.getDatePickerCurrentDate)(),
85
- invoice_number: "",
86
- agency_id: session.get("agency_id"),
87
- entity_id: session.get("selectedEntity"),
88
- reception_details_attributes: (0, common_1.arrayToObject)(body?.purchase_order_details?.map((x) => {
89
- return {
90
- item_id: x.item_id,
91
- purchase_order_detail_id: x.id,
92
- lot_delivered_quantity: [x.delivered_quantity],
93
- lot_name: [body.id_number],
94
- lot_expire: [body.fechaVencimiento],
95
- };
96
- })),
97
- };
98
- await httpZauru_js_1.default.post(`/purchases/purchase_orders/${body.id}/receptions.json`, { reception: sendBody, purchase_order_id: body.id }, {
99
- headers,
100
- });
101
- return true;
102
- });
103
- }
104
- exports.createNewLotPurchaseOrderReception = createNewLotPurchaseOrderReception;
@@ -156,10 +156,12 @@ export async function getMyAgencyLotStocks(session) {
156
156
  * @returns
157
157
  */
158
158
  export async function updateLote(headers, lot_id, updatedData) {
159
- const response = await httpZauru.patch(`/inventories/lots/${lot_id}.json`, updatedData, {
160
- headers,
159
+ return handlePossibleAxiosErrors(async () => {
160
+ const response = await httpZauru.patch(`/inventories/lots/${lot_id}.json`, updatedData, {
161
+ headers,
162
+ });
163
+ return response.data;
161
164
  });
162
- return response.data;
163
165
  }
164
166
  /**
165
167
  * getLotesExportJSON Function for get all zauru lotes by id_agencia
@@ -1,5 +1,4 @@
1
1
  import { arrayToObject, convertToFormData, formatDateToUTC, getBasketsSchema, handlePossibleAxiosErrors, reduceAdd, } from "@zauru-sdk/common";
2
- import { createNewLotPurchaseOrderReception, createNewPurchaseOrderReception, } from "./zauru-receptions.js";
3
2
  import httpZauru from "./httpZauru.js";
4
3
  import { getGraphQLAPIHeaders, getVariablesByName } from "../common.js";
5
4
  import httpGraphQLAPI from "./httpGraphQL.js";
@@ -24,24 +23,6 @@ export const markAsReceivePurchaseOrder = (headers, body) => {
24
23
  return true;
25
24
  });
26
25
  };
27
- /**
28
- * markAsReceivePartialPurchaseOrder
29
- * @param headers
30
- * @param body
31
- * @returns
32
- */
33
- export const markAsReceivePartialPurchaseOrder = (headers, session, body) => {
34
- return handlePossibleAxiosErrors(async () => {
35
- const sendBody = { ...body };
36
- if (sendBody.fechaVencimiento) {
37
- await createNewLotPurchaseOrderReception(headers, session, sendBody);
38
- }
39
- else {
40
- await createNewPurchaseOrderReception(headers, session, body);
41
- }
42
- return true;
43
- });
44
- };
45
26
  /**
46
27
  *
47
28
  * @param headers
@@ -344,24 +325,24 @@ export const getGraphQLPurchaseOrderBetweenDates = (session, dates, config = {
344
325
  itemId: config.itemId,
345
326
  payeeCategoryId: config.payeeCategoryId,
346
327
  betweenIssueDate: config.betweenIssueDate,
328
+ id_number: config.id_number,
347
329
  });
348
330
  const variables = {
349
- ...(config.lotItemIdExclusion
350
- ? { lotItemIdExclusion: config.lotItemIdExclusion }
351
- : {}),
352
- ...(config.poDetailTagId ? { poDetailTagId: config.poDetailTagId } : {}),
353
331
  startDate: formatDateToUTC(dates.startDate),
354
332
  endDate: formatDateToUTC(dates.endDate),
355
333
  };
356
- const response = await httpGraphQLAPI.post("", {
334
+ const graphQLBody = {
357
335
  query,
358
- variables,
359
- }, { headers });
336
+ };
337
+ if (!config.id_number) {
338
+ graphQLBody.variables = variables;
339
+ }
340
+ const response = await httpGraphQLAPI.post("", graphQLBody, { headers });
360
341
  if (response.data.errors) {
361
342
  throw new Error(response.data.errors.map((x) => x.message).join(";"));
362
343
  }
363
344
  //============ Aplicación de filtros
364
- let responseData = [];
345
+ let responseData = response.data.data.purchase_orders;
365
346
  if (config.withShipmentToMyAgency) {
366
347
  responseData = response.data?.data?.purchase_orders.filter((x) => x.shipment_purchase_orders.some((y) => y.shipment.agency_to_id?.toString() == session.get("agency_id")));
367
348
  }
@@ -40,16 +40,25 @@ export async function createNewPurchaseOrderReception(headers, session, body) {
40
40
  memo: "LABORATORIO - Recibido parcialmente desde WebApp",
41
41
  purchase_order_id: body.id,
42
42
  needs_transit: false,
43
- agency_id: session.get("agency_id"),
44
- entity_id: session.get("selectedEntity"),
45
43
  received_at: getDatePickerCurrentDate(),
46
44
  invoice_number: "",
45
+ agency_id: session.get("agency_id"),
46
+ entity_id: session.get("selectedEntity"),
47
47
  reception_details_attributes: arrayToObject(body?.purchase_order_details?.map((x) => {
48
- return {
48
+ const temp = {
49
49
  item_id: x.item_id,
50
50
  purchase_order_detail_id: x.id,
51
- quantity: x.delivered_quantity,
52
51
  };
52
+ if (x.expire_date) {
53
+ temp.lot_delivered_quantity = [`${x.delivered_quantity}`];
54
+ temp.lot_name = [body.id_number];
55
+ temp.lot_expire = [x.expire_date];
56
+ temp.lot_description = [body.id_number];
57
+ }
58
+ else {
59
+ temp.quantity = x.delivered_quantity;
60
+ }
61
+ return temp;
53
62
  })),
54
63
  },
55
64
  purchase_order_id: body.id,
@@ -60,35 +69,3 @@ export async function createNewPurchaseOrderReception(headers, session, body) {
60
69
  return true;
61
70
  });
62
71
  }
63
- /**
64
- *
65
- * @param headers
66
- * @param poId
67
- * @returns
68
- */
69
- export async function createNewLotPurchaseOrderReception(headers, session, body) {
70
- return handlePossibleAxiosErrors(async () => {
71
- const sendBody = {
72
- memo: "LABORATORIO - Recibido parcialmente desde WebApp",
73
- purchase_order_id: body.id,
74
- needs_transit: false,
75
- received_at: getDatePickerCurrentDate(),
76
- invoice_number: "",
77
- agency_id: session.get("agency_id"),
78
- entity_id: session.get("selectedEntity"),
79
- reception_details_attributes: arrayToObject(body?.purchase_order_details?.map((x) => {
80
- return {
81
- item_id: x.item_id,
82
- purchase_order_detail_id: x.id,
83
- lot_delivered_quantity: [x.delivered_quantity],
84
- lot_name: [body.id_number],
85
- lot_expire: [body.fechaVencimiento],
86
- };
87
- })),
88
- };
89
- await httpZauru.post(`/purchases/purchase_orders/${body.id}/receptions.json`, { reception: sendBody, purchase_order_id: body.id }, {
90
- headers,
91
- });
92
- return true;
93
- });
94
- }
@@ -53,7 +53,7 @@ export declare function getMyAgencyLotStocks(session: Session): Promise<AxiosUti
53
53
  * @param agency_id
54
54
  * @returns
55
55
  */
56
- export declare function updateLote(headers: any, lot_id: number, updatedData: UpdateLoteBody): Promise<any>;
56
+ export declare function updateLote(headers: any, lot_id: number, updatedData: UpdateLoteBody): Promise<AxiosUtilsResponse<any>>;
57
57
  /**
58
58
  * getLotesExportJSON Function for get all zauru lotes by id_agencia
59
59
  * @param headers
@@ -11,15 +11,6 @@ import { AxiosUtilsResponse, BasketSchema, CreateNewPurchaseOrderBody, DataTable
11
11
  export declare const markAsReceivePurchaseOrder: (headers: any, body: Partial<PurchaseOrderGraphQL> & {
12
12
  fechaVencimiento?: string;
13
13
  }) => Promise<AxiosUtilsResponse<boolean>>;
14
- /**
15
- * markAsReceivePartialPurchaseOrder
16
- * @param headers
17
- * @param body
18
- * @returns
19
- */
20
- export declare const markAsReceivePartialPurchaseOrder: (headers: any, session: Session, body: Partial<PurchaseOrderGraphQL> & {
21
- fechaVencimiento?: string;
22
- }) => Promise<AxiosUtilsResponse<boolean>>;
23
14
  /**
24
15
  *
25
16
  * @param headers
@@ -135,6 +126,7 @@ export declare const getGraphQLPurchaseOrderBetweenDates: (session: Session, dat
135
126
  }, config?: {
136
127
  agencyFilter: boolean;
137
128
  agencyId?: number;
129
+ id_number?: string;
138
130
  useProductionAgencyId?: boolean;
139
131
  consolidateIdFilter?: boolean;
140
132
  lotItemIdExclusion?: number;
@@ -22,12 +22,3 @@ export declare function deleteReception(headers: any, receptionId: string | numb
22
22
  * @returns
23
23
  */
24
24
  export declare function createNewPurchaseOrderReception(headers: any, session: Session, body: Partial<PurchaseOrderGraphQL>): Promise<AxiosUtilsResponse<boolean>>;
25
- /**
26
- *
27
- * @param headers
28
- * @param poId
29
- * @returns
30
- */
31
- export declare function createNewLotPurchaseOrderReception(headers: any, session: Session, body: Partial<PurchaseOrderGraphQL> & {
32
- fechaVencimiento: string;
33
- }): Promise<AxiosUtilsResponse<boolean>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zauru-sdk/services",
3
- "version": "1.0.68",
3
+ "version": "1.0.69",
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.60",
28
+ "@zauru-sdk/common": "^1.0.69",
29
29
  "@zauru-sdk/config": "^1.0.60",
30
- "@zauru-sdk/graphql": "^1.0.68",
31
- "@zauru-sdk/types": "^1.0.60",
30
+ "@zauru-sdk/graphql": "^1.0.69",
31
+ "@zauru-sdk/types": "^1.0.69",
32
32
  "axios": "^1.6.7",
33
33
  "chalk": "5.3.0"
34
34
  },
35
- "gitHead": "907be35569dc738a582858bb47d96910ab5dcec3"
35
+ "gitHead": "46dd382e956e8b34c2a65ef078d8fddb2cdd434c"
36
36
  }