Skip to main content

commit

Function commit 

Source
pub fn commit(
    sess: &mut Session,
    year: i32,
    ri: &ReturnInputs,
    table: Option<&TaxTable>,
    params: Option<&FullReturnParams>,
) -> Result<CommitOutcome, CliError>
Expand description

Screen ri, and ONLY if it passes write the committed row and delete the draft (SPEC §5.7).

The write is all-or-nothing:

  • No table/params for the year → CommitOutcome::NoTables (the TY2024-only gate, I-11) — writes nothing.
  • screen_inputs returns Some(refusal)CommitOutcome::Refused — writes nothing, so a refused commit never poisons the year at resolve and the draft remains for the user to fix.
  • Clean → snapshot the in-memory DB, return_inputs::set the committed row, delete_draft, then sess.save() to reach disk. If the save fails, RESTORE the snapshot so there is never an in-memory/disk split (the committed row + draft-deletion are rolled back together, I-7).

Takes &mut Session for save(); reads through the SAME session’s conn() — never opens a second Session (N-1).