@zauru-sdk/graphql 1.0.33 → 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,1252 +1,1206 @@
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
- onlyCurrent: boolean;
1073
- } = {
1074
- notNullPriceList: false,
1075
- withItems: false,
1076
- withItemCategories: false,
1077
- onlyCurrent: false,
1078
- }
1079
- ) => `
1080
- query getSuggestedPrices {
1081
- suggested_prices ${
1082
- config?.notNullPriceList || config?.onlyCurrent
1083
- ? `(
1084
- where: {${[
1085
- config?.onlyCurrent ? "current: { _eq: true }" : "",
1086
- config?.notNullPriceList ? "price_list_id: { _is_null: false }" : "",
1087
- ]
1088
- .filter(Boolean)
1089
- .join(", ")}
1090
- }
1091
- )`
1092
- : ""
1093
- } {
1094
- id
1095
- current
1096
- currency_id
1097
- amount
1098
- bundle_id
1099
- item_id
1100
- notes
1101
- price_list_id
1102
- flexible_price
1103
- price_list {
1104
- payee_categories {
1105
- id
1106
- }
1107
- }
1108
- ${
1109
- config?.withItems
1110
- ? `item {
1111
- id
1112
- name
1113
- stocks_only_integer
1114
- code
1115
- product_type
1116
- ${
1117
- config?.withItemCategories
1118
- ? `
1119
- item_category {
1120
- id
1121
- name
1122
- notes
1123
- items_count
1124
- }
1125
- `
1126
- : ""
1127
- }
1128
- }`
1129
- : ""
1130
- }
1131
- }
1132
- }
1133
- `;
1134
-
1135
- export const getPaymentTermsStringQuery = `
1136
- query getPaymentTerms {
1137
- payment_terms {
1138
- active
1139
- id
1140
- memo
1141
- name
1142
- }
1143
- }
1144
- `;
1145
-
1146
- export const getPaymentTermByIdStringQuery = `
1147
- query getPaymentTermById ($id: Int) {
1148
- payment_terms (where: {id: {_eq: $id }}) {
1149
- active
1150
- id
1151
- memo
1152
- name
1153
- account_from_id
1154
- account_to_id
1155
- allowed_payment_terms {
1156
- payee_category_id
1157
- }
1158
- }
1159
- }
1160
- `;
1161
-
1162
- export const getInvoicesByAgencyIdStringQuery = `
1163
- query getInvoicesByAgencyId($id: Int) {
1164
- invoices(limit: 1000, where: {agency_id: {_eq: $id}, voided: {_eq: false}}, order_by: {id: desc}) {
1165
- id
1166
- zid
1167
- id_number
1168
- currency_id
1169
- date
1170
- payee_id
1171
- total
1172
- subtotal
1173
- seller_id
1174
- order_number
1175
- memo
1176
- issued
1177
- invoice_number
1178
- id_number
1179
- payment_term_id
1180
- reference
1181
- submission_invoices {
1182
- id
1183
- settings_form_submission {
1184
- zid
1185
- voided
1186
- settings_form {
1187
- id
1188
- zid
1189
- }
1190
- }
1191
- }
1192
- invoice_details {
1193
- bundle_id
1194
- id
1195
- item_bundle_name
1196
- item_bundle_description
1197
- item_id
1198
- price
1199
- quantity
1200
- unit_price
1201
- }
1202
- payee {
1203
- name
1204
- payee_category_id
1205
- }
1206
- }
1207
- }
1208
- `;
1209
-
1210
- export const getCasesByResponsibleIdStringQuery = (wheres: string[] = []) => {
1211
- const additionalWheres = wheres.join(",");
1212
- return `
1213
- query getCasesByResponsibleId($responsible_id: Int) {
1214
- cases(where: {responsible_id: {_eq: $responsible_id}${
1215
- additionalWheres.length > 0 ? "," : ""
1216
- }${additionalWheres}}, order_by: {id: desc}) {
1217
- id
1218
- id_number
1219
- serial_id
1220
- critical
1221
- reference
1222
- date
1223
- closing_expected_at
1224
- contact_method_id
1225
- symptom
1226
- solution
1227
- memo
1228
- closed
1229
- closed_at
1230
- seller_id
1231
- closer_id
1232
- client_id
1233
- warranty
1234
- courtesy
1235
- client {
1236
- name
1237
- address_line_1
1238
- }
1239
- case_invoices {
1240
- invoice {
1241
- id
1242
- paid
1243
- }
1244
- }
1245
- case_supplies {
1246
- id
1247
- item_id
1248
- }
1249
- }
1250
- }
1251
- `;
1252
- };
1
+ "use strict";
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.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
+ `;
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
+ `;
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
+ ${config.withLotStocks
118
+ ? `lot_stocks {
119
+ id
120
+ available
121
+ incoming
122
+ outgoing
123
+ agency_id
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
+ }
147
+ `;
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
+ }
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
+ }
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
+ }
205
+ `;
206
+ const getPurchaseOrdersBetweenDatesStringQuery = (config = {
207
+ agencyFilter: false,
208
+ payeeCategoryFilter: false,
209
+ itemIdFilter: false,
210
+ consolidateIdFilter: false,
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}," : ""}
225
+ ${config.payeeCategoryFilter
226
+ ? "payee: {payee_category: {id: {_eq: $payeeCategoryId}}}},"
227
+ : ""}
228
+ ${config.itemIdFilter
229
+ ? "purchase_order_details: {item_id: {_eq: 10}},"
230
+ : ""}
231
+ ${config.lotItemIdExclusion
232
+ ? "lots: {item_id: {_neq: $lotItemIdExclusion}},"
233
+ : ""}
234
+ ${config.poDetailTagId
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
262
+ ${config.withLotStocks
263
+ ? `lot_stocks {
264
+ id
265
+ available
266
+ incoming
267
+ outgoing
268
+ agency_id
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
+ }
288
+ `;
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
+ }
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
+ }
312
+ `;
313
+ exports.getAgenciesStringQuery = `
314
+ query getAgencies {
315
+ agencies {
316
+ id
317
+ name
318
+ }
319
+ }
320
+ `;
321
+ exports.getWebAppRowStringQuery = `
322
+ query getWebAppRow($id: Int){
323
+ webapp_rows(where: {id: {_eq: $id}}) {
324
+ data
325
+ }
326
+ }
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
+ }
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
+ }
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
+ }
380
+ `;
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
+ }
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
+ }
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
+ }
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
+ }
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
+ }
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
+ }
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
+ }
463
+ `;
464
+ exports.getItemsStringQuery = `
465
+ query getItems {
466
+ items (where: {active: {_eq: true }}) {
467
+ id,
468
+ name
469
+ }
470
+ }
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
+ }
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
+ }
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
+ }
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
+ }
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
+ }
548
+ `;
549
+ exports.getBundleByNameStringQuery = `
550
+ query getBundleByName ($name: String) {
551
+ bundles (where: {name: {_eq: $name }}) {
552
+ id
553
+ }
554
+ }
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
+ }
566
+ `;
567
+ const getShipmentsStringQuery = (wheres = []) => {
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
+ }
587
+ `;
588
+ };
589
+ exports.getShipmentsStringQuery = getShipmentsStringQuery;
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
+ }
648
+ `;
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
+ }
681
+ `;
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
+ }
753
+ `;
754
+ exports.getFormsByDocumentTypeStringQuery = getFormsByDocumentTypeStringQuery;
755
+ const getMyCaseFormSubmissionsStringQuery = (filters = {}) => `
756
+ query getMyCaseFormSubmissions ($responsible_id: Int) {
757
+ submission_cases (
758
+ limit: 500,
759
+ where: {
760
+ settings_form_submission: {
761
+ ${filters?.formZid
762
+ ? `settings_form: {zid: {_eq: ${filters?.formZid}}},`
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
+ }
825
+ `;
826
+ exports.getMyCaseFormSubmissionsStringQuery = getMyCaseFormSubmissionsStringQuery;
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
+ }
860
+ `;
861
+ const getInvoiceFormSubmissionsByAgencyIdStringQuery = (filters) => {
862
+ return `
863
+ query getInvoiceFormSubmissionsByAgencyId (
864
+ $agency_id: Int
865
+ ) {
866
+ submission_invoices(
867
+ where: {
868
+ settings_form_submission: {
869
+ ${filters?.some_field_value
870
+ ? `settings_form_submission_values: {
871
+ value: { _eq: "${filters?.some_field_value}" }
872
+ },`
873
+ : ""}
874
+ voided: {_eq: false}
875
+ },
876
+ ${filters?.startDate?.length && filters?.endDate?.length
877
+ ? `created_at: { _gte: "${filters?.startDate}", _lte: "${filters?.endDate}" },`
878
+ : ""}
879
+ invoice: {
880
+ agency_id: {_eq: $agency_id},
881
+ ${filters?.seller_id ? `seller_id: {_eq: ${filters?.seller_id} },` : ""}
882
+ ${filters?.payee_id_number_search
883
+ ? `payee: { id_number: { _ilike: "%${filters?.payee_id_number_search}%"} },`
884
+ : ""}
885
+ ${filters?.item_ids?.length
886
+ ? `invoice_details: {item_id: {_in: [${filters?.item_ids?.join(",")}]}}`
887
+ : ""}
888
+ ${filters?.bundle_ids?.length
889
+ ? `invoice_details: {bundle_id: {_in: [${filters?.bundle_ids?.join(",")}]}}`
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
+ }
947
+ `;
948
+ };
949
+ exports.getInvoiceFormSubmissionsByAgencyIdStringQuery = getInvoiceFormSubmissionsByAgencyIdStringQuery;
950
+ const getLastInvoiceFormSubmissionStringQuery = (filters = {}) => `
951
+ query getLastInvoiceFormSubmission {
952
+ submission_invoices(
953
+ where: {
954
+ settings_form_submission: {
955
+ ${filters?.formZid
956
+ ? `settings_form: {zid: {_eq: ${filters?.formZid}}},`
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
+ }
970
+ `;
971
+ exports.getLastInvoiceFormSubmissionStringQuery = getLastInvoiceFormSubmissionStringQuery;
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: {
978
+ ${filters?.formZid
979
+ ? `settings_form: {zid: {_eq: ${filters?.formZid}}},`
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
+ }
1024
+ `;
1025
+ exports.getInvoiceFormSubmissionsByInvoiceIdStringQuery = getInvoiceFormSubmissionsByInvoiceIdStringQuery;
1026
+ exports.getCurrenciesStringQuery = `
1027
+ query getCurrencies {
1028
+ currencies {
1029
+ id
1030
+ name
1031
+ prefix
1032
+ code
1033
+ country
1034
+ plural_name
1035
+ }
1036
+ }
1037
+ `;
1038
+ const getSuggestedPricesStringQuery = (config = {
1039
+ notNullPriceList: false,
1040
+ withItems: false,
1041
+ withItemCategories: false,
1042
+ onlyCurrent: false,
1043
+ }) => `
1044
+ query getSuggestedPrices {
1045
+ suggested_prices ${config?.notNullPriceList || config?.onlyCurrent
1046
+ ? `(
1047
+ where: {${[
1048
+ config?.onlyCurrent ? "current: { _eq: true }" : "",
1049
+ config?.notNullPriceList ? "price_list_id: { _is_null: false }" : "",
1050
+ ]
1051
+ .filter(Boolean)
1052
+ .join(", ")}
1053
+ }
1054
+ )`
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
+ }
1070
+ ${config?.withItems
1071
+ ? `item {
1072
+ id
1073
+ name
1074
+ stocks_only_integer
1075
+ code
1076
+ product_type
1077
+ ${config?.withItemCategories
1078
+ ? `
1079
+ item_category {
1080
+ id
1081
+ name
1082
+ notes
1083
+ items_count
1084
+ }
1085
+ `
1086
+ : ""}
1087
+ }`
1088
+ : ""}
1089
+ }
1090
+ }
1091
+ `;
1092
+ exports.getSuggestedPricesStringQuery = getSuggestedPricesStringQuery;
1093
+ exports.getPaymentTermsStringQuery = `
1094
+ query getPaymentTerms {
1095
+ payment_terms {
1096
+ active
1097
+ id
1098
+ memo
1099
+ name
1100
+ }
1101
+ }
1102
+ `;
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
+ }
1117
+ `;
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
+ }
1164
+ `;
1165
+ const getCasesByResponsibleIdStringQuery = (wheres = []) => {
1166
+ const additionalWheres = wheres.join(",");
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
+ }
1204
+ `;
1205
+ };
1206
+ exports.getCasesByResponsibleIdStringQuery = getCasesByResponsibleIdStringQuery;