@zauru-sdk/graphql 1.0.48 → 1.0.61

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.
@@ -1,207 +1,207 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getCasesByResponsibleIdStringQuery = exports.getInvoicesByAgencyIdStringQuery = exports.getPaymentTermByIdStringQuery = exports.getPaymentTermsStringQuery = exports.getSuggestedPricesStringQuery = exports.getCurrenciesStringQuery = exports.getInvoiceFormSubmissionsByInvoiceIdStringQuery = exports.getLastInvoiceFormSubmissionStringQuery = exports.getInvoiceFormSubmissionsByAgencyIdStringQuery = exports.getFormSubmissionByIdStringQuery = exports.getMyCaseFormSubmissionsStringQuery = exports.getFormsByDocumentTypeStringQuery = exports.getFormsStringQuery = exports.getFormByNameStringQuery = exports.getShipmentsStringQuery = exports.getItemByNameStringQuery = exports.getBundleByNameStringQuery = exports.getBundlesByItemCategoryIdStringQuery = exports.getEmployeesByAgencyIdStringQuery = exports.getEmployeeProfileStringQuery = exports.getConsolidatesBetweenDatesStringQuery = exports.getItemsBySuperCategoryStringQuery = exports.getItemsStringQuery = exports.getItemsByCategoryStringQuery = exports.getItemCategoryByIdStringQuery = exports.getSuperCategoryByIdStringQuery = exports.getPayeeByIdStringQuery = exports.getClientCategoriesStringQuery = exports.getProviderCategoriesStringQuery = exports.getPayeeCategoriesStringQuery = exports.getPayeeCategoriesByNotesMatchStringQuery = exports.getPayeeCategoryByIdStringQuery = exports.getWebAppRowsByWebAppTableIdStringQuery = exports.getWebAppRowStringQuery = exports.getAgenciesStringQuery = exports.getProvidersStringQuery = exports.getPayeesStringQuery = exports.getPurchaseOrdersBetweenDatesStringQuery = exports.getLotStocksByAgencyIdStringQuery = exports.getLotsByNameStringQuery = exports.getShipmentsByToAgencyLast100StringQuery = exports.getPurchaseOrderStringQuery = exports.getPurchaseOrderByIdNumberStringQuery = exports.getLast100ReceptionsStringQuery = void 0;
4
- exports.getLast100ReceptionsStringQuery = `
5
- query getLast100Receptions($agencyId: Int) @cached {
6
- purchase_orders(limit: 100, order_by: {created_at: desc}, where: {voided: {_eq: false}, agency_id: {_eq: $agencyId}}) {
7
- id
8
- created_at
9
- due
10
- id_number
11
- memo
12
- payee_id
13
- issue_date
14
- discount
15
- authorized
16
- received
17
- transport_type
18
- purchase_order_details {
19
- item_id
20
- id
21
- reference
22
- booked_quantity
23
- delivered_quantity
24
- }
25
- lots(where: {active: {_eq: true}}) {
26
- id
27
- name
28
- description
29
- item_id
30
- }
31
- }
32
- }
3
+ exports.getCasesByResponsibleIdStringQuery = exports.getInvoicesByAgencyIdStringQuery = exports.getPaymentTermByIdStringQuery = exports.getPaymentTermsStringQuery = exports.getSuggestedPricesStringQuery = exports.getCurrenciesStringQuery = exports.getInvoiceFormSubmissionsByInvoiceIdStringQuery = exports.getLastInvoiceFormSubmissionStringQuery = exports.getInvoiceFormSubmissionsByAgencyIdStringQuery = exports.getFormSubmissionByIdStringQuery = exports.getMyCaseFormSubmissionsStringQuery = exports.getFormsByDocumentTypeStringQuery = exports.getFormsStringQuery = exports.getFormByNameStringQuery = exports.getAllFormsStringQuery = exports.getShipmentsStringQuery = exports.getItemByNameStringQuery = exports.getBundleByNameStringQuery = exports.getBundlesByItemCategoryIdStringQuery = exports.getEmployeesByAgencyIdStringQuery = exports.getEmployeeProfileStringQuery = exports.getConsolidatesBetweenDatesStringQuery = exports.getItemsBySuperCategoryStringQuery = exports.getItemsStringQuery = exports.getItemsByCategoryStringQuery = exports.getItemCategoryByIdStringQuery = exports.getSuperCategoryByIdStringQuery = exports.getPayeeByIdStringQuery = exports.getClientCategoriesStringQuery = exports.getProviderCategoriesStringQuery = exports.getPayeeCategoriesStringQuery = exports.getPayeeCategoriesByNotesMatchStringQuery = exports.getPayeeCategoryByIdStringQuery = exports.getWebAppRowsByWebAppTableIdStringQuery = exports.getWebAppRowStringQuery = exports.getAgenciesStringQuery = exports.getProvidersStringQuery = exports.getPayeesStringQuery = exports.getPurchaseOrdersBetweenDatesStringQuery = exports.getLotStocksByAgencyIdStringQuery = exports.getLotsByNameStringQuery = exports.getShipmentsByToAgencyLast100StringQuery = exports.getPurchaseOrderStringQuery = exports.getPurchaseOrderByIdNumberStringQuery = exports.getLast100ReceptionsStringQuery = void 0;
4
+ exports.getLast100ReceptionsStringQuery = `
5
+ query getLast100Receptions($agencyId: Int) @cached {
6
+ purchase_orders(limit: 100, order_by: {created_at: desc}, where: {voided: {_eq: false}, agency_id: {_eq: $agencyId}}) {
7
+ id
8
+ created_at
9
+ due
10
+ id_number
11
+ memo
12
+ payee_id
13
+ issue_date
14
+ discount
15
+ authorized
16
+ received
17
+ transport_type
18
+ purchase_order_details {
19
+ item_id
20
+ id
21
+ reference
22
+ booked_quantity
23
+ delivered_quantity
24
+ }
25
+ lots(where: {active: {_eq: true}}) {
26
+ id
27
+ name
28
+ description
29
+ item_id
30
+ }
31
+ }
32
+ }
33
33
  `;
34
- exports.getPurchaseOrderByIdNumberStringQuery = `
35
- query getPurchaseOrderByIdNumber($id_number: String) @cached {
36
- purchase_orders(where: {id_number: {_eq: $id_number}}) {
37
- id
38
- created_at
39
- due
40
- id_number
41
- memo
42
- payee_id
43
- transport_type
44
- reference
45
- incoterm_destination
46
- issue_date
47
- voided
48
- received
49
- discount
50
- other_charges
51
- webapp_table_rowables {
52
- webapp_rows {
53
- data
54
- }
55
- }
56
- purchase_order_details {
57
- item_id
58
- id
59
- reference
60
- booked_quantity
61
- delivered_quantity
62
- }
63
- lots(where: {active: {_eq: true}}) {
64
- id
65
- description
66
- }
67
- receptions {
68
- id
69
- received
70
- voided
71
- }
72
- shipments {
73
- shipment_id
74
- }
75
- }
76
- }
34
+ exports.getPurchaseOrderByIdNumberStringQuery = `
35
+ query getPurchaseOrderByIdNumber($id_number: String) @cached {
36
+ purchase_orders(where: {id_number: {_eq: $id_number}}) {
37
+ id
38
+ created_at
39
+ due
40
+ id_number
41
+ memo
42
+ payee_id
43
+ transport_type
44
+ reference
45
+ incoterm_destination
46
+ issue_date
47
+ voided
48
+ received
49
+ discount
50
+ other_charges
51
+ webapp_table_rowables {
52
+ webapp_rows {
53
+ data
54
+ }
55
+ }
56
+ purchase_order_details {
57
+ item_id
58
+ id
59
+ reference
60
+ booked_quantity
61
+ delivered_quantity
62
+ }
63
+ lots(where: {active: {_eq: true}}) {
64
+ id
65
+ description
66
+ }
67
+ receptions {
68
+ id
69
+ received
70
+ voided
71
+ }
72
+ shipments {
73
+ shipment_id
74
+ }
75
+ }
76
+ }
77
77
  `;
78
- const getPurchaseOrderStringQuery = (config = { withLotStocks: false }) => `
79
- query getPurchaseOrder($id: Int) @cached {
80
- purchase_orders(where: {id: {_eq: $id}}) {
81
- id
82
- agency_id
83
- entity_id
84
- created_at
85
- due
86
- id_number
87
- memo
88
- payee_id
89
- transport_type
90
- reference
91
- incoterm_destination
92
- issue_date
93
- voided
94
- received
95
- discount
96
- delivery_date
97
- other_charges
98
- webapp_table_rowables {
99
- webapp_rows {
100
- data
101
- }
102
- }
103
- purchase_order_details {
104
- item_id
105
- id
106
- reference
107
- booked_quantity
108
- delivered_quantity
109
- item {
110
- name
111
- }
112
- }
113
- lots(where: {active: {_eq: true}}) {
114
- id
115
- name
116
- description
78
+ const getPurchaseOrderStringQuery = (config = { withLotStocks: false }) => `
79
+ query getPurchaseOrder($id: Int) @cached {
80
+ purchase_orders(where: {id: {_eq: $id}}) {
81
+ id
82
+ agency_id
83
+ entity_id
84
+ created_at
85
+ due
86
+ id_number
87
+ memo
88
+ payee_id
89
+ transport_type
90
+ reference
91
+ incoterm_destination
92
+ issue_date
93
+ voided
94
+ received
95
+ discount
96
+ delivery_date
97
+ other_charges
98
+ webapp_table_rowables {
99
+ webapp_rows {
100
+ data
101
+ }
102
+ }
103
+ purchase_order_details {
104
+ item_id
105
+ id
106
+ reference
107
+ booked_quantity
108
+ delivered_quantity
109
+ item {
110
+ name
111
+ }
112
+ }
113
+ lots(where: {active: {_eq: true}}) {
114
+ id
115
+ name
116
+ description
117
117
  ${config.withLotStocks
118
- ? `lot_stocks {
119
- id
120
- available
121
- incoming
122
- outgoing
123
- agency_id
118
+ ? `lot_stocks {
119
+ id
120
+ available
121
+ incoming
122
+ outgoing
123
+ agency_id
124
124
  }`
125
- : ""}
126
- }
127
- receptions {
128
- id
129
- received
130
- voided
131
- agency_id
132
- entity_id
133
- reception_details {
134
- purchase_order_detail_id
135
- item_id
136
- lot_delivered_quantity
137
- lot_description
138
- lot_expire
139
- lot_name
140
- }
141
- }
142
- shipment_purchase_orders {
143
- shipment_id
144
- }
145
- }
146
- }
125
+ : ""}
126
+ }
127
+ receptions {
128
+ id
129
+ received
130
+ voided
131
+ agency_id
132
+ entity_id
133
+ reception_details {
134
+ purchase_order_detail_id
135
+ item_id
136
+ lot_delivered_quantity
137
+ lot_description
138
+ lot_expire
139
+ lot_name
140
+ }
141
+ }
142
+ shipment_purchase_orders {
143
+ shipment_id
144
+ }
145
+ }
146
+ }
147
147
  `;
148
148
  exports.getPurchaseOrderStringQuery = getPurchaseOrderStringQuery;
149
- exports.getShipmentsByToAgencyLast100StringQuery = `
150
- query getShipmentsByToAgencyLast100(
151
- $agency_to_id: Int
152
- ){
153
- shipments(limit: 100, order_by: {id: desc}, where: {voided: {_eq: false}, shipped: {_eq: false}, delivered: {_eq: false}, agency_to_id: {_eq: $agency_to_id}}) {
154
- id
155
- zid
156
- id_number
157
- reference
158
- needs_transport
159
- payee_id
160
- income
161
- booker_id
162
- agency_from_id
163
- agency_to_id
164
- transporter_id
165
- created_at
166
- movements {
167
- id
168
- booked_quantity
169
- delivered_quantity
170
- reference
171
- lot {
172
- id
173
- name
174
- description
175
- }
176
- }
177
- }
178
- }
149
+ exports.getShipmentsByToAgencyLast100StringQuery = `
150
+ query getShipmentsByToAgencyLast100(
151
+ $agency_to_id: Int
152
+ ){
153
+ shipments(limit: 100, order_by: {id: desc}, where: {voided: {_eq: false}, shipped: {_eq: false}, delivered: {_eq: false}, agency_to_id: {_eq: $agency_to_id}}) {
154
+ id
155
+ zid
156
+ id_number
157
+ reference
158
+ needs_transport
159
+ payee_id
160
+ income
161
+ booker_id
162
+ agency_from_id
163
+ agency_to_id
164
+ transporter_id
165
+ created_at
166
+ movements {
167
+ id
168
+ booked_quantity
169
+ delivered_quantity
170
+ reference
171
+ lot {
172
+ id
173
+ name
174
+ description
175
+ }
176
+ }
177
+ }
178
+ }
179
179
  `;
180
- exports.getLotsByNameStringQuery = `
181
- query getLots($name: String, $entity_id: Int){
182
- lots (limit: 100, order_by: {id: desc}, where: {entity_id: {_eq: $entity_id}, name: {_eq: $name}}) {
183
- id
184
- name
185
- description
186
- }
187
- }
180
+ exports.getLotsByNameStringQuery = `
181
+ query getLots($name: String, $entity_id: Int){
182
+ lots (limit: 100, order_by: {id: desc}, where: {entity_id: {_eq: $entity_id}, name: {_eq: $name}}) {
183
+ id
184
+ name
185
+ description
186
+ }
187
+ }
188
188
  `;
189
- exports.getLotStocksByAgencyIdStringQuery = `
190
- query getLotStocksByAgencyId($agency_id: Int){
191
- lot_stocks (
192
- order_by: { id: desc },
193
- where: { agency_id: { _eq: $agency_id }}
194
- ){
195
- id
196
- available
197
- lot_id
198
- lot {
199
- id
200
- item_id
201
- expires
202
- }
203
- }
204
- }
189
+ exports.getLotStocksByAgencyIdStringQuery = `
190
+ query getLotStocksByAgencyId($agency_id: Int){
191
+ lot_stocks (
192
+ order_by: { id: desc },
193
+ where: { agency_id: { _eq: $agency_id }}
194
+ ){
195
+ id
196
+ available
197
+ lot_id
198
+ lot {
199
+ id
200
+ item_id
201
+ expires
202
+ }
203
+ }
204
+ }
205
205
  `;
206
206
  const getPurchaseOrdersBetweenDatesStringQuery = (config = {
207
207
  agencyFilter: false,
@@ -209,938 +209,1001 @@ const getPurchaseOrdersBetweenDatesStringQuery = (config = {
209
209
  itemIdFilter: false,
210
210
  consolidateIdFilter: false,
211
211
  withLotStocks: false,
212
- }) => `
213
- query getPurchaseOrdersBetweenDates(
214
- $agencyId: Int,
215
- $startDate: timestamp,
216
- $endDate: timestamp,
217
- $lotItemIdExclusion: Int = null,
218
- $poDetailTagId: Int = null,
219
- $payeeCategoryId: Int = null
220
- ) {
221
- purchase_orders(
222
- order_by: {id: desc},
223
- where: {
224
- ${config.agencyFilter ? "agency_id: {_eq: $agencyId}," : ""}
212
+ betweenIssueDate: false,
213
+ }) => `
214
+ query getPurchaseOrdersBetweenDates(
215
+ $agencyId: Int,
216
+ $startDate: timestamp,
217
+ $endDate: timestamp,
218
+ $lotItemIdExclusion: Int = null,
219
+ $poDetailTagId: Int = null,
220
+ $payeeCategoryId: Int = null
221
+ ) {
222
+ purchase_orders(
223
+ order_by: {id: desc},
224
+ where: {
225
+ ${config.agencyFilter ? "agency_id: {_eq: $agencyId}," : ""}
225
226
  ${config.payeeCategoryFilter
226
227
  ? "payee: {payee_category: {id: {_eq: $payeeCategoryId}}}},"
227
- : ""}
228
+ : ""}
228
229
  ${config.itemIdFilter
229
230
  ? "purchase_order_details: {item_id: {_eq: 10}},"
230
- : ""}
231
+ : ""}
231
232
  ${config.lotItemIdExclusion
232
233
  ? "lots: {item_id: {_neq: $lotItemIdExclusion}},"
233
- : ""}
234
+ : ""}
234
235
  ${config.poDetailTagId
235
236
  ? "purchase_order_details: {tag_id: {_eq: $poDetailTagId}},"
236
- : ""}
237
- ${config.consolidateIdFilter ? "consolidate_id: {_is_null: true}," : ""}
238
- created_at: {_gte: $startDate, _lte: $endDate}
239
- }
240
- ) {
241
- id
242
- created_at
243
- due
244
- id_number
245
- memo
246
- payee_id
247
- issue_date
248
- agency_id
249
- discount
250
- consolidate_id
251
- purchase_order_details {
252
- item_id
253
- id
254
- reference
255
- booked_quantity
256
- delivered_quantity
257
- }
258
- lots(where: {active: {_eq: true}}){
259
- id
260
- name
261
- description
237
+ : ""}
238
+ ${config.consolidateIdFilter ? "consolidate_id: {_is_null: true}," : ""}
239
+ ${config.betweenIssueDate
240
+ ? "issue_date: {_gte: $startDate, _lte: $endDate}"
241
+ : "created_at: {_gte: $startDate, _lte: $endDate}"}
242
+ }
243
+ ) {
244
+ id
245
+ created_at
246
+ due
247
+ id_number
248
+ memo
249
+ payee_id
250
+ issue_date
251
+ agency_id
252
+ discount
253
+ consolidate_id
254
+ purchase_order_details {
255
+ item_id
256
+ id
257
+ reference
258
+ booked_quantity
259
+ delivered_quantity
260
+ }
261
+ lots(where: {active: {_eq: true}}){
262
+ id
263
+ name
264
+ description
262
265
  ${config.withLotStocks
263
- ? `lot_stocks {
264
- id
265
- available
266
- incoming
267
- outgoing
268
- agency_id
266
+ ? `lot_stocks {
267
+ id
268
+ available
269
+ incoming
270
+ outgoing
271
+ agency_id
269
272
  }`
270
- : ""}
271
- }
272
- shipment_purchase_orders {
273
- shipment {
274
- id
275
- zid
276
- id_number
277
- reference
278
- needs_transport
279
- payee_id
280
- income
281
- booker_id
282
- agency_from_id
283
- agency_to_id
284
- }
285
- }
286
- }
287
- }
273
+ : ""}
274
+ }
275
+ shipment_purchase_orders {
276
+ shipment {
277
+ id
278
+ zid
279
+ id_number
280
+ reference
281
+ needs_transport
282
+ payee_id
283
+ income
284
+ booker_id
285
+ agency_from_id
286
+ agency_to_id
287
+ }
288
+ }
289
+ }
290
+ }
288
291
  `;
289
292
  exports.getPurchaseOrdersBetweenDatesStringQuery = getPurchaseOrdersBetweenDatesStringQuery;
290
- exports.getPayeesStringQuery = `
291
- query getPayees {
292
- payees {
293
- id
294
- id_number
295
- name
296
- tin
297
- vendor
298
- address_line_1
299
- }
300
- }
293
+ exports.getPayeesStringQuery = `
294
+ query getPayees {
295
+ payees {
296
+ id
297
+ id_number
298
+ name
299
+ tin
300
+ vendor
301
+ address_line_1
302
+ }
303
+ }
301
304
  `;
302
- exports.getProvidersStringQuery = `
303
- query getProviders {
304
- payees (where: {vendor: {_eq: true}}) {
305
- id
306
- id_number
307
- name
308
- tin
309
- address_line_1
310
- }
311
- }
305
+ exports.getProvidersStringQuery = `
306
+ query getProviders {
307
+ payees (where: {vendor: {_eq: true}}) {
308
+ id
309
+ id_number
310
+ name
311
+ tin
312
+ address_line_1
313
+ }
314
+ }
312
315
  `;
313
- exports.getAgenciesStringQuery = `
314
- query getAgencies {
315
- agencies {
316
- id
317
- name
318
- }
319
- }
316
+ exports.getAgenciesStringQuery = `
317
+ query getAgencies {
318
+ agencies {
319
+ id
320
+ name
321
+ }
322
+ }
320
323
  `;
321
- exports.getWebAppRowStringQuery = `
322
- query getWebAppRow($id: Int){
323
- webapp_rows(where: {id: {_eq: $id}}) {
324
- data
325
- }
326
- }
324
+ exports.getWebAppRowStringQuery = `
325
+ query getWebAppRow($id: Int){
326
+ webapp_rows(where: {id: {_eq: $id}}) {
327
+ data
328
+ }
329
+ }
327
330
  `;
328
- exports.getWebAppRowsByWebAppTableIdStringQuery = `
329
- query getWebAppRowsByWebAppTableId ($webapp_table_id: Int) {
330
- webapp_rows (where: {webapp_table_id: {_eq: $webapp_table_id }}) {
331
- id
332
- data
333
- created_at
334
- }
335
- }
331
+ exports.getWebAppRowsByWebAppTableIdStringQuery = `
332
+ query getWebAppRowsByWebAppTableId ($webapp_table_id: Int) {
333
+ webapp_rows (where: {webapp_table_id: {_eq: $webapp_table_id }}) {
334
+ id
335
+ data
336
+ created_at
337
+ }
338
+ }
336
339
  `;
337
- exports.getPayeeCategoryByIdStringQuery = `
338
- query getPayeeCategoryById ($id: Int) {
339
- payee_categories (where: {id: {_eq: $id }}) {
340
- payees (order_by: { id: desc }) {
341
- id
342
- name
343
- id_number
344
- email
345
- phone
346
- tin
347
- active
348
- address_line_1
349
- }
350
- }
351
- }
340
+ exports.getPayeeCategoryByIdStringQuery = `
341
+ query getPayeeCategoryById ($id: Int) {
342
+ payee_categories (where: {id: {_eq: $id }}) {
343
+ payees (order_by: { id: desc }) {
344
+ id
345
+ name
346
+ id_number
347
+ email
348
+ phone
349
+ tin
350
+ active
351
+ address_line_1
352
+ }
353
+ }
354
+ }
352
355
  `;
353
- const getPayeeCategoriesByNotesMatchStringQuery = (match) => `
354
- query getPayeeCategoriesByNotesMatch {
355
- payee_categories(where: {notes: {_ilike: "%${match}%" }}) {
356
- id
357
- name
358
- notes
359
- payees_count
360
- price_list_id
361
- price_list {
362
- id
363
- name
364
- }
365
- payees(order_by: {id: desc}) {
366
- id
367
- name
368
- id_number
369
- email
370
- phone
371
- tin
372
- active
373
- payee_category_id
374
- allowed_payment_terms {
375
- payment_term_id
376
- }
377
- }
378
- }
379
- }
356
+ const getPayeeCategoriesByNotesMatchStringQuery = (match) => `
357
+ query getPayeeCategoriesByNotesMatch {
358
+ payee_categories(where: {notes: {_ilike: "%${match}%" }}) {
359
+ id
360
+ name
361
+ notes
362
+ payees_count
363
+ price_list_id
364
+ price_list {
365
+ id
366
+ name
367
+ }
368
+ payees(order_by: {id: desc}) {
369
+ id
370
+ name
371
+ id_number
372
+ email
373
+ phone
374
+ tin
375
+ active
376
+ payee_category_id
377
+ allowed_payment_terms {
378
+ payment_term_id
379
+ }
380
+ }
381
+ }
382
+ }
380
383
  `;
381
384
  exports.getPayeeCategoriesByNotesMatchStringQuery = getPayeeCategoriesByNotesMatchStringQuery;
382
- exports.getPayeeCategoriesStringQuery = `
383
- query getPayeeCategories {
384
- payee_categories {
385
- id
386
- name
387
- notes
388
- payees_count
389
- price_list_id
390
- }
391
- }
385
+ exports.getPayeeCategoriesStringQuery = `
386
+ query getPayeeCategories {
387
+ payee_categories {
388
+ id
389
+ name
390
+ notes
391
+ payees_count
392
+ price_list_id
393
+ }
394
+ }
392
395
  `;
393
- exports.getProviderCategoriesStringQuery = `
394
- query getProviderCategories {
395
- payee_categories (where: {vendor: {_eq: true}}) {
396
- id
397
- name
398
- notes
399
- payees_count
400
- price_list_id
401
- }
402
- }
396
+ exports.getProviderCategoriesStringQuery = `
397
+ query getProviderCategories {
398
+ payee_categories (where: {vendor: {_eq: true}}) {
399
+ id
400
+ name
401
+ notes
402
+ payees_count
403
+ price_list_id
404
+ }
405
+ }
403
406
  `;
404
- exports.getClientCategoriesStringQuery = `
405
- query getClientCategories {
406
- payee_categories (where: {vendor: {_eq: false}}) {
407
- id
408
- name
409
- notes
410
- payees_count
411
- price_list_id
412
- }
413
- }
407
+ exports.getClientCategoriesStringQuery = `
408
+ query getClientCategories {
409
+ payee_categories (where: {vendor: {_eq: false}}) {
410
+ id
411
+ name
412
+ notes
413
+ payees_count
414
+ price_list_id
415
+ }
416
+ }
414
417
  `;
415
- exports.getPayeeByIdStringQuery = `
416
- query getPayeeById ($id: Int) {
417
- payees (where: {id: {_eq: $id }}) {
418
- id
419
- name
420
- id_number
421
- email
422
- phone
423
- tin
424
- active
425
- address_line_1
426
- }
427
- }
418
+ exports.getPayeeByIdStringQuery = `
419
+ query getPayeeById ($id: Int) {
420
+ payees (where: {id: {_eq: $id }}) {
421
+ id
422
+ name
423
+ id_number
424
+ email
425
+ phone
426
+ tin
427
+ active
428
+ address_line_1
429
+ }
430
+ }
428
431
  `;
429
- exports.getSuperCategoryByIdStringQuery = `
430
- query getSuperCategoryById ($id: Int) {
431
- item_super_categories (where: {id: {_eq: $id }}) {
432
- item_categories {
433
- id
434
- name
435
- notes
436
- items_count
437
- }
438
- }
439
- }
432
+ exports.getSuperCategoryByIdStringQuery = `
433
+ query getSuperCategoryById ($id: Int) {
434
+ item_super_categories (where: {id: {_eq: $id }}) {
435
+ item_categories {
436
+ id
437
+ name
438
+ notes
439
+ items_count
440
+ }
441
+ }
442
+ }
440
443
  `;
441
- exports.getItemCategoryByIdStringQuery = `
442
- query getItemCategoryById ($id: Int) {
443
- item_categories (where: {id: {_eq: $id }}) {
444
- id
445
- name
446
- notes
447
- items_count
448
- }
449
- }
444
+ exports.getItemCategoryByIdStringQuery = `
445
+ query getItemCategoryById ($id: Int) {
446
+ item_categories (where: {id: {_eq: $id }}) {
447
+ id
448
+ name
449
+ notes
450
+ items_count
451
+ }
452
+ }
450
453
  `;
451
- exports.getItemsByCategoryStringQuery = `
452
- query getItemsByCategory ($id: Int) {
453
- item_categories (where: {id: {_eq: $id }}) {
454
- items (where: {active: {_eq: true }}) {
455
- id,
456
- name,
457
- stocks_only_integer,
458
- code
459
- product_type
460
- }
461
- }
462
- }
454
+ exports.getItemsByCategoryStringQuery = `
455
+ query getItemsByCategory ($id: Int) {
456
+ item_categories (where: {id: {_eq: $id }}) {
457
+ items (where: {active: {_eq: true }}) {
458
+ id,
459
+ name,
460
+ stocks_only_integer,
461
+ code
462
+ product_type
463
+ }
464
+ }
465
+ }
463
466
  `;
464
- exports.getItemsStringQuery = `
465
- query getItems {
466
- items (where: {active: {_eq: true }}) {
467
- id,
468
- name
469
- }
470
- }
467
+ exports.getItemsStringQuery = `
468
+ query getItems {
469
+ items (where: {active: {_eq: true }}) {
470
+ id,
471
+ name
472
+ }
473
+ }
471
474
  `;
472
- exports.getItemsBySuperCategoryStringQuery = `
473
- query getItemsBySuperCategory ($id: Int, $agency_id: Int) {
474
- item_super_categories (where: {id: {_eq: $id }}, order_by: {id: desc}) {
475
- item_categories {
476
- items (where: {active: {_eq: true }}) {
477
- id,
478
- name,
479
- stocks_only_integer,
480
- code,
481
- item_category_id,
482
- measurement_unit,
483
- description
484
- product_type
485
- stocks(where: {agency_id: {_eq: $agency_id}}, order_by: {id: desc}) {
486
- available
487
- id
488
- incoming
489
- outgoing
490
- }
491
- }
492
- }
493
- }
494
- }
475
+ exports.getItemsBySuperCategoryStringQuery = `
476
+ query getItemsBySuperCategory ($id: Int, $agency_id: Int) {
477
+ item_super_categories (where: {id: {_eq: $id }}, order_by: {id: desc}) {
478
+ item_categories {
479
+ items (where: {active: {_eq: true }}) {
480
+ id,
481
+ name,
482
+ stocks_only_integer,
483
+ code,
484
+ item_category_id,
485
+ measurement_unit,
486
+ description
487
+ product_type
488
+ stocks(where: {agency_id: {_eq: $agency_id}}, order_by: {id: desc}) {
489
+ available
490
+ id
491
+ incoming
492
+ outgoing
493
+ }
494
+ }
495
+ }
496
+ }
497
+ }
495
498
  `;
496
- exports.getConsolidatesBetweenDatesStringQuery = `
497
- query getConsolidatesBetweenDates ($startDate: timestamp, $endDate: timestamp) {
498
- consolidates (order_by: {id: desc}, where: {created_at: {_gte: $startDate, _lte: $endDate}}) {
499
- id
500
- id_number
501
- created_at
502
- name
503
- purchase_orders {
504
- id
505
- due
506
- }
507
- }
508
- }
499
+ exports.getConsolidatesBetweenDatesStringQuery = `
500
+ query getConsolidatesBetweenDates ($startDate: timestamp, $endDate: timestamp) {
501
+ consolidates (order_by: {id: desc}, where: {created_at: {_gte: $startDate, _lte: $endDate}}) {
502
+ id
503
+ id_number
504
+ created_at
505
+ name
506
+ purchase_orders {
507
+ id
508
+ due
509
+ }
510
+ }
511
+ }
509
512
  `;
510
- exports.getEmployeeProfileStringQuery = `
511
- query getEmployeeProfile ($id: Int) {
512
- employees(where: {id: {_eq: $id}}) {
513
- agency_id
514
- email
515
- entity_id
516
- id
517
- name
518
- user_id
519
- }
520
- }
513
+ exports.getEmployeeProfileStringQuery = `
514
+ query getEmployeeProfile ($id: Int) {
515
+ employees(where: {id: {_eq: $id}}) {
516
+ agency_id
517
+ email
518
+ entity_id
519
+ id
520
+ name
521
+ user_id
522
+ }
523
+ }
521
524
  `;
522
- exports.getEmployeesByAgencyIdStringQuery = `
523
- query getEmployeesByAgencyId ($id: Int) {
524
- employees(where: {agency_id: {_eq: $id}}) {
525
- name
526
- id
527
- user_id
528
- }
529
- }
525
+ exports.getEmployeesByAgencyIdStringQuery = `
526
+ query getEmployeesByAgencyId ($id: Int) {
527
+ employees(where: {agency_id: {_eq: $id}}) {
528
+ name
529
+ id
530
+ user_id
531
+ }
532
+ }
530
533
  `;
531
- exports.getBundlesByItemCategoryIdStringQuery = `
532
- query getBundlesByItemCategoryId ($id: Int) {
533
- bundles(where: {active: {_eq: true}, item_category_id: {_eq: $id}}) {
534
- id
535
- code
536
- description
537
- name
538
- updated_at
539
- image5
540
- bundle_details_count
541
- bundle_details {
542
- id
543
- item_id
544
- quantity
545
- }
546
- }
547
- }
534
+ exports.getBundlesByItemCategoryIdStringQuery = `
535
+ query getBundlesByItemCategoryId ($id: Int) {
536
+ bundles(where: {active: {_eq: true}, item_category_id: {_eq: $id}}) {
537
+ id
538
+ code
539
+ description
540
+ name
541
+ updated_at
542
+ image5
543
+ bundle_details_count
544
+ bundle_details {
545
+ id
546
+ item_id
547
+ quantity
548
+ }
549
+ }
550
+ }
548
551
  `;
549
- exports.getBundleByNameStringQuery = `
550
- query getBundleByName ($name: String) {
551
- bundles (where: {name: {_eq: $name }}) {
552
- id
553
- }
554
- }
552
+ exports.getBundleByNameStringQuery = `
553
+ query getBundleByName ($name: String) {
554
+ bundles (where: {name: {_eq: $name }}) {
555
+ id
556
+ }
557
+ }
555
558
  `;
556
- exports.getItemByNameStringQuery = `
557
- query getItemByName ($name: String) {
558
- items (where: {active: {_eq: true }, name: {_eq: $name }}) {
559
- id
560
- name
561
- stocks_only_integer
562
- code
563
- product_type
564
- }
565
- }
559
+ exports.getItemByNameStringQuery = `
560
+ query getItemByName ($name: String) {
561
+ items (where: {active: {_eq: true }, name: {_eq: $name }}) {
562
+ id
563
+ name
564
+ stocks_only_integer
565
+ code
566
+ product_type
567
+ }
568
+ }
566
569
  `;
567
570
  const getShipmentsStringQuery = (wheres = []) => {
568
571
  const additionalWheres = wheres.join(",");
569
- return `query getShipments {
570
- shipments (${additionalWheres.length > 0 ? `where: {${additionalWheres}},` : ""} order_by: {id: desc}) {
571
- id
572
- id_number
573
- reference
574
- needs_transport
575
- payee_id
576
- booker_id
577
- shipped
578
- shipper_id
579
- delivered
580
- delivered_at
581
- voided
582
- returned
583
- memo
584
- planned_delivery
585
- }
586
- }
572
+ return `query getShipments {
573
+ shipments (${additionalWheres.length > 0 ? `where: {${additionalWheres}},` : ""} order_by: {id: desc}) {
574
+ id
575
+ id_number
576
+ reference
577
+ needs_transport
578
+ payee_id
579
+ booker_id
580
+ shipped
581
+ shipper_id
582
+ delivered
583
+ delivered_at
584
+ voided
585
+ returned
586
+ memo
587
+ planned_delivery
588
+ }
589
+ }
587
590
  `;
588
591
  };
589
592
  exports.getShipmentsStringQuery = getShipmentsStringQuery;
590
- exports.getFormByNameStringQuery = `
591
- query getFormByName ($name: String) {
592
- settings_forms (
593
- where: {name: {_eq: $name }},
594
- order_by: {zid: desc, version: desc}
595
- ) {
596
- id
597
- zid
598
- name
599
- description
600
- version
601
- active
602
- settings_form_fields (order_by: {position: asc}) {
603
- id
604
- name
605
- field_type
606
- hint
607
- required
608
- default_value
609
- position
610
- print_var_name
611
- form_id
612
- settings_form_field_options {
613
- id
614
- label
615
- position
616
- value
617
- }
618
- }
619
- }
620
- }
593
+ const getAllFormsStringQuery = (config = { withSubmissions: false }) => `
594
+ query getAllForms {
595
+ settings_forms (
596
+ order_by: {zid: desc, version: desc}
597
+ ) {
598
+ id
599
+ zid
600
+ name
601
+ description
602
+ version
603
+ active
604
+ ${config.withSubmissions
605
+ ? `settings_form_submissions {
606
+ id
607
+ zid
608
+ reference
609
+ created_at
610
+ version
611
+ id_number
612
+ user_id
613
+ settings_form_submission_values {
614
+ id
615
+ form_field_id
616
+ value
617
+ settings_form_field {
618
+ id
619
+ name
620
+ print_var_name
621
+ field_type
622
+ settings_form_field_options {
623
+ id
624
+ label
625
+ position
626
+ value
627
+ }
628
+ }
629
+ }
630
+ }`
631
+ : ""}
632
+ settings_form_fields (order_by: {position: asc}) {
633
+ id
634
+ name
635
+ field_type
636
+ hint
637
+ required
638
+ default_value
639
+ position
640
+ print_var_name
641
+ form_id
642
+ settings_form_field_options {
643
+ id
644
+ label
645
+ position
646
+ value
647
+ }
648
+ }
649
+ }
650
+ }
621
651
  `;
622
- exports.getFormsStringQuery = `
623
- query getForms {
624
- settings_forms (
625
- order_by: {zid: desc, version: desc}
626
- ) {
627
- id
628
- zid
629
- name
630
- description
631
- version
632
- active
633
- settings_form_fields (order_by: {position: asc}) {
634
- id
635
- name
636
- field_type
637
- hint
638
- required
639
- default_value
640
- position
641
- print_var_name
642
- form_id
643
- settings_form_field_options {
644
- id
645
- label
646
- position
647
- value
648
- }
649
- }
650
- }
651
- }
652
+ exports.getAllFormsStringQuery = getAllFormsStringQuery;
653
+ exports.getFormByNameStringQuery = `
654
+ query getFormByName ($name: String) {
655
+ settings_forms (
656
+ where: {name: {_eq: $name }},
657
+ order_by: {zid: desc, version: desc}
658
+ ) {
659
+ id
660
+ zid
661
+ name
662
+ description
663
+ version
664
+ active
665
+ settings_form_fields (order_by: {position: asc}) {
666
+ id
667
+ name
668
+ field_type
669
+ hint
670
+ required
671
+ default_value
672
+ position
673
+ print_var_name
674
+ form_id
675
+ settings_form_field_options {
676
+ id
677
+ label
678
+ position
679
+ value
680
+ }
681
+ }
682
+ }
683
+ }
652
684
  `;
653
- const getFormsByDocumentTypeStringQuery = (filters = {}) => `
654
- query getFormsByDocumentType ($document_type: String) {
655
- settings_forms (
656
- where: {
657
- ${filters?.formZid ? `zid: {_eq: ${filters?.formZid}},` : ""}
658
- document_type: {_eq: $document_type}
659
- },
660
- order_by: {zid: desc, version: desc}
661
- ) {
662
- id
663
- zid
664
- name
665
- description
666
- version
667
- active
668
- settings_form_fields (order_by: {position: asc}) {
669
- id
670
- name
671
- field_type
672
- hint
673
- required
674
- default_value
675
- position
676
- print_var_name
677
- form_id
678
- settings_form_field_table_headers {
679
- id
680
- name
681
- cell_type
682
- position
683
- }
684
- settings_form_field_options {
685
- id
686
- label
687
- position
688
- value
689
- }
690
- }
691
- }
692
- }
685
+ exports.getFormsStringQuery = `
686
+ query getForms {
687
+ settings_forms (
688
+ order_by: {zid: desc, version: desc}
689
+ ) {
690
+ id
691
+ zid
692
+ name
693
+ description
694
+ version
695
+ active
696
+ settings_form_fields (order_by: {position: asc}) {
697
+ id
698
+ name
699
+ field_type
700
+ hint
701
+ required
702
+ default_value
703
+ position
704
+ print_var_name
705
+ form_id
706
+ settings_form_field_options {
707
+ id
708
+ label
709
+ position
710
+ value
711
+ }
712
+ }
713
+ }
714
+ }
715
+ `;
716
+ const getFormsByDocumentTypeStringQuery = (filters = {}) => `
717
+ query getFormsByDocumentType ($document_type: String) {
718
+ settings_forms (
719
+ where: {
720
+ ${filters?.formZid ? `zid: {_eq: ${filters?.formZid}},` : ""}
721
+ document_type: {_eq: $document_type}
722
+ },
723
+ order_by: {zid: desc, version: desc}
724
+ ) {
725
+ id
726
+ zid
727
+ name
728
+ description
729
+ version
730
+ active
731
+ settings_form_fields (order_by: {position: asc}) {
732
+ id
733
+ name
734
+ field_type
735
+ hint
736
+ required
737
+ default_value
738
+ position
739
+ print_var_name
740
+ form_id
741
+ settings_form_field_table_headers {
742
+ id
743
+ name
744
+ cell_type
745
+ position
746
+ }
747
+ settings_form_field_options {
748
+ id
749
+ label
750
+ position
751
+ value
752
+ }
753
+ }
754
+ }
755
+ }
693
756
  `;
694
757
  exports.getFormsByDocumentTypeStringQuery = getFormsByDocumentTypeStringQuery;
695
- const getMyCaseFormSubmissionsStringQuery = (filters = {}) => `
696
- query getMyCaseFormSubmissions ($responsible_id: Int) {
697
- submission_cases (
698
- limit: 500,
699
- where: {
700
- settings_form_submission: {
758
+ const getMyCaseFormSubmissionsStringQuery = (filters = {}) => `
759
+ query getMyCaseFormSubmissions ($responsible_id: Int) {
760
+ submission_cases (
761
+ limit: 500,
762
+ where: {
763
+ settings_form_submission: {
701
764
  ${filters?.formZid
702
765
  ? `settings_form: {zid: {_eq: ${filters?.formZid}}},`
703
- : ""}
704
- voided: {_eq: false}
705
- },
706
- case: {
707
- ${filters?.caseId ? `id: {_eq: ${filters?.caseId}},` : ""}
708
- responsible_id: {_eq: $responsible_id}
709
- }
710
- },
711
- order_by: {id: desc})
712
- {
713
- id
714
- case_id
715
- form_submission_id
716
- case {
717
- id
718
- id_number
719
- reference
720
- date
721
- symptom
722
- solution
723
- memo
724
- client {
725
- name
726
- address_line_1
727
- }
728
- }
729
- settings_form_submission {
730
- id
731
- zid
732
- reference
733
- created_at
734
- version
735
- id_number
736
- user_id
737
- settings_form_submission_values {
738
- id
739
- form_field_id
740
- value
741
- settings_form_field {
742
- id
743
- name
744
- print_var_name
745
- field_type
746
- settings_form_field_options {
747
- id
748
- label
749
- position
750
- value
751
- }
752
- }
753
- }
754
- settings_form {
755
- id
756
- name
757
- zid
758
- description
759
- created_at
760
- version
761
- }
762
- }
763
- }
764
- }
766
+ : ""}
767
+ voided: {_eq: false}
768
+ },
769
+ case: {
770
+ ${filters?.caseId ? `id: {_eq: ${filters?.caseId}},` : ""}
771
+ responsible_id: {_eq: $responsible_id}
772
+ }
773
+ },
774
+ order_by: {id: desc})
775
+ {
776
+ id
777
+ case_id
778
+ form_submission_id
779
+ case {
780
+ id
781
+ id_number
782
+ reference
783
+ date
784
+ symptom
785
+ solution
786
+ memo
787
+ client {
788
+ name
789
+ address_line_1
790
+ }
791
+ }
792
+ settings_form_submission {
793
+ id
794
+ zid
795
+ reference
796
+ created_at
797
+ version
798
+ id_number
799
+ user_id
800
+ settings_form_submission_values {
801
+ id
802
+ form_field_id
803
+ value
804
+ settings_form_field {
805
+ id
806
+ name
807
+ print_var_name
808
+ field_type
809
+ settings_form_field_options {
810
+ id
811
+ label
812
+ position
813
+ value
814
+ }
815
+ }
816
+ }
817
+ settings_form {
818
+ id
819
+ name
820
+ zid
821
+ description
822
+ created_at
823
+ version
824
+ }
825
+ }
826
+ }
827
+ }
765
828
  `;
766
829
  exports.getMyCaseFormSubmissionsStringQuery = getMyCaseFormSubmissionsStringQuery;
767
- exports.getFormSubmissionByIdStringQuery = `
768
- query getFormSubmissionById ($formId: bigint) {
769
- settings_form_submissions (where: {id: { _eq: $formId }}) {
770
- id
771
- zid
772
- reference
773
- created_at
774
- version
775
- id_number
776
- settings_form {
777
- id
778
- name
779
- description
780
- }
781
- settings_form_submission_values {
782
- id
783
- form_field_id
784
- value
785
- settings_form_field {
786
- id
787
- name
788
- print_var_name
789
- field_type
790
- settings_form_field_options {
791
- id
792
- label
793
- position
794
- value
795
- }
796
- }
797
- }
798
- }
799
- }
830
+ exports.getFormSubmissionByIdStringQuery = `
831
+ query getFormSubmissionById ($formId: bigint) {
832
+ settings_form_submissions (where: {id: { _eq: $formId }}) {
833
+ id
834
+ zid
835
+ reference
836
+ created_at
837
+ version
838
+ id_number
839
+ settings_form {
840
+ id
841
+ name
842
+ description
843
+ }
844
+ settings_form_submission_values {
845
+ id
846
+ form_field_id
847
+ value
848
+ settings_form_field {
849
+ id
850
+ name
851
+ print_var_name
852
+ field_type
853
+ settings_form_field_options {
854
+ id
855
+ label
856
+ position
857
+ value
858
+ }
859
+ }
860
+ }
861
+ }
862
+ }
800
863
  `;
801
864
  const getInvoiceFormSubmissionsByAgencyIdStringQuery = (filters) => {
802
- return `
803
- query getInvoiceFormSubmissionsByAgencyId (
804
- $agency_id: Int
805
- ) {
806
- submission_invoices(
807
- where: {
808
- settings_form_submission: {
865
+ return `
866
+ query getInvoiceFormSubmissionsByAgencyId (
867
+ $agency_id: Int
868
+ ) {
869
+ submission_invoices(
870
+ where: {
871
+ settings_form_submission: {
809
872
  ${filters?.some_field_value
810
- ? `settings_form_submission_values: {
811
- value: { _eq: "${filters?.some_field_value}" }
873
+ ? `settings_form_submission_values: {
874
+ value: { _eq: "${filters?.some_field_value}" }
812
875
  },`
813
- : ""}
814
- voided: {_eq: false}
815
- },
876
+ : ""}
877
+ voided: {_eq: false}
878
+ },
816
879
  ${filters?.startDate?.length && filters?.endDate?.length
817
880
  ? `created_at: { _gte: "${filters?.startDate}", _lte: "${filters?.endDate}" },`
818
- : ""}
819
- invoice: {
820
- agency_id: {_eq: $agency_id},
821
- ${filters?.seller_id ? `seller_id: {_eq: ${filters?.seller_id} },` : ""}
881
+ : ""}
882
+ invoice: {
883
+ agency_id: {_eq: $agency_id},
884
+ ${filters?.seller_id ? `seller_id: {_eq: ${filters?.seller_id} },` : ""}
822
885
  ${filters?.payee_id_number_search
823
886
  ? `payee: { id_number: { _ilike: "%${filters?.payee_id_number_search}%"} },`
824
- : ""}
887
+ : ""}
825
888
  ${filters?.item_ids?.length
826
889
  ? `invoice_details: {item_id: {_in: [${filters?.item_ids?.join(",")}]}}`
827
- : ""}
890
+ : ""}
828
891
  ${filters?.bundle_ids?.length
829
892
  ? `invoice_details: {bundle_id: {_in: [${filters?.bundle_ids?.join(",")}]}}`
830
- : ""}
831
- voided: {_eq: false}
832
- }
833
- },
834
- order_by: {id: desc}
835
- )
836
- {
837
- id
838
- invoice_id
839
- form_submission_id
840
- created_at
841
- invoice {
842
- id_number
843
- date
844
- currency_id
845
- order_number
846
- seller_id
847
- payee_id
848
- payee {
849
- id_number
850
- name
851
- }
852
- }
853
- settings_form_submission {
854
- id
855
- zid
856
- reference
857
- created_at
858
- version
859
- id_number
860
- settings_form_submission_values {
861
- id
862
- form_field_id
863
- value
864
- settings_form_field {
865
- id
866
- name
867
- print_var_name
868
- settings_form_field_options {
869
- id
870
- label
871
- position
872
- value
873
- }
874
- }
875
- }
876
- settings_form {
877
- id
878
- name
879
- zid
880
- description
881
- created_at
882
- version
883
- }
884
- }
885
- }
886
- }
893
+ : ""}
894
+ voided: {_eq: false}
895
+ }
896
+ },
897
+ order_by: {id: desc}
898
+ )
899
+ {
900
+ id
901
+ invoice_id
902
+ form_submission_id
903
+ created_at
904
+ invoice {
905
+ id_number
906
+ date
907
+ currency_id
908
+ order_number
909
+ seller_id
910
+ payee_id
911
+ payee {
912
+ id_number
913
+ name
914
+ }
915
+ }
916
+ settings_form_submission {
917
+ id
918
+ zid
919
+ reference
920
+ created_at
921
+ version
922
+ id_number
923
+ settings_form_submission_values {
924
+ id
925
+ form_field_id
926
+ value
927
+ settings_form_field {
928
+ id
929
+ name
930
+ print_var_name
931
+ settings_form_field_options {
932
+ id
933
+ label
934
+ position
935
+ value
936
+ }
937
+ }
938
+ }
939
+ settings_form {
940
+ id
941
+ name
942
+ zid
943
+ description
944
+ created_at
945
+ version
946
+ }
947
+ }
948
+ }
949
+ }
887
950
  `;
888
951
  };
889
952
  exports.getInvoiceFormSubmissionsByAgencyIdStringQuery = getInvoiceFormSubmissionsByAgencyIdStringQuery;
890
- const getLastInvoiceFormSubmissionStringQuery = (filters = {}) => `
891
- query getLastInvoiceFormSubmission {
892
- submission_invoices(
893
- where: {
894
- settings_form_submission: {
953
+ const getLastInvoiceFormSubmissionStringQuery = (filters = {}) => `
954
+ query getLastInvoiceFormSubmission {
955
+ submission_invoices(
956
+ where: {
957
+ settings_form_submission: {
895
958
  ${filters?.formZid
896
959
  ? `settings_form: {zid: {_eq: ${filters?.formZid}}},`
897
- : ""}
898
- voided: {_eq: false}
899
- }
900
- },
901
- order_by: {id: desc},
902
- limit: 1
903
- ) {
904
- settings_form_submission {
905
- id
906
- id_number
907
- }
908
- }
909
- }
960
+ : ""}
961
+ voided: {_eq: false}
962
+ }
963
+ },
964
+ order_by: {id: desc},
965
+ limit: 1
966
+ ) {
967
+ settings_form_submission {
968
+ id
969
+ id_number
970
+ }
971
+ }
972
+ }
910
973
  `;
911
974
  exports.getLastInvoiceFormSubmissionStringQuery = getLastInvoiceFormSubmissionStringQuery;
912
- const getInvoiceFormSubmissionsByInvoiceIdStringQuery = (filters = {}) => `
913
- query getInvoiceFormSubmissionsByInvoiceId ($invoice_id: bigint) {
914
- submission_invoices(
915
- where: {
916
- invoice_id: {_eq: $invoice_id},
917
- settings_form_submission: {
975
+ const getInvoiceFormSubmissionsByInvoiceIdStringQuery = (filters = {}) => `
976
+ query getInvoiceFormSubmissionsByInvoiceId ($invoice_id: bigint) {
977
+ submission_invoices(
978
+ where: {
979
+ invoice_id: {_eq: $invoice_id},
980
+ settings_form_submission: {
918
981
  ${filters?.formZid
919
982
  ? `settings_form: {zid: {_eq: ${filters?.formZid}}},`
920
- : ""}
921
- voided: {_eq: false}
922
- }
923
- },
924
- order_by: {id: desc}
925
- ) {
926
- id
927
- invoice_id
928
- form_submission_id
929
- created_at
930
- settings_form_submission {
931
- id
932
- zid
933
- reference
934
- created_at
935
- version
936
- id_number
937
- settings_form_submission_values {
938
- id
939
- form_field_id
940
- value
941
- settings_form_field {
942
- id
943
- name
944
- print_var_name
945
- settings_form_field_options {
946
- id
947
- label
948
- position
949
- value
950
- }
951
- }
952
- }
953
- settings_form {
954
- id
955
- name
956
- zid
957
- description
958
- created_at
959
- version
960
- }
961
- }
962
- }
963
- }
983
+ : ""}
984
+ voided: {_eq: false}
985
+ }
986
+ },
987
+ order_by: {id: desc}
988
+ ) {
989
+ id
990
+ invoice_id
991
+ form_submission_id
992
+ created_at
993
+ settings_form_submission {
994
+ id
995
+ zid
996
+ reference
997
+ created_at
998
+ version
999
+ id_number
1000
+ settings_form_submission_values {
1001
+ id
1002
+ form_field_id
1003
+ value
1004
+ settings_form_field {
1005
+ id
1006
+ name
1007
+ print_var_name
1008
+ settings_form_field_options {
1009
+ id
1010
+ label
1011
+ position
1012
+ value
1013
+ }
1014
+ }
1015
+ }
1016
+ settings_form {
1017
+ id
1018
+ name
1019
+ zid
1020
+ description
1021
+ created_at
1022
+ version
1023
+ }
1024
+ }
1025
+ }
1026
+ }
964
1027
  `;
965
1028
  exports.getInvoiceFormSubmissionsByInvoiceIdStringQuery = getInvoiceFormSubmissionsByInvoiceIdStringQuery;
966
- exports.getCurrenciesStringQuery = `
967
- query getCurrencies {
968
- currencies {
969
- id
970
- name
971
- prefix
972
- code
973
- country
974
- plural_name
975
- }
976
- }
1029
+ exports.getCurrenciesStringQuery = `
1030
+ query getCurrencies {
1031
+ currencies {
1032
+ id
1033
+ name
1034
+ prefix
1035
+ code
1036
+ country
1037
+ plural_name
1038
+ }
1039
+ }
977
1040
  `;
978
1041
  const getSuggestedPricesStringQuery = (config = {
979
1042
  notNullPriceList: false,
980
1043
  withItems: false,
981
1044
  withItemCategories: false,
982
1045
  onlyCurrent: false,
983
- }) => `
984
- query getSuggestedPrices {
1046
+ }) => `
1047
+ query getSuggestedPrices {
985
1048
  suggested_prices ${config?.notNullPriceList || config?.onlyCurrent
986
- ? `(
1049
+ ? `(
987
1050
  where: {${[
988
1051
  config?.onlyCurrent ? "current: { _eq: true }" : "",
989
1052
  config?.notNullPriceList ? "price_list_id: { _is_null: false }" : "",
990
1053
  ]
991
1054
  .filter(Boolean)
992
- .join(", ")}
993
- }
1055
+ .join(", ")}
1056
+ }
994
1057
  )`
995
- : ""} {
996
- id
997
- current
998
- currency_id
999
- amount
1000
- bundle_id
1001
- item_id
1002
- notes
1003
- price_list_id
1004
- flexible_price
1005
- price_list {
1006
- payee_categories {
1007
- id
1008
- }
1009
- }
1058
+ : ""} {
1059
+ id
1060
+ current
1061
+ currency_id
1062
+ amount
1063
+ bundle_id
1064
+ item_id
1065
+ notes
1066
+ price_list_id
1067
+ flexible_price
1068
+ price_list {
1069
+ payee_categories {
1070
+ id
1071
+ }
1072
+ }
1010
1073
  ${config?.withItems
1011
- ? `item {
1012
- id
1013
- name
1014
- stocks_only_integer
1015
- code
1016
- product_type
1074
+ ? `item {
1075
+ id
1076
+ name
1077
+ stocks_only_integer
1078
+ code
1079
+ product_type
1017
1080
  ${config?.withItemCategories
1018
- ? `
1019
- item_category {
1020
- id
1021
- name
1022
- notes
1023
- items_count
1024
- }
1081
+ ? `
1082
+ item_category {
1083
+ id
1084
+ name
1085
+ notes
1086
+ items_count
1087
+ }
1025
1088
  `
1026
- : ""}
1089
+ : ""}
1027
1090
  }`
1028
- : ""}
1029
- }
1030
- }
1091
+ : ""}
1092
+ }
1093
+ }
1031
1094
  `;
1032
1095
  exports.getSuggestedPricesStringQuery = getSuggestedPricesStringQuery;
1033
- exports.getPaymentTermsStringQuery = `
1034
- query getPaymentTerms {
1035
- payment_terms {
1036
- active
1037
- id
1038
- memo
1039
- name
1040
- }
1041
- }
1096
+ exports.getPaymentTermsStringQuery = `
1097
+ query getPaymentTerms {
1098
+ payment_terms {
1099
+ active
1100
+ id
1101
+ memo
1102
+ name
1103
+ }
1104
+ }
1042
1105
  `;
1043
- exports.getPaymentTermByIdStringQuery = `
1044
- query getPaymentTermById ($id: Int) {
1045
- payment_terms (where: {id: {_eq: $id }}) {
1046
- active
1047
- id
1048
- memo
1049
- name
1050
- account_from_id
1051
- account_to_id
1052
- allowed_payment_terms {
1053
- payee_category_id
1054
- }
1055
- }
1056
- }
1106
+ exports.getPaymentTermByIdStringQuery = `
1107
+ query getPaymentTermById ($id: Int) {
1108
+ payment_terms (where: {id: {_eq: $id }}) {
1109
+ active
1110
+ id
1111
+ memo
1112
+ name
1113
+ account_from_id
1114
+ account_to_id
1115
+ allowed_payment_terms {
1116
+ payee_category_id
1117
+ }
1118
+ }
1119
+ }
1057
1120
  `;
1058
- exports.getInvoicesByAgencyIdStringQuery = `
1059
- query getInvoicesByAgencyId($id: Int) {
1060
- invoices(limit: 1000, where: {agency_id: {_eq: $id}, voided: {_eq: false}}, order_by: {id: desc}) {
1061
- id
1062
- zid
1063
- id_number
1064
- currency_id
1065
- date
1066
- payee_id
1067
- total
1068
- subtotal
1069
- seller_id
1070
- order_number
1071
- memo
1072
- issued
1073
- invoice_number
1074
- id_number
1075
- payment_term_id
1076
- reference
1077
- submission_invoices {
1078
- id
1079
- settings_form_submission {
1080
- zid
1081
- voided
1082
- settings_form {
1083
- id
1084
- zid
1085
- }
1086
- }
1087
- }
1088
- invoice_details {
1089
- bundle_id
1090
- id
1091
- item_bundle_name
1092
- item_bundle_description
1093
- item_id
1094
- price
1095
- quantity
1096
- unit_price
1097
- }
1098
- payee {
1099
- name
1100
- payee_category_id
1101
- }
1102
- }
1103
- }
1121
+ exports.getInvoicesByAgencyIdStringQuery = `
1122
+ query getInvoicesByAgencyId($id: Int) {
1123
+ invoices(limit: 1000, where: {agency_id: {_eq: $id}, voided: {_eq: false}}, order_by: {id: desc}) {
1124
+ id
1125
+ zid
1126
+ id_number
1127
+ currency_id
1128
+ date
1129
+ payee_id
1130
+ total
1131
+ subtotal
1132
+ seller_id
1133
+ order_number
1134
+ memo
1135
+ issued
1136
+ invoice_number
1137
+ id_number
1138
+ payment_term_id
1139
+ reference
1140
+ submission_invoices {
1141
+ id
1142
+ settings_form_submission {
1143
+ zid
1144
+ voided
1145
+ settings_form {
1146
+ id
1147
+ zid
1148
+ }
1149
+ }
1150
+ }
1151
+ invoice_details {
1152
+ bundle_id
1153
+ id
1154
+ item_bundle_name
1155
+ item_bundle_description
1156
+ item_id
1157
+ price
1158
+ quantity
1159
+ unit_price
1160
+ }
1161
+ payee {
1162
+ name
1163
+ payee_category_id
1164
+ }
1165
+ }
1166
+ }
1104
1167
  `;
1105
1168
  const getCasesByResponsibleIdStringQuery = (wheres = []) => {
1106
1169
  const additionalWheres = wheres.join(",");
1107
- return `
1108
- query getCasesByResponsibleId($responsible_id: Int) {
1109
- cases(where: {responsible_id: {_eq: $responsible_id}${additionalWheres.length > 0 ? "," : ""}${additionalWheres}}, order_by: {id: desc}) {
1110
- id
1111
- id_number
1112
- serial_id
1113
- critical
1114
- reference
1115
- date
1116
- closing_expected_at
1117
- contact_method_id
1118
- symptom
1119
- solution
1120
- memo
1121
- closed
1122
- closed_at
1123
- seller_id
1124
- closer_id
1125
- client_id
1126
- warranty
1127
- courtesy
1128
- client {
1129
- name
1130
- address_line_1
1131
- }
1132
- case_invoices {
1133
- invoice {
1134
- id
1135
- paid
1136
- }
1137
- }
1138
- case_supplies {
1139
- id
1140
- item_id
1141
- }
1142
- }
1143
- }
1170
+ return `
1171
+ query getCasesByResponsibleId($responsible_id: Int) {
1172
+ cases(where: {responsible_id: {_eq: $responsible_id}${additionalWheres.length > 0 ? "," : ""}${additionalWheres}}, order_by: {id: desc}) {
1173
+ id
1174
+ id_number
1175
+ serial_id
1176
+ critical
1177
+ reference
1178
+ date
1179
+ closing_expected_at
1180
+ contact_method_id
1181
+ symptom
1182
+ solution
1183
+ memo
1184
+ closed
1185
+ closed_at
1186
+ seller_id
1187
+ closer_id
1188
+ client_id
1189
+ warranty
1190
+ courtesy
1191
+ client {
1192
+ name
1193
+ address_line_1
1194
+ }
1195
+ case_invoices {
1196
+ invoice {
1197
+ id
1198
+ paid
1199
+ }
1200
+ }
1201
+ case_supplies {
1202
+ id
1203
+ item_id
1204
+ }
1205
+ }
1206
+ }
1144
1207
  `;
1145
1208
  };
1146
1209
  exports.getCasesByResponsibleIdStringQuery = getCasesByResponsibleIdStringQuery;