@adatechnology/purchase-module 0.0.0-stage → 0.1.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.
@@ -0,0 +1,1503 @@
1
+ {
2
+ "id": "d6a23c7f-bb1c-40de-ae46-dd7415cab36c",
3
+ "prevId": "00000000-0000-0000-0000-000000000000",
4
+ "version": "7",
5
+ "dialect": "postgresql",
6
+ "tables": {
7
+ "purchase.order_counters": {
8
+ "name": "order_counters",
9
+ "schema": "purchase",
10
+ "columns": {
11
+ "company_id": {
12
+ "name": "company_id",
13
+ "type": "uuid",
14
+ "primaryKey": true,
15
+ "notNull": true
16
+ },
17
+ "last_number": {
18
+ "name": "last_number",
19
+ "type": "integer",
20
+ "primaryKey": false,
21
+ "notNull": true,
22
+ "default": 0
23
+ }
24
+ },
25
+ "indexes": {},
26
+ "foreignKeys": {},
27
+ "compositePrimaryKeys": {},
28
+ "uniqueConstraints": {},
29
+ "policies": {},
30
+ "checkConstraints": {},
31
+ "isRLSEnabled": false
32
+ },
33
+ "purchase.order_lines": {
34
+ "name": "order_lines",
35
+ "schema": "purchase",
36
+ "columns": {
37
+ "id": {
38
+ "name": "id",
39
+ "type": "uuid",
40
+ "primaryKey": true,
41
+ "notNull": true,
42
+ "default": "gen_random_uuid()"
43
+ },
44
+ "order_id": {
45
+ "name": "order_id",
46
+ "type": "uuid",
47
+ "primaryKey": false,
48
+ "notNull": true
49
+ },
50
+ "company_id": {
51
+ "name": "company_id",
52
+ "type": "uuid",
53
+ "primaryKey": false,
54
+ "notNull": true
55
+ },
56
+ "position": {
57
+ "name": "position",
58
+ "type": "integer",
59
+ "primaryKey": false,
60
+ "notNull": true
61
+ },
62
+ "supplier_item_id": {
63
+ "name": "supplier_item_id",
64
+ "type": "uuid",
65
+ "primaryKey": false,
66
+ "notNull": false
67
+ },
68
+ "item_ref": {
69
+ "name": "item_ref",
70
+ "type": "varchar(128)",
71
+ "primaryKey": false,
72
+ "notNull": false
73
+ },
74
+ "item_name": {
75
+ "name": "item_name",
76
+ "type": "varchar(160)",
77
+ "primaryKey": false,
78
+ "notNull": true
79
+ },
80
+ "supplier_sku": {
81
+ "name": "supplier_sku",
82
+ "type": "varchar(100)",
83
+ "primaryKey": false,
84
+ "notNull": false
85
+ },
86
+ "purchase_unit": {
87
+ "name": "purchase_unit",
88
+ "type": "varchar(12)",
89
+ "primaryKey": false,
90
+ "notNull": true
91
+ },
92
+ "units_per_purchase": {
93
+ "name": "units_per_purchase",
94
+ "type": "numeric(14, 4)",
95
+ "primaryKey": false,
96
+ "notNull": true,
97
+ "default": "'1'"
98
+ },
99
+ "stock_unit": {
100
+ "name": "stock_unit",
101
+ "type": "varchar(8)",
102
+ "primaryKey": false,
103
+ "notNull": false
104
+ },
105
+ "quantity": {
106
+ "name": "quantity",
107
+ "type": "numeric(14, 4)",
108
+ "primaryKey": false,
109
+ "notNull": true
110
+ },
111
+ "unit_price": {
112
+ "name": "unit_price",
113
+ "type": "numeric(14, 4)",
114
+ "primaryKey": false,
115
+ "notNull": true,
116
+ "default": "'0'"
117
+ },
118
+ "line_total": {
119
+ "name": "line_total",
120
+ "type": "numeric(14, 2)",
121
+ "primaryKey": false,
122
+ "notNull": true,
123
+ "default": "'0'"
124
+ },
125
+ "received_quantity": {
126
+ "name": "received_quantity",
127
+ "type": "numeric(14, 4)",
128
+ "primaryKey": false,
129
+ "notNull": true,
130
+ "default": "'0'"
131
+ },
132
+ "canceled_quantity": {
133
+ "name": "canceled_quantity",
134
+ "type": "numeric(14, 4)",
135
+ "primaryKey": false,
136
+ "notNull": true,
137
+ "default": "'0'"
138
+ },
139
+ "notes": {
140
+ "name": "notes",
141
+ "type": "varchar(500)",
142
+ "primaryKey": false,
143
+ "notNull": false
144
+ }
145
+ },
146
+ "indexes": {
147
+ "idx_purchase_order_lines_order": {
148
+ "name": "idx_purchase_order_lines_order",
149
+ "columns": [
150
+ {
151
+ "expression": "order_id",
152
+ "isExpression": false,
153
+ "asc": true,
154
+ "nulls": "last"
155
+ },
156
+ {
157
+ "expression": "position",
158
+ "isExpression": false,
159
+ "asc": true,
160
+ "nulls": "last"
161
+ }
162
+ ],
163
+ "isUnique": false,
164
+ "concurrently": false,
165
+ "method": "btree",
166
+ "with": {}
167
+ },
168
+ "idx_purchase_order_lines_item": {
169
+ "name": "idx_purchase_order_lines_item",
170
+ "columns": [
171
+ {
172
+ "expression": "company_id",
173
+ "isExpression": false,
174
+ "asc": true,
175
+ "nulls": "last"
176
+ },
177
+ {
178
+ "expression": "item_ref",
179
+ "isExpression": false,
180
+ "asc": true,
181
+ "nulls": "last"
182
+ }
183
+ ],
184
+ "isUnique": false,
185
+ "concurrently": false,
186
+ "method": "btree",
187
+ "with": {}
188
+ }
189
+ },
190
+ "foreignKeys": {
191
+ "order_lines_order_id_orders_id_fk": {
192
+ "name": "order_lines_order_id_orders_id_fk",
193
+ "tableFrom": "order_lines",
194
+ "tableTo": "orders",
195
+ "schemaTo": "purchase",
196
+ "columnsFrom": [
197
+ "order_id"
198
+ ],
199
+ "columnsTo": [
200
+ "id"
201
+ ],
202
+ "onDelete": "cascade",
203
+ "onUpdate": "no action"
204
+ },
205
+ "order_lines_supplier_item_id_supplier_items_id_fk": {
206
+ "name": "order_lines_supplier_item_id_supplier_items_id_fk",
207
+ "tableFrom": "order_lines",
208
+ "tableTo": "supplier_items",
209
+ "schemaTo": "purchase",
210
+ "columnsFrom": [
211
+ "supplier_item_id"
212
+ ],
213
+ "columnsTo": [
214
+ "id"
215
+ ],
216
+ "onDelete": "set null",
217
+ "onUpdate": "no action"
218
+ }
219
+ },
220
+ "compositePrimaryKeys": {},
221
+ "uniqueConstraints": {},
222
+ "policies": {},
223
+ "checkConstraints": {
224
+ "purchase_order_lines_quantity_positive": {
225
+ "name": "purchase_order_lines_quantity_positive",
226
+ "value": "\"quantity\" > 0"
227
+ },
228
+ "purchase_order_lines_units_positive": {
229
+ "name": "purchase_order_lines_units_positive",
230
+ "value": "\"units_per_purchase\" > 0"
231
+ }
232
+ },
233
+ "isRLSEnabled": false
234
+ },
235
+ "purchase.orders": {
236
+ "name": "orders",
237
+ "schema": "purchase",
238
+ "columns": {
239
+ "id": {
240
+ "name": "id",
241
+ "type": "uuid",
242
+ "primaryKey": true,
243
+ "notNull": true,
244
+ "default": "gen_random_uuid()"
245
+ },
246
+ "company_id": {
247
+ "name": "company_id",
248
+ "type": "uuid",
249
+ "primaryKey": false,
250
+ "notNull": true
251
+ },
252
+ "number": {
253
+ "name": "number",
254
+ "type": "integer",
255
+ "primaryKey": false,
256
+ "notNull": true
257
+ },
258
+ "supplier_id": {
259
+ "name": "supplier_id",
260
+ "type": "uuid",
261
+ "primaryKey": false,
262
+ "notNull": true
263
+ },
264
+ "status": {
265
+ "name": "status",
266
+ "type": "varchar(20)",
267
+ "primaryKey": false,
268
+ "notNull": true,
269
+ "default": "'draft'"
270
+ },
271
+ "expected_at": {
272
+ "name": "expected_at",
273
+ "type": "date",
274
+ "primaryKey": false,
275
+ "notNull": false
276
+ },
277
+ "notes": {
278
+ "name": "notes",
279
+ "type": "text",
280
+ "primaryKey": false,
281
+ "notNull": true,
282
+ "default": "''"
283
+ },
284
+ "subtotal": {
285
+ "name": "subtotal",
286
+ "type": "numeric(14, 2)",
287
+ "primaryKey": false,
288
+ "notNull": true,
289
+ "default": "'0'"
290
+ },
291
+ "freight": {
292
+ "name": "freight",
293
+ "type": "numeric(14, 2)",
294
+ "primaryKey": false,
295
+ "notNull": true,
296
+ "default": "'0'"
297
+ },
298
+ "discount": {
299
+ "name": "discount",
300
+ "type": "numeric(14, 2)",
301
+ "primaryKey": false,
302
+ "notNull": true,
303
+ "default": "'0'"
304
+ },
305
+ "total": {
306
+ "name": "total",
307
+ "type": "numeric(14, 2)",
308
+ "primaryKey": false,
309
+ "notNull": true,
310
+ "default": "'0'"
311
+ },
312
+ "payment_term_days": {
313
+ "name": "payment_term_days",
314
+ "type": "integer[]",
315
+ "primaryKey": false,
316
+ "notNull": true,
317
+ "default": "'{0}'::integer[]"
318
+ },
319
+ "requires_approval": {
320
+ "name": "requires_approval",
321
+ "type": "boolean",
322
+ "primaryKey": false,
323
+ "notNull": true,
324
+ "default": false
325
+ },
326
+ "created_by": {
327
+ "name": "created_by",
328
+ "type": "varchar(128)",
329
+ "primaryKey": false,
330
+ "notNull": false
331
+ },
332
+ "submitted_by": {
333
+ "name": "submitted_by",
334
+ "type": "varchar(128)",
335
+ "primaryKey": false,
336
+ "notNull": false
337
+ },
338
+ "submitted_at": {
339
+ "name": "submitted_at",
340
+ "type": "timestamp with time zone",
341
+ "primaryKey": false,
342
+ "notNull": false
343
+ },
344
+ "approved_by": {
345
+ "name": "approved_by",
346
+ "type": "varchar(128)",
347
+ "primaryKey": false,
348
+ "notNull": false
349
+ },
350
+ "approved_at": {
351
+ "name": "approved_at",
352
+ "type": "timestamp with time zone",
353
+ "primaryKey": false,
354
+ "notNull": false
355
+ },
356
+ "rejection_reason": {
357
+ "name": "rejection_reason",
358
+ "type": "varchar(500)",
359
+ "primaryKey": false,
360
+ "notNull": false
361
+ },
362
+ "sent_at": {
363
+ "name": "sent_at",
364
+ "type": "timestamp with time zone",
365
+ "primaryKey": false,
366
+ "notNull": false
367
+ },
368
+ "sent_via": {
369
+ "name": "sent_via",
370
+ "type": "varchar(12)",
371
+ "primaryKey": false,
372
+ "notNull": false
373
+ },
374
+ "canceled_at": {
375
+ "name": "canceled_at",
376
+ "type": "timestamp with time zone",
377
+ "primaryKey": false,
378
+ "notNull": false
379
+ },
380
+ "cancel_reason": {
381
+ "name": "cancel_reason",
382
+ "type": "varchar(500)",
383
+ "primaryKey": false,
384
+ "notNull": false
385
+ },
386
+ "closed_at": {
387
+ "name": "closed_at",
388
+ "type": "timestamp with time zone",
389
+ "primaryKey": false,
390
+ "notNull": false
391
+ },
392
+ "last_late_alert_at": {
393
+ "name": "last_late_alert_at",
394
+ "type": "date",
395
+ "primaryKey": false,
396
+ "notNull": false
397
+ },
398
+ "created_at": {
399
+ "name": "created_at",
400
+ "type": "timestamp with time zone",
401
+ "primaryKey": false,
402
+ "notNull": true,
403
+ "default": "now()"
404
+ },
405
+ "updated_at": {
406
+ "name": "updated_at",
407
+ "type": "timestamp with time zone",
408
+ "primaryKey": false,
409
+ "notNull": true,
410
+ "default": "now()"
411
+ }
412
+ },
413
+ "indexes": {
414
+ "uq_purchase_orders_company_number": {
415
+ "name": "uq_purchase_orders_company_number",
416
+ "columns": [
417
+ {
418
+ "expression": "company_id",
419
+ "isExpression": false,
420
+ "asc": true,
421
+ "nulls": "last"
422
+ },
423
+ {
424
+ "expression": "number",
425
+ "isExpression": false,
426
+ "asc": true,
427
+ "nulls": "last"
428
+ }
429
+ ],
430
+ "isUnique": true,
431
+ "concurrently": false,
432
+ "method": "btree",
433
+ "with": {}
434
+ },
435
+ "idx_purchase_orders_company_status": {
436
+ "name": "idx_purchase_orders_company_status",
437
+ "columns": [
438
+ {
439
+ "expression": "company_id",
440
+ "isExpression": false,
441
+ "asc": true,
442
+ "nulls": "last"
443
+ },
444
+ {
445
+ "expression": "status",
446
+ "isExpression": false,
447
+ "asc": true,
448
+ "nulls": "last"
449
+ },
450
+ {
451
+ "expression": "created_at",
452
+ "isExpression": false,
453
+ "asc": true,
454
+ "nulls": "last"
455
+ }
456
+ ],
457
+ "isUnique": false,
458
+ "concurrently": false,
459
+ "method": "btree",
460
+ "with": {}
461
+ },
462
+ "idx_purchase_orders_supplier": {
463
+ "name": "idx_purchase_orders_supplier",
464
+ "columns": [
465
+ {
466
+ "expression": "company_id",
467
+ "isExpression": false,
468
+ "asc": true,
469
+ "nulls": "last"
470
+ },
471
+ {
472
+ "expression": "supplier_id",
473
+ "isExpression": false,
474
+ "asc": true,
475
+ "nulls": "last"
476
+ }
477
+ ],
478
+ "isUnique": false,
479
+ "concurrently": false,
480
+ "method": "btree",
481
+ "with": {}
482
+ },
483
+ "idx_purchase_orders_open_expected": {
484
+ "name": "idx_purchase_orders_open_expected",
485
+ "columns": [
486
+ {
487
+ "expression": "expected_at",
488
+ "isExpression": false,
489
+ "asc": true,
490
+ "nulls": "last"
491
+ }
492
+ ],
493
+ "isUnique": false,
494
+ "where": "\"status\" in ('approved', 'sent', 'partially_received')",
495
+ "concurrently": false,
496
+ "method": "btree",
497
+ "with": {}
498
+ }
499
+ },
500
+ "foreignKeys": {
501
+ "orders_supplier_id_suppliers_id_fk": {
502
+ "name": "orders_supplier_id_suppliers_id_fk",
503
+ "tableFrom": "orders",
504
+ "tableTo": "suppliers",
505
+ "schemaTo": "purchase",
506
+ "columnsFrom": [
507
+ "supplier_id"
508
+ ],
509
+ "columnsTo": [
510
+ "id"
511
+ ],
512
+ "onDelete": "no action",
513
+ "onUpdate": "no action"
514
+ }
515
+ },
516
+ "compositePrimaryKeys": {},
517
+ "uniqueConstraints": {},
518
+ "policies": {},
519
+ "checkConstraints": {},
520
+ "isRLSEnabled": false
521
+ },
522
+ "purchase.receipt_lines": {
523
+ "name": "receipt_lines",
524
+ "schema": "purchase",
525
+ "columns": {
526
+ "id": {
527
+ "name": "id",
528
+ "type": "uuid",
529
+ "primaryKey": true,
530
+ "notNull": true,
531
+ "default": "gen_random_uuid()"
532
+ },
533
+ "receipt_id": {
534
+ "name": "receipt_id",
535
+ "type": "uuid",
536
+ "primaryKey": false,
537
+ "notNull": true
538
+ },
539
+ "company_id": {
540
+ "name": "company_id",
541
+ "type": "uuid",
542
+ "primaryKey": false,
543
+ "notNull": true
544
+ },
545
+ "position": {
546
+ "name": "position",
547
+ "type": "integer",
548
+ "primaryKey": false,
549
+ "notNull": true
550
+ },
551
+ "order_line_id": {
552
+ "name": "order_line_id",
553
+ "type": "uuid",
554
+ "primaryKey": false,
555
+ "notNull": false
556
+ },
557
+ "supplier_item_id": {
558
+ "name": "supplier_item_id",
559
+ "type": "uuid",
560
+ "primaryKey": false,
561
+ "notNull": false
562
+ },
563
+ "item_ref": {
564
+ "name": "item_ref",
565
+ "type": "varchar(128)",
566
+ "primaryKey": false,
567
+ "notNull": false
568
+ },
569
+ "item_name": {
570
+ "name": "item_name",
571
+ "type": "varchar(160)",
572
+ "primaryKey": false,
573
+ "notNull": true
574
+ },
575
+ "supplier_sku": {
576
+ "name": "supplier_sku",
577
+ "type": "varchar(100)",
578
+ "primaryKey": false,
579
+ "notNull": false
580
+ },
581
+ "purchase_unit": {
582
+ "name": "purchase_unit",
583
+ "type": "varchar(12)",
584
+ "primaryKey": false,
585
+ "notNull": true
586
+ },
587
+ "units_per_purchase": {
588
+ "name": "units_per_purchase",
589
+ "type": "numeric(14, 4)",
590
+ "primaryKey": false,
591
+ "notNull": true,
592
+ "default": "'1'"
593
+ },
594
+ "stock_unit": {
595
+ "name": "stock_unit",
596
+ "type": "varchar(8)",
597
+ "primaryKey": false,
598
+ "notNull": false
599
+ },
600
+ "quantity": {
601
+ "name": "quantity",
602
+ "type": "numeric(14, 4)",
603
+ "primaryKey": false,
604
+ "notNull": true
605
+ },
606
+ "unit_price": {
607
+ "name": "unit_price",
608
+ "type": "numeric(14, 4)",
609
+ "primaryKey": false,
610
+ "notNull": true
611
+ },
612
+ "line_total": {
613
+ "name": "line_total",
614
+ "type": "numeric(14, 2)",
615
+ "primaryKey": false,
616
+ "notNull": true
617
+ },
618
+ "allocated": {
619
+ "name": "allocated",
620
+ "type": "numeric(14, 2)",
621
+ "primaryKey": false,
622
+ "notNull": true,
623
+ "default": "'0'"
624
+ },
625
+ "landed_unit_cost": {
626
+ "name": "landed_unit_cost",
627
+ "type": "numeric(14, 4)",
628
+ "primaryKey": false,
629
+ "notNull": false
630
+ },
631
+ "batch_code": {
632
+ "name": "batch_code",
633
+ "type": "varchar(100)",
634
+ "primaryKey": false,
635
+ "notNull": false
636
+ },
637
+ "expires_at": {
638
+ "name": "expires_at",
639
+ "type": "date",
640
+ "primaryKey": false,
641
+ "notNull": false
642
+ },
643
+ "divergence": {
644
+ "name": "divergence",
645
+ "type": "varchar(10)",
646
+ "primaryKey": false,
647
+ "notNull": true,
648
+ "default": "'none'"
649
+ },
650
+ "divergence_reason": {
651
+ "name": "divergence_reason",
652
+ "type": "varchar(500)",
653
+ "primaryKey": false,
654
+ "notNull": false
655
+ },
656
+ "stock_status": {
657
+ "name": "stock_status",
658
+ "type": "varchar(10)",
659
+ "primaryKey": false,
660
+ "notNull": true,
661
+ "default": "'skipped'"
662
+ }
663
+ },
664
+ "indexes": {
665
+ "idx_purchase_receipt_lines_receipt": {
666
+ "name": "idx_purchase_receipt_lines_receipt",
667
+ "columns": [
668
+ {
669
+ "expression": "receipt_id",
670
+ "isExpression": false,
671
+ "asc": true,
672
+ "nulls": "last"
673
+ },
674
+ {
675
+ "expression": "position",
676
+ "isExpression": false,
677
+ "asc": true,
678
+ "nulls": "last"
679
+ }
680
+ ],
681
+ "isUnique": false,
682
+ "concurrently": false,
683
+ "method": "btree",
684
+ "with": {}
685
+ },
686
+ "idx_purchase_receipt_lines_item": {
687
+ "name": "idx_purchase_receipt_lines_item",
688
+ "columns": [
689
+ {
690
+ "expression": "company_id",
691
+ "isExpression": false,
692
+ "asc": true,
693
+ "nulls": "last"
694
+ },
695
+ {
696
+ "expression": "item_ref",
697
+ "isExpression": false,
698
+ "asc": true,
699
+ "nulls": "last"
700
+ }
701
+ ],
702
+ "isUnique": false,
703
+ "concurrently": false,
704
+ "method": "btree",
705
+ "with": {}
706
+ },
707
+ "idx_purchase_receipt_lines_supplier_item": {
708
+ "name": "idx_purchase_receipt_lines_supplier_item",
709
+ "columns": [
710
+ {
711
+ "expression": "supplier_item_id",
712
+ "isExpression": false,
713
+ "asc": true,
714
+ "nulls": "last"
715
+ }
716
+ ],
717
+ "isUnique": false,
718
+ "concurrently": false,
719
+ "method": "btree",
720
+ "with": {}
721
+ }
722
+ },
723
+ "foreignKeys": {
724
+ "receipt_lines_receipt_id_receipts_id_fk": {
725
+ "name": "receipt_lines_receipt_id_receipts_id_fk",
726
+ "tableFrom": "receipt_lines",
727
+ "tableTo": "receipts",
728
+ "schemaTo": "purchase",
729
+ "columnsFrom": [
730
+ "receipt_id"
731
+ ],
732
+ "columnsTo": [
733
+ "id"
734
+ ],
735
+ "onDelete": "cascade",
736
+ "onUpdate": "no action"
737
+ },
738
+ "receipt_lines_order_line_id_order_lines_id_fk": {
739
+ "name": "receipt_lines_order_line_id_order_lines_id_fk",
740
+ "tableFrom": "receipt_lines",
741
+ "tableTo": "order_lines",
742
+ "schemaTo": "purchase",
743
+ "columnsFrom": [
744
+ "order_line_id"
745
+ ],
746
+ "columnsTo": [
747
+ "id"
748
+ ],
749
+ "onDelete": "set null",
750
+ "onUpdate": "no action"
751
+ },
752
+ "receipt_lines_supplier_item_id_supplier_items_id_fk": {
753
+ "name": "receipt_lines_supplier_item_id_supplier_items_id_fk",
754
+ "tableFrom": "receipt_lines",
755
+ "tableTo": "supplier_items",
756
+ "schemaTo": "purchase",
757
+ "columnsFrom": [
758
+ "supplier_item_id"
759
+ ],
760
+ "columnsTo": [
761
+ "id"
762
+ ],
763
+ "onDelete": "set null",
764
+ "onUpdate": "no action"
765
+ }
766
+ },
767
+ "compositePrimaryKeys": {},
768
+ "uniqueConstraints": {},
769
+ "policies": {},
770
+ "checkConstraints": {
771
+ "purchase_receipt_lines_quantity_positive": {
772
+ "name": "purchase_receipt_lines_quantity_positive",
773
+ "value": "\"quantity\" > 0"
774
+ }
775
+ },
776
+ "isRLSEnabled": false
777
+ },
778
+ "purchase.receipt_payments": {
779
+ "name": "receipt_payments",
780
+ "schema": "purchase",
781
+ "columns": {
782
+ "company_id": {
783
+ "name": "company_id",
784
+ "type": "uuid",
785
+ "primaryKey": false,
786
+ "notNull": true
787
+ },
788
+ "receipt_id": {
789
+ "name": "receipt_id",
790
+ "type": "uuid",
791
+ "primaryKey": false,
792
+ "notNull": true
793
+ },
794
+ "installment_number": {
795
+ "name": "installment_number",
796
+ "type": "integer",
797
+ "primaryKey": false,
798
+ "notNull": true
799
+ },
800
+ "paid_amount": {
801
+ "name": "paid_amount",
802
+ "type": "numeric(14, 2)",
803
+ "primaryKey": false,
804
+ "notNull": true
805
+ },
806
+ "paid_at": {
807
+ "name": "paid_at",
808
+ "type": "date",
809
+ "primaryKey": false,
810
+ "notNull": true
811
+ }
812
+ },
813
+ "indexes": {},
814
+ "foreignKeys": {
815
+ "receipt_payments_receipt_id_receipts_id_fk": {
816
+ "name": "receipt_payments_receipt_id_receipts_id_fk",
817
+ "tableFrom": "receipt_payments",
818
+ "tableTo": "receipts",
819
+ "schemaTo": "purchase",
820
+ "columnsFrom": [
821
+ "receipt_id"
822
+ ],
823
+ "columnsTo": [
824
+ "id"
825
+ ],
826
+ "onDelete": "cascade",
827
+ "onUpdate": "no action"
828
+ }
829
+ },
830
+ "compositePrimaryKeys": {
831
+ "receipt_payments_receipt_id_installment_number_pk": {
832
+ "name": "receipt_payments_receipt_id_installment_number_pk",
833
+ "columns": [
834
+ "receipt_id",
835
+ "installment_number"
836
+ ]
837
+ }
838
+ },
839
+ "uniqueConstraints": {},
840
+ "policies": {},
841
+ "checkConstraints": {},
842
+ "isRLSEnabled": false
843
+ },
844
+ "purchase.receipts": {
845
+ "name": "receipts",
846
+ "schema": "purchase",
847
+ "columns": {
848
+ "id": {
849
+ "name": "id",
850
+ "type": "uuid",
851
+ "primaryKey": true,
852
+ "notNull": true,
853
+ "default": "gen_random_uuid()"
854
+ },
855
+ "company_id": {
856
+ "name": "company_id",
857
+ "type": "uuid",
858
+ "primaryKey": false,
859
+ "notNull": true
860
+ },
861
+ "order_id": {
862
+ "name": "order_id",
863
+ "type": "uuid",
864
+ "primaryKey": false,
865
+ "notNull": false
866
+ },
867
+ "supplier_id": {
868
+ "name": "supplier_id",
869
+ "type": "uuid",
870
+ "primaryKey": false,
871
+ "notNull": true
872
+ },
873
+ "received_at": {
874
+ "name": "received_at",
875
+ "type": "timestamp with time zone",
876
+ "primaryKey": false,
877
+ "notNull": true
878
+ },
879
+ "invoice_number": {
880
+ "name": "invoice_number",
881
+ "type": "varchar(30)",
882
+ "primaryKey": false,
883
+ "notNull": false
884
+ },
885
+ "invoice_key": {
886
+ "name": "invoice_key",
887
+ "type": "varchar(44)",
888
+ "primaryKey": false,
889
+ "notNull": false
890
+ },
891
+ "invoice_issued_at": {
892
+ "name": "invoice_issued_at",
893
+ "type": "timestamp with time zone",
894
+ "primaryKey": false,
895
+ "notNull": false
896
+ },
897
+ "subtotal": {
898
+ "name": "subtotal",
899
+ "type": "numeric(14, 2)",
900
+ "primaryKey": false,
901
+ "notNull": true
902
+ },
903
+ "freight": {
904
+ "name": "freight",
905
+ "type": "numeric(14, 2)",
906
+ "primaryKey": false,
907
+ "notNull": true,
908
+ "default": "'0'"
909
+ },
910
+ "discount": {
911
+ "name": "discount",
912
+ "type": "numeric(14, 2)",
913
+ "primaryKey": false,
914
+ "notNull": true,
915
+ "default": "'0'"
916
+ },
917
+ "total": {
918
+ "name": "total",
919
+ "type": "numeric(14, 2)",
920
+ "primaryKey": false,
921
+ "notNull": true
922
+ },
923
+ "notes": {
924
+ "name": "notes",
925
+ "type": "text",
926
+ "primaryKey": false,
927
+ "notNull": true,
928
+ "default": "''"
929
+ },
930
+ "actor_id": {
931
+ "name": "actor_id",
932
+ "type": "varchar(128)",
933
+ "primaryKey": false,
934
+ "notNull": false
935
+ },
936
+ "idempotency_key": {
937
+ "name": "idempotency_key",
938
+ "type": "varchar(128)",
939
+ "primaryKey": false,
940
+ "notNull": false
941
+ },
942
+ "installments": {
943
+ "name": "installments",
944
+ "type": "text",
945
+ "primaryKey": false,
946
+ "notNull": true,
947
+ "default": "'[]'"
948
+ },
949
+ "stock_status": {
950
+ "name": "stock_status",
951
+ "type": "varchar(10)",
952
+ "primaryKey": false,
953
+ "notNull": true,
954
+ "default": "'skipped'"
955
+ },
956
+ "payable_status": {
957
+ "name": "payable_status",
958
+ "type": "varchar(10)",
959
+ "primaryKey": false,
960
+ "notNull": true,
961
+ "default": "'skipped'"
962
+ },
963
+ "payable_ref": {
964
+ "name": "payable_ref",
965
+ "type": "varchar(200)",
966
+ "primaryKey": false,
967
+ "notNull": false
968
+ },
969
+ "payment_status": {
970
+ "name": "payment_status",
971
+ "type": "varchar(10)",
972
+ "primaryKey": false,
973
+ "notNull": true,
974
+ "default": "'none'"
975
+ },
976
+ "created_at": {
977
+ "name": "created_at",
978
+ "type": "timestamp with time zone",
979
+ "primaryKey": false,
980
+ "notNull": true,
981
+ "default": "now()"
982
+ }
983
+ },
984
+ "indexes": {
985
+ "idx_purchase_receipts_company_received": {
986
+ "name": "idx_purchase_receipts_company_received",
987
+ "columns": [
988
+ {
989
+ "expression": "company_id",
990
+ "isExpression": false,
991
+ "asc": true,
992
+ "nulls": "last"
993
+ },
994
+ {
995
+ "expression": "received_at",
996
+ "isExpression": false,
997
+ "asc": true,
998
+ "nulls": "last"
999
+ }
1000
+ ],
1001
+ "isUnique": false,
1002
+ "concurrently": false,
1003
+ "method": "btree",
1004
+ "with": {}
1005
+ },
1006
+ "idx_purchase_receipts_order": {
1007
+ "name": "idx_purchase_receipts_order",
1008
+ "columns": [
1009
+ {
1010
+ "expression": "order_id",
1011
+ "isExpression": false,
1012
+ "asc": true,
1013
+ "nulls": "last"
1014
+ }
1015
+ ],
1016
+ "isUnique": false,
1017
+ "concurrently": false,
1018
+ "method": "btree",
1019
+ "with": {}
1020
+ },
1021
+ "uq_purchase_receipts_invoice_key": {
1022
+ "name": "uq_purchase_receipts_invoice_key",
1023
+ "columns": [
1024
+ {
1025
+ "expression": "company_id",
1026
+ "isExpression": false,
1027
+ "asc": true,
1028
+ "nulls": "last"
1029
+ },
1030
+ {
1031
+ "expression": "invoice_key",
1032
+ "isExpression": false,
1033
+ "asc": true,
1034
+ "nulls": "last"
1035
+ }
1036
+ ],
1037
+ "isUnique": true,
1038
+ "where": "\"invoice_key\" is not null",
1039
+ "concurrently": false,
1040
+ "method": "btree",
1041
+ "with": {}
1042
+ },
1043
+ "uq_purchase_receipts_idempotency": {
1044
+ "name": "uq_purchase_receipts_idempotency",
1045
+ "columns": [
1046
+ {
1047
+ "expression": "company_id",
1048
+ "isExpression": false,
1049
+ "asc": true,
1050
+ "nulls": "last"
1051
+ },
1052
+ {
1053
+ "expression": "idempotency_key",
1054
+ "isExpression": false,
1055
+ "asc": true,
1056
+ "nulls": "last"
1057
+ }
1058
+ ],
1059
+ "isUnique": true,
1060
+ "where": "\"idempotency_key\" is not null",
1061
+ "concurrently": false,
1062
+ "method": "btree",
1063
+ "with": {}
1064
+ },
1065
+ "idx_purchase_receipts_failed": {
1066
+ "name": "idx_purchase_receipts_failed",
1067
+ "columns": [
1068
+ {
1069
+ "expression": "company_id",
1070
+ "isExpression": false,
1071
+ "asc": true,
1072
+ "nulls": "last"
1073
+ }
1074
+ ],
1075
+ "isUnique": false,
1076
+ "where": "\"stock_status\" = 'failed' or \"payable_status\" = 'failed'",
1077
+ "concurrently": false,
1078
+ "method": "btree",
1079
+ "with": {}
1080
+ }
1081
+ },
1082
+ "foreignKeys": {
1083
+ "receipts_order_id_orders_id_fk": {
1084
+ "name": "receipts_order_id_orders_id_fk",
1085
+ "tableFrom": "receipts",
1086
+ "tableTo": "orders",
1087
+ "schemaTo": "purchase",
1088
+ "columnsFrom": [
1089
+ "order_id"
1090
+ ],
1091
+ "columnsTo": [
1092
+ "id"
1093
+ ],
1094
+ "onDelete": "no action",
1095
+ "onUpdate": "no action"
1096
+ },
1097
+ "receipts_supplier_id_suppliers_id_fk": {
1098
+ "name": "receipts_supplier_id_suppliers_id_fk",
1099
+ "tableFrom": "receipts",
1100
+ "tableTo": "suppliers",
1101
+ "schemaTo": "purchase",
1102
+ "columnsFrom": [
1103
+ "supplier_id"
1104
+ ],
1105
+ "columnsTo": [
1106
+ "id"
1107
+ ],
1108
+ "onDelete": "no action",
1109
+ "onUpdate": "no action"
1110
+ }
1111
+ },
1112
+ "compositePrimaryKeys": {},
1113
+ "uniqueConstraints": {},
1114
+ "policies": {},
1115
+ "checkConstraints": {},
1116
+ "isRLSEnabled": false
1117
+ },
1118
+ "purchase.supplier_items": {
1119
+ "name": "supplier_items",
1120
+ "schema": "purchase",
1121
+ "columns": {
1122
+ "id": {
1123
+ "name": "id",
1124
+ "type": "uuid",
1125
+ "primaryKey": true,
1126
+ "notNull": true,
1127
+ "default": "gen_random_uuid()"
1128
+ },
1129
+ "company_id": {
1130
+ "name": "company_id",
1131
+ "type": "uuid",
1132
+ "primaryKey": false,
1133
+ "notNull": true
1134
+ },
1135
+ "supplier_id": {
1136
+ "name": "supplier_id",
1137
+ "type": "uuid",
1138
+ "primaryKey": false,
1139
+ "notNull": true
1140
+ },
1141
+ "item_ref": {
1142
+ "name": "item_ref",
1143
+ "type": "varchar(128)",
1144
+ "primaryKey": false,
1145
+ "notNull": false
1146
+ },
1147
+ "item_name": {
1148
+ "name": "item_name",
1149
+ "type": "varchar(160)",
1150
+ "primaryKey": false,
1151
+ "notNull": true
1152
+ },
1153
+ "supplier_sku": {
1154
+ "name": "supplier_sku",
1155
+ "type": "varchar(100)",
1156
+ "primaryKey": false,
1157
+ "notNull": false
1158
+ },
1159
+ "purchase_unit": {
1160
+ "name": "purchase_unit",
1161
+ "type": "varchar(12)",
1162
+ "primaryKey": false,
1163
+ "notNull": true
1164
+ },
1165
+ "units_per_purchase": {
1166
+ "name": "units_per_purchase",
1167
+ "type": "numeric(14, 4)",
1168
+ "primaryKey": false,
1169
+ "notNull": true,
1170
+ "default": "'1'"
1171
+ },
1172
+ "stock_unit": {
1173
+ "name": "stock_unit",
1174
+ "type": "varchar(8)",
1175
+ "primaryKey": false,
1176
+ "notNull": false
1177
+ },
1178
+ "last_price": {
1179
+ "name": "last_price",
1180
+ "type": "numeric(14, 4)",
1181
+ "primaryKey": false,
1182
+ "notNull": false
1183
+ },
1184
+ "last_price_at": {
1185
+ "name": "last_price_at",
1186
+ "type": "timestamp with time zone",
1187
+ "primaryKey": false,
1188
+ "notNull": false
1189
+ },
1190
+ "priority": {
1191
+ "name": "priority",
1192
+ "type": "integer",
1193
+ "primaryKey": false,
1194
+ "notNull": true,
1195
+ "default": 0
1196
+ },
1197
+ "is_active": {
1198
+ "name": "is_active",
1199
+ "type": "boolean",
1200
+ "primaryKey": false,
1201
+ "notNull": true,
1202
+ "default": true
1203
+ },
1204
+ "created_at": {
1205
+ "name": "created_at",
1206
+ "type": "timestamp with time zone",
1207
+ "primaryKey": false,
1208
+ "notNull": true,
1209
+ "default": "now()"
1210
+ },
1211
+ "updated_at": {
1212
+ "name": "updated_at",
1213
+ "type": "timestamp with time zone",
1214
+ "primaryKey": false,
1215
+ "notNull": true,
1216
+ "default": "now()"
1217
+ }
1218
+ },
1219
+ "indexes": {
1220
+ "idx_purchase_supplier_items_item": {
1221
+ "name": "idx_purchase_supplier_items_item",
1222
+ "columns": [
1223
+ {
1224
+ "expression": "company_id",
1225
+ "isExpression": false,
1226
+ "asc": true,
1227
+ "nulls": "last"
1228
+ },
1229
+ {
1230
+ "expression": "item_ref",
1231
+ "isExpression": false,
1232
+ "asc": true,
1233
+ "nulls": "last"
1234
+ }
1235
+ ],
1236
+ "isUnique": false,
1237
+ "concurrently": false,
1238
+ "method": "btree",
1239
+ "with": {}
1240
+ },
1241
+ "uq_purchase_supplier_items_sku": {
1242
+ "name": "uq_purchase_supplier_items_sku",
1243
+ "columns": [
1244
+ {
1245
+ "expression": "company_id",
1246
+ "isExpression": false,
1247
+ "asc": true,
1248
+ "nulls": "last"
1249
+ },
1250
+ {
1251
+ "expression": "supplier_id",
1252
+ "isExpression": false,
1253
+ "asc": true,
1254
+ "nulls": "last"
1255
+ },
1256
+ {
1257
+ "expression": "supplier_sku",
1258
+ "isExpression": false,
1259
+ "asc": true,
1260
+ "nulls": "last"
1261
+ }
1262
+ ],
1263
+ "isUnique": true,
1264
+ "where": "\"supplier_sku\" is not null",
1265
+ "concurrently": false,
1266
+ "method": "btree",
1267
+ "with": {}
1268
+ },
1269
+ "uq_purchase_supplier_items_ref": {
1270
+ "name": "uq_purchase_supplier_items_ref",
1271
+ "columns": [
1272
+ {
1273
+ "expression": "company_id",
1274
+ "isExpression": false,
1275
+ "asc": true,
1276
+ "nulls": "last"
1277
+ },
1278
+ {
1279
+ "expression": "supplier_id",
1280
+ "isExpression": false,
1281
+ "asc": true,
1282
+ "nulls": "last"
1283
+ },
1284
+ {
1285
+ "expression": "item_ref",
1286
+ "isExpression": false,
1287
+ "asc": true,
1288
+ "nulls": "last"
1289
+ }
1290
+ ],
1291
+ "isUnique": true,
1292
+ "where": "\"item_ref\" is not null",
1293
+ "concurrently": false,
1294
+ "method": "btree",
1295
+ "with": {}
1296
+ }
1297
+ },
1298
+ "foreignKeys": {
1299
+ "supplier_items_supplier_id_suppliers_id_fk": {
1300
+ "name": "supplier_items_supplier_id_suppliers_id_fk",
1301
+ "tableFrom": "supplier_items",
1302
+ "tableTo": "suppliers",
1303
+ "schemaTo": "purchase",
1304
+ "columnsFrom": [
1305
+ "supplier_id"
1306
+ ],
1307
+ "columnsTo": [
1308
+ "id"
1309
+ ],
1310
+ "onDelete": "cascade",
1311
+ "onUpdate": "no action"
1312
+ }
1313
+ },
1314
+ "compositePrimaryKeys": {},
1315
+ "uniqueConstraints": {},
1316
+ "policies": {},
1317
+ "checkConstraints": {
1318
+ "purchase_supplier_items_units_positive": {
1319
+ "name": "purchase_supplier_items_units_positive",
1320
+ "value": "\"units_per_purchase\" > 0"
1321
+ },
1322
+ "purchase_supplier_items_price_not_negative": {
1323
+ "name": "purchase_supplier_items_price_not_negative",
1324
+ "value": "\"last_price\" is null or \"last_price\" >= 0"
1325
+ }
1326
+ },
1327
+ "isRLSEnabled": false
1328
+ },
1329
+ "purchase.suppliers": {
1330
+ "name": "suppliers",
1331
+ "schema": "purchase",
1332
+ "columns": {
1333
+ "id": {
1334
+ "name": "id",
1335
+ "type": "uuid",
1336
+ "primaryKey": true,
1337
+ "notNull": true,
1338
+ "default": "gen_random_uuid()"
1339
+ },
1340
+ "company_id": {
1341
+ "name": "company_id",
1342
+ "type": "uuid",
1343
+ "primaryKey": false,
1344
+ "notNull": true
1345
+ },
1346
+ "name": {
1347
+ "name": "name",
1348
+ "type": "varchar(160)",
1349
+ "primaryKey": false,
1350
+ "notNull": true
1351
+ },
1352
+ "document": {
1353
+ "name": "document",
1354
+ "type": "varchar(20)",
1355
+ "primaryKey": false,
1356
+ "notNull": false
1357
+ },
1358
+ "contact_name": {
1359
+ "name": "contact_name",
1360
+ "type": "varchar(120)",
1361
+ "primaryKey": false,
1362
+ "notNull": false
1363
+ },
1364
+ "email": {
1365
+ "name": "email",
1366
+ "type": "varchar(254)",
1367
+ "primaryKey": false,
1368
+ "notNull": false
1369
+ },
1370
+ "phone": {
1371
+ "name": "phone",
1372
+ "type": "varchar(30)",
1373
+ "primaryKey": false,
1374
+ "notNull": false
1375
+ },
1376
+ "whatsapp": {
1377
+ "name": "whatsapp",
1378
+ "type": "varchar(30)",
1379
+ "primaryKey": false,
1380
+ "notNull": false
1381
+ },
1382
+ "payment_term_days": {
1383
+ "name": "payment_term_days",
1384
+ "type": "integer[]",
1385
+ "primaryKey": false,
1386
+ "notNull": true,
1387
+ "default": "'{0}'::integer[]"
1388
+ },
1389
+ "lead_time_days": {
1390
+ "name": "lead_time_days",
1391
+ "type": "integer",
1392
+ "primaryKey": false,
1393
+ "notNull": false
1394
+ },
1395
+ "minimum_order_amount": {
1396
+ "name": "minimum_order_amount",
1397
+ "type": "numeric(14, 2)",
1398
+ "primaryKey": false,
1399
+ "notNull": false
1400
+ },
1401
+ "delivery_weekdays": {
1402
+ "name": "delivery_weekdays",
1403
+ "type": "integer[]",
1404
+ "primaryKey": false,
1405
+ "notNull": true,
1406
+ "default": "'{}'::integer[]"
1407
+ },
1408
+ "notes": {
1409
+ "name": "notes",
1410
+ "type": "text",
1411
+ "primaryKey": false,
1412
+ "notNull": true,
1413
+ "default": "''"
1414
+ },
1415
+ "is_active": {
1416
+ "name": "is_active",
1417
+ "type": "boolean",
1418
+ "primaryKey": false,
1419
+ "notNull": true,
1420
+ "default": true
1421
+ },
1422
+ "created_at": {
1423
+ "name": "created_at",
1424
+ "type": "timestamp with time zone",
1425
+ "primaryKey": false,
1426
+ "notNull": true,
1427
+ "default": "now()"
1428
+ },
1429
+ "updated_at": {
1430
+ "name": "updated_at",
1431
+ "type": "timestamp with time zone",
1432
+ "primaryKey": false,
1433
+ "notNull": true,
1434
+ "default": "now()"
1435
+ }
1436
+ },
1437
+ "indexes": {
1438
+ "idx_purchase_suppliers_company_name": {
1439
+ "name": "idx_purchase_suppliers_company_name",
1440
+ "columns": [
1441
+ {
1442
+ "expression": "company_id",
1443
+ "isExpression": false,
1444
+ "asc": true,
1445
+ "nulls": "last"
1446
+ },
1447
+ {
1448
+ "expression": "name",
1449
+ "isExpression": false,
1450
+ "asc": true,
1451
+ "nulls": "last"
1452
+ }
1453
+ ],
1454
+ "isUnique": false,
1455
+ "concurrently": false,
1456
+ "method": "btree",
1457
+ "with": {}
1458
+ },
1459
+ "uq_purchase_suppliers_company_document": {
1460
+ "name": "uq_purchase_suppliers_company_document",
1461
+ "columns": [
1462
+ {
1463
+ "expression": "company_id",
1464
+ "isExpression": false,
1465
+ "asc": true,
1466
+ "nulls": "last"
1467
+ },
1468
+ {
1469
+ "expression": "document",
1470
+ "isExpression": false,
1471
+ "asc": true,
1472
+ "nulls": "last"
1473
+ }
1474
+ ],
1475
+ "isUnique": true,
1476
+ "where": "\"document\" is not null",
1477
+ "concurrently": false,
1478
+ "method": "btree",
1479
+ "with": {}
1480
+ }
1481
+ },
1482
+ "foreignKeys": {},
1483
+ "compositePrimaryKeys": {},
1484
+ "uniqueConstraints": {},
1485
+ "policies": {},
1486
+ "checkConstraints": {},
1487
+ "isRLSEnabled": false
1488
+ }
1489
+ },
1490
+ "enums": {},
1491
+ "schemas": {
1492
+ "purchase": "purchase"
1493
+ },
1494
+ "sequences": {},
1495
+ "roles": {},
1496
+ "policies": {},
1497
+ "views": {},
1498
+ "_meta": {
1499
+ "columns": {},
1500
+ "schemas": {},
1501
+ "tables": {}
1502
+ }
1503
+ }