@managesome/eposmatic-toolkit 0.2.364 → 0.2.365

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 (83) hide show
  1. package/lib/constants/ENUMS.d.ts +221 -0
  2. package/lib/constants/ENUMS.js +270 -4
  3. package/lib/constants/PURCHASE_ORDER.js +12 -3
  4. package/lib/helpers/store/common-purchase-order-actions.d.ts +2 -2
  5. package/lib/helpers/store/purchase-orders-cart-actions.d.ts +7 -6
  6. package/lib/schemas/models/index.d.ts +11 -0
  7. package/lib/schemas/models/index.js +11 -0
  8. package/lib/schemas/models/internal_movements.d.ts +357 -0
  9. package/lib/schemas/models/internal_movements.js +323 -0
  10. package/lib/schemas/models/inventory_lot_serial_numbers.d.ts +154 -0
  11. package/lib/schemas/models/inventory_lot_serial_numbers.js +193 -0
  12. package/lib/schemas/models/item_transactions.d.ts +3 -3
  13. package/lib/schemas/models/purchase_order_receipts.d.ts +165 -0
  14. package/lib/schemas/models/purchase_order_receipts.js +151 -0
  15. package/lib/schemas/models/purchase_order_rfq.d.ts +1938 -0
  16. package/lib/schemas/models/purchase_order_rfq.js +309 -0
  17. package/lib/schemas/models/purchase_order_vendor_returns.d.ts +234 -0
  18. package/lib/schemas/models/purchase_order_vendor_returns.js +188 -0
  19. package/lib/schemas/models/purchase_orders.d.ts +6 -3
  20. package/lib/schemas/models/purchase_orders.js +10 -1
  21. package/lib/schemas/models/rewards_usage.d.ts +3 -3
  22. package/lib/schemas/models/rider.d.ts +3 -3
  23. package/lib/schemas/models/sale_order_deliveries.d.ts +167 -0
  24. package/lib/schemas/models/sale_order_deliveries.js +155 -0
  25. package/lib/schemas/models/sale_order_invoices.d.ts +218 -0
  26. package/lib/schemas/models/sale_order_invoices.js +192 -0
  27. package/lib/schemas/models/sale_order_rfq.d.ts +1938 -0
  28. package/lib/schemas/models/sale_order_rfq.js +309 -0
  29. package/lib/schemas/models/sale_orders.d.ts +1943 -0
  30. package/lib/schemas/models/sale_orders.js +324 -0
  31. package/lib/schemas/models/void_purchase_order_items.d.ts +3 -3
  32. package/lib/schemas/models/void_purchase_order_items.js +2 -1
  33. package/lib/schemas/models/void_warehouse_invoice_items.d.ts +9 -9
  34. package/lib/schemas/models/warehouse-activity-logs.d.ts +127 -0
  35. package/lib/schemas/models/warehouse-activity-logs.js +143 -0
  36. package/lib/schemas/models/warehouse-communications.d.ts +228 -0
  37. package/lib/schemas/models/warehouse-communications.js +216 -0
  38. package/lib/schemas/models/warehouse.d.ts +7 -1
  39. package/lib/schemas/models/warehouse.js +9 -0
  40. package/lib/schemas/models/warehouse_categories.d.ts +4 -0
  41. package/lib/schemas/models/warehouse_categories.js +6 -0
  42. package/lib/schemas/models/warehouse_clients.d.ts +6 -0
  43. package/lib/schemas/models/warehouse_clients.js +8 -0
  44. package/lib/schemas/models/warehouse_inventory_transactions.d.ts +3 -3
  45. package/lib/schemas/models/warehouse_invoices.d.ts +3 -3
  46. package/lib/schemas/models/warehouse_item_transactions.d.ts +6 -6
  47. package/lib/schemas/models/warehouse_items.d.ts +28 -9
  48. package/lib/schemas/models/warehouse_items.js +29 -0
  49. package/lib/schemas/models/warehouse_vendors.d.ts +3 -3
  50. package/lib/schemas/types/index.d.ts +13 -0
  51. package/lib/schemas/types/index.js +13 -0
  52. package/lib/schemas/types/internal_movements.d.ts +73 -0
  53. package/lib/schemas/types/internal_movements.js +2 -0
  54. package/lib/schemas/types/inventory_lot_serial_numbers.d.ts +85 -0
  55. package/lib/schemas/types/inventory_lot_serial_numbers.js +4 -0
  56. package/lib/schemas/types/purchase_order_common.d.ts +39 -0
  57. package/lib/schemas/types/purchase_order_common.js +2 -0
  58. package/lib/schemas/types/purchase_order_receipts.d.ts +39 -0
  59. package/lib/schemas/types/purchase_order_receipts.js +21 -0
  60. package/lib/schemas/types/purchase_order_rfq.d.ts +25 -0
  61. package/lib/schemas/types/purchase_order_rfq.js +2 -0
  62. package/lib/schemas/types/purchase_order_vendor_returns.d.ts +49 -0
  63. package/lib/schemas/types/purchase_order_vendor_returns.js +42 -0
  64. package/lib/schemas/types/purchase_orders.d.ts +7 -43
  65. package/lib/schemas/types/sale_order_common.d.ts +39 -0
  66. package/lib/schemas/types/sale_order_common.js +2 -0
  67. package/lib/schemas/types/sale_order_deliveries.d.ts +67 -0
  68. package/lib/schemas/types/sale_order_deliveries.js +2 -0
  69. package/lib/schemas/types/sale_order_invoices.d.ts +46 -0
  70. package/lib/schemas/types/sale_order_invoices.js +2 -0
  71. package/lib/schemas/types/sale_order_rfq.d.ts +25 -0
  72. package/lib/schemas/types/sale_order_rfq.js +2 -0
  73. package/lib/schemas/types/sale_orders.d.ts +30 -0
  74. package/lib/schemas/types/sale_orders.js +2 -0
  75. package/lib/schemas/types/warehouse-activity-logs.d.ts +35 -0
  76. package/lib/schemas/types/warehouse-activity-logs.js +4 -0
  77. package/lib/schemas/types/warehouse-communications.d.ts +53 -0
  78. package/lib/schemas/types/warehouse-communications.js +2 -0
  79. package/lib/schemas/types/warehouse.d.ts +3 -1
  80. package/lib/schemas/types/warehouse_categories.d.ts +2 -0
  81. package/lib/schemas/types/warehouse_clients.d.ts +2 -0
  82. package/lib/schemas/types/warehouse_items.d.ts +7 -1
  83. package/package.json +1 -1
@@ -0,0 +1,188 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PURCHASE_ORDER_VENDOR_RETURNS_COLLECTION_NAME = exports.PurchaseOrderVendorReturnsSchema = void 0;
4
+ const mongoose_1 = require("mongoose");
5
+ const constants_1 = require("../../constants");
6
+ const purchase_orders_1 = require("./purchase_orders");
7
+ const warehouse_1 = require("./warehouse");
8
+ const warehouse_items_1 = require("./warehouse_items");
9
+ const warehouse_vendors_1 = require("./warehouse_vendors");
10
+ const PurchaseOrderVendorReturnActorSchema = new mongoose_1.Schema({
11
+ _id: {
12
+ type: String,
13
+ required: true,
14
+ },
15
+ name: {
16
+ type: String,
17
+ required: true,
18
+ default: '',
19
+ },
20
+ }, { _id: false, minimize: false });
21
+ const PurchaseOrderVendorReturnItemsSchema = new mongoose_1.Schema({
22
+ _id: {
23
+ type: mongoose_1.Schema.Types.ObjectId,
24
+ required: true,
25
+ immutable: true,
26
+ },
27
+ item_id: {
28
+ type: mongoose_1.Schema.Types.ObjectId,
29
+ required: true,
30
+ immutable: true,
31
+ ref: warehouse_items_1.WAREHOUSE_ITEMS_COLLECTION_NAME,
32
+ },
33
+ name: {
34
+ type: String,
35
+ required: true,
36
+ },
37
+ ordered_quantity: {
38
+ type: Number,
39
+ min: 0,
40
+ required: true,
41
+ },
42
+ return_quantity: {
43
+ type: Number,
44
+ min: 0,
45
+ required: true,
46
+ },
47
+ price: {
48
+ type: Number,
49
+ min: 0,
50
+ required: true,
51
+ },
52
+ subtotal: {
53
+ type: Number,
54
+ min: 0,
55
+ required: true,
56
+ },
57
+ reason: {
58
+ type: String,
59
+ required: false,
60
+ },
61
+ }, {
62
+ _id: false,
63
+ minimize: false,
64
+ });
65
+ exports.PurchaseOrderVendorReturnsSchema = new mongoose_1.Schema({
66
+ _id: {
67
+ type: mongoose_1.Schema.Types.ObjectId,
68
+ required: true,
69
+ immutable: true,
70
+ },
71
+ warehouse_id: {
72
+ type: String,
73
+ required: true,
74
+ ref: warehouse_1.WAREHOUSE_SETTINGS_COLLECTION_NAME,
75
+ },
76
+ purchase_order_id: {
77
+ type: mongoose_1.Schema.Types.ObjectId,
78
+ required: true,
79
+ ref: purchase_orders_1.PURCHASE_ORDER_COLLECTION_NAME,
80
+ },
81
+ vendor_id: {
82
+ type: mongoose_1.Schema.Types.ObjectId,
83
+ required: true,
84
+ ref: warehouse_vendors_1.WAREHOUSE_VENDORS_COLLECTION_NAME,
85
+ },
86
+ vendor_name: {
87
+ type: String,
88
+ default: '',
89
+ },
90
+ return_status: {
91
+ type: String,
92
+ enum: constants_1.ALL_PURCHASE_ORDER_VENDOR_RETURN_STATUS_NAMES,
93
+ required: true,
94
+ default: constants_1.PURCHASE_ORDER_VENDOR_RETURN_STATUS_ENUM.CREATED,
95
+ },
96
+ inventory_consumed: {
97
+ type: Boolean,
98
+ required: true,
99
+ default: false,
100
+ },
101
+ items: {
102
+ type: [PurchaseOrderVendorReturnItemsSchema],
103
+ required: true,
104
+ default: [],
105
+ },
106
+ total_return_amount: {
107
+ type: Number,
108
+ min: 0,
109
+ required: true,
110
+ },
111
+ notes: {
112
+ type: String,
113
+ required: false,
114
+ },
115
+ created_by: {
116
+ type: PurchaseOrderVendorReturnActorSchema,
117
+ required: false,
118
+ },
119
+ approved_by: {
120
+ type: PurchaseOrderVendorReturnActorSchema,
121
+ required: false,
122
+ },
123
+ dispatched_by: {
124
+ type: PurchaseOrderVendorReturnActorSchema,
125
+ required: false,
126
+ },
127
+ vendor_confirmed_by: {
128
+ type: PurchaseOrderVendorReturnActorSchema,
129
+ required: false,
130
+ },
131
+ completed_by: {
132
+ type: PurchaseOrderVendorReturnActorSchema,
133
+ required: false,
134
+ },
135
+ cancelled_by: {
136
+ type: PurchaseOrderVendorReturnActorSchema,
137
+ required: false,
138
+ },
139
+ approved_at: {
140
+ type: mongoose_1.Schema.Types.Date,
141
+ required: false,
142
+ },
143
+ dispatched_at: {
144
+ type: mongoose_1.Schema.Types.Date,
145
+ required: false,
146
+ },
147
+ vendor_confirmed_at: {
148
+ type: mongoose_1.Schema.Types.Date,
149
+ required: false,
150
+ },
151
+ completed_at: {
152
+ type: mongoose_1.Schema.Types.Date,
153
+ required: false,
154
+ },
155
+ cancelled_at: {
156
+ type: mongoose_1.Schema.Types.Date,
157
+ required: false,
158
+ },
159
+ cancel_reason: {
160
+ type: String,
161
+ required: false,
162
+ },
163
+ createdAt_mins: {
164
+ type: Number,
165
+ required: true,
166
+ immutable: true,
167
+ default: () => {
168
+ const date = new Date();
169
+ return Math.floor(date.getHours() * 60 + date.getMinutes());
170
+ },
171
+ },
172
+ createdAt: {
173
+ type: mongoose_1.Schema.Types.Date,
174
+ required: true,
175
+ default: () => new Date(),
176
+ immutable: true,
177
+ },
178
+ updatedAt: {
179
+ type: mongoose_1.Schema.Types.Date,
180
+ required: true,
181
+ default: () => new Date(),
182
+ },
183
+ }, {
184
+ timestamps: true,
185
+ versionKey: false,
186
+ minimize: false,
187
+ });
188
+ exports.PURCHASE_ORDER_VENDOR_RETURNS_COLLECTION_NAME = 'purchase_order_vendor_returns';
@@ -873,6 +873,7 @@ export declare const PurchaseOrderSchema: Schema<any, import("mongoose").Model<a
873
873
  amount_collected: number;
874
874
  is_deleted: boolean;
875
875
  order_status_updated_at: NativeDate;
876
+ warehouse_id: string;
876
877
  staff_details: {
877
878
  staff_id: string;
878
879
  staff_name: string;
@@ -881,7 +882,6 @@ export declare const PurchaseOrderSchema: Schema<any, import("mongoose").Model<a
881
882
  };
882
883
  order_settled_at: NativeDate;
883
884
  order_settled_at_mins: number;
884
- warehouse_id: string;
885
885
  vendor_id: import("mongoose").Types.ObjectId;
886
886
  vendor_name: string;
887
887
  cancel_reason?: string | null | undefined;
@@ -891,6 +891,7 @@ export declare const PurchaseOrderSchema: Schema<any, import("mongoose").Model<a
891
891
  gst?: number | null | undefined;
892
892
  gst_amount?: number | null | undefined;
893
893
  is_gst_inclusive?: boolean | null | undefined;
894
+ rfq_id?: import("mongoose").Types.ObjectId | null | undefined;
894
895
  }, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
895
896
  createdAt: NativeDate;
896
897
  updatedAt: NativeDate;
@@ -1761,6 +1762,7 @@ export declare const PurchaseOrderSchema: Schema<any, import("mongoose").Model<a
1761
1762
  amount_collected: number;
1762
1763
  is_deleted: boolean;
1763
1764
  order_status_updated_at: NativeDate;
1765
+ warehouse_id: string;
1764
1766
  staff_details: {
1765
1767
  staff_id: string;
1766
1768
  staff_name: string;
@@ -1769,7 +1771,6 @@ export declare const PurchaseOrderSchema: Schema<any, import("mongoose").Model<a
1769
1771
  };
1770
1772
  order_settled_at: NativeDate;
1771
1773
  order_settled_at_mins: number;
1772
- warehouse_id: string;
1773
1774
  vendor_id: import("mongoose").Types.ObjectId;
1774
1775
  vendor_name: string;
1775
1776
  cancel_reason?: string | null | undefined;
@@ -1779,6 +1780,7 @@ export declare const PurchaseOrderSchema: Schema<any, import("mongoose").Model<a
1779
1780
  gst?: number | null | undefined;
1780
1781
  gst_amount?: number | null | undefined;
1781
1782
  is_gst_inclusive?: boolean | null | undefined;
1783
+ rfq_id?: import("mongoose").Types.ObjectId | null | undefined;
1782
1784
  }>> & import("mongoose").FlatRecord<{
1783
1785
  createdAt: NativeDate;
1784
1786
  updatedAt: NativeDate;
@@ -2649,6 +2651,7 @@ export declare const PurchaseOrderSchema: Schema<any, import("mongoose").Model<a
2649
2651
  amount_collected: number;
2650
2652
  is_deleted: boolean;
2651
2653
  order_status_updated_at: NativeDate;
2654
+ warehouse_id: string;
2652
2655
  staff_details: {
2653
2656
  staff_id: string;
2654
2657
  staff_name: string;
@@ -2657,7 +2660,6 @@ export declare const PurchaseOrderSchema: Schema<any, import("mongoose").Model<a
2657
2660
  };
2658
2661
  order_settled_at: NativeDate;
2659
2662
  order_settled_at_mins: number;
2660
- warehouse_id: string;
2661
2663
  vendor_id: import("mongoose").Types.ObjectId;
2662
2664
  vendor_name: string;
2663
2665
  cancel_reason?: string | null | undefined;
@@ -2667,6 +2669,7 @@ export declare const PurchaseOrderSchema: Schema<any, import("mongoose").Model<a
2667
2669
  gst?: number | null | undefined;
2668
2670
  gst_amount?: number | null | undefined;
2669
2671
  is_gst_inclusive?: boolean | null | undefined;
2672
+ rfq_id?: import("mongoose").Types.ObjectId | null | undefined;
2670
2673
  }> & Required<{
2671
2674
  _id: import("mongoose").Types.ObjectId;
2672
2675
  }> & {
@@ -4,6 +4,9 @@ exports.PURCHASE_ORDER_COLLECTION_NAME = exports.PurchaseOrderSchema = void 0;
4
4
  const mongoose_1 = require("mongoose");
5
5
  const constants_1 = require("../../constants");
6
6
  const common_models_1 = require("./common-models");
7
+ const purchase_order_rfq_1 = require("./purchase_order_rfq");
8
+ const warehouse_categories_1 = require("./warehouse_categories");
9
+ const warehouse_items_1 = require("./warehouse_items");
7
10
  const warehouse_1 = require("./warehouse");
8
11
  const warehouse_vendors_1 = require("./warehouse_vendors");
9
12
  const StaffDetailsSchema = new mongoose_1.Schema({
@@ -34,6 +37,7 @@ const ItemsModal = new mongoose_1.Schema({
34
37
  type: mongoose_1.Schema.Types.ObjectId,
35
38
  required: true,
36
39
  immutable: true,
40
+ ref: warehouse_items_1.WAREHOUSE_ITEMS_COLLECTION_NAME,
37
41
  },
38
42
  is_ready: {
39
43
  type: Boolean,
@@ -92,7 +96,7 @@ const CatergoriesSchema = new mongoose_1.Schema({
92
96
  type: mongoose_1.Schema.Types.ObjectId,
93
97
  required: true,
94
98
  immutable: true,
95
- ref: 'warehouse_categories',
99
+ ref: warehouse_categories_1.WAREHOUSE_CATEGORY_COLLECTION_NAME,
96
100
  },
97
101
  name: {
98
102
  type: String,
@@ -190,6 +194,11 @@ exports.PurchaseOrderSchema = new mongoose_1.Schema({
190
194
  type: String,
191
195
  default: '',
192
196
  },
197
+ rfq_id: {
198
+ type: mongoose_1.Schema.Types.ObjectId,
199
+ required: false,
200
+ ref: purchase_order_rfq_1.PURCHASE_ORDER_RFQ_COLLECTION_NAME,
201
+ },
193
202
  categories: {
194
203
  type: [CatergoriesSchema],
195
204
  default: [],
@@ -12,11 +12,11 @@ export declare const RewardsUsageSchema: Schema<any, import("mongoose").Model<an
12
12
  updatedAt: NativeDate;
13
13
  ref_id: import("mongoose").Types.ObjectId;
14
14
  customer_phone: string;
15
+ ref_type: import("../../constants").REWARDS_USAGE_REF_TYPE_ENUM;
15
16
  used_count: number;
16
17
  last_used_at: NativeDate;
17
18
  assigned_count: number;
18
19
  last_assigned_at: NativeDate;
19
- ref_type: import("../../constants").REWARDS_USAGE_REF_TYPE_ENUM;
20
20
  }, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
21
21
  createdAt: NativeDate;
22
22
  updatedAt: NativeDate;
@@ -26,11 +26,11 @@ export declare const RewardsUsageSchema: Schema<any, import("mongoose").Model<an
26
26
  updatedAt: NativeDate;
27
27
  ref_id: import("mongoose").Types.ObjectId;
28
28
  customer_phone: string;
29
+ ref_type: import("../../constants").REWARDS_USAGE_REF_TYPE_ENUM;
29
30
  used_count: number;
30
31
  last_used_at: NativeDate;
31
32
  assigned_count: number;
32
33
  last_assigned_at: NativeDate;
33
- ref_type: import("../../constants").REWARDS_USAGE_REF_TYPE_ENUM;
34
34
  }>> & import("mongoose").FlatRecord<{
35
35
  createdAt: NativeDate;
36
36
  updatedAt: NativeDate;
@@ -40,11 +40,11 @@ export declare const RewardsUsageSchema: Schema<any, import("mongoose").Model<an
40
40
  updatedAt: NativeDate;
41
41
  ref_id: import("mongoose").Types.ObjectId;
42
42
  customer_phone: string;
43
+ ref_type: import("../../constants").REWARDS_USAGE_REF_TYPE_ENUM;
43
44
  used_count: number;
44
45
  last_used_at: NativeDate;
45
46
  assigned_count: number;
46
47
  last_assigned_at: NativeDate;
47
- ref_type: import("../../constants").REWARDS_USAGE_REF_TYPE_ENUM;
48
48
  }> & Required<{
49
49
  _id: import("mongoose").Types.ObjectId;
50
50
  }> & {
@@ -18,8 +18,8 @@ export declare const RiderSchema: Schema<any, import("mongoose").Model<any, any,
18
18
  display_name: string;
19
19
  email: string;
20
20
  is_disabled: boolean;
21
- is_public: boolean;
22
21
  is_available: boolean;
22
+ is_public: boolean;
23
23
  is_verified: boolean;
24
24
  }, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
25
25
  createdAt: NativeDate;
@@ -36,8 +36,8 @@ export declare const RiderSchema: Schema<any, import("mongoose").Model<any, any,
36
36
  display_name: string;
37
37
  email: string;
38
38
  is_disabled: boolean;
39
- is_public: boolean;
40
39
  is_available: boolean;
40
+ is_public: boolean;
41
41
  is_verified: boolean;
42
42
  }>> & import("mongoose").FlatRecord<{
43
43
  createdAt: NativeDate;
@@ -54,8 +54,8 @@ export declare const RiderSchema: Schema<any, import("mongoose").Model<any, any,
54
54
  display_name: string;
55
55
  email: string;
56
56
  is_disabled: boolean;
57
- is_public: boolean;
58
57
  is_available: boolean;
58
+ is_public: boolean;
59
59
  is_verified: boolean;
60
60
  }> & Required<{
61
61
  _id: import("mongoose").Types.ObjectId;
@@ -0,0 +1,167 @@
1
+ import { Schema } from 'mongoose';
2
+ export declare const WAREHOUSE_SALE_DELIVERY_COLLECTION_NAME = "warehouse_sale_deliveries";
3
+ export declare const SaleOrderDeliveriesSchema: Schema<any, import("mongoose").Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
4
+ timestamps: true;
5
+ versionKey: false;
6
+ minimize: false;
7
+ }, {
8
+ createdAt: NativeDate;
9
+ updatedAt: NativeDate;
10
+ } & {
11
+ _id: import("mongoose").Types.ObjectId;
12
+ createdAt_mins: number;
13
+ createdAt: NativeDate;
14
+ updatedAt: NativeDate;
15
+ items: import("mongoose").Types.DocumentArray<{
16
+ quantity: number;
17
+ item_id: import("mongoose").Types.ObjectId;
18
+ item_name: string;
19
+ reason?: string | null | undefined;
20
+ }, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
21
+ quantity: number;
22
+ item_id: import("mongoose").Types.ObjectId;
23
+ item_name: string;
24
+ reason?: string | null | undefined;
25
+ }> & {
26
+ quantity: number;
27
+ item_id: import("mongoose").Types.ObjectId;
28
+ item_name: string;
29
+ reason?: string | null | undefined;
30
+ }>;
31
+ status: import("../../constants").SALE_ORDER_DELIVERY_STATUS_ENUM | import("../../constants").SALE_ORDER_DELIVERY_RETURN_STATUS_ENUM;
32
+ warehouse_id: string;
33
+ doc_kind: import("../../constants").SALE_ORDER_PHYSICAL_DOC_KIND_ENUM;
34
+ sale_order_id: import("mongoose").Types.ObjectId;
35
+ cancel_reason?: string | null | undefined;
36
+ notes?: string | null | undefined;
37
+ created_by?: {
38
+ _id: string;
39
+ name: string;
40
+ } | null | undefined;
41
+ delivered_at?: NativeDate | null | undefined;
42
+ cancelled_at?: NativeDate | null | undefined;
43
+ delivered_by?: {
44
+ _id: string;
45
+ name: string;
46
+ } | null | undefined;
47
+ cancelled_by?: {
48
+ _id: string;
49
+ name: string;
50
+ } | null | undefined;
51
+ inventory_consumed?: boolean | null | undefined;
52
+ applied_to_doc_id?: import("mongoose").Types.ObjectId | null | undefined;
53
+ inventory_restocked?: boolean | null | undefined;
54
+ returned_by?: {
55
+ _id: string;
56
+ name: string;
57
+ } | null | undefined;
58
+ returned_at?: NativeDate | null | undefined;
59
+ }, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
60
+ createdAt: NativeDate;
61
+ updatedAt: NativeDate;
62
+ } & {
63
+ _id: import("mongoose").Types.ObjectId;
64
+ createdAt_mins: number;
65
+ createdAt: NativeDate;
66
+ updatedAt: NativeDate;
67
+ items: import("mongoose").Types.DocumentArray<{
68
+ quantity: number;
69
+ item_id: import("mongoose").Types.ObjectId;
70
+ item_name: string;
71
+ reason?: string | null | undefined;
72
+ }, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
73
+ quantity: number;
74
+ item_id: import("mongoose").Types.ObjectId;
75
+ item_name: string;
76
+ reason?: string | null | undefined;
77
+ }> & {
78
+ quantity: number;
79
+ item_id: import("mongoose").Types.ObjectId;
80
+ item_name: string;
81
+ reason?: string | null | undefined;
82
+ }>;
83
+ status: import("../../constants").SALE_ORDER_DELIVERY_STATUS_ENUM | import("../../constants").SALE_ORDER_DELIVERY_RETURN_STATUS_ENUM;
84
+ warehouse_id: string;
85
+ doc_kind: import("../../constants").SALE_ORDER_PHYSICAL_DOC_KIND_ENUM;
86
+ sale_order_id: import("mongoose").Types.ObjectId;
87
+ cancel_reason?: string | null | undefined;
88
+ notes?: string | null | undefined;
89
+ created_by?: {
90
+ _id: string;
91
+ name: string;
92
+ } | null | undefined;
93
+ delivered_at?: NativeDate | null | undefined;
94
+ cancelled_at?: NativeDate | null | undefined;
95
+ delivered_by?: {
96
+ _id: string;
97
+ name: string;
98
+ } | null | undefined;
99
+ cancelled_by?: {
100
+ _id: string;
101
+ name: string;
102
+ } | null | undefined;
103
+ inventory_consumed?: boolean | null | undefined;
104
+ applied_to_doc_id?: import("mongoose").Types.ObjectId | null | undefined;
105
+ inventory_restocked?: boolean | null | undefined;
106
+ returned_by?: {
107
+ _id: string;
108
+ name: string;
109
+ } | null | undefined;
110
+ returned_at?: NativeDate | null | undefined;
111
+ }>> & import("mongoose").FlatRecord<{
112
+ createdAt: NativeDate;
113
+ updatedAt: NativeDate;
114
+ } & {
115
+ _id: import("mongoose").Types.ObjectId;
116
+ createdAt_mins: number;
117
+ createdAt: NativeDate;
118
+ updatedAt: NativeDate;
119
+ items: import("mongoose").Types.DocumentArray<{
120
+ quantity: number;
121
+ item_id: import("mongoose").Types.ObjectId;
122
+ item_name: string;
123
+ reason?: string | null | undefined;
124
+ }, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
125
+ quantity: number;
126
+ item_id: import("mongoose").Types.ObjectId;
127
+ item_name: string;
128
+ reason?: string | null | undefined;
129
+ }> & {
130
+ quantity: number;
131
+ item_id: import("mongoose").Types.ObjectId;
132
+ item_name: string;
133
+ reason?: string | null | undefined;
134
+ }>;
135
+ status: import("../../constants").SALE_ORDER_DELIVERY_STATUS_ENUM | import("../../constants").SALE_ORDER_DELIVERY_RETURN_STATUS_ENUM;
136
+ warehouse_id: string;
137
+ doc_kind: import("../../constants").SALE_ORDER_PHYSICAL_DOC_KIND_ENUM;
138
+ sale_order_id: import("mongoose").Types.ObjectId;
139
+ cancel_reason?: string | null | undefined;
140
+ notes?: string | null | undefined;
141
+ created_by?: {
142
+ _id: string;
143
+ name: string;
144
+ } | null | undefined;
145
+ delivered_at?: NativeDate | null | undefined;
146
+ cancelled_at?: NativeDate | null | undefined;
147
+ delivered_by?: {
148
+ _id: string;
149
+ name: string;
150
+ } | null | undefined;
151
+ cancelled_by?: {
152
+ _id: string;
153
+ name: string;
154
+ } | null | undefined;
155
+ inventory_consumed?: boolean | null | undefined;
156
+ applied_to_doc_id?: import("mongoose").Types.ObjectId | null | undefined;
157
+ inventory_restocked?: boolean | null | undefined;
158
+ returned_by?: {
159
+ _id: string;
160
+ name: string;
161
+ } | null | undefined;
162
+ returned_at?: NativeDate | null | undefined;
163
+ }> & Required<{
164
+ _id: import("mongoose").Types.ObjectId;
165
+ }> & {
166
+ __v: number;
167
+ }>;
@@ -0,0 +1,155 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SaleOrderDeliveriesSchema = exports.WAREHOUSE_SALE_DELIVERY_COLLECTION_NAME = void 0;
4
+ const mongoose_1 = require("mongoose");
5
+ const constants_1 = require("../../constants");
6
+ const sale_orders_1 = require("./sale_orders");
7
+ const warehouse_1 = require("./warehouse");
8
+ const warehouse_items_1 = require("./warehouse_items");
9
+ exports.WAREHOUSE_SALE_DELIVERY_COLLECTION_NAME = 'warehouse_sale_deliveries';
10
+ const ALL_SALE_ORDER_PHYSICAL_DOC_STATUS_NAMES = Array.from(new Set([...constants_1.ALL_SALE_ORDER_DELIVERY_STATUS_NAMES, ...constants_1.ALL_SALE_ORDER_DELIVERY_RETURN_STATUS_NAMES]));
11
+ const SaleOrderDeliveryActorSchema = new mongoose_1.Schema({
12
+ _id: {
13
+ type: String,
14
+ required: true,
15
+ },
16
+ name: {
17
+ type: String,
18
+ default: '',
19
+ },
20
+ }, {
21
+ _id: false,
22
+ minimize: false,
23
+ });
24
+ const SaleOrderDeliveryItemsSchema = new mongoose_1.Schema({
25
+ item_id: {
26
+ type: mongoose_1.Schema.Types.ObjectId,
27
+ required: true,
28
+ ref: warehouse_items_1.WAREHOUSE_ITEMS_COLLECTION_NAME,
29
+ },
30
+ item_name: {
31
+ type: String,
32
+ required: true,
33
+ },
34
+ quantity: {
35
+ type: Number,
36
+ min: 0,
37
+ required: true,
38
+ },
39
+ reason: {
40
+ type: String,
41
+ required: false,
42
+ },
43
+ }, {
44
+ _id: false,
45
+ minimize: false,
46
+ });
47
+ exports.SaleOrderDeliveriesSchema = new mongoose_1.Schema({
48
+ _id: {
49
+ type: mongoose_1.Schema.Types.ObjectId,
50
+ required: true,
51
+ immutable: true,
52
+ },
53
+ doc_kind: {
54
+ type: String,
55
+ enum: constants_1.ALL_SALE_ORDER_PHYSICAL_DOC_KIND_NAMES,
56
+ required: true,
57
+ },
58
+ warehouse_id: {
59
+ type: String,
60
+ required: true,
61
+ ref: warehouse_1.WAREHOUSE_SETTINGS_COLLECTION_NAME,
62
+ },
63
+ sale_order_id: {
64
+ type: mongoose_1.Schema.Types.ObjectId,
65
+ required: true,
66
+ ref: sale_orders_1.SALE_ORDER_COLLECTION_NAME,
67
+ },
68
+ // Present for delivery-return records.
69
+ applied_to_doc_id: {
70
+ type: mongoose_1.Schema.Types.ObjectId,
71
+ required: false,
72
+ ref: exports.WAREHOUSE_SALE_DELIVERY_COLLECTION_NAME,
73
+ },
74
+ items: {
75
+ type: [SaleOrderDeliveryItemsSchema],
76
+ default: [],
77
+ },
78
+ status: {
79
+ type: String,
80
+ enum: ALL_SALE_ORDER_PHYSICAL_DOC_STATUS_NAMES,
81
+ required: true,
82
+ },
83
+ notes: {
84
+ type: String,
85
+ required: false,
86
+ },
87
+ // Delivery-side stock flag.
88
+ inventory_consumed: {
89
+ type: Boolean,
90
+ default: false,
91
+ required: false,
92
+ },
93
+ // Delivery-return-side stock flag.
94
+ inventory_restocked: {
95
+ type: Boolean,
96
+ default: false,
97
+ required: false,
98
+ },
99
+ created_by: {
100
+ type: SaleOrderDeliveryActorSchema,
101
+ required: false,
102
+ },
103
+ delivered_by: {
104
+ type: SaleOrderDeliveryActorSchema,
105
+ required: false,
106
+ },
107
+ returned_by: {
108
+ type: SaleOrderDeliveryActorSchema,
109
+ required: false,
110
+ },
111
+ cancelled_by: {
112
+ type: SaleOrderDeliveryActorSchema,
113
+ required: false,
114
+ },
115
+ delivered_at: {
116
+ type: mongoose_1.Schema.Types.Date,
117
+ required: false,
118
+ },
119
+ returned_at: {
120
+ type: mongoose_1.Schema.Types.Date,
121
+ required: false,
122
+ },
123
+ cancelled_at: {
124
+ type: mongoose_1.Schema.Types.Date,
125
+ required: false,
126
+ },
127
+ cancel_reason: {
128
+ type: String,
129
+ required: false,
130
+ },
131
+ createdAt_mins: {
132
+ type: Number,
133
+ required: true,
134
+ immutable: true,
135
+ default: () => {
136
+ const date = new Date();
137
+ return Math.floor(date.getHours() * 60 + date.getMinutes());
138
+ },
139
+ },
140
+ createdAt: {
141
+ type: mongoose_1.Schema.Types.Date,
142
+ required: true,
143
+ default: () => new Date(),
144
+ immutable: true,
145
+ },
146
+ updatedAt: {
147
+ type: mongoose_1.Schema.Types.Date,
148
+ required: true,
149
+ default: () => new Date(),
150
+ },
151
+ }, {
152
+ timestamps: true,
153
+ versionKey: false,
154
+ minimize: false,
155
+ });