Thanks a million.


On Wednesday, May 18, 2016 at 10:11:40 PM UTC-7, 黄祥 wrote:
>
> 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
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to