pub mod repository;
pub use repository::{Repository, Transactional};
use crate::errors::{BatchResult, Result};
use crate::models::{
A2APurchase, A2APurchaseFilter, AddCartItem, AddCarton, AddCartonItem, AddLotCertificate,
AddShipmentEvent, AddWishlistItem, AddWorkOrderMaterial, AddressType, AdjustInventory,
AdjustLocationInventory, AdjustLot, AdjustPoints, AdjustStoreCredit, AgentCard,
AgentCardFilter, AgentFeedback, AgentFeedbackFilter, AgentFeedbackResponse, AgentIdentity,
AgentIdentityFilter, AgentMetadataEntry, AgentValidationRequest, AgentValidationResponse,
AgentValidationStatus, AgentWalletProofType, AllocateBackorder, AnalyticsQuery, ApAgingSummary,
ApplyCreditMemo, ApplyPaymentToInvoices, ApplyPromotionsRequest, ApplyPromotionsResult,
ArAgingFilter, ArAgingSummary, ArPaymentApplication, AutoPostingConfig, Backorder,
BackorderAllocation, BackorderFilter, BackorderFulfillment, BackorderSummary, BalanceSheet,
Bill, BillFilter, BillItem, BillOfMaterials, BillPayment, BillPaymentFilter, BillingCycle,
BillingCycleFilter, BillingCycleStatus, BomComponent, BomFilter, CancelSubscription, Cart,
CartAddress, CartFilter, CartItem, Carton, CartonItem, ChangeSerialStatus, CheckoutResult,
ClaimResolution, CollectionActivity, CollectionActivityFilter, CollectionStatus, CompletePick,
CompletePutAway, CompleteShip, ConsumeLot, ConversionResult, ConvertCurrency, CostAdjustment,
CostAdjustmentFilter, CostLayer, CostLayerFilter, CostMethod, CostRollup, CostTransaction,
CostTransactionFilter, CostTransactionType, CostVariance, CostVarianceFilter, CouponCode,
CouponFilter, CreateA2APurchase, CreateA2AQuote, CreateAgentCard, CreateAgentFeedback,
CreateAgentFeedbackResponse, CreateAgentIdentity, CreateAgentValidationRequest,
CreateAgentValidationResponse, CreateAutoPostingConfig, CreateBackorder, CreateBill,
CreateBillItem, CreateBillPayment, CreateBillingCycle, CreateBom, CreateBomComponent,
CreateCart, CreateCollectionActivity, CreateCostAdjustment, CreateCostLayer, CreateCouponCode,
CreateCreditAccount, CreateCreditMemo, CreateCustomObject, CreateCustomObjectType,
CreateCustomer, CreateCustomerAddress, CreateCycleCount, CreateDefectCode,
CreateFraudAssessment, CreateFraudRule, CreateGiftCard, CreateGlAccount, CreateGlPeriod,
CreateInspection, CreateInventoryItem, CreateInvoice, CreateInvoiceItem, CreateJournalEntry,
CreateLocation, CreateLot, CreateLoyaltyProgram, CreateNonConformance, CreateOrder,
CreateOrderItem, CreatePackTask, CreatePayment, CreatePaymentMethod, CreatePaymentRun,
CreatePickTask, CreateProduct, CreateProductVariant, CreatePromotion, CreatePurchaseOrder,
CreatePurchaseOrderItem, CreatePutAway, CreateQualityHold, CreateReceipt, CreateRefund,
CreateReturn, CreateReview, CreateReward, CreateSearchConfig, CreateSegment,
CreateSerialNumber, CreateSerialNumbersBulk, CreateShipTask, CreateShipment,
CreateShipmentItem, CreateShippingZone, CreateStoreCredit, CreateSubscription,
CreateSubscriptionPlan, CreateSupplier, CreateTaxExemption, CreateTaxJurisdiction,
CreateTaxRate, CreateWarehouse, CreateWarranty, CreateWarrantyClaim, CreateWave,
CreateWishlist, CreateWorkOrder, CreateWorkOrderTask, CreateWriteOff, CreateX402PaymentIntent,
CreateZone, CreateZoneShippingMethod, CreditAccount, CreditAccountFilter, CreditAgingBucket,
CreditApplication, CreditApplicationFilter, CreditCheckResult, CreditHold, CreditHoldFilter,
CreditMemo, CreditMemoFilter, CreditTransaction, CreditTransactionFilter, Currency,
CustomObject, CustomObjectFilter, CustomObjectType, CustomObjectTypeFilter, Customer,
CustomerAddress, CustomerArAging, CustomerArSummary, CustomerCreditSummary, CustomerFilter,
CustomerMetrics, CustomerStatement, CycleCount, CycleCountFilter, DefectCode, DemandForecast,
DunningLetterType, EmbeddingMetadata, EmbeddingStats, EnrollCustomer, EntityType, ExchangeRate,
ExchangeRateFilter, FeedbackSummary, FraudAssessment, FraudAssessmentFilter, FraudDecision,
FraudRule, FraudRuleFilter, FulfillBackorder, FulfillmentMetrics, GenerateStatementRequest,
GiftCard, GiftCardFilter, GiftCardTransaction, GlAccount, GlAccountFilter, GlPeriod,
GlPeriodFilter, IncomeStatement, Inspection, InspectionFilter, InspectionItem,
InventoryBalance, InventoryFilter, InventoryHealth, InventoryItem, InventoryMovement,
InventoryReservation, InventoryTransaction, InventoryValuation, Invoice, InvoiceFilter,
InvoiceItem, IssueCostLayers, ItemCost, ItemCostFilter, JournalEntry, JournalEntryFilter,
JournalEntryLine, Location, LocationFilter, LocationInventory, LocationInventoryFilter,
LocationMovement, Lot, LotCertificate, LotFilter, LotLocation, LotTransaction, LowStockItem,
LoyaltyAccount, LoyaltyAccountFilter, LoyaltyProgram, LoyaltyTransaction, MergeLots,
MoveInventory, MoveSerial, MovementFilter, NonConformance, NonConformanceFilter, Order,
OrderFilter, OrderItem, OrderStatusBreakdown, PackTask, PackTaskFilter, PauseSubscription,
Payment, PaymentAllocation, PaymentFilter, PaymentMethod, PaymentRun, PaymentRunFilter,
PickTask, PickTaskFilter, PlaceCreditHold, Product, ProductFilter, ProductPerformance,
ProductTaxCategory, ProductVariant, Promotion, PromotionFilter, PromotionUsage, PurchaseOrder,
PurchaseOrderFilter, PurchaseOrderItem, PurchaseStatus, PutAway, PutAwayFilter, QualityHold,
QualityHoldFilter, QuoteStatus, Receipt, ReceiptFilter, ReceiptItem, ReceiveItems,
ReceivePurchaseOrderItems, RecordCostVariance, RecordCreditTransaction, RecordCycleCountLine,
RecordInspectionResult, RecordInvoicePayment, Refund, ReleaseCreditHold, ReleaseQualityHold,
ReserveInventory, ReserveLot, ReserveSerialNumber, Return, ReturnFilter, ReturnMetrics,
RevaluationResult, RevenueByPeriod, RevenueForecast, Review, ReviewCreditApplication,
ReviewFilter, ReviewSummary, Reward, RewardFilter, SalesSummary, SearchConfig,
SearchConfigFilter, Segment, SegmentFilter, SegmentMembership, SerialFilter, SerialHistory,
SerialHistoryFilter, SerialLookupResult, SerialNumber, SerialReservation, SerialValidation,
SetCartPayment, SetCartShipping, SetCartX402Payment, SetExchangeRate, SetItemCost, ShipTask,
ShipTaskFilter, Shipment, ShipmentEvent, ShipmentFilter, ShipmentItem, ShippingRate,
ShippingZone, ShippingZoneFilter, SignX402PaymentIntent, SkillQuote, SkillQuoteFilter,
SkipBillingCycle, SkuBackorderSummary, SkuCostSummary, SplitLot, StockLevel, StoreCredit,
StoreCreditFilter, StoreCreditTransaction, StoreCurrencySettings, SubmitCreditApplication,
Subscription, SubscriptionEvent, SubscriptionEventType, SubscriptionFilter, SubscriptionPlan,
SubscriptionPlanFilter, Supplier, SupplierApSummary, SupplierFilter, TaxAddress,
TaxCalculationRequest, TaxCalculationResult, TaxExemption, TaxJurisdiction,
TaxJurisdictionFilter, TaxRate, TaxRateFilter, TaxSettings, TimeGranularity, TopCustomer,
TopProduct, TraceabilityResult, TransferLot, TransferSerialOwnership, TrialBalance, TrustLevel,
UpdateAgentCard, UpdateAgentIdentity, UpdateBackorder, UpdateBill, UpdateBom, UpdateCart,
UpdateCartItem, UpdateCreditAccount, UpdateCustomObject, UpdateCustomObjectType,
UpdateCustomer, UpdateFraudRule, UpdateGiftCard, UpdateGlAccount, UpdateInspection,
UpdateInvoice, UpdateLocation, UpdateLot, UpdateNonConformance, UpdateOrder, UpdatePayment,
UpdateProduct, UpdatePromotion, UpdatePurchaseOrder, UpdateReceipt, UpdateReturn, UpdateReview,
UpdateSearchConfig, UpdateSegment, UpdateSerialNumber, UpdateShipment, UpdateShippingZone,
UpdateSubscription, UpdateSubscriptionPlan, UpdateSupplier, UpdateWarehouse, UpdateWarranty,
UpdateWarrantyClaim, UpdateWishlist, UpdateWorkOrder, UpdateWorkOrderTask, UpdateZone,
ValidationSummary, VectorSearchResult, Warehouse, WarehouseFilter, Warranty, WarrantyClaim,
WarrantyClaimFilter, WarrantyFilter, Wave, WaveFilter, Wishlist, WishlistFilter, WishlistItem,
WorkOrder, WorkOrderFilter, WorkOrderMaterial, WorkOrderTask, WriteOff, WriteOffFilter,
X402Asset, X402CheckoutResult, X402CreditAccount, X402CreditAdjustment, X402CreditTransaction,
X402CreditTransactionFilter, X402Network, X402PaymentIntent, X402PaymentIntentFilter, Zone,
ZoneShippingMethod, ZoneShippingMethodFilter, ZoneShippingRate, ZoneShippingRateRequest,
};
use crate::models::{
ActivityLogEntry, ActivityLogFilter, ApplyPrepayment, ApplyVendorCredit, BulkSupplierSkuItem,
CaptureStockSnapshot, CaptureTopologySnapshot, CreateEdiDocument, CreateInboundShipment,
CreateIntegrationFieldMapping, CreateIntegrationMapping, CreatePaymentObligation,
CreatePrepayment, CreatePriceLevel, CreatePriceSchedule, CreatePrintStation, CreateSupplierSku,
CreateVendorCredit, CreateVendorReturn, EdiAggregateSummary, EdiDocument, EdiDocumentFilter,
EdiStatus, EnqueuePrintJob, InboundShipment, InboundShipmentFilter, IngestOrder,
IntegrationFieldMapping, IntegrationFieldMappingFilter, IntegrationMapping,
IntegrationMappingFilter, MapPurgatoryLine, MappingLookup, PairStationResult,
PaymentObligation, PaymentObligationDashboard, PaymentObligationFilter,
PaymentObligationStatus, Prepayment, PrepaymentApplication, PrepaymentFilter, PriceLevel,
PriceLevelEntry, PriceLevelFilter, PriceSchedule, PriceScheduleEntry, PriceScheduleFilter,
PrintJob, PrintJobFilter, PrintStation, PurgatoryFilter, PurgatoryOrder, RecordActivity,
StockSnapshot, StockSnapshotFilter, SupplierSku, SupplierSkuFilter, TopologySnapshot,
TopologySnapshotFilter, UpdateIntegrationFieldMapping, UpdateIntegrationMapping,
UpdatePriceLevel, UpdatePriceSchedule, UpdateSupplierSku, VendorCredit,
VendorCreditApplication, VendorCreditFilter, VendorReturn, VendorReturnFilter,
};
use crate::models::{
Channel, ChannelFilter, ChannelProductMapping, ChannelProductSyncItem, Company, CompanyFilter,
CompanyPriceOverride, CompanyShippingAddress, Contact, CreateChannel, CreateCompany,
CreateContact, CreateProductionBatch, CreateTransferOrder, CreateUnitClass,
CreateUnitConversionRule, CreateUnitOfMeasure, ProductionBatch, ProductionBatchFilter,
TransferOrder, TransferOrderFilter, UnitClass, UnitConversionRule, UnitOfMeasure,
UnitOfMeasureFilter, UpdateChannel, UpdateCompany, UpdateProductionBatch,
};
use chrono::{DateTime, Utc};
use stateset_primitives::{
ActivityLogId, ChannelId, CompanyId, ContactId, EdiDocumentId, InboundShipmentId,
InboundShipmentItemId, IntegrationFieldMappingId, IntegrationMappingId, PaymentObligationId,
PrepaymentApplicationId, PrepaymentId, PriceLevelId, PriceScheduleId, PrintJobId,
PrintStationId, ProductionBatchId, PurgatoryLineItemId, PurgatoryOrderId, StockSnapshotId,
SupplierSkuId, TopologySnapshotId, TransferOrderId, TransferOrderItemId, UnitClassId,
UnitConversionRuleId, UnitOfMeasureId, VendorCreditApplicationId, VendorCreditId,
VendorReturnId,
};
use stateset_primitives::{
CartId, CreditId, CustomerId, FraudRuleId, FulfillmentId, GiftCardId, InvoiceId,
LoyaltyAccountId, LoyaltyProgramId, OrderId, OrderItemId, PaymentId, ProductId, PromotionId,
PurchaseOrderId, ReturnId, ReviewId, RewardId, SearchConfigId, SegmentId, ShipmentId,
ShippingMethodId, ShippingZoneId, StoreCreditId, SubscriptionId, WarrantyId, WishlistId,
};
use uuid::Uuid;
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait OrderRepository: Send + Sync {
fn create(&self, input: CreateOrder) -> Result<Order>;
fn get(&self, id: OrderId) -> Result<Option<Order>>;
fn get_by_number(&self, order_number: &str) -> Result<Option<Order>>;
fn update(&self, id: OrderId, input: UpdateOrder) -> Result<Order>;
fn list(&self, filter: OrderFilter) -> Result<Vec<Order>>;
fn delete(&self, id: OrderId) -> Result<()>;
fn add_item(&self, order_id: OrderId, item: CreateOrderItem) -> Result<OrderItem>;
fn remove_item(&self, order_id: OrderId, item_id: OrderItemId) -> Result<()>;
fn count(&self, filter: OrderFilter) -> Result<u64>;
fn create_batch(&self, inputs: Vec<CreateOrder>) -> Result<BatchResult<Order>>;
fn create_batch_atomic(&self, inputs: Vec<CreateOrder>) -> Result<Vec<Order>>;
fn update_batch(&self, updates: Vec<(OrderId, UpdateOrder)>) -> Result<BatchResult<Order>>;
fn update_batch_atomic(&self, updates: Vec<(OrderId, UpdateOrder)>) -> Result<Vec<Order>>;
fn delete_batch(&self, ids: Vec<OrderId>) -> Result<BatchResult<OrderId>>;
fn delete_batch_atomic(&self, ids: Vec<OrderId>) -> Result<()>;
fn get_batch(&self, ids: Vec<OrderId>) -> Result<Vec<Order>>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait InventoryRepository: Send + Sync {
fn create_item(&self, input: CreateInventoryItem) -> Result<InventoryItem>;
fn get_item(&self, id: i64) -> Result<Option<InventoryItem>>;
fn get_item_by_sku(&self, sku: &str) -> Result<Option<InventoryItem>>;
fn get_stock(&self, sku: &str) -> Result<Option<StockLevel>>;
fn get_balance(&self, item_id: i64, location_id: i32) -> Result<Option<InventoryBalance>>;
fn adjust(&self, input: AdjustInventory) -> Result<InventoryTransaction>;
fn reserve(&self, input: ReserveInventory) -> Result<InventoryReservation>;
fn get_reservation(&self, reservation_id: Uuid) -> Result<Option<InventoryReservation>>;
fn release_reservation(&self, reservation_id: Uuid) -> Result<()>;
fn confirm_reservation(&self, reservation_id: Uuid) -> Result<()>;
fn list_reservations_by_reference(
&self,
reference_type: &str,
reference_id: &str,
) -> Result<Vec<InventoryReservation>>;
fn list(&self, filter: InventoryFilter) -> Result<Vec<InventoryItem>>;
fn get_reorder_needed(&self) -> Result<Vec<StockLevel>>;
fn record_transaction(&self, transaction: InventoryTransaction)
-> Result<InventoryTransaction>;
fn get_transactions(&self, item_id: i64, limit: u32) -> Result<Vec<InventoryTransaction>>;
fn create_item_batch(
&self,
inputs: Vec<CreateInventoryItem>,
) -> Result<BatchResult<InventoryItem>>;
fn create_item_batch_atomic(
&self,
inputs: Vec<CreateInventoryItem>,
) -> Result<Vec<InventoryItem>>;
fn adjust_batch(
&self,
adjustments: Vec<AdjustInventory>,
) -> Result<BatchResult<InventoryTransaction>>;
fn adjust_batch_atomic(
&self,
adjustments: Vec<AdjustInventory>,
) -> Result<Vec<InventoryTransaction>>;
fn get_item_batch(&self, ids: Vec<i64>) -> Result<Vec<InventoryItem>>;
fn get_stock_batch(&self, skus: Vec<String>) -> Result<Vec<StockLevel>>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait CustomerRepository: Send + Sync {
fn create(&self, input: CreateCustomer) -> Result<Customer>;
fn get(&self, id: CustomerId) -> Result<Option<Customer>>;
fn get_by_email(&self, email: &str) -> Result<Option<Customer>>;
fn update(&self, id: CustomerId, input: UpdateCustomer) -> Result<Customer>;
fn list(&self, filter: CustomerFilter) -> Result<Vec<Customer>>;
fn delete(&self, id: CustomerId) -> Result<()>;
fn add_address(&self, input: CreateCustomerAddress) -> Result<CustomerAddress>;
fn get_addresses(&self, customer_id: CustomerId) -> Result<Vec<CustomerAddress>>;
fn update_address(
&self,
address_id: Uuid,
input: CreateCustomerAddress,
) -> Result<CustomerAddress>;
fn delete_address(&self, address_id: Uuid) -> Result<()>;
fn set_default_address(
&self,
customer_id: CustomerId,
address_id: Uuid,
address_type: AddressType,
) -> Result<()>;
fn count(&self, filter: CustomerFilter) -> Result<u64>;
fn create_batch(&self, inputs: Vec<CreateCustomer>) -> Result<BatchResult<Customer>>;
fn create_batch_atomic(&self, inputs: Vec<CreateCustomer>) -> Result<Vec<Customer>>;
fn update_batch(
&self,
updates: Vec<(CustomerId, UpdateCustomer)>,
) -> Result<BatchResult<Customer>>;
fn update_batch_atomic(
&self,
updates: Vec<(CustomerId, UpdateCustomer)>,
) -> Result<Vec<Customer>>;
fn delete_batch(&self, ids: Vec<CustomerId>) -> Result<BatchResult<CustomerId>>;
fn delete_batch_atomic(&self, ids: Vec<CustomerId>) -> Result<()>;
fn get_batch(&self, ids: Vec<CustomerId>) -> Result<Vec<Customer>>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait ProductRepository: Send + Sync {
fn create(&self, input: CreateProduct) -> Result<Product>;
fn get(&self, id: ProductId) -> Result<Option<Product>>;
fn get_by_slug(&self, slug: &str) -> Result<Option<Product>>;
fn update(&self, id: ProductId, input: UpdateProduct) -> Result<Product>;
fn list(&self, filter: ProductFilter) -> Result<Vec<Product>>;
fn delete(&self, id: ProductId) -> Result<()>;
fn add_variant(
&self,
product_id: ProductId,
variant: CreateProductVariant,
) -> Result<ProductVariant>;
fn get_variant(&self, id: Uuid) -> Result<Option<ProductVariant>>;
fn get_variant_by_sku(&self, sku: &str) -> Result<Option<ProductVariant>>;
fn update_variant(&self, id: Uuid, variant: CreateProductVariant) -> Result<ProductVariant>;
fn delete_variant(&self, id: Uuid) -> Result<()>;
fn get_variants(&self, product_id: ProductId) -> Result<Vec<ProductVariant>>;
fn count(&self, filter: ProductFilter) -> Result<u64>;
fn create_batch(&self, inputs: Vec<CreateProduct>) -> Result<BatchResult<Product>>;
fn create_batch_atomic(&self, inputs: Vec<CreateProduct>) -> Result<Vec<Product>>;
fn update_batch(
&self,
updates: Vec<(ProductId, UpdateProduct)>,
) -> Result<BatchResult<Product>>;
fn update_batch_atomic(&self, updates: Vec<(ProductId, UpdateProduct)>)
-> Result<Vec<Product>>;
fn delete_batch(&self, ids: Vec<ProductId>) -> Result<BatchResult<ProductId>>;
fn delete_batch_atomic(&self, ids: Vec<ProductId>) -> Result<()>;
fn get_batch(&self, ids: Vec<ProductId>) -> Result<Vec<Product>>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait ReturnRepository: Send + Sync {
fn create(&self, input: CreateReturn) -> Result<Return>;
fn get(&self, id: ReturnId) -> Result<Option<Return>>;
fn update(&self, id: ReturnId, input: UpdateReturn) -> Result<Return>;
fn list(&self, filter: ReturnFilter) -> Result<Vec<Return>>;
fn approve(&self, id: ReturnId) -> Result<Return>;
fn reject(&self, id: ReturnId, reason: &str) -> Result<Return>;
fn complete(&self, id: ReturnId) -> Result<Return>;
fn cancel(&self, id: ReturnId) -> Result<Return>;
fn count(&self, filter: ReturnFilter) -> Result<u64>;
fn create_batch(&self, inputs: Vec<CreateReturn>) -> Result<BatchResult<Return>>;
fn create_batch_atomic(&self, inputs: Vec<CreateReturn>) -> Result<Vec<Return>>;
fn update_batch(&self, updates: Vec<(ReturnId, UpdateReturn)>) -> Result<BatchResult<Return>>;
fn update_batch_atomic(&self, updates: Vec<(ReturnId, UpdateReturn)>) -> Result<Vec<Return>>;
fn delete_batch(&self, ids: Vec<ReturnId>) -> Result<BatchResult<Uuid>>;
fn delete_batch_atomic(&self, ids: Vec<ReturnId>) -> Result<()>;
fn get_batch(&self, ids: Vec<ReturnId>) -> Result<Vec<Return>>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait EventHandler: Send + Sync {
fn handle(&self, event: &crate::events::CommerceEvent) -> Result<()>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait BomRepository: Send + Sync {
fn create(&self, input: CreateBom) -> Result<BillOfMaterials>;
fn get(&self, id: Uuid) -> Result<Option<BillOfMaterials>>;
fn get_by_number(&self, bom_number: &str) -> Result<Option<BillOfMaterials>>;
fn update(&self, id: Uuid, input: UpdateBom) -> Result<BillOfMaterials>;
fn list(&self, filter: BomFilter) -> Result<Vec<BillOfMaterials>>;
fn delete(&self, id: Uuid) -> Result<()>;
fn add_component(&self, bom_id: Uuid, component: CreateBomComponent) -> Result<BomComponent>;
fn update_component(
&self,
component_id: Uuid,
component: CreateBomComponent,
) -> Result<BomComponent>;
fn remove_component(&self, component_id: Uuid) -> Result<()>;
fn get_components(&self, bom_id: Uuid) -> Result<Vec<BomComponent>>;
fn activate(&self, id: Uuid) -> Result<BillOfMaterials>;
fn count(&self, filter: BomFilter) -> Result<u64>;
fn create_batch(&self, inputs: Vec<CreateBom>) -> Result<BatchResult<BillOfMaterials>>;
fn create_batch_atomic(&self, inputs: Vec<CreateBom>) -> Result<Vec<BillOfMaterials>>;
fn update_batch(&self, updates: Vec<(Uuid, UpdateBom)>)
-> Result<BatchResult<BillOfMaterials>>;
fn update_batch_atomic(&self, updates: Vec<(Uuid, UpdateBom)>) -> Result<Vec<BillOfMaterials>>;
fn delete_batch(&self, ids: Vec<Uuid>) -> Result<BatchResult<Uuid>>;
fn delete_batch_atomic(&self, ids: Vec<Uuid>) -> Result<()>;
fn get_batch(&self, ids: Vec<Uuid>) -> Result<Vec<BillOfMaterials>>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait WorkOrderRepository: Send + Sync {
fn create(&self, input: CreateWorkOrder) -> Result<WorkOrder>;
fn get(&self, id: Uuid) -> Result<Option<WorkOrder>>;
fn get_by_number(&self, work_order_number: &str) -> Result<Option<WorkOrder>>;
fn update(&self, id: Uuid, input: UpdateWorkOrder) -> Result<WorkOrder>;
fn list(&self, filter: WorkOrderFilter) -> Result<Vec<WorkOrder>>;
fn delete(&self, id: Uuid) -> Result<()>;
fn start(&self, id: Uuid) -> Result<WorkOrder>;
fn complete(&self, id: Uuid, quantity_completed: rust_decimal::Decimal) -> Result<WorkOrder>;
fn hold(&self, id: Uuid) -> Result<WorkOrder>;
fn resume(&self, id: Uuid) -> Result<WorkOrder>;
fn cancel(&self, id: Uuid) -> Result<WorkOrder>;
fn add_task(&self, work_order_id: Uuid, task: CreateWorkOrderTask) -> Result<WorkOrderTask>;
fn update_task(&self, task_id: Uuid, task: UpdateWorkOrderTask) -> Result<WorkOrderTask>;
fn remove_task(&self, task_id: Uuid) -> Result<()>;
fn get_tasks(&self, work_order_id: Uuid) -> Result<Vec<WorkOrderTask>>;
fn start_task(&self, task_id: Uuid) -> Result<WorkOrderTask>;
fn complete_task(
&self,
task_id: Uuid,
actual_hours: Option<rust_decimal::Decimal>,
) -> Result<WorkOrderTask>;
fn add_material(
&self,
work_order_id: Uuid,
material: AddWorkOrderMaterial,
) -> Result<WorkOrderMaterial>;
fn consume_material(
&self,
material_id: Uuid,
quantity: rust_decimal::Decimal,
) -> Result<WorkOrderMaterial>;
fn get_materials(&self, work_order_id: Uuid) -> Result<Vec<WorkOrderMaterial>>;
fn count(&self, filter: WorkOrderFilter) -> Result<u64>;
fn create_batch(&self, inputs: Vec<CreateWorkOrder>) -> Result<BatchResult<WorkOrder>>;
fn create_batch_atomic(&self, inputs: Vec<CreateWorkOrder>) -> Result<Vec<WorkOrder>>;
fn update_batch(&self, updates: Vec<(Uuid, UpdateWorkOrder)>)
-> Result<BatchResult<WorkOrder>>;
fn update_batch_atomic(&self, updates: Vec<(Uuid, UpdateWorkOrder)>) -> Result<Vec<WorkOrder>>;
fn delete_batch(&self, ids: Vec<Uuid>) -> Result<BatchResult<Uuid>>;
fn delete_batch_atomic(&self, ids: Vec<Uuid>) -> Result<()>;
fn get_batch(&self, ids: Vec<Uuid>) -> Result<Vec<WorkOrder>>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait ShipmentRepository: Send + Sync {
fn create(&self, input: CreateShipment) -> Result<Shipment>;
fn get(&self, id: ShipmentId) -> Result<Option<Shipment>>;
fn get_by_number(&self, shipment_number: &str) -> Result<Option<Shipment>>;
fn get_by_tracking(&self, tracking_number: &str) -> Result<Option<Shipment>>;
fn update(&self, id: ShipmentId, input: UpdateShipment) -> Result<Shipment>;
fn list(&self, filter: ShipmentFilter) -> Result<Vec<Shipment>>;
fn for_order(&self, order_id: OrderId) -> Result<Vec<Shipment>>;
fn delete(&self, id: ShipmentId) -> Result<()>;
fn mark_processing(&self, id: ShipmentId) -> Result<Shipment>;
fn mark_ready(&self, id: ShipmentId) -> Result<Shipment>;
fn ship(&self, id: ShipmentId, tracking_number: Option<String>) -> Result<Shipment>;
fn mark_in_transit(&self, id: ShipmentId) -> Result<Shipment>;
fn mark_out_for_delivery(&self, id: ShipmentId) -> Result<Shipment>;
fn mark_delivered(&self, id: ShipmentId) -> Result<Shipment>;
fn mark_failed(&self, id: ShipmentId) -> Result<Shipment>;
fn hold(&self, id: ShipmentId) -> Result<Shipment>;
fn cancel(&self, id: ShipmentId) -> Result<Shipment>;
fn add_item(&self, shipment_id: ShipmentId, item: CreateShipmentItem) -> Result<ShipmentItem>;
fn remove_item(&self, item_id: Uuid) -> Result<()>;
fn get_items(&self, shipment_id: ShipmentId) -> Result<Vec<ShipmentItem>>;
fn add_event(&self, shipment_id: ShipmentId, event: AddShipmentEvent) -> Result<ShipmentEvent>;
fn get_events(&self, shipment_id: ShipmentId) -> Result<Vec<ShipmentEvent>>;
fn count(&self, filter: ShipmentFilter) -> Result<u64>;
fn create_batch(&self, inputs: Vec<CreateShipment>) -> Result<BatchResult<Shipment>>;
fn create_batch_atomic(&self, inputs: Vec<CreateShipment>) -> Result<Vec<Shipment>>;
fn update_batch(
&self,
updates: Vec<(ShipmentId, UpdateShipment)>,
) -> Result<BatchResult<Shipment>>;
fn update_batch_atomic(
&self,
updates: Vec<(ShipmentId, UpdateShipment)>,
) -> Result<Vec<Shipment>>;
fn delete_batch(&self, ids: Vec<ShipmentId>) -> Result<BatchResult<Uuid>>;
fn delete_batch_atomic(&self, ids: Vec<ShipmentId>) -> Result<()>;
fn get_batch(&self, ids: Vec<ShipmentId>) -> Result<Vec<Shipment>>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait PaymentRepository: Send + Sync {
fn create(&self, input: CreatePayment) -> Result<Payment>;
fn get(&self, id: PaymentId) -> Result<Option<Payment>>;
fn get_by_number(&self, payment_number: &str) -> Result<Option<Payment>>;
fn get_by_external_id(&self, external_id: &str) -> Result<Option<Payment>>;
fn update(&self, id: PaymentId, input: UpdatePayment) -> Result<Payment>;
fn list(&self, filter: PaymentFilter) -> Result<Vec<Payment>>;
fn for_order(&self, order_id: OrderId) -> Result<Vec<Payment>>;
fn for_invoice(&self, invoice_id: InvoiceId) -> Result<Vec<Payment>>;
fn mark_processing(&self, id: PaymentId) -> Result<Payment>;
fn mark_completed(&self, id: PaymentId) -> Result<Payment>;
fn mark_failed(&self, id: PaymentId, reason: &str, code: Option<&str>) -> Result<Payment>;
fn cancel(&self, id: PaymentId) -> Result<Payment>;
fn create_refund(&self, input: CreateRefund) -> Result<Refund>;
fn get_refund(&self, id: Uuid) -> Result<Option<Refund>>;
fn get_refunds(&self, payment_id: PaymentId) -> Result<Vec<Refund>>;
fn complete_refund(&self, id: Uuid) -> Result<Refund>;
fn fail_refund(&self, id: Uuid, reason: &str) -> Result<Refund>;
fn create_payment_method(&self, input: CreatePaymentMethod) -> Result<PaymentMethod>;
fn get_payment_methods(&self, customer_id: CustomerId) -> Result<Vec<PaymentMethod>>;
fn delete_payment_method(&self, id: Uuid) -> Result<()>;
fn set_default_payment_method(&self, customer_id: CustomerId, method_id: Uuid) -> Result<()>;
fn count(&self, filter: PaymentFilter) -> Result<u64>;
fn create_batch(&self, inputs: Vec<CreatePayment>) -> Result<BatchResult<Payment>>;
fn create_batch_atomic(&self, inputs: Vec<CreatePayment>) -> Result<Vec<Payment>>;
fn update_batch(
&self,
updates: Vec<(PaymentId, UpdatePayment)>,
) -> Result<BatchResult<Payment>>;
fn update_batch_atomic(&self, updates: Vec<(PaymentId, UpdatePayment)>)
-> Result<Vec<Payment>>;
fn delete_batch(&self, ids: Vec<PaymentId>) -> Result<BatchResult<Uuid>>;
fn delete_batch_atomic(&self, ids: Vec<PaymentId>) -> Result<()>;
fn get_batch(&self, ids: Vec<PaymentId>) -> Result<Vec<Payment>>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait WarrantyRepository: Send + Sync {
fn create(&self, input: CreateWarranty) -> Result<Warranty>;
fn get(&self, id: WarrantyId) -> Result<Option<Warranty>>;
fn get_by_number(&self, warranty_number: &str) -> Result<Option<Warranty>>;
fn get_by_serial(&self, serial_number: &str) -> Result<Option<Warranty>>;
fn update(&self, id: WarrantyId, input: UpdateWarranty) -> Result<Warranty>;
fn list(&self, filter: WarrantyFilter) -> Result<Vec<Warranty>>;
fn for_customer(&self, customer_id: CustomerId) -> Result<Vec<Warranty>>;
fn for_order(&self, order_id: OrderId) -> Result<Vec<Warranty>>;
fn void(&self, id: WarrantyId) -> Result<Warranty>;
fn expire(&self, id: WarrantyId) -> Result<Warranty>;
fn transfer(&self, id: WarrantyId, new_customer_id: CustomerId) -> Result<Warranty>;
fn create_claim(&self, input: CreateWarrantyClaim) -> Result<WarrantyClaim>;
fn get_claim(&self, id: Uuid) -> Result<Option<WarrantyClaim>>;
fn get_claim_by_number(&self, claim_number: &str) -> Result<Option<WarrantyClaim>>;
fn update_claim(&self, id: Uuid, input: UpdateWarrantyClaim) -> Result<WarrantyClaim>;
fn list_claims(&self, filter: WarrantyClaimFilter) -> Result<Vec<WarrantyClaim>>;
fn get_claims(&self, warranty_id: WarrantyId) -> Result<Vec<WarrantyClaim>>;
fn approve_claim(&self, id: Uuid) -> Result<WarrantyClaim>;
fn deny_claim(&self, id: Uuid, reason: &str) -> Result<WarrantyClaim>;
fn complete_claim(&self, id: Uuid, resolution: ClaimResolution) -> Result<WarrantyClaim>;
fn cancel_claim(&self, id: Uuid) -> Result<WarrantyClaim>;
fn count(&self, filter: WarrantyFilter) -> Result<u64>;
fn count_claims(&self, filter: WarrantyClaimFilter) -> Result<u64>;
fn create_batch(&self, inputs: Vec<CreateWarranty>) -> Result<BatchResult<Warranty>>;
fn create_batch_atomic(&self, inputs: Vec<CreateWarranty>) -> Result<Vec<Warranty>>;
fn update_batch(
&self,
updates: Vec<(WarrantyId, UpdateWarranty)>,
) -> Result<BatchResult<Warranty>>;
fn update_batch_atomic(
&self,
updates: Vec<(WarrantyId, UpdateWarranty)>,
) -> Result<Vec<Warranty>>;
fn delete_batch(&self, ids: Vec<WarrantyId>) -> Result<BatchResult<Uuid>>;
fn delete_batch_atomic(&self, ids: Vec<WarrantyId>) -> Result<()>;
fn get_batch(&self, ids: Vec<WarrantyId>) -> Result<Vec<Warranty>>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait PurchaseOrderRepository: Send + Sync {
fn create_supplier(&self, input: CreateSupplier) -> Result<Supplier>;
fn get_supplier(&self, id: Uuid) -> Result<Option<Supplier>>;
fn get_supplier_by_code(&self, code: &str) -> Result<Option<Supplier>>;
fn update_supplier(&self, id: Uuid, input: UpdateSupplier) -> Result<Supplier>;
fn list_suppliers(&self, filter: SupplierFilter) -> Result<Vec<Supplier>>;
fn delete_supplier(&self, id: Uuid) -> Result<()>;
fn create(&self, input: CreatePurchaseOrder) -> Result<PurchaseOrder>;
fn get(&self, id: PurchaseOrderId) -> Result<Option<PurchaseOrder>>;
fn get_by_number(&self, po_number: &str) -> Result<Option<PurchaseOrder>>;
fn update(&self, id: PurchaseOrderId, input: UpdatePurchaseOrder) -> Result<PurchaseOrder>;
fn list(&self, filter: PurchaseOrderFilter) -> Result<Vec<PurchaseOrder>>;
fn for_supplier(&self, supplier_id: Uuid) -> Result<Vec<PurchaseOrder>>;
fn delete(&self, id: PurchaseOrderId) -> Result<()>;
fn submit_for_approval(&self, id: PurchaseOrderId) -> Result<PurchaseOrder>;
fn approve(&self, id: PurchaseOrderId, approved_by: &str) -> Result<PurchaseOrder>;
fn send(&self, id: PurchaseOrderId) -> Result<PurchaseOrder>;
fn acknowledge(
&self,
id: PurchaseOrderId,
supplier_reference: Option<&str>,
) -> Result<PurchaseOrder>;
fn hold(&self, id: PurchaseOrderId) -> Result<PurchaseOrder>;
fn cancel(&self, id: PurchaseOrderId) -> Result<PurchaseOrder>;
fn receive(
&self,
id: PurchaseOrderId,
items: ReceivePurchaseOrderItems,
) -> Result<PurchaseOrder>;
fn complete(&self, id: PurchaseOrderId) -> Result<PurchaseOrder>;
fn add_item(
&self,
po_id: PurchaseOrderId,
item: CreatePurchaseOrderItem,
) -> Result<PurchaseOrderItem>;
fn update_item(
&self,
item_id: Uuid,
item: CreatePurchaseOrderItem,
) -> Result<PurchaseOrderItem>;
fn remove_item(&self, item_id: Uuid) -> Result<()>;
fn get_items(&self, po_id: PurchaseOrderId) -> Result<Vec<PurchaseOrderItem>>;
fn count(&self, filter: PurchaseOrderFilter) -> Result<u64>;
fn count_suppliers(&self, filter: SupplierFilter) -> Result<u64>;
fn create_batch(&self, inputs: Vec<CreatePurchaseOrder>) -> Result<BatchResult<PurchaseOrder>>;
fn create_batch_atomic(&self, inputs: Vec<CreatePurchaseOrder>) -> Result<Vec<PurchaseOrder>>;
fn update_batch(
&self,
updates: Vec<(PurchaseOrderId, UpdatePurchaseOrder)>,
) -> Result<BatchResult<PurchaseOrder>>;
fn update_batch_atomic(
&self,
updates: Vec<(PurchaseOrderId, UpdatePurchaseOrder)>,
) -> Result<Vec<PurchaseOrder>>;
fn delete_batch(&self, ids: Vec<PurchaseOrderId>) -> Result<BatchResult<PurchaseOrderId>>;
fn delete_batch_atomic(&self, ids: Vec<PurchaseOrderId>) -> Result<()>;
fn get_batch(&self, ids: Vec<PurchaseOrderId>) -> Result<Vec<PurchaseOrder>>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait InvoiceRepository: Send + Sync {
fn create(&self, input: CreateInvoice) -> Result<Invoice>;
fn get(&self, id: InvoiceId) -> Result<Option<Invoice>>;
fn get_by_number(&self, invoice_number: &str) -> Result<Option<Invoice>>;
fn update(&self, id: InvoiceId, input: UpdateInvoice) -> Result<Invoice>;
fn list(&self, filter: InvoiceFilter) -> Result<Vec<Invoice>>;
fn for_customer(&self, customer_id: CustomerId) -> Result<Vec<Invoice>>;
fn for_order(&self, order_id: OrderId) -> Result<Vec<Invoice>>;
fn delete(&self, id: InvoiceId) -> Result<()>;
fn send(&self, id: InvoiceId) -> Result<Invoice>;
fn mark_viewed(&self, id: InvoiceId) -> Result<Invoice>;
fn record_payment(&self, id: InvoiceId, payment: RecordInvoicePayment) -> Result<Invoice>;
fn void(&self, id: InvoiceId) -> Result<Invoice>;
fn write_off(&self, id: InvoiceId) -> Result<Invoice>;
fn dispute(&self, id: InvoiceId) -> Result<Invoice>;
fn add_item(&self, invoice_id: InvoiceId, item: CreateInvoiceItem) -> Result<InvoiceItem>;
fn update_item(&self, item_id: Uuid, item: CreateInvoiceItem) -> Result<InvoiceItem>;
fn remove_item(&self, item_id: Uuid) -> Result<()>;
fn get_items(&self, invoice_id: InvoiceId) -> Result<Vec<InvoiceItem>>;
fn recalculate(&self, id: InvoiceId) -> Result<Invoice>;
fn get_overdue(&self) -> Result<Vec<Invoice>>;
fn count(&self, filter: InvoiceFilter) -> Result<u64>;
fn create_batch(&self, inputs: Vec<CreateInvoice>) -> Result<BatchResult<Invoice>>;
fn create_batch_atomic(&self, inputs: Vec<CreateInvoice>) -> Result<Vec<Invoice>>;
fn update_batch(
&self,
updates: Vec<(InvoiceId, UpdateInvoice)>,
) -> Result<BatchResult<Invoice>>;
fn update_batch_atomic(&self, updates: Vec<(InvoiceId, UpdateInvoice)>)
-> Result<Vec<Invoice>>;
fn delete_batch(&self, ids: Vec<InvoiceId>) -> Result<BatchResult<Uuid>>;
fn delete_batch_atomic(&self, ids: Vec<InvoiceId>) -> Result<()>;
fn get_batch(&self, ids: Vec<InvoiceId>) -> Result<Vec<Invoice>>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait CartRepository: Send + Sync {
fn create(&self, input: CreateCart) -> Result<Cart>;
fn get(&self, id: CartId) -> Result<Option<Cart>>;
fn get_by_number(&self, cart_number: &str) -> Result<Option<Cart>>;
fn update(&self, id: CartId, input: UpdateCart) -> Result<Cart>;
fn list(&self, filter: CartFilter) -> Result<Vec<Cart>>;
fn for_customer(&self, customer_id: CustomerId) -> Result<Vec<Cart>>;
fn delete(&self, id: CartId) -> Result<()>;
fn add_item(&self, cart_id: CartId, item: AddCartItem) -> Result<CartItem>;
fn update_item(&self, item_id: Uuid, input: UpdateCartItem) -> Result<CartItem>;
fn remove_item(&self, item_id: Uuid) -> Result<()>;
fn get_items(&self, cart_id: CartId) -> Result<Vec<CartItem>>;
fn clear_items(&self, cart_id: CartId) -> Result<()>;
fn set_shipping_address(&self, id: CartId, address: CartAddress) -> Result<Cart>;
fn set_billing_address(&self, id: CartId, address: CartAddress) -> Result<Cart>;
fn set_shipping(&self, id: CartId, shipping: SetCartShipping) -> Result<Cart>;
fn get_shipping_rates(&self, id: CartId) -> Result<Vec<ShippingRate>>;
fn set_payment(&self, id: CartId, payment: SetCartPayment) -> Result<Cart>;
fn set_x402_payment(&self, id: CartId, payment: SetCartX402Payment) -> Result<Cart>;
fn complete_with_x402(&self, id: CartId, payee_address: &str) -> Result<X402CheckoutResult>;
fn apply_discount(&self, id: CartId, coupon_code: &str) -> Result<Cart>;
fn remove_discount(&self, id: CartId) -> Result<Cart>;
fn mark_ready_for_payment(&self, id: CartId) -> Result<Cart>;
fn begin_checkout(&self, id: CartId) -> Result<Cart>;
fn complete(&self, id: CartId) -> Result<CheckoutResult>;
fn complete_settled_externally(&self, id: CartId) -> Result<CheckoutResult>;
fn cancel(&self, id: CartId) -> Result<Cart>;
fn abandon(&self, id: CartId) -> Result<Cart>;
fn expire(&self, id: CartId) -> Result<Cart>;
fn reserve_inventory(&self, id: CartId) -> Result<Cart>;
fn release_inventory(&self, id: CartId) -> Result<Cart>;
fn recalculate(&self, id: CartId) -> Result<Cart>;
fn set_tax(&self, id: CartId, tax_amount: rust_decimal::Decimal) -> Result<Cart>;
fn get_abandoned(&self) -> Result<Vec<Cart>>;
fn get_expired(&self) -> Result<Vec<Cart>>;
fn count(&self, filter: CartFilter) -> Result<u64>;
fn create_batch(&self, inputs: Vec<CreateCart>) -> Result<BatchResult<Cart>>;
fn create_batch_atomic(&self, inputs: Vec<CreateCart>) -> Result<Vec<Cart>>;
fn update_batch(&self, updates: Vec<(CartId, UpdateCart)>) -> Result<BatchResult<Cart>>;
fn update_batch_atomic(&self, updates: Vec<(CartId, UpdateCart)>) -> Result<Vec<Cart>>;
fn delete_batch(&self, ids: Vec<CartId>) -> Result<BatchResult<CartId>>;
fn delete_batch_atomic(&self, ids: Vec<CartId>) -> Result<()>;
fn get_batch(&self, ids: Vec<CartId>) -> Result<Vec<Cart>>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait AnalyticsRepository: Send + Sync {
fn get_sales_summary(&self, query: AnalyticsQuery) -> Result<SalesSummary>;
fn get_revenue_by_period(&self, query: AnalyticsQuery) -> Result<Vec<RevenueByPeriod>>;
fn get_top_products(&self, query: AnalyticsQuery) -> Result<Vec<TopProduct>>;
fn get_product_performance(&self, query: AnalyticsQuery) -> Result<Vec<ProductPerformance>>;
fn get_customer_metrics(&self, query: AnalyticsQuery) -> Result<CustomerMetrics>;
fn get_top_customers(&self, query: AnalyticsQuery) -> Result<Vec<TopCustomer>>;
fn get_inventory_health(&self) -> Result<InventoryHealth>;
fn get_low_stock_items(
&self,
threshold: Option<rust_decimal::Decimal>,
) -> Result<Vec<LowStockItem>>;
fn get_inventory_movement(&self, query: AnalyticsQuery) -> Result<Vec<InventoryMovement>>;
fn get_order_status_breakdown(&self, query: AnalyticsQuery) -> Result<OrderStatusBreakdown>;
fn get_fulfillment_metrics(&self, query: AnalyticsQuery) -> Result<FulfillmentMetrics>;
fn get_return_metrics(&self, query: AnalyticsQuery) -> Result<ReturnMetrics>;
fn get_demand_forecast(
&self,
skus: Option<Vec<String>>,
days_ahead: u32,
) -> Result<Vec<DemandForecast>>;
fn get_revenue_forecast(
&self,
periods_ahead: u32,
granularity: TimeGranularity,
) -> Result<Vec<RevenueForecast>>;
fn get_sales_summary_batch(&self, queries: Vec<AnalyticsQuery>) -> Result<Vec<SalesSummary>>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait CurrencyRepository: Send + Sync {
fn get_rate(&self, from: Currency, to: Currency) -> Result<Option<ExchangeRate>>;
fn get_rates_for(&self, base: Currency) -> Result<Vec<ExchangeRate>>;
fn list_rates(&self, filter: ExchangeRateFilter) -> Result<Vec<ExchangeRate>>;
fn set_rate(&self, input: SetExchangeRate) -> Result<ExchangeRate>;
fn set_rates(&self, rates: Vec<SetExchangeRate>) -> Result<Vec<ExchangeRate>>;
fn delete_rate(&self, id: Uuid) -> Result<()>;
fn convert(&self, input: ConvertCurrency) -> Result<ConversionResult>;
fn get_settings(&self) -> Result<StoreCurrencySettings>;
fn update_settings(&self, settings: StoreCurrencySettings) -> Result<StoreCurrencySettings>;
fn set_rates_atomic(&self, rates: Vec<SetExchangeRate>) -> Result<Vec<ExchangeRate>>;
fn delete_rates_batch(&self, ids: Vec<Uuid>) -> Result<BatchResult<Uuid>>;
fn delete_rates_atomic(&self, ids: Vec<Uuid>) -> Result<()>;
fn get_rates_batch(&self, pairs: Vec<(Currency, Currency)>) -> Result<Vec<ExchangeRate>>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait TaxRepository: Send + Sync {
fn create_jurisdiction(&self, input: CreateTaxJurisdiction) -> Result<TaxJurisdiction>;
fn get_jurisdiction(&self, id: Uuid) -> Result<Option<TaxJurisdiction>>;
fn get_jurisdiction_by_code(&self, code: &str) -> Result<Option<TaxJurisdiction>>;
fn list_jurisdictions(&self, filter: TaxJurisdictionFilter) -> Result<Vec<TaxJurisdiction>>;
fn create_rate(&self, input: CreateTaxRate) -> Result<TaxRate>;
fn get_rate(&self, id: Uuid) -> Result<Option<TaxRate>>;
fn list_rates(&self, filter: TaxRateFilter) -> Result<Vec<TaxRate>>;
fn get_rates_for_address(
&self,
address: &TaxAddress,
category: ProductTaxCategory,
date: chrono::NaiveDate,
) -> Result<Vec<TaxRate>>;
fn create_exemption(&self, input: CreateTaxExemption) -> Result<TaxExemption>;
fn get_exemption(&self, id: Uuid) -> Result<Option<TaxExemption>>;
fn get_customer_exemptions(&self, customer_id: Uuid) -> Result<Vec<TaxExemption>>;
fn get_settings(&self) -> Result<TaxSettings>;
fn update_settings(&self, settings: TaxSettings) -> Result<TaxSettings>;
fn calculate_tax(&self, request: TaxCalculationRequest) -> Result<TaxCalculationResult>;
fn save_calculation(
&self,
result: &TaxCalculationResult,
order_id: Option<Uuid>,
cart_id: Option<Uuid>,
customer_id: Option<Uuid>,
address: &TaxAddress,
currency: &str,
) -> Result<()>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait PromotionRepository: Send + Sync {
fn create(&self, input: CreatePromotion) -> Result<Promotion>;
fn get(&self, id: PromotionId) -> Result<Option<Promotion>>;
fn get_by_code(&self, code: &str) -> Result<Option<Promotion>>;
fn list(&self, filter: PromotionFilter) -> Result<Vec<Promotion>>;
fn update(&self, id: PromotionId, input: UpdatePromotion) -> Result<Promotion>;
fn delete(&self, id: PromotionId) -> Result<()>;
fn activate(&self, id: PromotionId) -> Result<Promotion>;
fn deactivate(&self, id: PromotionId) -> Result<Promotion>;
fn create_coupon(&self, input: CreateCouponCode) -> Result<CouponCode>;
fn get_coupon(&self, id: Uuid) -> Result<Option<CouponCode>>;
fn get_coupon_by_code(&self, code: &str) -> Result<Option<CouponCode>>;
fn list_coupons(&self, filter: CouponFilter) -> Result<Vec<CouponCode>>;
fn apply_promotions(&self, request: ApplyPromotionsRequest) -> Result<ApplyPromotionsResult>;
#[allow(clippy::too_many_arguments)]
fn record_usage(
&self,
promotion_id: PromotionId,
coupon_id: Option<Uuid>,
customer_id: Option<CustomerId>,
order_id: Option<OrderId>,
cart_id: Option<CartId>,
discount_amount: rust_decimal::Decimal,
currency: &str,
) -> Result<PromotionUsage>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait SubscriptionRepository: Send + Sync {
fn create_plan(&self, input: CreateSubscriptionPlan) -> Result<SubscriptionPlan>;
fn get_plan(&self, id: Uuid) -> Result<Option<SubscriptionPlan>>;
fn get_plan_by_code(&self, code: &str) -> Result<Option<SubscriptionPlan>>;
fn list_plans(&self, filter: SubscriptionPlanFilter) -> Result<Vec<SubscriptionPlan>>;
fn update_plan(&self, id: Uuid, input: UpdateSubscriptionPlan) -> Result<SubscriptionPlan>;
fn activate_plan(&self, id: Uuid) -> Result<SubscriptionPlan>;
fn archive_plan(&self, id: Uuid) -> Result<SubscriptionPlan>;
fn create_subscription(&self, input: CreateSubscription) -> Result<Subscription>;
fn get_subscription(&self, id: SubscriptionId) -> Result<Option<Subscription>>;
fn get_subscription_by_number(&self, number: &str) -> Result<Option<Subscription>>;
fn list_subscriptions(&self, filter: SubscriptionFilter) -> Result<Vec<Subscription>>;
fn update_subscription(
&self,
id: SubscriptionId,
input: UpdateSubscription,
) -> Result<Subscription>;
fn cancel_subscription(
&self,
id: SubscriptionId,
input: CancelSubscription,
) -> Result<Subscription>;
fn pause_subscription(
&self,
id: SubscriptionId,
input: PauseSubscription,
) -> Result<Subscription>;
fn resume_subscription(&self, id: SubscriptionId) -> Result<Subscription>;
fn create_billing_cycle(&self, input: CreateBillingCycle) -> Result<BillingCycle>;
fn get_billing_cycle(&self, id: Uuid) -> Result<Option<BillingCycle>>;
fn list_billing_cycles(&self, filter: BillingCycleFilter) -> Result<Vec<BillingCycle>>;
fn update_billing_cycle_status(
&self,
id: Uuid,
status: BillingCycleStatus,
) -> Result<BillingCycle>;
fn skip_billing_cycle(
&self,
id: SubscriptionId,
input: SkipBillingCycle,
) -> Result<Subscription>;
fn record_event(
&self,
subscription_id: SubscriptionId,
event_type: SubscriptionEventType,
notes: Option<String>,
) -> Result<SubscriptionEvent>;
fn get_subscription_events(
&self,
subscription_id: SubscriptionId,
) -> Result<Vec<SubscriptionEvent>>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait QualityRepository: Send + Sync {
fn create_inspection(&self, input: CreateInspection) -> Result<Inspection>;
fn get_inspection(&self, id: Uuid) -> Result<Option<Inspection>>;
fn get_inspection_by_number(&self, number: &str) -> Result<Option<Inspection>>;
fn update_inspection(&self, id: Uuid, input: UpdateInspection) -> Result<Inspection>;
fn list_inspections(&self, filter: InspectionFilter) -> Result<Vec<Inspection>>;
fn delete_inspection(&self, id: Uuid) -> Result<()>;
fn start_inspection(&self, id: Uuid) -> Result<Inspection>;
fn complete_inspection(&self, id: Uuid) -> Result<Inspection>;
fn record_inspection_result(&self, input: RecordInspectionResult) -> Result<InspectionItem>;
fn get_inspection_items(&self, inspection_id: Uuid) -> Result<Vec<InspectionItem>>;
fn count_inspections(&self, filter: InspectionFilter) -> Result<u64>;
fn create_ncr(&self, input: CreateNonConformance) -> Result<NonConformance>;
fn get_ncr(&self, id: Uuid) -> Result<Option<NonConformance>>;
fn get_ncr_by_number(&self, number: &str) -> Result<Option<NonConformance>>;
fn update_ncr(&self, id: Uuid, input: UpdateNonConformance) -> Result<NonConformance>;
fn list_ncrs(&self, filter: NonConformanceFilter) -> Result<Vec<NonConformance>>;
fn close_ncr(&self, id: Uuid) -> Result<NonConformance>;
fn cancel_ncr(&self, id: Uuid) -> Result<NonConformance>;
fn count_ncrs(&self, filter: NonConformanceFilter) -> Result<u64>;
fn create_hold(&self, input: CreateQualityHold) -> Result<QualityHold>;
fn get_hold(&self, id: Uuid) -> Result<Option<QualityHold>>;
fn list_holds(&self, filter: QualityHoldFilter) -> Result<Vec<QualityHold>>;
fn release_hold(&self, id: Uuid, input: ReleaseQualityHold) -> Result<QualityHold>;
fn get_active_holds_for_sku(&self, sku: &str) -> Result<Vec<QualityHold>>;
fn get_active_holds_for_lot(&self, lot_number: &str) -> Result<Vec<QualityHold>>;
fn count_active_holds(&self) -> Result<u64>;
fn create_defect_code(&self, input: CreateDefectCode) -> Result<DefectCode>;
fn get_defect_code(&self, code: &str) -> Result<Option<DefectCode>>;
fn list_defect_codes(&self, category: Option<&str>) -> Result<Vec<DefectCode>>;
fn deactivate_defect_code(&self, id: Uuid) -> Result<()>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait LotRepository: Send + Sync {
fn create(&self, input: CreateLot) -> Result<Lot>;
fn get(&self, id: Uuid) -> Result<Option<Lot>>;
fn get_by_number(&self, lot_number: &str) -> Result<Option<Lot>>;
fn update(&self, id: Uuid, input: UpdateLot) -> Result<Lot>;
fn list(&self, filter: LotFilter) -> Result<Vec<Lot>>;
fn delete(&self, id: Uuid) -> Result<()>;
fn adjust(&self, input: AdjustLot) -> Result<LotTransaction>;
fn consume(&self, input: ConsumeLot) -> Result<LotTransaction>;
fn reserve(&self, input: ReserveLot) -> Result<Uuid>;
fn release_reservation(&self, reservation_id: Uuid) -> Result<()>;
fn confirm_reservation(&self, reservation_id: Uuid) -> Result<LotTransaction>;
fn transfer(&self, input: TransferLot) -> Result<LotTransaction>;
fn split(&self, input: SplitLot) -> Result<Lot>;
fn merge(&self, input: MergeLots) -> Result<Lot>;
fn quarantine(&self, id: Uuid, reason: &str) -> Result<Lot>;
fn release_quarantine(&self, id: Uuid) -> Result<Lot>;
fn get_transactions(&self, lot_id: Uuid, limit: u32) -> Result<Vec<LotTransaction>>;
fn get_quantity_at_location(
&self,
lot_id: Uuid,
location_id: i32,
) -> Result<Option<rust_decimal::Decimal>>;
fn get_lot_locations(&self, lot_id: Uuid) -> Result<Vec<LotLocation>>;
fn add_certificate(&self, input: AddLotCertificate) -> Result<LotCertificate>;
fn get_certificates(&self, lot_id: Uuid) -> Result<Vec<LotCertificate>>;
fn delete_certificate(&self, certificate_id: Uuid) -> Result<()>;
fn get_expiring_lots(&self, days: i32) -> Result<Vec<Lot>>;
fn get_expired_lots(&self) -> Result<Vec<Lot>>;
fn get_available_lots_for_sku(&self, sku: &str) -> Result<Vec<Lot>>;
fn trace(&self, lot_id: Uuid) -> Result<TraceabilityResult>;
fn count(&self, filter: LotFilter) -> Result<u64>;
fn create_batch(&self, inputs: Vec<CreateLot>) -> Result<BatchResult<Lot>>;
fn get_batch(&self, ids: Vec<Uuid>) -> Result<Vec<Lot>>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait SerialRepository: Send + Sync {
fn create(&self, input: CreateSerialNumber) -> Result<SerialNumber>;
fn create_bulk(&self, input: CreateSerialNumbersBulk) -> Result<Vec<SerialNumber>>;
fn get(&self, id: Uuid) -> Result<Option<SerialNumber>>;
fn get_by_serial(&self, serial: &str) -> Result<Option<SerialNumber>>;
fn update(&self, id: Uuid, input: UpdateSerialNumber) -> Result<SerialNumber>;
fn list(&self, filter: SerialFilter) -> Result<Vec<SerialNumber>>;
fn delete(&self, id: Uuid) -> Result<()>;
fn change_status(&self, input: ChangeSerialStatus) -> Result<SerialNumber>;
fn reserve(&self, input: ReserveSerialNumber) -> Result<SerialReservation>;
fn release_reservation(&self, reservation_id: Uuid) -> Result<()>;
fn confirm_reservation(&self, reservation_id: Uuid) -> Result<()>;
fn move_serial(&self, input: MoveSerial) -> Result<SerialNumber>;
fn transfer_ownership(&self, input: TransferSerialOwnership) -> Result<SerialNumber>;
fn mark_sold(
&self,
id: Uuid,
customer_id: Uuid,
order_id: Option<Uuid>,
) -> Result<SerialNumber>;
fn mark_shipped(&self, id: Uuid, shipment_id: Uuid) -> Result<SerialNumber>;
fn mark_returned(&self, id: Uuid, return_id: Uuid) -> Result<SerialNumber>;
fn activate(&self, id: Uuid) -> Result<SerialNumber>;
fn quarantine(&self, id: Uuid, reason: &str) -> Result<SerialNumber>;
fn release_quarantine(&self, id: Uuid) -> Result<SerialNumber>;
fn scrap(&self, id: Uuid, reason: &str) -> Result<SerialNumber>;
fn get_history(
&self,
serial_id: Uuid,
filter: SerialHistoryFilter,
) -> Result<Vec<SerialHistory>>;
fn lookup(&self, serial: &str) -> Result<Option<SerialLookupResult>>;
fn validate(&self, serial: &str) -> Result<SerialValidation>;
fn get_available_for_sku(&self, sku: &str, limit: u32) -> Result<Vec<SerialNumber>>;
fn get_for_lot(&self, lot_id: Uuid) -> Result<Vec<SerialNumber>>;
fn get_for_customer(&self, customer_id: Uuid) -> Result<Vec<SerialNumber>>;
fn count(&self, filter: SerialFilter) -> Result<u64>;
fn create_batch(&self, inputs: Vec<CreateSerialNumber>) -> Result<BatchResult<SerialNumber>>;
fn get_batch(&self, ids: Vec<Uuid>) -> Result<Vec<SerialNumber>>;
fn get_batch_by_serial(&self, serials: Vec<String>) -> Result<Vec<SerialNumber>>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait WarehouseRepository: Send + Sync {
fn create_warehouse(&self, input: CreateWarehouse) -> Result<Warehouse>;
fn get_warehouse(&self, id: i32) -> Result<Option<Warehouse>>;
fn get_warehouse_by_code(&self, code: &str) -> Result<Option<Warehouse>>;
fn update_warehouse(&self, id: i32, input: UpdateWarehouse) -> Result<Warehouse>;
fn list_warehouses(&self, filter: WarehouseFilter) -> Result<Vec<Warehouse>>;
fn delete_warehouse(&self, id: i32) -> Result<()>;
fn count_warehouses(&self, filter: WarehouseFilter) -> Result<u64>;
fn create_zone(&self, input: CreateZone) -> Result<Zone>;
fn get_zone(&self, id: i32) -> Result<Option<Zone>>;
fn get_zones(&self, warehouse_id: i32) -> Result<Vec<Zone>>;
fn update_zone(&self, id: i32, input: UpdateZone) -> Result<Zone>;
fn delete_zone(&self, id: i32) -> Result<()>;
fn create_location(&self, input: CreateLocation) -> Result<Location>;
fn get_location(&self, id: i32) -> Result<Option<Location>>;
fn get_location_by_code(&self, warehouse_id: i32, code: &str) -> Result<Option<Location>>;
fn update_location(&self, id: i32, input: UpdateLocation) -> Result<Location>;
fn list_locations(&self, filter: LocationFilter) -> Result<Vec<Location>>;
fn delete_location(&self, id: i32) -> Result<()>;
fn count_locations(&self, filter: LocationFilter) -> Result<u64>;
fn get_locations_for_warehouse(&self, warehouse_id: i32) -> Result<Vec<Location>>;
fn get_pickable_locations(&self, warehouse_id: i32, sku: &str) -> Result<Vec<Location>>;
fn get_receivable_locations(&self, warehouse_id: i32) -> Result<Vec<Location>>;
fn get_location_inventory(&self, location_id: i32) -> Result<Vec<LocationInventory>>;
fn get_inventory_for_sku(&self, warehouse_id: i32, sku: &str)
-> Result<Vec<LocationInventory>>;
fn adjust_inventory(&self, input: AdjustLocationInventory) -> Result<LocationInventory>;
fn move_inventory(&self, input: MoveInventory) -> Result<LocationMovement>;
fn list_location_inventory(
&self,
filter: LocationInventoryFilter,
) -> Result<Vec<LocationInventory>>;
fn get_movements(&self, filter: MovementFilter) -> Result<Vec<LocationMovement>>;
fn count_movements(&self, filter: MovementFilter) -> Result<u64>;
fn create_locations_batch(&self, inputs: Vec<CreateLocation>) -> Result<BatchResult<Location>>;
fn get_locations_batch(&self, ids: Vec<i32>) -> Result<Vec<Location>>;
fn create_cycle_count(&self, input: CreateCycleCount) -> Result<CycleCount>;
fn get_cycle_count(&self, id: Uuid) -> Result<Option<CycleCount>>;
fn list_cycle_counts(&self, filter: CycleCountFilter) -> Result<Vec<CycleCount>>;
fn start_cycle_count(&self, id: Uuid) -> Result<CycleCount>;
fn record_cycle_counts(
&self,
id: Uuid,
counts: Vec<RecordCycleCountLine>,
) -> Result<CycleCount>;
fn complete_cycle_count(&self, id: Uuid) -> Result<CycleCount>;
fn cancel_cycle_count(&self, id: Uuid) -> Result<CycleCount>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait ReceivingRepository: Send + Sync {
fn create_receipt(&self, input: CreateReceipt) -> Result<Receipt>;
fn get_receipt(&self, id: Uuid) -> Result<Option<Receipt>>;
fn get_receipt_by_number(&self, number: &str) -> Result<Option<Receipt>>;
fn update_receipt(&self, id: Uuid, input: UpdateReceipt) -> Result<Receipt>;
fn list_receipts(&self, filter: ReceiptFilter) -> Result<Vec<Receipt>>;
fn delete_receipt(&self, id: Uuid) -> Result<()>;
fn start_receiving(&self, id: Uuid) -> Result<Receipt>;
fn receive_items(&self, input: ReceiveItems) -> Result<Receipt>;
fn complete_receiving(&self, id: Uuid) -> Result<Receipt>;
fn cancel_receipt(&self, id: Uuid) -> Result<Receipt>;
fn get_receipt_items(&self, receipt_id: Uuid) -> Result<Vec<ReceiptItem>>;
fn count_receipts(&self, filter: ReceiptFilter) -> Result<u64>;
fn create_put_away(&self, input: CreatePutAway) -> Result<PutAway>;
fn get_put_away(&self, id: Uuid) -> Result<Option<PutAway>>;
fn list_put_aways(&self, filter: PutAwayFilter) -> Result<Vec<PutAway>>;
fn assign_put_away(&self, id: Uuid, assigned_to: &str) -> Result<PutAway>;
fn start_put_away(&self, id: Uuid) -> Result<PutAway>;
fn complete_put_away(&self, input: CompletePutAway) -> Result<PutAway>;
fn cancel_put_away(&self, id: Uuid) -> Result<PutAway>;
fn get_pending_put_aways(&self, receipt_id: Uuid) -> Result<Vec<PutAway>>;
fn count_put_aways(&self, filter: PutAwayFilter) -> Result<u64>;
fn create_receipt_from_po(&self, po_id: Uuid, warehouse_id: i32) -> Result<Receipt>;
fn create_receipts_batch(&self, inputs: Vec<CreateReceipt>) -> Result<BatchResult<Receipt>>;
fn get_receipts_batch(&self, ids: Vec<Uuid>) -> Result<Vec<Receipt>>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait FulfillmentRepository: Send + Sync {
fn create_wave(&self, input: CreateWave) -> Result<Wave>;
fn get_wave(&self, id: FulfillmentId) -> Result<Option<Wave>>;
fn get_wave_by_number(&self, number: &str) -> Result<Option<Wave>>;
fn list_waves(&self, filter: WaveFilter) -> Result<Vec<Wave>>;
fn release_wave(&self, id: FulfillmentId) -> Result<Wave>;
fn complete_wave(&self, id: FulfillmentId) -> Result<Wave>;
fn cancel_wave(&self, id: FulfillmentId) -> Result<Wave>;
fn get_wave_orders(&self, wave_id: FulfillmentId) -> Result<Vec<OrderId>>;
fn count_waves(&self, filter: WaveFilter) -> Result<u64>;
fn create_pick(&self, input: CreatePickTask) -> Result<PickTask>;
fn get_pick(&self, id: Uuid) -> Result<Option<PickTask>>;
fn list_picks(&self, filter: PickTaskFilter) -> Result<Vec<PickTask>>;
fn assign_pick(&self, id: Uuid, assigned_to: &str) -> Result<PickTask>;
fn start_pick(&self, id: Uuid) -> Result<PickTask>;
fn complete_pick(&self, input: CompletePick) -> Result<PickTask>;
fn report_short(
&self,
id: Uuid,
short_qty: rust_decimal::Decimal,
reason: &str,
) -> Result<PickTask>;
fn cancel_pick(&self, id: Uuid) -> Result<PickTask>;
fn get_picks_for_order(&self, order_id: OrderId) -> Result<Vec<PickTask>>;
fn get_picks_for_wave(&self, wave_id: FulfillmentId) -> Result<Vec<PickTask>>;
fn count_picks(&self, filter: PickTaskFilter) -> Result<u64>;
fn create_pack(&self, input: CreatePackTask) -> Result<PackTask>;
fn get_pack(&self, id: Uuid) -> Result<Option<PackTask>>;
fn list_packs(&self, filter: PackTaskFilter) -> Result<Vec<PackTask>>;
fn assign_pack(&self, id: Uuid, assigned_to: &str) -> Result<PackTask>;
fn start_pack(&self, id: Uuid) -> Result<PackTask>;
fn complete_pack(&self, id: Uuid) -> Result<PackTask>;
fn add_carton(&self, input: AddCarton) -> Result<Carton>;
fn add_carton_item(&self, input: AddCartonItem) -> Result<CartonItem>;
fn get_cartons(&self, pack_task_id: Uuid) -> Result<Vec<Carton>>;
fn get_carton_items(&self, carton_id: Uuid) -> Result<Vec<CartonItem>>;
fn mark_label_printed(&self, carton_id: Uuid) -> Result<Carton>;
fn cancel_pack(&self, id: Uuid) -> Result<PackTask>;
fn count_packs(&self, filter: PackTaskFilter) -> Result<u64>;
fn create_ship(&self, input: CreateShipTask) -> Result<ShipTask>;
fn get_ship(&self, id: Uuid) -> Result<Option<ShipTask>>;
fn list_ships(&self, filter: ShipTaskFilter) -> Result<Vec<ShipTask>>;
fn assign_ship(&self, id: Uuid, assigned_to: &str) -> Result<ShipTask>;
fn print_label(&self, id: Uuid, label_url: &str) -> Result<ShipTask>;
fn complete_ship(&self, input: CompleteShip) -> Result<ShipTask>;
fn cancel_ship(&self, id: Uuid) -> Result<ShipTask>;
fn count_ships(&self, filter: ShipTaskFilter) -> Result<u64>;
fn create_picks_for_order(&self, order_id: OrderId, warehouse_id: i32)
-> Result<Vec<PickTask>>;
fn is_order_ready_to_pack(&self, order_id: OrderId) -> Result<bool>;
fn is_order_ready_to_ship(&self, order_id: OrderId) -> Result<bool>;
fn create_waves_batch(&self, inputs: Vec<CreateWave>) -> Result<BatchResult<Wave>>;
fn get_picks_batch(&self, ids: Vec<Uuid>) -> Result<Vec<PickTask>>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait AccountsPayableRepository: Send + Sync {
fn create_bill(&self, input: CreateBill) -> Result<Bill>;
fn get_bill(&self, id: Uuid) -> Result<Option<Bill>>;
fn get_bill_by_number(&self, number: &str) -> Result<Option<Bill>>;
fn update_bill(&self, id: Uuid, input: UpdateBill) -> Result<Bill>;
fn list_bills(&self, filter: BillFilter) -> Result<Vec<Bill>>;
fn delete_bill(&self, id: Uuid) -> Result<()>;
fn approve_bill(&self, id: Uuid) -> Result<Bill>;
fn cancel_bill(&self, id: Uuid) -> Result<Bill>;
fn dispute_bill(&self, id: Uuid) -> Result<Bill>;
fn get_bill_items(&self, bill_id: Uuid) -> Result<Vec<BillItem>>;
fn add_bill_item(&self, bill_id: Uuid, item: CreateBillItem) -> Result<BillItem>;
fn remove_bill_item(&self, item_id: Uuid) -> Result<()>;
fn count_bills(&self, filter: BillFilter) -> Result<u64>;
fn get_overdue_bills(&self) -> Result<Vec<Bill>>;
fn get_bills_due_soon(&self, days: i32) -> Result<Vec<Bill>>;
fn create_payment(&self, input: CreateBillPayment) -> Result<BillPayment>;
fn get_payment(&self, id: Uuid) -> Result<Option<BillPayment>>;
fn get_payment_by_number(&self, number: &str) -> Result<Option<BillPayment>>;
fn list_payments(&self, filter: BillPaymentFilter) -> Result<Vec<BillPayment>>;
fn void_payment(&self, id: Uuid) -> Result<BillPayment>;
fn clear_payment(&self, id: Uuid) -> Result<BillPayment>;
fn get_payment_allocations(&self, payment_id: Uuid) -> Result<Vec<PaymentAllocation>>;
fn get_payments_for_bill(&self, bill_id: Uuid) -> Result<Vec<BillPayment>>;
fn count_payments(&self, filter: BillPaymentFilter) -> Result<u64>;
fn create_payment_run(&self, input: CreatePaymentRun) -> Result<PaymentRun>;
fn get_payment_run(&self, id: Uuid) -> Result<Option<PaymentRun>>;
fn list_payment_runs(&self, filter: PaymentRunFilter) -> Result<Vec<PaymentRun>>;
fn approve_payment_run(&self, id: Uuid, approved_by: &str) -> Result<PaymentRun>;
fn process_payment_run(&self, id: Uuid) -> Result<PaymentRun>;
fn cancel_payment_run(&self, id: Uuid) -> Result<PaymentRun>;
fn get_payment_run_bills(&self, run_id: Uuid) -> Result<Vec<Bill>>;
fn get_aging_summary(&self) -> Result<ApAgingSummary>;
fn get_supplier_summary(&self, supplier_id: Uuid) -> Result<Option<SupplierApSummary>>;
fn get_total_outstanding(&self) -> Result<rust_decimal::Decimal>;
fn create_bills_batch(&self, inputs: Vec<CreateBill>) -> Result<BatchResult<Bill>>;
fn get_bills_batch(&self, ids: Vec<Uuid>) -> Result<Vec<Bill>>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait CostAccountingRepository: Send + Sync {
fn get_item_cost(&self, sku: &str) -> Result<Option<ItemCost>>;
fn set_item_cost(&self, input: SetItemCost) -> Result<ItemCost>;
fn list_item_costs(&self, filter: ItemCostFilter) -> Result<Vec<ItemCost>>;
fn update_average_cost(
&self,
sku: &str,
quantity: rust_decimal::Decimal,
unit_cost: rust_decimal::Decimal,
) -> Result<ItemCost>;
fn update_last_cost(&self, sku: &str, unit_cost: rust_decimal::Decimal) -> Result<ItemCost>;
fn create_cost_layer(&self, input: CreateCostLayer) -> Result<CostLayer>;
fn get_cost_layer(&self, id: Uuid) -> Result<Option<CostLayer>>;
fn list_cost_layers(&self, filter: CostLayerFilter) -> Result<Vec<CostLayer>>;
fn issue_fifo(&self, input: IssueCostLayers) -> Result<Vec<CostTransaction>>;
fn issue_lifo(&self, input: IssueCostLayers) -> Result<Vec<CostTransaction>>;
fn get_layers_remaining(&self, sku: &str) -> Result<rust_decimal::Decimal>;
#[allow(clippy::too_many_arguments)]
fn record_cost_transaction(
&self,
sku: &str,
transaction_type: CostTransactionType,
quantity: rust_decimal::Decimal,
unit_cost: rust_decimal::Decimal,
layer_id: Option<Uuid>,
reference_type: Option<&str>,
reference_id: Option<Uuid>,
notes: Option<&str>,
) -> Result<CostTransaction>;
fn list_cost_transactions(&self, filter: CostTransactionFilter)
-> Result<Vec<CostTransaction>>;
fn record_variance(&self, input: RecordCostVariance) -> Result<CostVariance>;
fn list_variances(&self, filter: CostVarianceFilter) -> Result<Vec<CostVariance>>;
fn get_variance_summary(
&self,
from: DateTime<Utc>,
to: DateTime<Utc>,
) -> Result<rust_decimal::Decimal>;
fn create_adjustment(&self, input: CreateCostAdjustment) -> Result<CostAdjustment>;
fn get_adjustment(&self, id: Uuid) -> Result<Option<CostAdjustment>>;
fn list_adjustments(&self, filter: CostAdjustmentFilter) -> Result<Vec<CostAdjustment>>;
fn approve_adjustment(&self, id: Uuid, approved_by: &str) -> Result<CostAdjustment>;
fn apply_adjustment(&self, id: Uuid) -> Result<CostAdjustment>;
fn reject_adjustment(&self, id: Uuid) -> Result<CostAdjustment>;
fn calculate_rollup(&self, sku: &str, bom_id: Option<Uuid>) -> Result<CostRollup>;
fn get_rollup(&self, sku: &str) -> Result<Option<CostRollup>>;
fn get_inventory_valuation(&self, cost_method: CostMethod) -> Result<InventoryValuation>;
fn get_sku_cost_summary(&self, sku: &str) -> Result<Option<SkuCostSummary>>;
fn get_total_inventory_value(&self) -> Result<rust_decimal::Decimal>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait CreditRepository: Send + Sync {
fn create_credit_account(&self, input: CreateCreditAccount) -> Result<CreditAccount>;
fn get_credit_account(&self, id: CreditId) -> Result<Option<CreditAccount>>;
fn get_credit_account_by_customer(
&self,
customer_id: CustomerId,
) -> Result<Option<CreditAccount>>;
fn update_credit_account(
&self,
id: CreditId,
input: UpdateCreditAccount,
) -> Result<CreditAccount>;
fn list_credit_accounts(&self, filter: CreditAccountFilter) -> Result<Vec<CreditAccount>>;
fn adjust_credit_limit(
&self,
customer_id: CustomerId,
new_limit: rust_decimal::Decimal,
reason: &str,
) -> Result<CreditAccount>;
fn suspend_credit_account(
&self,
customer_id: CustomerId,
reason: &str,
) -> Result<CreditAccount>;
fn reactivate_credit_account(&self, customer_id: CustomerId) -> Result<CreditAccount>;
fn check_credit(
&self,
customer_id: CustomerId,
order_amount: rust_decimal::Decimal,
) -> Result<CreditCheckResult>;
fn reserve_credit(
&self,
customer_id: CustomerId,
order_id: OrderId,
amount: rust_decimal::Decimal,
) -> Result<CreditAccount>;
fn release_credit_reservation(
&self,
customer_id: CustomerId,
order_id: OrderId,
) -> Result<CreditAccount>;
fn charge_credit(
&self,
customer_id: CustomerId,
order_id: OrderId,
amount: rust_decimal::Decimal,
) -> Result<CreditAccount>;
fn place_hold(&self, input: PlaceCreditHold) -> Result<CreditHold>;
fn get_hold(&self, id: Uuid) -> Result<Option<CreditHold>>;
fn list_holds(&self, filter: CreditHoldFilter) -> Result<Vec<CreditHold>>;
fn release_hold(&self, input: ReleaseCreditHold) -> Result<CreditHold>;
fn get_active_holds(&self, customer_id: CustomerId) -> Result<Vec<CreditHold>>;
fn get_holds_for_order(&self, order_id: OrderId) -> Result<Vec<CreditHold>>;
fn submit_application(&self, input: SubmitCreditApplication) -> Result<CreditApplication>;
fn get_application(&self, id: Uuid) -> Result<Option<CreditApplication>>;
fn list_applications(&self, filter: CreditApplicationFilter) -> Result<Vec<CreditApplication>>;
fn review_application(&self, input: ReviewCreditApplication) -> Result<CreditApplication>;
fn withdraw_application(&self, id: Uuid) -> Result<CreditApplication>;
fn record_transaction(&self, input: RecordCreditTransaction) -> Result<CreditTransaction>;
fn list_transactions(&self, filter: CreditTransactionFilter) -> Result<Vec<CreditTransaction>>;
fn apply_payment(
&self,
customer_id: CustomerId,
amount: rust_decimal::Decimal,
reference_id: Option<Uuid>,
) -> Result<CreditAccount>;
fn get_customer_summary(
&self,
customer_id: CustomerId,
) -> Result<Option<CustomerCreditSummary>>;
fn get_aging_report(&self) -> Result<Vec<(CustomerId, CreditAgingBucket)>>;
fn get_over_limit_customers(&self) -> Result<Vec<CreditAccount>>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait BackorderRepository: Send + Sync {
fn create_backorder(&self, input: CreateBackorder) -> Result<Backorder>;
fn get_backorder(&self, id: Uuid) -> Result<Option<Backorder>>;
fn get_backorder_by_number(&self, number: &str) -> Result<Option<Backorder>>;
fn update_backorder(&self, id: Uuid, input: UpdateBackorder) -> Result<Backorder>;
fn list_backorders(&self, filter: BackorderFilter) -> Result<Vec<Backorder>>;
fn cancel_backorder(&self, id: Uuid) -> Result<Backorder>;
fn get_backorders_for_order(&self, order_id: Uuid) -> Result<Vec<Backorder>>;
fn get_backorders_for_customer(&self, customer_id: Uuid) -> Result<Vec<Backorder>>;
fn get_backorders_for_sku(&self, sku: &str) -> Result<Vec<Backorder>>;
fn fulfill_backorder(&self, input: FulfillBackorder) -> Result<Backorder>;
fn get_fulfillment_history(&self, backorder_id: Uuid) -> Result<Vec<BackorderFulfillment>>;
fn allocate_backorder(&self, input: AllocateBackorder) -> Result<BackorderAllocation>;
fn get_allocations(&self, backorder_id: Uuid) -> Result<Vec<BackorderAllocation>>;
fn release_allocation(&self, allocation_id: Uuid) -> Result<BackorderAllocation>;
fn confirm_allocation(&self, allocation_id: Uuid) -> Result<BackorderAllocation>;
fn expire_allocations(&self) -> Result<u32>;
fn auto_allocate_inventory(&self, sku: &str) -> Result<Vec<BackorderAllocation>>;
fn get_summary(&self) -> Result<BackorderSummary>;
fn get_sku_summary(&self, sku: &str) -> Result<Option<SkuBackorderSummary>>;
fn get_overdue_backorders(&self) -> Result<Vec<Backorder>>;
fn count_pending(&self) -> Result<u64>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait AccountsReceivableRepository: Send + Sync {
fn get_aging_summary(&self) -> Result<ArAgingSummary>;
fn get_customer_aging(&self, customer_id: Uuid) -> Result<Option<CustomerArAging>>;
fn get_aging_report(&self, filter: ArAgingFilter) -> Result<Vec<CustomerArAging>>;
fn log_collection_activity(
&self,
input: CreateCollectionActivity,
) -> Result<CollectionActivity>;
fn list_collection_activities(
&self,
filter: CollectionActivityFilter,
) -> Result<Vec<CollectionActivity>>;
fn update_collection_status(
&self,
invoice_id: InvoiceId,
status: CollectionStatus,
) -> Result<()>;
fn get_invoices_due_for_dunning(&self) -> Result<Vec<Invoice>>;
fn send_dunning_letter(
&self,
invoice_id: InvoiceId,
letter_type: DunningLetterType,
sent_by: Option<&str>,
) -> Result<CollectionActivity>;
fn create_write_off(&self, input: CreateWriteOff) -> Result<WriteOff>;
fn get_write_off(&self, id: Uuid) -> Result<Option<WriteOff>>;
fn list_write_offs(&self, filter: WriteOffFilter) -> Result<Vec<WriteOff>>;
fn reverse_write_off(&self, id: Uuid) -> Result<WriteOff>;
fn create_credit_memo(&self, input: CreateCreditMemo) -> Result<CreditMemo>;
fn get_credit_memo(&self, id: Uuid) -> Result<Option<CreditMemo>>;
fn get_credit_memo_by_number(&self, number: &str) -> Result<Option<CreditMemo>>;
fn list_credit_memos(&self, filter: CreditMemoFilter) -> Result<Vec<CreditMemo>>;
fn apply_credit_memo(&self, input: ApplyCreditMemo) -> Result<CreditMemo>;
fn void_credit_memo(&self, id: Uuid) -> Result<CreditMemo>;
fn get_unapplied_credits(&self, customer_id: Uuid) -> Result<Vec<CreditMemo>>;
fn apply_payment_to_invoices(
&self,
input: ApplyPaymentToInvoices,
) -> Result<Vec<ArPaymentApplication>>;
fn get_payment_applications(&self, payment_id: Uuid) -> Result<Vec<ArPaymentApplication>>;
fn unapply_payment(&self, application_id: Uuid) -> Result<()>;
fn get_customer_summary(&self, customer_id: Uuid) -> Result<Option<CustomerArSummary>>;
fn generate_statement(&self, request: GenerateStatementRequest) -> Result<CustomerStatement>;
fn get_total_outstanding(&self) -> Result<rust_decimal::Decimal>;
fn get_dso(&self, days: i32) -> Result<rust_decimal::Decimal>;
fn get_average_days_to_pay(&self, customer_id: Uuid) -> Result<Option<i32>>;
fn get_customers_batch(&self, ids: Vec<Uuid>) -> Result<Vec<CustomerArSummary>>;
}
use chrono::NaiveDate;
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait GeneralLedgerRepository: Send + Sync {
fn create_account(&self, input: CreateGlAccount) -> Result<GlAccount>;
fn get_account(&self, id: Uuid) -> Result<Option<GlAccount>>;
fn get_account_by_number(&self, account_number: &str) -> Result<Option<GlAccount>>;
fn update_account(&self, id: Uuid, input: UpdateGlAccount) -> Result<GlAccount>;
fn list_accounts(&self, filter: GlAccountFilter) -> Result<Vec<GlAccount>>;
fn get_account_hierarchy(&self) -> Result<Vec<GlAccount>>;
fn delete_account(&self, id: Uuid) -> Result<()>;
fn initialize_chart_of_accounts(&self) -> Result<Vec<GlAccount>>;
fn create_period(&self, input: CreateGlPeriod) -> Result<GlPeriod>;
fn get_period(&self, id: Uuid) -> Result<Option<GlPeriod>>;
fn get_current_period(&self) -> Result<Option<GlPeriod>>;
fn get_period_for_date(&self, date: NaiveDate) -> Result<Option<GlPeriod>>;
fn list_periods(&self, filter: GlPeriodFilter) -> Result<Vec<GlPeriod>>;
fn open_period(&self, id: Uuid) -> Result<GlPeriod>;
fn close_period(&self, id: Uuid, closed_by: &str) -> Result<GlPeriod>;
fn lock_period(&self, id: Uuid, locked_by: &str) -> Result<GlPeriod>;
fn reopen_period(&self, id: Uuid) -> Result<GlPeriod>;
fn create_journal_entry(&self, input: CreateJournalEntry) -> Result<JournalEntry>;
fn get_journal_entry(&self, id: Uuid) -> Result<Option<JournalEntry>>;
fn get_journal_entry_by_number(&self, number: &str) -> Result<Option<JournalEntry>>;
fn list_journal_entries(&self, filter: JournalEntryFilter) -> Result<Vec<JournalEntry>>;
fn post_journal_entry(&self, id: Uuid, posted_by: &str) -> Result<JournalEntry>;
fn void_journal_entry(&self, id: Uuid) -> Result<JournalEntry>;
fn reverse_journal_entry(&self, id: Uuid, reversal_date: NaiveDate) -> Result<JournalEntry>;
fn get_journal_entry_lines(&self, journal_entry_id: Uuid) -> Result<Vec<JournalEntryLine>>;
fn get_auto_posting_config(&self) -> Result<Option<AutoPostingConfig>>;
fn set_auto_posting_config(&self, input: CreateAutoPostingConfig) -> Result<AutoPostingConfig>;
fn auto_post_invoice(&self, invoice_id: InvoiceId) -> Result<JournalEntry>;
fn auto_post_payment_received(&self, payment_id: Uuid) -> Result<JournalEntry>;
fn auto_post_bill(&self, bill_id: Uuid) -> Result<JournalEntry>;
fn auto_post_bill_payment(&self, payment_id: Uuid) -> Result<JournalEntry>;
fn auto_post_inventory_cost(&self, cost_transaction_id: Uuid) -> Result<JournalEntry>;
fn auto_post_write_off(&self, write_off_id: Uuid) -> Result<JournalEntry>;
fn get_trial_balance(&self, as_of_date: NaiveDate) -> Result<TrialBalance>;
fn get_balance_sheet(&self, as_of_date: NaiveDate) -> Result<BalanceSheet>;
fn get_income_statement(
&self,
start_date: NaiveDate,
end_date: NaiveDate,
) -> Result<IncomeStatement>;
fn get_account_balance(
&self,
account_id: Uuid,
as_of_date: Option<NaiveDate>,
) -> Result<Option<rust_decimal::Decimal>>;
fn get_account_transactions(
&self,
account_id: Uuid,
filter: JournalEntryFilter,
) -> Result<Vec<JournalEntryLine>>;
fn run_period_close(&self, period_id: Uuid, closed_by: &str) -> Result<JournalEntry>;
fn revalue(
&self,
as_of_date: NaiveDate,
base_currency: Option<Currency>,
) -> Result<RevaluationResult>;
fn create_accounts_batch(&self, inputs: Vec<CreateGlAccount>)
-> Result<BatchResult<GlAccount>>;
fn get_accounts_batch(&self, ids: Vec<Uuid>) -> Result<Vec<GlAccount>>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait VectorRepository: Send + Sync {
fn store_embedding(
&self,
entity_type: EntityType,
entity_id: &str,
embedding: &[f32],
text_hash: &str,
model: &str,
) -> Result<()>;
fn search_products(
&self,
embedding: &[f32],
limit: usize,
) -> Result<Vec<VectorSearchResult<Product>>>;
fn search_customers(
&self,
embedding: &[f32],
limit: usize,
) -> Result<Vec<VectorSearchResult<Customer>>>;
fn search_orders(
&self,
embedding: &[f32],
limit: usize,
) -> Result<Vec<VectorSearchResult<Order>>>;
fn search_inventory(
&self,
embedding: &[f32],
limit: usize,
) -> Result<Vec<VectorSearchResult<InventoryItem>>>;
fn delete_embedding(&self, entity_type: EntityType, entity_id: &str) -> Result<()>;
fn has_embedding(&self, entity_type: EntityType, entity_id: &str) -> Result<bool>;
fn get_embedding_metadata(
&self,
entity_type: EntityType,
entity_id: &str,
) -> Result<Option<EmbeddingMetadata>>;
fn get_stats(&self) -> Result<EmbeddingStats>;
fn clear_embeddings(&self, entity_type: EntityType) -> Result<u64>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait X402PaymentIntentRepository: Send + Sync {
fn create(&self, input: CreateX402PaymentIntent) -> Result<X402PaymentIntent>;
fn get(&self, id: Uuid) -> Result<Option<X402PaymentIntent>>;
fn get_by_idempotency_key(&self, key: &str) -> Result<Option<X402PaymentIntent>>;
fn sign(&self, id: Uuid, input: SignX402PaymentIntent) -> Result<X402PaymentIntent>;
fn mark_sequenced(
&self,
id: Uuid,
sequence_number: u64,
batch_id: Uuid,
) -> Result<X402PaymentIntent>;
fn mark_settled(&self, id: Uuid, tx_hash: &str, block_number: u64)
-> Result<X402PaymentIntent>;
fn mark_failed(&self, id: Uuid, reason: &str) -> Result<X402PaymentIntent>;
fn mark_expired(&self, id: Uuid) -> Result<X402PaymentIntent>;
fn cancel(&self, id: Uuid) -> Result<X402PaymentIntent>;
fn for_cart(&self, cart_id: Uuid) -> Result<Vec<X402PaymentIntent>>;
fn for_order(&self, order_id: Uuid) -> Result<Vec<X402PaymentIntent>>;
fn get_next_nonce(&self, payer_address: &str) -> Result<u64>;
fn list(&self, filter: X402PaymentIntentFilter) -> Result<Vec<X402PaymentIntent>>;
fn count(&self, filter: X402PaymentIntentFilter) -> Result<u64>;
fn expire_stale_intents(&self) -> Result<u64>;
fn create_batch(
&self,
inputs: Vec<CreateX402PaymentIntent>,
) -> Result<BatchResult<X402PaymentIntent>>;
fn create_batch_atomic(
&self,
inputs: Vec<CreateX402PaymentIntent>,
) -> Result<Vec<X402PaymentIntent>>;
fn get_batch(&self, ids: Vec<Uuid>) -> Result<Vec<X402PaymentIntent>>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait X402CreditRepository: Send + Sync {
fn get_account(
&self,
payer_address: &str,
asset: X402Asset,
network: X402Network,
) -> Result<Option<X402CreditAccount>>;
fn get_or_create_account(
&self,
payer_address: &str,
asset: X402Asset,
network: X402Network,
) -> Result<X402CreditAccount>;
fn get_balance(
&self,
payer_address: &str,
asset: X402Asset,
network: X402Network,
) -> Result<u64>;
fn adjust_balance(&self, input: X402CreditAdjustment) -> Result<X402CreditTransaction>;
fn list_transactions(
&self,
filter: X402CreditTransactionFilter,
) -> Result<Vec<X402CreditTransaction>>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait AgentCardRepository: Send + Sync {
fn create(&self, input: CreateAgentCard) -> Result<AgentCard>;
fn get(&self, id: Uuid) -> Result<Option<AgentCard>>;
fn get_by_wallet(&self, wallet_address: &str) -> Result<Option<AgentCard>>;
fn update(&self, id: Uuid, input: UpdateAgentCard) -> Result<AgentCard>;
fn delete(&self, id: Uuid) -> Result<()>;
fn list(&self, filter: AgentCardFilter) -> Result<Vec<AgentCard>>;
fn count(&self, filter: AgentCardFilter) -> Result<u64>;
fn verify(&self, id: Uuid, trust_level: TrustLevel, method: &str) -> Result<AgentCard>;
fn suspend(&self, id: Uuid, reason: &str) -> Result<AgentCard>;
fn reactivate(&self, id: Uuid) -> Result<AgentCard>;
fn discover(&self, filter: AgentCardFilter) -> Result<Vec<AgentCard>>;
fn create_batch(&self, inputs: Vec<CreateAgentCard>) -> Result<BatchResult<AgentCard>>;
fn create_batch_atomic(&self, inputs: Vec<CreateAgentCard>) -> Result<Vec<AgentCard>>;
fn get_batch(&self, ids: Vec<Uuid>) -> Result<Vec<AgentCard>>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait AgentIdentityRepository: Send + Sync {
fn register(&self, input: CreateAgentIdentity) -> Result<AgentIdentity>;
fn get(&self, agent_registry: &str, agent_id: &str) -> Result<Option<AgentIdentity>>;
fn get_by_wallet(&self, agent_wallet: &str) -> Result<Option<AgentIdentity>>;
fn update(
&self,
agent_registry: &str,
agent_id: &str,
input: UpdateAgentIdentity,
) -> Result<AgentIdentity>;
#[allow(clippy::too_many_arguments)]
fn set_agent_wallet(
&self,
agent_registry: &str,
agent_id: &str,
agent_wallet: &str,
proof_type: Option<AgentWalletProofType>,
proof: Option<&str>,
proof_chain_id: Option<u64>,
proof_deadline: Option<DateTime<Utc>>,
) -> Result<AgentIdentity>;
fn clear_agent_wallet(&self, agent_registry: &str, agent_id: &str) -> Result<AgentIdentity>;
fn list(&self, filter: AgentIdentityFilter) -> Result<Vec<AgentIdentity>>;
fn count(&self, filter: AgentIdentityFilter) -> Result<u64>;
fn set_metadata(
&self,
agent_registry: &str,
agent_id: &str,
entry: AgentMetadataEntry,
) -> Result<()>;
fn get_metadata(
&self,
agent_registry: &str,
agent_id: &str,
metadata_key: &str,
) -> Result<Option<Vec<u8>>>;
fn delete_metadata(
&self,
agent_registry: &str,
agent_id: &str,
metadata_key: &str,
) -> Result<()>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait AgentReputationRepository: Send + Sync {
fn give_feedback(&self, input: CreateAgentFeedback) -> Result<AgentFeedback>;
fn revoke_feedback(
&self,
agent_registry: &str,
agent_id: &str,
client_address: &str,
feedback_index: u64,
) -> Result<AgentFeedback>;
fn read_feedback(
&self,
agent_registry: &str,
agent_id: &str,
client_address: &str,
feedback_index: u64,
) -> Result<Option<AgentFeedback>>;
fn read_all_feedback(&self, filter: AgentFeedbackFilter) -> Result<Vec<AgentFeedback>>;
fn get_summary(
&self,
agent_registry: &str,
agent_id: &str,
client_addresses: Vec<String>,
tag1: Option<String>,
tag2: Option<String>,
) -> Result<FeedbackSummary>;
fn append_response(&self, input: CreateAgentFeedbackResponse) -> Result<AgentFeedbackResponse>;
fn get_response_count(
&self,
agent_registry: &str,
agent_id: &str,
client_address: &str,
feedback_index: u64,
responders: Option<Vec<String>>,
) -> Result<u64>;
fn get_clients(&self, agent_registry: &str, agent_id: &str) -> Result<Vec<String>>;
fn get_last_index(
&self,
agent_registry: &str,
agent_id: &str,
client_address: &str,
) -> Result<u64>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait AgentValidationRepository: Send + Sync {
fn request_validation(
&self,
input: CreateAgentValidationRequest,
) -> Result<AgentValidationRequest>;
fn respond_validation(
&self,
request_hash: &str,
input: CreateAgentValidationResponse,
) -> Result<AgentValidationResponse>;
fn get_validation_status(&self, request_hash: &str) -> Result<Option<AgentValidationStatus>>;
fn get_summary(
&self,
agent_registry: &str,
agent_id: &str,
validator_addresses: Option<Vec<String>>,
tag: Option<String>,
) -> Result<ValidationSummary>;
fn get_agent_validations(&self, agent_registry: &str, agent_id: &str) -> Result<Vec<String>>;
fn get_validator_requests(&self, validator_address: &str) -> Result<Vec<String>>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait A2ACommerceRepository: Send + Sync {
fn create_quote(&self, input: CreateA2AQuote) -> Result<SkillQuote>;
fn get_quote(&self, id: Uuid) -> Result<Option<SkillQuote>>;
fn get_quote_by_number(&self, quote_number: &str) -> Result<Option<SkillQuote>>;
fn update_quote_status(&self, id: Uuid, status: QuoteStatus) -> Result<SkillQuote>;
fn list_quotes(&self, filter: SkillQuoteFilter) -> Result<Vec<SkillQuote>>;
fn count_quotes(&self, filter: SkillQuoteFilter) -> Result<u64>;
fn create_purchase(&self, input: CreateA2APurchase) -> Result<A2APurchase>;
fn get_purchase(&self, id: Uuid) -> Result<Option<A2APurchase>>;
fn get_purchase_by_number(&self, purchase_number: &str) -> Result<Option<A2APurchase>>;
fn update_purchase_status(&self, id: Uuid, status: PurchaseStatus) -> Result<A2APurchase>;
fn link_purchase_to_order(&self, purchase_id: Uuid, order_id: Uuid) -> Result<A2APurchase>;
fn confirm_delivery(
&self,
purchase_id: Uuid,
signature: &str,
rating: Option<u8>,
feedback: Option<&str>,
) -> Result<A2APurchase>;
fn list_purchases(&self, filter: A2APurchaseFilter) -> Result<Vec<A2APurchase>>;
fn count_purchases(&self, filter: A2APurchaseFilter) -> Result<u64>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait CustomObjectRepository: Send + Sync {
fn create_type(&self, input: CreateCustomObjectType) -> Result<CustomObjectType>;
fn get_type(&self, id: Uuid) -> Result<Option<CustomObjectType>>;
fn get_type_by_handle(&self, handle: &str) -> Result<Option<CustomObjectType>>;
fn update_type(&self, id: Uuid, input: UpdateCustomObjectType) -> Result<CustomObjectType>;
fn list_types(&self, filter: CustomObjectTypeFilter) -> Result<Vec<CustomObjectType>>;
fn delete_type(&self, id: Uuid) -> Result<()>;
fn create_object(&self, input: CreateCustomObject) -> Result<CustomObject>;
fn get_object(&self, id: Uuid) -> Result<Option<CustomObject>>;
fn get_object_by_handle(
&self,
type_handle: &str,
object_handle: &str,
) -> Result<Option<CustomObject>>;
fn update_object(&self, id: Uuid, input: UpdateCustomObject) -> Result<CustomObject>;
fn list_objects(&self, filter: CustomObjectFilter) -> Result<Vec<CustomObject>>;
fn delete_object(&self, id: Uuid) -> Result<()>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait GiftCardRepository: Send + Sync {
fn create(&self, input: CreateGiftCard) -> Result<GiftCard>;
fn get(&self, id: GiftCardId) -> Result<Option<GiftCard>>;
fn get_by_code(&self, code: &str) -> Result<Option<GiftCard>>;
fn update(&self, id: GiftCardId, input: UpdateGiftCard) -> Result<GiftCard>;
fn list(&self, filter: GiftCardFilter) -> Result<Vec<GiftCard>>;
fn charge(
&self,
id: GiftCardId,
amount: rust_decimal::Decimal,
reference_id: Option<String>,
) -> Result<GiftCardTransaction>;
fn refund(
&self,
id: GiftCardId,
amount: rust_decimal::Decimal,
reference_id: Option<String>,
) -> Result<GiftCardTransaction>;
fn disable(&self, id: GiftCardId) -> Result<GiftCard>;
fn get_transactions(&self, gift_card_id: GiftCardId) -> Result<Vec<GiftCardTransaction>>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait StoreCreditRepository: Send + Sync {
fn create(&self, input: CreateStoreCredit) -> Result<StoreCredit>;
fn get(&self, id: StoreCreditId) -> Result<Option<StoreCredit>>;
fn list(&self, filter: StoreCreditFilter) -> Result<Vec<StoreCredit>>;
fn adjust(&self, id: StoreCreditId, input: AdjustStoreCredit) -> Result<StoreCredit>;
fn apply(
&self,
id: StoreCreditId,
amount: rust_decimal::Decimal,
reference_id: Option<String>,
) -> Result<StoreCreditTransaction>;
fn get_transactions(
&self,
store_credit_id: StoreCreditId,
) -> Result<Vec<StoreCreditTransaction>>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait SegmentRepository: Send + Sync {
fn create(&self, input: CreateSegment) -> Result<Segment>;
fn get(&self, id: SegmentId) -> Result<Option<Segment>>;
fn update(&self, id: SegmentId, input: UpdateSegment) -> Result<Segment>;
fn list(&self, filter: SegmentFilter) -> Result<Vec<Segment>>;
fn delete(&self, id: SegmentId) -> Result<()>;
fn add_member(
&self,
segment_id: SegmentId,
customer_id: CustomerId,
) -> Result<SegmentMembership>;
fn remove_member(&self, segment_id: SegmentId, customer_id: CustomerId) -> Result<()>;
fn list_members(
&self,
segment_id: SegmentId,
limit: Option<u32>,
offset: Option<u32>,
) -> Result<Vec<SegmentMembership>>;
fn is_member(&self, segment_id: SegmentId, customer_id: CustomerId) -> Result<bool>;
fn count_members(&self, segment_id: SegmentId) -> Result<u64>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait ShippingZoneRepository: Send + Sync {
fn create(&self, input: CreateShippingZone) -> Result<ShippingZone>;
fn get(&self, id: ShippingZoneId) -> Result<Option<ShippingZone>>;
fn update(&self, id: ShippingZoneId, input: UpdateShippingZone) -> Result<ShippingZone>;
fn list(&self, filter: ShippingZoneFilter) -> Result<Vec<ShippingZone>>;
fn delete(&self, id: ShippingZoneId) -> Result<()>;
fn find_matching_zones(
&self,
country: &str,
region: Option<&str>,
postal_code: Option<&str>,
) -> Result<Vec<ShippingZone>>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait ZoneShippingMethodRepository: Send + Sync {
fn create(&self, input: CreateZoneShippingMethod) -> Result<ZoneShippingMethod>;
fn get(&self, id: ShippingMethodId) -> Result<Option<ZoneShippingMethod>>;
fn list(&self, filter: ZoneShippingMethodFilter) -> Result<Vec<ZoneShippingMethod>>;
fn delete(&self, id: ShippingMethodId) -> Result<()>;
fn calculate_rates(&self, request: ZoneShippingRateRequest) -> Result<Vec<ZoneShippingRate>>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait ReviewRepository: Send + Sync {
fn create(&self, input: CreateReview) -> Result<Review>;
fn get(&self, id: ReviewId) -> Result<Option<Review>>;
fn update(&self, id: ReviewId, input: UpdateReview) -> Result<Review>;
fn list(&self, filter: ReviewFilter) -> Result<Vec<Review>>;
fn delete(&self, id: ReviewId) -> Result<()>;
fn get_summary(&self, product_id: ProductId) -> Result<ReviewSummary>;
fn mark_helpful(&self, id: ReviewId) -> Result<()>;
fn mark_reported(&self, id: ReviewId) -> Result<()>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait WishlistRepository: Send + Sync {
fn create(&self, input: CreateWishlist) -> Result<Wishlist>;
fn get(&self, id: WishlistId) -> Result<Option<Wishlist>>;
fn update(&self, id: WishlistId, input: UpdateWishlist) -> Result<Wishlist>;
fn list(&self, filter: WishlistFilter) -> Result<Vec<Wishlist>>;
fn delete(&self, id: WishlistId) -> Result<()>;
fn add_item(&self, wishlist_id: WishlistId, item: AddWishlistItem) -> Result<WishlistItem>;
fn remove_item(&self, wishlist_id: WishlistId, product_id: ProductId) -> Result<()>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait LoyaltyProgramRepository: Send + Sync {
fn create(&self, input: CreateLoyaltyProgram) -> Result<LoyaltyProgram>;
fn get(&self, id: LoyaltyProgramId) -> Result<Option<LoyaltyProgram>>;
fn list(&self) -> Result<Vec<LoyaltyProgram>>;
fn enroll(&self, input: EnrollCustomer) -> Result<LoyaltyAccount>;
fn get_account(&self, id: LoyaltyAccountId) -> Result<Option<LoyaltyAccount>>;
fn get_account_by_customer(
&self,
customer_id: CustomerId,
program_id: LoyaltyProgramId,
) -> Result<Option<LoyaltyAccount>>;
fn list_accounts(&self, filter: LoyaltyAccountFilter) -> Result<Vec<LoyaltyAccount>>;
fn adjust_points(&self, input: AdjustPoints) -> Result<LoyaltyTransaction>;
fn get_transactions(
&self,
account_id: LoyaltyAccountId,
limit: Option<u32>,
) -> Result<Vec<LoyaltyTransaction>>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait RewardRepository: Send + Sync {
fn create(&self, input: CreateReward) -> Result<Reward>;
fn get(&self, id: RewardId) -> Result<Option<Reward>>;
fn list(&self, filter: RewardFilter) -> Result<Vec<Reward>>;
fn delete(&self, id: RewardId) -> Result<()>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait FraudRepository: Send + Sync {
fn create_assessment(&self, input: CreateFraudAssessment) -> Result<FraudAssessment>;
fn get_assessment(&self, order_id: OrderId) -> Result<Option<FraudAssessment>>;
fn list_assessments(&self, filter: FraudAssessmentFilter) -> Result<Vec<FraudAssessment>>;
fn review_assessment(
&self,
order_id: OrderId,
decision: FraudDecision,
reviewer: String,
notes: Option<String>,
) -> Result<FraudAssessment>;
fn create_rule(&self, input: CreateFraudRule) -> Result<FraudRule>;
fn get_rule(&self, id: FraudRuleId) -> Result<Option<FraudRule>>;
fn update_rule(&self, id: FraudRuleId, input: UpdateFraudRule) -> Result<FraudRule>;
fn list_rules(&self, filter: FraudRuleFilter) -> Result<Vec<FraudRule>>;
fn delete_rule(&self, id: FraudRuleId) -> Result<()>;
fn get_active_rules(&self) -> Result<Vec<FraudRule>>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait SearchConfigRepository: Send + Sync {
fn create(&self, input: CreateSearchConfig) -> Result<SearchConfig>;
fn get(&self, id: SearchConfigId) -> Result<Option<SearchConfig>>;
fn update(&self, id: SearchConfigId, input: UpdateSearchConfig) -> Result<SearchConfig>;
fn list(&self, filter: SearchConfigFilter) -> Result<Vec<SearchConfig>>;
fn delete(&self, id: SearchConfigId) -> Result<()>;
fn get_active(&self) -> Result<Option<SearchConfig>>;
fn set_active(&self, id: SearchConfigId) -> Result<SearchConfig>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait ChannelRepository: Send + Sync {
fn create(&self, input: CreateChannel) -> Result<Channel>;
fn get(&self, id: ChannelId) -> Result<Option<Channel>>;
fn update(&self, id: ChannelId, input: UpdateChannel) -> Result<Channel>;
fn list(&self, filter: ChannelFilter) -> Result<Vec<Channel>>;
fn delete(&self, id: ChannelId) -> Result<()>;
fn set_lock(&self, id: ChannelId, locked: bool) -> Result<Channel>;
fn sync_products(&self, id: ChannelId, items: Vec<ChannelProductSyncItem>) -> Result<u64>;
fn list_product_mappings(&self, id: ChannelId) -> Result<Vec<ChannelProductMapping>>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait CompanyRepository: Send + Sync {
fn create(&self, input: CreateCompany) -> Result<Company>;
fn get(&self, id: CompanyId) -> Result<Option<Company>>;
fn update(&self, id: CompanyId, input: UpdateCompany) -> Result<Company>;
fn list(&self, filter: CompanyFilter) -> Result<Vec<Company>>;
fn delete(&self, id: CompanyId) -> Result<()>;
fn list_addresses(&self, id: CompanyId) -> Result<Vec<CompanyShippingAddress>>;
fn list_price_overrides(&self, id: CompanyId) -> Result<Vec<CompanyPriceOverride>>;
fn create_contact(&self, input: CreateContact) -> Result<Contact>;
fn get_contact(&self, id: ContactId) -> Result<Option<Contact>>;
fn list_contacts(&self, company_id: CompanyId) -> Result<Vec<Contact>>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait TransferOrderRepository: Send + Sync {
fn create(&self, input: CreateTransferOrder) -> Result<TransferOrder>;
fn get(&self, id: TransferOrderId) -> Result<Option<TransferOrder>>;
fn list(&self, filter: TransferOrderFilter) -> Result<Vec<TransferOrder>>;
fn ship(&self, id: TransferOrderId) -> Result<TransferOrder>;
fn receive_line(
&self,
id: TransferOrderId,
item_id: TransferOrderItemId,
quantity: rust_decimal::Decimal,
) -> Result<TransferOrder>;
fn cancel(&self, id: TransferOrderId) -> Result<TransferOrder>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait UnitOfMeasureRepository: Send + Sync {
fn create_class(&self, input: CreateUnitClass) -> Result<UnitClass>;
fn list_classes(&self) -> Result<Vec<UnitClass>>;
fn delete_class(&self, id: UnitClassId) -> Result<()>;
fn create_uom(&self, input: CreateUnitOfMeasure) -> Result<UnitOfMeasure>;
fn list_uoms(&self, filter: UnitOfMeasureFilter) -> Result<Vec<UnitOfMeasure>>;
fn set_base_uom(&self, id: UnitOfMeasureId) -> Result<UnitOfMeasure>;
fn delete_uom(&self, id: UnitOfMeasureId) -> Result<()>;
fn create_rule(&self, input: CreateUnitConversionRule) -> Result<UnitConversionRule>;
fn list_rules(&self) -> Result<Vec<UnitConversionRule>>;
fn delete_rule(&self, id: UnitConversionRuleId) -> Result<()>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait ProductionBatchRepository: Send + Sync {
fn create(&self, input: CreateProductionBatch) -> Result<ProductionBatch>;
fn get(&self, id: ProductionBatchId) -> Result<Option<ProductionBatch>>;
fn update(
&self,
id: ProductionBatchId,
input: UpdateProductionBatch,
) -> Result<ProductionBatch>;
fn list(&self, filter: ProductionBatchFilter) -> Result<Vec<ProductionBatch>>;
fn delete(&self, id: ProductionBatchId) -> Result<()>;
fn add_work_orders(
&self,
id: ProductionBatchId,
work_order_ids: Vec<uuid::Uuid>,
) -> Result<ProductionBatch>;
fn remove_work_order(
&self,
id: ProductionBatchId,
work_order_id: uuid::Uuid,
) -> Result<ProductionBatch>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait SupplierSkuRepository: Send + Sync {
fn create(&self, input: CreateSupplierSku) -> Result<SupplierSku>;
fn get(&self, id: SupplierSkuId) -> Result<Option<SupplierSku>>;
fn update(&self, id: SupplierSkuId, input: UpdateSupplierSku) -> Result<SupplierSku>;
fn list(&self, filter: SupplierSkuFilter) -> Result<Vec<SupplierSku>>;
fn delete(&self, id: SupplierSkuId) -> Result<()>;
fn bulk_upsert(&self, supplier_id: uuid::Uuid, items: Vec<BulkSupplierSkuItem>) -> Result<u64>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait VendorReturnRepository: Send + Sync {
fn create(&self, input: CreateVendorReturn) -> Result<VendorReturn>;
fn get(&self, id: VendorReturnId) -> Result<Option<VendorReturn>>;
fn list(&self, filter: VendorReturnFilter) -> Result<Vec<VendorReturn>>;
fn submit(&self, id: VendorReturnId) -> Result<VendorReturn>;
fn process(&self, id: VendorReturnId, generate_credit: bool) -> Result<VendorReturn>;
fn cancel(&self, id: VendorReturnId) -> Result<VendorReturn>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait VendorCreditRepository: Send + Sync {
fn create(&self, input: CreateVendorCredit) -> Result<VendorCredit>;
fn get(&self, id: VendorCreditId) -> Result<Option<VendorCredit>>;
fn list(&self, filter: VendorCreditFilter) -> Result<Vec<VendorCredit>>;
fn apply(&self, id: VendorCreditId, input: ApplyVendorCredit) -> Result<VendorCredit>;
fn list_applications(&self, id: VendorCreditId) -> Result<Vec<VendorCreditApplication>>;
fn reverse_application(
&self,
id: VendorCreditId,
application_id: VendorCreditApplicationId,
) -> Result<VendorCredit>;
fn cancel(&self, id: VendorCreditId) -> Result<VendorCredit>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait PaymentObligationRepository: Send + Sync {
fn create(&self, input: CreatePaymentObligation) -> Result<PaymentObligation>;
fn get(&self, id: PaymentObligationId) -> Result<Option<PaymentObligation>>;
fn list(&self, filter: PaymentObligationFilter) -> Result<Vec<PaymentObligation>>;
fn record_payment(
&self,
id: PaymentObligationId,
amount: rust_decimal::Decimal,
) -> Result<PaymentObligation>;
fn set_status(
&self,
id: PaymentObligationId,
status: PaymentObligationStatus,
) -> Result<PaymentObligation>;
fn link_bill(&self, id: PaymentObligationId, bill_id: uuid::Uuid) -> Result<PaymentObligation>;
fn dashboard(&self, today: chrono::NaiveDate) -> Result<PaymentObligationDashboard>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait PriceLevelRepository: Send + Sync {
fn create(&self, input: CreatePriceLevel) -> Result<PriceLevel>;
fn get(&self, id: PriceLevelId) -> Result<Option<PriceLevel>>;
fn update(&self, id: PriceLevelId, input: UpdatePriceLevel) -> Result<PriceLevel>;
fn list(&self, filter: PriceLevelFilter) -> Result<Vec<PriceLevel>>;
fn delete(&self, id: PriceLevelId) -> Result<()>;
fn set_entry(
&self,
id: PriceLevelId,
product_id: ProductId,
price: rust_decimal::Decimal,
) -> Result<PriceLevelEntry>;
fn delete_entry(&self, id: PriceLevelId, product_id: ProductId) -> Result<()>;
fn list_entries(&self, id: PriceLevelId) -> Result<Vec<PriceLevelEntry>>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait PrepaymentRepository: Send + Sync {
fn create(&self, input: CreatePrepayment) -> Result<Prepayment>;
fn get(&self, id: PrepaymentId) -> Result<Option<Prepayment>>;
fn list(&self, filter: PrepaymentFilter) -> Result<Vec<Prepayment>>;
fn apply(&self, id: PrepaymentId, input: ApplyPrepayment) -> Result<Prepayment>;
fn list_applications(&self, id: PrepaymentId) -> Result<Vec<PrepaymentApplication>>;
fn reverse_application(
&self,
id: PrepaymentId,
application_id: PrepaymentApplicationId,
) -> Result<Prepayment>;
fn refund(&self, id: PrepaymentId) -> Result<Prepayment>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait PriceScheduleRepository: Send + Sync {
fn create(&self, input: CreatePriceSchedule) -> Result<PriceSchedule>;
fn get(&self, id: PriceScheduleId) -> Result<Option<PriceSchedule>>;
fn update(&self, id: PriceScheduleId, input: UpdatePriceSchedule) -> Result<PriceSchedule>;
fn list(&self, filter: PriceScheduleFilter) -> Result<Vec<PriceSchedule>>;
fn delete(&self, id: PriceScheduleId) -> Result<()>;
fn set_entry(
&self,
id: PriceScheduleId,
product_id: ProductId,
price: rust_decimal::Decimal,
) -> Result<PriceScheduleEntry>;
fn delete_entry(&self, id: PriceScheduleId, product_id: ProductId) -> Result<()>;
fn list_entries(&self, id: PriceScheduleId) -> Result<Vec<PriceScheduleEntry>>;
fn resolve_price(
&self,
product_id: ProductId,
at: chrono::DateTime<chrono::Utc>,
) -> Result<Option<rust_decimal::Decimal>>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait ActivityLogRepository: Send + Sync {
fn record(&self, input: RecordActivity) -> Result<ActivityLogEntry>;
fn get(&self, id: ActivityLogId) -> Result<Option<ActivityLogEntry>>;
fn list(&self, filter: ActivityLogFilter) -> Result<Vec<ActivityLogEntry>>;
fn history_for_subject(
&self,
subject_type: &str,
subject_id: uuid::Uuid,
) -> Result<Vec<ActivityLogEntry>>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait IntegrationMappingRepository: Send + Sync {
fn create(&self, input: CreateIntegrationMapping) -> Result<IntegrationMapping>;
fn get(&self, id: IntegrationMappingId) -> Result<Option<IntegrationMapping>>;
fn update(
&self,
id: IntegrationMappingId,
input: UpdateIntegrationMapping,
) -> Result<IntegrationMapping>;
fn list(&self, filter: IntegrationMappingFilter) -> Result<Vec<IntegrationMapping>>;
fn delete(&self, id: IntegrationMappingId) -> Result<()>;
fn bulk_upsert(&self, items: Vec<CreateIntegrationMapping>) -> Result<u64>;
fn resolve(&self, lookup: &MappingLookup) -> Result<Option<String>>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait InboundShipmentRepository: Send + Sync {
fn create(&self, input: CreateInboundShipment) -> Result<InboundShipment>;
fn get(&self, id: InboundShipmentId) -> Result<Option<InboundShipment>>;
fn list(&self, filter: InboundShipmentFilter) -> Result<Vec<InboundShipment>>;
fn mark_in_transit(&self, id: InboundShipmentId) -> Result<InboundShipment>;
fn mark_arrived(&self, id: InboundShipmentId) -> Result<InboundShipment>;
fn receive_line(
&self,
id: InboundShipmentId,
item_id: InboundShipmentItemId,
quantity: rust_decimal::Decimal,
) -> Result<InboundShipment>;
fn cancel(&self, id: InboundShipmentId) -> Result<InboundShipment>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait PurgatoryRepository: Send + Sync {
fn ingest(&self, input: IngestOrder) -> Result<PurgatoryOrder>;
fn get(&self, id: PurgatoryOrderId) -> Result<Option<PurgatoryOrder>>;
fn list(&self, filter: PurgatoryFilter) -> Result<Vec<PurgatoryOrder>>;
fn map_line(
&self,
id: PurgatoryOrderId,
line_id: PurgatoryLineItemId,
input: MapPurgatoryLine,
) -> Result<PurgatoryOrder>;
fn post(&self, id: PurgatoryOrderId) -> Result<PurgatoryOrder>;
fn delete(&self, id: PurgatoryOrderId) -> Result<()>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait PrintStationRepository: Send + Sync {
fn pair(&self, input: CreatePrintStation) -> Result<PairStationResult>;
fn list_stations(&self) -> Result<Vec<PrintStation>>;
fn get_station(&self, id: PrintStationId) -> Result<Option<PrintStation>>;
fn revoke_station(&self, id: PrintStationId) -> Result<PrintStation>;
fn enqueue_job(&self, station_id: PrintStationId, input: EnqueuePrintJob) -> Result<PrintJob>;
fn next_job(&self, station_id: PrintStationId) -> Result<Option<PrintJob>>;
fn complete_job(&self, job_id: PrintJobId, success: bool) -> Result<PrintJob>;
fn list_jobs(
&self,
station_id: PrintStationId,
filter: PrintJobFilter,
) -> Result<Vec<PrintJob>>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait EdiDocumentRepository: Send + Sync {
fn create(&self, input: CreateEdiDocument) -> Result<EdiDocument>;
fn get(&self, id: EdiDocumentId) -> Result<Option<EdiDocument>>;
fn list(&self, filter: EdiDocumentFilter) -> Result<Vec<EdiDocument>>;
fn set_status(
&self,
id: EdiDocumentId,
status: EdiStatus,
error_message: Option<String>,
) -> Result<EdiDocument>;
fn summary(&self) -> Result<EdiAggregateSummary>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait IntegrationFieldMappingRepository: Send + Sync {
fn create(&self, input: CreateIntegrationFieldMapping) -> Result<IntegrationFieldMapping>;
fn get(&self, id: IntegrationFieldMappingId) -> Result<Option<IntegrationFieldMapping>>;
fn update(
&self,
id: IntegrationFieldMappingId,
input: UpdateIntegrationFieldMapping,
) -> Result<IntegrationFieldMapping>;
fn list(&self, filter: IntegrationFieldMappingFilter) -> Result<Vec<IntegrationFieldMapping>>;
fn delete(&self, id: IntegrationFieldMappingId) -> Result<()>;
fn bulk_create(&self, items: Vec<CreateIntegrationFieldMapping>) -> Result<u64>;
fn bulk_delete(&self, ids: Vec<IntegrationFieldMappingId>) -> Result<u64>;
fn distinct_groups(&self, integration_account: &str) -> Result<Vec<String>>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait TopologySnapshotRepository: Send + Sync {
fn capture(&self, input: CaptureTopologySnapshot) -> Result<TopologySnapshot>;
fn get(&self, id: TopologySnapshotId) -> Result<Option<TopologySnapshot>>;
fn latest(&self) -> Result<Option<TopologySnapshot>>;
fn list(&self, filter: TopologySnapshotFilter) -> Result<Vec<TopologySnapshot>>;
fn delete(&self, id: TopologySnapshotId) -> Result<()>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait StockSnapshotRepository: Send + Sync {
fn capture(&self, input: CaptureStockSnapshot) -> Result<StockSnapshot>;
fn get(&self, id: StockSnapshotId) -> Result<Option<StockSnapshot>>;
fn latest(&self) -> Result<Option<StockSnapshot>>;
fn list(&self, filter: StockSnapshotFilter) -> Result<Vec<StockSnapshot>>;
fn delete(&self, id: StockSnapshotId) -> Result<()>;
}
use crate::models::{
CreateFixedAsset, CreateRevenueContract, DepreciationSchedule, FixedAsset, FixedAssetFilter,
PerformanceObligation, RevenueContract, RevenueContractFilter, RevenueSchedule,
UpdateFixedAsset, UpdateRevenueContract,
};
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait FixedAssetRepository: Send + Sync {
fn create(&self, input: CreateFixedAsset) -> Result<FixedAsset>;
fn get(&self, id: uuid::Uuid) -> Result<Option<FixedAsset>>;
fn list(&self, filter: FixedAssetFilter) -> Result<Vec<FixedAsset>>;
fn update(&self, id: uuid::Uuid, input: UpdateFixedAsset) -> Result<FixedAsset>;
fn place_in_service(&self, id: uuid::Uuid, date: chrono::NaiveDate) -> Result<FixedAsset>;
fn dispose(
&self,
id: uuid::Uuid,
date: chrono::NaiveDate,
proceeds: rust_decimal::Decimal,
notes: Option<String>,
) -> Result<FixedAsset>;
fn write_off(
&self,
id: uuid::Uuid,
date: chrono::NaiveDate,
notes: Option<String>,
) -> Result<FixedAsset>;
fn generate_schedule(&self, id: uuid::Uuid) -> Result<DepreciationSchedule>;
fn get_schedule(&self, id: uuid::Uuid) -> Result<Option<DepreciationSchedule>>;
fn post_depreciation(&self, id: uuid::Uuid, periods: u32) -> Result<FixedAsset>;
}
#[auto_impl::auto_impl(&, Box, Arc)]
pub trait RevenueRecognitionRepository: Send + Sync {
fn create_contract(&self, input: CreateRevenueContract) -> Result<RevenueContract>;
fn get_contract(&self, id: uuid::Uuid) -> Result<Option<RevenueContract>>;
fn list_contracts(&self, filter: RevenueContractFilter) -> Result<Vec<RevenueContract>>;
fn update_contract(
&self,
id: uuid::Uuid,
input: UpdateRevenueContract,
) -> Result<RevenueContract>;
fn list_obligations(&self, contract_id: uuid::Uuid) -> Result<Vec<PerformanceObligation>>;
fn generate_schedule(&self, obligation_id: uuid::Uuid) -> Result<RevenueSchedule>;
fn get_schedule(&self, obligation_id: uuid::Uuid) -> Result<Option<RevenueSchedule>>;
fn recognize_period(
&self,
obligation_id: uuid::Uuid,
through: chrono::NaiveDate,
) -> Result<RevenueSchedule>;
}