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 PosOpeningEntry aggregate
//!
//! Generated by metaphor-schema. Do not edit manually.
//!
//! This trait defines the repository contract for the PosOpeningEntry aggregate.
//! Implementation is in the infrastructure layer.

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

use crate::domain::entity::{PosOpeningEntry, PosSessionStatus};

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

impl PosOpeningEntryPaginationParams {
    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 PosOpeningEntryPaginatedResult {
    pub data: Vec<PosOpeningEntry>,
    pub total: u64,
    pub page: u32,
    pub per_page: u32,
}

/// Filter parameters for list queries
#[derive(Debug, Clone, Default)]
pub struct PosOpeningEntryFilter {
    pub pos_profile_id: Option<Uuid>,
    pub branch_id: Option<Uuid>,
    pub cashier_party_id: Option<Uuid>,
    pub status: Option<PosSessionStatus>,
}

impl PosOpeningEntryFilter {
    /// Check if any filter is set
    pub fn has_filters(&self) -> bool {
        self.pos_profile_id.is_some() || self.branch_id.is_some() || self.cashier_party_id.is_some() || self.status.is_some()
    }
}

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

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

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

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

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

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

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

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

    /// List pos_opening_entry with pagination
    async fn list(&self, params: PosOpeningEntryPaginationParams) -> Result<PosOpeningEntryPaginatedResult>;

    /// List pos_opening_entry with pagination and filters
    async fn list_with_filters(&self, params: PosOpeningEntryPaginationParams, filters: PosOpeningEntryFilter) -> Result<PosOpeningEntryPaginatedResult>;

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

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

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

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

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

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

    /// List soft-deleted pos_opening_entry entities
    async fn list_deleted(&self, params: PosOpeningEntryPaginationParams) -> Result<PosOpeningEntryPaginatedResult>;

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

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

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

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