@zauru-sdk/graphql 2.25.0 → 2.25.3

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.
@@ -6,8 +6,8 @@ export declare const getPurchaseOrderStringQuery: (id: number, config?: {
6
6
  withReceptions: boolean;
7
7
  }) => string;
8
8
  export declare const getShipmentsStringQuery: ({ agency_to_id, agency_from_id, suffix, voided, delivered, shipped, returned, id_number_not_null, id_number, id_number_not_empty, withMovementLots, withPurchaseOrdersByShipmentReference, limit, id, wheres, memoILike, plannedShippingDateRange, plannedDeliveryDateRange, }: {
9
- agency_to_id?: number;
10
- agency_from_id?: number;
9
+ agency_to_id?: number | number[];
10
+ agency_from_id?: number | number[];
11
11
  suffix?: string;
12
12
  id_number_not_null?: boolean;
13
13
  voided?: boolean;
@@ -201,23 +201,34 @@ 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
- conditions.push(`agency_to_id: {_eq: ${agency_to_id}}`);
205
+ if (Array.isArray(agency_to_id)) {
206
+ conditions.push(`agency_to_id: {_in: [${agency_to_id.join(", ")}]}`);
207
+ }
208
+ else {
209
+ conditions.push(`agency_to_id: {_eq: ${agency_to_id}}`);
210
+ }
209
211
  }
210
212
  if (agency_from_id) {
211
- conditions.push(`agency_from_id: {_eq: ${agency_from_id}}`);
212
- }
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: ""}`);
213
+ if (Array.isArray(agency_from_id)) {
214
+ conditions.push(`agency_from_id: {_in: [${agency_from_id.join(", ")}]}`);
215
+ }
216
+ else {
217
+ conditions.push(`agency_from_id: {_eq: ${agency_from_id}}`);
218
+ }
218
219
  }
219
- if (id_number_not_null) {
220
- conditions.push(`id_number: {_is_null: false}`);
220
+ // Merge all id_number conditions into a single object to avoid duplicate keys
221
+ const idNumberConditions = [];
222
+ if (suffix)
223
+ idNumberConditions.push(`_ilike: "%${suffix}%"`);
224
+ if (id_number)
225
+ idNumberConditions.push(`_eq: "${id_number}"`);
226
+ if (id_number_not_empty)
227
+ idNumberConditions.push(`_neq: ""`);
228
+ if (id_number_not_null)
229
+ idNumberConditions.push(`_is_null: false`);
230
+ if (idNumberConditions.length > 0) {
231
+ conditions.push(`id_number: { ${idNumberConditions.join(", ")} }`);
221
232
  }
222
233
  if (id) {
223
234
  conditions.push(`id: {_eq: ${id}}`);
@@ -398,7 +409,8 @@ const getPurchaseOrdersBetweenDatesStringQuery = (startDate, endDate, config) =>
398
409
  if (config.agencyNameIlike) {
399
410
  conditions.push(`agency: { name: { _ilike: "%${config.agencyNameIlike}%" } }`);
400
411
  }
401
- if (config.payeeId || config.payeeCategoryId) {
412
+ // Merge all payee conditions to avoid duplicate keys
413
+ {
402
414
  const payeeConditions = [];
403
415
  if (config.payeeId) {
404
416
  if (config.payeeId.toString().includes(",")) {
@@ -408,19 +420,40 @@ const getPurchaseOrdersBetweenDatesStringQuery = (startDate, endDate, config) =>
408
420
  payeeConditions.push(`id: { _eq: ${config.payeeId} }`);
409
421
  }
410
422
  }
423
+ const payeeCategoryIdConditions = [];
411
424
  if (config.payeeCategoryId) {
412
- payeeConditions.push(`payee_category: { id: { _eq: ${config.payeeCategoryId} } }`);
425
+ payeeCategoryIdConditions.push(`_eq: ${config.payeeCategoryId}`);
426
+ }
427
+ if (config.payeeCategoryIds && config.payeeCategoryIds.length > 0) {
428
+ payeeCategoryIdConditions.push(`_in: [${config.payeeCategoryIds.join(",")}]`);
429
+ }
430
+ if (config.excludePayeeCategoryIds &&
431
+ config.excludePayeeCategoryIds.length > 0) {
432
+ payeeCategoryIdConditions.push(`_nin: [${config.excludePayeeCategoryIds.join(",")}]`);
433
+ }
434
+ if (payeeCategoryIdConditions.length > 0) {
435
+ payeeConditions.push(`payee_category: { id: { ${payeeCategoryIdConditions.join(", ")} } }`);
436
+ }
437
+ if (payeeConditions.length > 0) {
438
+ conditions.push(`payee: { ${payeeConditions.join(", ")} }`);
413
439
  }
414
- conditions.push(`payee: { ${payeeConditions.join(", ")} }`);
415
440
  }
441
+ // Merge all purchase_order_details conditions to avoid duplicate keys
442
+ const purchaseOrderDetailsConditions = [];
416
443
  if (config.itemId) {
417
444
  if (config.itemId.toString().includes(",")) {
418
- conditions.push(`purchase_order_details: { item_id: { _in: [${config.itemId}] } }`);
445
+ purchaseOrderDetailsConditions.push(`item_id: { _in: [${config.itemId}] }`);
419
446
  }
420
447
  else {
421
- conditions.push(`purchase_order_details: { item_id: { _eq: ${config.itemId} } }`);
448
+ purchaseOrderDetailsConditions.push(`item_id: { _eq: ${config.itemId} }`);
422
449
  }
423
450
  }
451
+ if (config.poDetailTagId) {
452
+ purchaseOrderDetailsConditions.push(`tag_id: { _eq: ${config.poDetailTagId} }`);
453
+ }
454
+ if (purchaseOrderDetailsConditions.length > 0) {
455
+ conditions.push(`purchase_order_details: { ${purchaseOrderDetailsConditions.join(", ")} }`);
456
+ }
424
457
  if (config.reference) {
425
458
  if (config.reference.toString().includes(",")) {
426
459
  conditions.push(`reference: { _in: [${config.reference}] }`);
@@ -432,21 +465,11 @@ const getPurchaseOrdersBetweenDatesStringQuery = (startDate, endDate, config) =>
432
465
  if (config.lotItemIdExclusion) {
433
466
  conditions.push(`lots: { item_id: { _neq: ${config.lotItemIdExclusion} } }`);
434
467
  }
435
- if (config.poDetailTagId) {
436
- conditions.push(`purchase_order_details: { tag_id: { _eq: ${config.poDetailTagId} } }`);
437
- }
438
468
  if (!config.id_number && !config.ids?.length) {
439
469
  conditions.push(config.betweenIssueDate
440
470
  ? `issue_date: { _gte: "${startDate}", _lte: "${endDate}" }`
441
471
  : `created_at: { _gte: "${startDate}", _lte: "${endDate}"}`);
442
472
  }
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
473
  if (!!config.discountComparisonOperator && !!config.discount) {
451
474
  conditions.push(`discount: { ${config.discountComparisonOperator}: ${config.discount} }`);
452
475
  }
@@ -1218,11 +1241,17 @@ query getInvoiceFormSubmissionsByAgencyId {
1218
1241
  id_number: { _ilike: "%${filters?.payee_id_number_search}%"}
1219
1242
  },`
1220
1243
  : ""}
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(",")}]}}`
1244
+ ${filters?.item_ids?.length || filters?.bundle_ids?.length
1245
+ ? `invoice_details: {${[
1246
+ filters?.item_ids?.length
1247
+ ? `item_id: {_in: [${filters?.item_ids?.join(",")}]}`
1248
+ : "",
1249
+ filters?.bundle_ids?.length
1250
+ ? `bundle_id: {_in: [${filters?.bundle_ids?.join(",")}]}`
1251
+ : "",
1252
+ ]
1253
+ .filter(Boolean)
1254
+ .join(", ")}}`
1226
1255
  : ""}
1227
1256
  voided: {_eq: false}
1228
1257
  }
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.3",
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": "3ca3fc59312bd6aaba6ec2112f028d21a1bb0bab"
25
25
  }