Skip to main content

btctax_core/
lib.rs

1//! btctax-core: domain model + pure deterministic event-sourced projection for the bitcoin_tax ledger.
2//! The projection (`project`) is total and never panics (spec §7.1); only `persistence` performs I/O.
3pub mod conventions;
4pub mod donation;
5pub mod event;
6pub mod forms;
7pub mod identity;
8pub mod optimize;
9pub mod persistence;
10pub mod price;
11pub mod project;
12pub mod state;
13pub mod tax;
14pub mod void;
15pub mod whatif;
16
17pub use conventions::{Sat, TaxDate, Usd};
18pub use donation::DonationDetails;
19pub use event::*;
20pub use forms::{
21    form_8283, form_8949, schedule_d, year_donation_deduction, Form8283HowAcquired, Form8283Row,
22    Form8283Section, Form8949Box, Form8949Part, Form8949Row, ScheduleDPart, ScheduleDTotals,
23};
24pub use identity::{EventId, Fingerprint, LotId, Source, SourceRef, WalletId};
25pub use optimize::{
26    consult_sale, optimize_year, score_assignment, ApproxReason, ConsultReport, ConsultRequest,
27    DisposalProposal, OptimizeError, OptimizeProposal, Persistability, TimingInsight,
28};
29pub use price::PriceProvider;
30pub use project::{
31    conservation_report, disposal_compliance, evaluate_disposal, in_force_methods, project,
32    pseudo_plan, CandidateDisposal, ComplianceStatus, ConservationReport, DisposalCompliance,
33    EvaluateError, EvaluateOutcome, FeeTreatment, InForceMethod, LotMethod, ProjectionConfig,
34    PseudoDefault, PseudoKind,
35};
36pub use state::*;
37pub use tax::{
38    carryforward_consistency, compute_se_tax, compute_tax_year, loss_limit, niit_threshold,
39    se_addl_medicare_threshold, se_net_income, Carryforward, FilingStatus, LtcgBreakpoints,
40    MarginalRates, OrdinaryBracket, OrdinarySchedule, PrefSplit, SeTaxResult, TaxOutcome,
41    TaxProfile, TaxResult, TaxTable, TaxTables, NIIT_RATE, QUALIFIED_APPRAISAL_THRESHOLD,
42    SE_NET_EARNINGS_FACTOR, SE_RATE_ADDL_MEDICARE, SE_RATE_MEDICARE, SE_RATE_SS,
43};
44pub use void::{is_revocable_payload, voidable_decisions};
45pub use whatif::{
46    CarryforwardDelta, ConsumedLot, HarvestReport, HarvestRequest, HarvestStatus, HarvestTarget,
47    LtcgBracket, SellMethod, SellReport, SellRequest, SellStatus, WhatIfError, HARVEST_TAU_SAT,
48};
49
50#[derive(Debug, thiserror::Error)]
51pub enum CoreError {
52    #[error("sqlite: {0}")]
53    Sqlite(#[from] rusqlite::Error),
54    #[error("event (de)serialization: {0}")]
55    Serde(#[from] serde_json::Error),
56    #[error("persistence: {0}")]
57    Persistence(String),
58}