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