Skip to content

Commit

Permalink
- some warnign fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jczaja committed Sep 7, 2024
1 parent a140659 commit 178ca90
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 34 deletions.
23 changes: 9 additions & 14 deletions src/csvparser.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
pub use crate::logging::ResultExt;
use nom::{
branch::alt,
bytes::complete::tag,
bytes::complete::take,
character::{complete::alphanumeric1, is_digit},
error::Error,
multi::many_m_n,
number::complete::double,
sequence::delimited,
sequence::tuple,
IResult,
};
use polars::prelude::*;

Expand Down Expand Up @@ -72,16 +67,16 @@ fn extract_cash(cashline: &str) -> Result<crate::Currency, &'static str> {
}

fn extract_dividends_transactions(df: &DataFrame) -> Result<DataFrame, &'static str> {
let mut df_transactions = df
.select(&["Date", "Gross amount", "Withholding tax", "Currency"])
let df_transactions = df
.select(["Date", "Gross amount", "Withholding tax", "Currency"])
.map_err(|_| "Error: Unable to select dividend data")?;

Ok(df_transactions)
}

fn extract_sold_transactions(df: &DataFrame) -> Result<DataFrame, &'static str> {
let mut df_transactions = df
.select(&[
let df_transactions = df
.select([
"Date acquired",
"Date sold",
"Cost basis",
Expand All @@ -96,8 +91,8 @@ fn extract_sold_transactions(df: &DataFrame) -> Result<DataFrame, &'static str>
fn extract_investment_gains_and_costs_transactions(
df: &DataFrame,
) -> Result<DataFrame, &'static str> {
let mut df_transactions = df
.select(&["Date", "Type", "Total Amount"])
let df_transactions = df
.select(["Date", "Type", "Total Amount"])
.map_err(|_| "Error: Unable to select description")?;

let intrest_rate_mask = df_transactions
Expand Down Expand Up @@ -292,13 +287,13 @@ pub fn parse_revolut_transactions(
let mut dividend_transactions: Vec<(String, crate::Currency, crate::Currency)> = vec![];
let mut sold_transactions: Vec<(String, String, crate::Currency, crate::Currency)> = vec![];

let mut dates: Vec<String> = vec![];
let dates: Vec<String>;
let mut acquired_dates: Vec<String> = vec![];
let mut sold_dates: Vec<String> = vec![];
let mut costs: Vec<crate::Currency> = vec![];
let mut gross: Vec<crate::Currency> = vec![];
let mut incomes: Vec<crate::Currency> = vec![];
let mut taxes: Vec<crate::Currency> = vec![];
let incomes: Vec<crate::Currency>;
let taxes: Vec<crate::Currency>;
//let mut rdr = csv::Reader::from_path(csvtoparse).map_err(|_| "Error: opening CSV")?;
let mut rdr = csv::ReaderBuilder::new()
.flexible(true)
Expand Down
10 changes: 2 additions & 8 deletions src/gui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,10 @@ pub mod gui {
browser::MultiBrowser,
button::Button,
dialog,
enums::{CallbackTrigger, Color, Event, Font, FrameType, Key, Shortcut},
enums::{Event, Font, FrameType, Key},
frame::Frame,
group::Pack,
input::MultilineInput,
menu,
menu::Choice,
prelude::*,
text,
text::{TextBuffer, TextDisplay},
window,
};
Expand Down Expand Up @@ -221,8 +217,6 @@ pub mod gui {

wind.make_resizable(true);

let (s, r) = app::channel::<Message>();

let mut uberpack = Pack::new(0, 0, WIND_SIZE_X as i32, WIND_SIZE_Y as i32, "");

let mut pack = Pack::new(0, 0, WIND_SIZE_X as i32, WIND_SIZE_Y / 2 as i32, "");
Expand All @@ -233,7 +227,7 @@ pub mod gui {
let mut frame1 = Frame::new(0, 0, DOCUMENTS_COL_WIDTH, 30, "Documents");
frame1.set_frame(FrameType::EngravedFrame);

let mut browser = Rc::new(RefCell::new(MultiBrowser::new(
let browser = Rc::new(RefCell::new(MultiBrowser::new(
0,
30,
DOCUMENTS_COL_WIDTH,
Expand Down
2 changes: 1 addition & 1 deletion src/pdfparser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ fn process_transaction(
sequence: &mut std::collections::VecDeque<Box<dyn Entry>>,
transaction_type: TransactionType,
) -> Result<ParserState, String> {
let mut state = ParserState::ProcessingTransaction(transaction_type.clone());
let state;
let possible_obj = sequence.pop_front();
match possible_obj {
// Move executed parser objects into Vector
Expand Down
2 changes: 0 additions & 2 deletions src/pl.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use serde::{Deserialize, Serialize};

pub use crate::logging::ResultExt;

pub struct PL {}

type ReqwestClient = reqwest::blocking::Client;
Expand Down
18 changes: 9 additions & 9 deletions src/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ pub fn verify_interests_transactions<T>(transactions: &Vec<(String, T)>) -> Resu
}
};

let transaction_year = chrono::NaiveDate::parse_from_str(&transaction_date, "%m/%d/%y")
let transaction_year = chrono::NaiveDate::parse_from_str(transaction_date, "%m/%d/%y")
.map_err(|_| format!("Unable to parse transaction date: \"{transaction_date}\""))?
.year();
let mut verification: Result<(), String> = Ok(());
trans.try_for_each(|(tr_date, _)| {
let tr_year = chrono::NaiveDate::parse_from_str(&tr_date, "%m/%d/%y")
let tr_year = chrono::NaiveDate::parse_from_str(tr_date, "%m/%d/%y")
.map_err(|_| format!("Unable to parse transaction date: \"{tr_date}\""))?
.year();
if tr_year != transaction_year {
let msg: &str = "Error: Statements are related to different years!";
verification = Err(msg.to_owned());
}
Ok::<(), String>(())
});
})?;
verification
}

Expand All @@ -45,20 +45,20 @@ pub fn verify_dividends_transactions<T>(
}
};

let transaction_year = chrono::NaiveDate::parse_from_str(&transaction_date, "%m/%d/%y")
let transaction_year = chrono::NaiveDate::parse_from_str(transaction_date, "%m/%d/%y")
.map_err(|_| format!("Unable to parse transaction date: \"{transaction_date}\""))?
.year();
let mut verification: Result<(), String> = Ok(());
trans.try_for_each(|(tr_date, _, _)| {
let tr_year = chrono::NaiveDate::parse_from_str(&tr_date, "%m/%d/%y")
let tr_year = chrono::NaiveDate::parse_from_str(tr_date, "%m/%d/%y")
.map_err(|_| format!("Unable to parse transaction date: \"{tr_date}\""))?
.year();
if tr_year != transaction_year {
let msg: &str = "Error: Statements are related to different years!";
verification = Err(msg.to_owned());
}
Ok::<(), String>(())
});
})?;
verification
}

Expand All @@ -72,20 +72,20 @@ pub fn verify_transactions<T>(transactions: &Vec<(String, String, T, T)>) -> Res
}
};

let transaction_year = chrono::NaiveDate::parse_from_str(&transaction_date, "%m/%d/%y")
let transaction_year = chrono::NaiveDate::parse_from_str(transaction_date, "%m/%d/%y")
.map_err(|_| format!("Unable to parse transaction date: \"{transaction_date}\""))?
.year();
let mut verification: Result<(), String> = Ok(());
trans.try_for_each(|(_, tr_date, _, _)| {
let tr_year = chrono::NaiveDate::parse_from_str(&tr_date, "%m/%d/%y")
let tr_year = chrono::NaiveDate::parse_from_str(tr_date, "%m/%d/%y")
.map_err(|_| format!("Unable to parse transaction date: \"{tr_date}\""))?
.year();
if tr_year != transaction_year {
let msg: &str = "Error: Statements are related to different years!";
verification = Err(msg.to_owned());
}
Ok::<(), String>(())
});
})?;
verification
}

Expand Down

0 comments on commit 178ca90

Please sign in to comment.