1pub mod repository;
18
19pub use repository::{Repository, Transactional};
20
21use crate::errors::{BatchResult, Result};
22use crate::models::{
23 A2APurchase, A2APurchaseFilter, AddCartItem, AddCarton, AddCartonItem, AddLotCertificate,
24 AddShipmentEvent, AddWishlistItem, AddWorkOrderMaterial, AddressType, AdjustInventory,
25 AdjustLocationInventory, AdjustLot, AdjustPoints, AdjustStoreCredit, AgentCard,
26 AgentCardFilter, AgentFeedback, AgentFeedbackFilter, AgentFeedbackResponse, AgentIdentity,
27 AgentIdentityFilter, AgentMetadataEntry, AgentValidationRequest, AgentValidationResponse,
28 AgentValidationStatus, AgentWalletProofType, AllocateBackorder, AnalyticsQuery, ApAgingSummary,
29 ApplyCreditMemo, ApplyPaymentToInvoices, ApplyPromotionsRequest, ApplyPromotionsResult,
30 ArAgingFilter, ArAgingSummary, ArPaymentApplication, AutoPostingConfig, Backorder,
31 BackorderAllocation, BackorderFilter, BackorderFulfillment, BackorderSummary, BalanceSheet,
32 Bill, BillFilter, BillItem, BillOfMaterials, BillPayment, BillPaymentFilter, BillingCycle,
33 BillingCycleFilter, BillingCycleStatus, BomComponent, BomFilter, CancelSubscription, Cart,
34 CartAddress, CartFilter, CartItem, Carton, CartonItem, ChangeSerialStatus, CheckoutResult,
35 ClaimResolution, CollectionActivity, CollectionActivityFilter, CollectionStatus, CompletePick,
36 CompletePutAway, CompleteShip, ConsumeLot, ConversionResult, ConvertCurrency, CostAdjustment,
37 CostAdjustmentFilter, CostLayer, CostLayerFilter, CostMethod, CostRollup, CostTransaction,
38 CostTransactionFilter, CostTransactionType, CostVariance, CostVarianceFilter, CouponCode,
39 CouponFilter, CreateA2APurchase, CreateA2AQuote, CreateAgentCard, CreateAgentFeedback,
40 CreateAgentFeedbackResponse, CreateAgentIdentity, CreateAgentValidationRequest,
41 CreateAgentValidationResponse, CreateAutoPostingConfig, CreateBackorder, CreateBill,
42 CreateBillItem, CreateBillPayment, CreateBillingCycle, CreateBom, CreateBomComponent,
43 CreateCart, CreateCollectionActivity, CreateCostAdjustment, CreateCostLayer, CreateCouponCode,
44 CreateCreditAccount, CreateCreditMemo, CreateCustomObject, CreateCustomObjectType,
45 CreateCustomer, CreateCustomerAddress, CreateCycleCount, CreateDefectCode,
46 CreateFraudAssessment, CreateFraudRule, CreateGiftCard, CreateGlAccount, CreateGlPeriod,
47 CreateInspection, CreateInventoryItem, CreateInvoice, CreateInvoiceItem, CreateJournalEntry,
48 CreateLocation, CreateLot, CreateLoyaltyProgram, CreateNonConformance, CreateOrder,
49 CreateOrderItem, CreatePackTask, CreatePayment, CreatePaymentMethod, CreatePaymentRun,
50 CreatePickTask, CreateProduct, CreateProductVariant, CreatePromotion, CreatePurchaseOrder,
51 CreatePurchaseOrderItem, CreatePutAway, CreateQualityHold, CreateReceipt, CreateRefund,
52 CreateReturn, CreateReview, CreateReward, CreateSearchConfig, CreateSegment,
53 CreateSerialNumber, CreateSerialNumbersBulk, CreateShipTask, CreateShipment,
54 CreateShipmentItem, CreateShippingZone, CreateStoreCredit, CreateSubscription,
55 CreateSubscriptionPlan, CreateSupplier, CreateTaxExemption, CreateTaxJurisdiction,
56 CreateTaxRate, CreateWarehouse, CreateWarranty, CreateWarrantyClaim, CreateWave,
57 CreateWishlist, CreateWorkOrder, CreateWorkOrderTask, CreateWriteOff, CreateX402PaymentIntent,
58 CreateZone, CreateZoneShippingMethod, CreditAccount, CreditAccountFilter, CreditAgingBucket,
59 CreditApplication, CreditApplicationFilter, CreditCheckResult, CreditHold, CreditHoldFilter,
60 CreditMemo, CreditMemoFilter, CreditTransaction, CreditTransactionFilter, Currency,
61 CustomObject, CustomObjectFilter, CustomObjectType, CustomObjectTypeFilter, Customer,
62 CustomerAddress, CustomerArAging, CustomerArSummary, CustomerCreditSummary, CustomerFilter,
63 CustomerMetrics, CustomerStatement, CycleCount, CycleCountFilter, DefectCode, DemandForecast,
64 DunningLetterType, EmbeddingMetadata, EmbeddingStats, EnrollCustomer, EntityType, ExchangeRate,
65 ExchangeRateFilter, FeedbackSummary, FraudAssessment, FraudAssessmentFilter, FraudDecision,
66 FraudRule, FraudRuleFilter, FulfillBackorder, FulfillmentMetrics, GenerateStatementRequest,
67 GiftCard, GiftCardFilter, GiftCardTransaction, GlAccount, GlAccountFilter, GlPeriod,
68 GlPeriodFilter, IncomeStatement, Inspection, InspectionFilter, InspectionItem,
69 InventoryBalance, InventoryFilter, InventoryHealth, InventoryItem, InventoryMovement,
70 InventoryReservation, InventoryTransaction, InventoryValuation, Invoice, InvoiceFilter,
71 InvoiceItem, IssueCostLayers, ItemCost, ItemCostFilter, JournalEntry, JournalEntryFilter,
72 JournalEntryLine, Location, LocationFilter, LocationInventory, LocationInventoryFilter,
73 LocationMovement, Lot, LotCertificate, LotFilter, LotLocation, LotTransaction, LowStockItem,
74 LoyaltyAccount, LoyaltyAccountFilter, LoyaltyProgram, LoyaltyTransaction, MergeLots,
75 MoveInventory, MoveSerial, MovementFilter, NonConformance, NonConformanceFilter, Order,
76 OrderFilter, OrderItem, OrderStatusBreakdown, PackTask, PackTaskFilter, PauseSubscription,
77 Payment, PaymentAllocation, PaymentFilter, PaymentMethod, PaymentRun, PaymentRunFilter,
78 PickTask, PickTaskFilter, PlaceCreditHold, Product, ProductFilter, ProductPerformance,
79 ProductTaxCategory, ProductVariant, Promotion, PromotionFilter, PromotionUsage, PurchaseOrder,
80 PurchaseOrderFilter, PurchaseOrderItem, PurchaseStatus, PutAway, PutAwayFilter, QualityHold,
81 QualityHoldFilter, QuoteStatus, Receipt, ReceiptFilter, ReceiptItem, ReceiveItems,
82 ReceivePurchaseOrderItems, RecordCostVariance, RecordCreditTransaction, RecordCycleCountLine,
83 RecordInspectionResult, RecordInvoicePayment, Refund, ReleaseCreditHold, ReleaseQualityHold,
84 ReserveInventory, ReserveLot, ReserveSerialNumber, Return, ReturnFilter, ReturnMetrics,
85 RevaluationResult, RevenueByPeriod, RevenueForecast, Review, ReviewCreditApplication,
86 ReviewFilter, ReviewSummary, Reward, RewardFilter, SalesSummary, SearchConfig,
87 SearchConfigFilter, Segment, SegmentFilter, SegmentMembership, SerialFilter, SerialHistory,
88 SerialHistoryFilter, SerialLookupResult, SerialNumber, SerialReservation, SerialValidation,
89 SetCartPayment, SetCartShipping, SetCartX402Payment, SetExchangeRate, SetItemCost, ShipTask,
90 ShipTaskFilter, Shipment, ShipmentEvent, ShipmentFilter, ShipmentItem, ShippingRate,
91 ShippingZone, ShippingZoneFilter, SignX402PaymentIntent, SkillQuote, SkillQuoteFilter,
92 SkipBillingCycle, SkuBackorderSummary, SkuCostSummary, SplitLot, StockLevel, StoreCredit,
93 StoreCreditFilter, StoreCreditTransaction, StoreCurrencySettings, SubmitCreditApplication,
94 Subscription, SubscriptionEvent, SubscriptionEventType, SubscriptionFilter, SubscriptionPlan,
95 SubscriptionPlanFilter, Supplier, SupplierApSummary, SupplierFilter, TaxAddress,
96 TaxCalculationRequest, TaxCalculationResult, TaxExemption, TaxJurisdiction,
97 TaxJurisdictionFilter, TaxRate, TaxRateFilter, TaxSettings, TimeGranularity, TopCustomer,
98 TopProduct, TraceabilityResult, TransferLot, TransferSerialOwnership, TrialBalance, TrustLevel,
99 UpdateAgentCard, UpdateAgentIdentity, UpdateBackorder, UpdateBill, UpdateBom, UpdateCart,
100 UpdateCartItem, UpdateCreditAccount, UpdateCustomObject, UpdateCustomObjectType,
101 UpdateCustomer, UpdateFraudRule, UpdateGiftCard, UpdateGlAccount, UpdateInspection,
102 UpdateInvoice, UpdateLocation, UpdateLot, UpdateNonConformance, UpdateOrder, UpdatePayment,
103 UpdateProduct, UpdatePromotion, UpdatePurchaseOrder, UpdateReceipt, UpdateReturn, UpdateReview,
104 UpdateSearchConfig, UpdateSegment, UpdateSerialNumber, UpdateShipment, UpdateShippingZone,
105 UpdateSubscription, UpdateSubscriptionPlan, UpdateSupplier, UpdateWarehouse, UpdateWarranty,
106 UpdateWarrantyClaim, UpdateWishlist, UpdateWorkOrder, UpdateWorkOrderTask, UpdateZone,
107 ValidationSummary, VectorSearchResult, Warehouse, WarehouseFilter, Warranty, WarrantyClaim,
108 WarrantyClaimFilter, WarrantyFilter, Wave, WaveFilter, Wishlist, WishlistFilter, WishlistItem,
109 WorkOrder, WorkOrderFilter, WorkOrderMaterial, WorkOrderTask, WriteOff, WriteOffFilter,
110 X402Asset, X402CheckoutResult, X402CreditAccount, X402CreditAdjustment, X402CreditTransaction,
111 X402CreditTransactionFilter, X402Network, X402PaymentIntent, X402PaymentIntentFilter, Zone,
112 ZoneShippingMethod, ZoneShippingMethodFilter, ZoneShippingRate, ZoneShippingRateRequest,
113};
114use crate::models::{
117 ActivityLogEntry, ActivityLogFilter, ApplyPrepayment, ApplyVendorCredit, BulkSupplierSkuItem,
118 CaptureStockSnapshot, CaptureTopologySnapshot, CreateEdiDocument, CreateInboundShipment,
119 CreateIntegrationFieldMapping, CreateIntegrationMapping, CreatePaymentObligation,
120 CreatePrepayment, CreatePriceLevel, CreatePriceSchedule, CreatePrintStation, CreateSupplierSku,
121 CreateVendorCredit, CreateVendorReturn, EdiAggregateSummary, EdiDocument, EdiDocumentFilter,
122 EdiStatus, EnqueuePrintJob, InboundShipment, InboundShipmentFilter, IngestOrder,
123 IntegrationFieldMapping, IntegrationFieldMappingFilter, IntegrationMapping,
124 IntegrationMappingFilter, MapPurgatoryLine, MappingLookup, PairStationResult,
125 PaymentObligation, PaymentObligationDashboard, PaymentObligationFilter,
126 PaymentObligationStatus, Prepayment, PrepaymentApplication, PrepaymentFilter, PriceLevel,
127 PriceLevelEntry, PriceLevelFilter, PriceSchedule, PriceScheduleEntry, PriceScheduleFilter,
128 PrintJob, PrintJobFilter, PrintStation, PurgatoryFilter, PurgatoryOrder, RecordActivity,
129 StockSnapshot, StockSnapshotFilter, SupplierSku, SupplierSkuFilter, TopologySnapshot,
130 TopologySnapshotFilter, UpdateIntegrationFieldMapping, UpdateIntegrationMapping,
131 UpdatePriceLevel, UpdatePriceSchedule, UpdateSupplierSku, VendorCredit,
132 VendorCreditApplication, VendorCreditFilter, VendorReturn, VendorReturnFilter,
133};
134use crate::models::{
135 Channel, ChannelFilter, ChannelProductMapping, ChannelProductSyncItem, Company, CompanyFilter,
136 CompanyPriceOverride, CompanyShippingAddress, Contact, CreateChannel, CreateCompany,
137 CreateContact, CreateProductionBatch, CreateTransferOrder, CreateUnitClass,
138 CreateUnitConversionRule, CreateUnitOfMeasure, ProductionBatch, ProductionBatchFilter,
139 TransferOrder, TransferOrderFilter, UnitClass, UnitConversionRule, UnitOfMeasure,
140 UnitOfMeasureFilter, UpdateChannel, UpdateCompany, UpdateProductionBatch,
141};
142use chrono::{DateTime, Utc};
143use stateset_primitives::{
144 ActivityLogId, ChannelId, CompanyId, ContactId, EdiDocumentId, InboundShipmentId,
145 InboundShipmentItemId, IntegrationFieldMappingId, IntegrationMappingId, PaymentObligationId,
146 PrepaymentApplicationId, PrepaymentId, PriceLevelId, PriceScheduleId, PrintJobId,
147 PrintStationId, ProductionBatchId, PurgatoryLineItemId, PurgatoryOrderId, StockSnapshotId,
148 SupplierSkuId, TopologySnapshotId, TransferOrderId, TransferOrderItemId, UnitClassId,
149 UnitConversionRuleId, UnitOfMeasureId, VendorCreditApplicationId, VendorCreditId,
150 VendorReturnId,
151};
152use stateset_primitives::{
153 CartId, CreditId, CustomerId, FraudRuleId, FulfillmentId, GiftCardId, InvoiceId,
154 LoyaltyAccountId, LoyaltyProgramId, OrderId, OrderItemId, PaymentId, ProductId, PromotionId,
155 PurchaseOrderId, ReturnId, ReviewId, RewardId, SearchConfigId, SegmentId, ShipmentId,
156 ShippingMethodId, ShippingZoneId, StoreCreditId, SubscriptionId, WarrantyId, WishlistId,
157};
158use uuid::Uuid;
159
160#[auto_impl::auto_impl(&, Box, Arc)]
162pub trait OrderRepository: Send + Sync {
163 fn create(&self, input: CreateOrder) -> Result<Order>;
165
166 fn get(&self, id: OrderId) -> Result<Option<Order>>;
168
169 fn get_by_number(&self, order_number: &str) -> Result<Option<Order>>;
171
172 fn update(&self, id: OrderId, input: UpdateOrder) -> Result<Order>;
174
175 fn list(&self, filter: OrderFilter) -> Result<Vec<Order>>;
177
178 fn delete(&self, id: OrderId) -> Result<()>;
180
181 fn add_item(&self, order_id: OrderId, item: CreateOrderItem) -> Result<OrderItem>;
183
184 fn remove_item(&self, order_id: OrderId, item_id: OrderItemId) -> Result<()>;
186
187 fn count(&self, filter: OrderFilter) -> Result<u64>;
189
190 fn create_batch(&self, inputs: Vec<CreateOrder>) -> Result<BatchResult<Order>>;
194
195 fn create_batch_atomic(&self, inputs: Vec<CreateOrder>) -> Result<Vec<Order>>;
197
198 fn update_batch(&self, updates: Vec<(OrderId, UpdateOrder)>) -> Result<BatchResult<Order>>;
200
201 fn update_batch_atomic(&self, updates: Vec<(OrderId, UpdateOrder)>) -> Result<Vec<Order>>;
203
204 fn delete_batch(&self, ids: Vec<OrderId>) -> Result<BatchResult<OrderId>>;
206
207 fn delete_batch_atomic(&self, ids: Vec<OrderId>) -> Result<()>;
209
210 fn get_batch(&self, ids: Vec<OrderId>) -> Result<Vec<Order>>;
212}
213
214#[auto_impl::auto_impl(&, Box, Arc)]
216pub trait InventoryRepository: Send + Sync {
217 fn create_item(&self, input: CreateInventoryItem) -> Result<InventoryItem>;
219
220 fn get_item(&self, id: i64) -> Result<Option<InventoryItem>>;
222
223 fn get_item_by_sku(&self, sku: &str) -> Result<Option<InventoryItem>>;
225
226 fn get_stock(&self, sku: &str) -> Result<Option<StockLevel>>;
228
229 fn get_balance(&self, item_id: i64, location_id: i32) -> Result<Option<InventoryBalance>>;
231
232 fn adjust(&self, input: AdjustInventory) -> Result<InventoryTransaction>;
234
235 fn reserve(&self, input: ReserveInventory) -> Result<InventoryReservation>;
237
238 fn get_reservation(&self, reservation_id: Uuid) -> Result<Option<InventoryReservation>>;
240
241 fn release_reservation(&self, reservation_id: Uuid) -> Result<()>;
243
244 fn confirm_reservation(&self, reservation_id: Uuid) -> Result<()>;
246
247 fn list_reservations_by_reference(
249 &self,
250 reference_type: &str,
251 reference_id: &str,
252 ) -> Result<Vec<InventoryReservation>>;
253
254 fn list(&self, filter: InventoryFilter) -> Result<Vec<InventoryItem>>;
256
257 fn get_reorder_needed(&self) -> Result<Vec<StockLevel>>;
259
260 fn record_transaction(&self, transaction: InventoryTransaction)
262 -> Result<InventoryTransaction>;
263
264 fn get_transactions(&self, item_id: i64, limit: u32) -> Result<Vec<InventoryTransaction>>;
266
267 fn create_item_batch(
271 &self,
272 inputs: Vec<CreateInventoryItem>,
273 ) -> Result<BatchResult<InventoryItem>>;
274
275 fn create_item_batch_atomic(
277 &self,
278 inputs: Vec<CreateInventoryItem>,
279 ) -> Result<Vec<InventoryItem>>;
280
281 fn adjust_batch(
283 &self,
284 adjustments: Vec<AdjustInventory>,
285 ) -> Result<BatchResult<InventoryTransaction>>;
286
287 fn adjust_batch_atomic(
289 &self,
290 adjustments: Vec<AdjustInventory>,
291 ) -> Result<Vec<InventoryTransaction>>;
292
293 fn get_item_batch(&self, ids: Vec<i64>) -> Result<Vec<InventoryItem>>;
295
296 fn get_stock_batch(&self, skus: Vec<String>) -> Result<Vec<StockLevel>>;
298}
299
300#[auto_impl::auto_impl(&, Box, Arc)]
302pub trait CustomerRepository: Send + Sync {
303 fn create(&self, input: CreateCustomer) -> Result<Customer>;
305
306 fn get(&self, id: CustomerId) -> Result<Option<Customer>>;
308
309 fn get_by_email(&self, email: &str) -> Result<Option<Customer>>;
311
312 fn update(&self, id: CustomerId, input: UpdateCustomer) -> Result<Customer>;
314
315 fn list(&self, filter: CustomerFilter) -> Result<Vec<Customer>>;
317
318 fn delete(&self, id: CustomerId) -> Result<()>;
320
321 fn add_address(&self, input: CreateCustomerAddress) -> Result<CustomerAddress>;
323
324 fn get_addresses(&self, customer_id: CustomerId) -> Result<Vec<CustomerAddress>>;
326
327 fn update_address(
329 &self,
330 address_id: Uuid,
331 input: CreateCustomerAddress,
332 ) -> Result<CustomerAddress>;
333
334 fn delete_address(&self, address_id: Uuid) -> Result<()>;
336
337 fn set_default_address(
339 &self,
340 customer_id: CustomerId,
341 address_id: Uuid,
342 address_type: AddressType,
343 ) -> Result<()>;
344
345 fn count(&self, filter: CustomerFilter) -> Result<u64>;
347
348 fn create_batch(&self, inputs: Vec<CreateCustomer>) -> Result<BatchResult<Customer>>;
352
353 fn create_batch_atomic(&self, inputs: Vec<CreateCustomer>) -> Result<Vec<Customer>>;
355
356 fn update_batch(
358 &self,
359 updates: Vec<(CustomerId, UpdateCustomer)>,
360 ) -> Result<BatchResult<Customer>>;
361
362 fn update_batch_atomic(
364 &self,
365 updates: Vec<(CustomerId, UpdateCustomer)>,
366 ) -> Result<Vec<Customer>>;
367
368 fn delete_batch(&self, ids: Vec<CustomerId>) -> Result<BatchResult<CustomerId>>;
370
371 fn delete_batch_atomic(&self, ids: Vec<CustomerId>) -> Result<()>;
373
374 fn get_batch(&self, ids: Vec<CustomerId>) -> Result<Vec<Customer>>;
376}
377
378#[auto_impl::auto_impl(&, Box, Arc)]
380pub trait ProductRepository: Send + Sync {
381 fn create(&self, input: CreateProduct) -> Result<Product>;
383
384 fn get(&self, id: ProductId) -> Result<Option<Product>>;
386
387 fn get_by_slug(&self, slug: &str) -> Result<Option<Product>>;
389
390 fn update(&self, id: ProductId, input: UpdateProduct) -> Result<Product>;
392
393 fn list(&self, filter: ProductFilter) -> Result<Vec<Product>>;
395
396 fn delete(&self, id: ProductId) -> Result<()>;
398
399 fn add_variant(
401 &self,
402 product_id: ProductId,
403 variant: CreateProductVariant,
404 ) -> Result<ProductVariant>;
405
406 fn get_variant(&self, id: Uuid) -> Result<Option<ProductVariant>>;
408
409 fn get_variant_by_sku(&self, sku: &str) -> Result<Option<ProductVariant>>;
411
412 fn update_variant(&self, id: Uuid, variant: CreateProductVariant) -> Result<ProductVariant>;
414
415 fn delete_variant(&self, id: Uuid) -> Result<()>;
417
418 fn get_variants(&self, product_id: ProductId) -> Result<Vec<ProductVariant>>;
420
421 fn count(&self, filter: ProductFilter) -> Result<u64>;
423
424 fn create_batch(&self, inputs: Vec<CreateProduct>) -> Result<BatchResult<Product>>;
428
429 fn create_batch_atomic(&self, inputs: Vec<CreateProduct>) -> Result<Vec<Product>>;
431
432 fn update_batch(
434 &self,
435 updates: Vec<(ProductId, UpdateProduct)>,
436 ) -> Result<BatchResult<Product>>;
437
438 fn update_batch_atomic(&self, updates: Vec<(ProductId, UpdateProduct)>)
440 -> Result<Vec<Product>>;
441
442 fn delete_batch(&self, ids: Vec<ProductId>) -> Result<BatchResult<ProductId>>;
444
445 fn delete_batch_atomic(&self, ids: Vec<ProductId>) -> Result<()>;
447
448 fn get_batch(&self, ids: Vec<ProductId>) -> Result<Vec<Product>>;
450}
451
452#[auto_impl::auto_impl(&, Box, Arc)]
454pub trait ReturnRepository: Send + Sync {
455 fn create(&self, input: CreateReturn) -> Result<Return>;
457
458 fn get(&self, id: ReturnId) -> Result<Option<Return>>;
460
461 fn update(&self, id: ReturnId, input: UpdateReturn) -> Result<Return>;
463
464 fn list(&self, filter: ReturnFilter) -> Result<Vec<Return>>;
466
467 fn approve(&self, id: ReturnId) -> Result<Return>;
469
470 fn reject(&self, id: ReturnId, reason: &str) -> Result<Return>;
472
473 fn complete(&self, id: ReturnId) -> Result<Return>;
475
476 fn cancel(&self, id: ReturnId) -> Result<Return>;
478
479 fn count(&self, filter: ReturnFilter) -> Result<u64>;
481
482 fn create_batch(&self, inputs: Vec<CreateReturn>) -> Result<BatchResult<Return>>;
486
487 fn create_batch_atomic(&self, inputs: Vec<CreateReturn>) -> Result<Vec<Return>>;
489
490 fn update_batch(&self, updates: Vec<(ReturnId, UpdateReturn)>) -> Result<BatchResult<Return>>;
492
493 fn update_batch_atomic(&self, updates: Vec<(ReturnId, UpdateReturn)>) -> Result<Vec<Return>>;
495
496 fn delete_batch(&self, ids: Vec<ReturnId>) -> Result<BatchResult<Uuid>>;
498
499 fn delete_batch_atomic(&self, ids: Vec<ReturnId>) -> Result<()>;
501
502 fn get_batch(&self, ids: Vec<ReturnId>) -> Result<Vec<Return>>;
504}
505
506#[auto_impl::auto_impl(&, Box, Arc)]
508pub trait EventHandler: Send + Sync {
509 fn handle(&self, event: &crate::events::CommerceEvent) -> Result<()>;
511}
512
513#[auto_impl::auto_impl(&, Box, Arc)]
515pub trait BomRepository: Send + Sync {
516 fn create(&self, input: CreateBom) -> Result<BillOfMaterials>;
518
519 fn get(&self, id: Uuid) -> Result<Option<BillOfMaterials>>;
521
522 fn get_by_number(&self, bom_number: &str) -> Result<Option<BillOfMaterials>>;
524
525 fn update(&self, id: Uuid, input: UpdateBom) -> Result<BillOfMaterials>;
527
528 fn list(&self, filter: BomFilter) -> Result<Vec<BillOfMaterials>>;
530
531 fn delete(&self, id: Uuid) -> Result<()>;
533
534 fn add_component(&self, bom_id: Uuid, component: CreateBomComponent) -> Result<BomComponent>;
536
537 fn update_component(
539 &self,
540 component_id: Uuid,
541 component: CreateBomComponent,
542 ) -> Result<BomComponent>;
543
544 fn remove_component(&self, component_id: Uuid) -> Result<()>;
546
547 fn get_components(&self, bom_id: Uuid) -> Result<Vec<BomComponent>>;
549
550 fn activate(&self, id: Uuid) -> Result<BillOfMaterials>;
552
553 fn count(&self, filter: BomFilter) -> Result<u64>;
555
556 fn create_batch(&self, inputs: Vec<CreateBom>) -> Result<BatchResult<BillOfMaterials>>;
560
561 fn create_batch_atomic(&self, inputs: Vec<CreateBom>) -> Result<Vec<BillOfMaterials>>;
563
564 fn update_batch(&self, updates: Vec<(Uuid, UpdateBom)>)
566 -> Result<BatchResult<BillOfMaterials>>;
567
568 fn update_batch_atomic(&self, updates: Vec<(Uuid, UpdateBom)>) -> Result<Vec<BillOfMaterials>>;
570
571 fn delete_batch(&self, ids: Vec<Uuid>) -> Result<BatchResult<Uuid>>;
573
574 fn delete_batch_atomic(&self, ids: Vec<Uuid>) -> Result<()>;
576
577 fn get_batch(&self, ids: Vec<Uuid>) -> Result<Vec<BillOfMaterials>>;
579}
580
581#[auto_impl::auto_impl(&, Box, Arc)]
583pub trait WorkOrderRepository: Send + Sync {
584 fn create(&self, input: CreateWorkOrder) -> Result<WorkOrder>;
586
587 fn get(&self, id: Uuid) -> Result<Option<WorkOrder>>;
589
590 fn get_by_number(&self, work_order_number: &str) -> Result<Option<WorkOrder>>;
592
593 fn update(&self, id: Uuid, input: UpdateWorkOrder) -> Result<WorkOrder>;
595
596 fn list(&self, filter: WorkOrderFilter) -> Result<Vec<WorkOrder>>;
598
599 fn delete(&self, id: Uuid) -> Result<()>;
601
602 fn start(&self, id: Uuid) -> Result<WorkOrder>;
604
605 fn complete(&self, id: Uuid, quantity_completed: rust_decimal::Decimal) -> Result<WorkOrder>;
607
608 fn hold(&self, id: Uuid) -> Result<WorkOrder>;
610
611 fn resume(&self, id: Uuid) -> Result<WorkOrder>;
613
614 fn cancel(&self, id: Uuid) -> Result<WorkOrder>;
616
617 fn add_task(&self, work_order_id: Uuid, task: CreateWorkOrderTask) -> Result<WorkOrderTask>;
620
621 fn update_task(&self, task_id: Uuid, task: UpdateWorkOrderTask) -> Result<WorkOrderTask>;
623
624 fn remove_task(&self, task_id: Uuid) -> Result<()>;
626
627 fn get_tasks(&self, work_order_id: Uuid) -> Result<Vec<WorkOrderTask>>;
629
630 fn start_task(&self, task_id: Uuid) -> Result<WorkOrderTask>;
632
633 fn complete_task(
635 &self,
636 task_id: Uuid,
637 actual_hours: Option<rust_decimal::Decimal>,
638 ) -> Result<WorkOrderTask>;
639
640 fn add_material(
643 &self,
644 work_order_id: Uuid,
645 material: AddWorkOrderMaterial,
646 ) -> Result<WorkOrderMaterial>;
647
648 fn consume_material(
650 &self,
651 material_id: Uuid,
652 quantity: rust_decimal::Decimal,
653 ) -> Result<WorkOrderMaterial>;
654
655 fn get_materials(&self, work_order_id: Uuid) -> Result<Vec<WorkOrderMaterial>>;
657
658 fn count(&self, filter: WorkOrderFilter) -> Result<u64>;
660
661 fn create_batch(&self, inputs: Vec<CreateWorkOrder>) -> Result<BatchResult<WorkOrder>>;
665
666 fn create_batch_atomic(&self, inputs: Vec<CreateWorkOrder>) -> Result<Vec<WorkOrder>>;
668
669 fn update_batch(&self, updates: Vec<(Uuid, UpdateWorkOrder)>)
671 -> Result<BatchResult<WorkOrder>>;
672
673 fn update_batch_atomic(&self, updates: Vec<(Uuid, UpdateWorkOrder)>) -> Result<Vec<WorkOrder>>;
675
676 fn delete_batch(&self, ids: Vec<Uuid>) -> Result<BatchResult<Uuid>>;
678
679 fn delete_batch_atomic(&self, ids: Vec<Uuid>) -> Result<()>;
681
682 fn get_batch(&self, ids: Vec<Uuid>) -> Result<Vec<WorkOrder>>;
684}
685
686#[auto_impl::auto_impl(&, Box, Arc)]
688pub trait ShipmentRepository: Send + Sync {
689 fn create(&self, input: CreateShipment) -> Result<Shipment>;
691
692 fn get(&self, id: ShipmentId) -> Result<Option<Shipment>>;
694
695 fn get_by_number(&self, shipment_number: &str) -> Result<Option<Shipment>>;
697
698 fn get_by_tracking(&self, tracking_number: &str) -> Result<Option<Shipment>>;
700
701 fn update(&self, id: ShipmentId, input: UpdateShipment) -> Result<Shipment>;
703
704 fn list(&self, filter: ShipmentFilter) -> Result<Vec<Shipment>>;
706
707 fn for_order(&self, order_id: OrderId) -> Result<Vec<Shipment>>;
709
710 fn delete(&self, id: ShipmentId) -> Result<()>;
712
713 fn mark_processing(&self, id: ShipmentId) -> Result<Shipment>;
716
717 fn mark_ready(&self, id: ShipmentId) -> Result<Shipment>;
719
720 fn ship(&self, id: ShipmentId, tracking_number: Option<String>) -> Result<Shipment>;
722
723 fn mark_in_transit(&self, id: ShipmentId) -> Result<Shipment>;
725
726 fn mark_out_for_delivery(&self, id: ShipmentId) -> Result<Shipment>;
728
729 fn mark_delivered(&self, id: ShipmentId) -> Result<Shipment>;
731
732 fn mark_failed(&self, id: ShipmentId) -> Result<Shipment>;
734
735 fn hold(&self, id: ShipmentId) -> Result<Shipment>;
737
738 fn cancel(&self, id: ShipmentId) -> Result<Shipment>;
740
741 fn add_item(&self, shipment_id: ShipmentId, item: CreateShipmentItem) -> Result<ShipmentItem>;
744
745 fn remove_item(&self, item_id: Uuid) -> Result<()>;
747
748 fn get_items(&self, shipment_id: ShipmentId) -> Result<Vec<ShipmentItem>>;
750
751 fn add_event(&self, shipment_id: ShipmentId, event: AddShipmentEvent) -> Result<ShipmentEvent>;
754
755 fn get_events(&self, shipment_id: ShipmentId) -> Result<Vec<ShipmentEvent>>;
757
758 fn count(&self, filter: ShipmentFilter) -> Result<u64>;
760
761 fn create_batch(&self, inputs: Vec<CreateShipment>) -> Result<BatchResult<Shipment>>;
765
766 fn create_batch_atomic(&self, inputs: Vec<CreateShipment>) -> Result<Vec<Shipment>>;
768
769 fn update_batch(
771 &self,
772 updates: Vec<(ShipmentId, UpdateShipment)>,
773 ) -> Result<BatchResult<Shipment>>;
774
775 fn update_batch_atomic(
777 &self,
778 updates: Vec<(ShipmentId, UpdateShipment)>,
779 ) -> Result<Vec<Shipment>>;
780
781 fn delete_batch(&self, ids: Vec<ShipmentId>) -> Result<BatchResult<Uuid>>;
783
784 fn delete_batch_atomic(&self, ids: Vec<ShipmentId>) -> Result<()>;
786
787 fn get_batch(&self, ids: Vec<ShipmentId>) -> Result<Vec<Shipment>>;
789}
790
791#[auto_impl::auto_impl(&, Box, Arc)]
793pub trait PaymentRepository: Send + Sync {
794 fn create(&self, input: CreatePayment) -> Result<Payment>;
796
797 fn get(&self, id: PaymentId) -> Result<Option<Payment>>;
799
800 fn get_by_number(&self, payment_number: &str) -> Result<Option<Payment>>;
802
803 fn get_by_external_id(&self, external_id: &str) -> Result<Option<Payment>>;
805
806 fn update(&self, id: PaymentId, input: UpdatePayment) -> Result<Payment>;
808
809 fn list(&self, filter: PaymentFilter) -> Result<Vec<Payment>>;
811
812 fn for_order(&self, order_id: OrderId) -> Result<Vec<Payment>>;
814
815 fn for_invoice(&self, invoice_id: InvoiceId) -> Result<Vec<Payment>>;
817
818 fn mark_processing(&self, id: PaymentId) -> Result<Payment>;
821
822 fn mark_completed(&self, id: PaymentId) -> Result<Payment>;
824
825 fn mark_failed(&self, id: PaymentId, reason: &str, code: Option<&str>) -> Result<Payment>;
827
828 fn cancel(&self, id: PaymentId) -> Result<Payment>;
830
831 fn create_refund(&self, input: CreateRefund) -> Result<Refund>;
834
835 fn get_refund(&self, id: Uuid) -> Result<Option<Refund>>;
837
838 fn get_refunds(&self, payment_id: PaymentId) -> Result<Vec<Refund>>;
840
841 fn complete_refund(&self, id: Uuid) -> Result<Refund>;
843
844 fn fail_refund(&self, id: Uuid, reason: &str) -> Result<Refund>;
846
847 fn create_payment_method(&self, input: CreatePaymentMethod) -> Result<PaymentMethod>;
850
851 fn get_payment_methods(&self, customer_id: CustomerId) -> Result<Vec<PaymentMethod>>;
853
854 fn delete_payment_method(&self, id: Uuid) -> Result<()>;
856
857 fn set_default_payment_method(&self, customer_id: CustomerId, method_id: Uuid) -> Result<()>;
859
860 fn count(&self, filter: PaymentFilter) -> Result<u64>;
862
863 fn create_batch(&self, inputs: Vec<CreatePayment>) -> Result<BatchResult<Payment>>;
867
868 fn create_batch_atomic(&self, inputs: Vec<CreatePayment>) -> Result<Vec<Payment>>;
870
871 fn update_batch(
873 &self,
874 updates: Vec<(PaymentId, UpdatePayment)>,
875 ) -> Result<BatchResult<Payment>>;
876
877 fn update_batch_atomic(&self, updates: Vec<(PaymentId, UpdatePayment)>)
879 -> Result<Vec<Payment>>;
880
881 fn delete_batch(&self, ids: Vec<PaymentId>) -> Result<BatchResult<Uuid>>;
883
884 fn delete_batch_atomic(&self, ids: Vec<PaymentId>) -> Result<()>;
886
887 fn get_batch(&self, ids: Vec<PaymentId>) -> Result<Vec<Payment>>;
889}
890
891#[auto_impl::auto_impl(&, Box, Arc)]
893pub trait WarrantyRepository: Send + Sync {
894 fn create(&self, input: CreateWarranty) -> Result<Warranty>;
896
897 fn get(&self, id: WarrantyId) -> Result<Option<Warranty>>;
899
900 fn get_by_number(&self, warranty_number: &str) -> Result<Option<Warranty>>;
902
903 fn get_by_serial(&self, serial_number: &str) -> Result<Option<Warranty>>;
905
906 fn update(&self, id: WarrantyId, input: UpdateWarranty) -> Result<Warranty>;
908
909 fn list(&self, filter: WarrantyFilter) -> Result<Vec<Warranty>>;
911
912 fn for_customer(&self, customer_id: CustomerId) -> Result<Vec<Warranty>>;
914
915 fn for_order(&self, order_id: OrderId) -> Result<Vec<Warranty>>;
917
918 fn void(&self, id: WarrantyId) -> Result<Warranty>;
921
922 fn expire(&self, id: WarrantyId) -> Result<Warranty>;
924
925 fn transfer(&self, id: WarrantyId, new_customer_id: CustomerId) -> Result<Warranty>;
927
928 fn create_claim(&self, input: CreateWarrantyClaim) -> Result<WarrantyClaim>;
931
932 fn get_claim(&self, id: Uuid) -> Result<Option<WarrantyClaim>>;
934
935 fn get_claim_by_number(&self, claim_number: &str) -> Result<Option<WarrantyClaim>>;
937
938 fn update_claim(&self, id: Uuid, input: UpdateWarrantyClaim) -> Result<WarrantyClaim>;
940
941 fn list_claims(&self, filter: WarrantyClaimFilter) -> Result<Vec<WarrantyClaim>>;
943
944 fn get_claims(&self, warranty_id: WarrantyId) -> Result<Vec<WarrantyClaim>>;
946
947 fn approve_claim(&self, id: Uuid) -> Result<WarrantyClaim>;
950
951 fn deny_claim(&self, id: Uuid, reason: &str) -> Result<WarrantyClaim>;
953
954 fn complete_claim(&self, id: Uuid, resolution: ClaimResolution) -> Result<WarrantyClaim>;
956
957 fn cancel_claim(&self, id: Uuid) -> Result<WarrantyClaim>;
959
960 fn count(&self, filter: WarrantyFilter) -> Result<u64>;
962
963 fn count_claims(&self, filter: WarrantyClaimFilter) -> Result<u64>;
965
966 fn create_batch(&self, inputs: Vec<CreateWarranty>) -> Result<BatchResult<Warranty>>;
970
971 fn create_batch_atomic(&self, inputs: Vec<CreateWarranty>) -> Result<Vec<Warranty>>;
973
974 fn update_batch(
976 &self,
977 updates: Vec<(WarrantyId, UpdateWarranty)>,
978 ) -> Result<BatchResult<Warranty>>;
979
980 fn update_batch_atomic(
982 &self,
983 updates: Vec<(WarrantyId, UpdateWarranty)>,
984 ) -> Result<Vec<Warranty>>;
985
986 fn delete_batch(&self, ids: Vec<WarrantyId>) -> Result<BatchResult<Uuid>>;
988
989 fn delete_batch_atomic(&self, ids: Vec<WarrantyId>) -> Result<()>;
991
992 fn get_batch(&self, ids: Vec<WarrantyId>) -> Result<Vec<Warranty>>;
994}
995
996#[auto_impl::auto_impl(&, Box, Arc)]
998pub trait PurchaseOrderRepository: Send + Sync {
999 fn create_supplier(&self, input: CreateSupplier) -> Result<Supplier>;
1002
1003 fn get_supplier(&self, id: Uuid) -> Result<Option<Supplier>>;
1005
1006 fn get_supplier_by_code(&self, code: &str) -> Result<Option<Supplier>>;
1008
1009 fn update_supplier(&self, id: Uuid, input: UpdateSupplier) -> Result<Supplier>;
1011
1012 fn list_suppliers(&self, filter: SupplierFilter) -> Result<Vec<Supplier>>;
1014
1015 fn delete_supplier(&self, id: Uuid) -> Result<()>;
1017
1018 fn create(&self, input: CreatePurchaseOrder) -> Result<PurchaseOrder>;
1021
1022 fn get(&self, id: PurchaseOrderId) -> Result<Option<PurchaseOrder>>;
1024
1025 fn get_by_number(&self, po_number: &str) -> Result<Option<PurchaseOrder>>;
1027
1028 fn update(&self, id: PurchaseOrderId, input: UpdatePurchaseOrder) -> Result<PurchaseOrder>;
1030
1031 fn list(&self, filter: PurchaseOrderFilter) -> Result<Vec<PurchaseOrder>>;
1033
1034 fn for_supplier(&self, supplier_id: Uuid) -> Result<Vec<PurchaseOrder>>;
1036
1037 fn delete(&self, id: PurchaseOrderId) -> Result<()>;
1039
1040 fn submit_for_approval(&self, id: PurchaseOrderId) -> Result<PurchaseOrder>;
1043
1044 fn approve(&self, id: PurchaseOrderId, approved_by: &str) -> Result<PurchaseOrder>;
1046
1047 fn send(&self, id: PurchaseOrderId) -> Result<PurchaseOrder>;
1049
1050 fn acknowledge(
1052 &self,
1053 id: PurchaseOrderId,
1054 supplier_reference: Option<&str>,
1055 ) -> Result<PurchaseOrder>;
1056
1057 fn hold(&self, id: PurchaseOrderId) -> Result<PurchaseOrder>;
1059
1060 fn cancel(&self, id: PurchaseOrderId) -> Result<PurchaseOrder>;
1062
1063 fn receive(
1065 &self,
1066 id: PurchaseOrderId,
1067 items: ReceivePurchaseOrderItems,
1068 ) -> Result<PurchaseOrder>;
1069
1070 fn complete(&self, id: PurchaseOrderId) -> Result<PurchaseOrder>;
1072
1073 fn add_item(
1076 &self,
1077 po_id: PurchaseOrderId,
1078 item: CreatePurchaseOrderItem,
1079 ) -> Result<PurchaseOrderItem>;
1080
1081 fn update_item(
1083 &self,
1084 item_id: Uuid,
1085 item: CreatePurchaseOrderItem,
1086 ) -> Result<PurchaseOrderItem>;
1087
1088 fn remove_item(&self, item_id: Uuid) -> Result<()>;
1090
1091 fn get_items(&self, po_id: PurchaseOrderId) -> Result<Vec<PurchaseOrderItem>>;
1093
1094 fn count(&self, filter: PurchaseOrderFilter) -> Result<u64>;
1096
1097 fn count_suppliers(&self, filter: SupplierFilter) -> Result<u64>;
1099
1100 fn create_batch(&self, inputs: Vec<CreatePurchaseOrder>) -> Result<BatchResult<PurchaseOrder>>;
1104
1105 fn create_batch_atomic(&self, inputs: Vec<CreatePurchaseOrder>) -> Result<Vec<PurchaseOrder>>;
1107
1108 fn update_batch(
1110 &self,
1111 updates: Vec<(PurchaseOrderId, UpdatePurchaseOrder)>,
1112 ) -> Result<BatchResult<PurchaseOrder>>;
1113
1114 fn update_batch_atomic(
1116 &self,
1117 updates: Vec<(PurchaseOrderId, UpdatePurchaseOrder)>,
1118 ) -> Result<Vec<PurchaseOrder>>;
1119
1120 fn delete_batch(&self, ids: Vec<PurchaseOrderId>) -> Result<BatchResult<PurchaseOrderId>>;
1122
1123 fn delete_batch_atomic(&self, ids: Vec<PurchaseOrderId>) -> Result<()>;
1125
1126 fn get_batch(&self, ids: Vec<PurchaseOrderId>) -> Result<Vec<PurchaseOrder>>;
1128}
1129
1130#[auto_impl::auto_impl(&, Box, Arc)]
1132pub trait InvoiceRepository: Send + Sync {
1133 fn create(&self, input: CreateInvoice) -> Result<Invoice>;
1135
1136 fn get(&self, id: InvoiceId) -> Result<Option<Invoice>>;
1138
1139 fn get_by_number(&self, invoice_number: &str) -> Result<Option<Invoice>>;
1141
1142 fn update(&self, id: InvoiceId, input: UpdateInvoice) -> Result<Invoice>;
1144
1145 fn list(&self, filter: InvoiceFilter) -> Result<Vec<Invoice>>;
1147
1148 fn for_customer(&self, customer_id: CustomerId) -> Result<Vec<Invoice>>;
1150
1151 fn for_order(&self, order_id: OrderId) -> Result<Vec<Invoice>>;
1153
1154 fn delete(&self, id: InvoiceId) -> Result<()>;
1156
1157 fn send(&self, id: InvoiceId) -> Result<Invoice>;
1160
1161 fn mark_viewed(&self, id: InvoiceId) -> Result<Invoice>;
1163
1164 fn record_payment(&self, id: InvoiceId, payment: RecordInvoicePayment) -> Result<Invoice>;
1166
1167 fn void(&self, id: InvoiceId) -> Result<Invoice>;
1169
1170 fn write_off(&self, id: InvoiceId) -> Result<Invoice>;
1172
1173 fn dispute(&self, id: InvoiceId) -> Result<Invoice>;
1175
1176 fn add_item(&self, invoice_id: InvoiceId, item: CreateInvoiceItem) -> Result<InvoiceItem>;
1179
1180 fn update_item(&self, item_id: Uuid, item: CreateInvoiceItem) -> Result<InvoiceItem>;
1182
1183 fn remove_item(&self, item_id: Uuid) -> Result<()>;
1185
1186 fn get_items(&self, invoice_id: InvoiceId) -> Result<Vec<InvoiceItem>>;
1188
1189 fn recalculate(&self, id: InvoiceId) -> Result<Invoice>;
1191
1192 fn get_overdue(&self) -> Result<Vec<Invoice>>;
1194
1195 fn count(&self, filter: InvoiceFilter) -> Result<u64>;
1197
1198 fn create_batch(&self, inputs: Vec<CreateInvoice>) -> Result<BatchResult<Invoice>>;
1202
1203 fn create_batch_atomic(&self, inputs: Vec<CreateInvoice>) -> Result<Vec<Invoice>>;
1205
1206 fn update_batch(
1208 &self,
1209 updates: Vec<(InvoiceId, UpdateInvoice)>,
1210 ) -> Result<BatchResult<Invoice>>;
1211
1212 fn update_batch_atomic(&self, updates: Vec<(InvoiceId, UpdateInvoice)>)
1214 -> Result<Vec<Invoice>>;
1215
1216 fn delete_batch(&self, ids: Vec<InvoiceId>) -> Result<BatchResult<Uuid>>;
1218
1219 fn delete_batch_atomic(&self, ids: Vec<InvoiceId>) -> Result<()>;
1221
1222 fn get_batch(&self, ids: Vec<InvoiceId>) -> Result<Vec<Invoice>>;
1224}
1225
1226#[auto_impl::auto_impl(&, Box, Arc)]
1228pub trait CartRepository: Send + Sync {
1229 fn create(&self, input: CreateCart) -> Result<Cart>;
1231
1232 fn get(&self, id: CartId) -> Result<Option<Cart>>;
1234
1235 fn get_by_number(&self, cart_number: &str) -> Result<Option<Cart>>;
1237
1238 fn update(&self, id: CartId, input: UpdateCart) -> Result<Cart>;
1240
1241 fn list(&self, filter: CartFilter) -> Result<Vec<Cart>>;
1243
1244 fn for_customer(&self, customer_id: CustomerId) -> Result<Vec<Cart>>;
1246
1247 fn delete(&self, id: CartId) -> Result<()>;
1249
1250 fn add_item(&self, cart_id: CartId, item: AddCartItem) -> Result<CartItem>;
1253
1254 fn update_item(&self, item_id: Uuid, input: UpdateCartItem) -> Result<CartItem>;
1256
1257 fn remove_item(&self, item_id: Uuid) -> Result<()>;
1259
1260 fn get_items(&self, cart_id: CartId) -> Result<Vec<CartItem>>;
1262
1263 fn clear_items(&self, cart_id: CartId) -> Result<()>;
1265
1266 fn set_shipping_address(&self, id: CartId, address: CartAddress) -> Result<Cart>;
1269
1270 fn set_billing_address(&self, id: CartId, address: CartAddress) -> Result<Cart>;
1272
1273 fn set_shipping(&self, id: CartId, shipping: SetCartShipping) -> Result<Cart>;
1276
1277 fn get_shipping_rates(&self, id: CartId) -> Result<Vec<ShippingRate>>;
1279
1280 fn set_payment(&self, id: CartId, payment: SetCartPayment) -> Result<Cart>;
1283
1284 fn set_x402_payment(&self, id: CartId, payment: SetCartX402Payment) -> Result<Cart>;
1286
1287 fn complete_with_x402(&self, id: CartId, payee_address: &str) -> Result<X402CheckoutResult>;
1291
1292 fn apply_discount(&self, id: CartId, coupon_code: &str) -> Result<Cart>;
1295
1296 fn remove_discount(&self, id: CartId) -> Result<Cart>;
1298
1299 fn mark_ready_for_payment(&self, id: CartId) -> Result<Cart>;
1302
1303 fn begin_checkout(&self, id: CartId) -> Result<Cart>;
1305
1306 fn complete(&self, id: CartId) -> Result<CheckoutResult>;
1313
1314 fn complete_settled_externally(&self, id: CartId) -> Result<CheckoutResult>;
1318
1319 fn cancel(&self, id: CartId) -> Result<Cart>;
1321
1322 fn abandon(&self, id: CartId) -> Result<Cart>;
1324
1325 fn expire(&self, id: CartId) -> Result<Cart>;
1327
1328 fn reserve_inventory(&self, id: CartId) -> Result<Cart>;
1331
1332 fn release_inventory(&self, id: CartId) -> Result<Cart>;
1334
1335 fn recalculate(&self, id: CartId) -> Result<Cart>;
1338
1339 fn set_tax(&self, id: CartId, tax_amount: rust_decimal::Decimal) -> Result<Cart>;
1341
1342 fn get_abandoned(&self) -> Result<Vec<Cart>>;
1345
1346 fn get_expired(&self) -> Result<Vec<Cart>>;
1348
1349 fn count(&self, filter: CartFilter) -> Result<u64>;
1351
1352 fn create_batch(&self, inputs: Vec<CreateCart>) -> Result<BatchResult<Cart>>;
1356
1357 fn create_batch_atomic(&self, inputs: Vec<CreateCart>) -> Result<Vec<Cart>>;
1359
1360 fn update_batch(&self, updates: Vec<(CartId, UpdateCart)>) -> Result<BatchResult<Cart>>;
1362
1363 fn update_batch_atomic(&self, updates: Vec<(CartId, UpdateCart)>) -> Result<Vec<Cart>>;
1365
1366 fn delete_batch(&self, ids: Vec<CartId>) -> Result<BatchResult<CartId>>;
1368
1369 fn delete_batch_atomic(&self, ids: Vec<CartId>) -> Result<()>;
1371
1372 fn get_batch(&self, ids: Vec<CartId>) -> Result<Vec<Cart>>;
1374}
1375
1376#[auto_impl::auto_impl(&, Box, Arc)]
1378pub trait AnalyticsRepository: Send + Sync {
1379 fn get_sales_summary(&self, query: AnalyticsQuery) -> Result<SalesSummary>;
1382
1383 fn get_revenue_by_period(&self, query: AnalyticsQuery) -> Result<Vec<RevenueByPeriod>>;
1385
1386 fn get_top_products(&self, query: AnalyticsQuery) -> Result<Vec<TopProduct>>;
1388
1389 fn get_product_performance(&self, query: AnalyticsQuery) -> Result<Vec<ProductPerformance>>;
1391
1392 fn get_customer_metrics(&self, query: AnalyticsQuery) -> Result<CustomerMetrics>;
1395
1396 fn get_top_customers(&self, query: AnalyticsQuery) -> Result<Vec<TopCustomer>>;
1398
1399 fn get_inventory_health(&self) -> Result<InventoryHealth>;
1402
1403 fn get_low_stock_items(
1405 &self,
1406 threshold: Option<rust_decimal::Decimal>,
1407 ) -> Result<Vec<LowStockItem>>;
1408
1409 fn get_inventory_movement(&self, query: AnalyticsQuery) -> Result<Vec<InventoryMovement>>;
1411
1412 fn get_order_status_breakdown(&self, query: AnalyticsQuery) -> Result<OrderStatusBreakdown>;
1415
1416 fn get_fulfillment_metrics(&self, query: AnalyticsQuery) -> Result<FulfillmentMetrics>;
1418
1419 fn get_return_metrics(&self, query: AnalyticsQuery) -> Result<ReturnMetrics>;
1422
1423 fn get_demand_forecast(
1426 &self,
1427 skus: Option<Vec<String>>,
1428 days_ahead: u32,
1429 ) -> Result<Vec<DemandForecast>>;
1430
1431 fn get_revenue_forecast(
1433 &self,
1434 periods_ahead: u32,
1435 granularity: TimeGranularity,
1436 ) -> Result<Vec<RevenueForecast>>;
1437
1438 fn get_sales_summary_batch(&self, queries: Vec<AnalyticsQuery>) -> Result<Vec<SalesSummary>>;
1442}
1443
1444#[auto_impl::auto_impl(&, Box, Arc)]
1446pub trait CurrencyRepository: Send + Sync {
1447 fn get_rate(&self, from: Currency, to: Currency) -> Result<Option<ExchangeRate>>;
1449
1450 fn get_rates_for(&self, base: Currency) -> Result<Vec<ExchangeRate>>;
1452
1453 fn list_rates(&self, filter: ExchangeRateFilter) -> Result<Vec<ExchangeRate>>;
1455
1456 fn set_rate(&self, input: SetExchangeRate) -> Result<ExchangeRate>;
1458
1459 fn set_rates(&self, rates: Vec<SetExchangeRate>) -> Result<Vec<ExchangeRate>>;
1461
1462 fn delete_rate(&self, id: Uuid) -> Result<()>;
1464
1465 fn convert(&self, input: ConvertCurrency) -> Result<ConversionResult>;
1467
1468 fn get_settings(&self) -> Result<StoreCurrencySettings>;
1470
1471 fn update_settings(&self, settings: StoreCurrencySettings) -> Result<StoreCurrencySettings>;
1473
1474 fn set_rates_atomic(&self, rates: Vec<SetExchangeRate>) -> Result<Vec<ExchangeRate>>;
1479
1480 fn delete_rates_batch(&self, ids: Vec<Uuid>) -> Result<BatchResult<Uuid>>;
1482
1483 fn delete_rates_atomic(&self, ids: Vec<Uuid>) -> Result<()>;
1485
1486 fn get_rates_batch(&self, pairs: Vec<(Currency, Currency)>) -> Result<Vec<ExchangeRate>>;
1488}
1489
1490#[auto_impl::auto_impl(&, Box, Arc)]
1492pub trait TaxRepository: Send + Sync {
1493 fn create_jurisdiction(&self, input: CreateTaxJurisdiction) -> Result<TaxJurisdiction>;
1495 fn get_jurisdiction(&self, id: Uuid) -> Result<Option<TaxJurisdiction>>;
1497 fn get_jurisdiction_by_code(&self, code: &str) -> Result<Option<TaxJurisdiction>>;
1499 fn list_jurisdictions(&self, filter: TaxJurisdictionFilter) -> Result<Vec<TaxJurisdiction>>;
1501
1502 fn create_rate(&self, input: CreateTaxRate) -> Result<TaxRate>;
1504 fn get_rate(&self, id: Uuid) -> Result<Option<TaxRate>>;
1506 fn list_rates(&self, filter: TaxRateFilter) -> Result<Vec<TaxRate>>;
1508 fn get_rates_for_address(
1510 &self,
1511 address: &TaxAddress,
1512 category: ProductTaxCategory,
1513 date: chrono::NaiveDate,
1514 ) -> Result<Vec<TaxRate>>;
1515
1516 fn create_exemption(&self, input: CreateTaxExemption) -> Result<TaxExemption>;
1518 fn get_exemption(&self, id: Uuid) -> Result<Option<TaxExemption>>;
1520 fn get_customer_exemptions(&self, customer_id: Uuid) -> Result<Vec<TaxExemption>>;
1522
1523 fn get_settings(&self) -> Result<TaxSettings>;
1525 fn update_settings(&self, settings: TaxSettings) -> Result<TaxSettings>;
1527
1528 fn calculate_tax(&self, request: TaxCalculationRequest) -> Result<TaxCalculationResult>;
1530 fn save_calculation(
1532 &self,
1533 result: &TaxCalculationResult,
1534 order_id: Option<Uuid>,
1535 cart_id: Option<Uuid>,
1536 customer_id: Option<Uuid>,
1537 address: &TaxAddress,
1538 currency: &str,
1539 ) -> Result<()>;
1540}
1541
1542#[auto_impl::auto_impl(&, Box, Arc)]
1544pub trait PromotionRepository: Send + Sync {
1545 fn create(&self, input: CreatePromotion) -> Result<Promotion>;
1547 fn get(&self, id: PromotionId) -> Result<Option<Promotion>>;
1549 fn get_by_code(&self, code: &str) -> Result<Option<Promotion>>;
1551 fn list(&self, filter: PromotionFilter) -> Result<Vec<Promotion>>;
1553 fn update(&self, id: PromotionId, input: UpdatePromotion) -> Result<Promotion>;
1555 fn delete(&self, id: PromotionId) -> Result<()>;
1557 fn activate(&self, id: PromotionId) -> Result<Promotion>;
1559 fn deactivate(&self, id: PromotionId) -> Result<Promotion>;
1561
1562 fn create_coupon(&self, input: CreateCouponCode) -> Result<CouponCode>;
1564 fn get_coupon(&self, id: Uuid) -> Result<Option<CouponCode>>;
1566 fn get_coupon_by_code(&self, code: &str) -> Result<Option<CouponCode>>;
1568 fn list_coupons(&self, filter: CouponFilter) -> Result<Vec<CouponCode>>;
1570
1571 fn apply_promotions(&self, request: ApplyPromotionsRequest) -> Result<ApplyPromotionsResult>;
1573 #[allow(clippy::too_many_arguments)]
1575 fn record_usage(
1576 &self,
1577 promotion_id: PromotionId,
1578 coupon_id: Option<Uuid>,
1579 customer_id: Option<CustomerId>,
1580 order_id: Option<OrderId>,
1581 cart_id: Option<CartId>,
1582 discount_amount: rust_decimal::Decimal,
1583 currency: &str,
1584 ) -> Result<PromotionUsage>;
1585}
1586
1587#[auto_impl::auto_impl(&, Box, Arc)]
1589pub trait SubscriptionRepository: Send + Sync {
1590 fn create_plan(&self, input: CreateSubscriptionPlan) -> Result<SubscriptionPlan>;
1592 fn get_plan(&self, id: Uuid) -> Result<Option<SubscriptionPlan>>;
1594 fn get_plan_by_code(&self, code: &str) -> Result<Option<SubscriptionPlan>>;
1596 fn list_plans(&self, filter: SubscriptionPlanFilter) -> Result<Vec<SubscriptionPlan>>;
1598 fn update_plan(&self, id: Uuid, input: UpdateSubscriptionPlan) -> Result<SubscriptionPlan>;
1600 fn activate_plan(&self, id: Uuid) -> Result<SubscriptionPlan>;
1602 fn archive_plan(&self, id: Uuid) -> Result<SubscriptionPlan>;
1604
1605 fn create_subscription(&self, input: CreateSubscription) -> Result<Subscription>;
1607 fn get_subscription(&self, id: SubscriptionId) -> Result<Option<Subscription>>;
1609 fn get_subscription_by_number(&self, number: &str) -> Result<Option<Subscription>>;
1611 fn list_subscriptions(&self, filter: SubscriptionFilter) -> Result<Vec<Subscription>>;
1613 fn update_subscription(
1615 &self,
1616 id: SubscriptionId,
1617 input: UpdateSubscription,
1618 ) -> Result<Subscription>;
1619 fn cancel_subscription(
1621 &self,
1622 id: SubscriptionId,
1623 input: CancelSubscription,
1624 ) -> Result<Subscription>;
1625 fn pause_subscription(
1627 &self,
1628 id: SubscriptionId,
1629 input: PauseSubscription,
1630 ) -> Result<Subscription>;
1631 fn resume_subscription(&self, id: SubscriptionId) -> Result<Subscription>;
1633
1634 fn create_billing_cycle(&self, input: CreateBillingCycle) -> Result<BillingCycle>;
1636 fn get_billing_cycle(&self, id: Uuid) -> Result<Option<BillingCycle>>;
1638 fn list_billing_cycles(&self, filter: BillingCycleFilter) -> Result<Vec<BillingCycle>>;
1640 fn update_billing_cycle_status(
1642 &self,
1643 id: Uuid,
1644 status: BillingCycleStatus,
1645 ) -> Result<BillingCycle>;
1646 fn skip_billing_cycle(
1648 &self,
1649 id: SubscriptionId,
1650 input: SkipBillingCycle,
1651 ) -> Result<Subscription>;
1652
1653 fn record_event(
1655 &self,
1656 subscription_id: SubscriptionId,
1657 event_type: SubscriptionEventType,
1658 notes: Option<String>,
1659 ) -> Result<SubscriptionEvent>;
1660 fn get_subscription_events(
1662 &self,
1663 subscription_id: SubscriptionId,
1664 ) -> Result<Vec<SubscriptionEvent>>;
1665}
1666
1667#[auto_impl::auto_impl(&, Box, Arc)]
1676pub trait QualityRepository: Send + Sync {
1677 fn create_inspection(&self, input: CreateInspection) -> Result<Inspection>;
1680
1681 fn get_inspection(&self, id: Uuid) -> Result<Option<Inspection>>;
1683
1684 fn get_inspection_by_number(&self, number: &str) -> Result<Option<Inspection>>;
1686
1687 fn update_inspection(&self, id: Uuid, input: UpdateInspection) -> Result<Inspection>;
1689
1690 fn list_inspections(&self, filter: InspectionFilter) -> Result<Vec<Inspection>>;
1692
1693 fn delete_inspection(&self, id: Uuid) -> Result<()>;
1695
1696 fn start_inspection(&self, id: Uuid) -> Result<Inspection>;
1698
1699 fn complete_inspection(&self, id: Uuid) -> Result<Inspection>;
1701
1702 fn record_inspection_result(&self, input: RecordInspectionResult) -> Result<InspectionItem>;
1704
1705 fn get_inspection_items(&self, inspection_id: Uuid) -> Result<Vec<InspectionItem>>;
1707
1708 fn count_inspections(&self, filter: InspectionFilter) -> Result<u64>;
1710
1711 fn create_ncr(&self, input: CreateNonConformance) -> Result<NonConformance>;
1714
1715 fn get_ncr(&self, id: Uuid) -> Result<Option<NonConformance>>;
1717
1718 fn get_ncr_by_number(&self, number: &str) -> Result<Option<NonConformance>>;
1720
1721 fn update_ncr(&self, id: Uuid, input: UpdateNonConformance) -> Result<NonConformance>;
1723
1724 fn list_ncrs(&self, filter: NonConformanceFilter) -> Result<Vec<NonConformance>>;
1726
1727 fn close_ncr(&self, id: Uuid) -> Result<NonConformance>;
1729
1730 fn cancel_ncr(&self, id: Uuid) -> Result<NonConformance>;
1732
1733 fn count_ncrs(&self, filter: NonConformanceFilter) -> Result<u64>;
1735
1736 fn create_hold(&self, input: CreateQualityHold) -> Result<QualityHold>;
1739
1740 fn get_hold(&self, id: Uuid) -> Result<Option<QualityHold>>;
1742
1743 fn list_holds(&self, filter: QualityHoldFilter) -> Result<Vec<QualityHold>>;
1745
1746 fn release_hold(&self, id: Uuid, input: ReleaseQualityHold) -> Result<QualityHold>;
1748
1749 fn get_active_holds_for_sku(&self, sku: &str) -> Result<Vec<QualityHold>>;
1751
1752 fn get_active_holds_for_lot(&self, lot_number: &str) -> Result<Vec<QualityHold>>;
1754
1755 fn count_active_holds(&self) -> Result<u64>;
1757
1758 fn create_defect_code(&self, input: CreateDefectCode) -> Result<DefectCode>;
1761
1762 fn get_defect_code(&self, code: &str) -> Result<Option<DefectCode>>;
1764
1765 fn list_defect_codes(&self, category: Option<&str>) -> Result<Vec<DefectCode>>;
1767
1768 fn deactivate_defect_code(&self, id: Uuid) -> Result<()>;
1770}
1771
1772#[auto_impl::auto_impl(&, Box, Arc)]
1778pub trait LotRepository: Send + Sync {
1779 fn create(&self, input: CreateLot) -> Result<Lot>;
1781
1782 fn get(&self, id: Uuid) -> Result<Option<Lot>>;
1784
1785 fn get_by_number(&self, lot_number: &str) -> Result<Option<Lot>>;
1787
1788 fn update(&self, id: Uuid, input: UpdateLot) -> Result<Lot>;
1790
1791 fn list(&self, filter: LotFilter) -> Result<Vec<Lot>>;
1793
1794 fn delete(&self, id: Uuid) -> Result<()>;
1796
1797 fn adjust(&self, input: AdjustLot) -> Result<LotTransaction>;
1799
1800 fn consume(&self, input: ConsumeLot) -> Result<LotTransaction>;
1802
1803 fn reserve(&self, input: ReserveLot) -> Result<Uuid>;
1805
1806 fn release_reservation(&self, reservation_id: Uuid) -> Result<()>;
1808
1809 fn confirm_reservation(&self, reservation_id: Uuid) -> Result<LotTransaction>;
1811
1812 fn transfer(&self, input: TransferLot) -> Result<LotTransaction>;
1814
1815 fn split(&self, input: SplitLot) -> Result<Lot>;
1817
1818 fn merge(&self, input: MergeLots) -> Result<Lot>;
1820
1821 fn quarantine(&self, id: Uuid, reason: &str) -> Result<Lot>;
1823
1824 fn release_quarantine(&self, id: Uuid) -> Result<Lot>;
1826
1827 fn get_transactions(&self, lot_id: Uuid, limit: u32) -> Result<Vec<LotTransaction>>;
1829
1830 fn get_quantity_at_location(
1832 &self,
1833 lot_id: Uuid,
1834 location_id: i32,
1835 ) -> Result<Option<rust_decimal::Decimal>>;
1836
1837 fn get_lot_locations(&self, lot_id: Uuid) -> Result<Vec<LotLocation>>;
1839
1840 fn add_certificate(&self, input: AddLotCertificate) -> Result<LotCertificate>;
1843
1844 fn get_certificates(&self, lot_id: Uuid) -> Result<Vec<LotCertificate>>;
1846
1847 fn delete_certificate(&self, certificate_id: Uuid) -> Result<()>;
1849
1850 fn get_expiring_lots(&self, days: i32) -> Result<Vec<Lot>>;
1853
1854 fn get_expired_lots(&self) -> Result<Vec<Lot>>;
1856
1857 fn get_available_lots_for_sku(&self, sku: &str) -> Result<Vec<Lot>>;
1859
1860 fn trace(&self, lot_id: Uuid) -> Result<TraceabilityResult>;
1862
1863 fn count(&self, filter: LotFilter) -> Result<u64>;
1865
1866 fn create_batch(&self, inputs: Vec<CreateLot>) -> Result<BatchResult<Lot>>;
1869
1870 fn get_batch(&self, ids: Vec<Uuid>) -> Result<Vec<Lot>>;
1872}
1873
1874#[auto_impl::auto_impl(&, Box, Arc)]
1880pub trait SerialRepository: Send + Sync {
1881 fn create(&self, input: CreateSerialNumber) -> Result<SerialNumber>;
1883
1884 fn create_bulk(&self, input: CreateSerialNumbersBulk) -> Result<Vec<SerialNumber>>;
1886
1887 fn get(&self, id: Uuid) -> Result<Option<SerialNumber>>;
1889
1890 fn get_by_serial(&self, serial: &str) -> Result<Option<SerialNumber>>;
1892
1893 fn update(&self, id: Uuid, input: UpdateSerialNumber) -> Result<SerialNumber>;
1895
1896 fn list(&self, filter: SerialFilter) -> Result<Vec<SerialNumber>>;
1898
1899 fn delete(&self, id: Uuid) -> Result<()>;
1901
1902 fn change_status(&self, input: ChangeSerialStatus) -> Result<SerialNumber>;
1904
1905 fn reserve(&self, input: ReserveSerialNumber) -> Result<SerialReservation>;
1907
1908 fn release_reservation(&self, reservation_id: Uuid) -> Result<()>;
1910
1911 fn confirm_reservation(&self, reservation_id: Uuid) -> Result<()>;
1913
1914 fn move_serial(&self, input: MoveSerial) -> Result<SerialNumber>;
1916
1917 fn transfer_ownership(&self, input: TransferSerialOwnership) -> Result<SerialNumber>;
1919
1920 fn mark_sold(
1922 &self,
1923 id: Uuid,
1924 customer_id: Uuid,
1925 order_id: Option<Uuid>,
1926 ) -> Result<SerialNumber>;
1927
1928 fn mark_shipped(&self, id: Uuid, shipment_id: Uuid) -> Result<SerialNumber>;
1930
1931 fn mark_returned(&self, id: Uuid, return_id: Uuid) -> Result<SerialNumber>;
1933
1934 fn activate(&self, id: Uuid) -> Result<SerialNumber>;
1936
1937 fn quarantine(&self, id: Uuid, reason: &str) -> Result<SerialNumber>;
1939
1940 fn release_quarantine(&self, id: Uuid) -> Result<SerialNumber>;
1942
1943 fn scrap(&self, id: Uuid, reason: &str) -> Result<SerialNumber>;
1945
1946 fn get_history(
1949 &self,
1950 serial_id: Uuid,
1951 filter: SerialHistoryFilter,
1952 ) -> Result<Vec<SerialHistory>>;
1953
1954 fn lookup(&self, serial: &str) -> Result<Option<SerialLookupResult>>;
1956
1957 fn validate(&self, serial: &str) -> Result<SerialValidation>;
1959
1960 fn get_available_for_sku(&self, sku: &str, limit: u32) -> Result<Vec<SerialNumber>>;
1963
1964 fn get_for_lot(&self, lot_id: Uuid) -> Result<Vec<SerialNumber>>;
1966
1967 fn get_for_customer(&self, customer_id: Uuid) -> Result<Vec<SerialNumber>>;
1969
1970 fn count(&self, filter: SerialFilter) -> Result<u64>;
1972
1973 fn create_batch(&self, inputs: Vec<CreateSerialNumber>) -> Result<BatchResult<SerialNumber>>;
1976
1977 fn get_batch(&self, ids: Vec<Uuid>) -> Result<Vec<SerialNumber>>;
1979
1980 fn get_batch_by_serial(&self, serials: Vec<String>) -> Result<Vec<SerialNumber>>;
1982}
1983
1984#[auto_impl::auto_impl(&, Box, Arc)]
1990pub trait WarehouseRepository: Send + Sync {
1991 fn create_warehouse(&self, input: CreateWarehouse) -> Result<Warehouse>;
1994
1995 fn get_warehouse(&self, id: i32) -> Result<Option<Warehouse>>;
1997
1998 fn get_warehouse_by_code(&self, code: &str) -> Result<Option<Warehouse>>;
2000
2001 fn update_warehouse(&self, id: i32, input: UpdateWarehouse) -> Result<Warehouse>;
2003
2004 fn list_warehouses(&self, filter: WarehouseFilter) -> Result<Vec<Warehouse>>;
2006
2007 fn delete_warehouse(&self, id: i32) -> Result<()>;
2009
2010 fn count_warehouses(&self, filter: WarehouseFilter) -> Result<u64>;
2012
2013 fn create_zone(&self, input: CreateZone) -> Result<Zone>;
2016
2017 fn get_zone(&self, id: i32) -> Result<Option<Zone>>;
2019
2020 fn get_zones(&self, warehouse_id: i32) -> Result<Vec<Zone>>;
2022
2023 fn update_zone(&self, id: i32, input: UpdateZone) -> Result<Zone>;
2025
2026 fn delete_zone(&self, id: i32) -> Result<()>;
2028
2029 fn create_location(&self, input: CreateLocation) -> Result<Location>;
2032
2033 fn get_location(&self, id: i32) -> Result<Option<Location>>;
2035
2036 fn get_location_by_code(&self, warehouse_id: i32, code: &str) -> Result<Option<Location>>;
2038
2039 fn update_location(&self, id: i32, input: UpdateLocation) -> Result<Location>;
2041
2042 fn list_locations(&self, filter: LocationFilter) -> Result<Vec<Location>>;
2044
2045 fn delete_location(&self, id: i32) -> Result<()>;
2047
2048 fn count_locations(&self, filter: LocationFilter) -> Result<u64>;
2050
2051 fn get_locations_for_warehouse(&self, warehouse_id: i32) -> Result<Vec<Location>>;
2053
2054 fn get_pickable_locations(&self, warehouse_id: i32, sku: &str) -> Result<Vec<Location>>;
2056
2057 fn get_receivable_locations(&self, warehouse_id: i32) -> Result<Vec<Location>>;
2059
2060 fn get_location_inventory(&self, location_id: i32) -> Result<Vec<LocationInventory>>;
2063
2064 fn get_inventory_for_sku(&self, warehouse_id: i32, sku: &str)
2066 -> Result<Vec<LocationInventory>>;
2067
2068 fn adjust_inventory(&self, input: AdjustLocationInventory) -> Result<LocationInventory>;
2070
2071 fn move_inventory(&self, input: MoveInventory) -> Result<LocationMovement>;
2073
2074 fn list_location_inventory(
2076 &self,
2077 filter: LocationInventoryFilter,
2078 ) -> Result<Vec<LocationInventory>>;
2079
2080 fn get_movements(&self, filter: MovementFilter) -> Result<Vec<LocationMovement>>;
2083
2084 fn count_movements(&self, filter: MovementFilter) -> Result<u64>;
2086
2087 fn create_locations_batch(&self, inputs: Vec<CreateLocation>) -> Result<BatchResult<Location>>;
2090
2091 fn get_locations_batch(&self, ids: Vec<i32>) -> Result<Vec<Location>>;
2093
2094 fn create_cycle_count(&self, input: CreateCycleCount) -> Result<CycleCount>;
2097
2098 fn get_cycle_count(&self, id: Uuid) -> Result<Option<CycleCount>>;
2100
2101 fn list_cycle_counts(&self, filter: CycleCountFilter) -> Result<Vec<CycleCount>>;
2103
2104 fn start_cycle_count(&self, id: Uuid) -> Result<CycleCount>;
2106
2107 fn record_cycle_counts(
2109 &self,
2110 id: Uuid,
2111 counts: Vec<RecordCycleCountLine>,
2112 ) -> Result<CycleCount>;
2113
2114 fn complete_cycle_count(&self, id: Uuid) -> Result<CycleCount>;
2117
2118 fn cancel_cycle_count(&self, id: Uuid) -> Result<CycleCount>;
2120}
2121
2122#[auto_impl::auto_impl(&, Box, Arc)]
2128pub trait ReceivingRepository: Send + Sync {
2129 fn create_receipt(&self, input: CreateReceipt) -> Result<Receipt>;
2132
2133 fn get_receipt(&self, id: Uuid) -> Result<Option<Receipt>>;
2135
2136 fn get_receipt_by_number(&self, number: &str) -> Result<Option<Receipt>>;
2138
2139 fn update_receipt(&self, id: Uuid, input: UpdateReceipt) -> Result<Receipt>;
2141
2142 fn list_receipts(&self, filter: ReceiptFilter) -> Result<Vec<Receipt>>;
2144
2145 fn delete_receipt(&self, id: Uuid) -> Result<()>;
2147
2148 fn start_receiving(&self, id: Uuid) -> Result<Receipt>;
2150
2151 fn receive_items(&self, input: ReceiveItems) -> Result<Receipt>;
2153
2154 fn complete_receiving(&self, id: Uuid) -> Result<Receipt>;
2156
2157 fn cancel_receipt(&self, id: Uuid) -> Result<Receipt>;
2159
2160 fn get_receipt_items(&self, receipt_id: Uuid) -> Result<Vec<ReceiptItem>>;
2162
2163 fn count_receipts(&self, filter: ReceiptFilter) -> Result<u64>;
2165
2166 fn create_put_away(&self, input: CreatePutAway) -> Result<PutAway>;
2169
2170 fn get_put_away(&self, id: Uuid) -> Result<Option<PutAway>>;
2172
2173 fn list_put_aways(&self, filter: PutAwayFilter) -> Result<Vec<PutAway>>;
2175
2176 fn assign_put_away(&self, id: Uuid, assigned_to: &str) -> Result<PutAway>;
2178
2179 fn start_put_away(&self, id: Uuid) -> Result<PutAway>;
2181
2182 fn complete_put_away(&self, input: CompletePutAway) -> Result<PutAway>;
2184
2185 fn cancel_put_away(&self, id: Uuid) -> Result<PutAway>;
2187
2188 fn get_pending_put_aways(&self, receipt_id: Uuid) -> Result<Vec<PutAway>>;
2190
2191 fn count_put_aways(&self, filter: PutAwayFilter) -> Result<u64>;
2193
2194 fn create_receipt_from_po(&self, po_id: Uuid, warehouse_id: i32) -> Result<Receipt>;
2197
2198 fn create_receipts_batch(&self, inputs: Vec<CreateReceipt>) -> Result<BatchResult<Receipt>>;
2201
2202 fn get_receipts_batch(&self, ids: Vec<Uuid>) -> Result<Vec<Receipt>>;
2204}
2205
2206#[auto_impl::auto_impl(&, Box, Arc)]
2212pub trait FulfillmentRepository: Send + Sync {
2213 fn create_wave(&self, input: CreateWave) -> Result<Wave>;
2216
2217 fn get_wave(&self, id: FulfillmentId) -> Result<Option<Wave>>;
2219
2220 fn get_wave_by_number(&self, number: &str) -> Result<Option<Wave>>;
2222
2223 fn list_waves(&self, filter: WaveFilter) -> Result<Vec<Wave>>;
2225
2226 fn release_wave(&self, id: FulfillmentId) -> Result<Wave>;
2228
2229 fn complete_wave(&self, id: FulfillmentId) -> Result<Wave>;
2231
2232 fn cancel_wave(&self, id: FulfillmentId) -> Result<Wave>;
2234
2235 fn get_wave_orders(&self, wave_id: FulfillmentId) -> Result<Vec<OrderId>>;
2237
2238 fn count_waves(&self, filter: WaveFilter) -> Result<u64>;
2240
2241 fn create_pick(&self, input: CreatePickTask) -> Result<PickTask>;
2244
2245 fn get_pick(&self, id: Uuid) -> Result<Option<PickTask>>;
2247
2248 fn list_picks(&self, filter: PickTaskFilter) -> Result<Vec<PickTask>>;
2250
2251 fn assign_pick(&self, id: Uuid, assigned_to: &str) -> Result<PickTask>;
2253
2254 fn start_pick(&self, id: Uuid) -> Result<PickTask>;
2256
2257 fn complete_pick(&self, input: CompletePick) -> Result<PickTask>;
2259
2260 fn report_short(
2262 &self,
2263 id: Uuid,
2264 short_qty: rust_decimal::Decimal,
2265 reason: &str,
2266 ) -> Result<PickTask>;
2267
2268 fn cancel_pick(&self, id: Uuid) -> Result<PickTask>;
2270
2271 fn get_picks_for_order(&self, order_id: OrderId) -> Result<Vec<PickTask>>;
2273
2274 fn get_picks_for_wave(&self, wave_id: FulfillmentId) -> Result<Vec<PickTask>>;
2276
2277 fn count_picks(&self, filter: PickTaskFilter) -> Result<u64>;
2279
2280 fn create_pack(&self, input: CreatePackTask) -> Result<PackTask>;
2283
2284 fn get_pack(&self, id: Uuid) -> Result<Option<PackTask>>;
2286
2287 fn list_packs(&self, filter: PackTaskFilter) -> Result<Vec<PackTask>>;
2289
2290 fn assign_pack(&self, id: Uuid, assigned_to: &str) -> Result<PackTask>;
2292
2293 fn start_pack(&self, id: Uuid) -> Result<PackTask>;
2295
2296 fn complete_pack(&self, id: Uuid) -> Result<PackTask>;
2298
2299 fn add_carton(&self, input: AddCarton) -> Result<Carton>;
2301
2302 fn add_carton_item(&self, input: AddCartonItem) -> Result<CartonItem>;
2304
2305 fn get_cartons(&self, pack_task_id: Uuid) -> Result<Vec<Carton>>;
2307
2308 fn get_carton_items(&self, carton_id: Uuid) -> Result<Vec<CartonItem>>;
2310
2311 fn mark_label_printed(&self, carton_id: Uuid) -> Result<Carton>;
2313
2314 fn cancel_pack(&self, id: Uuid) -> Result<PackTask>;
2316
2317 fn count_packs(&self, filter: PackTaskFilter) -> Result<u64>;
2319
2320 fn create_ship(&self, input: CreateShipTask) -> Result<ShipTask>;
2323
2324 fn get_ship(&self, id: Uuid) -> Result<Option<ShipTask>>;
2326
2327 fn list_ships(&self, filter: ShipTaskFilter) -> Result<Vec<ShipTask>>;
2329
2330 fn assign_ship(&self, id: Uuid, assigned_to: &str) -> Result<ShipTask>;
2332
2333 fn print_label(&self, id: Uuid, label_url: &str) -> Result<ShipTask>;
2335
2336 fn complete_ship(&self, input: CompleteShip) -> Result<ShipTask>;
2338
2339 fn cancel_ship(&self, id: Uuid) -> Result<ShipTask>;
2341
2342 fn count_ships(&self, filter: ShipTaskFilter) -> Result<u64>;
2344
2345 fn create_picks_for_order(&self, order_id: OrderId, warehouse_id: i32)
2348 -> Result<Vec<PickTask>>;
2349
2350 fn is_order_ready_to_pack(&self, order_id: OrderId) -> Result<bool>;
2352
2353 fn is_order_ready_to_ship(&self, order_id: OrderId) -> Result<bool>;
2355
2356 fn create_waves_batch(&self, inputs: Vec<CreateWave>) -> Result<BatchResult<Wave>>;
2359
2360 fn get_picks_batch(&self, ids: Vec<Uuid>) -> Result<Vec<PickTask>>;
2362}
2363
2364#[auto_impl::auto_impl(&, Box, Arc)]
2370pub trait AccountsPayableRepository: Send + Sync {
2371 fn create_bill(&self, input: CreateBill) -> Result<Bill>;
2374
2375 fn get_bill(&self, id: Uuid) -> Result<Option<Bill>>;
2377
2378 fn get_bill_by_number(&self, number: &str) -> Result<Option<Bill>>;
2380
2381 fn update_bill(&self, id: Uuid, input: UpdateBill) -> Result<Bill>;
2383
2384 fn list_bills(&self, filter: BillFilter) -> Result<Vec<Bill>>;
2386
2387 fn delete_bill(&self, id: Uuid) -> Result<()>;
2389
2390 fn approve_bill(&self, id: Uuid) -> Result<Bill>;
2392
2393 fn cancel_bill(&self, id: Uuid) -> Result<Bill>;
2395
2396 fn dispute_bill(&self, id: Uuid) -> Result<Bill>;
2398
2399 fn get_bill_items(&self, bill_id: Uuid) -> Result<Vec<BillItem>>;
2401
2402 fn add_bill_item(&self, bill_id: Uuid, item: CreateBillItem) -> Result<BillItem>;
2404
2405 fn remove_bill_item(&self, item_id: Uuid) -> Result<()>;
2407
2408 fn count_bills(&self, filter: BillFilter) -> Result<u64>;
2410
2411 fn get_overdue_bills(&self) -> Result<Vec<Bill>>;
2413
2414 fn get_bills_due_soon(&self, days: i32) -> Result<Vec<Bill>>;
2416
2417 fn create_payment(&self, input: CreateBillPayment) -> Result<BillPayment>;
2420
2421 fn get_payment(&self, id: Uuid) -> Result<Option<BillPayment>>;
2423
2424 fn get_payment_by_number(&self, number: &str) -> Result<Option<BillPayment>>;
2426
2427 fn list_payments(&self, filter: BillPaymentFilter) -> Result<Vec<BillPayment>>;
2429
2430 fn void_payment(&self, id: Uuid) -> Result<BillPayment>;
2432
2433 fn clear_payment(&self, id: Uuid) -> Result<BillPayment>;
2435
2436 fn get_payment_allocations(&self, payment_id: Uuid) -> Result<Vec<PaymentAllocation>>;
2438
2439 fn get_payments_for_bill(&self, bill_id: Uuid) -> Result<Vec<BillPayment>>;
2441
2442 fn count_payments(&self, filter: BillPaymentFilter) -> Result<u64>;
2444
2445 fn create_payment_run(&self, input: CreatePaymentRun) -> Result<PaymentRun>;
2448
2449 fn get_payment_run(&self, id: Uuid) -> Result<Option<PaymentRun>>;
2451
2452 fn list_payment_runs(&self, filter: PaymentRunFilter) -> Result<Vec<PaymentRun>>;
2454
2455 fn approve_payment_run(&self, id: Uuid, approved_by: &str) -> Result<PaymentRun>;
2457
2458 fn process_payment_run(&self, id: Uuid) -> Result<PaymentRun>;
2460
2461 fn cancel_payment_run(&self, id: Uuid) -> Result<PaymentRun>;
2463
2464 fn get_payment_run_bills(&self, run_id: Uuid) -> Result<Vec<Bill>>;
2466
2467 fn get_aging_summary(&self) -> Result<ApAgingSummary>;
2470
2471 fn get_supplier_summary(&self, supplier_id: Uuid) -> Result<Option<SupplierApSummary>>;
2473
2474 fn get_total_outstanding(&self) -> Result<rust_decimal::Decimal>;
2476
2477 fn create_bills_batch(&self, inputs: Vec<CreateBill>) -> Result<BatchResult<Bill>>;
2480
2481 fn get_bills_batch(&self, ids: Vec<Uuid>) -> Result<Vec<Bill>>;
2483}
2484
2485#[auto_impl::auto_impl(&, Box, Arc)]
2487pub trait CostAccountingRepository: Send + Sync {
2488 fn get_item_cost(&self, sku: &str) -> Result<Option<ItemCost>>;
2491
2492 fn set_item_cost(&self, input: SetItemCost) -> Result<ItemCost>;
2494
2495 fn list_item_costs(&self, filter: ItemCostFilter) -> Result<Vec<ItemCost>>;
2497
2498 fn update_average_cost(
2500 &self,
2501 sku: &str,
2502 quantity: rust_decimal::Decimal,
2503 unit_cost: rust_decimal::Decimal,
2504 ) -> Result<ItemCost>;
2505
2506 fn update_last_cost(&self, sku: &str, unit_cost: rust_decimal::Decimal) -> Result<ItemCost>;
2508
2509 fn create_cost_layer(&self, input: CreateCostLayer) -> Result<CostLayer>;
2512
2513 fn get_cost_layer(&self, id: Uuid) -> Result<Option<CostLayer>>;
2515
2516 fn list_cost_layers(&self, filter: CostLayerFilter) -> Result<Vec<CostLayer>>;
2518
2519 fn issue_fifo(&self, input: IssueCostLayers) -> Result<Vec<CostTransaction>>;
2521
2522 fn issue_lifo(&self, input: IssueCostLayers) -> Result<Vec<CostTransaction>>;
2524
2525 fn get_layers_remaining(&self, sku: &str) -> Result<rust_decimal::Decimal>;
2527
2528 #[allow(clippy::too_many_arguments)]
2531 fn record_cost_transaction(
2532 &self,
2533 sku: &str,
2534 transaction_type: CostTransactionType,
2535 quantity: rust_decimal::Decimal,
2536 unit_cost: rust_decimal::Decimal,
2537 layer_id: Option<Uuid>,
2538 reference_type: Option<&str>,
2539 reference_id: Option<Uuid>,
2540 notes: Option<&str>,
2541 ) -> Result<CostTransaction>;
2542
2543 fn list_cost_transactions(&self, filter: CostTransactionFilter)
2545 -> Result<Vec<CostTransaction>>;
2546
2547 fn record_variance(&self, input: RecordCostVariance) -> Result<CostVariance>;
2550
2551 fn list_variances(&self, filter: CostVarianceFilter) -> Result<Vec<CostVariance>>;
2553
2554 fn get_variance_summary(
2556 &self,
2557 from: DateTime<Utc>,
2558 to: DateTime<Utc>,
2559 ) -> Result<rust_decimal::Decimal>;
2560
2561 fn create_adjustment(&self, input: CreateCostAdjustment) -> Result<CostAdjustment>;
2564
2565 fn get_adjustment(&self, id: Uuid) -> Result<Option<CostAdjustment>>;
2567
2568 fn list_adjustments(&self, filter: CostAdjustmentFilter) -> Result<Vec<CostAdjustment>>;
2570
2571 fn approve_adjustment(&self, id: Uuid, approved_by: &str) -> Result<CostAdjustment>;
2573
2574 fn apply_adjustment(&self, id: Uuid) -> Result<CostAdjustment>;
2576
2577 fn reject_adjustment(&self, id: Uuid) -> Result<CostAdjustment>;
2579
2580 fn calculate_rollup(&self, sku: &str, bom_id: Option<Uuid>) -> Result<CostRollup>;
2583
2584 fn get_rollup(&self, sku: &str) -> Result<Option<CostRollup>>;
2586
2587 fn get_inventory_valuation(&self, cost_method: CostMethod) -> Result<InventoryValuation>;
2590
2591 fn get_sku_cost_summary(&self, sku: &str) -> Result<Option<SkuCostSummary>>;
2593
2594 fn get_total_inventory_value(&self) -> Result<rust_decimal::Decimal>;
2596}
2597
2598#[auto_impl::auto_impl(&, Box, Arc)]
2600pub trait CreditRepository: Send + Sync {
2601 fn create_credit_account(&self, input: CreateCreditAccount) -> Result<CreditAccount>;
2604
2605 fn get_credit_account(&self, id: CreditId) -> Result<Option<CreditAccount>>;
2607
2608 fn get_credit_account_by_customer(
2610 &self,
2611 customer_id: CustomerId,
2612 ) -> Result<Option<CreditAccount>>;
2613
2614 fn update_credit_account(
2616 &self,
2617 id: CreditId,
2618 input: UpdateCreditAccount,
2619 ) -> Result<CreditAccount>;
2620
2621 fn list_credit_accounts(&self, filter: CreditAccountFilter) -> Result<Vec<CreditAccount>>;
2623
2624 fn adjust_credit_limit(
2626 &self,
2627 customer_id: CustomerId,
2628 new_limit: rust_decimal::Decimal,
2629 reason: &str,
2630 ) -> Result<CreditAccount>;
2631
2632 fn suspend_credit_account(
2634 &self,
2635 customer_id: CustomerId,
2636 reason: &str,
2637 ) -> Result<CreditAccount>;
2638
2639 fn reactivate_credit_account(&self, customer_id: CustomerId) -> Result<CreditAccount>;
2641
2642 fn check_credit(
2645 &self,
2646 customer_id: CustomerId,
2647 order_amount: rust_decimal::Decimal,
2648 ) -> Result<CreditCheckResult>;
2649
2650 fn reserve_credit(
2652 &self,
2653 customer_id: CustomerId,
2654 order_id: OrderId,
2655 amount: rust_decimal::Decimal,
2656 ) -> Result<CreditAccount>;
2657
2658 fn release_credit_reservation(
2660 &self,
2661 customer_id: CustomerId,
2662 order_id: OrderId,
2663 ) -> Result<CreditAccount>;
2664
2665 fn charge_credit(
2667 &self,
2668 customer_id: CustomerId,
2669 order_id: OrderId,
2670 amount: rust_decimal::Decimal,
2671 ) -> Result<CreditAccount>;
2672
2673 fn place_hold(&self, input: PlaceCreditHold) -> Result<CreditHold>;
2676
2677 fn get_hold(&self, id: Uuid) -> Result<Option<CreditHold>>;
2679
2680 fn list_holds(&self, filter: CreditHoldFilter) -> Result<Vec<CreditHold>>;
2682
2683 fn release_hold(&self, input: ReleaseCreditHold) -> Result<CreditHold>;
2685
2686 fn get_active_holds(&self, customer_id: CustomerId) -> Result<Vec<CreditHold>>;
2688
2689 fn get_holds_for_order(&self, order_id: OrderId) -> Result<Vec<CreditHold>>;
2691
2692 fn submit_application(&self, input: SubmitCreditApplication) -> Result<CreditApplication>;
2695
2696 fn get_application(&self, id: Uuid) -> Result<Option<CreditApplication>>;
2698
2699 fn list_applications(&self, filter: CreditApplicationFilter) -> Result<Vec<CreditApplication>>;
2701
2702 fn review_application(&self, input: ReviewCreditApplication) -> Result<CreditApplication>;
2704
2705 fn withdraw_application(&self, id: Uuid) -> Result<CreditApplication>;
2707
2708 fn record_transaction(&self, input: RecordCreditTransaction) -> Result<CreditTransaction>;
2711
2712 fn list_transactions(&self, filter: CreditTransactionFilter) -> Result<Vec<CreditTransaction>>;
2714
2715 fn apply_payment(
2717 &self,
2718 customer_id: CustomerId,
2719 amount: rust_decimal::Decimal,
2720 reference_id: Option<Uuid>,
2721 ) -> Result<CreditAccount>;
2722
2723 fn get_customer_summary(
2726 &self,
2727 customer_id: CustomerId,
2728 ) -> Result<Option<CustomerCreditSummary>>;
2729
2730 fn get_aging_report(&self) -> Result<Vec<(CustomerId, CreditAgingBucket)>>;
2732
2733 fn get_over_limit_customers(&self) -> Result<Vec<CreditAccount>>;
2735}
2736
2737#[auto_impl::auto_impl(&, Box, Arc)]
2739pub trait BackorderRepository: Send + Sync {
2740 fn create_backorder(&self, input: CreateBackorder) -> Result<Backorder>;
2743
2744 fn get_backorder(&self, id: Uuid) -> Result<Option<Backorder>>;
2746
2747 fn get_backorder_by_number(&self, number: &str) -> Result<Option<Backorder>>;
2749
2750 fn update_backorder(&self, id: Uuid, input: UpdateBackorder) -> Result<Backorder>;
2752
2753 fn list_backorders(&self, filter: BackorderFilter) -> Result<Vec<Backorder>>;
2755
2756 fn cancel_backorder(&self, id: Uuid) -> Result<Backorder>;
2758
2759 fn get_backorders_for_order(&self, order_id: Uuid) -> Result<Vec<Backorder>>;
2761
2762 fn get_backorders_for_customer(&self, customer_id: Uuid) -> Result<Vec<Backorder>>;
2764
2765 fn get_backorders_for_sku(&self, sku: &str) -> Result<Vec<Backorder>>;
2767
2768 fn fulfill_backorder(&self, input: FulfillBackorder) -> Result<Backorder>;
2771
2772 fn get_fulfillment_history(&self, backorder_id: Uuid) -> Result<Vec<BackorderFulfillment>>;
2774
2775 fn allocate_backorder(&self, input: AllocateBackorder) -> Result<BackorderAllocation>;
2778
2779 fn get_allocations(&self, backorder_id: Uuid) -> Result<Vec<BackorderAllocation>>;
2781
2782 fn release_allocation(&self, allocation_id: Uuid) -> Result<BackorderAllocation>;
2784
2785 fn confirm_allocation(&self, allocation_id: Uuid) -> Result<BackorderAllocation>;
2787
2788 fn expire_allocations(&self) -> Result<u32>;
2790
2791 fn auto_allocate_inventory(&self, sku: &str) -> Result<Vec<BackorderAllocation>>;
2794
2795 fn get_summary(&self) -> Result<BackorderSummary>;
2798
2799 fn get_sku_summary(&self, sku: &str) -> Result<Option<SkuBackorderSummary>>;
2801
2802 fn get_overdue_backorders(&self) -> Result<Vec<Backorder>>;
2804
2805 fn count_pending(&self) -> Result<u64>;
2807}
2808
2809#[auto_impl::auto_impl(&, Box, Arc)]
2815pub trait AccountsReceivableRepository: Send + Sync {
2816 fn get_aging_summary(&self) -> Result<ArAgingSummary>;
2819
2820 fn get_customer_aging(&self, customer_id: Uuid) -> Result<Option<CustomerArAging>>;
2822
2823 fn get_aging_report(&self, filter: ArAgingFilter) -> Result<Vec<CustomerArAging>>;
2825
2826 fn log_collection_activity(
2829 &self,
2830 input: CreateCollectionActivity,
2831 ) -> Result<CollectionActivity>;
2832
2833 fn list_collection_activities(
2835 &self,
2836 filter: CollectionActivityFilter,
2837 ) -> Result<Vec<CollectionActivity>>;
2838
2839 fn update_collection_status(
2841 &self,
2842 invoice_id: InvoiceId,
2843 status: CollectionStatus,
2844 ) -> Result<()>;
2845
2846 fn get_invoices_due_for_dunning(&self) -> Result<Vec<Invoice>>;
2848
2849 fn send_dunning_letter(
2851 &self,
2852 invoice_id: InvoiceId,
2853 letter_type: DunningLetterType,
2854 sent_by: Option<&str>,
2855 ) -> Result<CollectionActivity>;
2856
2857 fn create_write_off(&self, input: CreateWriteOff) -> Result<WriteOff>;
2860
2861 fn get_write_off(&self, id: Uuid) -> Result<Option<WriteOff>>;
2863
2864 fn list_write_offs(&self, filter: WriteOffFilter) -> Result<Vec<WriteOff>>;
2866
2867 fn reverse_write_off(&self, id: Uuid) -> Result<WriteOff>;
2869
2870 fn create_credit_memo(&self, input: CreateCreditMemo) -> Result<CreditMemo>;
2873
2874 fn get_credit_memo(&self, id: Uuid) -> Result<Option<CreditMemo>>;
2876
2877 fn get_credit_memo_by_number(&self, number: &str) -> Result<Option<CreditMemo>>;
2879
2880 fn list_credit_memos(&self, filter: CreditMemoFilter) -> Result<Vec<CreditMemo>>;
2882
2883 fn apply_credit_memo(&self, input: ApplyCreditMemo) -> Result<CreditMemo>;
2885
2886 fn void_credit_memo(&self, id: Uuid) -> Result<CreditMemo>;
2888
2889 fn get_unapplied_credits(&self, customer_id: Uuid) -> Result<Vec<CreditMemo>>;
2891
2892 fn apply_payment_to_invoices(
2895 &self,
2896 input: ApplyPaymentToInvoices,
2897 ) -> Result<Vec<ArPaymentApplication>>;
2898
2899 fn get_payment_applications(&self, payment_id: Uuid) -> Result<Vec<ArPaymentApplication>>;
2901
2902 fn unapply_payment(&self, application_id: Uuid) -> Result<()>;
2904
2905 fn get_customer_summary(&self, customer_id: Uuid) -> Result<Option<CustomerArSummary>>;
2908
2909 fn generate_statement(&self, request: GenerateStatementRequest) -> Result<CustomerStatement>;
2911
2912 fn get_total_outstanding(&self) -> Result<rust_decimal::Decimal>;
2915
2916 fn get_dso(&self, days: i32) -> Result<rust_decimal::Decimal>;
2918
2919 fn get_average_days_to_pay(&self, customer_id: Uuid) -> Result<Option<i32>>;
2921
2922 fn get_customers_batch(&self, ids: Vec<Uuid>) -> Result<Vec<CustomerArSummary>>;
2924}
2925
2926use chrono::NaiveDate;
2931
2932#[auto_impl::auto_impl(&, Box, Arc)]
2934pub trait GeneralLedgerRepository: Send + Sync {
2935 fn create_account(&self, input: CreateGlAccount) -> Result<GlAccount>;
2938
2939 fn get_account(&self, id: Uuid) -> Result<Option<GlAccount>>;
2941
2942 fn get_account_by_number(&self, account_number: &str) -> Result<Option<GlAccount>>;
2944
2945 fn update_account(&self, id: Uuid, input: UpdateGlAccount) -> Result<GlAccount>;
2947
2948 fn list_accounts(&self, filter: GlAccountFilter) -> Result<Vec<GlAccount>>;
2950
2951 fn get_account_hierarchy(&self) -> Result<Vec<GlAccount>>;
2953
2954 fn delete_account(&self, id: Uuid) -> Result<()>;
2956
2957 fn initialize_chart_of_accounts(&self) -> Result<Vec<GlAccount>>;
2959
2960 fn create_period(&self, input: CreateGlPeriod) -> Result<GlPeriod>;
2963
2964 fn get_period(&self, id: Uuid) -> Result<Option<GlPeriod>>;
2966
2967 fn get_current_period(&self) -> Result<Option<GlPeriod>>;
2969
2970 fn get_period_for_date(&self, date: NaiveDate) -> Result<Option<GlPeriod>>;
2972
2973 fn list_periods(&self, filter: GlPeriodFilter) -> Result<Vec<GlPeriod>>;
2975
2976 fn open_period(&self, id: Uuid) -> Result<GlPeriod>;
2978
2979 fn close_period(&self, id: Uuid, closed_by: &str) -> Result<GlPeriod>;
2981
2982 fn lock_period(&self, id: Uuid, locked_by: &str) -> Result<GlPeriod>;
2984
2985 fn reopen_period(&self, id: Uuid) -> Result<GlPeriod>;
2987
2988 fn create_journal_entry(&self, input: CreateJournalEntry) -> Result<JournalEntry>;
2991
2992 fn get_journal_entry(&self, id: Uuid) -> Result<Option<JournalEntry>>;
2994
2995 fn get_journal_entry_by_number(&self, number: &str) -> Result<Option<JournalEntry>>;
2997
2998 fn list_journal_entries(&self, filter: JournalEntryFilter) -> Result<Vec<JournalEntry>>;
3000
3001 fn post_journal_entry(&self, id: Uuid, posted_by: &str) -> Result<JournalEntry>;
3003
3004 fn void_journal_entry(&self, id: Uuid) -> Result<JournalEntry>;
3006
3007 fn reverse_journal_entry(&self, id: Uuid, reversal_date: NaiveDate) -> Result<JournalEntry>;
3009
3010 fn get_journal_entry_lines(&self, journal_entry_id: Uuid) -> Result<Vec<JournalEntryLine>>;
3012
3013 fn get_auto_posting_config(&self) -> Result<Option<AutoPostingConfig>>;
3016
3017 fn set_auto_posting_config(&self, input: CreateAutoPostingConfig) -> Result<AutoPostingConfig>;
3019
3020 fn auto_post_invoice(&self, invoice_id: InvoiceId) -> Result<JournalEntry>;
3022
3023 fn auto_post_payment_received(&self, payment_id: Uuid) -> Result<JournalEntry>;
3025
3026 fn auto_post_bill(&self, bill_id: Uuid) -> Result<JournalEntry>;
3028
3029 fn auto_post_bill_payment(&self, payment_id: Uuid) -> Result<JournalEntry>;
3031
3032 fn auto_post_inventory_cost(&self, cost_transaction_id: Uuid) -> Result<JournalEntry>;
3034
3035 fn auto_post_write_off(&self, write_off_id: Uuid) -> Result<JournalEntry>;
3037
3038 fn get_trial_balance(&self, as_of_date: NaiveDate) -> Result<TrialBalance>;
3041
3042 fn get_balance_sheet(&self, as_of_date: NaiveDate) -> Result<BalanceSheet>;
3044
3045 fn get_income_statement(
3047 &self,
3048 start_date: NaiveDate,
3049 end_date: NaiveDate,
3050 ) -> Result<IncomeStatement>;
3051
3052 fn get_account_balance(
3054 &self,
3055 account_id: Uuid,
3056 as_of_date: Option<NaiveDate>,
3057 ) -> Result<Option<rust_decimal::Decimal>>;
3058
3059 fn get_account_transactions(
3061 &self,
3062 account_id: Uuid,
3063 filter: JournalEntryFilter,
3064 ) -> Result<Vec<JournalEntryLine>>;
3065
3066 fn run_period_close(&self, period_id: Uuid, closed_by: &str) -> Result<JournalEntry>;
3069
3070 fn revalue(
3076 &self,
3077 as_of_date: NaiveDate,
3078 base_currency: Option<Currency>,
3079 ) -> Result<RevaluationResult>;
3080
3081 fn create_accounts_batch(&self, inputs: Vec<CreateGlAccount>)
3083 -> Result<BatchResult<GlAccount>>;
3084 fn get_accounts_batch(&self, ids: Vec<Uuid>) -> Result<Vec<GlAccount>>;
3085}
3086
3087#[auto_impl::auto_impl(&, Box, Arc)]
3093pub trait VectorRepository: Send + Sync {
3094 fn store_embedding(
3096 &self,
3097 entity_type: EntityType,
3098 entity_id: &str,
3099 embedding: &[f32],
3100 text_hash: &str,
3101 model: &str,
3102 ) -> Result<()>;
3103
3104 fn search_products(
3106 &self,
3107 embedding: &[f32],
3108 limit: usize,
3109 ) -> Result<Vec<VectorSearchResult<Product>>>;
3110
3111 fn search_customers(
3113 &self,
3114 embedding: &[f32],
3115 limit: usize,
3116 ) -> Result<Vec<VectorSearchResult<Customer>>>;
3117
3118 fn search_orders(
3120 &self,
3121 embedding: &[f32],
3122 limit: usize,
3123 ) -> Result<Vec<VectorSearchResult<Order>>>;
3124
3125 fn search_inventory(
3127 &self,
3128 embedding: &[f32],
3129 limit: usize,
3130 ) -> Result<Vec<VectorSearchResult<InventoryItem>>>;
3131
3132 fn delete_embedding(&self, entity_type: EntityType, entity_id: &str) -> Result<()>;
3134
3135 fn has_embedding(&self, entity_type: EntityType, entity_id: &str) -> Result<bool>;
3137
3138 fn get_embedding_metadata(
3140 &self,
3141 entity_type: EntityType,
3142 entity_id: &str,
3143 ) -> Result<Option<EmbeddingMetadata>>;
3144
3145 fn get_stats(&self) -> Result<EmbeddingStats>;
3147
3148 fn clear_embeddings(&self, entity_type: EntityType) -> Result<u64>;
3150}
3151
3152#[auto_impl::auto_impl(&, Box, Arc)]
3158pub trait X402PaymentIntentRepository: Send + Sync {
3159 fn create(&self, input: CreateX402PaymentIntent) -> Result<X402PaymentIntent>;
3161
3162 fn get(&self, id: Uuid) -> Result<Option<X402PaymentIntent>>;
3164
3165 fn get_by_idempotency_key(&self, key: &str) -> Result<Option<X402PaymentIntent>>;
3167
3168 fn sign(&self, id: Uuid, input: SignX402PaymentIntent) -> Result<X402PaymentIntent>;
3170
3171 fn mark_sequenced(
3173 &self,
3174 id: Uuid,
3175 sequence_number: u64,
3176 batch_id: Uuid,
3177 ) -> Result<X402PaymentIntent>;
3178
3179 fn mark_settled(&self, id: Uuid, tx_hash: &str, block_number: u64)
3181 -> Result<X402PaymentIntent>;
3182
3183 fn mark_failed(&self, id: Uuid, reason: &str) -> Result<X402PaymentIntent>;
3185
3186 fn mark_expired(&self, id: Uuid) -> Result<X402PaymentIntent>;
3188
3189 fn cancel(&self, id: Uuid) -> Result<X402PaymentIntent>;
3191
3192 fn for_cart(&self, cart_id: Uuid) -> Result<Vec<X402PaymentIntent>>;
3194
3195 fn for_order(&self, order_id: Uuid) -> Result<Vec<X402PaymentIntent>>;
3197
3198 fn get_next_nonce(&self, payer_address: &str) -> Result<u64>;
3200
3201 fn list(&self, filter: X402PaymentIntentFilter) -> Result<Vec<X402PaymentIntent>>;
3203
3204 fn count(&self, filter: X402PaymentIntentFilter) -> Result<u64>;
3206
3207 fn expire_stale_intents(&self) -> Result<u64>;
3209
3210 fn create_batch(
3214 &self,
3215 inputs: Vec<CreateX402PaymentIntent>,
3216 ) -> Result<BatchResult<X402PaymentIntent>>;
3217
3218 fn create_batch_atomic(
3220 &self,
3221 inputs: Vec<CreateX402PaymentIntent>,
3222 ) -> Result<Vec<X402PaymentIntent>>;
3223
3224 fn get_batch(&self, ids: Vec<Uuid>) -> Result<Vec<X402PaymentIntent>>;
3226}
3227
3228#[auto_impl::auto_impl(&, Box, Arc)]
3234pub trait X402CreditRepository: Send + Sync {
3235 fn get_account(
3237 &self,
3238 payer_address: &str,
3239 asset: X402Asset,
3240 network: X402Network,
3241 ) -> Result<Option<X402CreditAccount>>;
3242
3243 fn get_or_create_account(
3245 &self,
3246 payer_address: &str,
3247 asset: X402Asset,
3248 network: X402Network,
3249 ) -> Result<X402CreditAccount>;
3250
3251 fn get_balance(
3253 &self,
3254 payer_address: &str,
3255 asset: X402Asset,
3256 network: X402Network,
3257 ) -> Result<u64>;
3258
3259 fn adjust_balance(&self, input: X402CreditAdjustment) -> Result<X402CreditTransaction>;
3261
3262 fn list_transactions(
3264 &self,
3265 filter: X402CreditTransactionFilter,
3266 ) -> Result<Vec<X402CreditTransaction>>;
3267}
3268
3269#[auto_impl::auto_impl(&, Box, Arc)]
3275pub trait AgentCardRepository: Send + Sync {
3276 fn create(&self, input: CreateAgentCard) -> Result<AgentCard>;
3278
3279 fn get(&self, id: Uuid) -> Result<Option<AgentCard>>;
3281
3282 fn get_by_wallet(&self, wallet_address: &str) -> Result<Option<AgentCard>>;
3284
3285 fn update(&self, id: Uuid, input: UpdateAgentCard) -> Result<AgentCard>;
3287
3288 fn delete(&self, id: Uuid) -> Result<()>;
3290
3291 fn list(&self, filter: AgentCardFilter) -> Result<Vec<AgentCard>>;
3293
3294 fn count(&self, filter: AgentCardFilter) -> Result<u64>;
3296
3297 fn verify(&self, id: Uuid, trust_level: TrustLevel, method: &str) -> Result<AgentCard>;
3299
3300 fn suspend(&self, id: Uuid, reason: &str) -> Result<AgentCard>;
3302
3303 fn reactivate(&self, id: Uuid) -> Result<AgentCard>;
3305
3306 fn discover(&self, filter: AgentCardFilter) -> Result<Vec<AgentCard>>;
3308
3309 fn create_batch(&self, inputs: Vec<CreateAgentCard>) -> Result<BatchResult<AgentCard>>;
3313
3314 fn create_batch_atomic(&self, inputs: Vec<CreateAgentCard>) -> Result<Vec<AgentCard>>;
3316
3317 fn get_batch(&self, ids: Vec<Uuid>) -> Result<Vec<AgentCard>>;
3319}
3320
3321#[auto_impl::auto_impl(&, Box, Arc)]
3327pub trait AgentIdentityRepository: Send + Sync {
3328 fn register(&self, input: CreateAgentIdentity) -> Result<AgentIdentity>;
3330
3331 fn get(&self, agent_registry: &str, agent_id: &str) -> Result<Option<AgentIdentity>>;
3333
3334 fn get_by_wallet(&self, agent_wallet: &str) -> Result<Option<AgentIdentity>>;
3336
3337 fn update(
3339 &self,
3340 agent_registry: &str,
3341 agent_id: &str,
3342 input: UpdateAgentIdentity,
3343 ) -> Result<AgentIdentity>;
3344
3345 #[allow(clippy::too_many_arguments)]
3347 fn set_agent_wallet(
3348 &self,
3349 agent_registry: &str,
3350 agent_id: &str,
3351 agent_wallet: &str,
3352 proof_type: Option<AgentWalletProofType>,
3353 proof: Option<&str>,
3354 proof_chain_id: Option<u64>,
3355 proof_deadline: Option<DateTime<Utc>>,
3356 ) -> Result<AgentIdentity>;
3357
3358 fn clear_agent_wallet(&self, agent_registry: &str, agent_id: &str) -> Result<AgentIdentity>;
3360
3361 fn list(&self, filter: AgentIdentityFilter) -> Result<Vec<AgentIdentity>>;
3363
3364 fn count(&self, filter: AgentIdentityFilter) -> Result<u64>;
3366
3367 fn set_metadata(
3369 &self,
3370 agent_registry: &str,
3371 agent_id: &str,
3372 entry: AgentMetadataEntry,
3373 ) -> Result<()>;
3374
3375 fn get_metadata(
3377 &self,
3378 agent_registry: &str,
3379 agent_id: &str,
3380 metadata_key: &str,
3381 ) -> Result<Option<Vec<u8>>>;
3382
3383 fn delete_metadata(
3385 &self,
3386 agent_registry: &str,
3387 agent_id: &str,
3388 metadata_key: &str,
3389 ) -> Result<()>;
3390}
3391
3392#[auto_impl::auto_impl(&, Box, Arc)]
3398pub trait AgentReputationRepository: Send + Sync {
3399 fn give_feedback(&self, input: CreateAgentFeedback) -> Result<AgentFeedback>;
3401
3402 fn revoke_feedback(
3404 &self,
3405 agent_registry: &str,
3406 agent_id: &str,
3407 client_address: &str,
3408 feedback_index: u64,
3409 ) -> Result<AgentFeedback>;
3410
3411 fn read_feedback(
3413 &self,
3414 agent_registry: &str,
3415 agent_id: &str,
3416 client_address: &str,
3417 feedback_index: u64,
3418 ) -> Result<Option<AgentFeedback>>;
3419
3420 fn read_all_feedback(&self, filter: AgentFeedbackFilter) -> Result<Vec<AgentFeedback>>;
3422
3423 fn get_summary(
3425 &self,
3426 agent_registry: &str,
3427 agent_id: &str,
3428 client_addresses: Vec<String>,
3429 tag1: Option<String>,
3430 tag2: Option<String>,
3431 ) -> Result<FeedbackSummary>;
3432
3433 fn append_response(&self, input: CreateAgentFeedbackResponse) -> Result<AgentFeedbackResponse>;
3435
3436 fn get_response_count(
3438 &self,
3439 agent_registry: &str,
3440 agent_id: &str,
3441 client_address: &str,
3442 feedback_index: u64,
3443 responders: Option<Vec<String>>,
3444 ) -> Result<u64>;
3445
3446 fn get_clients(&self, agent_registry: &str, agent_id: &str) -> Result<Vec<String>>;
3448
3449 fn get_last_index(
3451 &self,
3452 agent_registry: &str,
3453 agent_id: &str,
3454 client_address: &str,
3455 ) -> Result<u64>;
3456}
3457
3458#[auto_impl::auto_impl(&, Box, Arc)]
3464pub trait AgentValidationRepository: Send + Sync {
3465 fn request_validation(
3467 &self,
3468 input: CreateAgentValidationRequest,
3469 ) -> Result<AgentValidationRequest>;
3470
3471 fn respond_validation(
3473 &self,
3474 request_hash: &str,
3475 input: CreateAgentValidationResponse,
3476 ) -> Result<AgentValidationResponse>;
3477
3478 fn get_validation_status(&self, request_hash: &str) -> Result<Option<AgentValidationStatus>>;
3480
3481 fn get_summary(
3483 &self,
3484 agent_registry: &str,
3485 agent_id: &str,
3486 validator_addresses: Option<Vec<String>>,
3487 tag: Option<String>,
3488 ) -> Result<ValidationSummary>;
3489
3490 fn get_agent_validations(&self, agent_registry: &str, agent_id: &str) -> Result<Vec<String>>;
3492
3493 fn get_validator_requests(&self, validator_address: &str) -> Result<Vec<String>>;
3495}
3496
3497#[auto_impl::auto_impl(&, Box, Arc)]
3503pub trait A2ACommerceRepository: Send + Sync {
3504 fn create_quote(&self, input: CreateA2AQuote) -> Result<SkillQuote>;
3507
3508 fn get_quote(&self, id: Uuid) -> Result<Option<SkillQuote>>;
3510
3511 fn get_quote_by_number(&self, quote_number: &str) -> Result<Option<SkillQuote>>;
3513
3514 fn update_quote_status(&self, id: Uuid, status: QuoteStatus) -> Result<SkillQuote>;
3516
3517 fn list_quotes(&self, filter: SkillQuoteFilter) -> Result<Vec<SkillQuote>>;
3519
3520 fn count_quotes(&self, filter: SkillQuoteFilter) -> Result<u64>;
3522
3523 fn create_purchase(&self, input: CreateA2APurchase) -> Result<A2APurchase>;
3526
3527 fn get_purchase(&self, id: Uuid) -> Result<Option<A2APurchase>>;
3529
3530 fn get_purchase_by_number(&self, purchase_number: &str) -> Result<Option<A2APurchase>>;
3532
3533 fn update_purchase_status(&self, id: Uuid, status: PurchaseStatus) -> Result<A2APurchase>;
3535
3536 fn link_purchase_to_order(&self, purchase_id: Uuid, order_id: Uuid) -> Result<A2APurchase>;
3538
3539 fn confirm_delivery(
3541 &self,
3542 purchase_id: Uuid,
3543 signature: &str,
3544 rating: Option<u8>,
3545 feedback: Option<&str>,
3546 ) -> Result<A2APurchase>;
3547
3548 fn list_purchases(&self, filter: A2APurchaseFilter) -> Result<Vec<A2APurchase>>;
3550
3551 fn count_purchases(&self, filter: A2APurchaseFilter) -> Result<u64>;
3553}
3554
3555#[auto_impl::auto_impl(&, Box, Arc)]
3565pub trait CustomObjectRepository: Send + Sync {
3566 fn create_type(&self, input: CreateCustomObjectType) -> Result<CustomObjectType>;
3571
3572 fn get_type(&self, id: Uuid) -> Result<Option<CustomObjectType>>;
3573
3574 fn get_type_by_handle(&self, handle: &str) -> Result<Option<CustomObjectType>>;
3575
3576 fn update_type(&self, id: Uuid, input: UpdateCustomObjectType) -> Result<CustomObjectType>;
3577
3578 fn list_types(&self, filter: CustomObjectTypeFilter) -> Result<Vec<CustomObjectType>>;
3579
3580 fn delete_type(&self, id: Uuid) -> Result<()>;
3581
3582 fn create_object(&self, input: CreateCustomObject) -> Result<CustomObject>;
3587
3588 fn get_object(&self, id: Uuid) -> Result<Option<CustomObject>>;
3589
3590 fn get_object_by_handle(
3591 &self,
3592 type_handle: &str,
3593 object_handle: &str,
3594 ) -> Result<Option<CustomObject>>;
3595
3596 fn update_object(&self, id: Uuid, input: UpdateCustomObject) -> Result<CustomObject>;
3597
3598 fn list_objects(&self, filter: CustomObjectFilter) -> Result<Vec<CustomObject>>;
3599
3600 fn delete_object(&self, id: Uuid) -> Result<()>;
3601}
3602
3603#[auto_impl::auto_impl(&, Box, Arc)]
3609pub trait GiftCardRepository: Send + Sync {
3610 fn create(&self, input: CreateGiftCard) -> Result<GiftCard>;
3612
3613 fn get(&self, id: GiftCardId) -> Result<Option<GiftCard>>;
3615
3616 fn get_by_code(&self, code: &str) -> Result<Option<GiftCard>>;
3618
3619 fn update(&self, id: GiftCardId, input: UpdateGiftCard) -> Result<GiftCard>;
3621
3622 fn list(&self, filter: GiftCardFilter) -> Result<Vec<GiftCard>>;
3624
3625 fn charge(
3627 &self,
3628 id: GiftCardId,
3629 amount: rust_decimal::Decimal,
3630 reference_id: Option<String>,
3631 ) -> Result<GiftCardTransaction>;
3632
3633 fn refund(
3635 &self,
3636 id: GiftCardId,
3637 amount: rust_decimal::Decimal,
3638 reference_id: Option<String>,
3639 ) -> Result<GiftCardTransaction>;
3640
3641 fn disable(&self, id: GiftCardId) -> Result<GiftCard>;
3643
3644 fn get_transactions(&self, gift_card_id: GiftCardId) -> Result<Vec<GiftCardTransaction>>;
3646}
3647
3648#[auto_impl::auto_impl(&, Box, Arc)]
3650pub trait StoreCreditRepository: Send + Sync {
3651 fn create(&self, input: CreateStoreCredit) -> Result<StoreCredit>;
3653
3654 fn get(&self, id: StoreCreditId) -> Result<Option<StoreCredit>>;
3656
3657 fn list(&self, filter: StoreCreditFilter) -> Result<Vec<StoreCredit>>;
3659
3660 fn adjust(&self, id: StoreCreditId, input: AdjustStoreCredit) -> Result<StoreCredit>;
3662
3663 fn apply(
3665 &self,
3666 id: StoreCreditId,
3667 amount: rust_decimal::Decimal,
3668 reference_id: Option<String>,
3669 ) -> Result<StoreCreditTransaction>;
3670
3671 fn get_transactions(
3673 &self,
3674 store_credit_id: StoreCreditId,
3675 ) -> Result<Vec<StoreCreditTransaction>>;
3676}
3677
3678#[auto_impl::auto_impl(&, Box, Arc)]
3680pub trait SegmentRepository: Send + Sync {
3681 fn create(&self, input: CreateSegment) -> Result<Segment>;
3683
3684 fn get(&self, id: SegmentId) -> Result<Option<Segment>>;
3686
3687 fn update(&self, id: SegmentId, input: UpdateSegment) -> Result<Segment>;
3689
3690 fn list(&self, filter: SegmentFilter) -> Result<Vec<Segment>>;
3692
3693 fn delete(&self, id: SegmentId) -> Result<()>;
3695
3696 fn add_member(
3698 &self,
3699 segment_id: SegmentId,
3700 customer_id: CustomerId,
3701 ) -> Result<SegmentMembership>;
3702
3703 fn remove_member(&self, segment_id: SegmentId, customer_id: CustomerId) -> Result<()>;
3705
3706 fn list_members(
3708 &self,
3709 segment_id: SegmentId,
3710 limit: Option<u32>,
3711 offset: Option<u32>,
3712 ) -> Result<Vec<SegmentMembership>>;
3713
3714 fn is_member(&self, segment_id: SegmentId, customer_id: CustomerId) -> Result<bool>;
3716
3717 fn count_members(&self, segment_id: SegmentId) -> Result<u64>;
3719}
3720
3721#[auto_impl::auto_impl(&, Box, Arc)]
3723pub trait ShippingZoneRepository: Send + Sync {
3724 fn create(&self, input: CreateShippingZone) -> Result<ShippingZone>;
3726
3727 fn get(&self, id: ShippingZoneId) -> Result<Option<ShippingZone>>;
3729
3730 fn update(&self, id: ShippingZoneId, input: UpdateShippingZone) -> Result<ShippingZone>;
3732
3733 fn list(&self, filter: ShippingZoneFilter) -> Result<Vec<ShippingZone>>;
3735
3736 fn delete(&self, id: ShippingZoneId) -> Result<()>;
3738
3739 fn find_matching_zones(
3741 &self,
3742 country: &str,
3743 region: Option<&str>,
3744 postal_code: Option<&str>,
3745 ) -> Result<Vec<ShippingZone>>;
3746}
3747
3748#[auto_impl::auto_impl(&, Box, Arc)]
3750pub trait ZoneShippingMethodRepository: Send + Sync {
3751 fn create(&self, input: CreateZoneShippingMethod) -> Result<ZoneShippingMethod>;
3753
3754 fn get(&self, id: ShippingMethodId) -> Result<Option<ZoneShippingMethod>>;
3756
3757 fn list(&self, filter: ZoneShippingMethodFilter) -> Result<Vec<ZoneShippingMethod>>;
3759
3760 fn delete(&self, id: ShippingMethodId) -> Result<()>;
3762
3763 fn calculate_rates(&self, request: ZoneShippingRateRequest) -> Result<Vec<ZoneShippingRate>>;
3765}
3766
3767#[auto_impl::auto_impl(&, Box, Arc)]
3769pub trait ReviewRepository: Send + Sync {
3770 fn create(&self, input: CreateReview) -> Result<Review>;
3772
3773 fn get(&self, id: ReviewId) -> Result<Option<Review>>;
3775
3776 fn update(&self, id: ReviewId, input: UpdateReview) -> Result<Review>;
3778
3779 fn list(&self, filter: ReviewFilter) -> Result<Vec<Review>>;
3781
3782 fn delete(&self, id: ReviewId) -> Result<()>;
3784
3785 fn get_summary(&self, product_id: ProductId) -> Result<ReviewSummary>;
3787
3788 fn mark_helpful(&self, id: ReviewId) -> Result<()>;
3790
3791 fn mark_reported(&self, id: ReviewId) -> Result<()>;
3793}
3794
3795#[auto_impl::auto_impl(&, Box, Arc)]
3797pub trait WishlistRepository: Send + Sync {
3798 fn create(&self, input: CreateWishlist) -> Result<Wishlist>;
3800
3801 fn get(&self, id: WishlistId) -> Result<Option<Wishlist>>;
3803
3804 fn update(&self, id: WishlistId, input: UpdateWishlist) -> Result<Wishlist>;
3806
3807 fn list(&self, filter: WishlistFilter) -> Result<Vec<Wishlist>>;
3809
3810 fn delete(&self, id: WishlistId) -> Result<()>;
3812
3813 fn add_item(&self, wishlist_id: WishlistId, item: AddWishlistItem) -> Result<WishlistItem>;
3815
3816 fn remove_item(&self, wishlist_id: WishlistId, product_id: ProductId) -> Result<()>;
3818}
3819
3820#[auto_impl::auto_impl(&, Box, Arc)]
3822pub trait LoyaltyProgramRepository: Send + Sync {
3823 fn create(&self, input: CreateLoyaltyProgram) -> Result<LoyaltyProgram>;
3825
3826 fn get(&self, id: LoyaltyProgramId) -> Result<Option<LoyaltyProgram>>;
3828
3829 fn list(&self) -> Result<Vec<LoyaltyProgram>>;
3831
3832 fn enroll(&self, input: EnrollCustomer) -> Result<LoyaltyAccount>;
3834
3835 fn get_account(&self, id: LoyaltyAccountId) -> Result<Option<LoyaltyAccount>>;
3837
3838 fn get_account_by_customer(
3840 &self,
3841 customer_id: CustomerId,
3842 program_id: LoyaltyProgramId,
3843 ) -> Result<Option<LoyaltyAccount>>;
3844
3845 fn list_accounts(&self, filter: LoyaltyAccountFilter) -> Result<Vec<LoyaltyAccount>>;
3847
3848 fn adjust_points(&self, input: AdjustPoints) -> Result<LoyaltyTransaction>;
3850
3851 fn get_transactions(
3853 &self,
3854 account_id: LoyaltyAccountId,
3855 limit: Option<u32>,
3856 ) -> Result<Vec<LoyaltyTransaction>>;
3857}
3858
3859#[auto_impl::auto_impl(&, Box, Arc)]
3861pub trait RewardRepository: Send + Sync {
3862 fn create(&self, input: CreateReward) -> Result<Reward>;
3864
3865 fn get(&self, id: RewardId) -> Result<Option<Reward>>;
3867
3868 fn list(&self, filter: RewardFilter) -> Result<Vec<Reward>>;
3870
3871 fn delete(&self, id: RewardId) -> Result<()>;
3873}
3874
3875#[auto_impl::auto_impl(&, Box, Arc)]
3877pub trait FraudRepository: Send + Sync {
3878 fn create_assessment(&self, input: CreateFraudAssessment) -> Result<FraudAssessment>;
3880
3881 fn get_assessment(&self, order_id: OrderId) -> Result<Option<FraudAssessment>>;
3883
3884 fn list_assessments(&self, filter: FraudAssessmentFilter) -> Result<Vec<FraudAssessment>>;
3886
3887 fn review_assessment(
3889 &self,
3890 order_id: OrderId,
3891 decision: FraudDecision,
3892 reviewer: String,
3893 notes: Option<String>,
3894 ) -> Result<FraudAssessment>;
3895
3896 fn create_rule(&self, input: CreateFraudRule) -> Result<FraudRule>;
3898
3899 fn get_rule(&self, id: FraudRuleId) -> Result<Option<FraudRule>>;
3901
3902 fn update_rule(&self, id: FraudRuleId, input: UpdateFraudRule) -> Result<FraudRule>;
3904
3905 fn list_rules(&self, filter: FraudRuleFilter) -> Result<Vec<FraudRule>>;
3907
3908 fn delete_rule(&self, id: FraudRuleId) -> Result<()>;
3910
3911 fn get_active_rules(&self) -> Result<Vec<FraudRule>>;
3913}
3914
3915#[auto_impl::auto_impl(&, Box, Arc)]
3917pub trait SearchConfigRepository: Send + Sync {
3918 fn create(&self, input: CreateSearchConfig) -> Result<SearchConfig>;
3920
3921 fn get(&self, id: SearchConfigId) -> Result<Option<SearchConfig>>;
3923
3924 fn update(&self, id: SearchConfigId, input: UpdateSearchConfig) -> Result<SearchConfig>;
3926
3927 fn list(&self, filter: SearchConfigFilter) -> Result<Vec<SearchConfig>>;
3929
3930 fn delete(&self, id: SearchConfigId) -> Result<()>;
3932
3933 fn get_active(&self) -> Result<Option<SearchConfig>>;
3935
3936 fn set_active(&self, id: SearchConfigId) -> Result<SearchConfig>;
3938}
3939
3940#[auto_impl::auto_impl(&, Box, Arc)]
3942pub trait ChannelRepository: Send + Sync {
3943 fn create(&self, input: CreateChannel) -> Result<Channel>;
3945
3946 fn get(&self, id: ChannelId) -> Result<Option<Channel>>;
3948
3949 fn update(&self, id: ChannelId, input: UpdateChannel) -> Result<Channel>;
3951
3952 fn list(&self, filter: ChannelFilter) -> Result<Vec<Channel>>;
3954
3955 fn delete(&self, id: ChannelId) -> Result<()>;
3957
3958 fn set_lock(&self, id: ChannelId, locked: bool) -> Result<Channel>;
3960
3961 fn sync_products(&self, id: ChannelId, items: Vec<ChannelProductSyncItem>) -> Result<u64>;
3963
3964 fn list_product_mappings(&self, id: ChannelId) -> Result<Vec<ChannelProductMapping>>;
3966}
3967
3968#[auto_impl::auto_impl(&, Box, Arc)]
3970pub trait CompanyRepository: Send + Sync {
3971 fn create(&self, input: CreateCompany) -> Result<Company>;
3973
3974 fn get(&self, id: CompanyId) -> Result<Option<Company>>;
3976
3977 fn update(&self, id: CompanyId, input: UpdateCompany) -> Result<Company>;
3979
3980 fn list(&self, filter: CompanyFilter) -> Result<Vec<Company>>;
3982
3983 fn delete(&self, id: CompanyId) -> Result<()>;
3985
3986 fn list_addresses(&self, id: CompanyId) -> Result<Vec<CompanyShippingAddress>>;
3988
3989 fn list_price_overrides(&self, id: CompanyId) -> Result<Vec<CompanyPriceOverride>>;
3991
3992 fn create_contact(&self, input: CreateContact) -> Result<Contact>;
3994
3995 fn get_contact(&self, id: ContactId) -> Result<Option<Contact>>;
3997
3998 fn list_contacts(&self, company_id: CompanyId) -> Result<Vec<Contact>>;
4000}
4001
4002#[auto_impl::auto_impl(&, Box, Arc)]
4004pub trait TransferOrderRepository: Send + Sync {
4005 fn create(&self, input: CreateTransferOrder) -> Result<TransferOrder>;
4007
4008 fn get(&self, id: TransferOrderId) -> Result<Option<TransferOrder>>;
4010
4011 fn list(&self, filter: TransferOrderFilter) -> Result<Vec<TransferOrder>>;
4013
4014 fn ship(&self, id: TransferOrderId) -> Result<TransferOrder>;
4016
4017 fn receive_line(
4019 &self,
4020 id: TransferOrderId,
4021 item_id: TransferOrderItemId,
4022 quantity: rust_decimal::Decimal,
4023 ) -> Result<TransferOrder>;
4024
4025 fn cancel(&self, id: TransferOrderId) -> Result<TransferOrder>;
4027}
4028
4029#[auto_impl::auto_impl(&, Box, Arc)]
4031pub trait UnitOfMeasureRepository: Send + Sync {
4032 fn create_class(&self, input: CreateUnitClass) -> Result<UnitClass>;
4034
4035 fn list_classes(&self) -> Result<Vec<UnitClass>>;
4037
4038 fn delete_class(&self, id: UnitClassId) -> Result<()>;
4040
4041 fn create_uom(&self, input: CreateUnitOfMeasure) -> Result<UnitOfMeasure>;
4043
4044 fn list_uoms(&self, filter: UnitOfMeasureFilter) -> Result<Vec<UnitOfMeasure>>;
4048
4049 fn set_base_uom(&self, id: UnitOfMeasureId) -> Result<UnitOfMeasure>;
4051
4052 fn delete_uom(&self, id: UnitOfMeasureId) -> Result<()>;
4054
4055 fn create_rule(&self, input: CreateUnitConversionRule) -> Result<UnitConversionRule>;
4057
4058 fn list_rules(&self) -> Result<Vec<UnitConversionRule>>;
4060
4061 fn delete_rule(&self, id: UnitConversionRuleId) -> Result<()>;
4063}
4064
4065#[auto_impl::auto_impl(&, Box, Arc)]
4067pub trait ProductionBatchRepository: Send + Sync {
4068 fn create(&self, input: CreateProductionBatch) -> Result<ProductionBatch>;
4070
4071 fn get(&self, id: ProductionBatchId) -> Result<Option<ProductionBatch>>;
4073
4074 fn update(
4076 &self,
4077 id: ProductionBatchId,
4078 input: UpdateProductionBatch,
4079 ) -> Result<ProductionBatch>;
4080
4081 fn list(&self, filter: ProductionBatchFilter) -> Result<Vec<ProductionBatch>>;
4083
4084 fn delete(&self, id: ProductionBatchId) -> Result<()>;
4086
4087 fn add_work_orders(
4089 &self,
4090 id: ProductionBatchId,
4091 work_order_ids: Vec<uuid::Uuid>,
4092 ) -> Result<ProductionBatch>;
4093
4094 fn remove_work_order(
4096 &self,
4097 id: ProductionBatchId,
4098 work_order_id: uuid::Uuid,
4099 ) -> Result<ProductionBatch>;
4100}
4101
4102#[auto_impl::auto_impl(&, Box, Arc)]
4104pub trait SupplierSkuRepository: Send + Sync {
4105 fn create(&self, input: CreateSupplierSku) -> Result<SupplierSku>;
4107
4108 fn get(&self, id: SupplierSkuId) -> Result<Option<SupplierSku>>;
4110
4111 fn update(&self, id: SupplierSkuId, input: UpdateSupplierSku) -> Result<SupplierSku>;
4113
4114 fn list(&self, filter: SupplierSkuFilter) -> Result<Vec<SupplierSku>>;
4116
4117 fn delete(&self, id: SupplierSkuId) -> Result<()>;
4119
4120 fn bulk_upsert(&self, supplier_id: uuid::Uuid, items: Vec<BulkSupplierSkuItem>) -> Result<u64>;
4123}
4124
4125#[auto_impl::auto_impl(&, Box, Arc)]
4127pub trait VendorReturnRepository: Send + Sync {
4128 fn create(&self, input: CreateVendorReturn) -> Result<VendorReturn>;
4130
4131 fn get(&self, id: VendorReturnId) -> Result<Option<VendorReturn>>;
4133
4134 fn list(&self, filter: VendorReturnFilter) -> Result<Vec<VendorReturn>>;
4136
4137 fn submit(&self, id: VendorReturnId) -> Result<VendorReturn>;
4139
4140 fn process(&self, id: VendorReturnId, generate_credit: bool) -> Result<VendorReturn>;
4142
4143 fn cancel(&self, id: VendorReturnId) -> Result<VendorReturn>;
4145}
4146
4147#[auto_impl::auto_impl(&, Box, Arc)]
4149pub trait VendorCreditRepository: Send + Sync {
4150 fn create(&self, input: CreateVendorCredit) -> Result<VendorCredit>;
4152
4153 fn get(&self, id: VendorCreditId) -> Result<Option<VendorCredit>>;
4155
4156 fn list(&self, filter: VendorCreditFilter) -> Result<Vec<VendorCredit>>;
4158
4159 fn apply(&self, id: VendorCreditId, input: ApplyVendorCredit) -> Result<VendorCredit>;
4162
4163 fn list_applications(&self, id: VendorCreditId) -> Result<Vec<VendorCreditApplication>>;
4165
4166 fn reverse_application(
4168 &self,
4169 id: VendorCreditId,
4170 application_id: VendorCreditApplicationId,
4171 ) -> Result<VendorCredit>;
4172
4173 fn cancel(&self, id: VendorCreditId) -> Result<VendorCredit>;
4175}
4176
4177#[auto_impl::auto_impl(&, Box, Arc)]
4179pub trait PaymentObligationRepository: Send + Sync {
4180 fn create(&self, input: CreatePaymentObligation) -> Result<PaymentObligation>;
4182
4183 fn get(&self, id: PaymentObligationId) -> Result<Option<PaymentObligation>>;
4185
4186 fn list(&self, filter: PaymentObligationFilter) -> Result<Vec<PaymentObligation>>;
4188
4189 fn record_payment(
4191 &self,
4192 id: PaymentObligationId,
4193 amount: rust_decimal::Decimal,
4194 ) -> Result<PaymentObligation>;
4195
4196 fn set_status(
4198 &self,
4199 id: PaymentObligationId,
4200 status: PaymentObligationStatus,
4201 ) -> Result<PaymentObligation>;
4202
4203 fn link_bill(&self, id: PaymentObligationId, bill_id: uuid::Uuid) -> Result<PaymentObligation>;
4205
4206 fn dashboard(&self, today: chrono::NaiveDate) -> Result<PaymentObligationDashboard>;
4208}
4209
4210#[auto_impl::auto_impl(&, Box, Arc)]
4212pub trait PriceLevelRepository: Send + Sync {
4213 fn create(&self, input: CreatePriceLevel) -> Result<PriceLevel>;
4215
4216 fn get(&self, id: PriceLevelId) -> Result<Option<PriceLevel>>;
4218
4219 fn update(&self, id: PriceLevelId, input: UpdatePriceLevel) -> Result<PriceLevel>;
4221
4222 fn list(&self, filter: PriceLevelFilter) -> Result<Vec<PriceLevel>>;
4224
4225 fn delete(&self, id: PriceLevelId) -> Result<()>;
4227
4228 fn set_entry(
4230 &self,
4231 id: PriceLevelId,
4232 product_id: ProductId,
4233 price: rust_decimal::Decimal,
4234 ) -> Result<PriceLevelEntry>;
4235
4236 fn delete_entry(&self, id: PriceLevelId, product_id: ProductId) -> Result<()>;
4238
4239 fn list_entries(&self, id: PriceLevelId) -> Result<Vec<PriceLevelEntry>>;
4241}
4242
4243#[auto_impl::auto_impl(&, Box, Arc)]
4245pub trait PrepaymentRepository: Send + Sync {
4246 fn create(&self, input: CreatePrepayment) -> Result<Prepayment>;
4248
4249 fn get(&self, id: PrepaymentId) -> Result<Option<Prepayment>>;
4251
4252 fn list(&self, filter: PrepaymentFilter) -> Result<Vec<Prepayment>>;
4254
4255 fn apply(&self, id: PrepaymentId, input: ApplyPrepayment) -> Result<Prepayment>;
4258
4259 fn list_applications(&self, id: PrepaymentId) -> Result<Vec<PrepaymentApplication>>;
4261
4262 fn reverse_application(
4264 &self,
4265 id: PrepaymentId,
4266 application_id: PrepaymentApplicationId,
4267 ) -> Result<Prepayment>;
4268
4269 fn refund(&self, id: PrepaymentId) -> Result<Prepayment>;
4271}
4272
4273#[auto_impl::auto_impl(&, Box, Arc)]
4275pub trait PriceScheduleRepository: Send + Sync {
4276 fn create(&self, input: CreatePriceSchedule) -> Result<PriceSchedule>;
4278
4279 fn get(&self, id: PriceScheduleId) -> Result<Option<PriceSchedule>>;
4281
4282 fn update(&self, id: PriceScheduleId, input: UpdatePriceSchedule) -> Result<PriceSchedule>;
4284
4285 fn list(&self, filter: PriceScheduleFilter) -> Result<Vec<PriceSchedule>>;
4287
4288 fn delete(&self, id: PriceScheduleId) -> Result<()>;
4290
4291 fn set_entry(
4293 &self,
4294 id: PriceScheduleId,
4295 product_id: ProductId,
4296 price: rust_decimal::Decimal,
4297 ) -> Result<PriceScheduleEntry>;
4298
4299 fn delete_entry(&self, id: PriceScheduleId, product_id: ProductId) -> Result<()>;
4301
4302 fn list_entries(&self, id: PriceScheduleId) -> Result<Vec<PriceScheduleEntry>>;
4304
4305 fn resolve_price(
4308 &self,
4309 product_id: ProductId,
4310 at: chrono::DateTime<chrono::Utc>,
4311 ) -> Result<Option<rust_decimal::Decimal>>;
4312}
4313
4314#[auto_impl::auto_impl(&, Box, Arc)]
4316pub trait ActivityLogRepository: Send + Sync {
4317 fn record(&self, input: RecordActivity) -> Result<ActivityLogEntry>;
4319
4320 fn get(&self, id: ActivityLogId) -> Result<Option<ActivityLogEntry>>;
4322
4323 fn list(&self, filter: ActivityLogFilter) -> Result<Vec<ActivityLogEntry>>;
4325
4326 fn history_for_subject(
4329 &self,
4330 subject_type: &str,
4331 subject_id: uuid::Uuid,
4332 ) -> Result<Vec<ActivityLogEntry>>;
4333}
4334
4335#[auto_impl::auto_impl(&, Box, Arc)]
4337pub trait IntegrationMappingRepository: Send + Sync {
4338 fn create(&self, input: CreateIntegrationMapping) -> Result<IntegrationMapping>;
4340
4341 fn get(&self, id: IntegrationMappingId) -> Result<Option<IntegrationMapping>>;
4343
4344 fn update(
4346 &self,
4347 id: IntegrationMappingId,
4348 input: UpdateIntegrationMapping,
4349 ) -> Result<IntegrationMapping>;
4350
4351 fn list(&self, filter: IntegrationMappingFilter) -> Result<Vec<IntegrationMapping>>;
4353
4354 fn delete(&self, id: IntegrationMappingId) -> Result<()>;
4356
4357 fn bulk_upsert(&self, items: Vec<CreateIntegrationMapping>) -> Result<u64>;
4359
4360 fn resolve(&self, lookup: &MappingLookup) -> Result<Option<String>>;
4363}
4364
4365#[auto_impl::auto_impl(&, Box, Arc)]
4367pub trait InboundShipmentRepository: Send + Sync {
4368 fn create(&self, input: CreateInboundShipment) -> Result<InboundShipment>;
4370
4371 fn get(&self, id: InboundShipmentId) -> Result<Option<InboundShipment>>;
4373
4374 fn list(&self, filter: InboundShipmentFilter) -> Result<Vec<InboundShipment>>;
4376
4377 fn mark_in_transit(&self, id: InboundShipmentId) -> Result<InboundShipment>;
4379
4380 fn mark_arrived(&self, id: InboundShipmentId) -> Result<InboundShipment>;
4382
4383 fn receive_line(
4385 &self,
4386 id: InboundShipmentId,
4387 item_id: InboundShipmentItemId,
4388 quantity: rust_decimal::Decimal,
4389 ) -> Result<InboundShipment>;
4390
4391 fn cancel(&self, id: InboundShipmentId) -> Result<InboundShipment>;
4393}
4394
4395#[auto_impl::auto_impl(&, Box, Arc)]
4397pub trait PurgatoryRepository: Send + Sync {
4398 fn ingest(&self, input: IngestOrder) -> Result<PurgatoryOrder>;
4400
4401 fn get(&self, id: PurgatoryOrderId) -> Result<Option<PurgatoryOrder>>;
4403
4404 fn list(&self, filter: PurgatoryFilter) -> Result<Vec<PurgatoryOrder>>;
4406
4407 fn map_line(
4409 &self,
4410 id: PurgatoryOrderId,
4411 line_id: PurgatoryLineItemId,
4412 input: MapPurgatoryLine,
4413 ) -> Result<PurgatoryOrder>;
4414
4415 fn post(&self, id: PurgatoryOrderId) -> Result<PurgatoryOrder>;
4418
4419 fn delete(&self, id: PurgatoryOrderId) -> Result<()>;
4421}
4422
4423#[auto_impl::auto_impl(&, Box, Arc)]
4425pub trait PrintStationRepository: Send + Sync {
4426 fn pair(&self, input: CreatePrintStation) -> Result<PairStationResult>;
4428
4429 fn list_stations(&self) -> Result<Vec<PrintStation>>;
4431
4432 fn get_station(&self, id: PrintStationId) -> Result<Option<PrintStation>>;
4434
4435 fn revoke_station(&self, id: PrintStationId) -> Result<PrintStation>;
4437
4438 fn enqueue_job(&self, station_id: PrintStationId, input: EnqueuePrintJob) -> Result<PrintJob>;
4440
4441 fn next_job(&self, station_id: PrintStationId) -> Result<Option<PrintJob>>;
4445
4446 fn complete_job(&self, job_id: PrintJobId, success: bool) -> Result<PrintJob>;
4448
4449 fn list_jobs(
4451 &self,
4452 station_id: PrintStationId,
4453 filter: PrintJobFilter,
4454 ) -> Result<Vec<PrintJob>>;
4455}
4456
4457#[auto_impl::auto_impl(&, Box, Arc)]
4459pub trait EdiDocumentRepository: Send + Sync {
4460 fn create(&self, input: CreateEdiDocument) -> Result<EdiDocument>;
4462
4463 fn get(&self, id: EdiDocumentId) -> Result<Option<EdiDocument>>;
4465
4466 fn list(&self, filter: EdiDocumentFilter) -> Result<Vec<EdiDocument>>;
4468
4469 fn set_status(
4471 &self,
4472 id: EdiDocumentId,
4473 status: EdiStatus,
4474 error_message: Option<String>,
4475 ) -> Result<EdiDocument>;
4476
4477 fn summary(&self) -> Result<EdiAggregateSummary>;
4479}
4480
4481#[auto_impl::auto_impl(&, Box, Arc)]
4483pub trait IntegrationFieldMappingRepository: Send + Sync {
4484 fn create(&self, input: CreateIntegrationFieldMapping) -> Result<IntegrationFieldMapping>;
4486
4487 fn get(&self, id: IntegrationFieldMappingId) -> Result<Option<IntegrationFieldMapping>>;
4489
4490 fn update(
4492 &self,
4493 id: IntegrationFieldMappingId,
4494 input: UpdateIntegrationFieldMapping,
4495 ) -> Result<IntegrationFieldMapping>;
4496
4497 fn list(&self, filter: IntegrationFieldMappingFilter) -> Result<Vec<IntegrationFieldMapping>>;
4499
4500 fn delete(&self, id: IntegrationFieldMappingId) -> Result<()>;
4502
4503 fn bulk_create(&self, items: Vec<CreateIntegrationFieldMapping>) -> Result<u64>;
4505
4506 fn bulk_delete(&self, ids: Vec<IntegrationFieldMappingId>) -> Result<u64>;
4508
4509 fn distinct_groups(&self, integration_account: &str) -> Result<Vec<String>>;
4511}
4512
4513#[auto_impl::auto_impl(&, Box, Arc)]
4515pub trait TopologySnapshotRepository: Send + Sync {
4516 fn capture(&self, input: CaptureTopologySnapshot) -> Result<TopologySnapshot>;
4518
4519 fn get(&self, id: TopologySnapshotId) -> Result<Option<TopologySnapshot>>;
4521
4522 fn latest(&self) -> Result<Option<TopologySnapshot>>;
4524
4525 fn list(&self, filter: TopologySnapshotFilter) -> Result<Vec<TopologySnapshot>>;
4527
4528 fn delete(&self, id: TopologySnapshotId) -> Result<()>;
4530}
4531
4532#[auto_impl::auto_impl(&, Box, Arc)]
4534pub trait StockSnapshotRepository: Send + Sync {
4535 fn capture(&self, input: CaptureStockSnapshot) -> Result<StockSnapshot>;
4537
4538 fn get(&self, id: StockSnapshotId) -> Result<Option<StockSnapshot>>;
4540
4541 fn latest(&self) -> Result<Option<StockSnapshot>>;
4543
4544 fn list(&self, filter: StockSnapshotFilter) -> Result<Vec<StockSnapshot>>;
4546
4547 fn delete(&self, id: StockSnapshotId) -> Result<()>;
4549}
4550
4551use crate::models::{
4552 CreateFixedAsset, CreateRevenueContract, DepreciationSchedule, FixedAsset, FixedAssetFilter,
4553 PerformanceObligation, RevenueContract, RevenueContractFilter, RevenueSchedule,
4554 UpdateFixedAsset, UpdateRevenueContract,
4555};
4556
4557#[auto_impl::auto_impl(&, Box, Arc)]
4559pub trait FixedAssetRepository: Send + Sync {
4560 fn create(&self, input: CreateFixedAsset) -> Result<FixedAsset>;
4562
4563 fn get(&self, id: uuid::Uuid) -> Result<Option<FixedAsset>>;
4565
4566 fn list(&self, filter: FixedAssetFilter) -> Result<Vec<FixedAsset>>;
4568
4569 fn update(&self, id: uuid::Uuid, input: UpdateFixedAsset) -> Result<FixedAsset>;
4571
4572 fn place_in_service(&self, id: uuid::Uuid, date: chrono::NaiveDate) -> Result<FixedAsset>;
4574
4575 fn dispose(
4577 &self,
4578 id: uuid::Uuid,
4579 date: chrono::NaiveDate,
4580 proceeds: rust_decimal::Decimal,
4581 notes: Option<String>,
4582 ) -> Result<FixedAsset>;
4583
4584 fn write_off(
4586 &self,
4587 id: uuid::Uuid,
4588 date: chrono::NaiveDate,
4589 notes: Option<String>,
4590 ) -> Result<FixedAsset>;
4591
4592 fn generate_schedule(&self, id: uuid::Uuid) -> Result<DepreciationSchedule>;
4595
4596 fn get_schedule(&self, id: uuid::Uuid) -> Result<Option<DepreciationSchedule>>;
4598
4599 fn post_depreciation(&self, id: uuid::Uuid, periods: u32) -> Result<FixedAsset>;
4602}
4603
4604#[auto_impl::auto_impl(&, Box, Arc)]
4606pub trait RevenueRecognitionRepository: Send + Sync {
4607 fn create_contract(&self, input: CreateRevenueContract) -> Result<RevenueContract>;
4609
4610 fn get_contract(&self, id: uuid::Uuid) -> Result<Option<RevenueContract>>;
4612
4613 fn list_contracts(&self, filter: RevenueContractFilter) -> Result<Vec<RevenueContract>>;
4615
4616 fn update_contract(
4618 &self,
4619 id: uuid::Uuid,
4620 input: UpdateRevenueContract,
4621 ) -> Result<RevenueContract>;
4622
4623 fn list_obligations(&self, contract_id: uuid::Uuid) -> Result<Vec<PerformanceObligation>>;
4625
4626 fn generate_schedule(&self, obligation_id: uuid::Uuid) -> Result<RevenueSchedule>;
4629
4630 fn get_schedule(&self, obligation_id: uuid::Uuid) -> Result<Option<RevenueSchedule>>;
4632
4633 fn recognize_period(
4637 &self,
4638 obligation_id: uuid::Uuid,
4639 through: chrono::NaiveDate,
4640 ) -> Result<RevenueSchedule>;
4641}