diff --git a/container/src/finance/lib/internal/lib_taxes.bash b/container/src/finance/lib/internal/lib_taxes.bash index b4274cf..db01876 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 @@ -1000,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" @@ -1024,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}" @@ -1046,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 @@ -1054,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 $? @@ -1138,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: