backbone-accounting 0.15.0

GL, journals, ledger, reconciliation (extracted from bersihir)
Documentation
//! HTTP route configuration
//!
//! Generated by metaphor-schema. Do not edit manually.
//!
//! This module provides consolidated Axum route configuration using backbone-core's
//! BackboneCrudHandler for all 12 standard Backbone CRUD endpoints per entity.

use axum::Router;
use std::sync::Arc;

use super::{
    account_handler::create_account_routes,
    accounting_post_handler::create_accounting_post_routes,
    cost_center_handler::create_cost_center_routes,
    emv_qr_config_handler::create_emv_qr_config_routes,
    bank_check_sequence_handler::create_bank_check_sequence_routes,
    printed_check_handler::create_printed_check_routes,
    tax_tag_repair_run_handler::create_tax_tag_repair_run_routes,
    financial_statement_handler::create_financial_statement_routes,
    fiscal_period_handler::create_fiscal_period_read_routes,
    journal_handler::create_journal_routes,
    journal_line_handler::create_journal_line_routes,
    ledger_handler::create_ledger_routes,
    reconciliation_handler::create_reconciliation_routes,
    reconciliation_item_handler::create_reconciliation_item_routes,
    full_reconcile_handler::create_full_reconcile_routes,
    partial_reconcile_handler::create_partial_reconcile_routes,
};

use crate::application::service::{
    AccountService,
    AccountingPostService,
    CostCenterService,
    EmvQrConfigService,
    BankCheckSequenceService,
    PrintedCheckService,
    TaxTagRepairRunService,
    FinancialStatementService,
    FiscalPeriodService,
    JournalService,
    JournalLineService,
    LedgerService,
    ReconciliationService,
    ReconciliationItemService,
    FullReconcileService,
    PartialReconcileService,
};

/// Services collection for all CRUD endpoints
pub struct HttpServices {
    pub account: Arc<AccountService>,
    pub accounting_post: Arc<AccountingPostService>,
    pub cost_center: Arc<CostCenterService>,
    pub emv_qr_config: Arc<EmvQrConfigService>,
    pub bank_check_sequence: Arc<BankCheckSequenceService>,
    pub printed_check: Arc<PrintedCheckService>,
    pub tax_tag_repair_run: Arc<TaxTagRepairRunService>,
    pub financial_statement: Arc<FinancialStatementService>,
    pub fiscal_period: Arc<FiscalPeriodService>,
    pub journal: Arc<JournalService>,
    pub journal_line: Arc<JournalLineService>,
    pub ledger: Arc<LedgerService>,
    pub reconciliation: Arc<ReconciliationService>,
    pub reconciliation_item: Arc<ReconciliationItemService>,
    pub full_reconcile: Arc<FullReconcileService>,
    pub partial_reconcile: Arc<PartialReconcileService>,
}

/// Configure all HTTP routes for this module using Axum and BackboneCrudHandler.
///
/// Each entity gets 12 standard Backbone CRUD endpoints:
/// 1. GET /api/v1/{collection} - List with pagination
/// 2. POST /api/v1/{collection} - Create
/// 3. GET /api/v1/{collection}/:id - Get by ID
/// 4. PUT /api/v1/{collection}/:id - Full update
/// 5. PATCH /api/v1/{collection}/:id - Partial update
/// 6. DELETE /api/v1/{collection}/:id - Soft delete
/// 7. POST /api/v1/{collection}/bulk - Bulk create
/// 8. POST /api/v1/{collection}/upsert - Upsert
/// 9. GET /api/v1/{collection}/trash - List deleted
/// 10. POST /api/v1/{collection}/:id/restore - Restore
/// 11. DELETE /api/v1/{collection}/empty - Empty trash
/// 12. GET /api/v1/{collection}/:id/deleted - Get deleted by ID
pub fn configure_routes(services: HttpServices) -> Router {
    Router::new()
        // Account routes (12 Backbone endpoints)
        .merge(create_account_routes(services.account))
        // AccountingPost routes (12 Backbone endpoints)
        .merge(create_accounting_post_routes(services.accounting_post))
        // CostCenter routes (12 Backbone endpoints)
        .merge(create_cost_center_routes(services.cost_center))
        // EmvQrConfig routes (12 Backbone endpoints)
        .merge(create_emv_qr_config_routes(services.emv_qr_config))
        // BankCheckSequence routes (12 Backbone endpoints)
        .merge(create_bank_check_sequence_routes(services.bank_check_sequence))
        // PrintedCheck routes (12 Backbone endpoints)
        .merge(create_printed_check_routes(services.printed_check))
        // TaxTagRepairRun routes (12 Backbone endpoints)
        .merge(create_tax_tag_repair_run_routes(services.tax_tag_repair_run))
        // FinancialStatement routes (12 Backbone endpoints)
        .merge(create_financial_statement_routes(services.financial_statement))
        // FiscalPeriod routes (READ-ONLY mount — hand_set lifecycle; the state field moves only through the module's validated verbs)
        .merge(create_fiscal_period_read_routes(services.fiscal_period))
        // Journal routes (12 Backbone endpoints)
        .merge(create_journal_routes(services.journal))
        // JournalLine routes (12 Backbone endpoints)
        .merge(create_journal_line_routes(services.journal_line))
        // Ledger routes (12 Backbone endpoints)
        .merge(create_ledger_routes(services.ledger))
        // Reconciliation routes (12 Backbone endpoints)
        .merge(create_reconciliation_routes(services.reconciliation))
        // ReconciliationItem routes (12 Backbone endpoints)
        .merge(create_reconciliation_item_routes(services.reconciliation_item))
        // FullReconcile routes (12 Backbone endpoints)
        .merge(create_full_reconcile_routes(services.full_reconcile))
        // PartialReconcile routes (12 Backbone endpoints)
        .merge(create_partial_reconcile_routes(services.partial_reconcile))
}

/// Create an individual entity's routes (for modular configuration)
pub mod individual {
    use super::*;

    pub fn account_routes(service: Arc<AccountService>) -> Router {
        create_account_routes(service)
    }

    pub fn accounting_post_routes(service: Arc<AccountingPostService>) -> Router {
        create_accounting_post_routes(service)
    }

    pub fn cost_center_routes(service: Arc<CostCenterService>) -> Router {
        create_cost_center_routes(service)
    }

    pub fn emv_qr_config_routes(service: Arc<EmvQrConfigService>) -> Router {
        create_emv_qr_config_routes(service)
    }

    pub fn bank_check_sequence_routes(service: Arc<BankCheckSequenceService>) -> Router {
        create_bank_check_sequence_routes(service)
    }

    pub fn printed_check_routes(service: Arc<PrintedCheckService>) -> Router {
        create_printed_check_routes(service)
    }

    pub fn tax_tag_repair_run_routes(service: Arc<TaxTagRepairRunService>) -> Router {
        create_tax_tag_repair_run_routes(service)
    }

    pub fn financial_statement_routes(service: Arc<FinancialStatementService>) -> Router {
        create_financial_statement_routes(service)
    }

    pub fn fiscal_period_routes(service: Arc<FiscalPeriodService>) -> Router {
        create_fiscal_period_read_routes(service)
    }

    pub fn journal_routes(service: Arc<JournalService>) -> Router {
        create_journal_routes(service)
    }

    pub fn journal_line_routes(service: Arc<JournalLineService>) -> Router {
        create_journal_line_routes(service)
    }

    pub fn ledger_routes(service: Arc<LedgerService>) -> Router {
        create_ledger_routes(service)
    }

    pub fn reconciliation_routes(service: Arc<ReconciliationService>) -> Router {
        create_reconciliation_routes(service)
    }

    pub fn reconciliation_item_routes(service: Arc<ReconciliationItemService>) -> Router {
        create_reconciliation_item_routes(service)
    }

    pub fn full_reconcile_routes(service: Arc<FullReconcileService>) -> Router {
        create_full_reconcile_routes(service)
    }

    pub fn partial_reconcile_routes(service: Arc<PartialReconcileService>) -> Router {
        create_partial_reconcile_routes(service)
    }

}