diff --git a/src/account.rs b/src/account.rs index 430c95e..07c1fb1 100644 --- a/src/account.rs +++ b/src/account.rs @@ -37,11 +37,6 @@ pub struct Account { impl Account { - // pub fn is_home_currency(&self, compare: &String, raw_acct_map: &HashMap) -> bool { - // let raw_acct = raw_acct_map.get(&self.raw_key).unwrap(); - // &raw_acct.ticker == compare - // } - pub fn get_sum_of_amts_in_lots(&self) -> d128 { let lots = self.list_of_lots.borrow(); let mut total_amount = d128!(0); diff --git a/src/cli_user_choices.rs b/src/cli_user_choices.rs index 5d04cc1..e158797 100644 --- a/src/cli_user_choices.rs +++ b/src/cli_user_choices.rs @@ -112,23 +112,6 @@ fn _get_path() -> Result<(String, bool), Box> { } } - -// impl std::convert::From for InventoryCostingMethod { -// fn from(osstr: OsStr) -> InventoryCostingMethod { -// let osstring1 = OsString::from(Box::); -// let new_string = osstr.into_string().expect("Invalid input. Could not convert to string."); -// let method = match new_string.trim() { -// "1" => InventoryCostingMethod::LIFObyLotCreationDate, -// "2" => InventoryCostingMethod::LIFObyLotBasisDate, -// "3" => InventoryCostingMethod::FIFObyLotCreationDate, -// "4" => InventoryCostingMethod::FIFObyLotBasisDate, -// _ => { println!("Invalid choice. Could not convert."); process::exit(1) -// } -// }; -// method -// } -// } - pub fn choose_inventory_costing_method(cmd_line_arg: OsString) -> Result> { println!("Choose the lot inventory costing method. [Default/Chosen: {:?}]", cmd_line_arg); diff --git a/src/core_functions.rs b/src/core_functions.rs index ad92833..f64e6e0 100644 --- a/src/core_functions.rs +++ b/src/core_functions.rs @@ -111,7 +111,6 @@ pub(crate) fn import_and_process_final( Ok(()) } - // println!("like_kind_cutoff_date is: {}...", like_kind_cutoff_date); let likekind_settings: Option = if settings.enable_like_kind_treatment { diff --git a/src/create_lots_mvmts.rs b/src/create_lots_mvmts.rs index ec0612e..bd87361 100644 --- a/src/create_lots_mvmts.rs +++ b/src/create_lots_mvmts.rs @@ -472,7 +472,6 @@ pub(crate) fn create_lots_and_movements( }; wrap_mvmt_and_push(inner_mvmt, &ar, &inner_lot, &settings, &raw_acct_map, &acct_map); acct.list_of_lots.borrow_mut().push(inner_lot); - // acct.push_lot(inner_lot); amounts_used += amount_used; percentages_used += percentage_used; } @@ -662,7 +661,6 @@ fn wrap_mvmt_and_push( let amt = this_mvmt.amount; let amt2 = round_d128_1e8(&amt); assert_eq!(amt, amt2); - // println!("Unrounded: {}; Rounded: {}; on {}", amt, amt2, mvmt_ref.borrow().date); let mvmt = Rc::from(this_mvmt); lot.movements.borrow_mut().push(mvmt.clone()); diff --git a/src/csv_export.rs b/src/csv_export.rs index 81d8496..af41087 100644 --- a/src/csv_export.rs +++ b/src/csv_export.rs @@ -604,74 +604,3 @@ pub fn _6_transaction_mvmt_detail_to_csv_w_orig( Ok(()) } - -// pub fn accounts_to_csv( -// accounts: &[Rc], -// ars: &HashMap, -// raw_acct_map: &HashMap, -// acct_map: &HashMap, -// txns_map: &HashMap, -// ) { - -// let mut rows: Vec> = [].to_vec(); -// let mut header: Vec = [].to_vec(); - -// header.extend_from_slice(&[ -// "#".to_string(), -// "Account".to_string(), -// "Ticker".to_string(), -// "Margin".to_string(), -// "Date".to_string(), -// "Txn#".to_string(), -// "Type".to_string(), -// "Memo".to_string(), -// "Amount".to_string(), -// "Proceeds".to_string(), -// "Cost basis\n".to_string(), -// "Gain/loss".to_string(), -// "Term".to_string(), -// "Income".to_string(), -// "Expense".to_string(), -// ]); -// rows.push(header); - -// for acct in accounts { -// for lot in acct.list_of_lots.borrow().iter() { -// for mvmt in lot.movements.borrow().iter() { - -// let raw_acct = raw_acct_map.get(&acct.raw_key).unwrap(); -// let txn = txns_map.get(&mvmt.transaction_key).unwrap(); -// let mut row: Vec = [].to_vec(); - -// row.push(raw_acct.account_num.to_string()); -// row.push(raw_acct.name.to_string()); -// row.push(raw_acct.ticker.to_string()); -// row.push(raw_acct.is_margin.to_string()); -// row.push(mvmt.date.format("%Y/%m/%d").to_string()); -// row.push(txn.tx_number.to_string()); -// row.push(txn.transaction_type(ars, &raw_acct_map, &acct_map).to_string()); -// row.push(txn.memo.to_string()); -// row.push(mvmt.amount.to_string()); -// row.push(mvmt.proceeds_lk.get().to_string()); -// row.push(mvmt.cost_basis.get().to_string()); -// row.push(mvmt.get_gain_or_loss().to_string()); -// row.push(mvmt.get_term(acct_map, ars).to_string()); -// row.push(mvmt.get_income(ars, &raw_acct_map, &acct_map, &txns_map).to_string()); -// row.push(mvmt.get_expense(ars, &raw_acct_map, &acct_map, &txns_map).to_string()); - -// rows.push(row); -// } -// } -// } - -// let file_name = PathBuf::from("accounts_mvmts.csv"); -// let path = PathBuf::from(&settings.export_path); - -// let buffer = File::create(full_path).unwrap(); -// let mut wtr = csv::Writer::from_writer(buffer); - -// for row in rows.iter() { -// wtr.write_record(row).expect("Could not write row to CSV file"); -// } -// wtr.flush().expect("Could not flush Writer, though file should exist and be complete"); -// } diff --git a/src/import_cost_proceeds_etc.rs b/src/import_cost_proceeds_etc.rs index 2effc0b..8256e25 100644 --- a/src/import_cost_proceeds_etc.rs +++ b/src/import_cost_proceeds_etc.rs @@ -58,10 +58,6 @@ pub(crate) fn add_cost_basis_to_movements( } else { - // let mvmt_lot = mvmt_copy.get_lot(acct_map, ars); - // let borrowed_mvmt_list = mvmt_lot.movements.borrow().clone(); - // let lots_first_mvmt = borrowed_mvmt_list.first().unwrap().clone(); - // let cb_of_lots_first_mvmt = lots_first_mvmt.cost_basis.get(); let cb_of_lots_first_mvmt = mvmt_copy.get_cost_basis_of_lots_first_mvmt(acct_map, ars); let ratio_of_amt_to_lots_first_mvmt = borrowed_mvmt.ratio_of_amt_to_lots_first_mvmt(acct_map, ars); let unrounded_basis = -(cb_of_lots_first_mvmt * ratio_of_amt_to_lots_first_mvmt); @@ -126,10 +122,7 @@ pub(crate) fn add_cost_basis_to_movements( txns_map, acct_map ); - // let this_ratio = ratio_of_amt_to_incoming_mvmts_in_a_r - // .to_string() - // .parse::() - // .unwrap(); // I don't recall why this was once needed in the next line. + let unrounded_basis = cb_outgoing_ar * ratio_of_amt_to_incoming_mvmts_in_a_r; let rounded_basis = round_d128_1e2(&unrounded_basis); @@ -240,13 +233,6 @@ pub(crate) fn add_proceeds_to_movements( } } - // TxType::Flow => { - // let ratio = borrowed_mvmt.amount / ar.amount; - // let proceeds_unrounded = txn.proceeds.to_string().parse::().unwrap() * ratio; - // let proceeds_rounded = round_d128_1e2(&proceeds_unrounded); - // mvmt.proceeds.set(proceeds_rounded); - // } - TxType::ToSelf => { // Originally did nothing. Now explicity creating a condition where a report containing // ToSelf txns would reflect a $0 gain/loss. @@ -281,9 +267,6 @@ pub(crate) fn apply_like_kind_treatment( if txn.date <= cutoff_date { perform_likekind_treatment_on_txn(txn_num, &settings, &ars, &raw_acct_map, &acct_map, &txns_map)?; } - // else { - // // carry_forward_deferred_gains(txn_num, &settings, &ars, &raw_acct_map, &acct_map, &txns_map)?; - // } } Ok(()) @@ -325,9 +308,6 @@ fn update_current_txn_for_prior_likekind_treatment( if !is_home_curr { - // let borrowed_mvmt_lot = borrowed_mvmt.get_lot(acct_map, ars); - // let borrowed_mvmt_list = borrowed_mvmt_lot.movements.borrow(); - // let lk_cb_of_lots_first_mvmt = borrowed_mvmt_list.first().unwrap().cost_basis_lk.get(); let lk_cb_of_lots_first_mvmt = borrowed_mvmt.get_lk_cost_basis_of_lots_first_mvmt(acct_map, ars); let ratio_of_amt_to_lots_first_mvmt = borrowed_mvmt.ratio_of_amt_to_lots_first_mvmt(acct_map, ars); let unrounded_lk_basis = -(lk_cb_of_lots_first_mvmt * ratio_of_amt_to_lots_first_mvmt);