from ._builtin import Page, WaitPage from otree.api import Currency as c, currency_range from .models import Constants class PaymentInfo(Page): def vars_for_template(self): participant = self.participant config = self.session.config points = float(participant.payoff) rate = float(config['real_world_currency_per_point']) fee = float(config['participation_fee']) earnings_dollars = round(points * rate, 2) total_dollars = round(earnings_dollars + fee, 2) return dict( redemption_code=participant.label or participant.code, rate_display='${:g}'.format(rate), earnings_dollars='${:,.2f}'.format(earnings_dollars), participation_fee='${:,.2f}'.format(fee), total_payment='${:,.2f}'.format(total_dollars), ) page_sequence = [PaymentInfo]