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