@zauru-sdk/graphql 1.0.48 → 1.0.60

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,998 @@ 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
+ }) => `
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}," : ""}
225
225
  ${config.payeeCategoryFilter
226
226
  ? "payee: {payee_category: {id: {_eq: $payeeCategoryId}}}},"
227
- : ""}
227
+ : ""}
228
228
  ${config.itemIdFilter
229
229
  ? "purchase_order_details: {item_id: {_eq: 10}},"
230
- : ""}
230
+ : ""}
231
231
  ${config.lotItemIdExclusion
232
232
  ? "lots: {item_id: {_neq: $lotItemIdExclusion}},"
233
- : ""}
233
+ : ""}
234
234
  ${config.poDetailTagId
235
235
  ? "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
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
262
262
  ${config.withLotStocks
263
- ? `lot_stocks {
264
- id
265
- available
266
- incoming
267
- outgoing
268
- agency_id
263
+ ? `lot_stocks {
264
+ id
265
+ available
266
+ incoming
267
+ outgoing
268
+ agency_id
269
269
  }`
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
- }
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
+ }
288
288
  `;
289
289
  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
- }
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
+ }
301
301
  `;
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
- }
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
+ }
312
312
  `;
313
- exports.getAgenciesStringQuery = `
314
- query getAgencies {
315
- agencies {
316
- id
317
- name
318
- }
319
- }
313
+ exports.getAgenciesStringQuery = `
314
+ query getAgencies {
315
+ agencies {
316
+ id
317
+ name
318
+ }
319
+ }
320
320
  `;
321
- exports.getWebAppRowStringQuery = `
322
- query getWebAppRow($id: Int){
323
- webapp_rows(where: {id: {_eq: $id}}) {
324
- data
325
- }
326
- }
321
+ exports.getWebAppRowStringQuery = `
322
+ query getWebAppRow($id: Int){
323
+ webapp_rows(where: {id: {_eq: $id}}) {
324
+ data
325
+ }
326
+ }
327
327
  `;
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
- }
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
+ }
336
336
  `;
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
- }
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
+ }
352
352
  `;
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
- }
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
+ }
380
380
  `;
381
381
  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
- }
382
+ exports.getPayeeCategoriesStringQuery = `
383
+ query getPayeeCategories {
384
+ payee_categories {
385
+ id
386
+ name
387
+ notes
388
+ payees_count
389
+ price_list_id
390
+ }
391
+ }
392
392
  `;
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
- }
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
+ }
403
403
  `;
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
- }
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
+ }
414
414
  `;
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
- }
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
+ }
428
428
  `;
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
- }
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
+ }
440
440
  `;
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
- }
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
+ }
450
450
  `;
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
- }
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
+ }
463
463
  `;
464
- exports.getItemsStringQuery = `
465
- query getItems {
466
- items (where: {active: {_eq: true }}) {
467
- id,
468
- name
469
- }
470
- }
464
+ exports.getItemsStringQuery = `
465
+ query getItems {
466
+ items (where: {active: {_eq: true }}) {
467
+ id,
468
+ name
469
+ }
470
+ }
471
471
  `;
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
- }
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
+ }
495
495
  `;
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
- }
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
+ }
509
509
  `;
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
- }
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
+ }
521
521
  `;
522
- exports.getEmployeesByAgencyIdStringQuery = `
523
- query getEmployeesByAgencyId ($id: Int) {
524
- employees(where: {agency_id: {_eq: $id}}) {
525
- name
526
- id
527
- user_id
528
- }
529
- }
522
+ exports.getEmployeesByAgencyIdStringQuery = `
523
+ query getEmployeesByAgencyId ($id: Int) {
524
+ employees(where: {agency_id: {_eq: $id}}) {
525
+ name
526
+ id
527
+ user_id
528
+ }
529
+ }
530
530
  `;
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
- }
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
+ }
548
548
  `;
549
- exports.getBundleByNameStringQuery = `
550
- query getBundleByName ($name: String) {
551
- bundles (where: {name: {_eq: $name }}) {
552
- id
553
- }
554
- }
549
+ exports.getBundleByNameStringQuery = `
550
+ query getBundleByName ($name: String) {
551
+ bundles (where: {name: {_eq: $name }}) {
552
+ id
553
+ }
554
+ }
555
555
  `;
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
- }
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
+ }
566
566
  `;
567
567
  const getShipmentsStringQuery = (wheres = []) => {
568
568
  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
- }
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
+ }
587
587
  `;
588
588
  };
589
589
  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
- }
590
+ const getAllFormsStringQuery = (config = { withSubmissions: false }) => `
591
+ query getAllForms {
592
+ settings_forms (
593
+ order_by: {zid: desc, version: desc}
594
+ ) {
595
+ id
596
+ zid
597
+ name
598
+ description
599
+ version
600
+ active
601
+ ${config.withSubmissions
602
+ ? `settings_form_submissions {
603
+ id
604
+ zid
605
+ reference
606
+ created_at
607
+ version
608
+ id_number
609
+ user_id
610
+ settings_form_submission_values {
611
+ id
612
+ form_field_id
613
+ value
614
+ settings_form_field {
615
+ id
616
+ name
617
+ print_var_name
618
+ field_type
619
+ settings_form_field_options {
620
+ id
621
+ label
622
+ position
623
+ value
624
+ }
625
+ }
626
+ }
627
+ }`
628
+ : ""}
629
+ settings_form_fields (order_by: {position: asc}) {
630
+ id
631
+ name
632
+ field_type
633
+ hint
634
+ required
635
+ default_value
636
+ position
637
+ print_var_name
638
+ form_id
639
+ settings_form_field_options {
640
+ id
641
+ label
642
+ position
643
+ value
644
+ }
645
+ }
646
+ }
647
+ }
621
648
  `;
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
- }
649
+ exports.getAllFormsStringQuery = getAllFormsStringQuery;
650
+ exports.getFormByNameStringQuery = `
651
+ query getFormByName ($name: String) {
652
+ settings_forms (
653
+ where: {name: {_eq: $name }},
654
+ order_by: {zid: desc, version: desc}
655
+ ) {
656
+ id
657
+ zid
658
+ name
659
+ description
660
+ version
661
+ active
662
+ settings_form_fields (order_by: {position: asc}) {
663
+ id
664
+ name
665
+ field_type
666
+ hint
667
+ required
668
+ default_value
669
+ position
670
+ print_var_name
671
+ form_id
672
+ settings_form_field_options {
673
+ id
674
+ label
675
+ position
676
+ value
677
+ }
678
+ }
679
+ }
680
+ }
652
681
  `;
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
- }
682
+ exports.getFormsStringQuery = `
683
+ query getForms {
684
+ settings_forms (
685
+ order_by: {zid: desc, version: desc}
686
+ ) {
687
+ id
688
+ zid
689
+ name
690
+ description
691
+ version
692
+ active
693
+ settings_form_fields (order_by: {position: asc}) {
694
+ id
695
+ name
696
+ field_type
697
+ hint
698
+ required
699
+ default_value
700
+ position
701
+ print_var_name
702
+ form_id
703
+ settings_form_field_options {
704
+ id
705
+ label
706
+ position
707
+ value
708
+ }
709
+ }
710
+ }
711
+ }
712
+ `;
713
+ const getFormsByDocumentTypeStringQuery = (filters = {}) => `
714
+ query getFormsByDocumentType ($document_type: String) {
715
+ settings_forms (
716
+ where: {
717
+ ${filters?.formZid ? `zid: {_eq: ${filters?.formZid}},` : ""}
718
+ document_type: {_eq: $document_type}
719
+ },
720
+ order_by: {zid: desc, version: desc}
721
+ ) {
722
+ id
723
+ zid
724
+ name
725
+ description
726
+ version
727
+ active
728
+ settings_form_fields (order_by: {position: asc}) {
729
+ id
730
+ name
731
+ field_type
732
+ hint
733
+ required
734
+ default_value
735
+ position
736
+ print_var_name
737
+ form_id
738
+ settings_form_field_table_headers {
739
+ id
740
+ name
741
+ cell_type
742
+ position
743
+ }
744
+ settings_form_field_options {
745
+ id
746
+ label
747
+ position
748
+ value
749
+ }
750
+ }
751
+ }
752
+ }
693
753
  `;
694
754
  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: {
755
+ const getMyCaseFormSubmissionsStringQuery = (filters = {}) => `
756
+ query getMyCaseFormSubmissions ($responsible_id: Int) {
757
+ submission_cases (
758
+ limit: 500,
759
+ where: {
760
+ settings_form_submission: {
701
761
  ${filters?.formZid
702
762
  ? `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
- }
763
+ : ""}
764
+ voided: {_eq: false}
765
+ },
766
+ case: {
767
+ ${filters?.caseId ? `id: {_eq: ${filters?.caseId}},` : ""}
768
+ responsible_id: {_eq: $responsible_id}
769
+ }
770
+ },
771
+ order_by: {id: desc})
772
+ {
773
+ id
774
+ case_id
775
+ form_submission_id
776
+ case {
777
+ id
778
+ id_number
779
+ reference
780
+ date
781
+ symptom
782
+ solution
783
+ memo
784
+ client {
785
+ name
786
+ address_line_1
787
+ }
788
+ }
789
+ settings_form_submission {
790
+ id
791
+ zid
792
+ reference
793
+ created_at
794
+ version
795
+ id_number
796
+ user_id
797
+ settings_form_submission_values {
798
+ id
799
+ form_field_id
800
+ value
801
+ settings_form_field {
802
+ id
803
+ name
804
+ print_var_name
805
+ field_type
806
+ settings_form_field_options {
807
+ id
808
+ label
809
+ position
810
+ value
811
+ }
812
+ }
813
+ }
814
+ settings_form {
815
+ id
816
+ name
817
+ zid
818
+ description
819
+ created_at
820
+ version
821
+ }
822
+ }
823
+ }
824
+ }
765
825
  `;
766
826
  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
- }
827
+ exports.getFormSubmissionByIdStringQuery = `
828
+ query getFormSubmissionById ($formId: bigint) {
829
+ settings_form_submissions (where: {id: { _eq: $formId }}) {
830
+ id
831
+ zid
832
+ reference
833
+ created_at
834
+ version
835
+ id_number
836
+ settings_form {
837
+ id
838
+ name
839
+ description
840
+ }
841
+ settings_form_submission_values {
842
+ id
843
+ form_field_id
844
+ value
845
+ settings_form_field {
846
+ id
847
+ name
848
+ print_var_name
849
+ field_type
850
+ settings_form_field_options {
851
+ id
852
+ label
853
+ position
854
+ value
855
+ }
856
+ }
857
+ }
858
+ }
859
+ }
800
860
  `;
801
861
  const getInvoiceFormSubmissionsByAgencyIdStringQuery = (filters) => {
802
- return `
803
- query getInvoiceFormSubmissionsByAgencyId (
804
- $agency_id: Int
805
- ) {
806
- submission_invoices(
807
- where: {
808
- settings_form_submission: {
862
+ return `
863
+ query getInvoiceFormSubmissionsByAgencyId (
864
+ $agency_id: Int
865
+ ) {
866
+ submission_invoices(
867
+ where: {
868
+ settings_form_submission: {
809
869
  ${filters?.some_field_value
810
- ? `settings_form_submission_values: {
811
- value: { _eq: "${filters?.some_field_value}" }
870
+ ? `settings_form_submission_values: {
871
+ value: { _eq: "${filters?.some_field_value}" }
812
872
  },`
813
- : ""}
814
- voided: {_eq: false}
815
- },
873
+ : ""}
874
+ voided: {_eq: false}
875
+ },
816
876
  ${filters?.startDate?.length && filters?.endDate?.length
817
877
  ? `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} },` : ""}
878
+ : ""}
879
+ invoice: {
880
+ agency_id: {_eq: $agency_id},
881
+ ${filters?.seller_id ? `seller_id: {_eq: ${filters?.seller_id} },` : ""}
822
882
  ${filters?.payee_id_number_search
823
883
  ? `payee: { id_number: { _ilike: "%${filters?.payee_id_number_search}%"} },`
824
- : ""}
884
+ : ""}
825
885
  ${filters?.item_ids?.length
826
886
  ? `invoice_details: {item_id: {_in: [${filters?.item_ids?.join(",")}]}}`
827
- : ""}
887
+ : ""}
828
888
  ${filters?.bundle_ids?.length
829
889
  ? `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
- }
890
+ : ""}
891
+ voided: {_eq: false}
892
+ }
893
+ },
894
+ order_by: {id: desc}
895
+ )
896
+ {
897
+ id
898
+ invoice_id
899
+ form_submission_id
900
+ created_at
901
+ invoice {
902
+ id_number
903
+ date
904
+ currency_id
905
+ order_number
906
+ seller_id
907
+ payee_id
908
+ payee {
909
+ id_number
910
+ name
911
+ }
912
+ }
913
+ settings_form_submission {
914
+ id
915
+ zid
916
+ reference
917
+ created_at
918
+ version
919
+ id_number
920
+ settings_form_submission_values {
921
+ id
922
+ form_field_id
923
+ value
924
+ settings_form_field {
925
+ id
926
+ name
927
+ print_var_name
928
+ settings_form_field_options {
929
+ id
930
+ label
931
+ position
932
+ value
933
+ }
934
+ }
935
+ }
936
+ settings_form {
937
+ id
938
+ name
939
+ zid
940
+ description
941
+ created_at
942
+ version
943
+ }
944
+ }
945
+ }
946
+ }
887
947
  `;
888
948
  };
889
949
  exports.getInvoiceFormSubmissionsByAgencyIdStringQuery = getInvoiceFormSubmissionsByAgencyIdStringQuery;
890
- const getLastInvoiceFormSubmissionStringQuery = (filters = {}) => `
891
- query getLastInvoiceFormSubmission {
892
- submission_invoices(
893
- where: {
894
- settings_form_submission: {
950
+ const getLastInvoiceFormSubmissionStringQuery = (filters = {}) => `
951
+ query getLastInvoiceFormSubmission {
952
+ submission_invoices(
953
+ where: {
954
+ settings_form_submission: {
895
955
  ${filters?.formZid
896
956
  ? `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
- }
957
+ : ""}
958
+ voided: {_eq: false}
959
+ }
960
+ },
961
+ order_by: {id: desc},
962
+ limit: 1
963
+ ) {
964
+ settings_form_submission {
965
+ id
966
+ id_number
967
+ }
968
+ }
969
+ }
910
970
  `;
911
971
  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: {
972
+ const getInvoiceFormSubmissionsByInvoiceIdStringQuery = (filters = {}) => `
973
+ query getInvoiceFormSubmissionsByInvoiceId ($invoice_id: bigint) {
974
+ submission_invoices(
975
+ where: {
976
+ invoice_id: {_eq: $invoice_id},
977
+ settings_form_submission: {
918
978
  ${filters?.formZid
919
979
  ? `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
- }
980
+ : ""}
981
+ voided: {_eq: false}
982
+ }
983
+ },
984
+ order_by: {id: desc}
985
+ ) {
986
+ id
987
+ invoice_id
988
+ form_submission_id
989
+ created_at
990
+ settings_form_submission {
991
+ id
992
+ zid
993
+ reference
994
+ created_at
995
+ version
996
+ id_number
997
+ settings_form_submission_values {
998
+ id
999
+ form_field_id
1000
+ value
1001
+ settings_form_field {
1002
+ id
1003
+ name
1004
+ print_var_name
1005
+ settings_form_field_options {
1006
+ id
1007
+ label
1008
+ position
1009
+ value
1010
+ }
1011
+ }
1012
+ }
1013
+ settings_form {
1014
+ id
1015
+ name
1016
+ zid
1017
+ description
1018
+ created_at
1019
+ version
1020
+ }
1021
+ }
1022
+ }
1023
+ }
964
1024
  `;
965
1025
  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
- }
1026
+ exports.getCurrenciesStringQuery = `
1027
+ query getCurrencies {
1028
+ currencies {
1029
+ id
1030
+ name
1031
+ prefix
1032
+ code
1033
+ country
1034
+ plural_name
1035
+ }
1036
+ }
977
1037
  `;
978
1038
  const getSuggestedPricesStringQuery = (config = {
979
1039
  notNullPriceList: false,
980
1040
  withItems: false,
981
1041
  withItemCategories: false,
982
1042
  onlyCurrent: false,
983
- }) => `
984
- query getSuggestedPrices {
1043
+ }) => `
1044
+ query getSuggestedPrices {
985
1045
  suggested_prices ${config?.notNullPriceList || config?.onlyCurrent
986
- ? `(
1046
+ ? `(
987
1047
  where: {${[
988
1048
  config?.onlyCurrent ? "current: { _eq: true }" : "",
989
1049
  config?.notNullPriceList ? "price_list_id: { _is_null: false }" : "",
990
1050
  ]
991
1051
  .filter(Boolean)
992
- .join(", ")}
993
- }
1052
+ .join(", ")}
1053
+ }
994
1054
  )`
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
- }
1055
+ : ""} {
1056
+ id
1057
+ current
1058
+ currency_id
1059
+ amount
1060
+ bundle_id
1061
+ item_id
1062
+ notes
1063
+ price_list_id
1064
+ flexible_price
1065
+ price_list {
1066
+ payee_categories {
1067
+ id
1068
+ }
1069
+ }
1010
1070
  ${config?.withItems
1011
- ? `item {
1012
- id
1013
- name
1014
- stocks_only_integer
1015
- code
1016
- product_type
1071
+ ? `item {
1072
+ id
1073
+ name
1074
+ stocks_only_integer
1075
+ code
1076
+ product_type
1017
1077
  ${config?.withItemCategories
1018
- ? `
1019
- item_category {
1020
- id
1021
- name
1022
- notes
1023
- items_count
1024
- }
1078
+ ? `
1079
+ item_category {
1080
+ id
1081
+ name
1082
+ notes
1083
+ items_count
1084
+ }
1025
1085
  `
1026
- : ""}
1086
+ : ""}
1027
1087
  }`
1028
- : ""}
1029
- }
1030
- }
1088
+ : ""}
1089
+ }
1090
+ }
1031
1091
  `;
1032
1092
  exports.getSuggestedPricesStringQuery = getSuggestedPricesStringQuery;
1033
- exports.getPaymentTermsStringQuery = `
1034
- query getPaymentTerms {
1035
- payment_terms {
1036
- active
1037
- id
1038
- memo
1039
- name
1040
- }
1041
- }
1093
+ exports.getPaymentTermsStringQuery = `
1094
+ query getPaymentTerms {
1095
+ payment_terms {
1096
+ active
1097
+ id
1098
+ memo
1099
+ name
1100
+ }
1101
+ }
1042
1102
  `;
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
- }
1103
+ exports.getPaymentTermByIdStringQuery = `
1104
+ query getPaymentTermById ($id: Int) {
1105
+ payment_terms (where: {id: {_eq: $id }}) {
1106
+ active
1107
+ id
1108
+ memo
1109
+ name
1110
+ account_from_id
1111
+ account_to_id
1112
+ allowed_payment_terms {
1113
+ payee_category_id
1114
+ }
1115
+ }
1116
+ }
1057
1117
  `;
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
- }
1118
+ exports.getInvoicesByAgencyIdStringQuery = `
1119
+ query getInvoicesByAgencyId($id: Int) {
1120
+ invoices(limit: 1000, where: {agency_id: {_eq: $id}, voided: {_eq: false}}, order_by: {id: desc}) {
1121
+ id
1122
+ zid
1123
+ id_number
1124
+ currency_id
1125
+ date
1126
+ payee_id
1127
+ total
1128
+ subtotal
1129
+ seller_id
1130
+ order_number
1131
+ memo
1132
+ issued
1133
+ invoice_number
1134
+ id_number
1135
+ payment_term_id
1136
+ reference
1137
+ submission_invoices {
1138
+ id
1139
+ settings_form_submission {
1140
+ zid
1141
+ voided
1142
+ settings_form {
1143
+ id
1144
+ zid
1145
+ }
1146
+ }
1147
+ }
1148
+ invoice_details {
1149
+ bundle_id
1150
+ id
1151
+ item_bundle_name
1152
+ item_bundle_description
1153
+ item_id
1154
+ price
1155
+ quantity
1156
+ unit_price
1157
+ }
1158
+ payee {
1159
+ name
1160
+ payee_category_id
1161
+ }
1162
+ }
1163
+ }
1104
1164
  `;
1105
1165
  const getCasesByResponsibleIdStringQuery = (wheres = []) => {
1106
1166
  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
- }
1167
+ return `
1168
+ query getCasesByResponsibleId($responsible_id: Int) {
1169
+ cases(where: {responsible_id: {_eq: $responsible_id}${additionalWheres.length > 0 ? "," : ""}${additionalWheres}}, order_by: {id: desc}) {
1170
+ id
1171
+ id_number
1172
+ serial_id
1173
+ critical
1174
+ reference
1175
+ date
1176
+ closing_expected_at
1177
+ contact_method_id
1178
+ symptom
1179
+ solution
1180
+ memo
1181
+ closed
1182
+ closed_at
1183
+ seller_id
1184
+ closer_id
1185
+ client_id
1186
+ warranty
1187
+ courtesy
1188
+ client {
1189
+ name
1190
+ address_line_1
1191
+ }
1192
+ case_invoices {
1193
+ invoice {
1194
+ id
1195
+ paid
1196
+ }
1197
+ }
1198
+ case_supplies {
1199
+ id
1200
+ item_id
1201
+ }
1202
+ }
1203
+ }
1144
1204
  `;
1145
1205
  };
1146
1206
  exports.getCasesByResponsibleIdStringQuery = getCasesByResponsibleIdStringQuery;