LotProcessingChoices -> ImportProcessParameters

This commit is contained in:
scoobybejesus 2019-08-25 20:56:33 -04:00
parent d1bb1c255e
commit 557546b103
7 changed files with 26 additions and 26 deletions

View File

@ -261,14 +261,14 @@ pub fn elect_like_kind_treatment(cutoff_date_arg: &Option<String>) -> (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 {

View File

@ -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<u16, Account>,
HashMap<u16, RawAccount>,

View File

@ -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<u32, Transaction>,
settings: &LotProcessingChoices,
settings: &ImportProcessParameters,
likekind_settings: &Option<LikeKindSettings>,
ar_map: &HashMap<u32, ActionRecord>,
raw_acct_map: &HashMap<u16, RawAccount>,
@ -625,7 +625,7 @@ fn wrap_mvmt_and_push(
this_mvmt: Movement,
ar: &ActionRecord,
lot: &Lot,
settings: &LotProcessingChoices,
settings: &ImportProcessParameters,
raw_acct_map: &HashMap<u16, RawAccount>,
acct_map: &HashMap<u16, Account>,
) {
@ -656,7 +656,7 @@ fn fit_into_lots(
list_of_lots_to_use: RefCell<Vec<Rc<Lot>>>,
vec_of_ordered_index_values: Vec<usize>,
index_position: usize,
settings: &LotProcessingChoices,
settings: &ImportProcessParameters,
ar_map: &HashMap<u32, ActionRecord>,
raw_acct_map: &HashMap<u16, RawAccount>,
acct_map: &HashMap<u16, Account>,
@ -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<u16, RawAccount>,
acct_map: &HashMap<u16, Account>,

View File

@ -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<u16, RawAccount>,
acct_map: &HashMap<u16, Account>
) {
@ -77,7 +77,7 @@ pub fn _1_account_sums_to_csv(
pub fn _2_account_sums_nonzero_to_csv(
acct_map: &HashMap<u16, Account>,
settings: &LotProcessingChoices,
settings: &ImportProcessParameters,
raw_acct_map: &HashMap<u16, RawAccount>
) {
@ -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<u32, ActionRecord>,
raw_acct_map: &HashMap<u16, RawAccount>,
acct_map: &HashMap<u16, Account>,

View File

@ -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<u32, ActionRecord>,
raw_acct_map: &HashMap<u16, RawAccount>,
acct_map: &HashMap<u16, Account>,
@ -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<u32, ActionRecord>,
raw_acct_map: &HashMap<u16, RawAccount>,
acct_map: &HashMap<u16, Account>,
@ -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<u32, ActionRecord>,
raw_acct_map: &HashMap<u16, RawAccount>,
acct_map: &HashMap<u16, Account>,
@ -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<u32, ActionRecord>,
raw_acct_map: &HashMap<u16, RawAccount>,
acct_map: &HashMap<u16, Account>,
@ -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;

View File

@ -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<dyn std::error::Error>> {
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<dyn std::error::Error>> {
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<dyn std::error::Error>> {
Err(err) => { println!("Export choice error. {}", err); process::exit(1); }
};
fn _export(settings: &mut LotProcessingChoices) -> Result<(bool), Box<Error>> {
fn _export(settings: &mut ImportProcessParameters) -> Result<(bool), Box<Error>> {
let mut input = String::new();
let stdin = io::stdin();
@ -234,7 +234,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
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,

View File

@ -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<u32, ActionRecord>,
raw_acct_map: &HashMap<u16, RawAccount>,
acct_map: &HashMap<u16, Account>,