feat(import,store): bank files mask, chart files refuse, the audit finds an old line
A bank file's description cell is not typed by a person and often carries a nine-digit reference, so books.import_bank_csv no longer meets a refusal for one: a number that reads as a tax id is kept masked to its last four digits (•••-••-1234) and the answer says how many values and on which lines (masked_count, masked, masked_note). A chart file is typed by a person: a cell that looks like a tax id refuses the file, naming its row and column, never the number. The store's own attachment, unlink, withdraw and void texts meet the same check. books.audit gains tax_id_in_journal: a journal line an earlier version took whose text field looks like a tax id is named by line and field, never the number; the books open and replay as they are and the journal is never rewritten (BS-entry-4). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
7327d04897
commit
98b1adb754
8 files changed
+337
-11
No files matched your search
@@ -732,7 +732,13 @@ impl BooksServer {
|
||||
}
|
||||
};
|
||||
let (csv, claim) = self.csv_given(&p.upload_id)?;
|
||||
let txns = ledger_import::parse_bank_csv_with(&csv, order).map_err(|e| e.to_string())?;
|
||||
// A description a bank wrote is not typed by a person: a number in
|
||||
// it that reads as a tax id is kept masked to its last four digits
|
||||
// and named in the answer, never a reason to refuse the file.
|
||||
let ledger_import::MaskedBankImport {
|
||||
transactions: txns,
|
||||
masked,
|
||||
} = ledger_import::parse_bank_csv_masked(&csv, order).map_err(|e| e.to_string())?;
|
||||
let mut store = self.lock()?;
|
||||
let bank = store
|
||||
.ledger()
|
||||
@@ -838,11 +844,32 @@ impl BooksServer {
|
||||
.map_err(|e| e.to_string())?;
|
||||
}
|
||||
let count = imported.len();
|
||||
let masked_count: usize = masked.iter().map(|m| m.numbers).sum();
|
||||
let masked_note = (masked_count > 0).then(|| {
|
||||
let lines: Vec<String> = masked.iter().map(|m| m.line.to_string()).collect();
|
||||
format!(
|
||||
"{masked_count} value{} in the Description column read as a tax id (nine digits standing alone, or an SSN's or an EIN's shape) and {} kept masked to the last four digits, on line{} {}. A bank's description is not typed by a person and often carries a nine-digit reference, so the file was not refused; a tax id is stored only with books.set_tin or a W-9 (books.set_w9)",
|
||||
if masked_count == 1 { "" } else { "s" },
|
||||
if masked_count == 1 { "was" } else { "were" },
|
||||
if lines.len() == 1 { "" } else { "s" },
|
||||
lines.join(", ")
|
||||
)
|
||||
});
|
||||
Ok(Json(ImportBankCsvOut {
|
||||
imported,
|
||||
count,
|
||||
source_attachment_id: p.source_attachment_id,
|
||||
source_linked: link_source,
|
||||
masked_count,
|
||||
masked: masked
|
||||
.into_iter()
|
||||
.map(|m| MaskedCellOut {
|
||||
row: m.line,
|
||||
column: m.column.to_string(),
|
||||
numbers: m.numbers,
|
||||
})
|
||||
.collect(),
|
||||
masked_note,
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1368,6 +1368,29 @@ pub struct ImportBankCsvOut {
|
||||
/// True when this call linked it to the account (false when it already
|
||||
/// was, or none was given).
|
||||
pub source_linked: bool,
|
||||
/// How many descriptions held a number that reads as a tax id (nine
|
||||
/// digits standing alone, an SSN's or an EIN's shape) and were kept
|
||||
/// masked to its last four digits: a bank's description is not typed by
|
||||
/// a person and often carries a nine-digit reference, so the file is
|
||||
/// not refused for one (BS-partner-2).
|
||||
pub masked_count: usize,
|
||||
/// Which descriptions were masked, by the file's line.
|
||||
pub masked: Vec<MaskedCellOut>,
|
||||
/// What masking did, in words; present when `masked_count` is above
|
||||
/// zero.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub masked_note: Option<String>,
|
||||
}
|
||||
|
||||
/// One description of a bank file that was kept masked.
|
||||
#[derive(Debug, Serialize, JsonSchema)]
|
||||
pub struct MaskedCellOut {
|
||||
/// The file's line (the first line is 1).
|
||||
pub row: u64,
|
||||
/// The column: "Description".
|
||||
pub column: String,
|
||||
/// How many numbers in the cell were masked.
|
||||
pub numbers: usize,
|
||||
}
|
||||
|
||||
/// Parameters for `books.import_chart_csv`. No other argument is taken: a
|
||||
|
||||
Reference in new issue
Block a user