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