use async_trait::async_trait;
use chrono::NaiveDate;
use rust_decimal::Decimal;
use uuid::Uuid;
#[derive(Debug, Clone)]
pub struct AccountSumRow {
pub account_id: Uuid,
pub account_type: String,
pub account_number: String,
pub name: String,
pub debit: Decimal,
pub credit: Decimal,
}
#[derive(Debug, Clone)]
pub struct AccountNodeRow {
pub id: Uuid,
pub parent_id: Option<Uuid>,
pub account_number: String,
pub name: String,
pub account_type: String,
pub level: i32,
pub is_header: bool,
pub is_detail: bool,
}
#[derive(Debug, Clone)]
pub struct GlLineRow {
pub account_id: Uuid,
pub account_number: String,
pub account_name: String,
pub journal_number: String,
pub transaction_date: NaiveDate,
pub posting_date: NaiveDate,
pub description: String,
pub reference: Option<String>,
pub currency: String,
pub debit: Decimal,
pub credit: Decimal,
pub balance_before: Decimal,
pub balance_after: Decimal,
pub party_type: Option<String>,
pub party_id: Option<Uuid>,
pub source_type: Option<String>,
pub source_reference: Option<String>,
pub is_reconciled: bool,
}
#[derive(Debug, Clone)]
pub struct PartyLedgerRow {
pub line_id: Uuid,
pub account_id: Uuid,
pub account_number: String,
pub account_name: String,
pub journal_number: String,
pub transaction_date: NaiveDate,
pub description: Option<String>,
pub debit: Decimal,
pub credit: Decimal,
pub currency: String,
pub residual: Decimal,
}
#[derive(Debug, Clone)]
pub struct AgedItemRow {
pub party_type: String,
pub party_id: Uuid,
pub account_id: Uuid,
pub account_number: String,
pub transaction_date: NaiveDate,
pub source_reference: Option<String>,
pub currency: String,
pub residual: Decimal,
}
#[async_trait]
pub trait ReportingRepository: Send + Sync {
async fn account_sums(
&self,
lo: Option<NaiveDate>,
hi: NaiveDate,
) -> anyhow::Result<Vec<AccountSumRow>>;
async fn account_directory(&self) -> anyhow::Result<Vec<AccountNodeRow>>;
async fn gl_lines(
&self,
account_id: Option<Uuid>,
lo: Option<NaiveDate>,
hi: NaiveDate,
limit: i64,
offset: i64,
) -> anyhow::Result<Vec<GlLineRow>>;
async fn party_ledger_lines(
&self,
party_type: &str,
party_id: Uuid,
as_of: NaiveDate,
) -> anyhow::Result<Vec<PartyLedgerRow>>;
async fn aged_open_items(
&self,
account_subtype: &str,
as_of: NaiveDate,
) -> anyhow::Result<Vec<AgedItemRow>>;
}