diff --git a/src/core_functions.rs b/src/core_functions.rs index 2f47acc..7761739 100644 --- a/src/core_functions.rs +++ b/src/core_functions.rs @@ -50,10 +50,10 @@ 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, - pub date_separator: String, - pub iso_date_style: bool, + pub costing_method: InventoryCostingMethod, + pub input_file_date_separator: String, + pub input_file_has_iso_date_style: bool, pub should_export: bool, } @@ -80,8 +80,8 @@ pub(crate) fn import_and_process_final( &mut action_records_map, &mut raw_account_map, &mut account_map, - &settings.date_separator, - settings.iso_date_style, + &settings.input_file_date_separator, + settings.input_file_has_iso_date_style, ) { Ok(()) => { println!("Successfully imported csv file."); } Err(err) => { diff --git a/src/csv_import_accts_txns.rs b/src/csv_import_accts_txns.rs index e0b5293..2116ead 100644 --- a/src/csv_import_accts_txns.rs +++ b/src/csv_import_accts_txns.rs @@ -130,7 +130,7 @@ pub(crate) fn import_transactions( // First, initialize metadata fields. let mut this_tx_date: &str = ""; - let mut this_proceeds: &str = ""; + let mut this_proceeds: &str; let mut this_memo: &str = ""; let mut this: String; let mut proceeds_parsed = 0f32; diff --git a/src/setup.rs b/src/setup.rs index 92526dc..ad78f8e 100644 --- a/src/setup.rs +++ b/src/setup.rs @@ -12,7 +12,7 @@ use crate::skip_wizard; use crate::wizard; -pub struct WizardMaybeArgs { +pub struct ArgsForImportVarsTBD { pub inv_costing_method_arg: OsString, pub lk_cutoff_date_arg: Option, pub output_dir_path: PathBuf, @@ -33,7 +33,7 @@ pub (crate) fn run_setup(args: super::Cli) -> Result<(PathBuf, ImportProcessPara None => cli_user_choices::choose_file_for_import()? }; - let wizard_or_not_args = WizardMaybeArgs { + let wizard_or_not_args = ArgsForImportVarsTBD { inv_costing_method_arg: args.opts.inv_costing_method, lk_cutoff_date_arg: args.opts.lk_cutoff_date, output_dir_path: args.opts.output_dir_path, @@ -49,20 +49,20 @@ pub (crate) fn run_setup(args: super::Cli) -> Result<(PathBuf, ImportProcessPara ) = wizard_or_not(args.flags.accept_args, wizard_or_not_args)?; let settings = ImportProcessParameters { - export_path: output_dir_path, home_currency: args.opts.home_currency.into_string().unwrap().to_uppercase(), + input_file_has_iso_date_style: args.flags.iso_date, + input_file_date_separator: date_separator.to_string(), costing_method: costing_method_choice, enable_like_kind_treatment: like_kind_election, lk_cutoff_date_string: like_kind_cutoff_date_string, - date_separator: date_separator.to_string(), - iso_date_style: args.flags.iso_date, should_export: should_export, + export_path: output_dir_path, }; Ok((input_file_path, settings)) } -fn wizard_or_not(accept_args: bool, excl_args: WizardMaybeArgs) -> Result<( +fn wizard_or_not(accept_args: bool, args: ArgsForImportVarsTBD) -> Result<( InventoryCostingMethod, bool, String, @@ -84,7 +84,7 @@ fn wizard_or_not(accept_args: bool, excl_args: WizardMaybeArgs) -> Result<( like_kind_cutoff_date_string1, should_export1, output_dir_path1, - ) = wizard::wizard(excl_args)?; + ) = wizard::wizard(args)?; costing_method_choice = costing_method_choice1; like_kind_election = like_kind_election1; @@ -100,7 +100,7 @@ fn wizard_or_not(accept_args: bool, excl_args: WizardMaybeArgs) -> Result<( like_kind_cutoff_date_string1, should_export1, output_dir_path1, - ) = skip_wizard::skip_wizard(excl_args)?; + ) = skip_wizard::skip_wizard(args)?; costing_method_choice = costing_method_choice1; like_kind_election = like_kind_election1; diff --git a/src/skip_wizard.rs b/src/skip_wizard.rs index 1a8aefa..0dc9c7b 100644 --- a/src/skip_wizard.rs +++ b/src/skip_wizard.rs @@ -6,9 +6,9 @@ use std::error::Error; use crate::cli_user_choices; use crate::core_functions::{InventoryCostingMethod}; -use crate::setup::{WizardMaybeArgs}; +use crate::setup::{ArgsForImportVarsTBD}; -pub(crate) fn skip_wizard(excl_args: WizardMaybeArgs) -> Result<( +pub(crate) fn skip_wizard(args: ArgsForImportVarsTBD) -> Result<( InventoryCostingMethod, bool, String, @@ -16,12 +16,12 @@ pub(crate) fn skip_wizard(excl_args: WizardMaybeArgs) -> Result<( PathBuf, ), Box> { - let costing_method_choice = cli_user_choices::inv_costing_from_cmd_arg(excl_args.inv_costing_method_arg)?; + let costing_method_choice = cli_user_choices::inv_costing_from_cmd_arg(args.inv_costing_method_arg)?; let like_kind_election; let like_kind_cutoff_date_string: String; - if let Some(date) = excl_args.lk_cutoff_date_arg { + if let Some(date) = args.lk_cutoff_date_arg { like_kind_election = true; like_kind_cutoff_date_string = date.into_string().unwrap(); } else { @@ -29,7 +29,7 @@ pub(crate) fn skip_wizard(excl_args: WizardMaybeArgs) -> Result<( like_kind_cutoff_date_string = "1-1-1".to_string(); }; - let should_export = !excl_args.suppress_reports; + let should_export = !args.suppress_reports; - Ok((costing_method_choice, like_kind_election, like_kind_cutoff_date_string, should_export, excl_args.output_dir_path)) + Ok((costing_method_choice, like_kind_election, like_kind_cutoff_date_string, should_export, args.output_dir_path)) } \ No newline at end of file diff --git a/src/wizard.rs b/src/wizard.rs index de75930..a0c67da 100644 --- a/src/wizard.rs +++ b/src/wizard.rs @@ -8,9 +8,9 @@ use std::path::PathBuf; use crate::cli_user_choices; use crate::core_functions::{InventoryCostingMethod}; -use crate::setup::{WizardMaybeArgs}; +use crate::setup::{ArgsForImportVarsTBD}; -pub(crate) fn wizard(excl_args: WizardMaybeArgs) -> Result<( +pub(crate) fn wizard(args: ArgsForImportVarsTBD) -> Result<( InventoryCostingMethod, bool, String, @@ -20,11 +20,11 @@ pub(crate) fn wizard(excl_args: WizardMaybeArgs) -> Result<( shall_we_proceed()?; - let costing_method_choice = cli_user_choices::choose_inventory_costing_method(excl_args.inv_costing_method_arg)?; + let costing_method_choice = cli_user_choices::choose_inventory_costing_method(args.inv_costing_method_arg)?; let lk_cutoff_date_opt_string; - if let Some(lk_cutoff) = excl_args.lk_cutoff_date_arg { + if let Some(lk_cutoff) = args.lk_cutoff_date_arg { lk_cutoff_date_opt_string = Some(lk_cutoff.into_string().unwrap()) } else { lk_cutoff_date_opt_string = None @@ -32,7 +32,7 @@ pub(crate) fn wizard(excl_args: WizardMaybeArgs) -> Result<( let (like_kind_election, like_kind_cutoff_date_string) = cli_user_choices::elect_like_kind_treatment(&lk_cutoff_date_opt_string)?; - let (should_export, output_dir_path) = export_reports_to_output_dir(excl_args.output_dir_path)?; + let (should_export, output_dir_path) = export_reports_to_output_dir(args.output_dir_path)?; Ok((costing_method_choice, like_kind_election, like_kind_cutoff_date_string, should_export, output_dir_path.to_path_buf())) }