backbone-pos 0.7.0

Point of sale — cashier session, ticket + multi-tender; orchestrates billing (revenue) + payment (settlement), posts no GL directly
Documentation
//! Repository trait for PosTable aggregate
//!
//! Generated by metaphor-schema. Do not edit manually.
//!
//! This trait defines the repository contract for the PosTable aggregate.
//! Implementation is in the infrastructure layer.

use async_trait::async_trait;
use anyhow::Result;
use uuid::Uuid;

use crate::domain::entity::PosTable;

/// Pagination parameters for list queries
#[derive(Debug, Clone, Default)]
pub struct PosTablePaginationParams {
    pub page: u32,
    pub per_page: u32,
}

impl PosTablePaginationParams {
    pub fn new(page: u32, per_page: u32) -> Self {
        Self { page, per_page }
    }

    pub fn offset(&self) -> u64 {
        ((self.page.saturating_sub(1)) * self.per_page) as u64
    }

    pub fn limit(&self) -> u64 {
        self.per_page as u64
    }
}

/// Paginated result for list queries
#[derive(Debug, Clone)]
pub struct PosTablePaginatedResult {
    pub data: Vec<PosTable>,
    pub total: u64,
    pub page: u32,
    pub per_page: u32,
}

/// Filter parameters for list queries
#[derive(Debug, Clone, Default)]
pub struct PosTableFilter {
    pub pos_floor_plan_id: Option<Uuid>,
    pub name: Option<String>,
    pub shape: Option<String>,
}

impl PosTableFilter {
    /// Check if any filter is set
    pub fn has_filters(&self) -> bool {
        self.pos_floor_plan_id.is_some() || self.name.is_some() || self.shape.is_some()
    }
}

/// Repository trait for PosTable aggregate
///
/// This trait defines the persistence contract for PosTable entities.
/// Implementations should be in the infrastructure layer.
#[async_trait]
pub trait PosTableRepository: Send + Sync {

    // =========================================================================
    // Core CRUD Operations
    // =========================================================================

    /// Save a new pos_table entity
    async fn save(&self, entity: &PosTable) -> Result<PosTable>;

    /// Find pos_table by ID
    async fn find_by_id(&self, id: &str) -> Result<Option<PosTable>>;

    /// Find all pos_table entities
    async fn find_all(&self) -> Result<Vec<PosTable>>;

    /// Update pos_table by ID
    async fn update(&self, id: &str, entity: &PosTable) -> Result<Option<PosTable>>;

    /// Delete pos_table by ID
    async fn delete(&self, id: &str) -> Result<bool>;

    // =========================================================================
    // Pagination
    // =========================================================================

    /// List pos_table with pagination
    async fn list(&self, params: PosTablePaginationParams) -> Result<PosTablePaginatedResult>;

    /// List pos_table with pagination and filters
    async fn list_with_filters(&self, params: PosTablePaginationParams, filters: PosTableFilter) -> Result<PosTablePaginatedResult>;

    /// Count all pos_table entities
    async fn count(&self) -> Result<u64>;

    /// Count pos_table entities matching filters
    async fn count_with_filters(&self, filters: PosTableFilter) -> Result<u64>;

    /// Check if pos_table exists by ID
    async fn exists(&self, id: &str) -> Result<bool>;

    // =========================================================================
    // Soft Delete Operations
    // =========================================================================

    /// Soft delete pos_table by ID
    async fn soft_delete(&self, id: &str) -> Result<bool>;

    /// Restore soft-deleted pos_table by ID
    async fn restore(&self, id: &str) -> Result<Option<PosTable>>;

    /// List soft-deleted pos_table entities
    async fn list_deleted(&self, params: PosTablePaginationParams) -> Result<PosTablePaginatedResult>;

    /// Empty trash (permanently delete all soft-deleted entities)
    async fn empty_trash(&self) -> Result<u64>;

    // =========================================================================
    // Bulk Operations
    // =========================================================================

    /// Bulk save pos_table entities
    async fn bulk_save(&self, entities: &[PosTable]) -> Result<Vec<PosTable>>;

    /// Bulk delete by IDs
    async fn bulk_delete(&self, ids: &[&str]) -> Result<u64>;
}