fixes tax and giveaways,...

This commit is contained in:
olli 2024-06-04 15:16:04 +02:00
parent 35b7ba12c2
commit 0341ba683a

View File

@ -6,11 +6,13 @@ function transactions_overview {
get_justtrade_csv_transactions get_justtrade_csv_transactions
get_onetrading_csv_transactions get_onetrading_csv_transactions
#get_transactions get_transactions
>ALL_TRANSACTIONS_OVERVIEW.csv.tmp >ALL_TRANSACTIONS_OVERVIEW.csv.tmp
>ALL_TRANSACTIONS_OVERVIEW_WARN.csv.tmp
>TRANSACTIONS_OVERVIEW-trade-result_tax_german_eur.tmp
local f_exchange f_asset f_transactions_array f_transaction f_result f_asset_quantity f_asset_quantity_sold f_currency_quantity f_currency_quantity_sold f_currency_spent f_date f_type f_asset_amount f_currency f_currency_amount f_fee_currency f_fee_amount f_sell_result f_taxable f_tax_type f_one_year_ago f_currency_amount_eur f_currency_spent_eur f_currency_quantity_sold_eur local f_exchange f_asset f_transactions_array f_transaction f_result f_asset_quantity f_asset_quantity_sold f_currency_quantity f_currency_quantity_sold f_currency_spent f_date f_type f_asset_amount f_currency f_currency_amount f_fee_currency f_fee_amount f_sell_result f_taxable f_tax_type f_one_year_ago f_currency_amount_eur f_currency_spent_eur f_currency_quantity_sold_eur f_note f_asset_quantity_remaining f_currency_remaining f_year
f_assets_per_exchange=$(egrep -h -v '^DATE,TYPE,ASSET,ASSET_AMOUNT,CURRENCY,CURRENCY_AMOUNT,EXCHANGE|^#|^$|^ +$|^$' TRANSACTIONS-*.csv | cut -d, -f3,7 | sort -u) f_assets_per_exchange=$(egrep -h -v '^DATE,TYPE,ASSET,ASSET_AMOUNT,CURRENCY,CURRENCY_AMOUNT,EXCHANGE|^#|^$|^ +$|^$' TRANSACTIONS-*.csv | cut -d, -f3,7 | sort -u)
@ -20,7 +22,6 @@ function transactions_overview {
f_asset=${f_asset_per_exchange_array[0]} f_asset=${f_asset_per_exchange_array[0]}
f_exchange=${f_asset_per_exchange_array[1]%$'\n'} f_exchange=${f_asset_per_exchange_array[1]%$'\n'}
# Ignore stableCoins, EUR, USD # Ignore stableCoins, EUR, USD
[[ $f_asset = USDT ]] && continue [[ $f_asset = USDT ]] && continue
[[ $f_asset = USDC ]] && continue [[ $f_asset = USDC ]] && continue
@ -28,7 +29,8 @@ function transactions_overview {
[[ $f_asset = USD ]] && continue [[ $f_asset = USD ]] && continue
[[ $f_asset = EUR ]] && continue [[ $f_asset = EUR ]] && continue
echo -e "\n\n=== Asset $f_asset on Exchange $f_exchange" echo -e "\n\n=== Asset $f_asset on Exchange $f_exchange" >>ALL_TRANSACTIONS_OVERVIEW.log
g_echo_note "transactions_overview: Asset $f_asset on Exchange $f_exchange"
f_result=0 f_result=0
f_result_eur=0 f_result_eur=0
@ -37,6 +39,7 @@ function transactions_overview {
f_currency_quantity=0 f_currency_quantity=0
f_currency_quantity_sold=0 f_currency_quantity_sold=0
f_currency_quantity_sold_eur=0 f_currency_quantity_sold_eur=0
f_asset_quantity_remaining=0
f_currency_spent=0 f_currency_spent=0
f_currency_spent_eur=0 f_currency_spent_eur=0
@ -58,6 +61,7 @@ function transactions_overview {
f_taxable=0 f_taxable=0
f_tax_type="" f_tax_type=""
f_one_year_ago="" f_one_year_ago=""
f_note=""
# if there is a fee change to f_currency_amount and deduct f_currency_amount # if there is a fee change to f_currency_amount and deduct f_currency_amount
if [ -n "$f_fee_amount" ] if [ -n "$f_fee_amount" ]
@ -71,7 +75,8 @@ function transactions_overview {
f_fee_amount=$f_currency_converter_result f_fee_amount=$f_currency_converter_result
f_fee_currency=$f_currency f_fee_currency=$f_currency
else else
g_echo_warn "!!!!!! Could not convert currency $f_fee_currency to $f_currency" #g_echo_warn "!!!!!! Could not convert currency $f_fee_currency to $f_currency"
echo "$f_date,$f_exchange,$f_type,$f_asset,$f_asset_amount,$f_currency,$f_currency_amount,$f_one_year_ago,$f_currency_spent,$f_asset_quantity,$f_result,$f_sell_result,$f_tax_type,$f_taxable,$f_currency_amount_eur,$f_result_eur,$f_sell_result_eur,$f_asset_quantity_remaining,$f_note,Could not convert currency $f_fee_currency to $f_currency"
continue continue
fi fi
fi fi
@ -85,7 +90,7 @@ function transactions_overview {
g_calc "$f_currency_spent+($f_fee_amount)" g_calc "$f_currency_spent+($f_fee_amount)"
f_currency_spent=$g_calc_result f_currency_spent=$g_calc_result
f_currency_amount=$f_fee_amount f_currency_amount=$f_fee_amount
f_tax_type="Note: Included in purchase price" f_tax_type="Included in purchase price"
else else
g_calc "$f_currency_amount+($f_fee_amount)" g_calc "$f_currency_amount+($f_fee_amount)"
f_currency_amount=$g_calc_result f_currency_amount=$g_calc_result
@ -119,7 +124,7 @@ function transactions_overview {
[[ $f_type =~ stake ]] && continue [[ $f_type =~ stake ]] && continue
# what did I spent on asset in currency # what did I spent on asset in currency
if [[ $f_type =~ buy|leverage-buy ]] if [[ $f_type =~ buy|leverage-buy|reward-staking|instant_trade_bonus|giveaway ]]
then then
g_calc "$f_currency_spent+$f_currency_amount" g_calc "$f_currency_spent+$f_currency_amount"
f_currency_spent=$g_calc_result f_currency_spent=$g_calc_result
@ -133,6 +138,8 @@ function transactions_overview {
then then
g_calc "$f_asset_quantity+$f_asset_amount" g_calc "$f_asset_quantity+$f_asset_amount"
f_asset_quantity=$g_calc_result f_asset_quantity=$g_calc_result
g_calc "$f_asset_quantity_remaining+$f_asset_amount"
f_asset_quantity_remaining=$g_calc_result
fi fi
@ -181,13 +188,15 @@ function transactions_overview {
# if sell on never buyed!? # if sell on never buyed!?
if [ $f_currency_spent = 0 ] if [ $f_currency_spent = 0 ]
then then
g_echo_warn "!!!!!! Sell never buyed!? Spent currency on $f_asset is 0" #g_echo_warn "!!!!!! Sell never buyed!? Spent currency on $f_asset is 0"
echo "$f_date,$f_exchange,$f_type,$f_asset,$f_asset_amount,$f_currency,$f_currency_amount,$f_one_year_ago,$f_currency_spent,$f_asset_quantity,$f_result,$f_sell_result,$f_tax_type,$f_taxable,$f_currency_amount_eur,$f_result_eur,$f_sell_result_eur,$f_asset_quantity_remaining,$f_note,Sell never buyed!? Spent currency on $f_asset is 0"
continue continue
fi fi
# if sell wahats not exists!? # if sell wahats not exists!?
if [ $f_asset_quantity = 0 ] if [ $f_asset_quantity = 0 ]
then then
g_echo_warn "!!!!!! Sell never buyed!? Buyed asset $f_asset is 0" #g_echo_warn "!!!!!! Sell never buyed!? Buyed asset $f_asset is 0"
echo "$f_date,$f_exchange,$f_type,$f_asset,$f_asset_amount,$f_currency,$f_currency_amount,$f_one_year_ago,$f_currency_spent,$f_asset_quantity,$f_result,$f_sell_result,$f_tax_type,$f_taxable,$f_currency_amount_eur,$f_result_eur,$f_sell_result_eur,$f_asset_quantity_remaining,$f_note,Sell never buyed!? Buyed asset $f_asset is 0"
continue continue
fi fi
fi fi
@ -208,7 +217,7 @@ function transactions_overview {
g_calc "$f_currency_quantity_sold_eur+$f_currency_amount_eur" g_calc "$f_currency_quantity_sold_eur+$f_currency_amount_eur"
f_currency_quantity_sold_eur=$g_calc_result f_currency_quantity_sold_eur=$g_calc_result
## Check for ended trade (asset-quantity=0 or dust) ## Check for ended trade (asset-quantity=0 or tttt)
# if all is sold trade ended and calculate PNL # if all is sold trade ended and calculate PNL
local f_trade_end=0 local f_trade_end=0
local f_dust=0 local f_dust=0
@ -219,15 +228,16 @@ function transactions_overview {
# Alterntively check for remaining dust only to find end of trade and calculate PNL # Alterntively check for remaining dust only to find end of trade and calculate PNL
if [ ${g_calc_result} -eq 0 ] if [ ${g_calc_result} -eq 0 ]
then then
echo currency_converter $f_asset_quantity_remaining $f_asset $f_currency "${f_date}"
currency_converter $f_asset_quantity_remaining $f_asset $f_currency "${f_date}" currency_converter $f_asset_quantity_remaining $f_asset $f_currency "${f_date}"
local f_currency_remaining=$f_currency_converter_result f_currency_remaining=$f_currency_converter_result
if g_num_is_between $f_currency_remaining -5 5 if g_num_is_between $f_currency_remaining -5 5
then then
f_dust=$f_currency_remaining f_dust=$f_currency_remaining
currency_converter $f_asset_quantity_remaining $f_asset EUR "${f_date}" currency_converter $f_asset_quantity_remaining $f_asset EUR "${f_date}"
f_dust_eur=$f_currency_converter_result f_dust_eur=$f_currency_converter_result
g_echo_note "Quantity ($f_asset_quantity $f_asset - $f_dust (USD) looks like dust - Ending trade" g_echo_note "Quantity ($f_asset_quantity $f_asset - $f_dust (USD) looks like dust - Ending trade" >>ALL_TRANSACTIONS_OVERVIEW.log
f_note="$f_asset_quantity $f_asset - $f_dust (USD) looks like dust - Ending trade"
f_trade_end=1 f_trade_end=1
# add to sold quantity # add to sold quantity
@ -236,30 +246,36 @@ function transactions_overview {
# add to sold quantity EUR # add to sold quantity EUR
g_calc "$f_currency_quantity_sold_eur+($f_dust_eur)" g_calc "$f_currency_quantity_sold_eur+($f_dust_eur)"
f_currency_quantity_sold_eur=$g_calc_result f_currency_quantity_sold_eur=$g_calc_result
# correct positions
f_currency_amount=$f_currency_quantity_sold
f_currency_amount_eur=$f_currency_quantity_sold_eur
f_asset_amount=$f_asset_quantity
else else
g_echo_note "Tade not closed - partial sale!? Remaining $f_asset_quantity_remaining $f_asset ($f_currency_remaining $f_currency)!?" g_echo_note "Tade not closed - partial sale!? Remaining $f_asset_quantity_remaining $f_asset ($f_currency_remaining $f_currency)!?" >>ALL_TRANSACTIONS_OVERVIEW.log
f_tax_type="Note: Trade not closed - partial sale. Remaining $f_asset_quantity_remaining $f_asset ($f_currency_remaining $f_currency)" f_note="Trade not closed - partial sale. Remaining $f_asset_quantity_remaining $f_asset ($f_currency_remaining $f_currency)"
fi fi
fi fi
if [ ${f_trade_end} -eq 1 ] if [ ${f_trade_end} -eq 1 ]
then then
echo "Buy price: $f_currency_spent $f_currency ($f_currency_spent_eur EUR)" echo "Buy price: $f_currency_spent $f_currency ($f_currency_spent_eur EUR)" >>ALL_TRANSACTIONS_OVERVIEW.log
echo "Sell price: $f_currency_quantity_sold $f_currency ($f_currency_quantity_sold_eur EUR)" echo "Sell price: $f_currency_quantity_sold $f_currency ($f_currency_quantity_sold_eur EUR)" >>ALL_TRANSACTIONS_OVERVIEW.log
# calculate result of trade # calculate result of trade
g_calc "$f_currency_quantity_sold-$f_currency_spent" g_calc "$f_currency_quantity_sold-$f_currency_spent"
f_sell_result=$g_calc_result f_sell_result=$g_calc_result
g_calc "$f_currency_quantity_sold_eur-$f_currency_spent_eur" g_calc "$f_currency_quantity_sold_eur-$f_currency_spent_eur"
f_sell_result_eur=$g_calc_result f_sell_result_eur=$g_calc_result
echo "Sell result: $f_sell_result $f_currency ($f_sell_result_eur EUR)" echo "Sell result: $f_sell_result $f_currency ($f_sell_result_eur EUR)" >>ALL_TRANSACTIONS_OVERVIEW.log
g_percentage-diff $f_currency_spent $f_currency_quantity_sold g_percentage-diff $f_currency_spent $f_currency_quantity_sold
f_sell_result_percentage=$g_percentage_diff_result f_sell_result_percentage=$g_percentage_diff_result
g_percentage-diff $f_currency_spent_eur $f_currency_quantity_sold_eur g_percentage-diff $f_currency_spent_eur $f_currency_quantity_sold_eur
f_sell_result_percentage_eur=$g_percentage_diff_result f_sell_result_percentage_eur=$g_percentage_diff_result
echo "Sell result percentage: ${f_sell_result_percentage}% (EUR ${f_sell_result_percentage_eur}%)" echo "Sell result percentage: ${f_sell_result_percentage}% (EUR ${f_sell_result_percentage_eur}%)" >>ALL_TRANSACTIONS_OVERVIEW.log
# calculate complete result # calculate complete result
g_calc "$f_result+($f_sell_result)" g_calc "$f_result+($f_sell_result)"
@ -348,6 +364,7 @@ function transactions_overview {
f_tax_type="Verkauf (Einkommenssteuersatz)" f_tax_type="Verkauf (Einkommenssteuersatz)"
g_calc "$f_asset_amount_tax_able-$f_asset_amount" g_calc "$f_asset_amount_tax_able-$f_asset_amount"
f_asset_amount_tax_able=$g_calc_result f_asset_amount_tax_able=$g_calc_result
echo "$f_date,$f_exchange,$f_currency_spent_eur,$f_currency_quantity_sold_eur" >> "TRANSACTIONS_OVERVIEW-trade-result_tax_german_eur.tmp"
else else
## partially taxable ## partially taxable
f_one_year_ago="partially" f_one_year_ago="partially"
@ -366,39 +383,40 @@ function transactions_overview {
f_tax_type="Verkauf (Einkommenssteuersatz)" f_tax_type="Verkauf (Einkommenssteuersatz)"
g_calc "$f_asset_amount_tax_able-$f_taxable_asset" g_calc "$f_asset_amount_tax_able-$f_taxable_asset"
fi echo "$f_date,$f_exchange,$f_currency_spent_eur,$f_currency_quantity_sold_eur,$f_percentage_taxable" >> "TRANSACTIONS_OVERVIEW-trade-result_tax_german_eur.tmp"
fi
fi
fi
fi
fi
## Fields ## Fields
# 1 date # 1 date - f_date
# 2 exchange # 2 exchange - f_exchange
# 3 type # 3 type - f_type
# 4 krypto asset # 4 krypto asset - f_asset
# 5 krypto asset amount # 5 krypto asset amount - f_asset_amount
# 6 mutual currency # 6 mutual currency - f_currency
# 7 mutual currency amount # 7 mutual currency amount - f_currency_amount
# 8 tax 1 year ago yes/no/partially? # 8 tax 1 year ago yes/no/partially? - f_one_year_ago
# 9 totally mutal currency amount (spent money for trade) # 9 totally mutal currency amount (money for trade) spent - f_currency_spent
# 10 totally krypto asset amount (got krypto in trade) # 10 totally krypto asset amount (got krypto in trade) - f_asset_quantity
# 11 total result profit/loss for exchange/krypto asset # 11 total result profit/loss for exchange/krypto asset - f_result
# 12 total result of trade (from/until krypto asset amount is 0 again) # 12 total result of trade (from/until krypto asset amount is 0 again) - f_sell_result
# 13 type of tax if to pay # 13 type of tax if to pay - f_tax_type
# 14 taxable amount of trade # 14 taxable amount of trade - f_taxable
# 15 mutual currency amount in EUR # 15 mutual currency amount in EUR - f_currency_amount_eur
# 16 total result profit/loss for exchange/krypto asset calculated in EUR # 16 total result profit/loss for exchange/krypto asset calculated in EUR - f_result_eur
# 17 total result of trade (from/until krypto asset amount is 0 again) calculated in EUR # 17 total result of trade (from/until krypto asset amount is 0 again) calculated in EUR - f_sell_result_eur
# 18 remaining krypto asset amount # 18 remaining krypto asset amount - f_asset_quantity_remaining
echo "$f_date,$f_exchange,$f_type,$f_asset,$f_asset_amount,$f_currency,$f_currency_amount,$f_one_year_ago,$f_currency_spent,$f_asset_quantity,$f_result,$f_sell_result,$f_tax_type,$f_taxable,$f_currency_amount_eur,$f_result_eur,$f_sell_result_eur,$f_asset_quantity_remaining" | tee -a ALL_TRANSACTIONS_OVERVIEW.csv.tmp # 19 Optional Note - f_note
# 20 totally mutal currency amount (money for trade) spent in EUR - f_currency_spent_eur
#printf -v f_currency_amount_rounded %.2f $f_currency_amount # 21 totally mutal currency amount (money for trade) sold - f_currency_quantity_sold
#printf -v f_sell_result_rounded %.2f $f_sell_result # 22 totally mutal currency amount (money for trade) sold in EUR - f_currency_quantity_sold_eur
#printf -v f_taxable_rounded %.2f $f_taxable echo "$f_date,$f_exchange,$f_type,$f_asset,$f_asset_amount,$f_currency,$f_currency_amount,$f_one_year_ago,$f_currency_spent,$f_asset_quantity,$f_result,$f_sell_result,$f_tax_type,$f_taxable,$f_currency_amount_eur,$f_result_eur,$f_sell_result_eur,$f_asset_quantity_remaining,$f_note,$f_currency_spent_eur,$f_currency_quantity_sold,$f_currency_quantity_sold_eur" | tee -a ALL_TRANSACTIONS_OVERVIEW.csv.tmp >>ALL_TRANSACTIONS_OVERVIEW.log
if [[ $f_type =~ sell|leverage-sell ]] if [[ $f_type =~ sell|leverage-sell ]]
then then
echo -e "\n" echo -e "\n" >>ALL_TRANSACTIONS_OVERVIEW.log
fi fi
done done
@ -410,115 +428,21 @@ function transactions_overview {
f_tax_total=$(cat ALL_TRANSACTIONS_OVERVIEW.csv.tmp | egrep ",$f_exchange,.+,$f_asset," | cut -d, -f14 | awk "{ SUM += \$1} END { printf(\"%.10f\", SUM) }") f_tax_total=$(cat ALL_TRANSACTIONS_OVERVIEW.csv.tmp | egrep ",$f_exchange,.+,$f_asset," | cut -d, -f14 | awk "{ SUM += \$1} END { printf(\"%.10f\", SUM) }")
echo -e "\n $f_exchange $f_asset Results:" echo -e "\n $f_exchange $f_asset Results:" >>ALL_TRANSACTIONS_OVERVIEW.log
echo " Remaining $f_asset_quantity_remaining $f_asset" echo " Remaining $f_asset_quantity_remaining $f_asset" >>ALL_TRANSACTIONS_OVERVIEW.log
echo " Straking Rewards: $f_staking_rewards_asset $f_currency" echo " Straking Rewards: $f_staking_rewards_asset $f_currency" >>ALL_TRANSACTIONS_OVERVIEW.log
echo " Giveaways: $f_giveaway_asset $f_currency" echo " Giveaways: $f_giveaway_asset $f_currency" >>ALL_TRANSACTIONS_OVERVIEW.log
echo " Instand Trade Bonus: $f_instant_trade_bonus_asset $f_currency" echo " Instand Trade Bonus: $f_instant_trade_bonus_asset $f_currency" >>ALL_TRANSACTIONS_OVERVIEW.log
echo " Result: $f_result $f_currency ($f_result_eur EUR)" echo " Result: $f_result $f_currency ($f_result_eur EUR)" >>ALL_TRANSACTIONS_OVERVIEW.log
echo " German Tax: $f_tax_total EUR" echo " German Tax: $f_tax_total EUR" >>ALL_TRANSACTIONS_OVERVIEW.log
echo "======================================" echo "======================================" >>ALL_TRANSACTIONS_OVERVIEW.log
done done
mv ALL_TRANSACTIONS_OVERVIEW.csv.tmp ALL_TRANSACTIONS_OVERVIEW.csv mv ALL_TRANSACTIONS_OVERVIEW.csv.tmp ALL_TRANSACTIONS_OVERVIEW.csv
mv ALL_TRANSACTIONS_OVERVIEW_WARN.csv.tmp ALL_TRANSACTIONS_OVERVIEW_WARN.csv
mv TRANSACTIONS_OVERVIEW-trade-result_tax_german_eur.tmp TRANSACTIONS_OVERVIEW-trade-result_tax_german_eur.csv
} }
function transactions_summary {
# calculate totals from csv
local f_instant_trade_bonus=$(cat ALL_TRANSACTIONS_OVERVIEW.csv | grep ',instant_trade_bonus,' | cut -d, -f7 | awk "{ SUM += \$1} END { printf(\"%.2f\", SUM) }")
local f_staking_rewards=$(cat ALL_TRANSACTIONS_OVERVIEW.csv | grep ',reward-staking,' | cut -d, -f7 | awk "{ SUM += \$1} END { printf(\"%.2f\", SUM) }")
local f_giveaway=$(cat ALL_TRANSACTIONS_OVERVIEW.csv | grep ',giveaway,' | cut -d, -f7 | awk "{ SUM += \$1} END { printf(\"%.2f\", SUM) }")
echo -e "\n\n========== Total Results ==========="
#echo "Trade Result: $f_trade_result EUR"
echo "Staking Result: $f_staking_rewards EUR"
echo "Giveaway Result: $f_giveaway EUR"
echo -e "Instand Trade Bonus: $f_instant_trade_bonus EUR\n"
rm -f ${g_tmp}/tax_summary_*
# generate and go through list of years and Exchange/Tax-Types
local f_tax_year
cat ALL_TRANSACTIONS_OVERVIEW.csv | cut -d- -f1 | sort -u | while read f_tax_year
do
echo "========== Tax year $f_tax_year (German Tax Law) =========="
local f_exchange_tax_type
cat ALL_TRANSACTIONS_OVERVIEW.csv | grep "^$f_tax_year-" | cut -d, -f 2,13 | sort -u | egrep -v ',$' | grep -v "Note: " | while read f_exchange_tax_type
do
local f_exchange=$(echo $f_exchange_tax_type | cut -d, -f1)
local f_tax_type=$(echo $f_exchange_tax_type | cut -d, -f2)
local f_tax=$(cat ALL_TRANSACTIONS_OVERVIEW.csv | grep "^$f_tax_year-" | cut -d, -f 2,13,14 | egrep -v ',,0$' | grep "$f_exchange_tax_type" | cut -d, -f3 | awk "{ SUM += \$1} END { printf(\"%.2f\", SUM) }")
echo "$f_exchange_tax_type: $f_tax"
echo "$f_tax_type: $f_tax EUR<br>" >>${g_tmp}/tax_summary_$f_exchange-$f_tax_year
echo "<html>
<head>
<meta charset='UTF-8'>
<meta http-equiv='refresh' content='${INTERVAL}'>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<link rel='stylesheet' type='text/css' href='/browser.css'>
<link rel='stylesheet' type='text/css' href='/charts.min.css'>
<title>Detailed Transactions on $f_exchange from ${f_tax_year}</title>
</head>
<body>
<h1>Detailed Transactions on $f_exchange from ${f_tax_year}</h1>
<h2>Summary</h2>
$(cat ${g_tmp}/tax_summary_$f_exchange-$f_tax_year)
<h2>List of trades</h2>
- Fees included<br>
- EUR values were calculated using the exchange rate at the time of trading<br>
- Fiat rounded to two decimal places. Internally, further decimal places are used in the calculation<br>
<table>
<tr><td>Date</td><td>Type of transaction</td><td>Crypto value</td><td>Fiat value</td><td>Result</td><td>Tax type</td><td>Tax amount</td></tr>
" >TRANSACTIONS_OVERVIEW-${f_exchange}-${f_tax_year}.html.tmp
cat ALL_TRANSACTIONS_OVERVIEW.csv | grep "^${f_tax_year}-" | grep ",${f_exchange}," | awk -F, '
{printf "<tr><td>"$1"</td><td>"$3"</td><td>"$5" "$4"</td><td>"}
{printf("%.2f", $7)}
{printf " EUR </td><td>"}
{printf("%.2f", $16)}
{printf " EUR</td><td>"$13"</td><td>"}
{printf("%.2f", $14)}
{print " EUR</td></tr>"}' >>TRANSACTIONS_OVERVIEW-${f_exchange}-${f_tax_year}.html.tmp
echo "</table></body></html>" >>TRANSACTIONS_OVERVIEW-${f_exchange}-${f_tax_year}.html.tmp
mv TRANSACTIONS_OVERVIEW-${f_exchange}-${f_tax_year}.html.tmp ../TRANSACTIONS_OVERVIEW-${f_exchange}-${f_tax_year}.html
done
echo ""
done
## Overview over Overviews
echo "<html>
<head>
<meta charset='UTF-8'>
<meta http-equiv='refresh' content='${INTERVAL}'>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<link rel='stylesheet' type='text/css' href='/browser.css'>
<link rel='stylesheet' type='text/css' href='/charts.min.css'>
<title>Trading Overview</title>
</head>
<body>
<h1>Transaction Overviews</h1>" >../TRANSACTIONS_OVERVIEWS.html
local f_html f_name
ls ../TRANSACTIONS_OVERVIEW-* | while read f_html
do
f_html=$(basename $f_html)
f_name=$(echo $f_html | cut -d- -f2,3 | cut -d. -f1)
echo "<a href='${f_html}'>$f_name</a><br>" >>../TRANSACTIONS_OVERVIEWS.html
done
echo "</body></html>" >>../TRANSACTIONS_OVERVIEWS.htm
}