diff --git a/dabo/functions/webpage_transactions.sh b/dabo/functions/webpage_transactions.sh new file mode 100644 index 0000000..c86d140 --- /dev/null +++ b/dabo/functions/webpage_transactions.sh @@ -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
" >>${g_tmp}/tax_summary_$f_exchange-$f_tax_year + + echo " + + + + + + + Detailed Transactions on $f_exchange from ${f_tax_year} - Created: $(date) + + +

Detailed Transactions on $f_exchange from ${f_tax_year}

+

Summary

+$(cat ${g_tmp}/tax_summary_$f_exchange-$f_tax_year) +

List of trades

+- Fees included
+- EUR values were calculated using the exchange rate at the time of trading
+- Fiat rounded to two decimal places. Internally, further decimal places are used in the calculation
+ + +" >TRANSACTIONS_OVERVIEW-${f_exchange}-${f_tax_year}.html.tmp + + cat ALL_TRANSACTIONS_OVERVIEW.csv | grep "^${f_tax_year}-" | grep ",${f_exchange}," | awk -F, ' +{printf ""}' >>TRANSACTIONS_OVERVIEW-${f_exchange}-${f_tax_year}.html.tmp + + echo "
DateType of transactionCrypto valueFiat valueResultTax typeTax amount
"$1""$3""$5" "$4""} +{printf("%.2f", $15)} +{printf " EUR "} +{printf("%.2f", $17)} +{printf " EUR"$13""} +{printf("%.2f", $14)} +{print " EUR
" >>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 " + + + + + + + Trading Overview + + +

Transaction Overviews

" >../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 "$f_name
" >>../TRANSACTIONS_OVERVIEWS.html + done + echo "$(cat ALL_TRANSACTIONS_OVERVIEW_WARN.csv | cut -d, -f1,2,20)
" >>../TRANSACTIONS_OVERVIEWS.html + + echo "" >>../TRANSACTIONS_OVERVIEWS.html + + +} +