Skip to content
Open
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
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ readme = "README.md"
keywords = ["etrade", "revolut"]
repository = "https://github.com/jczaja/e-trade-tax-return-pl-helper"
homepage = "https://github.com/jczaja/e-trade-tax-return-pl-helper"
default-run = "etradeTaxReturnHelper"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

exclude = [
Expand Down
11 changes: 8 additions & 3 deletions src/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,18 @@ impl etradeTaxReturnHelper::Residency for DE {

fn present_result(
&self,
gross_interests: f32,
gross_div: f32,
tax_div: f32,
gross_sold: f32,
cost_sold: f32,
) -> (Vec<String>, Option<String>) {
let total_gross_div = gross_interests + gross_div;
let mut presentation: Vec<String> = vec![];
presentation.push(format!("===> (DIVIDENDS) INCOME: {:.2} EUR", gross_div));
presentation.push(format!(
"===> (DIVIDENDS+INTERESTS) INCOME: {:.2} EUR",
total_gross_div
));
presentation.push(format!("===> (DIVIDENDS) TAX PAID: {:.2} EUR", tax_div));
presentation.push(format!("===> (SOLD STOCK) INCOME: {:.2} EUR", gross_sold));
presentation.push(format!(
Expand All @@ -89,13 +94,13 @@ mod tests {
let cost_sold = 10.0f32;

let ref_results: Vec<String> = vec![
"===> (DIVIDENDS) INCOME: 100.00 EUR".to_string(),
"===> (DIVIDENDS+INTERESTS) INCOME: 100.00 EUR".to_string(),
"===> (DIVIDENDS) TAX PAID: 15.00 EUR".to_string(),
"===> (SOLD STOCK) INCOME: 1000.00 EUR".to_string(),
"===> (SOLD STOCK) TAX DEDUCTIBLE COST: 10.00 EUR".to_string(),
];

let (results, _) = rd.present_result(gross_div, tax_div, gross_sold, cost_sold);
let (results, _) = rd.present_result(0.0f32, gross_div, tax_div, gross_sold, cost_sold);

results
.iter()
Expand Down
29 changes: 24 additions & 5 deletions src/gui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ use fltk::{
browser::MultiBrowser,
button::Button,
dialog,
enums::{Event, Font, FrameType, Key},
enums::{Event, Font, FrameType, Key, Shortcut},
frame::Frame,
group::Pack,
menu::{MenuBar, MenuFlag},
prelude::*,
text::{TextBuffer, TextDisplay},
window,
Expand Down Expand Up @@ -77,6 +78,7 @@ fn create_clear_documents(

fn create_execute_documents(
browser: Rc<RefCell<MultiBrowser>>,
menubar: Rc<RefCell<MenuBar>>,
tdisplay: Rc<RefCell<TextDisplay>>,
sdisplay: Rc<RefCell<TextDisplay>>,
ndisplay: Rc<RefCell<TextDisplay>>,
Expand Down Expand Up @@ -118,9 +120,16 @@ fn create_execute_documents(
buffer.set_text("");
tbuffer.set_text("");
nbuffer.set_text("Running...");
let round_per_transaction = {
let mb = menubar.borrow();
mb.find_item("Options/Round per transaction")
.map(|item| item.value())
.unwrap_or(false)
};
let rd: Box<dyn etradeTaxReturnHelper::Residency> = Box::new(PL {});
let etradeTaxReturnHelper::TaxCalculationResult {
gross_income: gross_div,
gross_interests,
gross_div,
tax: tax_div,
gross_sold,
cost_sold,
Expand All @@ -129,7 +138,7 @@ fn create_execute_documents(
revolut_dividends_transactions: revolut_transactions,
sold_transactions,
revolut_sold_transactions,
} = match run_taxation(&rd, file_names,false, false) {
} = match run_taxation(&rd, file_names, false, false, round_per_transaction) {
Ok(res) => {
nbuffer.set_text("Finished.\n\n (Double check if generated tax data (Summary) makes sense and then copy it to your tax form)");
res
Expand All @@ -139,7 +148,7 @@ fn create_execute_documents(
panic!("Error: unable to perform taxation");
}
};
let (presentation,warning) = rd.present_result(gross_div, tax_div, gross_sold, cost_sold);
let (presentation,warning) = rd.present_result(gross_interests, gross_div, tax_div, gross_sold, cost_sold);
buffer.set_text(&presentation.join("\n"));
if let Some(warn_msg) = warning {
nbuffer.set_text(&warn_msg);
Expand Down Expand Up @@ -228,7 +237,16 @@ pub fn run_gui() {

wind.make_resizable(true);

let mut uberpack = Pack::new(0, 0, WIND_SIZE_X as i32, WIND_SIZE_Y as i32, "");
let mut menubar = MenuBar::new(0, 0, WIND_SIZE_X, 25, "");
menubar.add(
"Options/Round per transaction",
Shortcut::None,
MenuFlag::Toggle,
|_| {},
);
let menubar = Rc::new(RefCell::new(menubar));

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

let mut pack = Pack::new(0, 0, WIND_SIZE_X as i32, WIND_SIZE_Y / 2 as i32, "");
pack.set_type(fltk::group::PackType::Horizontal);
Expand Down Expand Up @@ -327,6 +345,7 @@ pub fn run_gui() {
);
create_execute_documents(
browser.clone(),
menubar.clone(),
tdisplay.clone(),
sdisplay.clone(),
ndisplay.clone(),
Expand Down
Loading
Loading