From 557546b103e4d55ada092def504419cbb8171500 Mon Sep 17 00:00:00 2001 From: scoobybejesus Date: Sun, 25 Aug 2019 20:56:33 -0400 Subject: [PATCH] LotProcessingChoices -> ImportProcessParameters --- src/cli_user_choices.rs | 4 ++-- src/core_functions.rs | 4 ++-- src/create_lots_mvmts.rs | 10 +++++----- src/csv_export.rs | 8 ++++---- src/import_cost_proceeds_etc.rs | 12 ++++++------ src/main.rs | 10 +++++----- src/transaction.rs | 4 ++-- 7 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/cli_user_choices.rs b/src/cli_user_choices.rs index 58dfce5..cc799f1 100644 --- a/src/cli_user_choices.rs +++ b/src/cli_user_choices.rs @@ -261,14 +261,14 @@ pub fn elect_like_kind_treatment(cutoff_date_arg: &Option) -> (bool, Str } -pub struct LotProcessingChoices { +pub struct ImportProcessParameters { pub export_path: PathBuf, pub home_currency: String, pub enable_like_kind_treatment: bool, pub costing_method: InventoryCostingMethod, pub lk_cutoff_date_string: String, } -impl LotProcessingChoices {} +impl ImportProcessParameters {} #[derive(Clone)] pub struct LikeKindSettings { diff --git a/src/core_functions.rs b/src/core_functions.rs index 74e1c20..221c33c 100644 --- a/src/core_functions.rs +++ b/src/core_functions.rs @@ -12,7 +12,7 @@ use structopt::StructOpt; use crate::account::{Account, RawAccount, Lot}; use crate::transaction::{Transaction, ActionRecord}; -use crate::cli_user_choices::{LotProcessingChoices, LikeKindSettings}; +use crate::cli_user_choices::{ImportProcessParameters, LikeKindSettings}; use crate::import_accts_txns; use crate::import_cost_proceeds_etc; use crate::create_lots_mvmts; @@ -31,7 +31,7 @@ pub enum InventoryCostingMethod { pub fn import_and_process_final( input_file_path: PathBuf, - settings: &LotProcessingChoices, + settings: &ImportProcessParameters, ) -> ( HashMap, HashMap, diff --git a/src/create_lots_mvmts.rs b/src/create_lots_mvmts.rs index 981cd2b..67caff4 100644 --- a/src/create_lots_mvmts.rs +++ b/src/create_lots_mvmts.rs @@ -11,12 +11,12 @@ use chrono::NaiveDate; use crate::transaction::{Transaction, ActionRecord, TxType, Polarity, TxHasMargin}; use crate::account::{Account, RawAccount, Lot, Movement}; use crate::core_functions::InventoryCostingMethod; -use crate::cli_user_choices::{LotProcessingChoices, LikeKindSettings}; +use crate::cli_user_choices::{ImportProcessParameters, LikeKindSettings}; use crate::utils::{round_d128_1e8}; pub fn create_lots_and_movements( txns_map: HashMap, - settings: &LotProcessingChoices, + settings: &ImportProcessParameters, likekind_settings: &Option, ar_map: &HashMap, raw_acct_map: &HashMap, @@ -625,7 +625,7 @@ fn wrap_mvmt_and_push( this_mvmt: Movement, ar: &ActionRecord, lot: &Lot, - settings: &LotProcessingChoices, + settings: &ImportProcessParameters, raw_acct_map: &HashMap, acct_map: &HashMap, ) { @@ -656,7 +656,7 @@ fn fit_into_lots( list_of_lots_to_use: RefCell>>, vec_of_ordered_index_values: Vec, index_position: usize, - settings: &LotProcessingChoices, + settings: &ImportProcessParameters, ar_map: &HashMap, raw_acct_map: &HashMap, acct_map: &HashMap, @@ -789,7 +789,7 @@ fn process_multiple_incoming_lots_and_mvmts( txn_num: u32, outgoing_ar: &ActionRecord, incoming_ar: &ActionRecord, - settings: &LotProcessingChoices, + settings: &ImportProcessParameters, incoming_ar_key: u32, raw_acct_map: &HashMap, acct_map: &HashMap, diff --git a/src/csv_export.rs b/src/csv_export.rs index 3b43e7a..4e4736e 100644 --- a/src/csv_export.rs +++ b/src/csv_export.rs @@ -10,11 +10,11 @@ use decimal::d128; use crate::transaction::{Transaction, ActionRecord, Polarity, TxType}; use crate::account::{Account, RawAccount, Term}; -use crate::cli_user_choices::{LotProcessingChoices}; +use crate::cli_user_choices::{ImportProcessParameters}; pub fn _1_account_sums_to_csv( - settings: &LotProcessingChoices, + settings: &ImportProcessParameters, raw_acct_map: &HashMap, acct_map: &HashMap ) { @@ -77,7 +77,7 @@ pub fn _1_account_sums_to_csv( pub fn _2_account_sums_nonzero_to_csv( acct_map: &HashMap, - settings: &LotProcessingChoices, + settings: &ImportProcessParameters, raw_acct_map: &HashMap ) { @@ -197,7 +197,7 @@ pub fn _2_account_sums_nonzero_to_csv( // } pub fn _5_transaction_mvmt_summaries_to_csv( - settings: &LotProcessingChoices, + settings: &ImportProcessParameters, ars: &HashMap, raw_acct_map: &HashMap, acct_map: &HashMap, diff --git a/src/import_cost_proceeds_etc.rs b/src/import_cost_proceeds_etc.rs index f784dc8..f79725b 100644 --- a/src/import_cost_proceeds_etc.rs +++ b/src/import_cost_proceeds_etc.rs @@ -9,10 +9,10 @@ use decimal::d128; use crate::transaction::{Transaction, TxType, ActionRecord, Polarity}; use crate::account::{Account, RawAccount}; use crate::utils::{round_d128_1e2}; -use crate::cli_user_choices::{LotProcessingChoices}; +use crate::cli_user_choices::{ImportProcessParameters}; pub fn add_cost_basis_to_movements( - settings: &LotProcessingChoices, + settings: &ImportProcessParameters, ars: &HashMap, raw_acct_map: &HashMap, acct_map: &HashMap, @@ -199,7 +199,7 @@ pub fn add_proceeds_to_movements( pub fn apply_like_kind_treatment( cutoff_date: NaiveDate, - settings: &LotProcessingChoices, + settings: &ImportProcessParameters, ars: &HashMap, raw_acct_map: &HashMap, acct_map: &HashMap, @@ -222,7 +222,7 @@ pub fn apply_like_kind_treatment( fn update_current_txn_for_prior_likekind_treatment( txn_num: u32, - settings: &LotProcessingChoices, + settings: &ImportProcessParameters, ars: &HashMap, raw_acct_map: &HashMap, acct_map: &HashMap, @@ -286,7 +286,7 @@ fn update_current_txn_for_prior_likekind_treatment( fn perform_likekind_treatment_on_txn( txn_num: u32, - settings: &LotProcessingChoices, + settings: &ImportProcessParameters, ars: &HashMap, raw_acct_map: &HashMap, acct_map: &HashMap, @@ -303,7 +303,7 @@ fn perform_likekind_treatment_on_txn( let raw_og_acct = raw_acct_map.get(&og_acct.raw_key).unwrap(); let raw_ic_acct = raw_acct_map.get(&ic_acct.raw_key).unwrap(); - fn both_are_non_home_curr(raw_og_acct: &RawAccount, raw_ic_acct: &RawAccount, settings: &LotProcessingChoices) -> bool { + fn both_are_non_home_curr(raw_og_acct: &RawAccount, raw_ic_acct: &RawAccount, settings: &ImportProcessParameters) -> bool { let og_is_home_curr = raw_og_acct.is_home_currency(&settings.home_currency); let ic_is_home_curr = raw_ic_acct.is_home_currency(&settings.home_currency); let both_are_non_home_curr = !ic_is_home_curr && !og_is_home_curr; diff --git a/src/main.rs b/src/main.rs index fc4cf05..700d1da 100644 --- a/src/main.rs +++ b/src/main.rs @@ -26,7 +26,7 @@ mod csv_export; mod utils; mod tests; -use crate::cli_user_choices::LotProcessingChoices; +use crate::cli_user_choices::ImportProcessParameters; #[derive(StructOpt, Debug)] @@ -144,7 +144,7 @@ fn main() -> Result<(), Box> { let (like_kind_election, like_kind_cutoff_date) = cli_user_choices::elect_like_kind_treatment(&lk_cutoff_date_opt_string); - settings = LotProcessingChoices { + settings = ImportProcessParameters { export_path: output_dir_path, home_currency: home_currency_choice, costing_method: costing_method_choice, @@ -168,7 +168,7 @@ fn main() -> Result<(), Box> { should_export = export_reports_to_output_dir(&mut settings); - fn export_reports_to_output_dir(settings: &mut LotProcessingChoices) -> bool { + fn export_reports_to_output_dir(settings: &mut ImportProcessParameters) -> bool { println!("\nThe directory currently selected for exporting reports is: {}", settings.export_path.to_str().unwrap()); @@ -182,7 +182,7 @@ fn main() -> Result<(), Box> { Err(err) => { println!("Export choice error. {}", err); process::exit(1); } }; - fn _export(settings: &mut LotProcessingChoices) -> Result<(bool), Box> { + fn _export(settings: &mut ImportProcessParameters) -> Result<(bool), Box> { let mut input = String::new(); let stdin = io::stdin(); @@ -234,7 +234,7 @@ fn main() -> Result<(), Box> { let costing_method_choice = cli_user_choices::inv_costing_from_cmd_arg(args.inv_costing_method.into_string().unwrap()); - settings = LotProcessingChoices { + settings = ImportProcessParameters { export_path: output_dir_path, home_currency: home_currency_choice, costing_method: costing_method_choice, diff --git a/src/transaction.rs b/src/transaction.rs index 053daa0..0d37e9c 100644 --- a/src/transaction.rs +++ b/src/transaction.rs @@ -11,7 +11,7 @@ use decimal::d128; use chrono::NaiveDate; use serde_derive::{Serialize, Deserialize}; -use crate::cli_user_choices::LotProcessingChoices; +use crate::cli_user_choices::ImportProcessParameters; use crate::account::{Account, Movement, RawAccount}; #[derive(Clone, Debug, Serialize, Deserialize)] @@ -147,7 +147,7 @@ impl Transaction { pub fn get_outgoing_exchange_and_flow_mvmts( &self, - settings: &LotProcessingChoices, + settings: &ImportProcessParameters, ars: &HashMap, raw_acct_map: &HashMap, acct_map: &HashMap,