@tillhub/schemas 6.121.0 → 6.124.0

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,4 +1,4 @@
1
- const { oneOf } = require('../../../helpers/payload-or-null')
1
+ const { anyOf, oneOf } = require('../../../helpers/payload-or-null')
2
2
  const productServiceAnswerObject = require('../../transactions/components/embedded/product_service_answer/base')
3
3
  const returnReason = require('../../transactions/components/embedded/return/return_reason')
4
4
  const voucherObject = require('../../transactions/components/embedded/voucher/base')
@@ -6,34 +6,34 @@ const customProperties = require('../../../common/custom_properties')
6
6
 
7
7
  const masterData = {
8
8
  salesman_staff: {
9
- oneOf: [
10
- {
11
- type: 'string',
12
- format: 'uuid'
13
- },
14
- {
15
- type: 'null'
16
- }
17
- ]
9
+ description: 'Staff person ID',
10
+ ...oneOf({
11
+ type: 'string',
12
+ format: 'uuid'
13
+ })
18
14
  },
19
15
  tax: {
16
+ description: 'Tax rate ID',
20
17
  type: 'string',
21
18
  format: 'uuid'
22
19
  },
23
20
  account: {
21
+ description: 'Account ID',
24
22
  type: 'string',
25
23
  format: 'uuid'
26
24
  },
25
+ account_number: {
26
+ description: 'Account number',
27
+ ...oneOf({
28
+ type: 'string'
29
+ })
30
+ },
27
31
  product_group: {
28
- oneOf: [
29
- {
30
- type: 'string',
31
- format: 'uuid'
32
- },
33
- {
34
- type: 'null'
35
- }
36
- ]
32
+ description: 'Product group ID',
33
+ ...oneOf({
34
+ type: 'string',
35
+ format: 'uuid'
36
+ })
37
37
  }
38
38
  }
39
39
 
@@ -88,16 +88,11 @@ const externalDiscounts = {
88
88
  type: 'object',
89
89
  properties: {
90
90
  rate: {
91
- oneOf: [
92
- {
93
- type: 'number',
94
- minimum: 0,
95
- maximum: 1
96
- },
97
- {
98
- type: 'null'
99
- }
100
- ]
91
+ ...oneOf({
92
+ type: 'number',
93
+ minimum: 0,
94
+ maximum: 1
95
+ })
101
96
  },
102
97
  order_index: {
103
98
  type: 'integer'
@@ -139,14 +134,9 @@ const externalDiscounts = {
139
134
  type: 'object',
140
135
  properties: {
141
136
  value: {
142
- oneOf: [
143
- {
144
- type: 'number'
145
- },
146
- {
147
- type: 'null'
148
- }
149
- ]
137
+ ...oneOf({
138
+ type: 'number'
139
+ })
150
140
  },
151
141
  order_index: {
152
142
  type: 'integer'
@@ -310,26 +300,16 @@ const internalDiscounts = {
310
300
  description: 'The logical group type of the discount, reflecting it\'s origin.'
311
301
  },
312
302
  value: {
313
- oneOf: [
314
- {
315
- type: 'number'
316
- },
317
- {
318
- type: 'null'
319
- }
320
- ]
303
+ ...oneOf({
304
+ type: 'number'
305
+ })
321
306
  },
322
307
  rate: {
323
- oneOf: [
324
- {
325
- type: 'number',
326
- minimum: 0,
327
- maximum: 1
328
- },
329
- {
330
- type: 'null'
331
- }
332
- ]
308
+ ...oneOf({
309
+ type: 'number',
310
+ minimum: 0,
311
+ maximum: 1
312
+ })
333
313
  },
334
314
  client_id: {
335
315
  type: 'string',
@@ -337,61 +317,41 @@ const internalDiscounts = {
337
317
  },
338
318
  external_reference_id: {
339
319
  description: 'A caller defined custom ID for the purpose of syncing from external resources, or to use in analytics.',
340
- oneOf: [
341
- {
342
- type: 'string',
343
- maxLength: 128
344
- },
345
- {
346
- type: 'null'
347
- }
348
- ]
320
+ ...oneOf({
321
+ type: 'string',
322
+ maxLength: 128
323
+ })
349
324
  },
350
325
  source_id: {
351
326
  description: 'The Tillhub discount resource (if available)',
352
- oneOf: [
353
- {
354
- type: 'string',
355
- format: 'uuid'
356
- },
357
- {
358
- type: 'null'
359
- }
360
- ]
327
+ ...oneOf({
328
+ type: 'string',
329
+ format: 'uuid'
330
+ })
361
331
  },
362
332
  assignment_id: {
363
333
  description: 'Identification of the process that created this discount',
364
- oneOf: [
365
- {
366
- type: 'string',
367
- maxLength: 128
368
- },
369
- {
370
- type: 'null'
371
- }
372
- ]
334
+ ...oneOf({
335
+ type: 'string',
336
+ maxLength: 128
337
+ })
373
338
  },
374
339
  assignment_source: {
375
340
  description: 'Identification of the source of the process that created this discount',
376
- oneOf: [
377
- {
378
- type: 'string',
379
- enum: [
380
- 'customer',
381
- 'staff',
382
- 'cart',
383
- 'product_set',
384
- 'sconto',
385
- 'item',
386
- 'promotion',
387
- 'voucher',
388
- 'product_voucher'
389
- ]
390
- },
391
- {
392
- type: 'null'
393
- }
394
- ]
341
+ ...oneOf({
342
+ type: 'string',
343
+ enum: [
344
+ 'customer',
345
+ 'staff',
346
+ 'cart',
347
+ 'product_set',
348
+ 'sconto',
349
+ 'item',
350
+ 'promotion',
351
+ 'voucher',
352
+ 'product_voucher'
353
+ ]
354
+ })
395
355
  },
396
356
  name: {
397
357
  type: 'string',
@@ -457,24 +417,22 @@ const internalDiscounts = {
457
417
 
458
418
  const base = {
459
419
  name: {
420
+ description: 'Cart item display name',
460
421
  type: 'string',
461
422
  minLength: 1,
462
423
  maxLength: 128
463
424
  },
464
425
  position: {
426
+ description: 'Cart item position',
465
427
  type: 'number',
466
428
  minimum: 0
467
429
  },
468
430
  comments: {
469
- anyOf: [
470
- {
471
- type: 'string',
472
- maxLength: 4096
473
- },
474
- {
475
- type: 'null'
476
- }
477
- ],
431
+ description: 'Additional comments',
432
+ ...anyOf({
433
+ type: 'string',
434
+ maxLength: 4096
435
+ }),
478
436
  default: null
479
437
  },
480
438
  client_id: {
@@ -490,117 +448,115 @@ const base = {
490
448
  const externalCart = {
491
449
  additionalProperties: false,
492
450
  type: 'object',
493
- required: [
494
- 'custom_id',
495
- 'qty',
496
- 'name',
497
- 'currency',
498
- 'amount',
499
- 'tax',
500
- 'account'
501
- ],
502
451
  properties: {
503
452
  product: {
504
453
  description: 'The Tillhub product unique identifier',
454
+ example: 'aa165950-26f1-4a59-a85a-1c6017b3cb79',
505
455
  type: 'string',
506
- format: 'uuid',
507
- example: 'aa165950-26f1-4a59-a85a-1c6017b3cb79'
456
+ format: 'uuid'
508
457
  },
509
458
  custom_id: {
510
459
  description: 'The product.custom_id as stated in https://tillhub.atlassian.net/browse/TM-5665',
460
+ example: '260620-727-DE',
511
461
  type: 'string',
512
- maxLength: 128,
513
- example: '260620-727-DE'
462
+ maxLength: 128
514
463
  },
515
464
  product_supplier_name: {
516
- oneOf: [
517
- {
518
- type: 'string',
519
- description: 'Custom identifier for the product\'s supplier',
520
- maxLength: 128
521
- },
522
- {
523
- type: 'null'
524
- }
525
- ]
465
+ description: 'Custom identifier for the product\'s supplier',
466
+ ...oneOf({
467
+ type: 'string',
468
+ maxLength: 128
469
+ })
526
470
  },
527
471
  is_service: {
528
- oneOf: [
529
- {
530
- type: 'boolean',
531
- default: false,
532
- description: 'If true, this item represents a service and might come with answers to service questions'
533
- },
534
- {
535
- type: 'null'
536
- }
537
- ]
472
+ description: 'If true, this item represents a service and might come with answers to service questions',
473
+ default: false,
474
+ ...oneOf({
475
+ type: 'boolean'
476
+ })
538
477
  },
539
478
  discountable: {
540
- // supports correct discount behavior without product lookup
541
- oneOf: [
542
- {
543
- type: 'boolean'
544
- },
545
- {
546
- type: 'null'
547
- }
548
- ]
479
+ description: 'Supports correct discount behavior without product lookup',
480
+ ...oneOf({
481
+ type: 'boolean'
482
+ })
549
483
  },
550
484
  qty: {
485
+ description: 'Product quantity in the cart',
486
+ example: 2,
551
487
  type: 'number'
552
488
  },
553
489
  currency: {
490
+ description: 'Currency symbol',
491
+ example: 'EUR',
554
492
  type: 'string',
555
493
  minLength: 3,
556
494
  maxLength: 3
557
495
  },
558
496
  amount: {
559
- ...amount,
560
- description: 'the currency / amount object combination is the Tillhub Money object. In this context it is the price of 1 item. The total will price * qty.'
497
+ description: 'The currency / amount object combination is the Tillhub Money object. In this context it is the price of 1 item. The total will price * qty.',
498
+ ...amount
561
499
  },
562
500
  vat_rate: {
501
+ description: 'VAT rate',
502
+ example: 0.12,
563
503
  type: 'number',
564
504
  minimum: 0,
565
505
  maximum: 1
566
506
  },
567
507
  discounts: externalDiscounts,
568
508
  ...base
569
- }
509
+ },
510
+ anyOf: [{
511
+ required: [
512
+ 'custom_id',
513
+ 'qty',
514
+ 'name',
515
+ 'currency',
516
+ 'amount',
517
+ 'tax'
518
+ ]
519
+ }, {
520
+ required: [
521
+ 'custom_id',
522
+ 'qty',
523
+ 'name',
524
+ 'currency',
525
+ 'amount',
526
+ 'vat_rate'
527
+ ]
528
+ }]
570
529
  }
571
530
 
572
531
  const cartOfIds = {
573
- required: [
574
- 'product',
575
- 'currency',
576
- 'qty'
577
- ],
578
532
  additionalProperties: false,
579
533
  type: 'object',
580
534
  properties: {
581
535
  position: {
536
+ description: 'Cart item position',
582
537
  type: 'number',
583
538
  minimum: 0
584
539
  },
585
540
  discountable: {
586
- // supports correct discount behavior without product lookup
587
- oneOf: [
588
- {
589
- type: 'boolean'
590
- },
591
- {
592
- type: 'null'
593
- }
594
- ]
541
+ description: 'Supports correct discount behavior without product lookup',
542
+ ...oneOf({
543
+ type: 'boolean'
544
+ })
595
545
  },
596
546
  product: {
547
+ description: 'Identifier of the product',
548
+ example: 'cd0a2886-e245-4ed9-a758-443e7e5b3a3f',
597
549
  type: 'string'
598
550
  // format: 'uuid'
599
551
  },
600
552
  qty: {
553
+ description: 'Product quantity in the cart',
554
+ example: 2,
601
555
  type: 'number'
602
556
  },
603
557
  currency: {
558
+ description: 'Currency symbol',
559
+ example: 'EUR',
604
560
  type: 'string',
605
561
  minLength: 3,
606
562
  maxLength: 3
@@ -610,102 +566,84 @@ const cartOfIds = {
610
566
  maxLength: 128
611
567
  },
612
568
  discounts: externalDiscounts
613
- }
569
+ },
570
+ required: [
571
+ 'product',
572
+ 'currency',
573
+ 'qty'
574
+ ]
614
575
  }
615
576
 
616
577
  const internalCart = {
617
578
  additionalProperties: false,
618
579
  type: 'object',
619
- required: [
620
- 'product',
621
- 'qty',
622
- 'custom_id',
623
- 'vat_rate',
624
- 'salesman_staff',
625
- 'tax',
626
- 'account',
627
- 'name',
628
- 'discounts',
629
- 'amount',
630
- 'currency'
631
- ],
632
580
  properties: {
633
581
  product: {
582
+ description: 'Identifier of the product',
583
+ example: 'cd0a2886-e245-4ed9-a758-443e7e5b3a3f',
634
584
  type: 'string',
635
585
  format: 'uuid'
636
586
  },
637
587
  product_supplier_name: {
638
- oneOf: [
639
- {
640
- type: 'string',
641
- description: 'Custom identifier for the product\'s supplier',
642
- maxLength: 128
643
- },
644
- {
645
- type: 'null'
646
- }
647
- ]
588
+ description: 'Custom identifier for the product\'s supplier',
589
+ example: '00555kff34323',
590
+ ...oneOf({
591
+ type: 'string',
592
+ maxLength: 128
593
+ })
648
594
  },
649
595
  is_service: {
650
- oneOf: [
651
- {
652
- type: 'boolean',
653
- default: false,
654
- description: 'If true, this item represents a service and might come with answers to service questions'
655
- },
656
- {
657
- type: 'null'
658
- }
659
- ]
596
+ description: 'If true, this item represents a service and might come with answers to service questions',
597
+ ...oneOf({
598
+ type: 'boolean',
599
+ default: false
600
+ })
660
601
  },
661
602
  discountable: {
662
- // supports correct discount behavior without product lookup
663
- oneOf: [
664
- {
665
- type: 'boolean'
666
- },
667
- {
668
- type: 'null'
669
- }
670
- ]
603
+ description: 'Supports correct discount behavior without product lookup',
604
+ ...oneOf({
605
+ type: 'boolean'
606
+ })
671
607
  },
672
608
  qty: {
609
+ description: 'Product quantity in the cart',
610
+ example: 2,
673
611
  type: 'number'
674
612
  },
675
613
  custom_id: {
676
- oneOf: [
677
- {
678
- type: 'string',
679
- maxLength: 128
680
- },
681
- {
682
- type: 'null'
683
- }
684
- ]
614
+ description: 'Custom cart item ID',
615
+ ...oneOf({
616
+ type: 'string',
617
+ maxLength: 128
618
+ })
685
619
  },
686
620
  vat_rate: {
621
+ description: 'VAT rate',
622
+ example: 0.12,
687
623
  type: 'number',
688
624
  minimum: 0,
689
625
  maximum: 1
690
626
  },
691
- vat_rate_class: oneOf({
692
- default: 'normal',
627
+ vat_rate_class: {
693
628
  description: 'Rate class from \'taxes.rate_class\' according to international standards, used in Germany to map types for e.g. fiscalization',
694
- type: 'string',
695
- 'enum': [
696
- 'normal',
697
- 'reduced',
698
- 'super_reduced'
699
- ]
700
- }),
629
+ default: 'normal',
630
+ ...oneOf({
631
+ type: 'string',
632
+ 'enum': [
633
+ 'normal',
634
+ 'reduced',
635
+ 'super_reduced'
636
+ ]
637
+ })
638
+ },
701
639
  currency: {
640
+ description: 'Currency symbol',
641
+ example: 'EUR',
702
642
  type: 'string',
703
643
  minLength: 3,
704
644
  maxLength: 3
705
645
  },
706
- amount: {
707
- ...amount
708
- },
646
+ amount,
709
647
  promotion_amount: oneOf({
710
648
  description: 'The promotion amount on the per unit qty base of 1.',
711
649
  type: 'number',
@@ -728,10 +666,10 @@ const internalCart = {
728
666
  }
729
667
  }),
730
668
  is_voucher: {
669
+ description: 'If true, this item represents a voucher and must come with voucher information in \'voucher\'',
670
+ default: false,
731
671
  ...oneOf({
732
- type: 'boolean',
733
- default: false,
734
- description: 'If true, this item represents a voucher and must come with voucher information in \'voucher\''
672
+ type: 'boolean'
735
673
  })
736
674
  },
737
675
  voucher: {
@@ -741,47 +679,67 @@ const internalCart = {
741
679
  default: null
742
680
  },
743
681
  is_refund: {
682
+ description: 'If true, the item was created by (partially) refunding a previous sale.',
744
683
  ...oneOf({
745
- type: 'boolean',
746
- description: 'If true, the item was created by (partially) refunding a previous sale.'
684
+ type: 'boolean'
747
685
  })
748
686
  },
749
687
  return_reason: returnReason,
750
688
  attributes_description: {
689
+ description: 'A short description of the child attributes in variant products',
690
+ example: 'red | big | 32',
751
691
  ...oneOf({
752
- type: 'string',
753
- example: 'red | big | 32',
754
- description: 'A short description of the child attributes in variant products'
692
+ type: 'string'
755
693
  })
756
694
  },
757
695
  reference_cartitem_client_id: {
696
+ description: 'In cases of refund or cancellation, or invoicing a delivery note or selling a saved cart: the client_id of the origin item',
697
+ example: '01331B44-130B-45D4-97A7-401247FD5B68',
758
698
  ...oneOf({
759
- type: 'string',
760
- example: '01331B44-130B-45D4-97A7-401247FD5B68',
761
- description: 'In cases of refund or cancellation, or invoicing a delivery note or selling a saved cart: the client_id of the origin item'
699
+ type: 'string'
762
700
  })
763
701
  },
764
702
  used_barcode: {
703
+ description: 'The barcode used to trigger putting this item into the cart (defaults to the first available barcode from the product)',
704
+ example: '0E9761310XF',
765
705
  ...oneOf({
766
- type: 'string',
767
- example: '0E9761310XF',
768
- description: 'The barcode used to trigger putting this item into the cart (defaults to the first available barcode from the product)'
706
+ type: 'string'
769
707
  })
770
708
  },
771
709
  ...base,
772
710
  discounts: internalDiscounts,
773
711
  attributes: {
774
712
  default: null,
775
- anyOf: [
776
- {
777
- type: 'object'
778
- },
779
- {
780
- type: 'null'
781
- }
782
- ]
713
+ ...anyOf({
714
+ type: 'object'
715
+ })
783
716
  }
784
- }
717
+ },
718
+ anyOf: [{
719
+ required: [
720
+ 'product',
721
+ 'qty',
722
+ 'custom_id',
723
+ 'salesman_staff',
724
+ 'name',
725
+ 'discounts',
726
+ 'amount',
727
+ 'currency',
728
+ 'tax'
729
+ ]
730
+ }, {
731
+ required: [
732
+ 'product',
733
+ 'qty',
734
+ 'custom_id',
735
+ 'salesman_staff',
736
+ 'name',
737
+ 'discounts',
738
+ 'amount',
739
+ 'currency',
740
+ 'vat_rate'
741
+ ]
742
+ }]
785
743
  }
786
744
 
787
745
  module.exports = {
@@ -790,7 +748,7 @@ module.exports = {
790
748
  maxItems: 300,
791
749
  items: {
792
750
  anyOf: [
793
- // order is important: most specialised schema will win
751
+ // order is important: most specialized schema will win
794
752
  internalCart,
795
753
  externalCart,
796
754
  cartOfIds