just do like usual in controller
e.g.
controllers/default.py
def report_investor():
choose_investor = request.args(0)
# query
query_account = (db.account.investor == choose_investor)
# row
rows_account = db(query_account).select(orderby = ~
db.account.id)
return dict(rows_account = rows_account)
views/default/report_investor.html
<table class = 'detail'>
<tbody>
<th class = 'border'>
{{=SPAN(T('P/L') ) }}
<br />
{{=SPAN(T('P/L (%)') ) }}
</th>
<th class = 'border'>
{{=SPAN(T('Net P/L') ) }}
<br />
{{=SPAN(T('Net P/L (%)') ) }}
</th>
</tr>
{{for row_account in rows_account:}}
<tr>
{{
profit_loss_value = row_account.balance - row_account.subscription_amount
profit_loss_percentage = (profit_loss_value / row_account.subscription_amount) * 100 if row_account.subscription_amount > 0 else 0
}}
<td class="text-right border">
{{=SPAN('%s %s' % (row_account.product.currency.symbol, locale.format("%.2f", profit_loss_value, grouping = True) ), _class = 'red' if profit_loss_value <= 0 else 'green') }}
<br />
{{=SPAN('%s %%' % (locale.format("%.2f", profit_loss_percentage, grouping = True) ), _class = 'red' if profit_loss_percentage <= 0 else 'green') }}
</td>
{{
net_subscription = row_account.subscription_amount + row_account.subscription_fee + row_account.redemption_fee
net_profit_loss_value = row_account.balance - net_subscription
net_profit_loss_percentage = (net_profit_loss_value / net_subscription) * 100 if net_subscription > 0 else 0
}}
<td class="text-right border">
{{=SPAN('%s %s' % (row_account.product.currency.symbol, locale.format("%.2f", net_profit_loss_value, grouping = True) ), _class = 'red' if net_profit_loss_value <= 0 else 'green') }}
<br />
{{=SPAN('%s %%' % (locale.format("%.2f", net_profit_loss_percentage, grouping = True) ), _class = 'red' if net_profit_loss_percentage <= 0 else 'green') }}
</td>
</tr>
{{pass}}
</tbody>
</table>
best regards,
stifan