@zauru-sdk/graphql 1.0.4 → 1.0.5

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