backbone-accounting 0.15.0

GL, journals, ledger, reconciliation (extracted from bersihir)
Documentation
//! Repository trait for PrintedCheck aggregate
//!
//! Generated by metaphor-schema. Do not edit manually.
//!
//! This trait defines the repository contract for the PrintedCheck aggregate.
//! Implementation is in the infrastructure layer.

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

use crate::domain::entity::PrintedCheck;

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

impl PrintedCheckPaginationParams {
    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 PrintedCheckPaginatedResult {
    pub data: Vec<PrintedCheck>,
    pub total: u64,
    pub page: u32,
    pub per_page: u32,
}

/// Filter parameters for list queries
#[derive(Debug, Clone, Default)]
pub struct PrintedCheckFilter {
    pub bank_account_id: Option<Uuid>,
    pub payment_id: Option<Uuid>,
    pub payment_number: Option<String>,
    pub check_number: Option<String>,
    pub payee_name: Option<String>,
    pub status: Option<String>,
    pub printed_by: Option<Uuid>,
}

impl PrintedCheckFilter {
    /// Check if any filter is set
    pub fn has_filters(&self) -> bool {
        self.bank_account_id.is_some() || self.payment_id.is_some() || self.payment_number.is_some() || self.check_number.is_some() || self.payee_name.is_some() || self.status.is_some() || self.printed_by.is_some()
    }
}

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

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

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

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

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

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

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

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

    /// List printed_check with pagination
    async fn list(&self, params: PrintedCheckPaginationParams) -> Result<PrintedCheckPaginatedResult>;

    /// List printed_check with pagination and filters
    async fn list_with_filters(&self, params: PrintedCheckPaginationParams, filters: PrintedCheckFilter) -> Result<PrintedCheckPaginatedResult>;

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

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

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

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

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

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