Compare commits

..

2 Commits

Author SHA1 Message Date
scoobybejesus f6e9b5525b Improve/fix messages/wording. 2020-12-12 14:33:36 -05:00
scoobybejesus f7f9926e5e Improve/fix messages/wording. 2020-12-12 14:10:06 -05:00
7 changed files with 27 additions and 26 deletions

View File

@ -200,7 +200,6 @@ but be sure not to include the ticker or symbol of the currency
(i.e., for `$14,567.27 USD`, enter `14567.27` or `14,567.27`). (i.e., for `$14,567.27 USD`, enter `14567.27` or `14,567.27`).
* **memo**: This can be a string of characters of any length, though fewer than 20-30 characters is advised. * **memo**: This can be a string of characters of any length, though fewer than 20-30 characters is advised.
Currently, **commas** in the memo field are **not** supported.
* *quantity*: This is similar to **proceeds**, in that the **decimal separator** must be a **period**, * *quantity*: This is similar to **proceeds**, in that the **decimal separator** must be a **period**,
and you *cannot* include the ticker or symbol of the currency in that field. and you *cannot* include the ticker or symbol of the currency in that field.

View File

@ -34,7 +34,7 @@ so it can be successfully imported into `cryptools`.
* Two methods each of LIFO or FIFO (compatible w/ the concept of "specific identification") * Two methods each of LIFO or FIFO (compatible w/ the concept of "specific identification")
* Ability to perform like-kind exchange treatment through a particular date * Ability to perform like-kind exchange treatment through a particular date (must use wizard or `.env` file)
* Compatible with any (single) home currency * Compatible with any (single) home currency

View File

@ -60,7 +60,7 @@ pub fn import_and_process_final(
&mut transactions_map, &mut transactions_map,
)?; )?;
println!(" Successfully imported csv file."); println!(" Successfully imported CSV Input File.");
println!("Processing the data..."); println!("Processing the data...");
transactions_map = create_lots_mvmts::create_lots_and_movements( transactions_map = create_lots_mvmts::create_lots_and_movements(

View File

@ -28,7 +28,7 @@ pub fn import_from_csv(
let file = match File::open(import_file_path) { let file = match File::open(import_file_path) {
Ok(x) => { Ok(x) => {
println!("\nCSV ledger file opened successfully.\n"); // println!("\nCSV ledger file opened successfully.\n");
x x
}, },
Err(e) => { Err(e) => {
@ -90,7 +90,7 @@ ordered chronologically (i.e., beginning in column 4 - the 1st account column -
The next column's value should be 2, then 3, etc, until the final account)."; The next column's value should be 2, then 3, etc, until the final account).";
// Header row variables have been set. It's now time to set up the accounts. // Header row variables have been set. It's now time to set up the accounts.
println!("Attempting to create accounts..."); println!("\nCreating accounts...");
let length = &headerstrings.len(); let length = &headerstrings.len();
@ -153,7 +153,7 @@ fn import_transactions(
let mut changed_action_records = 0; let mut changed_action_records = 0;
let mut changed_txn_num = Vec::new(); let mut changed_txn_num = Vec::new();
println!("Attempting to create transactions..."); println!("Creating transactions...");
for result in rdr.records() { for result in rdr.records() {
@ -243,9 +243,9 @@ fn import_transactions(
let tx_date = NaiveDate::parse_from_str(this_tx_date, &format_yy) let tx_date = NaiveDate::parse_from_str(this_tx_date, &format_yy)
.unwrap_or_else(|_| NaiveDate::parse_from_str(this_tx_date, &format_yyyy) .unwrap_or_else(|_| NaiveDate::parse_from_str(this_tx_date, &format_yyyy)
.expect(" .expect("
Failed to parse date in input file. Confirm your choice of the separator character, which is expected to be a hyphen \ FATAL: Transaction date parsing failed. You must tell the program the format of the date in your CSV Input File. The date separator \
unless otherwise set via command line flag, environment variable or .env file. Also confirm your choice of dating format \ is expected to be a hyphen. The dating format is expected to be \"American\" (%m-%d-%y), not ISO 8601 (%y-%m-%d). You may set different \
whether it be American (%m-%d-%y) or ISO (%y-%m-%d). Run with `--help` or see `.env.example.`\n") date format options via command line flag, environment variable or .env file. Perhaps first run with `--help` or see `.env.example.`\n")
); );
let transaction = Transaction { let transaction = Transaction {

View File

@ -1,6 +1,6 @@
## CONFIGURATION ## CONFIGURATION
## ##
## If the defaults below are not suitable, copy this .env.example into a new .env file, ## The defaults are shown below. If the defaults are not suitable, copy this .env.example into a new .env file,
## uncomment the respective enviroment variable, and set the value according to your needs. ## uncomment the respective enviroment variable, and set the value according to your needs.
## Alternatively, command line flags are available for ISO_DATE and DATE_SEPARATOR_SWITCH. ## Alternatively, command line flags are available for ISO_DATE and DATE_SEPARATOR_SWITCH.
## Command line flags will override enviroment variables. ## Command line flags will override enviroment variables.
@ -26,6 +26,7 @@
# (Optional; default is not set) # (Optional; default is not set)
#LK_CUTOFF_DATE=YYYY-mm-DD #LK_CUTOFF_DATE=YYYY-mm-DD
# These are the options available for choosing in which order lots are chosen for disposals.
#1. LIFO according to the order the lot was created. #1. LIFO according to the order the lot was created.
#2. LIFO according to the basis date of the lot. #2. LIFO according to the basis date of the lot.
#3. FIFO according to the order the lot was created. #3. FIFO according to the order the lot was created.

View File

@ -119,8 +119,7 @@ This software will import your csv file's ledger of cryptocurrency transactions.
It will then process it by creating 'lots' and posting 'movements' to those lots. It will then process it by creating 'lots' and posting 'movements' to those lots.
Along the way, it will keep track of income, expenses, gains, and losses. Along the way, it will keep track of income, expenses, gains, and losses.
See .env.example for environment variables that may be set in a .env file in order to See examples/.env.example or run with --help to learn how to change default program behavior.
change default program behavior.
Note: The software is designed to import a full history. Gains and losses may be incorrect otherwise. Note: The software is designed to import a full history. Gains and losses may be incorrect otherwise.
"); ");

View File

@ -20,47 +20,49 @@ use crate::wizard;
pub fn get_env(cmd_args: &super::Cli) -> Result<super::Cfg, Box<dyn Error>> { pub fn get_env(cmd_args: &super::Cli) -> Result<super::Cfg, Box<dyn Error>> {
match dotenv::dotenv() { match dotenv::dotenv() {
Ok(_path) => { println!("Setting environment variables from .env file.") }, Ok(_path) => { println!("Exporting temporary environment variables from .env file.") },
Err(_e) => println!("Did not find .env file.") Err(_e) => println!("Did not find .env file.")
} }
println!(" Setting runtime variables according to command line options or environment variables (the former take precedent).");
let iso_date: bool = if cmd_args.iso_date { let iso_date: bool = if cmd_args.iso_date {
println!(" Command line flag for ISO_DATE was set. Using YY-mm-dd or YY/mm/dd."); println!(" Command line flag for ISO_DATE was set. Using YY-mm-dd or YY/mm/dd.");
true true
} else { } else {
match env::var("ISO_DATE") { match env::var("ISO_DATE") {
Ok(val) => { Ok(val) => {
if val == "1" || val.to_lowercase() == "true" { if val == "1" || val.to_lowercase() == "true" {
println!(" Found ISO_DATE env var: {}. Using YY-mm-dd or YY/mm/dd.", val); println!(" Found ISO_DATE env var: {}. Using YY-mm-dd or YY/mm/dd.", val);
true true
} else { } else {
println!(" Found ISO_DATE env var: {} (not 1 or true). Using MM-dd-YY or MM/dd/YY.", val); println!(" Found ISO_DATE env var: {} (not 1 or true). Using MM-dd-YY or MM/dd/YY.", val);
false false
} }
}, },
Err(_e) => { Err(_e) => {
println!(" Using default dating convention (MM-dd-YY or MM/dd/YY)."); println!(" Using default dating convention (MM-dd-YY or MM/dd/YY).");
false false
}, },
} }
}; };
let date_separator_is_slash: bool = if cmd_args.date_separator_is_slash { let date_separator_is_slash: bool = if cmd_args.date_separator_is_slash {
println!(" Command line flag for DATE_SEPARATOR_IS_SLASH was set. Date separator set to slash (\"/\")."); println!(" Command line flag for DATE_SEPARATOR_IS_SLASH was set. Date separator set to slash (\"/\").");
true true
} else { } else {
match env::var("DATE_SEPARATOR_IS_SLASH") { match env::var("DATE_SEPARATOR_IS_SLASH") {
Ok(val) => { Ok(val) => {
if val == "1" || val.to_ascii_lowercase() == "true" { if val == "1" || val.to_ascii_lowercase() == "true" {
println!(" Found DATE_SEPARATOR_IS_SLASH env var: {}. Date separator set to slash (\"/\").", val); println!(" Found DATE_SEPARATOR_IS_SLASH env var: {}. Date separator set to slash (\"/\").", val);
true true
} else { } else {
println!(" Found DATE_SEPARATOR_IS_SLASH env var: {} (not 1 or true). Date separator set to hyphen (\"-\").", val); println!(" Found DATE_SEPARATOR_IS_SLASH env var: {} (not 1 or true). Date separator set to hyphen (\"-\").", val);
false false
} }
} }
Err(_e) => { Err(_e) => {
println!(" Using default date separator, hyphen (\"-\")."); println!(" Using default date separator, hyphen (\"-\").");
false false
}, },
} }
@ -68,26 +70,26 @@ pub fn get_env(cmd_args: &super::Cli) -> Result<super::Cfg, Box<dyn Error>> {
let home_currency = match env::var("HOME_CURRENCY") { let home_currency = match env::var("HOME_CURRENCY") {
Ok(val) => { Ok(val) => {
println!(" Found HOME_CURRENCY env var: {}", val); println!(" Found HOME_CURRENCY env var: {}", val);
val.to_uppercase()}, val.to_uppercase()},
Err(_e) => { Err(_e) => {
println!(" Using default home currency (USD)."); println!(" Using default home currency (USD).");
"USD".to_string()}, "USD".to_string()},
}; };
let lk_cutoff_date = match env::var("LK_CUTOFF_DATE") { let lk_cutoff_date = match env::var("LK_CUTOFF_DATE") {
Ok(val) => { Ok(val) => {
println!(" Found LK_CUTOFF_DATE env var: {}", val); println!(" Found LK_CUTOFF_DATE env var: {}", val);
Some(val)}, Some(val)},
Err(_e) => None, Err(_e) => None,
}; };
let inv_costing_method = match env::var("INV_COSTING_METHOD") { let inv_costing_method = match env::var("INV_COSTING_METHOD") {
Ok(val) => { Ok(val) => {
println!(" Found INV_COSTING_METHOD env var: {}", val); println!(" Found INV_COSTING_METHOD env var: {}", val);
val}, val},
Err(_e) => { Err(_e) => {
println!(" Using default inventory costing method (LIFO by lot creation date)."); println!(" Using default inventory costing method (LIFO by lot creation date).");
"1".to_string()}, "1".to_string()},
}; };