Improved struct and variable names.
This commit is contained in:
parent
379aff1795
commit
fcd3c91bd8
|
@ -50,10 +50,10 @@ pub struct ImportProcessParameters {
|
||||||
pub export_path: PathBuf,
|
pub export_path: PathBuf,
|
||||||
pub home_currency: String,
|
pub home_currency: String,
|
||||||
pub enable_like_kind_treatment: bool,
|
pub enable_like_kind_treatment: bool,
|
||||||
pub costing_method: InventoryCostingMethod,
|
|
||||||
pub lk_cutoff_date_string: String,
|
pub lk_cutoff_date_string: String,
|
||||||
pub date_separator: String,
|
pub costing_method: InventoryCostingMethod,
|
||||||
pub iso_date_style: bool,
|
pub input_file_date_separator: String,
|
||||||
|
pub input_file_has_iso_date_style: bool,
|
||||||
pub should_export: bool,
|
pub should_export: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,8 +80,8 @@ pub(crate) fn import_and_process_final(
|
||||||
&mut action_records_map,
|
&mut action_records_map,
|
||||||
&mut raw_account_map,
|
&mut raw_account_map,
|
||||||
&mut account_map,
|
&mut account_map,
|
||||||
&settings.date_separator,
|
&settings.input_file_date_separator,
|
||||||
settings.iso_date_style,
|
settings.input_file_has_iso_date_style,
|
||||||
) {
|
) {
|
||||||
Ok(()) => { println!("Successfully imported csv file."); }
|
Ok(()) => { println!("Successfully imported csv file."); }
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
|
|
|
@ -130,7 +130,7 @@ pub(crate) fn import_transactions(
|
||||||
|
|
||||||
// First, initialize metadata fields.
|
// First, initialize metadata fields.
|
||||||
let mut this_tx_date: &str = "";
|
let mut this_tx_date: &str = "";
|
||||||
let mut this_proceeds: &str = "";
|
let mut this_proceeds: &str;
|
||||||
let mut this_memo: &str = "";
|
let mut this_memo: &str = "";
|
||||||
let mut this: String;
|
let mut this: String;
|
||||||
let mut proceeds_parsed = 0f32;
|
let mut proceeds_parsed = 0f32;
|
||||||
|
|
16
src/setup.rs
16
src/setup.rs
|
@ -12,7 +12,7 @@ use crate::skip_wizard;
|
||||||
use crate::wizard;
|
use crate::wizard;
|
||||||
|
|
||||||
|
|
||||||
pub struct WizardMaybeArgs {
|
pub struct ArgsForImportVarsTBD {
|
||||||
pub inv_costing_method_arg: OsString,
|
pub inv_costing_method_arg: OsString,
|
||||||
pub lk_cutoff_date_arg: Option<OsString>,
|
pub lk_cutoff_date_arg: Option<OsString>,
|
||||||
pub output_dir_path: PathBuf,
|
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()?
|
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,
|
inv_costing_method_arg: args.opts.inv_costing_method,
|
||||||
lk_cutoff_date_arg: args.opts.lk_cutoff_date,
|
lk_cutoff_date_arg: args.opts.lk_cutoff_date,
|
||||||
output_dir_path: args.opts.output_dir_path,
|
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)?;
|
) = wizard_or_not(args.flags.accept_args, wizard_or_not_args)?;
|
||||||
|
|
||||||
let settings = ImportProcessParameters {
|
let settings = ImportProcessParameters {
|
||||||
export_path: output_dir_path,
|
|
||||||
home_currency: args.opts.home_currency.into_string().unwrap().to_uppercase(),
|
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,
|
costing_method: costing_method_choice,
|
||||||
enable_like_kind_treatment: like_kind_election,
|
enable_like_kind_treatment: like_kind_election,
|
||||||
lk_cutoff_date_string: like_kind_cutoff_date_string,
|
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,
|
should_export: should_export,
|
||||||
|
export_path: output_dir_path,
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok((input_file_path, settings))
|
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,
|
InventoryCostingMethod,
|
||||||
bool,
|
bool,
|
||||||
String,
|
String,
|
||||||
|
@ -84,7 +84,7 @@ fn wizard_or_not(accept_args: bool, excl_args: WizardMaybeArgs) -> Result<(
|
||||||
like_kind_cutoff_date_string1,
|
like_kind_cutoff_date_string1,
|
||||||
should_export1,
|
should_export1,
|
||||||
output_dir_path1,
|
output_dir_path1,
|
||||||
) = wizard::wizard(excl_args)?;
|
) = wizard::wizard(args)?;
|
||||||
|
|
||||||
costing_method_choice = costing_method_choice1;
|
costing_method_choice = costing_method_choice1;
|
||||||
like_kind_election = like_kind_election1;
|
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,
|
like_kind_cutoff_date_string1,
|
||||||
should_export1,
|
should_export1,
|
||||||
output_dir_path1,
|
output_dir_path1,
|
||||||
) = skip_wizard::skip_wizard(excl_args)?;
|
) = skip_wizard::skip_wizard(args)?;
|
||||||
|
|
||||||
costing_method_choice = costing_method_choice1;
|
costing_method_choice = costing_method_choice1;
|
||||||
like_kind_election = like_kind_election1;
|
like_kind_election = like_kind_election1;
|
||||||
|
|
|
@ -6,9 +6,9 @@ use std::error::Error;
|
||||||
|
|
||||||
use crate::cli_user_choices;
|
use crate::cli_user_choices;
|
||||||
use crate::core_functions::{InventoryCostingMethod};
|
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,
|
InventoryCostingMethod,
|
||||||
bool,
|
bool,
|
||||||
String,
|
String,
|
||||||
|
@ -16,12 +16,12 @@ pub(crate) fn skip_wizard(excl_args: WizardMaybeArgs) -> Result<(
|
||||||
PathBuf,
|
PathBuf,
|
||||||
), Box<dyn Error>> {
|
), Box<dyn Error>> {
|
||||||
|
|
||||||
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_election;
|
||||||
let like_kind_cutoff_date_string: String;
|
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_election = true;
|
||||||
like_kind_cutoff_date_string = date.into_string().unwrap();
|
like_kind_cutoff_date_string = date.into_string().unwrap();
|
||||||
} else {
|
} else {
|
||||||
|
@ -29,7 +29,7 @@ pub(crate) fn skip_wizard(excl_args: WizardMaybeArgs) -> Result<(
|
||||||
like_kind_cutoff_date_string = "1-1-1".to_string();
|
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))
|
||||||
}
|
}
|
|
@ -8,9 +8,9 @@ use std::path::PathBuf;
|
||||||
|
|
||||||
use crate::cli_user_choices;
|
use crate::cli_user_choices;
|
||||||
use crate::core_functions::{InventoryCostingMethod};
|
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,
|
InventoryCostingMethod,
|
||||||
bool,
|
bool,
|
||||||
String,
|
String,
|
||||||
|
@ -20,11 +20,11 @@ pub(crate) fn wizard(excl_args: WizardMaybeArgs) -> Result<(
|
||||||
|
|
||||||
shall_we_proceed()?;
|
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;
|
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())
|
lk_cutoff_date_opt_string = Some(lk_cutoff.into_string().unwrap())
|
||||||
} else {
|
} else {
|
||||||
lk_cutoff_date_opt_string = None
|
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 (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()))
|
Ok((costing_method_choice, like_kind_election, like_kind_cutoff_date_string, should_export, output_dir_path.to_path_buf()))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue