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    apply_carryover_writeback, assemble_absolute, carryforward_consistency, compute_se_tax,
39    compute_tax_year, loss_limit, niit_threshold, screen_absolute, se_addl_medicare_threshold,
40    se_net_income, AbsoluteReturn, Carryforward, FilingStatus, LtcgBreakpoints, MarginalRates,
41    OrdinaryBracket, OrdinarySchedule, PrefSplit, SeTaxResult, TaxOutcome, TaxProfile, TaxResult,
42    TaxTable, TaxTables, NIIT_RATE, QUALIFIED_APPRAISAL_THRESHOLD, SE_NET_EARNINGS_FACTOR,
43    SE_RATE_ADDL_MEDICARE, SE_RATE_MEDICARE, SE_RATE_SS,
44};
45pub use void::{is_revocable_payload, voidable_decisions};
46pub use whatif::{
47    CarryforwardDelta, ConsumedLot, HarvestReport, HarvestRequest, HarvestStatus, HarvestTarget,
48    LtcgBracket, SellMethod, SellReport, SellRequest, SellStatus, WhatIfError, HARVEST_TAU_SAT,
49};
50
51#[derive(Debug, thiserror::Error)]
52pub enum CoreError {
53    #[error("sqlite: {0}")]
54    Sqlite(#[from] rusqlite::Error),
55    #[error("event (de)serialization: {0}")]
56    Serde(#[from] serde_json::Error),
57    #[error("persistence: {0}")]
58    Persistence(String),
59}