3 # Copyright 2013 Thadeu Lima de Souza Cascardo <cascardo@cascardo.info>
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 # -*- mode: python; encoding: utf-8; -*-
26 class OcupacaoForm(form.OptionsForm):
27 def __init__(self, ocupacoes, contribuinte):
28 g = ocupacoes.groups()
32 o = map(lambda x: (x[0], x[3]), l)
33 form.OptionsForm.__init__(self, u"Ocupações", o, contribuinte.get_campo_contribuinte("ocupacaoPrincipal"))
34 self.ocupacoes = ocupacoes
35 self.contribuinte = contribuinte
36 def set_value(self, value):
37 form.OptionsForm.set_value(self, value)
38 self.contribuinte.set_campo_contribuinte("ocupacaoPrincipal", value)
40 class ContribuinteForm(form.StringForm):
41 def __init__(self, name, attr, contribuinte):
42 self.contribuinte = contribuinte
44 form.StringForm.__init__(self, name, self.contribuinte.get_campo_contribuinte(self.attr))
45 def set_value(self, value):
46 form.StringForm.set_value(self, value)
47 self.contribuinte.set_campo_contribuinte(self.attr, value)
49 def List(UI, L, display):
54 d = i.get_attr(display)
62 UI.form(L.form(L.new_item()))
64 UI.form(L.form(L.items[r[0] - 1]))
65 elif r[1] == 'delete':
66 L.remove_item(r[0] - 1)
69 def RendimentosPJ(UI, contrib):
70 rend = rendimentoPJ.RendimentosPJ(contrib)
71 return List(UI, rend, "nomeFontePagadora")
73 def DadosPessoais(UI, contrib):
75 ocup = ocupacoes.Ocupacoes()
76 form.append(ContribuinteForm("Nome", "nome", contrib))
77 form.append(OcupacaoForm(ocup, contrib))
78 for i in contribuinte.contribuinte_attributes:
79 form.append(ContribuinteForm(i, i, contrib))
83 def Salvar(UI, contrib):
86 def menu(UI, contrib):
87 m = [ "Sair", "Salvar", "Dados Pessoais", "Rendimentos PJ" ]
88 f = [ None, Salvar, DadosPessoais, RendimentosPJ ]
101 cpf = UI.get_string("Digite seu CPF: ")
103 contrib = contribuinte.Contribuinte(cpf)
104 ret = menu(UI, contrib)
105 except RuntimeError, e:
108 if __name__ == '__main__':
111 # vim:tabstop=4:expandtab:smartindent