use rust_decimal::Decimal;
use serde::{Deserialize, Serialize};
use uuid::Uuid;
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct BankStatementImported {
pub import_id: Uuid,
pub bank_account_id: Uuid,
pub row_count: i32,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct BankTransactionMatched {
pub bank_transaction_id: Uuid,
pub matched_source_type: String,
pub matched_source_id: Uuid,
pub amount: Decimal,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct BankTransactionCleared {
pub bank_transaction_id: Uuid,
pub matched_source_type: String,
pub matched_source_id: Uuid,
pub company_id: Uuid,
pub journal_id: Uuid,
pub post_id: Uuid,
pub amount: Decimal,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct BankReconciliationClosed {
pub reconciliation_id: Uuid,
pub bank_account_id: Uuid,
pub difference: Decimal,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct BankChargeRecognized {
pub bank_transaction_id: Uuid,
pub company_id: Uuid,
pub amount: Decimal,
pub journal_id: Uuid,
pub post_id: Uuid,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[serde(tag = "type")]
pub enum BankingEvent {
BankStatementImported(BankStatementImported),
BankTransactionMatched(BankTransactionMatched),
BankTransactionCleared(BankTransactionCleared),
BankReconciliationClosed(BankReconciliationClosed),
BankChargeRecognized(BankChargeRecognized),
}
pub trait BankingEventSink: Send + Sync {
fn publish(&self, event: BankingEvent);
}
pub struct LoggingSink;
impl BankingEventSink for LoggingSink {
fn publish(&self, event: BankingEvent) {
tracing::info!(target: "banking.events", ?event, "banking domain event");
}
}