Skip to content

Commit

Permalink
round profit in excel export to 2 decimals
Browse files Browse the repository at this point in the history
  • Loading branch information
martin committed Feb 27, 2021
1 parent 85ce92b commit c9af2e6
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions koalafolio/exp/profitExport.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,18 @@ def trans(text):
ws.append(
['', '', '', buy.date, buy.amount, buy.getPrice()[currency],
buy.value[currency], '', sell.date, sell.amount, sell.getPrice()[currency],
sell.value[currency], '', profit[currency], taxProfit])
sell.value[currency], '', round(profit[currency], 3), round(taxProfit, 3)])
else:
taxProfit = profit[currency]
ws.append(['', '', '', buy.date, buy.amount, buy.getPrice()[currency],
buy.value[currency], '', sell.date, sell.amount, sell.getPrice()[currency],
sell.value[currency], '', profit[currency], taxProfit])
sell.value[currency], '', round(profit[currency], 3), round(taxProfit, 3)])

profitSumRows.append(ws.max_row + 2)
profitSumColumns.append(15)
# ws['M' + str(profitSumRows[-1])] = 'Summe'
ws[profitSumColumn + str(profitSumRows[-1])] = '=SUM(' + profitSumColumn + str(
firstProfitRow) + ':' + profitSumColumn + str(profitSumRows[-1] - 2) + ')'
ws[profitSumColumn + str(profitSumRows[-1])] = '=ROUNDDOWN(SUM(' + profitSumColumn + str(
firstProfitRow) + ':' + profitSumColumn + str(profitSumRows[-1] - 2) + '),2)'

# set width of date columns
ws.column_dimensions['D'].width = 11
Expand Down Expand Up @@ -193,13 +193,13 @@ def trans(text):
for fee in coin.getFees():
# check date of sell
if fee.date.date() >= minDate and fee.date.date() <= maxDate:
ws.append(['', '', '', fee.date, fee.amount, '', fee.value[currency], ''])
ws.append(['', '', '', fee.date, fee.amount, '', round(fee.value[currency], 3), ''])

profitSumRows.append(ws.max_row + 2)
profitSumColumns.append(7)
# ws['M' + str(profitSumRows[-1])] = 'Summe'
ws[feeSumColumn + str(profitSumRows[-1])] = '=SUM(' + feeSumColumn + str(
firstProfitRow) + ':' + feeSumColumn + str(profitSumRows[-1] - 2) + ')'
ws[feeSumColumn + str(profitSumRows[-1])] = '=ROUNDDOWN(SUM(' + feeSumColumn + str(
firstProfitRow) + ':' + feeSumColumn + str(profitSumRows[-1] - 2) + '),2)'

# set width of date columns
ws.column_dimensions['D'].width = 11
Expand Down

0 comments on commit c9af2e6

Please sign in to comment.