for anthony's post, i think you can see it in the web2py google groups. he 
explain detail about this. for your another question, this is my full code 
of the cutted code above that work.
*modules/transaction.py*
def callback_0(session_order):
id = int(current.request.vars.id)
if current.request.vars.action == 'remove':
del session_order[id]
total_debit = 0
total_credit = 0
for calculation_id, (calculation_debit, calculation_credit) in 
session_order.items():
total_debit += calculation_debit
total_credit += calculation_credit
if int(total_debit) == int(total_credit):
status = 'Balance'
value = 'text-success'
else:
status = 'Unbalance'
value = 'text-danger'
target_response = "jQuery('#total_debit').html('%s'); 
jQuery('#total_credit').html('%s'); jQuery('#status').html('%s'); 
jQuery('#status').removeClass().addClass('%s');" % (format(total_debit, 
",d").replace(",", "."), 
  format(total_credit, ",d").replace(",", "."), status, value)
current.response.js =  target_response
if current.request.vars.action == 'adjust_total':
debit = int(current.request.vars['debit_%s' % id])
credit = int(current.request.vars['credit_%s' % id])
session_order[id] = debit, credit
total_debit = 0
total_credit = 0
for calculation_id, (calculation_debit, calculation_credit) in 
session_order.items():
total_debit += calculation_debit
total_credit += calculation_credit
if int(total_debit) == int(total_credit):
status = 'Balance'
value = 'text-success'
else:
status = 'Unbalance'
value = 'text-danger'
return "jQuery('#total_debit').html('%s'); 
jQuery('#total_credit').html('%s'); jQuery('#status').html('%s'); 
jQuery('#status').removeClass().addClass('%s');" % (format(total_debit, 
",d").replace(",", "."), 
   format(total_credit, ",d").replace(",", "."), status, value)

*views/transaction/templates/checkout_0.html*
{{total_debit = 0 }}
{{total_credit = 0 }}

<table class = "table table-condensed table-hover">
    <tr>
        <th>{{=T('Chart of Account') }}</th>
        <th>{{=T('Debit') }}</th>
        <th>{{=T('Credit') }}</th>
        <th>{{=T('Action') }}</td>
    </tr>
{{for id, (debit, credit) in session_detail.items():}}
{{chart_of_account = db.chart_of_account(id) }}
{{total_debit += debit}}
{{total_credit += credit}}
    <tr>
        <td>
{{=SPAN(chart_of_account.name) }}
</td>
        <td>
<form>
<input name="{{='debit_%s' % id}}" value="{{=debit}}" 
onkeyup="ajax('{{=URL(link_callback, vars = dict(id = id, 
action = 'adjust_total') ) }}', 
['{{='debit_%s' % id}}', '{{='credit_%s' % id}}'], ':eval' )" />
</form>
</td>
<td>
<form>
<input name="{{='credit_%s' % id}}" value="{{=credit}}" 
onkeyup="ajax('{{=URL(link_callback, vars = dict(id = id, 
action = 'adjust_total') ) }}', 
['{{='debit_%s' % id}}', '{{='credit_%s' % id}}'], ':eval' )" />
</form>
</td>
        <td>
{{=SPAN(A(I(_class = 'glyphicon glyphicon-remove-sign'), callback = 
URL(link_callback, 
vars = dict(id = id, action = 'remove') ), delete = 'tr', 
_title = 'Remove %s' % chart_of_account.name) ) }}
</td>
    </tr>
{{pass}}
    <tr>
        <td>{{=B(T('Grand Total') ) }}</td>
<td>Rp. {{=SPAN('%s' % format(total_debit, ",d").replace(",", "."), _id = 
'total_debit') }}</td>
<td>Rp. {{=SPAN('%s' % format(total_credit, ",d").replace(",", "."), _id = 
'total_credit') }}</td>
{{if total_debit == total_credit:}}
{{status = "Balance" }}
{{value = "text-success" }}
<td>{{=SPAN(status, _id = 'status', _class = value) }}</td>
{{else:}}
{{status = "Unbalance" }}
{{value = "text-danger" }}
<td>{{=SPAN(status, _id = 'status', _class = value) }}</td>
{{pass}}
    </tr>
</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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to