@zauru-sdk/graphql 1.0.4 → 1.0.7

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