From eec7edd0d3415fd91a2abff062c99f0e43d22c25 Mon Sep 17 00:00:00 2001 From: Jacek Czaja Date: Thu, 11 Apr 2024 08:50:56 +0200 Subject: [PATCH] - Added support for polish version of XLSX documents --- Cargo.toml | 2 +- data/G&L_Expanded_polish.xlsx | Bin 0 -> 8909 bytes src/xlsxparser.rs | 94 +++++++++++++++++++++++++++++++--- 3 files changed, 88 insertions(+), 8 deletions(-) create mode 100644 data/G&L_Expanded_polish.xlsx diff --git a/Cargo.toml b/Cargo.toml index 97623ef..321b512 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "etradeTaxReturnHelper" -version = "0.5.2" +version = "0.5.3" edition = "2021" description = "Parses etrade financial documents for transaction details (income, tax paid, cost basis) and compute total income and total tax paid according to chosen tax residency (currency)" license = "BSD-3-Clause" diff --git a/data/G&L_Expanded_polish.xlsx b/data/G&L_Expanded_polish.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..5d4b24259459e1fe836966b3f5371ec2afb8695c GIT binary patch literal 8909 zcmZ{K1ymecv-JSM0zn3M2ol^0?h;&rGq~#jgIjP5?h**@!Ck}P8e9Saf(LgG@RNJr z`|o#o@6B4%y?T1>nsatl*Qq+YmF3`GyaWIMNC0v0N3FykX+m31R|>EI0Ls(Z0AgnA z#KQdNSRM~m>}Ew3@ufcXap9&48n4mAm;@swp|gfBs@tv8vW?#huEMGjPN5O6&yS5I zH{N*=j`A1%kgKYyux2IBxE6B8)lcuAAxZs$Ef58q?+WMGcU!a|m64MXx@7y*h4j5k zg=?A8+-)NqLLDc5V@0iyznR7txq+~Y&+Xz9vBM3QEbnxTI|;3XauyBDRTbEI^`oyX z)1Y}4!k>O27PwQFFA%aaFlT#J5Iqxsccs=vK-X8A4gKj+FnS^D8xw)W;PGDUO*jjR zkC`rK%gq=y6UPVVElgpmSCy~38&R3R8D1eP|BDXbzyh)&3;>Yw0sz2zq5~vu4|X;K zI~%BZIG8!4Tq*QdqDF=(B&g*=B5N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tgy&#gRf_WrSg_LPmEto+mZJ%>Io&i{d?;r<1EUaCJg k@I3YZW5ApE@Be date_acquired_idx = idx, - "Date Sold" => date_sold_idx = idx, - "Acquisition Cost" => acquistion_cost_idx = idx, - "Adjusted Cost Basis" => cost_basis_idx = idx, - "Total Proceeds" => total_proceeds_idx = idx, + "Date Acquired" | "Data nabycia" => date_acquired_idx = idx, + "Date Sold" | "Data sprzedaży" => date_sold_idx = idx, + "Acquisition Cost" | "Koszt zakupu" => acquistion_cost_idx = idx, + "Adjusted Cost Basis" | "Skorygowana podstawa kosztów" => cost_basis_idx = idx, + "Total Proceeds" | "Łączne wpływy" => total_proceeds_idx = idx, _ => (), } } @@ -120,7 +120,7 @@ mod tests { ); assert_eq!( parse_gains_and_losses("data/G&L_Expanded.xlsx"), - Ok((vec![ + Ok(vec![ ( "04/24/2013".to_owned(), "04/11/2022".to_owned(), @@ -135,9 +135,89 @@ mod tests { 29.28195, 43.67 ) - ])) + ]) ); Ok(()) } + + #[test] + fn test_parse_gain_and_losses_pl() -> Result<(), String> { + assert_eq!( + parse_gains_and_losses("data/G&L_Expanded_polish.xlsx"), + Ok(vec![ + ( + "02/17/2023".to_owned(), + "02/21/2023".to_owned(), + 1791.0388, + 2107.1, + 2018.3545 + ), + ( + "08/01/2022".to_owned(), + "06/05/2023".to_owned(), + 0.0, + 258.09, + 219.0275 + ), + ( + "01/31/2023".to_owned(), + "06/05/2023".to_owned(), + 0.0, + 195.37, + 219.0275 + ), + ( + "10/31/2022".to_owned(), + "06/05/2023".to_owned(), + 0.0, + 200.305, + 219.0275 + ), + ( + "05/01/2023".to_owned(), + "06/05/2023".to_owned(), + 0.0, + 215.32, + 219.0275 + ), + ( + "07/31/2023".to_owned(), + "08/07/2023".to_owned(), + 0.0, + 255.0275, + 247.16 + ), + ( + "08/18/2023".to_owned(), + "08/21/2023".to_owned(), + 1969.0505, + 2701.235, + 2689.0754 + ), + ( + "08/30/2023".to_owned(), + "12/13/2023".to_owned(), + 0.0, + 923.8725, + 1187.31 + ), + ( + "11/30/2023".to_owned(), + "12/13/2023".to_owned(), + 0.0, + 1163.5, + 1143.34 + ), + ( + "10/31/2023".to_owned(), + "12/13/2023".to_owned(), + 0.0, + 252.665, + 307.82 + ) + ]) + ); + Ok(()) + } }