Skip to main content

save_draft

Function save_draft 

Source
pub fn save_draft(
    sess: &mut Session,
    year: i32,
    ri: &ReturnInputs,
) -> Result<(), CliError>
Expand description

Autosave a mid-entry return to the draft table (the input form’s crash-recovery scratch).

Read-modify-write that PRESERVES the row’s parked flag (NI-1): a parked committed return stays parked across edits. Reads the existing flag (default false — a fresh year is WIP, not parked), upserts ri with that flag, then sess.save() re-encrypts and atomically writes the vault to disk (I-7) — nothing survives a crash until save() returns. Takes &mut Session for save(); reads through the SAME session’s conn() (never opens a second Session — N-1).