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 conservative;
4pub mod conventions;
5pub mod donation;
6pub mod event;
7pub mod forms;
8pub mod identity;
9pub mod optimize;
10pub mod persistence;
11pub mod price;
12pub mod project;
13pub mod state;
14pub mod tax;
15pub mod void;
16pub mod whatif;
17
18pub use conventions::{Sat, TaxDate, Usd};
19pub use donation::DonationDetails;
20pub use event::*;
21pub use forms::{
22    form_8283, form_8949, schedule_d, year_donation_deduction, Form8283HowAcquired, Form8283Row,
23    Form8283Section, Form8949Box, Form8949Part, Form8949Row, ScheduleDPart, ScheduleDTotals,
24    DIGITAL_ASSET_8949_FIRST_YEAR,
25};
26pub use identity::{EventId, Fingerprint, LotId, Source, SourceRef, WalletId};
27pub use optimize::{
28    consult_sale, optimize_year, score_assignment, ApproxReason, ConsultReport, ConsultRequest,
29    DisposalProposal, OptimizeError, OptimizeProposal, Persistability, TimingInsight,
30};
31pub use price::PriceProvider;
32pub use project::{
33    conservation_report, disposal_compliance, evaluate_disposal, in_force_methods, project,
34    pseudo_plan, would_conflict, CandidateDisposal, ComplianceStatus, ConservationReport,
35    DisposalCompliance, EvaluateError, EvaluateOutcome, FeeTreatment, InForceMethod, LotMethod,
36    ProjectionConfig, PseudoDefault, PseudoKind,
37};
38pub use state::*;
39pub use tax::{
40    apply_carryover_writeback, assemble_absolute, carryforward_consistency, compute_se_tax,
41    compute_tax_year, loss_limit, niit_threshold, screen_absolute, se_addl_medicare_threshold,
42    se_net_income, AbsoluteReturn, Carryforward, FilingStatus, LtcgBreakpoints, MarginalRates,
43    OrdinaryBracket, OrdinarySchedule, PrefSplit, SeTaxResult, TaxOutcome, TaxProfile, TaxResult,
44    TaxTable, TaxTables, NIIT_RATE, QUALIFIED_APPRAISAL_THRESHOLD, SE_NET_EARNINGS_FACTOR,
45    SE_RATE_ADDL_MEDICARE, SE_RATE_MEDICARE, SE_RATE_SS,
46};
47pub use void::{is_revocable_payload, voidable_decisions};
48pub use whatif::{
49    CarryforwardDelta, ConsumedLot, HarvestReport, HarvestRequest, HarvestStatus, HarvestTarget,
50    LtcgBracket, SellMethod, SellReport, SellRequest, SellStatus, WhatIfError, HARVEST_TAU_SAT,
51};
52
53#[derive(Debug, thiserror::Error)]
54pub enum CoreError {
55    #[error("sqlite: {0}")]
56    Sqlite(#[from] rusqlite::Error),
57    #[error("event (de)serialization: {0}")]
58    Serde(#[from] serde_json::Error),
59    #[error("persistence: {0}")]
60    Persistence(String),
61}