@managesome/eposmatic-toolkit 0.4.58 → 0.4.59

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.
Files changed (54) hide show
  1. package/esm/constants/MATERIALIZED_REPORTS.js +45 -0
  2. package/esm/helpers/materialized-reports/index.js +1 -0
  3. package/esm/helpers/materialized-reports/materialized-day-readiness.js +94 -0
  4. package/esm/helpers/materialized-reports/materialized-index-bootstrap.js +3 -0
  5. package/esm/helpers/materialized-reports/report-platform/definition.js +12 -2
  6. package/esm/helpers/order/generate-warehouse-purchase-order.js +3 -0
  7. package/esm/helpers/reporting-contract/report-contract.js +12 -0
  8. package/esm/helpers/store/common-tenant-purchase-order-actions.js +23 -0
  9. package/esm/helpers/store/common-warehouse-purchase-order-actions.js +21 -0
  10. package/esm/helpers/store/tenant-purchase-orders-cart-actions.js +60 -12
  11. package/esm/helpers/store/warehouse-purchase-orders-cart-actions.js +58 -13
  12. package/esm/schemas/models/index.js +1 -0
  13. package/esm/schemas/models/materialized_tenant_day_readiness.js +66 -0
  14. package/esm/schemas/models/tenant_purchase_orders.js +36 -0
  15. package/esm/schemas/models/warehouse_purchase_orders.js +48 -0
  16. package/esm/schemas/types/index.js +1 -0
  17. package/esm/schemas/types/materialized_tenant_day_readiness.js +1 -0
  18. package/lib/constants/MATERIALIZED_REPORTS.d.ts +42 -0
  19. package/lib/constants/MATERIALIZED_REPORTS.js +46 -1
  20. package/lib/helpers/materialized-reports/index.d.ts +1 -0
  21. package/lib/helpers/materialized-reports/index.js +1 -0
  22. package/lib/helpers/materialized-reports/materialized-day-readiness.d.ts +84 -0
  23. package/lib/helpers/materialized-reports/materialized-day-readiness.js +100 -0
  24. package/lib/helpers/materialized-reports/materialized-index-bootstrap.js +3 -0
  25. package/lib/helpers/materialized-reports/report-platform/definition.js +12 -2
  26. package/lib/helpers/order/generate-warehouse-purchase-order.js +3 -0
  27. package/lib/helpers/reporting-contract/report-contract.d.ts +13 -1
  28. package/lib/helpers/reporting-contract/report-contract.js +12 -0
  29. package/lib/helpers/store/common-tenant-purchase-order-actions.d.ts +2 -1
  30. package/lib/helpers/store/common-tenant-purchase-order-actions.js +24 -0
  31. package/lib/helpers/store/common-warehouse-purchase-order-actions.d.ts +2 -1
  32. package/lib/helpers/store/common-warehouse-purchase-order-actions.js +22 -0
  33. package/lib/helpers/store/tenant-purchase-orders-cart-actions.d.ts +15 -1
  34. package/lib/helpers/store/tenant-purchase-orders-cart-actions.js +61 -12
  35. package/lib/helpers/store/warehouse-purchase-orders-cart-actions.d.ts +10 -1
  36. package/lib/helpers/store/warehouse-purchase-orders-cart-actions.js +59 -13
  37. package/lib/schemas/models/index.d.ts +1 -0
  38. package/lib/schemas/models/index.js +1 -0
  39. package/lib/schemas/models/materialized_tenant_day_readiness.d.ts +78 -0
  40. package/lib/schemas/models/materialized_tenant_day_readiness.js +69 -0
  41. package/lib/schemas/models/orders.d.ts +240 -240
  42. package/lib/schemas/models/tenant_purchase_orders.d.ts +132 -0
  43. package/lib/schemas/models/tenant_purchase_orders.js +36 -0
  44. package/lib/schemas/models/warehouse_purchase_orders.d.ts +132 -0
  45. package/lib/schemas/models/warehouse_purchase_orders.js +48 -0
  46. package/lib/schemas/types/index.d.ts +1 -0
  47. package/lib/schemas/types/index.js +1 -0
  48. package/lib/schemas/types/materialized_tenant_day_readiness.d.ts +28 -0
  49. package/lib/schemas/types/materialized_tenant_day_readiness.js +2 -0
  50. package/lib/schemas/types/tenant_purchase_orders.d.ts +28 -0
  51. package/lib/schemas/types/warehouse_purchase_orders.d.ts +12 -0
  52. package/lib/tests/materialized-reports/materialized-day-readiness.test.d.ts +1 -0
  53. package/lib/tests/materialized-reports/materialized-day-readiness.test.js +64 -0
  54. package/package.json +1 -1
@@ -385,6 +385,17 @@ export declare const TenantPurchaseOrderSchema: Schema<any, import("mongoose").M
385
385
  staff_mobile: string;
386
386
  staff_email: string;
387
387
  } | null | undefined;
388
+ order_discount_details?: {
389
+ total_discount: number;
390
+ special_discount_id?: string | null | undefined;
391
+ special_discount?: number | null | undefined;
392
+ is_special_discount_percentage?: boolean | null | undefined;
393
+ special_discount_name?: string | null | undefined;
394
+ special_discount_reason?: string | null | undefined;
395
+ special_reference_number?: string | null | undefined;
396
+ } | null | undefined;
397
+ total_discount_applied?: number | null | undefined;
398
+ exclude_discount_from_gst?: boolean | null | undefined;
388
399
  is_gst_inclusive?: boolean | null | undefined;
389
400
  gst?: number | null | undefined;
390
401
  gst_amount?: number | null | undefined;
@@ -611,6 +622,17 @@ export declare const TenantPurchaseOrderSchema: Schema<any, import("mongoose").M
611
622
  staff_mobile: string;
612
623
  staff_email: string;
613
624
  } | null | undefined;
625
+ order_discount_details?: {
626
+ total_discount: number;
627
+ special_discount_id?: string | null | undefined;
628
+ special_discount?: number | null | undefined;
629
+ is_special_discount_percentage?: boolean | null | undefined;
630
+ special_discount_name?: string | null | undefined;
631
+ special_discount_reason?: string | null | undefined;
632
+ special_reference_number?: string | null | undefined;
633
+ } | null | undefined;
634
+ total_discount_applied?: number | null | undefined;
635
+ exclude_discount_from_gst?: boolean | null | undefined;
614
636
  is_gst_inclusive?: boolean | null | undefined;
615
637
  gst?: number | null | undefined;
616
638
  gst_amount?: number | null | undefined;
@@ -837,6 +859,17 @@ export declare const TenantPurchaseOrderSchema: Schema<any, import("mongoose").M
837
859
  staff_mobile: string;
838
860
  staff_email: string;
839
861
  } | null | undefined;
862
+ order_discount_details?: {
863
+ total_discount: number;
864
+ special_discount_id?: string | null | undefined;
865
+ special_discount?: number | null | undefined;
866
+ is_special_discount_percentage?: boolean | null | undefined;
867
+ special_discount_name?: string | null | undefined;
868
+ special_discount_reason?: string | null | undefined;
869
+ special_reference_number?: string | null | undefined;
870
+ } | null | undefined;
871
+ total_discount_applied?: number | null | undefined;
872
+ exclude_discount_from_gst?: boolean | null | undefined;
840
873
  is_gst_inclusive?: boolean | null | undefined;
841
874
  gst?: number | null | undefined;
842
875
  gst_amount?: number | null | undefined;
@@ -924,6 +957,17 @@ export declare const TenantPurchaseOrderSchema: Schema<any, import("mongoose").M
924
957
  delete_reason?: string | null | undefined;
925
958
  is_reopened?: boolean | null | undefined;
926
959
  deferred_settlement?: boolean | null | undefined;
960
+ order_discount_details?: {
961
+ total_discount: number;
962
+ special_discount_id?: string | null | undefined;
963
+ special_discount?: number | null | undefined;
964
+ is_special_discount_percentage?: boolean | null | undefined;
965
+ special_discount_name?: string | null | undefined;
966
+ special_discount_reason?: string | null | undefined;
967
+ special_reference_number?: string | null | undefined;
968
+ } | null | undefined;
969
+ total_discount_applied?: number | null | undefined;
970
+ exclude_discount_from_gst?: boolean | null | undefined;
927
971
  is_gst_inclusive?: boolean | null | undefined;
928
972
  gst?: number | null | undefined;
929
973
  gst_amount?: number | null | undefined;
@@ -1309,6 +1353,17 @@ export declare const TenantPurchaseOrderSchema: Schema<any, import("mongoose").M
1309
1353
  staff_mobile: string;
1310
1354
  staff_email: string;
1311
1355
  } | null | undefined;
1356
+ order_discount_details?: {
1357
+ total_discount: number;
1358
+ special_discount_id?: string | null | undefined;
1359
+ special_discount?: number | null | undefined;
1360
+ is_special_discount_percentage?: boolean | null | undefined;
1361
+ special_discount_name?: string | null | undefined;
1362
+ special_discount_reason?: string | null | undefined;
1363
+ special_reference_number?: string | null | undefined;
1364
+ } | null | undefined;
1365
+ total_discount_applied?: number | null | undefined;
1366
+ exclude_discount_from_gst?: boolean | null | undefined;
1312
1367
  is_gst_inclusive?: boolean | null | undefined;
1313
1368
  gst?: number | null | undefined;
1314
1369
  gst_amount?: number | null | undefined;
@@ -1535,6 +1590,17 @@ export declare const TenantPurchaseOrderSchema: Schema<any, import("mongoose").M
1535
1590
  staff_mobile: string;
1536
1591
  staff_email: string;
1537
1592
  } | null | undefined;
1593
+ order_discount_details?: {
1594
+ total_discount: number;
1595
+ special_discount_id?: string | null | undefined;
1596
+ special_discount?: number | null | undefined;
1597
+ is_special_discount_percentage?: boolean | null | undefined;
1598
+ special_discount_name?: string | null | undefined;
1599
+ special_discount_reason?: string | null | undefined;
1600
+ special_reference_number?: string | null | undefined;
1601
+ } | null | undefined;
1602
+ total_discount_applied?: number | null | undefined;
1603
+ exclude_discount_from_gst?: boolean | null | undefined;
1538
1604
  is_gst_inclusive?: boolean | null | undefined;
1539
1605
  gst?: number | null | undefined;
1540
1606
  gst_amount?: number | null | undefined;
@@ -1761,6 +1827,17 @@ export declare const TenantPurchaseOrderSchema: Schema<any, import("mongoose").M
1761
1827
  staff_mobile: string;
1762
1828
  staff_email: string;
1763
1829
  } | null | undefined;
1830
+ order_discount_details?: {
1831
+ total_discount: number;
1832
+ special_discount_id?: string | null | undefined;
1833
+ special_discount?: number | null | undefined;
1834
+ is_special_discount_percentage?: boolean | null | undefined;
1835
+ special_discount_name?: string | null | undefined;
1836
+ special_discount_reason?: string | null | undefined;
1837
+ special_reference_number?: string | null | undefined;
1838
+ } | null | undefined;
1839
+ total_discount_applied?: number | null | undefined;
1840
+ exclude_discount_from_gst?: boolean | null | undefined;
1764
1841
  is_gst_inclusive?: boolean | null | undefined;
1765
1842
  gst?: number | null | undefined;
1766
1843
  gst_amount?: number | null | undefined;
@@ -1848,6 +1925,17 @@ export declare const TenantPurchaseOrderSchema: Schema<any, import("mongoose").M
1848
1925
  delete_reason?: string | null | undefined;
1849
1926
  is_reopened?: boolean | null | undefined;
1850
1927
  deferred_settlement?: boolean | null | undefined;
1928
+ order_discount_details?: {
1929
+ total_discount: number;
1930
+ special_discount_id?: string | null | undefined;
1931
+ special_discount?: number | null | undefined;
1932
+ is_special_discount_percentage?: boolean | null | undefined;
1933
+ special_discount_name?: string | null | undefined;
1934
+ special_discount_reason?: string | null | undefined;
1935
+ special_reference_number?: string | null | undefined;
1936
+ } | null | undefined;
1937
+ total_discount_applied?: number | null | undefined;
1938
+ exclude_discount_from_gst?: boolean | null | undefined;
1851
1939
  is_gst_inclusive?: boolean | null | undefined;
1852
1940
  gst?: number | null | undefined;
1853
1941
  gst_amount?: number | null | undefined;
@@ -2233,6 +2321,17 @@ export declare const TenantPurchaseOrderSchema: Schema<any, import("mongoose").M
2233
2321
  staff_mobile: string;
2234
2322
  staff_email: string;
2235
2323
  } | null | undefined;
2324
+ order_discount_details?: {
2325
+ total_discount: number;
2326
+ special_discount_id?: string | null | undefined;
2327
+ special_discount?: number | null | undefined;
2328
+ is_special_discount_percentage?: boolean | null | undefined;
2329
+ special_discount_name?: string | null | undefined;
2330
+ special_discount_reason?: string | null | undefined;
2331
+ special_reference_number?: string | null | undefined;
2332
+ } | null | undefined;
2333
+ total_discount_applied?: number | null | undefined;
2334
+ exclude_discount_from_gst?: boolean | null | undefined;
2236
2335
  is_gst_inclusive?: boolean | null | undefined;
2237
2336
  gst?: number | null | undefined;
2238
2337
  gst_amount?: number | null | undefined;
@@ -2459,6 +2558,17 @@ export declare const TenantPurchaseOrderSchema: Schema<any, import("mongoose").M
2459
2558
  staff_mobile: string;
2460
2559
  staff_email: string;
2461
2560
  } | null | undefined;
2561
+ order_discount_details?: {
2562
+ total_discount: number;
2563
+ special_discount_id?: string | null | undefined;
2564
+ special_discount?: number | null | undefined;
2565
+ is_special_discount_percentage?: boolean | null | undefined;
2566
+ special_discount_name?: string | null | undefined;
2567
+ special_discount_reason?: string | null | undefined;
2568
+ special_reference_number?: string | null | undefined;
2569
+ } | null | undefined;
2570
+ total_discount_applied?: number | null | undefined;
2571
+ exclude_discount_from_gst?: boolean | null | undefined;
2462
2572
  is_gst_inclusive?: boolean | null | undefined;
2463
2573
  gst?: number | null | undefined;
2464
2574
  gst_amount?: number | null | undefined;
@@ -2685,6 +2795,17 @@ export declare const TenantPurchaseOrderSchema: Schema<any, import("mongoose").M
2685
2795
  staff_mobile: string;
2686
2796
  staff_email: string;
2687
2797
  } | null | undefined;
2798
+ order_discount_details?: {
2799
+ total_discount: number;
2800
+ special_discount_id?: string | null | undefined;
2801
+ special_discount?: number | null | undefined;
2802
+ is_special_discount_percentage?: boolean | null | undefined;
2803
+ special_discount_name?: string | null | undefined;
2804
+ special_discount_reason?: string | null | undefined;
2805
+ special_reference_number?: string | null | undefined;
2806
+ } | null | undefined;
2807
+ total_discount_applied?: number | null | undefined;
2808
+ exclude_discount_from_gst?: boolean | null | undefined;
2688
2809
  is_gst_inclusive?: boolean | null | undefined;
2689
2810
  gst?: number | null | undefined;
2690
2811
  gst_amount?: number | null | undefined;
@@ -2772,6 +2893,17 @@ export declare const TenantPurchaseOrderSchema: Schema<any, import("mongoose").M
2772
2893
  delete_reason?: string | null | undefined;
2773
2894
  is_reopened?: boolean | null | undefined;
2774
2895
  deferred_settlement?: boolean | null | undefined;
2896
+ order_discount_details?: {
2897
+ total_discount: number;
2898
+ special_discount_id?: string | null | undefined;
2899
+ special_discount?: number | null | undefined;
2900
+ is_special_discount_percentage?: boolean | null | undefined;
2901
+ special_discount_name?: string | null | undefined;
2902
+ special_discount_reason?: string | null | undefined;
2903
+ special_reference_number?: string | null | undefined;
2904
+ } | null | undefined;
2905
+ total_discount_applied?: number | null | undefined;
2906
+ exclude_discount_from_gst?: boolean | null | undefined;
2775
2907
  is_gst_inclusive?: boolean | null | undefined;
2776
2908
  gst?: number | null | undefined;
2777
2909
  gst_amount?: number | null | undefined;
@@ -13,6 +13,30 @@ const StaffDetailsSchema = new mongoose_1.Schema({
13
13
  staff_mobile: { type: String, default: null },
14
14
  staff_email: { type: String, default: null },
15
15
  }, { _id: false, minimize: false });
16
+ const DiscountDetailsSchema = new mongoose_1.Schema({
17
+ special_discount: {
18
+ type: Number,
19
+ },
20
+ special_discount_id: {
21
+ type: String,
22
+ },
23
+ special_discount_name: {
24
+ type: String,
25
+ },
26
+ is_special_discount_percentage: {
27
+ type: Boolean,
28
+ },
29
+ special_discount_reason: {
30
+ type: String,
31
+ },
32
+ special_reference_number: {
33
+ type: String,
34
+ },
35
+ total_discount: {
36
+ type: Number,
37
+ required: true,
38
+ },
39
+ }, { _id: false, minimize: false });
16
40
  const ItemsSchema = new mongoose_1.Schema({
17
41
  _id: { type: mongoose_1.Schema.Types.ObjectId, required: true, immutable: true },
18
42
  item_id: {
@@ -57,6 +81,12 @@ const IterationsOrderSchema = new mongoose_1.Schema({
57
81
  price: { type: Number, min: 0, required: true },
58
82
  amount_earned: { type: Number, min: 0, required: true },
59
83
  grand_total: { type: Number, min: 0, required: true },
84
+ order_discount_details: {
85
+ type: DiscountDetailsSchema,
86
+ required: false,
87
+ },
88
+ total_discount_applied: { type: Number, required: false },
89
+ exclude_discount_from_gst: { type: Boolean, required: false },
60
90
  staff_details: { type: StaffDetailsSchema, required: false },
61
91
  gst: { type: Number, min: 0, required: false },
62
92
  gst_amount: { type: Number, min: 0, required: false },
@@ -87,6 +117,12 @@ exports.TenantPurchaseOrderSchema = new mongoose_1.Schema({
87
117
  amount_collected: { type: Number, min: 0, required: true },
88
118
  amount_earned: { type: Number, min: 0, required: true },
89
119
  grand_total: { type: Number, min: 0, required: true },
120
+ order_discount_details: {
121
+ type: DiscountDetailsSchema,
122
+ required: false,
123
+ },
124
+ total_discount_applied: { type: Number, required: false },
125
+ exclude_discount_from_gst: { type: Boolean, required: false },
90
126
  order_number: { type: Number, min: 0, default: null },
91
127
  delete_reason: { type: String, required: false },
92
128
  cancel_reason: { type: String, required: false },
@@ -367,6 +367,17 @@ export declare const PurchaseOrderSchema: Schema<any, import("mongoose").Model<a
367
367
  staff_mobile: string;
368
368
  staff_email: string;
369
369
  } | null | undefined;
370
+ order_discount_details?: {
371
+ total_discount: number;
372
+ special_discount_id?: string | null | undefined;
373
+ special_discount?: number | null | undefined;
374
+ is_special_discount_percentage?: boolean | null | undefined;
375
+ special_discount_name?: string | null | undefined;
376
+ special_discount_reason?: string | null | undefined;
377
+ special_reference_number?: string | null | undefined;
378
+ } | null | undefined;
379
+ total_discount_applied?: number | null | undefined;
380
+ exclude_discount_from_gst?: boolean | null | undefined;
370
381
  is_gst_inclusive?: boolean | null | undefined;
371
382
  gst?: number | null | undefined;
372
383
  gst_amount?: number | null | undefined;
@@ -584,6 +595,17 @@ export declare const PurchaseOrderSchema: Schema<any, import("mongoose").Model<a
584
595
  staff_mobile: string;
585
596
  staff_email: string;
586
597
  } | null | undefined;
598
+ order_discount_details?: {
599
+ total_discount: number;
600
+ special_discount_id?: string | null | undefined;
601
+ special_discount?: number | null | undefined;
602
+ is_special_discount_percentage?: boolean | null | undefined;
603
+ special_discount_name?: string | null | undefined;
604
+ special_discount_reason?: string | null | undefined;
605
+ special_reference_number?: string | null | undefined;
606
+ } | null | undefined;
607
+ total_discount_applied?: number | null | undefined;
608
+ exclude_discount_from_gst?: boolean | null | undefined;
587
609
  is_gst_inclusive?: boolean | null | undefined;
588
610
  gst?: number | null | undefined;
589
611
  gst_amount?: number | null | undefined;
@@ -801,6 +823,17 @@ export declare const PurchaseOrderSchema: Schema<any, import("mongoose").Model<a
801
823
  staff_mobile: string;
802
824
  staff_email: string;
803
825
  } | null | undefined;
826
+ order_discount_details?: {
827
+ total_discount: number;
828
+ special_discount_id?: string | null | undefined;
829
+ special_discount?: number | null | undefined;
830
+ is_special_discount_percentage?: boolean | null | undefined;
831
+ special_discount_name?: string | null | undefined;
832
+ special_discount_reason?: string | null | undefined;
833
+ special_reference_number?: string | null | undefined;
834
+ } | null | undefined;
835
+ total_discount_applied?: number | null | undefined;
836
+ exclude_discount_from_gst?: boolean | null | undefined;
804
837
  is_gst_inclusive?: boolean | null | undefined;
805
838
  gst?: number | null | undefined;
806
839
  gst_amount?: number | null | undefined;
@@ -889,6 +922,17 @@ export declare const PurchaseOrderSchema: Schema<any, import("mongoose").Model<a
889
922
  delete_reason?: string | null | undefined;
890
923
  is_reopened?: boolean | null | undefined;
891
924
  deferred_settlement?: boolean | null | undefined;
925
+ order_discount_details?: {
926
+ total_discount: number;
927
+ special_discount_id?: string | null | undefined;
928
+ special_discount?: number | null | undefined;
929
+ is_special_discount_percentage?: boolean | null | undefined;
930
+ special_discount_name?: string | null | undefined;
931
+ special_discount_reason?: string | null | undefined;
932
+ special_reference_number?: string | null | undefined;
933
+ } | null | undefined;
934
+ total_discount_applied?: number | null | undefined;
935
+ exclude_discount_from_gst?: boolean | null | undefined;
892
936
  is_gst_inclusive?: boolean | null | undefined;
893
937
  gst?: number | null | undefined;
894
938
  gst_amount?: number | null | undefined;
@@ -1256,6 +1300,17 @@ export declare const PurchaseOrderSchema: Schema<any, import("mongoose").Model<a
1256
1300
  staff_mobile: string;
1257
1301
  staff_email: string;
1258
1302
  } | null | undefined;
1303
+ order_discount_details?: {
1304
+ total_discount: number;
1305
+ special_discount_id?: string | null | undefined;
1306
+ special_discount?: number | null | undefined;
1307
+ is_special_discount_percentage?: boolean | null | undefined;
1308
+ special_discount_name?: string | null | undefined;
1309
+ special_discount_reason?: string | null | undefined;
1310
+ special_reference_number?: string | null | undefined;
1311
+ } | null | undefined;
1312
+ total_discount_applied?: number | null | undefined;
1313
+ exclude_discount_from_gst?: boolean | null | undefined;
1259
1314
  is_gst_inclusive?: boolean | null | undefined;
1260
1315
  gst?: number | null | undefined;
1261
1316
  gst_amount?: number | null | undefined;
@@ -1473,6 +1528,17 @@ export declare const PurchaseOrderSchema: Schema<any, import("mongoose").Model<a
1473
1528
  staff_mobile: string;
1474
1529
  staff_email: string;
1475
1530
  } | null | undefined;
1531
+ order_discount_details?: {
1532
+ total_discount: number;
1533
+ special_discount_id?: string | null | undefined;
1534
+ special_discount?: number | null | undefined;
1535
+ is_special_discount_percentage?: boolean | null | undefined;
1536
+ special_discount_name?: string | null | undefined;
1537
+ special_discount_reason?: string | null | undefined;
1538
+ special_reference_number?: string | null | undefined;
1539
+ } | null | undefined;
1540
+ total_discount_applied?: number | null | undefined;
1541
+ exclude_discount_from_gst?: boolean | null | undefined;
1476
1542
  is_gst_inclusive?: boolean | null | undefined;
1477
1543
  gst?: number | null | undefined;
1478
1544
  gst_amount?: number | null | undefined;
@@ -1690,6 +1756,17 @@ export declare const PurchaseOrderSchema: Schema<any, import("mongoose").Model<a
1690
1756
  staff_mobile: string;
1691
1757
  staff_email: string;
1692
1758
  } | null | undefined;
1759
+ order_discount_details?: {
1760
+ total_discount: number;
1761
+ special_discount_id?: string | null | undefined;
1762
+ special_discount?: number | null | undefined;
1763
+ is_special_discount_percentage?: boolean | null | undefined;
1764
+ special_discount_name?: string | null | undefined;
1765
+ special_discount_reason?: string | null | undefined;
1766
+ special_reference_number?: string | null | undefined;
1767
+ } | null | undefined;
1768
+ total_discount_applied?: number | null | undefined;
1769
+ exclude_discount_from_gst?: boolean | null | undefined;
1693
1770
  is_gst_inclusive?: boolean | null | undefined;
1694
1771
  gst?: number | null | undefined;
1695
1772
  gst_amount?: number | null | undefined;
@@ -1778,6 +1855,17 @@ export declare const PurchaseOrderSchema: Schema<any, import("mongoose").Model<a
1778
1855
  delete_reason?: string | null | undefined;
1779
1856
  is_reopened?: boolean | null | undefined;
1780
1857
  deferred_settlement?: boolean | null | undefined;
1858
+ order_discount_details?: {
1859
+ total_discount: number;
1860
+ special_discount_id?: string | null | undefined;
1861
+ special_discount?: number | null | undefined;
1862
+ is_special_discount_percentage?: boolean | null | undefined;
1863
+ special_discount_name?: string | null | undefined;
1864
+ special_discount_reason?: string | null | undefined;
1865
+ special_reference_number?: string | null | undefined;
1866
+ } | null | undefined;
1867
+ total_discount_applied?: number | null | undefined;
1868
+ exclude_discount_from_gst?: boolean | null | undefined;
1781
1869
  is_gst_inclusive?: boolean | null | undefined;
1782
1870
  gst?: number | null | undefined;
1783
1871
  gst_amount?: number | null | undefined;
@@ -2145,6 +2233,17 @@ export declare const PurchaseOrderSchema: Schema<any, import("mongoose").Model<a
2145
2233
  staff_mobile: string;
2146
2234
  staff_email: string;
2147
2235
  } | null | undefined;
2236
+ order_discount_details?: {
2237
+ total_discount: number;
2238
+ special_discount_id?: string | null | undefined;
2239
+ special_discount?: number | null | undefined;
2240
+ is_special_discount_percentage?: boolean | null | undefined;
2241
+ special_discount_name?: string | null | undefined;
2242
+ special_discount_reason?: string | null | undefined;
2243
+ special_reference_number?: string | null | undefined;
2244
+ } | null | undefined;
2245
+ total_discount_applied?: number | null | undefined;
2246
+ exclude_discount_from_gst?: boolean | null | undefined;
2148
2247
  is_gst_inclusive?: boolean | null | undefined;
2149
2248
  gst?: number | null | undefined;
2150
2249
  gst_amount?: number | null | undefined;
@@ -2362,6 +2461,17 @@ export declare const PurchaseOrderSchema: Schema<any, import("mongoose").Model<a
2362
2461
  staff_mobile: string;
2363
2462
  staff_email: string;
2364
2463
  } | null | undefined;
2464
+ order_discount_details?: {
2465
+ total_discount: number;
2466
+ special_discount_id?: string | null | undefined;
2467
+ special_discount?: number | null | undefined;
2468
+ is_special_discount_percentage?: boolean | null | undefined;
2469
+ special_discount_name?: string | null | undefined;
2470
+ special_discount_reason?: string | null | undefined;
2471
+ special_reference_number?: string | null | undefined;
2472
+ } | null | undefined;
2473
+ total_discount_applied?: number | null | undefined;
2474
+ exclude_discount_from_gst?: boolean | null | undefined;
2365
2475
  is_gst_inclusive?: boolean | null | undefined;
2366
2476
  gst?: number | null | undefined;
2367
2477
  gst_amount?: number | null | undefined;
@@ -2579,6 +2689,17 @@ export declare const PurchaseOrderSchema: Schema<any, import("mongoose").Model<a
2579
2689
  staff_mobile: string;
2580
2690
  staff_email: string;
2581
2691
  } | null | undefined;
2692
+ order_discount_details?: {
2693
+ total_discount: number;
2694
+ special_discount_id?: string | null | undefined;
2695
+ special_discount?: number | null | undefined;
2696
+ is_special_discount_percentage?: boolean | null | undefined;
2697
+ special_discount_name?: string | null | undefined;
2698
+ special_discount_reason?: string | null | undefined;
2699
+ special_reference_number?: string | null | undefined;
2700
+ } | null | undefined;
2701
+ total_discount_applied?: number | null | undefined;
2702
+ exclude_discount_from_gst?: boolean | null | undefined;
2582
2703
  is_gst_inclusive?: boolean | null | undefined;
2583
2704
  gst?: number | null | undefined;
2584
2705
  gst_amount?: number | null | undefined;
@@ -2667,6 +2788,17 @@ export declare const PurchaseOrderSchema: Schema<any, import("mongoose").Model<a
2667
2788
  delete_reason?: string | null | undefined;
2668
2789
  is_reopened?: boolean | null | undefined;
2669
2790
  deferred_settlement?: boolean | null | undefined;
2791
+ order_discount_details?: {
2792
+ total_discount: number;
2793
+ special_discount_id?: string | null | undefined;
2794
+ special_discount?: number | null | undefined;
2795
+ is_special_discount_percentage?: boolean | null | undefined;
2796
+ special_discount_name?: string | null | undefined;
2797
+ special_discount_reason?: string | null | undefined;
2798
+ special_reference_number?: string | null | undefined;
2799
+ } | null | undefined;
2800
+ total_discount_applied?: number | null | undefined;
2801
+ exclude_discount_from_gst?: boolean | null | undefined;
2670
2802
  is_gst_inclusive?: boolean | null | undefined;
2671
2803
  gst?: number | null | undefined;
2672
2804
  gst_amount?: number | null | undefined;
@@ -27,6 +27,30 @@ const StaffDetailsSchema = new mongoose_1.Schema({
27
27
  default: null,
28
28
  },
29
29
  }, { _id: false, minimize: false });
30
+ const DiscountDetailsSchema = new mongoose_1.Schema({
31
+ special_discount: {
32
+ type: Number,
33
+ },
34
+ special_discount_id: {
35
+ type: String,
36
+ },
37
+ special_discount_name: {
38
+ type: String,
39
+ },
40
+ is_special_discount_percentage: {
41
+ type: Boolean,
42
+ },
43
+ special_discount_reason: {
44
+ type: String,
45
+ },
46
+ special_reference_number: {
47
+ type: String,
48
+ },
49
+ total_discount: {
50
+ type: Number,
51
+ required: true,
52
+ },
53
+ }, { _id: false, minimize: false });
30
54
  const ItemsModal = new mongoose_1.Schema({
31
55
  _id: {
32
56
  type: mongoose_1.Schema.Types.ObjectId,
@@ -144,6 +168,18 @@ const IterationsOrderSchema = new mongoose_1.Schema({
144
168
  min: 0,
145
169
  required: true,
146
170
  },
171
+ order_discount_details: {
172
+ type: DiscountDetailsSchema,
173
+ required: false,
174
+ },
175
+ total_discount_applied: {
176
+ type: Number,
177
+ required: false,
178
+ },
179
+ exclude_discount_from_gst: {
180
+ type: Boolean,
181
+ required: false,
182
+ },
147
183
  staff_details: {
148
184
  type: StaffDetailsSchema,
149
185
  required: false,
@@ -245,6 +281,18 @@ exports.PurchaseOrderSchema = new mongoose_1.Schema({
245
281
  min: 0,
246
282
  required: true,
247
283
  },
284
+ order_discount_details: {
285
+ type: DiscountDetailsSchema,
286
+ required: false,
287
+ },
288
+ total_discount_applied: {
289
+ type: Number,
290
+ required: false,
291
+ },
292
+ exclude_discount_from_gst: {
293
+ type: Boolean,
294
+ required: false,
295
+ },
248
296
  order_number: {
249
297
  type: Number,
250
298
  min: 0,
@@ -39,6 +39,7 @@ export * from './materialized_tenant_delivery_entries';
39
39
  export * from './materialized_tenant_delivery_geo_cells';
40
40
  export * from './materialized_tenant_delivery_geo_scopes';
41
41
  export * from './materialized_tenant_delivery_reports';
42
+ export * from './materialized_tenant_day_readiness';
42
43
  export * from './materialized_tenant_discount_entries';
43
44
  export * from './materialized_tenant_discount_reports';
44
45
  export * from './materialized_tenant_dialer_entries';
@@ -55,6 +55,7 @@ __exportStar(require("./materialized_tenant_delivery_entries"), exports);
55
55
  __exportStar(require("./materialized_tenant_delivery_geo_cells"), exports);
56
56
  __exportStar(require("./materialized_tenant_delivery_geo_scopes"), exports);
57
57
  __exportStar(require("./materialized_tenant_delivery_reports"), exports);
58
+ __exportStar(require("./materialized_tenant_day_readiness"), exports);
58
59
  __exportStar(require("./materialized_tenant_discount_entries"), exports);
59
60
  __exportStar(require("./materialized_tenant_discount_reports"), exports);
60
61
  __exportStar(require("./materialized_tenant_dialer_entries"), exports);
@@ -0,0 +1,28 @@
1
+ import { MATERIALIZED_REPORT_READINESS_STATUS_ENUM, type TMaterializedReadinessReportKey } from '../../constants/MATERIALIZED_REPORTS';
2
+ /**
3
+ * One committed-readiness row per
4
+ * `(tenant_id, localDate, report_key, schema_version)`.
5
+ *
6
+ * Written in the SAME transaction/session as the day's report documents, so the
7
+ * row is the durable proof that the tenant-day-report was materialized (even when
8
+ * the day was genuinely empty). Historical reads use it to distinguish:
9
+ * - `HISTORICAL_NOT_MATERIALIZED` (no row) from
10
+ * - `HISTORICAL_NEEDS_RECONCILIATION` (row says the report is not final) from
11
+ * - a valid 200 final read.
12
+ */
13
+ export interface IMaterializedTenantDayReadiness {
14
+ tenant_id: string;
15
+ /** Tenant-local business day, `YYYY-MM-DD`. */
16
+ localDate: string;
17
+ /** One of the FIVE production report keys; never an out-of-scope report. */
18
+ report_key: TMaterializedReadinessReportKey | string;
19
+ /** Pinned readiness contract version (1). */
20
+ schema_version: number;
21
+ status: MATERIALIZED_REPORT_READINESS_STATUS_ENUM;
22
+ /** Identity of the run that last committed this row (lease/run id). */
23
+ run_id: string;
24
+ /** When the row's status was last written by a committed transaction. */
25
+ committed_at: Date;
26
+ createdAt: Date;
27
+ updatedAt: Date;
28
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,5 +1,20 @@
1
1
  import { TENANT_PURCHASE_ORDER_STATUS_ENUM } from '../../constants';
2
2
  import { IOrderPayment, IStaffDetails } from './orders';
3
+ /**
4
+ * Order-level discount for a tenant purchase order.
5
+ *
6
+ * Only the special discount slot is supported for now; voucher/loyalty
7
+ * discount slots are intentionally not part of the purchase order contract.
8
+ */
9
+ export interface ITenantPurchaseOrderDiscountDetails {
10
+ special_discount?: number;
11
+ special_discount_id?: string;
12
+ special_discount_name?: string;
13
+ is_special_discount_percentage?: boolean;
14
+ special_discount_reason?: string;
15
+ special_reference_number?: string;
16
+ total_discount: number;
17
+ }
3
18
  export interface ITenantPurchaseOrderItem {
4
19
  _id: string;
5
20
  item_id: string;
@@ -32,6 +47,19 @@ interface ITenantPurchaseOrderIterationBase<TCategory, TStatus> {
32
47
  price: number;
33
48
  amount_earned: number;
34
49
  grand_total: number;
50
+ /**
51
+ * Order-level discount (applied on top of the order subtotal).
52
+ * Mirrors `ITenantPurchaseOrder.order_discount_details`.
53
+ */
54
+ order_discount_details?: ITenantPurchaseOrderDiscountDetails | null;
55
+ /**
56
+ * Total discount applied to the order, including item-level discounts.
57
+ */
58
+ total_discount_applied?: number;
59
+ /**
60
+ * When true, GST is calculated on the original (pre-discount) amount.
61
+ */
62
+ exclude_discount_from_gst?: boolean;
35
63
  order_status: TStatus;
36
64
  updatedAt: Date;
37
65
  }
@@ -1,5 +1,14 @@
1
1
  import { WAREHOUSE_PURCHASE_ORDER_STATUS_ENUM } from '../../constants';
2
2
  import { IOrderPayment, IStaffDetails } from './orders';
3
+ export interface IWarehousePurchaseOrderDiscountDetails {
4
+ special_discount?: number;
5
+ special_discount_id?: string;
6
+ special_discount_name?: string;
7
+ is_special_discount_percentage?: boolean;
8
+ special_discount_reason?: string;
9
+ special_reference_number?: string;
10
+ total_discount: number;
11
+ }
3
12
  export type IWarehousePurchaseOrderItem = {
4
13
  _id: string;
5
14
  item_id: string;
@@ -30,6 +39,9 @@ export interface IWarehousePurchaseOrderIteration {
30
39
  price: number;
31
40
  amount_earned: number;
32
41
  grand_total: number;
42
+ order_discount_details?: IWarehousePurchaseOrderDiscountDetails | null;
43
+ total_discount_applied?: number;
44
+ exclude_discount_from_gst?: boolean;
33
45
  order_status: WAREHOUSE_PURCHASE_ORDER_STATUS_ENUM;
34
46
  updatedAt: Date;
35
47
  payments: IOrderPayment[];