from otree.api import * c = cu doc = 'Declaracion del Impuesto, control y grupos tratados' class C(BaseConstants): # built-in constants NAME_IN_URL = 'Tercera_Ronda' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 # user-defined constants TASA_TX = 0.2 TASA_TX2 = 0.4 TASA1 = '20%' TASA2 = '40%' SANCION = 0.15 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): Income3 = models.IntegerField(label='¿Cuál fue el su ingreso a declarar?') class Salud_Ronda3(Page): form_model = 'player' form_fields = ['Income3'] @staticmethod def is_displayed(player: Player): participant = player.participant return participant.random==1 @staticmethod def error_message(player: Player, values): participant = player.participant if values['Income3'] > participant.task_payment3: return "El Ingreso Declarado NO puede ser mayor al Ingreso Ganado" class Defensa_Ronda3(Page): form_model = 'player' form_fields = ['Income3'] @staticmethod def is_displayed(player: Player): participant = player.participant return participant.random==2 @staticmethod def error_message(player: Player, values): participant = player.participant if values['Income3'] > participant.task_payment3: return "El Ingreso Declarado NO puede ser mayor al Ingreso Ganado" class Resultados3(Page): form_model = 'player' @staticmethod def vars_for_template(player: Player): return dict( tx_3= int(player.Income3 * C.TASA_TX2) ) @staticmethod def before_next_page(player: Player, timeout_happened): participant = player.participant participant.Income_declarado3= player.Income3 participant.CTX2= C.TASA_TX2 participant.TX3= (player.Income3 * C.TASA_TX2) participant.subdeclara_r3=participant.task_payment3-player.Income3 if participant.prob_audit == 9: participant.sancion_r3 = int(1.5*0.4 * participant.subdeclara_r3) else: participant.sancion_r3 = 0 class Auditoria3(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): participant = player.participant return participant.prob_audit==9 @staticmethod def vars_for_template(player: Player): participant = player.participant return dict( sancion_r3= int(1.5* C.TASA_TX2 * participant.subdeclara_r3) ) @staticmethod def before_next_page(player: Player, timeout_happened): pass class No_Auditoria3(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): participant = player.participant return participant.prob_audit!=9 page_sequence = [Salud_Ronda3, Defensa_Ronda3, Resultados3, Auditoria3, No_Auditoria3]