pardon, i forgot to include my code i'm done so far with the unexpected
result (no error occured)
code:
def __after_insert_redemption_detail(f, id):
query_unit = db.unit.account == f['account']
row_unit = db(query_unit).select(orderby = ~current.db.unit.id).first()
db.unit.insert(account = f['account'], unit = row_unit.unit - f['unit'] if
row_unit else f['unit'],
previous_unit = row_unit.unit if row_unit else 0,
nav_date = f['nav_date'], nav_per_unit = f['nav_per_unit'] )
# confuse with this part below
redemption_unit = f['unit']
rows_remaining_unit = db(query_unit & db.unit.remaining_unit >
0).select(orderby = ~current.db.unit.id)
single_row_remaining_unit = db(query_unit & db.unit.remaining_unit >
0).select(orderby = ~current.db.unit.id).first()
for row_remaining_unit in rows_remaining_unit:
if redemption_unit > 0:
if redemption_unit < row_remaining_unit.remaining_unit:
db(db.unit.id == single_row_remaining_unit.id).update(unit =
single_row_remaining_unit.unit,
previous_unit = single_row_remaining_unit.previous_unit,
#remaining_unit = db.unit(single_row_remaining_unit.id).remaining_unit -
redemption_unit,
remaining_unit = single_row_remaining_unit.duration_plan,
nav_date = str(single_row_remaining_unit.nav_date),
nav_per_unit = single_row_remaining_unit.nav_per_unit,
duration_plan = single_row_remaining_unit.duration_plan)
redemption_unit = 0
elif redemption_unit > row_remaining_unit.remaining_unit:
db(db.unit.id == single_row_remaining_unit.id).update(unit =
single_row_remaining_unit.unit,
previous_unit = single_row_remaining_unit.previous_unit,
#remaining_unit = db.unit(single_row_remaining_unit.id).remaining_unit -
single_row_remaining_unit.remaining_unit,
remaining_unit = 100,
nav_date = str(single_row_remaining_unit.nav_date),
nav_per_unit = single_row_remaining_unit.nav_per_unit,
duration_plan = single_row_remaining_unit.duration_plan)
redemption_unit = redemption_unit - single_row_remaining_unit.remaining_unit
db.redemption_detail._after_insert.append(__after_insert_redemption_detail)
any idea how to achieve it using web2py way?
thanks and 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.