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; -*-
25 class OcupacaoForm(baseui.OptionsForm):
26 def __init__(self, ocupacoes, contribuinte):
27 g = ocupacoes.groups()
31 o = map(lambda x: (x[0], x[3]), l)
32 baseui.OptionsForm.__init__(self, u"Ocupações", o, contribuinte.get_campo_contribuinte("ocupacaoPrincipal"))
33 self.ocupacoes = ocupacoes
34 self.contribuinte = contribuinte
35 def set_value(self, value):
36 baseui.OptionsForm.set_value(self, value)
37 self.contribuinte.set_campo_contribuinte("ocupacaoPrincipal", value)
39 class ContribuinteForm(baseui.StringForm):
40 def __init__(self, name, attr, contribuinte):
41 self.contribuinte = contribuinte
43 baseui.StringForm.__init__(self, name, self.contribuinte.get_campo_contribuinte(self.attr))
44 def set_value(self, value):
45 baseui.StringForm.set_value(self, value)
46 self.contribuinte.set_campo_contribuinte(self.attr, value)
48 class AttrForm(baseui.StringForm):
49 def __init__(self, name, attr, element):
50 self.element = element
52 baseui.StringForm.__init__(self, name, self.element.get_attr(self.attr))
53 def set_value(self, value):
54 baseui.StringForm.set_value(self, value)
55 self.element.set_attr(self.attr, value)
57 def RendimentoPJ(UI, rend):
59 form.append(AttrForm("Nome", "nomeFontePagadora", rend))
60 form.append(AttrForm("CNPJ", "NIFontePagadora", rend))
61 form.append(AttrForm("Rendimentos", "rendRecebidoPJ", rend))
62 form.append(AttrForm(u"Previdência", "contribuicaoPrevOficial", rend))
63 form.append(AttrForm("Imposto Retido", "impostoRetidoFonte", rend))
64 form.append(AttrForm(u"Décimo Terceiro", "decimoTerceiro", rend))
68 def List(UI, L, Edit, display):
73 ls.append(i.get_attr(display))
78 Edit(UI, L.new_item())
80 Edit(UI, L.items[r[0] - 1])
81 elif r[1] == 'delete':
82 L.remove_item(r[0] - 1)
85 def RendimentosPJ(UI, contrib):
86 rend = rendimentoPJ.RendimentosPJ(contrib)
87 return List(UI, rend, RendimentoPJ, "nomeFontePagadora")
89 def DadosPessoais(UI, contrib):
91 ocup = ocupacoes.Ocupacoes()
92 form.append(ContribuinteForm("Nome", "nome", contrib))
93 form.append(OcupacaoForm(ocup, contrib))
94 for i in contribuinte.contribuinte_attributes:
95 form.append(ContribuinteForm(i, i, contrib))
99 def menu(UI, contrib):
100 m = [ "Sair", "Dados Pessoais", "Rendimentos PJ" ]
101 f = [ None, DadosPessoais, RendimentosPJ ]
114 cpf = UI.get_string("Digite seu CPF: ")
116 contrib = contribuinte.Contribuinte(cpf)
117 ret = menu(UI, contrib)
118 except RuntimeError, e:
121 if __name__ == '__main__':
124 # vim:tabstop=4:expandtab:smartindent