diff --git a/src/csvparser.rs b/src/csvparser.rs index 40281e3..b51d559 100644 --- a/src/csvparser.rs +++ b/src/csvparser.rs @@ -17,9 +17,6 @@ fn extract_cash_with_currency(cashline: &str, currency: &str) -> Result>, take(1usize), tag("PLN"))); let mut usd_parser = tuple((tag("$"), double::<&str, Error<_>>)); @@ -346,8 +343,6 @@ pub fn parse_revolut_transactions( log::info!("Content of first to be DataFrame: {sales}"); log::info!("Content of second to be DataFrame: {others}"); - println!("Content of second to be DataFrame: {others}"); - let filtred_df = extract_dividends_transactions(&others)?; log::info!("Filtered Data of interest: {filtred_df}"); dates = parse_investment_transaction_dates(&filtred_df)?; diff --git a/src/lib.rs b/src/lib.rs index 05fd45d..1202a43 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -412,10 +412,10 @@ 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, _) = compute_div_taxation(&revolut_transactions); + let (gross_revolut, tax_revolut) = compute_div_taxation(&revolut_transactions); Ok(( gross_interests + gross_div + gross_revolut, - tax_div, + tax_div + tax_revolut, gross_sold, // We put sold and savings income into the same column cost_sold, interests, diff --git a/src/main.rs b/src/main.rs index f26f0d3..21f9276 100644 --- a/src/main.rs +++ b/src/main.rs @@ -387,6 +387,33 @@ mod tests { } } + #[test] + fn test_revolut_dividends_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/trading-pnl-statement_2024-01-01_2024-08-04_pl-pl_8e8783.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), + (6331.29, 871.17993, 0.0, 0.0), + ); + Ok(()) + } + Err(x) => panic!("Error in taxation process"), + } + } + #[test] fn test_revolut_interests_taxation_pln() -> Result<(), clap::Error> { // Get all brokerage with dividends only