Skip to main content

backbone_inventory/
lib.rs

1//! Inventory Module
2//!
3//! Generated by metaphor-schema. Enhanced with runtime implementations.
4//!
5//! This module provides:
6//! - Domain entities and repositories
7//! - Application services
8//! - HTTP and gRPC handlers
9//! - Route configuration
10//! - State machine enforcement
11//! - Validation rules runtime
12//! - RBAC middleware
13//! - Trigger execution system
14//! - Computed fields
15//! - Workflow orchestrator
16
17#![recursion_limit = "1024"]
18#![allow(unused_imports)]
19
20// Generated modules
21pub mod domain;
22pub mod infrastructure;
23pub mod application;
24pub mod presentation;
25pub mod seeders;
26pub mod exports;
27
28// Re-exports for convenience - Domain entities
29pub use domain::entity::*;
30
31// Re-exports - Infrastructure
32pub use infrastructure::persistence::*;
33
34// Re-exports - Application services
35pub use application::service::PickingBatchService;
36pub use application::service::DeliveryNoteService;
37pub use application::service::DeliveryNoteItemService;
38pub use application::service::InventoryCompanySettingService;
39pub use application::service::LandedCostService;
40pub use application::service::LandedCostLineService;
41pub use application::service::LandedCostAdjustmentLineService;
42pub use application::service::LocationService;
43pub use application::service::StockMoveService;
44pub use application::service::StockMoveLineService;
45pub use application::service::OperationTypeService;
46pub use application::service::TransferService;
47pub use application::service::RouteService;
48pub use application::service::RouteRuleService;
49pub use application::service::ReorderingRuleService;
50pub use application::service::PurchaseReceiptService;
51pub use application::service::PurchaseReceiptItemService;
52pub use application::service::QuantService;
53pub use application::service::ScrapService;
54pub use application::service::ScrapReasonTagService;
55pub use application::service::StockEntryService;
56pub use application::service::StockEntryItemService;
57pub use application::service::StockLedgerEntryService;
58pub use application::service::BinService;
59pub use application::service::StockReconciliationService;
60pub use application::service::StockReconciliationItemService;
61pub use application::service::PackageTypeService;
62pub use application::service::StorageCategoryService;
63pub use application::service::StorageCategoryCapacityService;
64pub use application::service::PutawayRuleService;
65pub use application::service::LotService;
66pub use application::service::PackageService;
67pub use application::service::WarehouseService;
68pub use application::service::StockItemService;
69
70// Re-exports - Validation
71pub use application::validator::{ValidationError, ValidationResult};
72
73use std::sync::Arc;
74use axum::Router;
75use sqlx::PgPool;
76
77/// Inventory module configuration
78///
79/// Use the builder pattern to configure and register this module:
80///
81/// ```text
82/// let inventory = InventoryModule::builder()
83///     .with_database(pool.clone())
84///     .build()?;
85///
86/// // Unguarded full CRUD (trusted/admin); compose a guarded router for production.
87/// let router = inventory.all_crud_routes();
88/// ```
89pub struct InventoryModule {
90    pub(crate) picking_batch_service: Arc<PickingBatchService>,
91    pub(crate) delivery_note_service: Arc<DeliveryNoteService>,
92    pub(crate) delivery_note_item_service: Arc<DeliveryNoteItemService>,
93    pub(crate) inventory_company_setting_service: Arc<InventoryCompanySettingService>,
94    pub(crate) landed_cost_service: Arc<LandedCostService>,
95    pub(crate) landed_cost_line_service: Arc<LandedCostLineService>,
96    pub(crate) landed_cost_adjustment_line_service: Arc<LandedCostAdjustmentLineService>,
97    pub(crate) location_service: Arc<LocationService>,
98    pub(crate) stock_move_service: Arc<StockMoveService>,
99    pub(crate) stock_move_line_service: Arc<StockMoveLineService>,
100    pub(crate) operation_type_service: Arc<OperationTypeService>,
101    pub(crate) transfer_service: Arc<TransferService>,
102    pub(crate) route_service: Arc<RouteService>,
103    pub(crate) route_rule_service: Arc<RouteRuleService>,
104    pub(crate) reordering_rule_service: Arc<ReorderingRuleService>,
105    pub(crate) purchase_receipt_service: Arc<PurchaseReceiptService>,
106    pub(crate) purchase_receipt_item_service: Arc<PurchaseReceiptItemService>,
107    pub(crate) quant_service: Arc<QuantService>,
108    pub(crate) scrap_service: Arc<ScrapService>,
109    pub(crate) scrap_reason_tag_service: Arc<ScrapReasonTagService>,
110    pub(crate) stock_entry_service: Arc<StockEntryService>,
111    pub(crate) stock_entry_item_service: Arc<StockEntryItemService>,
112    pub(crate) stock_ledger_entry_service: Arc<StockLedgerEntryService>,
113    pub(crate) bin_service: Arc<BinService>,
114    pub(crate) stock_reconciliation_service: Arc<StockReconciliationService>,
115    pub(crate) stock_reconciliation_item_service: Arc<StockReconciliationItemService>,
116    pub(crate) package_type_service: Arc<PackageTypeService>,
117    pub(crate) storage_category_service: Arc<StorageCategoryService>,
118    pub(crate) storage_category_capacity_service: Arc<StorageCategoryCapacityService>,
119    pub(crate) putaway_rule_service: Arc<PutawayRuleService>,
120    pub(crate) lot_service: Arc<LotService>,
121    pub(crate) package_service: Arc<PackageService>,
122    pub(crate) warehouse_service: Arc<WarehouseService>,
123    pub(crate) stock_item_service: Arc<StockItemService>,
124    // <<< CUSTOM FIELDS
125    // END CUSTOM
126}
127
128impl InventoryModule {
129    /// Create a new module builder
130    pub fn builder() -> InventoryModuleBuilder {
131        InventoryModuleBuilder::new()
132    }
133
134    /// Mount ALL generated CRUD endpoints (12 per entity) with NO domain
135    /// validation — the fully **unguarded** surface. A well-formed request can
136    /// create invalid rows or soft-delete a referenced master out from under its
137    /// dependents. Prefer a guarded composition (read + validated writes) for any
138    /// real deployment; use this only in trusted/admin/seeding contexts.
139    pub fn all_crud_routes(&self) -> Router {
140        use presentation::http::{
141            create_picking_batch_read_routes,
142            create_delivery_note_read_routes,
143            create_delivery_note_item_read_routes,
144            create_inventory_company_setting_routes,
145            create_landed_cost_read_routes,
146            create_landed_cost_line_read_routes,
147            create_landed_cost_adjustment_line_read_routes,
148            create_location_routes,
149            create_stock_move_read_routes,
150            create_stock_move_line_read_routes,
151            create_operation_type_routes,
152            create_transfer_read_routes,
153            create_route_routes,
154            create_route_rule_routes,
155            create_reordering_rule_routes,
156            create_purchase_receipt_read_routes,
157            create_purchase_receipt_item_read_routes,
158            create_quant_read_routes,
159            create_scrap_read_routes,
160            create_scrap_reason_tag_routes,
161            create_stock_entry_read_routes,
162            create_stock_entry_item_read_routes,
163            create_stock_ledger_entry_read_routes,
164            create_bin_read_routes,
165            create_stock_reconciliation_read_routes,
166            create_stock_reconciliation_item_read_routes,
167            create_package_type_routes,
168            create_storage_category_routes,
169            create_storage_category_capacity_routes,
170            create_putaway_rule_routes,
171            create_lot_routes,
172            create_package_routes,
173            create_warehouse_routes,
174            create_stock_item_routes,
175        };
176
177        Router::new()
178            .merge(create_picking_batch_read_routes(self.picking_batch_service.clone()))
179            // DeliveryNote: hand_set lifecycle — the state field moves only through the
180            // module's validated verbs; generic writes cannot reach it, so only the
181            // read surface mounts here.
182            .merge(create_delivery_note_read_routes(self.delivery_note_service.clone()))
183            .merge(create_delivery_note_item_read_routes(self.delivery_note_item_service.clone()))
184            .merge(create_inventory_company_setting_routes(self.inventory_company_setting_service.clone()))
185            // LandedCost: hand_set lifecycle — the state field moves only through the
186            // module's validated verbs; generic writes cannot reach it, so only the
187            // read surface mounts here.
188            .merge(create_landed_cost_read_routes(self.landed_cost_service.clone()))
189            .merge(create_landed_cost_line_read_routes(self.landed_cost_line_service.clone()))
190            .merge(create_landed_cost_adjustment_line_read_routes(self.landed_cost_adjustment_line_service.clone()))
191            .merge(create_location_routes(self.location_service.clone()))
192            // StockMove: hand_set lifecycle — the state field moves only through the
193            // module's validated verbs; generic writes cannot reach it, so only the
194            // read surface mounts here.
195            .merge(create_stock_move_read_routes(self.stock_move_service.clone()))
196            .merge(create_stock_move_line_read_routes(self.stock_move_line_service.clone()))
197            .merge(create_operation_type_routes(self.operation_type_service.clone()))
198            .merge(create_transfer_read_routes(self.transfer_service.clone()))
199            .merge(create_route_routes(self.route_service.clone()))
200            .merge(create_route_rule_routes(self.route_rule_service.clone()))
201            .merge(create_reordering_rule_routes(self.reordering_rule_service.clone()))
202            // PurchaseReceipt: hand_set lifecycle — the state field moves only through the
203            // module's validated verbs; generic writes cannot reach it, so only the
204            // read surface mounts here.
205            .merge(create_purchase_receipt_read_routes(self.purchase_receipt_service.clone()))
206            .merge(create_purchase_receipt_item_read_routes(self.purchase_receipt_item_service.clone()))
207            .merge(create_quant_read_routes(self.quant_service.clone()))
208            .merge(create_scrap_read_routes(self.scrap_service.clone()))
209            .merge(create_scrap_reason_tag_routes(self.scrap_reason_tag_service.clone()))
210            // StockEntry: hand_set lifecycle — the state field moves only through the
211            // module's validated verbs; generic writes cannot reach it, so only the
212            // read surface mounts here.
213            .merge(create_stock_entry_read_routes(self.stock_entry_service.clone()))
214            .merge(create_stock_entry_item_read_routes(self.stock_entry_item_service.clone()))
215            // StockLedgerEntry: hand_set lifecycle — the state field moves only through the
216            // module's validated verbs; generic writes cannot reach it, so only the
217            // read surface mounts here.
218            .merge(create_stock_ledger_entry_read_routes(self.stock_ledger_entry_service.clone()))
219            .merge(create_bin_read_routes(self.bin_service.clone()))
220            // StockReconciliation: hand_set lifecycle — the state field moves only through the
221            // module's validated verbs; generic writes cannot reach it, so only the
222            // read surface mounts here.
223            .merge(create_stock_reconciliation_read_routes(self.stock_reconciliation_service.clone()))
224            .merge(create_stock_reconciliation_item_read_routes(self.stock_reconciliation_item_service.clone()))
225            .merge(create_package_type_routes(self.package_type_service.clone()))
226            .merge(create_storage_category_routes(self.storage_category_service.clone()))
227            .merge(create_storage_category_capacity_routes(self.storage_category_capacity_service.clone()))
228            .merge(create_putaway_rule_routes(self.putaway_rule_service.clone()))
229            .merge(create_lot_routes(self.lot_service.clone()))
230            .merge(create_package_routes(self.package_service.clone()))
231            .merge(create_warehouse_routes(self.warehouse_service.clone()))
232            .merge(create_stock_item_routes(self.stock_item_service.clone()))
233    }
234
235    /// Deprecated alias for [`Self::all_crud_routes`]. `routes()` reads like
236    /// "the routes" but mounts UNVALIDATED generic CRUD on every entity — a naive
237    /// mount exposes unguarded writes. Compose a guarded router (read + validated
238    /// writes) for production, or call `all_crud_routes()` to opt into the full
239    /// unguarded surface explicitly.
240    #[deprecated(note = "mounts unvalidated generic CRUD; prefer readonly_routes() + validated writes, or all_crud_routes() for the full/unguarded surface")]
241    pub fn routes(&self) -> Router {
242        self.all_crud_routes()
243    }
244
245    /// Read-only routes for every entity (GET endpoints only) — the safe base.
246    ///
247    /// Generic mutation can't reach here, so this surface cannot bypass a
248    /// validated write service's invariants. Use this as the production base and
249    /// merge validated write routes (or a write service's HTTP layer) onto it.
250    pub fn readonly_routes(&self) -> Router {
251        use presentation::http::{
252            create_picking_batch_read_routes,
253            create_delivery_note_read_routes,
254            create_delivery_note_item_read_routes,
255            create_inventory_company_setting_read_routes,
256            create_landed_cost_read_routes,
257            create_landed_cost_line_read_routes,
258            create_landed_cost_adjustment_line_read_routes,
259            create_location_read_routes,
260            create_stock_move_read_routes,
261            create_stock_move_line_read_routes,
262            create_operation_type_read_routes,
263            create_transfer_read_routes,
264            create_route_read_routes,
265            create_route_rule_read_routes,
266            create_reordering_rule_read_routes,
267            create_purchase_receipt_read_routes,
268            create_purchase_receipt_item_read_routes,
269            create_quant_read_routes,
270            create_scrap_read_routes,
271            create_scrap_reason_tag_read_routes,
272            create_stock_entry_read_routes,
273            create_stock_entry_item_read_routes,
274            create_stock_ledger_entry_read_routes,
275            create_bin_read_routes,
276            create_stock_reconciliation_read_routes,
277            create_stock_reconciliation_item_read_routes,
278            create_package_type_read_routes,
279            create_storage_category_read_routes,
280            create_storage_category_capacity_read_routes,
281            create_putaway_rule_read_routes,
282            create_lot_read_routes,
283            create_package_read_routes,
284            create_warehouse_read_routes,
285            create_stock_item_read_routes,
286        };
287
288        Router::new()
289            .merge(create_picking_batch_read_routes(self.picking_batch_service.clone()))
290            .merge(create_delivery_note_read_routes(self.delivery_note_service.clone()))
291            .merge(create_delivery_note_item_read_routes(self.delivery_note_item_service.clone()))
292            .merge(create_inventory_company_setting_read_routes(self.inventory_company_setting_service.clone()))
293            .merge(create_landed_cost_read_routes(self.landed_cost_service.clone()))
294            .merge(create_landed_cost_line_read_routes(self.landed_cost_line_service.clone()))
295            .merge(create_landed_cost_adjustment_line_read_routes(self.landed_cost_adjustment_line_service.clone()))
296            .merge(create_location_read_routes(self.location_service.clone()))
297            .merge(create_stock_move_read_routes(self.stock_move_service.clone()))
298            .merge(create_stock_move_line_read_routes(self.stock_move_line_service.clone()))
299            .merge(create_operation_type_read_routes(self.operation_type_service.clone()))
300            .merge(create_transfer_read_routes(self.transfer_service.clone()))
301            .merge(create_route_read_routes(self.route_service.clone()))
302            .merge(create_route_rule_read_routes(self.route_rule_service.clone()))
303            .merge(create_reordering_rule_read_routes(self.reordering_rule_service.clone()))
304            .merge(create_purchase_receipt_read_routes(self.purchase_receipt_service.clone()))
305            .merge(create_purchase_receipt_item_read_routes(self.purchase_receipt_item_service.clone()))
306            .merge(create_quant_read_routes(self.quant_service.clone()))
307            .merge(create_scrap_read_routes(self.scrap_service.clone()))
308            .merge(create_scrap_reason_tag_read_routes(self.scrap_reason_tag_service.clone()))
309            .merge(create_stock_entry_read_routes(self.stock_entry_service.clone()))
310            .merge(create_stock_entry_item_read_routes(self.stock_entry_item_service.clone()))
311            .merge(create_stock_ledger_entry_read_routes(self.stock_ledger_entry_service.clone()))
312            .merge(create_bin_read_routes(self.bin_service.clone()))
313            .merge(create_stock_reconciliation_read_routes(self.stock_reconciliation_service.clone()))
314            .merge(create_stock_reconciliation_item_read_routes(self.stock_reconciliation_item_service.clone()))
315            .merge(create_package_type_read_routes(self.package_type_service.clone()))
316            .merge(create_storage_category_read_routes(self.storage_category_service.clone()))
317            .merge(create_storage_category_capacity_read_routes(self.storage_category_capacity_service.clone()))
318            .merge(create_putaway_rule_read_routes(self.putaway_rule_service.clone()))
319            .merge(create_lot_read_routes(self.lot_service.clone()))
320            .merge(create_package_read_routes(self.package_service.clone()))
321            .merge(create_warehouse_read_routes(self.warehouse_service.clone()))
322            .merge(create_stock_item_read_routes(self.stock_item_service.clone()))
323    }
324
325    // <<< CUSTOM METHODS
326    // END CUSTOM
327}
328
329/// Builder for InventoryModule
330pub struct InventoryModuleBuilder {
331    db_pool: Option<PgPool>,
332}
333
334impl InventoryModuleBuilder {
335    /// Create a new builder
336    pub fn new() -> Self {
337        Self {
338            db_pool: None,
339        }
340    }
341
342    /// Set the database connection pool
343    pub fn with_database(mut self, pool: PgPool) -> Self {
344        self.db_pool = Some(pool);
345        self
346    }
347
348    // <<< CUSTOM - custom builder methods
349    // END CUSTOM
350
351    /// Build the module with configured dependencies
352    pub fn build(self) -> anyhow::Result<InventoryModule> {
353        let db_pool = self.db_pool
354            .ok_or_else(|| anyhow::anyhow!("Database pool not configured"))?;
355
356        // PickingBatch service
357        let picking_batch_repository = Arc::new(PickingBatchRepository::new(db_pool.clone()));
358        let picking_batch_service = Arc::new(PickingBatchService::with_repository(picking_batch_repository.clone()));
359
360        // DeliveryNote service
361        let delivery_note_repository = Arc::new(DeliveryNoteRepository::new(db_pool.clone()));
362        let delivery_note_service = Arc::new(DeliveryNoteService::with_repository(delivery_note_repository.clone()));
363
364        // DeliveryNoteItem service
365        let delivery_note_item_repository = Arc::new(DeliveryNoteItemRepository::new(db_pool.clone()));
366        let delivery_note_item_service = Arc::new(DeliveryNoteItemService::with_repository(delivery_note_item_repository.clone()));
367
368        // InventoryCompanySetting service
369        let inventory_company_setting_repository = Arc::new(InventoryCompanySettingRepository::new(db_pool.clone()));
370        let inventory_company_setting_service = Arc::new(InventoryCompanySettingService::with_repository(inventory_company_setting_repository.clone()));
371
372        // LandedCost service
373        let landed_cost_repository = Arc::new(LandedCostRepository::new(db_pool.clone()));
374        let landed_cost_service = Arc::new(LandedCostService::with_repository(landed_cost_repository.clone()));
375
376        // LandedCostLine service
377        let landed_cost_line_repository = Arc::new(LandedCostLineRepository::new(db_pool.clone()));
378        let landed_cost_line_service = Arc::new(LandedCostLineService::with_repository(landed_cost_line_repository.clone()));
379
380        // LandedCostAdjustmentLine service
381        let landed_cost_adjustment_line_repository = Arc::new(LandedCostAdjustmentLineRepository::new(db_pool.clone()));
382        let landed_cost_adjustment_line_service = Arc::new(LandedCostAdjustmentLineService::with_repository(landed_cost_adjustment_line_repository.clone()));
383
384        // Location service
385        let location_repository = Arc::new(LocationRepository::new(db_pool.clone()));
386        let location_service = Arc::new(LocationService::with_repository(location_repository.clone()));
387
388        // StockMove service
389        let stock_move_repository = Arc::new(StockMoveRepository::new(db_pool.clone()));
390        let stock_move_service = Arc::new(StockMoveService::with_repository(stock_move_repository.clone()));
391
392        // StockMoveLine service
393        let stock_move_line_repository = Arc::new(StockMoveLineRepository::new(db_pool.clone()));
394        let stock_move_line_service = Arc::new(StockMoveLineService::with_repository(stock_move_line_repository.clone()));
395
396        // OperationType service
397        let operation_type_repository = Arc::new(OperationTypeRepository::new(db_pool.clone()));
398        let operation_type_service = Arc::new(OperationTypeService::with_repository(operation_type_repository.clone()));
399
400        // Transfer service
401        let transfer_repository = Arc::new(TransferRepository::new(db_pool.clone()));
402        let transfer_service = Arc::new(TransferService::with_repository(transfer_repository.clone()));
403
404        // Route service
405        let route_repository = Arc::new(RouteRepository::new(db_pool.clone()));
406        let route_service = Arc::new(RouteService::with_repository(route_repository.clone()));
407
408        // RouteRule service
409        let route_rule_repository = Arc::new(RouteRuleRepository::new(db_pool.clone()));
410        let route_rule_service = Arc::new(RouteRuleService::with_repository(route_rule_repository.clone()));
411
412        // ReorderingRule service
413        let reordering_rule_repository = Arc::new(ReorderingRuleRepository::new(db_pool.clone()));
414        let reordering_rule_service = Arc::new(ReorderingRuleService::with_repository(reordering_rule_repository.clone()));
415
416        // PurchaseReceipt service
417        let purchase_receipt_repository = Arc::new(PurchaseReceiptRepository::new(db_pool.clone()));
418        let purchase_receipt_service = Arc::new(PurchaseReceiptService::with_repository(purchase_receipt_repository.clone()));
419
420        // PurchaseReceiptItem service
421        let purchase_receipt_item_repository = Arc::new(PurchaseReceiptItemRepository::new(db_pool.clone()));
422        let purchase_receipt_item_service = Arc::new(PurchaseReceiptItemService::with_repository(purchase_receipt_item_repository.clone()));
423
424        // Quant service
425        let quant_repository = Arc::new(QuantRepository::new(db_pool.clone()));
426        let quant_service = Arc::new(QuantService::with_repository(quant_repository.clone()));
427
428        // Scrap service
429        let scrap_repository = Arc::new(ScrapRepository::new(db_pool.clone()));
430        let scrap_service = Arc::new(ScrapService::with_repository(scrap_repository.clone()));
431
432        // ScrapReasonTag service
433        let scrap_reason_tag_repository = Arc::new(ScrapReasonTagRepository::new(db_pool.clone()));
434        let scrap_reason_tag_service = Arc::new(ScrapReasonTagService::with_repository(scrap_reason_tag_repository.clone()));
435
436        // StockEntry service
437        let stock_entry_repository = Arc::new(StockEntryRepository::new(db_pool.clone()));
438        let stock_entry_service = Arc::new(StockEntryService::with_repository(stock_entry_repository.clone()));
439
440        // StockEntryItem service
441        let stock_entry_item_repository = Arc::new(StockEntryItemRepository::new(db_pool.clone()));
442        let stock_entry_item_service = Arc::new(StockEntryItemService::with_repository(stock_entry_item_repository.clone()));
443
444        // StockLedgerEntry service
445        let stock_ledger_entry_repository = Arc::new(StockLedgerEntryRepository::new(db_pool.clone()));
446        let stock_ledger_entry_service = Arc::new(StockLedgerEntryService::with_repository(stock_ledger_entry_repository.clone()));
447
448        // Bin service
449        let bin_repository = Arc::new(BinRepository::new(db_pool.clone()));
450        let bin_service = Arc::new(BinService::with_repository(bin_repository.clone()));
451
452        // StockReconciliation service
453        let stock_reconciliation_repository = Arc::new(StockReconciliationRepository::new(db_pool.clone()));
454        let stock_reconciliation_service = Arc::new(StockReconciliationService::with_repository(stock_reconciliation_repository.clone()));
455
456        // StockReconciliationItem service
457        let stock_reconciliation_item_repository = Arc::new(StockReconciliationItemRepository::new(db_pool.clone()));
458        let stock_reconciliation_item_service = Arc::new(StockReconciliationItemService::with_repository(stock_reconciliation_item_repository.clone()));
459
460        // PackageType service
461        let package_type_repository = Arc::new(PackageTypeRepository::new(db_pool.clone()));
462        let package_type_service = Arc::new(PackageTypeService::with_repository(package_type_repository.clone()));
463
464        // StorageCategory service
465        let storage_category_repository = Arc::new(StorageCategoryRepository::new(db_pool.clone()));
466        let storage_category_service = Arc::new(StorageCategoryService::with_repository(storage_category_repository.clone()));
467
468        // StorageCategoryCapacity service
469        let storage_category_capacity_repository = Arc::new(StorageCategoryCapacityRepository::new(db_pool.clone()));
470        let storage_category_capacity_service = Arc::new(StorageCategoryCapacityService::with_repository(storage_category_capacity_repository.clone()));
471
472        // PutawayRule service
473        let putaway_rule_repository = Arc::new(PutawayRuleRepository::new(db_pool.clone()));
474        let putaway_rule_service = Arc::new(PutawayRuleService::with_repository(putaway_rule_repository.clone()));
475
476        // Lot service
477        let lot_repository = Arc::new(LotRepository::new(db_pool.clone()));
478        let lot_service = Arc::new(LotService::with_repository(lot_repository.clone()));
479
480        // Package service
481        let package_repository = Arc::new(PackageRepository::new(db_pool.clone()));
482        let package_service = Arc::new(PackageService::with_repository(package_repository.clone()));
483
484        // Warehouse service
485        let warehouse_repository = Arc::new(WarehouseRepository::new(db_pool.clone()));
486        let warehouse_service = Arc::new(WarehouseService::with_repository(warehouse_repository.clone()));
487
488        // StockItem service
489        let stock_item_repository = Arc::new(StockItemRepository::new(db_pool.clone()));
490        let stock_item_service = Arc::new(StockItemService::with_repository(stock_item_repository.clone()));
491
492        // <<< CUSTOM
493        // END CUSTOM
494
495        Ok(InventoryModule {
496            picking_batch_service,
497            delivery_note_service,
498            delivery_note_item_service,
499            inventory_company_setting_service,
500            landed_cost_service,
501            landed_cost_line_service,
502            landed_cost_adjustment_line_service,
503            location_service,
504            stock_move_service,
505            stock_move_line_service,
506            operation_type_service,
507            transfer_service,
508            route_service,
509            route_rule_service,
510            reordering_rule_service,
511            purchase_receipt_service,
512            purchase_receipt_item_service,
513            quant_service,
514            scrap_service,
515            scrap_reason_tag_service,
516            stock_entry_service,
517            stock_entry_item_service,
518            stock_ledger_entry_service,
519            bin_service,
520            stock_reconciliation_service,
521            stock_reconciliation_item_service,
522            package_type_service,
523            storage_category_service,
524            storage_category_capacity_service,
525            putaway_rule_service,
526            lot_service,
527            package_service,
528            warehouse_service,
529            stock_item_service,
530            // <<< CUSTOM
531            // END CUSTOM
532        })
533    }
534}
535
536impl Default for InventoryModuleBuilder {
537    fn default() -> Self {
538        Self::new()
539    }
540}