From 1cf60d9dd776c0658df823cdd52529cef72df2a6 Mon Sep 17 00:00:00 2001 From: hermes Date: Wed, 14 Oct 2026 11:25:12 +0000 Subject: [PATCH] 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 --- crates/idx-core/src/ownership/xlsx.rs | 45 ++++++++++++++++++++------- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/crates/idx-core/src/ownership/xlsx.rs b/crates/idx-core/src/ownership/xlsx.rs index d12be20..90f7348 100644 --- a/crates/idx-core/src/ownership/xlsx.rs +++ b/crates/idx-core/src/ownership/xlsx.rs @@ -214,18 +214,26 @@ fn parse_sheet_rows(xml: &str, shared_strings: &[String]) -> Result().map_err(|e| { - xml_error("worksheet", format!("bad shared string index: {e}")) - })?; - shared_strings.get(index).cloned().ok_or_else(|| { - xml_error( - "worksheet", - format!("shared string {index} out of range"), - ) - })? - } else { - value.clone() + let text = match cell_type.as_str() { + "s" => { + let index = value.trim().parse::().map_err(|e| { + xml_error("worksheet", format!("bad shared string index: {e}")) + })?; + shared_strings.get(index).cloned().ok_or_else(|| { + xml_error( + "worksheet", + format!("shared string {index} out of range"), + ) + })? + } + // 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#" + 46295 + 1 + 0 + "#; + 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(