@zauru-sdk/graphql 2.25.0 → 2.25.2

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.
@@ -201,23 +201,24 @@ query getPurchaseOrder($id: bigint) @cached {
201
201
  exports.getPurchaseOrderStringQuery = getPurchaseOrderStringQuery;
202
202
  const getShipmentsStringQuery = ({ agency_to_id, agency_from_id, suffix, voided, delivered, shipped, returned, id_number_not_null = false, id_number, id_number_not_empty = false, withMovementLots = false, withPurchaseOrdersByShipmentReference = false, limit = 1000, id, wheres, memoILike, plannedShippingDateRange, plannedDeliveryDateRange, }) => {
203
203
  let conditions = [];
204
- if (suffix) {
205
- conditions.push(`id_number: {_ilike: "%${suffix}%"}`);
206
- }
207
204
  if (agency_to_id) {
208
205
  conditions.push(`agency_to_id: {_eq: ${agency_to_id}}`);
209
206
  }
210
207
  if (agency_from_id) {
211
208
  conditions.push(`agency_from_id: {_eq: ${agency_from_id}}`);
212
209
  }
213
- if (id_number) {
214
- conditions.push(`id_number: {_eq: "${id_number}"}`);
215
- }
216
- if (id_number_not_empty) {
217
- conditions.push(`id_number: {_neq: ""}`);
218
- }
219
- if (id_number_not_null) {
220
- conditions.push(`id_number: {_is_null: false}`);
210
+ // Merge all id_number conditions into a single object to avoid duplicate keys
211
+ const idNumberConditions = [];
212
+ if (suffix)
213
+ idNumberConditions.push(`_ilike: "%${suffix}%"`);
214
+ if (id_number)
215
+ idNumberConditions.push(`_eq: "${id_number}"`);
216
+ if (id_number_not_empty)
217
+ idNumberConditions.push(`_neq: ""`);
218
+ if (id_number_not_null)
219
+ idNumberConditions.push(`_is_null: false`);
220
+ if (idNumberConditions.length > 0) {
221
+ conditions.push(`id_number: { ${idNumberConditions.join(", ")} }`);
221
222
  }
222
223
  if (id) {
223
224
  conditions.push(`id: {_eq: ${id}}`);
@@ -398,7 +399,8 @@ const getPurchaseOrdersBetweenDatesStringQuery = (startDate, endDate, config) =>
398
399
  if (config.agencyNameIlike) {
399
400
  conditions.push(`agency: { name: { _ilike: "%${config.agencyNameIlike}%" } }`);
400
401
  }
401
- if (config.payeeId || config.payeeCategoryId) {
402
+ // Merge all payee conditions to avoid duplicate keys
403
+ {
402
404
  const payeeConditions = [];
403
405
  if (config.payeeId) {
404
406
  if (config.payeeId.toString().includes(",")) {
@@ -408,19 +410,40 @@ const getPurchaseOrdersBetweenDatesStringQuery = (startDate, endDate, config) =>
408
410
  payeeConditions.push(`id: { _eq: ${config.payeeId} }`);
409
411
  }
410
412
  }
413
+ const payeeCategoryIdConditions = [];
411
414
  if (config.payeeCategoryId) {
412
- payeeConditions.push(`payee_category: { id: { _eq: ${config.payeeCategoryId} } }`);
415
+ payeeCategoryIdConditions.push(`_eq: ${config.payeeCategoryId}`);
416
+ }
417
+ if (config.payeeCategoryIds && config.payeeCategoryIds.length > 0) {
418
+ payeeCategoryIdConditions.push(`_in: [${config.payeeCategoryIds.join(",")}]`);
419
+ }
420
+ if (config.excludePayeeCategoryIds &&
421
+ config.excludePayeeCategoryIds.length > 0) {
422
+ payeeCategoryIdConditions.push(`_nin: [${config.excludePayeeCategoryIds.join(",")}]`);
423
+ }
424
+ if (payeeCategoryIdConditions.length > 0) {
425
+ payeeConditions.push(`payee_category: { id: { ${payeeCategoryIdConditions.join(", ")} } }`);
426
+ }
427
+ if (payeeConditions.length > 0) {
428
+ conditions.push(`payee: { ${payeeConditions.join(", ")} }`);
413
429
  }
414
- conditions.push(`payee: { ${payeeConditions.join(", ")} }`);
415
430
  }
431
+ // Merge all purchase_order_details conditions to avoid duplicate keys
432
+ const purchaseOrderDetailsConditions = [];
416
433
  if (config.itemId) {
417
434
  if (config.itemId.toString().includes(",")) {
418
- conditions.push(`purchase_order_details: { item_id: { _in: [${config.itemId}] } }`);
435
+ purchaseOrderDetailsConditions.push(`item_id: { _in: [${config.itemId}] }`);
419
436
  }
420
437
  else {
421
- conditions.push(`purchase_order_details: { item_id: { _eq: ${config.itemId} } }`);
438
+ purchaseOrderDetailsConditions.push(`item_id: { _eq: ${config.itemId} }`);
422
439
  }
423
440
  }
441
+ if (config.poDetailTagId) {
442
+ purchaseOrderDetailsConditions.push(`tag_id: { _eq: ${config.poDetailTagId} }`);
443
+ }
444
+ if (purchaseOrderDetailsConditions.length > 0) {
445
+ conditions.push(`purchase_order_details: { ${purchaseOrderDetailsConditions.join(", ")} }`);
446
+ }
424
447
  if (config.reference) {
425
448
  if (config.reference.toString().includes(",")) {
426
449
  conditions.push(`reference: { _in: [${config.reference}] }`);
@@ -432,21 +455,11 @@ const getPurchaseOrdersBetweenDatesStringQuery = (startDate, endDate, config) =>
432
455
  if (config.lotItemIdExclusion) {
433
456
  conditions.push(`lots: { item_id: { _neq: ${config.lotItemIdExclusion} } }`);
434
457
  }
435
- if (config.poDetailTagId) {
436
- conditions.push(`purchase_order_details: { tag_id: { _eq: ${config.poDetailTagId} } }`);
437
- }
438
458
  if (!config.id_number && !config.ids?.length) {
439
459
  conditions.push(config.betweenIssueDate
440
460
  ? `issue_date: { _gte: "${startDate}", _lte: "${endDate}" }`
441
461
  : `created_at: { _gte: "${startDate}", _lte: "${endDate}"}`);
442
462
  }
443
- if (config.payeeCategoryIds && config.payeeCategoryIds.length > 0) {
444
- conditions.push(`payee: { payee_category: { id: { _in: [${config.payeeCategoryIds.join(",")}] } } }`);
445
- }
446
- if (config.excludePayeeCategoryIds &&
447
- config.excludePayeeCategoryIds.length > 0) {
448
- conditions.push(`payee: { payee_category: { id: { _nin: [${config.excludePayeeCategoryIds.join(",")}] } } }`);
449
- }
450
463
  if (!!config.discountComparisonOperator && !!config.discount) {
451
464
  conditions.push(`discount: { ${config.discountComparisonOperator}: ${config.discount} }`);
452
465
  }
@@ -1218,11 +1231,17 @@ query getInvoiceFormSubmissionsByAgencyId {
1218
1231
  id_number: { _ilike: "%${filters?.payee_id_number_search}%"}
1219
1232
  },`
1220
1233
  : ""}
1221
- ${filters?.item_ids?.length
1222
- ? `invoice_details: {item_id: {_in: [${filters?.item_ids?.join(",")}]}}`
1223
- : ""}
1224
- ${filters?.bundle_ids?.length
1225
- ? `invoice_details: {bundle_id: {_in: [${filters?.bundle_ids?.join(",")}]}}`
1234
+ ${filters?.item_ids?.length || filters?.bundle_ids?.length
1235
+ ? `invoice_details: {${[
1236
+ filters?.item_ids?.length
1237
+ ? `item_id: {_in: [${filters?.item_ids?.join(",")}]}`
1238
+ : "",
1239
+ filters?.bundle_ids?.length
1240
+ ? `bundle_id: {_in: [${filters?.bundle_ids?.join(",")}]}`
1241
+ : "",
1242
+ ]
1243
+ .filter(Boolean)
1244
+ .join(", ")}}`
1226
1245
  : ""}
1227
1246
  voided: {_eq: false}
1228
1247
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zauru-sdk/graphql",
3
- "version": "2.25.0",
3
+ "version": "2.25.2",
4
4
  "description": "Queries de uso común para las aplicación de Zauru.",
5
5
  "main": "./dist/esm/index.js",
6
6
  "module": "./dist/esm/index.js",
@@ -21,5 +21,5 @@
21
21
  "devDependencies": {
22
22
  "typescript": "^5.1.6"
23
23
  },
24
- "gitHead": "da550f653a8f3439364198939bb2fc1e3aeb2752"
24
+ "gitHead": "2cb51ed168e3e4df68625aecd1be63ff987977b3"
25
25
  }