From e9960461b7b33864e89883f3bd9cd4678b28abb1 Mon Sep 17 00:00:00 2001 From: Aaron Fiore Date: Wed, 22 Oct 2025 12:35:49 -0700 Subject: [PATCH 1/3] container: lib_taxes: fix arg parsing for 'all' years Impl was not able to process 'all' years because global_arg_year was set --- container/src/finance/lib/internal/lib_taxes.bash | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/container/src/finance/lib/internal/lib_taxes.bash b/container/src/finance/lib/internal/lib_taxes.bash index b4274cf..0865fa7 100644 --- a/container/src/finance/lib/internal/lib_taxes.bash +++ b/container/src/finance/lib/internal/lib_taxes.bash @@ -284,11 +284,12 @@ function lib_taxes::__parse_args() lib_utils::die_usage "$_usage" fi global_arg_year="$_arg_year" - declare -gr global_arg_year + declare -g global_arg_year if [ "$global_arg_year" == "all" ]; then # Implementation will treat an empty as all years unset global_arg_year fi + declare -r global_arg_year else global_arg_year="$(date +%Y)" # Set default declare -gr global_arg_year From 960e51fe0a46c02e91ce0ce9309bd1f06de20f07 Mon Sep 17 00:00:00 2001 From: Aaron Fiore Date: Wed, 22 Oct 2025 12:49:32 -0700 Subject: [PATCH 2/3] container: lib_taxes: fix printing for 'all' years --- container/src/finance/lib/internal/lib_taxes.bash | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/container/src/finance/lib/internal/lib_taxes.bash b/container/src/finance/lib/internal/lib_taxes.bash index 0865fa7..0160498 100644 --- a/container/src/finance/lib/internal/lib_taxes.bash +++ b/container/src/finance/lib/internal/lib_taxes.bash @@ -1001,7 +1001,7 @@ function lib_taxes::__taxes_write() local _current_year _current_year="$(date +%Y)" if [ -z "$global_arg_year" ]; then - lib_utils::print_normal "Capturing the year of the oldest tagged record ..." + lib_utils::print_info "Capturing the year of the oldest tagged record ...\n" local -r _oldest_year="$("${_base_hledger[@]}" | head -n2 | xan select \"date\" | tail -n1 | cut -d'-' -f1)" [ -z "$_oldest_year" ] && lib_utils::die_fatal "No records available to write" @@ -1025,6 +1025,12 @@ function lib_taxes::__taxes_write() [ -z "$global_child_profile_flow" ] && lib_utils::die_fatal for ((_tax_year = ${_oldest_year}; _tax_year <= ${_current_year}; _tax_year++)); do + if [ -z "$global_arg_year" ]; then + lib_utils::print_custom " \e[32m│\e[0m\n" + lib_utils::print_info "Generating taxable events in year '${_tax_year}' ..." + lib_utils::print_custom " \e[32m│\e[0m\n" + fi + # Final output dir local _tax_root_dir="${global_child_profile_flow}/taxes/${_tax_year}" @@ -1047,7 +1053,7 @@ function lib_taxes::__taxes_write() lib_utils::catch $? if [[ ! -f "$_out_file" || ! -s "$_out_file" ]]; then - lib_utils::print_warning "Nothing generated for '${_arg_tag}' (no taxable event found for the year ${global_arg_year})" + lib_utils::print_warning "Nothing generated for '${_arg_tag}' (no taxable event found for the year ${_tax_year})" fi ) & done From da40a93ae19b1e4b35c1f5af6cb017905c99a047 Mon Sep 17 00:00:00 2001 From: Aaron Fiore Date: Wed, 22 Oct 2025 14:26:26 -0700 Subject: [PATCH 3/3] container: lib_taxes: don't attempt to patch non-existent taxable events An optimization and printing cleanup (attempts to patch won't break) --- container/src/finance/lib/internal/lib_taxes.bash | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/container/src/finance/lib/internal/lib_taxes.bash b/container/src/finance/lib/internal/lib_taxes.bash index 0160498..db01876 100644 --- a/container/src/finance/lib/internal/lib_taxes.bash +++ b/container/src/finance/lib/internal/lib_taxes.bash @@ -1061,10 +1061,6 @@ function lib_taxes::__taxes_write() # Patch transparent (full) reports # WARNING: depends on previous base path / extension format # TODO: no, not this way - lib_utils::print_custom " \e[32m│\e[0m\n" - lib_utils::print_custom " \e[32m│\e[0m\t\e[37;2m ... Applying patches (full) ...\e[0m\n" - lib_utils::print_custom " \e[32m│\e[0m\n" - lib_taxes::__reports_patch lib_utils::catch $? @@ -1145,6 +1141,12 @@ function lib_taxes::__reports_patch() local _spends="${_tax_root_dir}/spends/${_tax_year}_spends-${_ext_full}" local _trades="${_tax_root_dir}/trades/${_tax_year}_trades-${_ext_full}" + [[ ! -s "$_income" && ! -s "$_spends" && ! -s "$_trades" ]] && return 0 + + lib_utils::print_custom " \e[32m│\e[0m\n" + lib_utils::print_custom " \e[32m│\e[0m\t\e[37;2m ... Applying patches (full) ...\e[0m\n" + lib_utils::print_custom " \e[32m│\e[0m\n" + # Ensure appropriate tags in respective files # # NOTE: