From 247f885e99d7d47c195508c83b4d702a15360158 Mon Sep 17 00:00:00 2001 From: Jacek Czaja Date: Sun, 3 Mar 2024 11:59:37 +0100 Subject: [PATCH] - Moved revolut interests rate transaction to be combined with dividends (#100) --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/lib.rs | 8 ++++---- src/main.rs | 27 +++++++++++++++++++++++++++ 4 files changed, 33 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a5d7134..3f0a6e7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -571,7 +571,7 @@ checksum = "b90ca2580b73ab6a1f724b76ca11ab632df820fd6040c336200d2c1df7b3c82c" [[package]] name = "etradeTaxReturnHelper" -version = "0.4.3" +version = "0.4.4" dependencies = [ "calamine", "chrono", diff --git a/Cargo.toml b/Cargo.toml index 2d890ed..0b7fba2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "etradeTaxReturnHelper" -version = "0.4.3" +version = "0.4.4" 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/src/lib.rs b/src/lib.rs index 99f252a..c45c7b9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -362,12 +362,12 @@ pub fn run_taxation( let (gross_interests, _) = compute_div_taxation(&interests); let (gross_div, tax_div) = compute_div_taxation(&transactions); let (gross_sold, cost_sold) = compute_sold_taxation(&sold_transactions); - let (gross_revolut, cost_revolut) = compute_div_taxation(&revolut_transactions); + let (gross_revolut, _) = compute_div_taxation(&revolut_transactions); Ok(( - gross_interests + gross_div, + gross_interests + gross_div + gross_revolut, tax_div, - gross_sold + gross_revolut, // We put sold and savings income into the same column - cost_sold + cost_revolut, + gross_sold, // We put sold and savings income into the same column + cost_sold, interests, transactions, revolut_transactions, diff --git a/src/main.rs b/src/main.rs index 528df8d..bb90283 100644 --- a/src/main.rs +++ b/src/main.rs @@ -366,6 +366,33 @@ mod tests { } } + #[test] + fn test_revolut_interests_taxation_pln() -> Result<(), clap::Error> { + // Get all brokerage with dividends only + let myapp = App::new("E-trade tax helper").setting(AppSettings::ArgRequiredElseHelp); + let rd: Box = Box::new(pl::PL {}); + + let matches = create_cmd_line_pattern(myapp).get_matches_from_safe(vec![ + "mytest", + "revolut_data/Revolut_30cze2023_27lis2023.csv", + ])?; + let pdfnames = matches + .values_of("financial documents") + .expect_and_log("error getting brokarage statements pdfs names"); + let pdfnames: Vec = pdfnames.map(|x| x.to_string()).collect(); + + match etradeTaxReturnHelper::run_taxation(&rd, pdfnames) { + Ok((gross_div, tax_div, gross_sold, cost_sold, _, _, _, _)) => { + assert_eq!( + (gross_div, tax_div, gross_sold, cost_sold), + (86.93008, 0.0, 0.0, 0.0), + ); + Ok(()) + } + Err(x) => panic!("Error in taxation process"), + } + } + #[test] #[ignore] fn test_sold_dividends_only_taxation() -> Result<(), clap::Error> {