Minor refactoring and renaming to clean things up.
This commit is contained in:
parent
c15420643a
commit
0af550cee6
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "cryptools"
|
name = "cryptools"
|
||||||
version = "0.8.4"
|
version = "0.8.5"
|
||||||
authors = ["scoobybejesus <scoobybejesus@users.noreply.github.com>"]
|
authors = ["scoobybejesus <scoobybejesus@users.noreply.github.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
description = "Command-line utility for processing cryptocurrency transactions into 'lots' and 'movements'."
|
description = "Command-line utility for processing cryptocurrency transactions into 'lots' and 'movements'."
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::fs::File;
|
|
||||||
use std::collections::{HashMap};
|
use std::collections::{HashMap};
|
||||||
|
|
||||||
use chrono::NaiveDate;
|
use chrono::NaiveDate;
|
||||||
|
@ -21,16 +21,16 @@ use crate::crptls_lib::costing_method::InventoryCostingMethod;
|
||||||
/// `Account`s and `Transaction`s, creation of `Lot`s and `Movement`s, addition of cost basis and proceeds
|
/// `Account`s and `Transaction`s, creation of `Lot`s and `Movement`s, addition of cost basis and proceeds
|
||||||
/// to `Movement`s, and application of like-kind treatment, in a specific and automated fashion.
|
/// to `Movement`s, and application of like-kind treatment, in a specific and automated fashion.
|
||||||
pub struct ImportProcessParameters {
|
pub struct ImportProcessParameters {
|
||||||
pub export_path: PathBuf,
|
pub input_file_date_separator: String,
|
||||||
|
pub input_file_uses_iso_date_style: bool,
|
||||||
pub home_currency: String,
|
pub home_currency: String,
|
||||||
|
pub costing_method: InventoryCostingMethod,
|
||||||
pub lk_treatment_enabled: bool,
|
pub lk_treatment_enabled: bool,
|
||||||
/// NaiveDate either from "1-1-1" (default and not to be used) or the actual date chosen (or passed in via Cli option)
|
/// NaiveDate either from "1-1-1" (default and not to be used) or the actual date chosen (or passed in via Cli option)
|
||||||
pub lk_cutoff_date: NaiveDate,
|
pub lk_cutoff_date: NaiveDate,
|
||||||
pub lk_basis_date_preserved: bool,
|
pub lk_basis_date_preserved: bool,
|
||||||
pub costing_method: InventoryCostingMethod,
|
|
||||||
pub input_file_date_separator: String,
|
|
||||||
pub input_file_has_iso_date_style: bool,
|
|
||||||
pub should_export: bool,
|
pub should_export: bool,
|
||||||
|
pub export_path: PathBuf,
|
||||||
pub print_menu: bool,
|
pub print_menu: bool,
|
||||||
pub journal_entry_export: bool,
|
pub journal_entry_export: bool,
|
||||||
}
|
}
|
||||||
|
@ -39,8 +39,8 @@ pub fn import_and_process_final(
|
||||||
input_file_path: PathBuf,
|
input_file_path: PathBuf,
|
||||||
settings: &ImportProcessParameters,
|
settings: &ImportProcessParameters,
|
||||||
) -> Result<(
|
) -> Result<(
|
||||||
HashMap<u16, Account>,
|
|
||||||
HashMap<u16, RawAccount>,
|
HashMap<u16, RawAccount>,
|
||||||
|
HashMap<u16, Account>,
|
||||||
HashMap<u32, ActionRecord>,
|
HashMap<u32, ActionRecord>,
|
||||||
HashMap<u32, Transaction>,
|
HashMap<u32, Transaction>,
|
||||||
), Box<dyn Error>> {
|
), Box<dyn Error>> {
|
||||||
|
@ -51,63 +51,23 @@ pub fn import_and_process_final(
|
||||||
let mut account_map: HashMap<u16, Account> = HashMap::new();
|
let mut account_map: HashMap<u16, Account> = HashMap::new();
|
||||||
let mut _lot_map: HashMap<(RawAccount, u32), Lot> = HashMap::new();
|
let mut _lot_map: HashMap<(RawAccount, u32), Lot> = HashMap::new();
|
||||||
|
|
||||||
match import_from_csv(
|
csv_import_accts_txns::import_from_csv(
|
||||||
input_file_path,
|
input_file_path,
|
||||||
&mut transactions_map,
|
settings,
|
||||||
&mut action_records_map,
|
|
||||||
&mut raw_account_map,
|
&mut raw_account_map,
|
||||||
&mut account_map,
|
&mut account_map,
|
||||||
&settings.input_file_date_separator,
|
&mut action_records_map,
|
||||||
settings.input_file_has_iso_date_style,
|
&mut transactions_map,
|
||||||
) {
|
)?;
|
||||||
Ok(()) => { println!("Successfully imported csv file."); }
|
|
||||||
Err(err) => {
|
|
||||||
println!("\nFailed to import accounts and transactions from CSV.");
|
|
||||||
println!("{}", err);
|
|
||||||
|
|
||||||
return Err(err)
|
println!("Successfully imported csv file.");
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
pub(crate) fn import_from_csv(
|
|
||||||
import_file_path: PathBuf,
|
|
||||||
transactions_map: &mut HashMap<u32, Transaction>,
|
|
||||||
action_records: &mut HashMap<u32, ActionRecord>,
|
|
||||||
raw_acct_map: &mut HashMap<u16, RawAccount>,
|
|
||||||
acct_map: &mut HashMap<u16, Account>,
|
|
||||||
date_separator: &str,
|
|
||||||
iso_date_style: bool,
|
|
||||||
) -> Result<(), Box<dyn Error>> {
|
|
||||||
|
|
||||||
let file = File::open(import_file_path)?; println!("CSV ledger file opened successfully.\n");
|
|
||||||
|
|
||||||
let mut rdr = csv::ReaderBuilder::new()
|
|
||||||
.has_headers(true)
|
|
||||||
.from_reader(file);
|
|
||||||
|
|
||||||
csv_import_accts_txns::import_accounts(&mut rdr, raw_acct_map, acct_map)?;
|
|
||||||
|
|
||||||
csv_import_accts_txns::import_transactions(
|
|
||||||
&mut rdr,
|
|
||||||
transactions_map,
|
|
||||||
action_records,
|
|
||||||
date_separator,
|
|
||||||
iso_date_style,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
transactions_map = create_lots_mvmts::create_lots_and_movements(
|
transactions_map = create_lots_mvmts::create_lots_and_movements(
|
||||||
transactions_map,
|
&settings,
|
||||||
&action_records_map,
|
|
||||||
&raw_account_map,
|
&raw_account_map,
|
||||||
&account_map,
|
&account_map,
|
||||||
&settings.home_currency.as_str(),
|
&action_records_map,
|
||||||
&settings.costing_method,
|
transactions_map,
|
||||||
settings.lk_treatment_enabled,
|
|
||||||
settings.lk_cutoff_date,
|
|
||||||
settings.lk_basis_date_preserved,
|
|
||||||
// &mut lot_map,
|
// &mut lot_map,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
|
@ -115,18 +75,18 @@ pub fn import_and_process_final(
|
||||||
|
|
||||||
import_cost_proceeds_etc::add_cost_basis_to_movements(
|
import_cost_proceeds_etc::add_cost_basis_to_movements(
|
||||||
&settings,
|
&settings,
|
||||||
&action_records_map,
|
|
||||||
&raw_account_map,
|
&raw_account_map,
|
||||||
&account_map,
|
&account_map,
|
||||||
|
&action_records_map,
|
||||||
&transactions_map
|
&transactions_map
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
println!(" Successfully added cost basis to movements.");
|
println!(" Successfully added cost basis to movements.");
|
||||||
|
|
||||||
import_cost_proceeds_etc::add_proceeds_to_movements(
|
import_cost_proceeds_etc::add_proceeds_to_movements(
|
||||||
&action_records_map,
|
|
||||||
&raw_account_map,
|
&raw_account_map,
|
||||||
&account_map,
|
&account_map,
|
||||||
|
&action_records_map,
|
||||||
&transactions_map
|
&transactions_map
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
|
@ -139,14 +99,14 @@ pub fn import_and_process_final(
|
||||||
|
|
||||||
import_cost_proceeds_etc::apply_like_kind_treatment(
|
import_cost_proceeds_etc::apply_like_kind_treatment(
|
||||||
&settings,
|
&settings,
|
||||||
&action_records_map,
|
|
||||||
&raw_account_map,
|
&raw_account_map,
|
||||||
&account_map,
|
&account_map,
|
||||||
|
&action_records_map,
|
||||||
&transactions_map
|
&transactions_map
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
println!(" Successfully applied like-kind treatment.");
|
println!(" Successfully applied like-kind treatment.");
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok((account_map, raw_account_map, action_records_map, transactions_map))
|
Ok((raw_account_map, account_map, action_records_map, transactions_map))
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,26 +7,28 @@ use std::collections::{HashMap};
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
|
|
||||||
use decimal::d128;
|
use decimal::d128;
|
||||||
use chrono::NaiveDate;
|
|
||||||
|
|
||||||
|
use crate::crptls_lib::core_functions::{ImportProcessParameters};
|
||||||
use crate::crptls_lib::transaction::{Transaction, ActionRecord, TxType, Polarity, TxHasMargin};
|
use crate::crptls_lib::transaction::{Transaction, ActionRecord, TxType, Polarity, TxHasMargin};
|
||||||
use crate::crptls_lib::account::{Account, RawAccount, Lot, Movement};
|
use crate::crptls_lib::account::{Account, RawAccount, Lot, Movement};
|
||||||
use crate::crptls_lib::costing_method::{InventoryCostingMethod};
|
use crate::crptls_lib::costing_method::{InventoryCostingMethod};
|
||||||
use crate::crptls_lib::decimal_utils::{round_d128_1e8};
|
use crate::crptls_lib::decimal_utils::{round_d128_1e8};
|
||||||
|
|
||||||
pub(crate) fn create_lots_and_movements(
|
pub(crate) fn create_lots_and_movements(
|
||||||
txns_map: HashMap<u32, Transaction>,
|
settings: &ImportProcessParameters,
|
||||||
ar_map: &HashMap<u32, ActionRecord>,
|
|
||||||
raw_acct_map: &HashMap<u16, RawAccount>,
|
raw_acct_map: &HashMap<u16, RawAccount>,
|
||||||
acct_map: &HashMap<u16, Account>,
|
acct_map: &HashMap<u16, Account>,
|
||||||
chosen_home_currency: &str,
|
ar_map: &HashMap<u32, ActionRecord>,
|
||||||
chosen_costing_method: &InventoryCostingMethod,
|
txns_map: HashMap<u32, Transaction>,
|
||||||
enable_lk_treatment: bool,
|
|
||||||
like_kind_cutoff_date: NaiveDate,
|
|
||||||
lk_basis_date_preserved: bool,
|
|
||||||
// lot_map: &HashMap<(RawAccount, u32), Lot>,
|
// lot_map: &HashMap<(RawAccount, u32), Lot>,
|
||||||
) -> Result<HashMap<u32,Transaction>, Box<dyn Error>> {
|
) -> Result<HashMap<u32,Transaction>, Box<dyn Error>> {
|
||||||
|
|
||||||
|
let chosen_home_currency = &settings.home_currency;
|
||||||
|
let chosen_costing_method = &settings.costing_method;
|
||||||
|
let enable_lk_treatment = settings.lk_treatment_enabled;
|
||||||
|
let like_kind_cutoff_date = settings.lk_cutoff_date;
|
||||||
|
let lk_basis_date_preserved = settings.lk_basis_date_preserved;
|
||||||
|
|
||||||
let multiple_incoming_mvmts_per_ar = lk_basis_date_preserved;
|
let multiple_incoming_mvmts_per_ar = lk_basis_date_preserved;
|
||||||
|
|
||||||
// On with the creating of lots and movements.
|
// On with the creating of lots and movements.
|
||||||
|
|
|
@ -6,16 +6,45 @@ use std::process;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::cell::{RefCell};
|
use std::cell::{RefCell};
|
||||||
use std::collections::{HashMap};
|
use std::collections::{HashMap};
|
||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use chrono::NaiveDate;
|
use chrono::NaiveDate;
|
||||||
use decimal::d128;
|
use decimal::d128;
|
||||||
|
|
||||||
|
use crate::crptls_lib::core_functions::{ImportProcessParameters};
|
||||||
use crate::crptls_lib::transaction::{Transaction, ActionRecord};
|
use crate::crptls_lib::transaction::{Transaction, ActionRecord};
|
||||||
use crate::crptls_lib::account::{Account, RawAccount};
|
use crate::crptls_lib::account::{Account, RawAccount};
|
||||||
use crate::crptls_lib::decimal_utils::{round_d128_1e8};
|
use crate::crptls_lib::decimal_utils::{round_d128_1e8};
|
||||||
|
|
||||||
|
|
||||||
pub(crate) fn import_accounts(
|
pub(crate) fn import_from_csv(
|
||||||
|
import_file_path: PathBuf,
|
||||||
|
settings: &ImportProcessParameters,
|
||||||
|
raw_acct_map: &mut HashMap<u16, RawAccount>,
|
||||||
|
acct_map: &mut HashMap<u16, Account>,
|
||||||
|
action_records: &mut HashMap<u32, ActionRecord>,
|
||||||
|
transactions_map: &mut HashMap<u32, Transaction>,
|
||||||
|
) -> Result<(), Box<dyn Error>> {
|
||||||
|
|
||||||
|
let file = File::open(import_file_path)?; println!("CSV ledger file opened successfully.\n");
|
||||||
|
|
||||||
|
let mut rdr = csv::ReaderBuilder::new()
|
||||||
|
.has_headers(true)
|
||||||
|
.from_reader(file);
|
||||||
|
|
||||||
|
import_accounts(&mut rdr, raw_acct_map, acct_map)?;
|
||||||
|
|
||||||
|
import_transactions(
|
||||||
|
&mut rdr,
|
||||||
|
settings,
|
||||||
|
action_records,
|
||||||
|
transactions_map,
|
||||||
|
)?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn import_accounts(
|
||||||
rdr: &mut csv::Reader<File>,
|
rdr: &mut csv::Reader<File>,
|
||||||
raw_acct_map: &mut HashMap<u16, RawAccount>,
|
raw_acct_map: &mut HashMap<u16, RawAccount>,
|
||||||
acct_map: &mut HashMap<u16, Account>,
|
acct_map: &mut HashMap<u16, Account>,
|
||||||
|
@ -107,12 +136,11 @@ The next column's value should be 2, then 3, etc, until the final account).";
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn import_transactions(
|
fn import_transactions(
|
||||||
rdr: &mut csv::Reader<File>,
|
rdr: &mut csv::Reader<File>,
|
||||||
txns_map: &mut HashMap<u32, Transaction>,
|
settings: &ImportProcessParameters,
|
||||||
action_records: &mut HashMap<u32, ActionRecord>,
|
action_records: &mut HashMap<u32, ActionRecord>,
|
||||||
sep: &str,
|
txns_map: &mut HashMap<u32, Transaction>,
|
||||||
iso: bool,
|
|
||||||
) -> Result<(), Box<dyn Error>> {
|
) -> Result<(), Box<dyn Error>> {
|
||||||
|
|
||||||
let mut this_tx_number = 0;
|
let mut this_tx_number = 0;
|
||||||
|
@ -198,12 +226,15 @@ pub(crate) fn import_transactions(
|
||||||
let format_yy: String;
|
let format_yy: String;
|
||||||
let format_yyyy: String;
|
let format_yyyy: String;
|
||||||
|
|
||||||
if iso {
|
let iso_date_style = settings.input_file_uses_iso_date_style;
|
||||||
format_yyyy = "%Y".to_owned() + sep + "%d" + sep + "%m";
|
let separator = &settings.input_file_date_separator;
|
||||||
format_yy = "%y".to_owned() + sep + "%d" + sep + "%m";
|
|
||||||
|
if iso_date_style {
|
||||||
|
format_yyyy = "%Y".to_owned() + separator + "%d" + separator + "%m";
|
||||||
|
format_yy = "%y".to_owned() + separator + "%d" + separator + "%m";
|
||||||
} else {
|
} else {
|
||||||
format_yyyy = "%m".to_owned() + sep + "%d" + sep + "%Y";
|
format_yyyy = "%m".to_owned() + separator + "%d" + separator + "%Y";
|
||||||
format_yy = "%m".to_owned() + sep + "%d" + sep + "%y";
|
format_yy = "%m".to_owned() + separator + "%d" + separator + "%y";
|
||||||
}
|
}
|
||||||
|
|
||||||
let tx_date = NaiveDate::parse_from_str(this_tx_date, &format_yy)
|
let tx_date = NaiveDate::parse_from_str(this_tx_date, &format_yy)
|
||||||
|
|
|
@ -13,9 +13,9 @@ use crate::crptls_lib::core_functions::{ImportProcessParameters};
|
||||||
|
|
||||||
pub(crate) fn add_cost_basis_to_movements(
|
pub(crate) fn add_cost_basis_to_movements(
|
||||||
settings: &ImportProcessParameters,
|
settings: &ImportProcessParameters,
|
||||||
ars: &HashMap<u32, ActionRecord>,
|
|
||||||
raw_acct_map: &HashMap<u16, RawAccount>,
|
raw_acct_map: &HashMap<u16, RawAccount>,
|
||||||
acct_map: &HashMap<u16, Account>,
|
acct_map: &HashMap<u16, Account>,
|
||||||
|
ars: &HashMap<u32, ActionRecord>,
|
||||||
txns_map: &HashMap<u32, Transaction>,
|
txns_map: &HashMap<u32, Transaction>,
|
||||||
) -> Result<(), Box<dyn Error>> {
|
) -> Result<(), Box<dyn Error>> {
|
||||||
|
|
||||||
|
@ -183,9 +183,9 @@ pub(crate) fn add_cost_basis_to_movements(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn add_proceeds_to_movements(
|
pub(crate) fn add_proceeds_to_movements(
|
||||||
ars: &HashMap<u32, ActionRecord>,
|
|
||||||
raw_acct_map: &HashMap<u16, RawAccount>,
|
raw_acct_map: &HashMap<u16, RawAccount>,
|
||||||
acct_map: &HashMap<u16, Account>,
|
acct_map: &HashMap<u16, Account>,
|
||||||
|
ars: &HashMap<u32, ActionRecord>,
|
||||||
txns_map: &HashMap<u32, Transaction>,
|
txns_map: &HashMap<u32, Transaction>,
|
||||||
) -> Result<(), Box<dyn Error>> {
|
) -> Result<(), Box<dyn Error>> {
|
||||||
|
|
||||||
|
@ -266,9 +266,9 @@ pub(crate) fn add_proceeds_to_movements(
|
||||||
|
|
||||||
pub(crate) fn apply_like_kind_treatment(
|
pub(crate) fn apply_like_kind_treatment(
|
||||||
settings: &ImportProcessParameters,
|
settings: &ImportProcessParameters,
|
||||||
ars: &HashMap<u32, ActionRecord>,
|
|
||||||
raw_acct_map: &HashMap<u16, RawAccount>,
|
raw_acct_map: &HashMap<u16, RawAccount>,
|
||||||
acct_map: &HashMap<u16, Account>,
|
acct_map: &HashMap<u16, Account>,
|
||||||
|
ars: &HashMap<u32, ActionRecord>,
|
||||||
txns_map: &HashMap<u32, Transaction>,
|
txns_map: &HashMap<u32, Transaction>,
|
||||||
) -> Result<(), Box<dyn Error>> {
|
) -> Result<(), Box<dyn Error>> {
|
||||||
|
|
||||||
|
@ -279,10 +279,10 @@ pub(crate) fn apply_like_kind_treatment(
|
||||||
let txn_num = txn_num as u32;
|
let txn_num = txn_num as u32;
|
||||||
let txn = txns_map.get(&(txn_num)).unwrap();
|
let txn = txns_map.get(&(txn_num)).unwrap();
|
||||||
|
|
||||||
update_current_txn_for_prior_likekind_treatment(txn_num, &settings, &ars, &raw_acct_map, &acct_map, &txns_map)?;
|
update_current_txn_for_prior_likekind_treatment(txn_num, &settings, &raw_acct_map, &acct_map, &ars, &txns_map)?;
|
||||||
|
|
||||||
if txn.date <= cutoff_date {
|
if txn.date <= cutoff_date {
|
||||||
perform_likekind_treatment_on_txn(txn_num, &settings, &ars, &raw_acct_map, &acct_map, &txns_map)?;
|
perform_likekind_treatment_on_txn(txn_num, &settings, &raw_acct_map, &acct_map, &ars, &txns_map)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -292,9 +292,9 @@ pub(crate) fn apply_like_kind_treatment(
|
||||||
fn update_current_txn_for_prior_likekind_treatment(
|
fn update_current_txn_for_prior_likekind_treatment(
|
||||||
txn_num: u32,
|
txn_num: u32,
|
||||||
settings: &ImportProcessParameters,
|
settings: &ImportProcessParameters,
|
||||||
ars: &HashMap<u32, ActionRecord>,
|
|
||||||
raw_acct_map: &HashMap<u16, RawAccount>,
|
raw_acct_map: &HashMap<u16, RawAccount>,
|
||||||
acct_map: &HashMap<u16, Account>,
|
acct_map: &HashMap<u16, Account>,
|
||||||
|
ars: &HashMap<u32, ActionRecord>,
|
||||||
txns_map: &HashMap<u32, Transaction>,
|
txns_map: &HashMap<u32, Transaction>,
|
||||||
) -> Result<(), Box<dyn Error>> {
|
) -> Result<(), Box<dyn Error>> {
|
||||||
|
|
||||||
|
@ -382,9 +382,9 @@ fn update_current_txn_for_prior_likekind_treatment(
|
||||||
fn perform_likekind_treatment_on_txn(
|
fn perform_likekind_treatment_on_txn(
|
||||||
txn_num: u32,
|
txn_num: u32,
|
||||||
settings: &ImportProcessParameters,
|
settings: &ImportProcessParameters,
|
||||||
ars: &HashMap<u32, ActionRecord>,
|
|
||||||
raw_acct_map: &HashMap<u16, RawAccount>,
|
raw_acct_map: &HashMap<u16, RawAccount>,
|
||||||
acct_map: &HashMap<u16, Account>,
|
acct_map: &HashMap<u16, Account>,
|
||||||
|
ars: &HashMap<u32, ActionRecord>,
|
||||||
txns_map: &HashMap<u32, Transaction>,
|
txns_map: &HashMap<u32, Transaction>,
|
||||||
) -> Result<(), Box<dyn Error>> {
|
) -> Result<(), Box<dyn Error>> {
|
||||||
|
|
||||||
|
|
|
@ -14,9 +14,9 @@ use crate::export_je;
|
||||||
|
|
||||||
pub fn export(
|
pub fn export(
|
||||||
settings: &ImportProcessParameters,
|
settings: &ImportProcessParameters,
|
||||||
action_records_map: &HashMap<u32, ActionRecord>,
|
|
||||||
raw_acct_map: &HashMap<u16, RawAccount>,
|
raw_acct_map: &HashMap<u16, RawAccount>,
|
||||||
account_map: &HashMap<u16, Account>,
|
account_map: &HashMap<u16, Account>,
|
||||||
|
action_records_map: &HashMap<u32, ActionRecord>,
|
||||||
transactions_map: &HashMap<u32, Transaction>,
|
transactions_map: &HashMap<u32, Transaction>,
|
||||||
) -> Result<(), Box<dyn Error>> {
|
) -> Result<(), Box<dyn Error>> {
|
||||||
|
|
||||||
|
@ -29,9 +29,9 @@ pub fn export(
|
||||||
);
|
);
|
||||||
|
|
||||||
export_csv::_2_account_sums_nonzero_to_csv(
|
export_csv::_2_account_sums_nonzero_to_csv(
|
||||||
&account_map,
|
|
||||||
&settings,
|
&settings,
|
||||||
&raw_acct_map
|
&raw_acct_map,
|
||||||
|
&account_map,
|
||||||
);
|
);
|
||||||
|
|
||||||
if settings.lk_treatment_enabled {
|
if settings.lk_treatment_enabled {
|
||||||
|
@ -44,25 +44,25 @@ pub fn export(
|
||||||
|
|
||||||
export_csv::_4_transaction_mvmt_detail_to_csv(
|
export_csv::_4_transaction_mvmt_detail_to_csv(
|
||||||
&settings,
|
&settings,
|
||||||
&action_records_map,
|
|
||||||
&raw_acct_map,
|
&raw_acct_map,
|
||||||
&account_map,
|
&account_map,
|
||||||
|
&action_records_map,
|
||||||
&transactions_map
|
&transactions_map
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
export_csv::_5_transaction_mvmt_summaries_to_csv(
|
export_csv::_5_transaction_mvmt_summaries_to_csv(
|
||||||
&settings,
|
&settings,
|
||||||
&action_records_map,
|
|
||||||
&raw_acct_map,
|
&raw_acct_map,
|
||||||
&account_map,
|
&account_map,
|
||||||
|
&action_records_map,
|
||||||
&transactions_map
|
&transactions_map
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
export_csv::_6_transaction_mvmt_detail_to_csv_w_orig(
|
export_csv::_6_transaction_mvmt_detail_to_csv_w_orig(
|
||||||
&settings,
|
&settings,
|
||||||
&action_records_map,
|
|
||||||
&raw_acct_map,
|
&raw_acct_map,
|
||||||
&account_map,
|
&account_map,
|
||||||
|
&action_records_map,
|
||||||
&transactions_map
|
&transactions_map
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
|
@ -70,8 +70,8 @@ pub fn export(
|
||||||
&settings,
|
&settings,
|
||||||
&raw_acct_map,
|
&raw_acct_map,
|
||||||
&account_map,
|
&account_map,
|
||||||
|
&action_records_map,
|
||||||
&transactions_map,
|
&transactions_map,
|
||||||
&action_records_map
|
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
export_txt::_2_account_lot_summary_to_txt(
|
export_txt::_2_account_lot_summary_to_txt(
|
||||||
|
@ -89,9 +89,9 @@ pub fn export(
|
||||||
if !settings.lk_treatment_enabled {
|
if !settings.lk_treatment_enabled {
|
||||||
export_je::prepare_non_lk_journal_entries(
|
export_je::prepare_non_lk_journal_entries(
|
||||||
&settings,
|
&settings,
|
||||||
&action_records_map,
|
|
||||||
&raw_acct_map,
|
&raw_acct_map,
|
||||||
&account_map,
|
&account_map,
|
||||||
|
&action_records_map,
|
||||||
&transactions_map,
|
&transactions_map,
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,9 +87,9 @@ pub fn _1_account_sums_to_csv(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn _2_account_sums_nonzero_to_csv(
|
pub fn _2_account_sums_nonzero_to_csv(
|
||||||
acct_map: &HashMap<u16, Account>,
|
|
||||||
settings: &ImportProcessParameters,
|
settings: &ImportProcessParameters,
|
||||||
raw_acct_map: &HashMap<u16, RawAccount>
|
raw_acct_map: &HashMap<u16, RawAccount>,
|
||||||
|
acct_map: &HashMap<u16, Account>,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
let mut rows: Vec<Vec<String>> = Vec::with_capacity(acct_map.len()); // more than needed...
|
let mut rows: Vec<Vec<String>> = Vec::with_capacity(acct_map.len()); // more than needed...
|
||||||
|
@ -257,9 +257,9 @@ pub fn _3_account_sums_to_csv_with_orig_basis(
|
||||||
|
|
||||||
pub fn _4_transaction_mvmt_detail_to_csv(
|
pub fn _4_transaction_mvmt_detail_to_csv(
|
||||||
settings: &ImportProcessParameters,
|
settings: &ImportProcessParameters,
|
||||||
ars: &HashMap<u32, ActionRecord>,
|
|
||||||
raw_acct_map: &HashMap<u16, RawAccount>,
|
raw_acct_map: &HashMap<u16, RawAccount>,
|
||||||
acct_map: &HashMap<u16, Account>,
|
acct_map: &HashMap<u16, Account>,
|
||||||
|
ars: &HashMap<u32, ActionRecord>,
|
||||||
txns_map: &HashMap<u32, Transaction>,
|
txns_map: &HashMap<u32, Transaction>,
|
||||||
) -> Result<(), Box<dyn Error>> {
|
) -> Result<(), Box<dyn Error>> {
|
||||||
|
|
||||||
|
@ -363,9 +363,9 @@ pub fn _4_transaction_mvmt_detail_to_csv(
|
||||||
|
|
||||||
pub fn _5_transaction_mvmt_summaries_to_csv(
|
pub fn _5_transaction_mvmt_summaries_to_csv(
|
||||||
settings: &ImportProcessParameters,
|
settings: &ImportProcessParameters,
|
||||||
ars: &HashMap<u32, ActionRecord>,
|
|
||||||
raw_acct_map: &HashMap<u16, RawAccount>,
|
raw_acct_map: &HashMap<u16, RawAccount>,
|
||||||
acct_map: &HashMap<u16, Account>,
|
acct_map: &HashMap<u16, Account>,
|
||||||
|
ars: &HashMap<u32, ActionRecord>,
|
||||||
txns_map: &HashMap<u32, Transaction>,
|
txns_map: &HashMap<u32, Transaction>,
|
||||||
) -> Result<(), Box<dyn Error>> {
|
) -> Result<(), Box<dyn Error>> {
|
||||||
|
|
||||||
|
@ -546,9 +546,9 @@ pub fn _5_transaction_mvmt_summaries_to_csv(
|
||||||
|
|
||||||
pub fn _6_transaction_mvmt_detail_to_csv_w_orig(
|
pub fn _6_transaction_mvmt_detail_to_csv_w_orig(
|
||||||
settings: &ImportProcessParameters,
|
settings: &ImportProcessParameters,
|
||||||
ars: &HashMap<u32, ActionRecord>,
|
|
||||||
raw_acct_map: &HashMap<u16, RawAccount>,
|
raw_acct_map: &HashMap<u16, RawAccount>,
|
||||||
acct_map: &HashMap<u16, Account>,
|
acct_map: &HashMap<u16, Account>,
|
||||||
|
ars: &HashMap<u32, ActionRecord>,
|
||||||
txns_map: &HashMap<u32, Transaction>,
|
txns_map: &HashMap<u32, Transaction>,
|
||||||
) -> Result<(), Box<dyn Error>> {
|
) -> Result<(), Box<dyn Error>> {
|
||||||
|
|
||||||
|
|
|
@ -16,9 +16,9 @@ use crptls::core_functions::{ImportProcessParameters};
|
||||||
|
|
||||||
pub fn prepare_non_lk_journal_entries(
|
pub fn prepare_non_lk_journal_entries(
|
||||||
settings: &ImportProcessParameters,
|
settings: &ImportProcessParameters,
|
||||||
ars: &HashMap<u32, ActionRecord>,
|
|
||||||
raw_acct_map: &HashMap<u16, RawAccount>,
|
raw_acct_map: &HashMap<u16, RawAccount>,
|
||||||
acct_map: &HashMap<u16, Account>,
|
acct_map: &HashMap<u16, Account>,
|
||||||
|
ars: &HashMap<u32, ActionRecord>,
|
||||||
txns_map: &HashMap<u32, Transaction>,
|
txns_map: &HashMap<u32, Transaction>,
|
||||||
) -> Result<(), Box<dyn Error>> {
|
) -> Result<(), Box<dyn Error>> {
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,8 @@ pub fn _1_account_lot_detail_to_txt(
|
||||||
settings: &ImportProcessParameters,
|
settings: &ImportProcessParameters,
|
||||||
raw_acct_map: &HashMap<u16, RawAccount>,
|
raw_acct_map: &HashMap<u16, RawAccount>,
|
||||||
acct_map: &HashMap<u16, Account>,
|
acct_map: &HashMap<u16, Account>,
|
||||||
txns_map: &HashMap<u32, Transaction>,
|
|
||||||
ars: &HashMap<u32, ActionRecord>,
|
ars: &HashMap<u32, ActionRecord>,
|
||||||
|
txns_map: &HashMap<u32, Transaction>,
|
||||||
) -> Result<(), Box<dyn Error>> {
|
) -> Result<(), Box<dyn Error>> {
|
||||||
|
|
||||||
// =====================================
|
// =====================================
|
||||||
|
|
|
@ -126,8 +126,8 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||||
let (input_file_path, settings) = setup::run_setup(args)?;
|
let (input_file_path, settings) = setup::run_setup(args)?;
|
||||||
|
|
||||||
let (
|
let (
|
||||||
account_map,
|
|
||||||
raw_acct_map,
|
raw_acct_map,
|
||||||
|
account_map,
|
||||||
action_records_map,
|
action_records_map,
|
||||||
transactions_map,
|
transactions_map,
|
||||||
) = crptls::core_functions::import_and_process_final(input_file_path, &settings)?;
|
) = crptls::core_functions::import_and_process_final(input_file_path, &settings)?;
|
||||||
|
@ -143,9 +143,9 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||||
|
|
||||||
export_all::export(
|
export_all::export(
|
||||||
&settings,
|
&settings,
|
||||||
&action_records_map,
|
|
||||||
&raw_acct_map,
|
&raw_acct_map,
|
||||||
&account_map,
|
&account_map,
|
||||||
|
&action_records_map,
|
||||||
&transactions_map
|
&transactions_map
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
@ -154,9 +154,9 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||||
|
|
||||||
export_je::prepare_non_lk_journal_entries(
|
export_je::prepare_non_lk_journal_entries(
|
||||||
&settings,
|
&settings,
|
||||||
&action_records_map,
|
|
||||||
&raw_acct_map,
|
&raw_acct_map,
|
||||||
&account_map,
|
&account_map,
|
||||||
|
&action_records_map,
|
||||||
&transactions_map,
|
&transactions_map,
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
@ -165,9 +165,9 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||||
|
|
||||||
mytui::print_menu_tui::print_menu_tui(
|
mytui::print_menu_tui::print_menu_tui(
|
||||||
&settings,
|
&settings,
|
||||||
&action_records_map,
|
|
||||||
&raw_acct_map,
|
&raw_acct_map,
|
||||||
&account_map,
|
&account_map,
|
||||||
|
&action_records_map,
|
||||||
&transactions_map
|
&transactions_map
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,9 +129,9 @@ impl<'a> PrintWindow<'a> {
|
||||||
pub fn export(
|
pub fn export(
|
||||||
app: &PrintWindow,
|
app: &PrintWindow,
|
||||||
settings: &ImportProcessParameters,
|
settings: &ImportProcessParameters,
|
||||||
action_records_map: &HashMap<u32, ActionRecord>,
|
|
||||||
raw_acct_map: &HashMap<u16, RawAccount>,
|
raw_acct_map: &HashMap<u16, RawAccount>,
|
||||||
account_map: &HashMap<u16, Account>,
|
account_map: &HashMap<u16, Account>,
|
||||||
|
action_records_map: &HashMap<u32, ActionRecord>,
|
||||||
transactions_map: &HashMap<u32, Transaction>,
|
transactions_map: &HashMap<u32, Transaction>,
|
||||||
) -> Result<(), Box<dyn Error>> {
|
) -> Result<(), Box<dyn Error>> {
|
||||||
|
|
||||||
|
@ -154,9 +154,9 @@ pub fn export(
|
||||||
}
|
}
|
||||||
2 => {
|
2 => {
|
||||||
export_csv::_2_account_sums_nonzero_to_csv(
|
export_csv::_2_account_sums_nonzero_to_csv(
|
||||||
&account_map,
|
|
||||||
&settings,
|
&settings,
|
||||||
&raw_acct_map
|
&raw_acct_map,
|
||||||
|
&account_map,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
3 => {
|
3 => {
|
||||||
|
@ -169,27 +169,27 @@ pub fn export(
|
||||||
4 => {
|
4 => {
|
||||||
export_csv::_4_transaction_mvmt_detail_to_csv(
|
export_csv::_4_transaction_mvmt_detail_to_csv(
|
||||||
&settings,
|
&settings,
|
||||||
&action_records_map,
|
|
||||||
&raw_acct_map,
|
&raw_acct_map,
|
||||||
&account_map,
|
&account_map,
|
||||||
|
&action_records_map,
|
||||||
&transactions_map
|
&transactions_map
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
5 => {
|
5 => {
|
||||||
export_csv::_5_transaction_mvmt_summaries_to_csv(
|
export_csv::_5_transaction_mvmt_summaries_to_csv(
|
||||||
&settings,
|
&settings,
|
||||||
&action_records_map,
|
|
||||||
&raw_acct_map,
|
&raw_acct_map,
|
||||||
&account_map,
|
&account_map,
|
||||||
|
&action_records_map,
|
||||||
&transactions_map
|
&transactions_map
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
6 => {
|
6 => {
|
||||||
export_csv::_6_transaction_mvmt_detail_to_csv_w_orig(
|
export_csv::_6_transaction_mvmt_detail_to_csv_w_orig(
|
||||||
&settings,
|
&settings,
|
||||||
&action_records_map,
|
|
||||||
&raw_acct_map,
|
&raw_acct_map,
|
||||||
&account_map,
|
&account_map,
|
||||||
|
&action_records_map,
|
||||||
&transactions_map
|
&transactions_map
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
@ -198,8 +198,8 @@ pub fn export(
|
||||||
&settings,
|
&settings,
|
||||||
&raw_acct_map,
|
&raw_acct_map,
|
||||||
&account_map,
|
&account_map,
|
||||||
|
&action_records_map,
|
||||||
&transactions_map,
|
&transactions_map,
|
||||||
&action_records_map
|
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
8 => {
|
8 => {
|
||||||
|
@ -220,9 +220,9 @@ pub fn export(
|
||||||
if !settings.lk_treatment_enabled {
|
if !settings.lk_treatment_enabled {
|
||||||
export_je::prepare_non_lk_journal_entries(
|
export_je::prepare_non_lk_journal_entries(
|
||||||
&settings,
|
&settings,
|
||||||
&action_records_map,
|
|
||||||
&raw_acct_map,
|
&raw_acct_map,
|
||||||
&account_map,
|
&account_map,
|
||||||
|
&action_records_map,
|
||||||
&transactions_map,
|
&transactions_map,
|
||||||
)?;
|
)?;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -24,9 +24,9 @@ use crate::mytui::app as app;
|
||||||
|
|
||||||
pub (crate) fn print_menu_tui(
|
pub (crate) fn print_menu_tui(
|
||||||
settings: &ImportProcessParameters,
|
settings: &ImportProcessParameters,
|
||||||
action_records_map: &HashMap<u32, ActionRecord>,
|
|
||||||
raw_acct_map: &HashMap<u16, RawAccount>,
|
raw_acct_map: &HashMap<u16, RawAccount>,
|
||||||
account_map: &HashMap<u16, Account>,
|
account_map: &HashMap<u16, Account>,
|
||||||
|
action_records_map: &HashMap<u32, ActionRecord>,
|
||||||
transactions_map: &HashMap<u32, Transaction>,
|
transactions_map: &HashMap<u32, Transaction>,
|
||||||
) -> Result<(), Box<dyn Error>> {
|
) -> Result<(), Box<dyn Error>> {
|
||||||
|
|
||||||
|
@ -77,9 +77,9 @@ pub (crate) fn print_menu_tui(
|
||||||
app::export(
|
app::export(
|
||||||
&app,
|
&app,
|
||||||
&settings,
|
&settings,
|
||||||
&action_records_map,
|
|
||||||
&raw_acct_map,
|
&raw_acct_map,
|
||||||
&account_map,
|
&account_map,
|
||||||
|
&action_records_map,
|
||||||
&transactions_map
|
&transactions_map
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
|
|
|
@ -59,9 +59,9 @@ pub (crate) fn run_setup(args: super::Cli) -> Result<(PathBuf, ImportProcessPara
|
||||||
} else { NaiveDate::parse_from_str(&"1-1-1", "%y-%m-%d").unwrap() };
|
} else { NaiveDate::parse_from_str(&"1-1-1", "%y-%m-%d").unwrap() };
|
||||||
|
|
||||||
let settings = ImportProcessParameters {
|
let settings = ImportProcessParameters {
|
||||||
home_currency: args.opts.home_currency.into_string().unwrap().to_uppercase(),
|
input_file_uses_iso_date_style: args.flags.iso_date,
|
||||||
input_file_has_iso_date_style: args.flags.iso_date,
|
|
||||||
input_file_date_separator: date_separator.to_string(),
|
input_file_date_separator: date_separator.to_string(),
|
||||||
|
home_currency: args.opts.home_currency.into_string().unwrap().to_uppercase(),
|
||||||
costing_method: costing_method_choice,
|
costing_method: costing_method_choice,
|
||||||
lk_treatment_enabled: like_kind_election,
|
lk_treatment_enabled: like_kind_election,
|
||||||
lk_cutoff_date: like_kind_cutoff_date,
|
lk_cutoff_date: like_kind_cutoff_date,
|
||||||
|
|
Loading…
Reference in New Issue