use crate::error::FormsError;
use serde::Deserialize;
#[derive(Debug, Clone, Deserialize)]
pub struct IdentityCells {
pub name: String,
pub ssn: String,
}
pub const F8949_MAP_2025: &str = include_str!("../forms/2025/f8949.map.toml");
pub const SCHEDULE_D_MAP_2025: &str = include_str!("../forms/2025/schedule_d.map.toml");
pub const SCHEDULE_SE_MAP_2025: &str = include_str!("../forms/2025/schedule_se.map.toml");
pub const F8283_MAP_2025: &str = include_str!("../forms/2025/f8283.map.toml");
pub const F1040_MAP_2025: &str = include_str!("../forms/2025/f1040.map.toml");
pub const F8949_MAP_2024: &str = include_str!("../forms/2024/f8949.map.toml");
pub const SCHEDULE_D_MAP_2024: &str = include_str!("../forms/2024/schedule_d.map.toml");
pub const SCHEDULE_SE_MAP_2024: &str = include_str!("../forms/2024/schedule_se.map.toml");
pub const F8283_MAP_2024: &str = include_str!("../forms/2024/f8283.map.toml");
pub const F8275_MAP_2024: &str = include_str!("../forms/2024/f8275.map.toml");
pub const F1040_MAP_2024: &str = include_str!("../forms/2024/f1040.map.toml");
pub const F8959_MAP_2024: &str = include_str!("../forms/2024/f8959.map.toml");
pub const F8960_MAP_2024: &str = include_str!("../forms/2024/f8960.map.toml");
pub const F8995_MAP_2024: &str = include_str!("../forms/2024/f8995.map.toml");
pub const SCHEDULE_2_MAP_2024: &str = include_str!("../forms/2024/f1040s2.map.toml");
pub const SCHEDULE_3_MAP_2024: &str = include_str!("../forms/2024/f1040s3.map.toml");
pub const SCHEDULE_A_MAP_2024: &str = include_str!("../forms/2024/f1040sa.map.toml");
pub const SCHEDULE_1_MAP_2024: &str = include_str!("../forms/2024/f1040s1.map.toml");
pub const SCHEDULE_C_MAP_2024: &str = include_str!("../forms/2024/f1040sc.map.toml");
pub const SCHEDULE_B_MAP_2024: &str = include_str!("../forms/2024/f1040sb.map.toml");
pub const F8949_MAP_2017: &str = include_str!("../forms/2017/f8949.map.toml");
pub const SCHEDULE_D_MAP_2017: &str = include_str!("../forms/2017/schedule_d.map.toml");
pub const SCHEDULE_SE_MAP_2017: &str = include_str!("../forms/2017/schedule_se.map.toml");
pub const F8283_MAP_2017: &str = include_str!("../forms/2017/f8283.map.toml");
pub const F1040_MAP_2017: &str = include_str!("../forms/2017/f1040.map.toml");
#[derive(Debug, Clone, Deserialize)]
pub struct AmountCols {
pub proceeds_d: String,
pub cost_e: String,
pub adj_g: String,
pub gain_h: String,
}
#[derive(Debug, Clone, Deserialize)]
pub struct PartMap {
pub term: String,
pub page: usize,
pub box_field: String,
pub box_on: String,
pub totals: AmountCols,
pub rows: Vec<Vec<String>>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct Form8949Map {
pub form: String,
pub year: i32,
#[serde(default)]
pub identity_page1: Option<IdentityCells>,
#[serde(default)]
pub identity_page2: Option<IdentityCells>,
pub rows_per_page: usize,
pub table_token: String,
pub parts: Vec<PartMap>,
}
impl Form8949Map {
pub fn parse(toml_src: &str) -> Result<Self, toml::de::Error> {
toml::from_str(toml_src)
}
pub fn ty2025() -> Self {
Self::parse(F8949_MAP_2025).expect("bundled f8949 2025 map parses")
}
pub fn ty2024() -> Self {
Self::parse(F8949_MAP_2024).expect("bundled f8949 2024 map parses")
}
pub fn ty2017() -> Self {
Self::parse(F8949_MAP_2017).expect("bundled f8949 2017 map parses")
}
pub fn for_year(year: i32) -> Result<Self, FormsError> {
match year {
2017 => Ok(Self::ty2017()),
2024 => Ok(Self::ty2024()),
2025 => Ok(Self::ty2025()),
_ => Err(FormsError::UnsupportedYear(year)),
}
}
pub fn part(&self, term: &str) -> Option<&PartMap> {
self.parts.iter().find(|p| p.term == term)
}
}
#[derive(Debug, Clone, Deserialize)]
pub struct CheckChoice {
pub field: String,
pub on: String,
}
#[derive(Debug, Clone, Deserialize)]
pub struct MoneyPair {
pub dollars_field: String,
pub cents_field: String,
}
#[derive(Debug, Clone, Deserialize)]
#[serde(untagged)]
pub enum MoneyCell {
Single(String),
Pair(MoneyPair),
}
impl MoneyCell {
pub fn fields(&self) -> Vec<&str> {
match self {
MoneyCell::Single(f) => vec![f.as_str()],
MoneyCell::Pair(p) => vec![p.dollars_field.as_str(), p.cents_field.as_str()],
}
}
}
fn default_da_present() -> bool {
true
}
#[derive(Debug, Clone, Deserialize)]
pub struct Form1040HeaderCells {
pub taxpayer_first: String,
pub taxpayer_last: String,
pub taxpayer_ssn: String,
pub spouse_first: String,
pub spouse_last: String,
pub spouse_ssn: String,
pub address_street: String,
pub address_apt: String,
pub address_city: String,
pub address_state: String,
pub address_zip: String,
pub mfs_spouse_name: String,
pub occupation_taxpayer: String,
pub occupation_spouse: String,
pub ip_pin: String,
pub presidential_taxpayer: CheckChoice,
pub presidential_spouse: CheckChoice,
pub claimed_dependent_taxpayer: CheckChoice,
pub claimed_dependent_spouse: CheckChoice,
pub mfs_spouse_itemizes: CheckChoice,
pub taxpayer_aged: CheckChoice,
pub taxpayer_blind: CheckChoice,
pub spouse_aged: CheckChoice,
pub spouse_blind: CheckChoice,
pub more_than_four_dependents: CheckChoice,
pub dependent_rows: Vec<DependentRowCells>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct DependentRowCells {
pub name: String,
pub ssn: String,
pub relationship: String,
pub ctc: CheckChoice,
pub odc: CheckChoice,
}
#[derive(Debug, Clone, Deserialize)]
pub struct Form1040Map {
pub form: String,
pub year: i32,
#[serde(default)]
pub header: Option<Form1040HeaderCells>,
pub line7a: MoneyCell,
#[serde(default = "default_da_present")]
pub da_present: bool,
#[serde(default)]
pub da_yes: Option<CheckChoice>,
#[serde(default)]
pub da_no: Option<CheckChoice>,
#[serde(default)]
pub line1a: Option<MoneyCell>,
#[serde(default)]
pub line2a: Option<MoneyCell>,
#[serde(default)]
pub line1z: Option<MoneyCell>,
#[serde(default)]
pub line2b: Option<MoneyCell>,
#[serde(default)]
pub line3a: Option<MoneyCell>,
#[serde(default)]
pub line3b: Option<MoneyCell>,
#[serde(default)]
pub line8: Option<MoneyCell>,
#[serde(default)]
pub line9: Option<MoneyCell>,
#[serde(default)]
pub line10: Option<MoneyCell>,
#[serde(default)]
pub line11: Option<MoneyCell>,
#[serde(default)]
pub line12: Option<MoneyCell>,
#[serde(default)]
pub line13: Option<MoneyCell>,
#[serde(default)]
pub line14: Option<MoneyCell>,
#[serde(default)]
pub line15: Option<MoneyCell>,
#[serde(default)]
pub line16: Option<MoneyCell>,
#[serde(default)]
pub line17: Option<MoneyCell>,
#[serde(default)]
pub line18: Option<MoneyCell>,
#[serde(default)]
pub line19: Option<MoneyCell>,
#[serde(default)]
pub line20: Option<MoneyCell>,
#[serde(default)]
pub line21: Option<MoneyCell>,
#[serde(default)]
pub line22: Option<MoneyCell>,
#[serde(default)]
pub line23: Option<MoneyCell>,
#[serde(default)]
pub line24: Option<MoneyCell>,
#[serde(default)]
pub line25a: Option<MoneyCell>,
#[serde(default)]
pub line25b: Option<MoneyCell>,
#[serde(default)]
pub line25c: Option<MoneyCell>,
#[serde(default)]
pub line25d: Option<MoneyCell>,
#[serde(default)]
pub line26: Option<MoneyCell>,
#[serde(default)]
pub line31: Option<MoneyCell>,
#[serde(default)]
pub line32: Option<MoneyCell>,
#[serde(default)]
pub line33: Option<MoneyCell>,
#[serde(default)]
pub line34: Option<MoneyCell>,
#[serde(default)]
pub line35a: Option<MoneyCell>,
#[serde(default)]
pub line37: Option<MoneyCell>,
#[serde(default)]
pub filing_status: Option<FilingStatusBoxes>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct FilingStatusBoxes {
pub single: CheckChoice,
pub hoh: CheckChoice,
pub mfj: CheckChoice,
pub mfs: CheckChoice,
pub qss: CheckChoice,
}
impl Form1040Map {
pub fn parse(toml_src: &str) -> Result<Self, toml::de::Error> {
toml::from_str(toml_src)
}
pub fn ty2025() -> Self {
Self::parse(F1040_MAP_2025).expect("bundled f1040 2025 map parses")
}
pub fn ty2024() -> Self {
Self::parse(F1040_MAP_2024).expect("bundled f1040 2024 map parses")
}
pub fn ty2017() -> Self {
Self::parse(F1040_MAP_2017).expect("bundled f1040 2017 map parses")
}
pub fn for_year(year: i32) -> Result<Self, FormsError> {
match year {
2017 => Ok(Self::ty2017()),
2024 => Ok(Self::ty2024()),
2025 => Ok(Self::ty2025()),
_ => Err(FormsError::UnsupportedYear(year)),
}
}
}
#[derive(Debug, Clone, Deserialize)]
pub struct Section8283ARow {
pub donee: String,
pub desc: String,
pub date_contrib: String,
pub date_acq: String,
pub how: String,
pub cost: MoneyCell,
pub fmv: MoneyCell,
pub method: String,
}
#[derive(Debug, Clone, Deserialize)]
pub struct Section8283A {
pub rows: Vec<Section8283ARow>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct Section8283BRow {
pub desc: String,
pub fmv: MoneyCell,
pub date_acq: String,
pub how: String,
pub cost: MoneyCell,
pub deduction: MoneyCell,
}
#[derive(Debug, Clone, Deserialize)]
pub struct Section8283B {
pub k_digital_assets: CheckChoice,
#[serde(default)]
pub btc_property_note: Option<String>,
#[serde(default)]
pub appraiser_name: Option<String>,
pub appraiser_address: String,
pub appraiser_tin: String,
pub donee_name: String,
pub donee_ein: String,
pub donee_address: String,
pub rows: Vec<Section8283BRow>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct Form8283Map {
pub form: String,
pub year: i32,
#[serde(default)]
pub identity: Option<IdentityCells>,
pub section_a: Section8283A,
pub section_b: Section8283B,
}
impl Form8283Map {
pub fn parse(toml_src: &str) -> Result<Self, toml::de::Error> {
toml::from_str(toml_src)
}
pub fn ty2025() -> Self {
Self::parse(F8283_MAP_2025).expect("bundled f8283 2025 map parses")
}
pub fn ty2024() -> Self {
Self::parse(F8283_MAP_2024).expect("bundled f8283 2024 map parses")
}
pub fn ty2017() -> Self {
Self::parse(F8283_MAP_2017).expect("bundled f8283 2017 map parses")
}
pub fn for_year(year: i32) -> Result<Self, FormsError> {
match year {
2017 => Ok(Self::ty2017()),
2024 => Ok(Self::ty2024()),
2025 => Ok(Self::ty2025()),
_ => Err(FormsError::UnsupportedYear(year)),
}
}
pub fn field_names(&self) -> Vec<&str> {
let mut v = Vec::new();
for r in &self.section_a.rows {
v.extend([
r.donee.as_str(),
r.desc.as_str(),
r.date_contrib.as_str(),
r.date_acq.as_str(),
r.how.as_str(),
]);
v.extend(r.cost.fields());
v.extend(r.fmv.fields());
v.push(r.method.as_str());
}
let b = &self.section_b;
v.push(b.k_digital_assets.field.as_str());
if let Some(n) = &b.appraiser_name {
v.push(n.as_str());
}
v.extend([
b.appraiser_address.as_str(),
b.appraiser_tin.as_str(),
b.donee_name.as_str(),
b.donee_ein.as_str(),
b.donee_address.as_str(),
]);
for r in &b.rows {
v.extend([r.desc.as_str(), r.date_acq.as_str(), r.how.as_str()]);
v.extend(r.fmv.fields());
v.extend(r.cost.fields());
v.extend(r.deduction.fields());
}
v
}
}
#[derive(Debug, Clone, Deserialize)]
pub struct Form8275Row {
pub item: String,
pub desc: String,
pub form_schedule: String,
pub amount: String,
}
#[derive(Debug, Clone, Deserialize)]
pub struct Form8275Map {
pub form: String,
pub year: i32,
pub identity: IdentityCells,
pub rows: Vec<Form8275Row>,
pub part_ii_narrative: String,
pub part_ii_continuation: Vec<String>,
pub part_iv_continuation: Vec<String>,
}
impl Form8275Map {
pub fn parse(toml_src: &str) -> Result<Self, toml::de::Error> {
toml::from_str(toml_src)
}
pub fn ty2024() -> Self {
Self::parse(F8275_MAP_2024).expect("bundled f8275 map parses")
}
pub fn for_year(year: i32) -> Result<Self, FormsError> {
match year {
2017 | 2024 | 2025 => {
let mut m = Self::ty2024();
m.year = year;
Ok(m)
}
_ => Err(FormsError::UnsupportedYear(year)),
}
}
pub fn field_names(&self) -> Vec<&str> {
let mut v = vec![self.identity.name.as_str(), self.identity.ssn.as_str()];
for r in &self.rows {
v.extend([
r.item.as_str(),
r.desc.as_str(),
r.form_schedule.as_str(),
r.amount.as_str(),
]);
}
v.push(self.part_ii_narrative.as_str());
v.extend(self.part_ii_continuation.iter().map(String::as_str));
v.extend(self.part_iv_continuation.iter().map(String::as_str));
v
}
pub fn narrative_continuation_fields(&self) -> Vec<&str> {
let mut v = vec![self.part_ii_narrative.as_str()];
v.extend(self.part_ii_continuation.iter().map(String::as_str));
v.extend(self.part_iv_continuation.iter().map(String::as_str));
v
}
}
#[derive(Debug, Clone, Deserialize)]
pub struct ScheduleDMap {
pub form: String,
pub year: i32,
#[serde(default)]
pub identity: Option<IdentityCells>,
pub line3: AmountCols,
pub line7_h: String,
pub line10: AmountCols,
pub line15_h: String,
pub line16_h: String,
#[serde(default)]
pub line6: Option<MoneyCell>,
#[serde(default)]
pub line13: Option<MoneyCell>,
#[serde(default)]
pub line14: Option<MoneyCell>,
#[serde(default)]
pub line18: Option<MoneyCell>,
#[serde(default)]
pub line19: Option<MoneyCell>,
#[serde(default)]
pub line21: Option<MoneyCell>,
#[serde(default)]
pub line17: Option<YesNoPair>,
#[serde(default)]
pub line20: Option<YesNoPair>,
#[serde(default)]
pub line22: Option<YesNoPair>,
#[serde(default = "default_sched_d_token")]
pub table_token: String,
#[serde(default)]
pub qof_yes: Option<CheckChoice>,
#[serde(default)]
pub qof_no: Option<CheckChoice>,
}
fn default_sched_d_token() -> String {
"Table_PartI".to_string()
}
impl ScheduleDMap {
pub fn parse(toml_src: &str) -> Result<Self, toml::de::Error> {
toml::from_str(toml_src)
}
pub fn ty2025() -> Self {
Self::parse(SCHEDULE_D_MAP_2025).expect("bundled schedule_d 2025 map parses")
}
pub fn ty2024() -> Self {
Self::parse(SCHEDULE_D_MAP_2024).expect("bundled schedule_d 2024 map parses")
}
pub fn ty2017() -> Self {
Self::parse(SCHEDULE_D_MAP_2017).expect("bundled schedule_d 2017 map parses")
}
pub fn for_year(year: i32) -> Result<Self, FormsError> {
match year {
2017 => Ok(Self::ty2017()),
2024 => Ok(Self::ty2024()),
2025 => Ok(Self::ty2025()),
_ => Err(FormsError::UnsupportedYear(year)),
}
}
}
#[derive(Debug, Clone, Deserialize)]
pub struct Form8959Map {
pub form: String,
pub year: i32,
pub identity: IdentityCells,
pub line1: MoneyCell,
pub line4: MoneyCell,
pub line5: MoneyCell,
pub line6: MoneyCell,
pub line7: MoneyCell,
pub line8: MoneyCell,
pub line9: MoneyCell,
pub line10: MoneyCell,
pub line11: MoneyCell,
pub line12: MoneyCell,
pub line13: MoneyCell,
pub line18: MoneyCell,
pub line19: MoneyCell,
pub line20: MoneyCell,
pub line21: MoneyCell,
pub line22: MoneyCell,
pub line24: MoneyCell,
}
impl Form8959Map {
pub fn parse(toml_src: &str) -> Result<Self, toml::de::Error> {
toml::from_str(toml_src)
}
pub fn ty2024() -> Self {
Self::parse(F8959_MAP_2024).expect("bundled f8959 2024 map parses")
}
pub fn for_year(year: i32) -> Result<Self, FormsError> {
match year {
2024 => Ok(Self::ty2024()),
_ => Err(FormsError::UnsupportedYear(year)),
}
}
pub fn lines(&self) -> [&MoneyCell; 17] {
[
&self.line1,
&self.line4,
&self.line5,
&self.line6,
&self.line7,
&self.line8,
&self.line9,
&self.line10,
&self.line11,
&self.line12,
&self.line13,
&self.line18,
&self.line19,
&self.line20,
&self.line21,
&self.line22,
&self.line24,
]
}
}
#[derive(Debug, Clone, Deserialize)]
pub struct Form8960Map {
pub form: String,
pub year: i32,
pub identity: IdentityCells,
pub line1: MoneyCell,
pub line2: MoneyCell,
pub line5a: MoneyCell,
pub line5d: MoneyCell,
pub line7: MoneyCell,
pub line8: MoneyCell,
pub line9d: MoneyCell,
pub line11: MoneyCell,
pub line12: MoneyCell,
pub line13: MoneyCell,
pub line14: MoneyCell,
pub line15: MoneyCell,
pub line16: MoneyCell,
pub line17: MoneyCell,
}
impl Form8960Map {
pub fn parse(toml_src: &str) -> Result<Self, toml::de::Error> {
toml::from_str(toml_src)
}
pub fn ty2024() -> Self {
Self::parse(F8960_MAP_2024).expect("bundled f8960 2024 map parses")
}
pub fn for_year(year: i32) -> Result<Self, FormsError> {
match year {
2024 => Ok(Self::ty2024()),
_ => Err(FormsError::UnsupportedYear(year)),
}
}
pub fn lines(&self) -> [&MoneyCell; 14] {
[
&self.line1,
&self.line2,
&self.line5a,
&self.line5d,
&self.line7,
&self.line8,
&self.line9d,
&self.line11,
&self.line12,
&self.line13,
&self.line14,
&self.line15,
&self.line16,
&self.line17,
]
}
}
#[derive(Debug, Clone, Deserialize)]
pub struct Form8995Map {
pub form: String,
pub year: i32,
pub identity: IdentityCells,
pub row1_business: MoneyCell,
pub row1_tin: MoneyCell,
pub row1_qbi: MoneyCell,
pub line2: MoneyCell,
pub line4: MoneyCell,
pub line5: MoneyCell,
pub line6: MoneyCell,
pub line7: MoneyCell,
pub line8: MoneyCell,
pub line9: MoneyCell,
pub line10: MoneyCell,
pub line11: MoneyCell,
pub line12: MoneyCell,
pub line13: MoneyCell,
pub line14: MoneyCell,
pub line15: MoneyCell,
pub line16: MoneyCell,
pub line17: MoneyCell,
}
impl Form8995Map {
pub fn parse(toml_src: &str) -> Result<Self, toml::de::Error> {
toml::from_str(toml_src)
}
pub fn ty2024() -> Self {
Self::parse(F8995_MAP_2024).expect("bundled f8995 2024 map parses")
}
pub fn for_year(year: i32) -> Result<Self, FormsError> {
match year {
2024 => Ok(Self::ty2024()),
_ => Err(FormsError::UnsupportedYear(year)),
}
}
pub fn lines(&self) -> [&MoneyCell; 15] {
[
&self.line2,
&self.line4,
&self.line5,
&self.line6,
&self.line7,
&self.line8,
&self.line9,
&self.line10,
&self.line11,
&self.line12,
&self.line13,
&self.line14,
&self.line15,
&self.line16,
&self.line17,
]
}
}
#[derive(Debug, Clone, Deserialize)]
pub struct Schedule2Map {
pub form: String,
pub year: i32,
pub identity: IdentityCells,
pub line4: MoneyCell,
pub line11: MoneyCell,
pub line12: MoneyCell,
pub line21: MoneyCell,
}
impl Schedule2Map {
pub fn parse(toml_src: &str) -> Result<Self, toml::de::Error> {
toml::from_str(toml_src)
}
pub fn ty2024() -> Self {
Self::parse(SCHEDULE_2_MAP_2024).expect("bundled schedule 2 2024 map parses")
}
pub fn for_year(year: i32) -> Result<Self, FormsError> {
match year {
2024 => Ok(Self::ty2024()),
_ => Err(FormsError::UnsupportedYear(year)),
}
}
pub fn lines(&self) -> [&MoneyCell; 4] {
[&self.line4, &self.line11, &self.line12, &self.line21]
}
}
#[derive(Debug, Clone, Deserialize)]
pub struct Schedule3Map {
pub form: String,
pub year: i32,
pub identity: IdentityCells,
pub line1: MoneyCell,
pub line8: MoneyCell,
pub line10: MoneyCell,
pub line11: MoneyCell,
pub line15: MoneyCell,
}
impl Schedule3Map {
pub fn parse(toml_src: &str) -> Result<Self, toml::de::Error> {
toml::from_str(toml_src)
}
pub fn ty2024() -> Self {
Self::parse(SCHEDULE_3_MAP_2024).expect("bundled schedule 3 2024 map parses")
}
pub fn for_year(year: i32) -> Result<Self, FormsError> {
match year {
2024 => Ok(Self::ty2024()),
_ => Err(FormsError::UnsupportedYear(year)),
}
}
pub fn lines(&self) -> [&MoneyCell; 5] {
[
&self.line1,
&self.line8,
&self.line10,
&self.line11,
&self.line15,
]
}
}
#[derive(Debug, Clone, Deserialize)]
pub struct ScheduleAMap {
pub form: String,
pub year: i32,
pub check_5a_sales_tax: CheckChoice,
pub check_8_mixed_use: CheckChoice,
pub check_18_elects_smaller: CheckChoice,
pub identity: IdentityCells,
pub line1: MoneyCell,
pub line2: MoneyCell,
pub line3: MoneyCell,
pub line4: MoneyCell,
pub line5a: MoneyCell,
pub line5b: MoneyCell,
pub line5c: MoneyCell,
pub line5d: MoneyCell,
pub line5e: MoneyCell,
pub line7: MoneyCell,
pub line8a: MoneyCell,
pub line8e: MoneyCell,
pub line10: MoneyCell,
pub line11: MoneyCell,
pub line12: MoneyCell,
pub line13: MoneyCell,
pub line14: MoneyCell,
pub line17: MoneyCell,
}
impl ScheduleAMap {
pub fn parse(toml_src: &str) -> Result<Self, toml::de::Error> {
toml::from_str(toml_src)
}
pub fn ty2024() -> Self {
Self::parse(SCHEDULE_A_MAP_2024).expect("bundled schedule A 2024 map parses")
}
pub fn for_year(year: i32) -> Result<Self, FormsError> {
match year {
2024 => Ok(Self::ty2024()),
_ => Err(FormsError::UnsupportedYear(year)),
}
}
pub fn lines(&self) -> [&MoneyCell; 18] {
[
&self.line1,
&self.line2,
&self.line3,
&self.line4,
&self.line5a,
&self.line5b,
&self.line5c,
&self.line5d,
&self.line5e,
&self.line7,
&self.line8a,
&self.line8e,
&self.line10,
&self.line11,
&self.line12,
&self.line13,
&self.line14,
&self.line17,
]
}
}
#[derive(Debug, Clone, Deserialize)]
pub struct Schedule1Map {
pub form: String,
pub year: i32,
pub identity: IdentityCells,
pub line1: MoneyCell,
pub line3: MoneyCell,
pub line7: MoneyCell,
pub line8v: MoneyCell,
pub line9: MoneyCell,
pub line10: MoneyCell,
pub line15: MoneyCell,
pub line18: MoneyCell,
pub line21: MoneyCell,
pub line26: MoneyCell,
}
impl Schedule1Map {
pub fn parse(toml_src: &str) -> Result<Self, toml::de::Error> {
toml::from_str(toml_src)
}
pub fn ty2024() -> Self {
Self::parse(SCHEDULE_1_MAP_2024).expect("bundled schedule 1 2024 map parses")
}
pub fn for_year(year: i32) -> Result<Self, FormsError> {
match year {
2024 => Ok(Self::ty2024()),
_ => Err(FormsError::UnsupportedYear(year)),
}
}
pub fn lines(&self) -> [&MoneyCell; 10] {
[
&self.line1,
&self.line3,
&self.line7,
&self.line8v,
&self.line9,
&self.line10,
&self.line15,
&self.line18,
&self.line21,
&self.line26,
]
}
}
#[derive(Debug, Clone, Deserialize)]
pub struct ScheduleCMap {
pub form: String,
pub year: i32,
pub line_a_business: String,
pub line_b_naics: String,
pub method_cash: CheckChoice,
pub method_accrual: CheckChoice,
pub identity: IdentityCells,
pub line1: MoneyCell,
pub line3: MoneyCell,
pub line5: MoneyCell,
pub line7: MoneyCell,
pub line28: MoneyCell,
pub line29: MoneyCell,
pub line31: MoneyCell,
}
impl ScheduleCMap {
pub fn parse(toml_src: &str) -> Result<Self, toml::de::Error> {
toml::from_str(toml_src)
}
pub fn ty2024() -> Self {
Self::parse(SCHEDULE_C_MAP_2024).expect("bundled schedule C 2024 map parses")
}
pub fn for_year(year: i32) -> Result<Self, FormsError> {
match year {
2024 => Ok(Self::ty2024()),
_ => Err(FormsError::UnsupportedYear(year)),
}
}
pub fn lines(&self) -> [&MoneyCell; 7] {
[
&self.line1,
&self.line3,
&self.line5,
&self.line7,
&self.line28,
&self.line29,
&self.line31,
]
}
}
#[derive(Debug, Clone, Deserialize)]
pub struct ScheduleBRowMap {
pub payer: String,
pub amount: MoneyCell,
}
#[derive(Debug, Clone, Deserialize)]
pub struct YesNoPair {
pub yes: CheckChoice,
pub no: CheckChoice,
}
#[derive(Debug, Clone, Deserialize)]
pub struct ScheduleBMap {
pub form: String,
pub year: i32,
pub line7b_countries: String,
pub identity: IdentityCells,
pub part1_rows: Vec<ScheduleBRowMap>,
pub line2: MoneyCell,
pub line4: MoneyCell,
pub part2_rows: Vec<ScheduleBRowMap>,
pub line6: MoneyCell,
pub line7a: YesNoPair,
pub line8: YesNoPair,
}
impl ScheduleBMap {
pub fn parse(toml_src: &str) -> Result<Self, toml::de::Error> {
toml::from_str(toml_src)
}
pub fn ty2024() -> Self {
Self::parse(SCHEDULE_B_MAP_2024).expect("bundled schedule B 2024 map parses")
}
pub fn for_year(year: i32) -> Result<Self, FormsError> {
match year {
2024 => Ok(Self::ty2024()),
_ => Err(FormsError::UnsupportedYear(year)),
}
}
}
#[derive(Debug, Clone, Deserialize)]
pub struct ScheduleSeMap {
pub form: String,
pub year: i32,
#[serde(default)]
pub identity: Option<IdentityCells>,
pub line2: MoneyCell,
pub line3: MoneyCell,
pub line4a: MoneyCell,
pub line4c: MoneyCell,
pub line6: MoneyCell,
pub line8a: MoneyCell,
pub line8d: MoneyCell,
pub line9: MoneyCell,
pub line10: MoneyCell,
pub line11: MoneyCell,
pub line12: MoneyCell,
pub line13: MoneyCell,
#[serde(default)]
pub prefilled_exempt: Vec<String>,
}
impl ScheduleSeMap {
pub fn parse(toml_src: &str) -> Result<Self, toml::de::Error> {
toml::from_str(toml_src)
}
pub fn ty2025() -> Self {
Self::parse(SCHEDULE_SE_MAP_2025).expect("bundled schedule_se 2025 map parses")
}
pub fn ty2024() -> Self {
Self::parse(SCHEDULE_SE_MAP_2024).expect("bundled schedule_se 2024 map parses")
}
pub fn ty2017() -> Self {
Self::parse(SCHEDULE_SE_MAP_2017).expect("bundled schedule_se 2017 map parses")
}
pub fn for_year(year: i32) -> Result<Self, FormsError> {
match year {
2017 => Ok(Self::ty2017()),
2024 => Ok(Self::ty2024()),
2025 => Ok(Self::ty2025()),
_ => Err(FormsError::UnsupportedYear(year)),
}
}
pub fn lines(&self) -> [&MoneyCell; 12] {
[
&self.line2,
&self.line3,
&self.line4a,
&self.line4c,
&self.line6,
&self.line8a,
&self.line8d,
&self.line9,
&self.line10,
&self.line11,
&self.line12,
&self.line13,
]
}
pub fn field_names(&self) -> Vec<&str> {
self.lines().iter().flat_map(|c| c.fields()).collect()
}
}