Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for polish version of XLSX documents #111

Merged
merged 1 commit into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
Binary file added data/G&L_Expanded_polish.xlsx
Binary file not shown.
94 changes: 87 additions & 7 deletions src/xlsxparser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@
// Find indices of interesting collumns
if let Some(v) = c.get_string() {
match v {
"Date Acquired" => 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,
_ => (),
}
}
Expand Down Expand Up @@ -101,7 +101,7 @@
fn test_parse_gain_and_losses() -> Result<(), String> {
assert_eq!(
parse_gains_and_losses("data/G&L_Collapsed.xlsx"),
Ok((vec![

Check warning on line 104 in src/xlsxparser.rs

View workflow job for this annotation

GitHub Actions / coverage

unnecessary parentheses around function argument
(
"04/24/2013".to_owned(),
"04/11/2022".to_owned(),
Expand All @@ -120,7 +120,7 @@
);
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(),
Expand All @@ -135,9 +135,89 @@
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(())
}
}
Loading