fix(ownership): read boolean XLSX cells as TRUE/FALSE

The IDX above-1% workbook stores the share code TRUE (TRINITI DINAMIK)
as a boolean cell holding 1, so its holders were imported under ticker
"1". Map t="b" cells to what Excel displays.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
hermes 2026-10-14 11:25:12 +00:00
commit b78da50e07

View file

@ -214,7 +214,8 @@ fn parse_sheet_rows(xml: &str, shared_strings: &[String]) -> Result<Vec<SheetRow
if let (Some((column, cell_type)), Some(current_row)) =
(cell.take(), row.as_mut())
{
let text = if cell_type == "s" {
let text = match cell_type.as_str() {
"s" => {
let index = value.trim().parse::<usize>().map_err(|e| {
xml_error("worksheet", format!("bad shared string index: {e}"))
})?;
@ -224,8 +225,15 @@ fn parse_sheet_rows(xml: &str, shared_strings: &[String]) -> Result<Vec<SheetRow
format!("shared string {index} out of range"),
)
})?
} else {
value.clone()
}
// Excel stores the share code TRUE (TRINITI DINAMIK)
// as a boolean cell holding 1.
"b" => match value.trim() {
"1" => "TRUE".to_string(),
"0" => "FALSE".to_string(),
_ => value.clone(),
},
_ => value.clone(),
};
current_row.cells.insert(column, text);
}
@ -501,6 +509,19 @@ mod tests {
assert!(drafts[0].locality.is_some());
}
#[test]
fn boolean_cells_read_as_excel_displays_them() {
let xml = r#"<worksheet><sheetData><row r="6687">
<c r="A6687"><v>46295</v></c>
<c r="B6687" t="b"><v>1</v></c>
<c r="C6687" t="b"><v>0</v></c>
</row></sheetData></worksheet>"#;
let rows = parse_sheet_rows(xml, &[]).expect("sheet parses");
assert_eq!(rows[0].cells["A"], "46295");
assert_eq!(rows[0].cells["B"], "TRUE");
assert_eq!(rows[0].cells["C"], "FALSE");
}
#[test]
fn row_errors_report_excel_row_numbers() {
let missing_investor = sheet_row(