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

support for english statement of revolut savings account added #108

Merged
merged 2 commits into from
Apr 4, 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.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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.1"
version = "0.5.2"
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
48 changes: 48 additions & 0 deletions revolut_data/revolut-savings-eng.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
Completed Date,Product name,Description,Interest rate (p.a.),Money out,Money in,Balance
"1 Jan 2023","","Money brought forward","","","","0 PLN"
"11 Dec 2023","Instant Access - Aion Bank","Deposit","","","+2,500 PLN","2,500 PLN"
"11 Dec 2023","Instant Access - Aion Bank","Deposit","","","+10 PLN","2,510 PLN"
"11 Dec 2023","Instant Access - Aion Bank","Deposit","","","+10 PLN","2,520 PLN"
"12 Dec 2023","Instant Access - Aion Bank","Gross interest
Earned on 2023/12/12","3.05%","","+0.21 PLN","2,520.21 PLN"
"13 Dec 2023","Instant Access - Aion Bank","Gross interest
Earned on 2023/12/13","3.05%","","+0.20 PLN","2,520.41 PLN"
"14 Dec 2023","Instant Access - Aion Bank","Deposit","","","+10 PLN","2,530.41 PLN"
"15 Dec 2023","Instant Access - Aion Bank","Deposit","","","+8.22 PLN","2,538.63 PLN"
"15 Dec 2023","Instant Access - Aion Bank","Gross interest
Earned on 2023/12/15","3.05%","","+0.21 PLN","2,538.84 PLN"
"16 Dec 2023","Instant Access - Aion Bank","Gross interest
Earned on 2023/12/16","3.05%","","+0.21 PLN","2,539.05 PLN"
"17 Dec 2023","Instant Access - Aion Bank","Gross interest
Earned on 2023/12/17","3.05%","","+0.21 PLN","2,539.26 PLN"
"18 Dec 2023","Instant Access - Aion Bank","Gross interest
Earned on 2023/12/18","3.05%","","+0.21 PLN","2,539.47 PLN"
"19 Dec 2023","Instant Access - Aion Bank","Gross interest
Earned on 2023/12/19","3.05%","","+0.41 PLN","2,539.88 PLN"
"20 Dec 2023","Instant Access - Aion Bank","Gross interest
Earned on 2023/12/20","3.05%","","+0.21 PLN","2,540.09 PLN"
"21 Dec 2023","Instant Access - Aion Bank","Gross interest
Earned on 2023/12/21","3.05%","","+0.21 PLN","2,540.30 PLN"
"21 Dec 2023","Instant Access - Aion Bank","Deposit","","","+10 PLN","2,550.30 PLN"
"22 Dec 2023","Instant Access - Aion Bank","Gross interest
Earned on 2023/12/22","3.05%","","+0.21 PLN","2,550.51 PLN"
"23 Dec 2023","Instant Access - Aion Bank","Gross interest
Earned on 2023/12/23","3.05%","","+0.21 PLN","2,550.72 PLN"
"24 Dec 2023","Instant Access - Aion Bank","Gross interest
Earned on 2023/12/24","3.05%","","+0.21 PLN","2,550.93 PLN"
"25 Dec 2023","Instant Access - Aion Bank","Gross interest
Earned on 2023/12/25","3.05%","","+0.21 PLN","2,551.14 PLN"
"26 Dec 2023","Instant Access - Aion Bank","Gross interest
Earned on 2023/12/26","3.05%","","+0.21 PLN","2,551.35 PLN"
"27 Dec 2023","Instant Access - Aion Bank","Gross interest
Earned on 2023/12/27","3.05%","","+0.21 PLN","2,551.56 PLN"
"28 Dec 2023","Instant Access - Aion Bank","Gross interest
Earned on 2023/12/28","3.05%","","+0.21 PLN","2,551.77 PLN"
"28 Dec 2023","Instant Access - Aion Bank","Deposit","","","+10 PLN","2,561.77 PLN"
"29 Dec 2023","Instant Access - Aion Bank","Gross interest
Earned on 2023/12/29","3.05%","","+0.21 PLN","2,561.98 PLN"
"30 Dec 2023","Instant Access - Aion Bank","Gross interest
Earned on 2023/12/30","3.05%","","+0.21 PLN","2,562.19 PLN"
"31 Dec 2023","Instant Access - Aion Bank","Gross interest
Earned on 2023/12/31","3.05%","","+0.21 PLN","2,562.40 PLN"
"31 Dec 2023","","Money carried forward","","","","2,562.40 PLN"
33 changes: 32 additions & 1 deletion src/csvparser.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pub use crate::logging::ResultExt;

Check warning on line 1 in src/csvparser.rs

View workflow job for this annotation

GitHub Actions / coverage

unused import: `crate::logging::ResultExt`
use nom::{
branch::alt,

Check warning on line 3 in src/csvparser.rs

View workflow job for this annotation

GitHub Actions / coverage

unused imports: `IResult`, `branch::alt`, `complete::alphanumeric1`, `is_digit`, `sequence::delimited`
bytes::complete::tag,
bytes::complete::take,
character::{complete::alphanumeric1, is_digit},
Expand Down Expand Up @@ -43,7 +43,7 @@
fn extract_investment_gains_and_costs_transactions(
df: &DataFrame,
) -> Result<DataFrame, &'static str> {
let mut df_transactions = df

Check warning on line 46 in src/csvparser.rs

View workflow job for this annotation

GitHub Actions / coverage

variable does not need to be mutable
.select(&["Date", "Type", "Total Amount"])
.map_err(|_| "Error: Unable to select description")?;

Expand Down Expand Up @@ -76,7 +76,7 @@
.map(|x| {
let m = match x {
AnyValue::Utf8(x) => {
if x.contains("Odsetki brutto") {
if x.contains("Odsetki brutto") || x.contains("Gross interest") {
Some("odsetki")
} else {
None
Expand Down Expand Up @@ -216,7 +216,7 @@
}

mod tests {
use super::*;

Check warning on line 219 in src/csvparser.rs

View workflow job for this annotation

GitHub Actions / coverage

unused import: `super::*`

#[test]
fn test_extract_cash() -> Result<(), String> {
Expand Down Expand Up @@ -535,6 +535,37 @@
Ok(())
}

#[test]
fn test_parse_revolut_transactions_english_statement_pln() -> Result<(), String> {
let expected_result = Ok(vec![
("12/12/23".to_owned(), crate::Currency::PLN(0.21)),
("12/13/23".to_owned(), crate::Currency::PLN(0.20)),
("12/15/23".to_owned(), crate::Currency::PLN(0.21)),
("12/16/23".to_owned(), crate::Currency::PLN(0.21)),
("12/17/23".to_owned(), crate::Currency::PLN(0.21)),
("12/18/23".to_owned(), crate::Currency::PLN(0.21)),
("12/19/23".to_owned(), crate::Currency::PLN(0.41)),
("12/20/23".to_owned(), crate::Currency::PLN(0.21)),
("12/21/23".to_owned(), crate::Currency::PLN(0.21)),
("12/22/23".to_owned(), crate::Currency::PLN(0.21)),
("12/23/23".to_owned(), crate::Currency::PLN(0.21)),
("12/24/23".to_owned(), crate::Currency::PLN(0.21)),
("12/25/23".to_owned(), crate::Currency::PLN(0.21)),
("12/26/23".to_owned(), crate::Currency::PLN(0.21)),
("12/27/23".to_owned(), crate::Currency::PLN(0.21)),
("12/28/23".to_owned(), crate::Currency::PLN(0.21)),
("12/29/23".to_owned(), crate::Currency::PLN(0.21)),
("12/30/23".to_owned(), crate::Currency::PLN(0.21)),
("12/31/23".to_owned(), crate::Currency::PLN(0.21)),
]);
assert_eq!(
parse_revolut_transactions("revolut_data/revolut-savings-eng.csv"),
expected_result
);

Ok(())
}

#[test]
fn test_parse_revolut_investment_transactions_usd() -> Result<(), String> {
let expected_result = Ok(vec![
Expand Down
1 change: 0 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ use logging::ResultExt;
// TODO: parse_gain_and_losses expect -> ?
// TODO: GUI : choosing residency
// TODO: Drag&Drop to work on MultiBrowser field
// TODO: Change run_taxation for_Each into try_for_Ech if possible
// TODO: taxation of EUR instruments in US

fn create_cmd_line_pattern<'a, 'b>(myapp: App<'a, 'b>) -> App<'a, 'b> {
Expand Down
Loading