webpage for transaction history and tax

This commit is contained in:
olli 2024-06-04 15:17:24 +02:00
parent 2417df2317
commit ecd6f3d7ff

View File

@ -0,0 +1,98 @@
function webpage_transactions {
# 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"
# generate and go through list of years and Exchange/Tax-Types
rm -f ${g_tmp}/tax_summary_*
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} - Created: $(date)</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", $15)}
{printf " EUR </td><td>"}
{printf("%.2f", $17)}
{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 "$(cat ALL_TRANSACTIONS_OVERVIEW_WARN.csv | cut -d, -f1,2,20)<br>" >>../TRANSACTIONS_OVERVIEWS.html
echo "</body></html>" >>../TRANSACTIONS_OVERVIEWS.html
}