1 # -*- mode: python; encoding: utf-8; -*-
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/>.
24 class OcupacaoForm(baseui.OptionsForm):
25 def __init__(self, ocupacoes, contribuinte):
26 g = ocupacoes.groups()
30 o = map(lambda x: (x[0], x[3]), l)
31 baseui.OptionsForm.__init__(self, u"Ocupações", o, contribuinte.get_campo_contribuinte("ocupacaoPrincipal"))
32 self.ocupacoes = ocupacoes
33 self.contribuinte = contribuinte
34 def set_value(self, value):
35 baseui.OptionsForm.set_value(self, value)
36 self.contribuinte.set_campo_contribuinte("ocupacaoPrincipal", value)
38 class ContribuinteForm(baseui.StringForm):
39 def __init__(self, name, attr, contribuinte):
40 self.contribuinte = contribuinte
42 baseui.StringForm.__init__(self, name, self.contribuinte.get_campo_contribuinte(self.attr))
43 def set_value(self, value):
44 baseui.StringForm.set_value(self, value)
45 self.contribuinte.set_campo_contribuinte(self.attr, value)
47 class AttrForm(baseui.StringForm):
48 def __init__(self, name, attr, element):
49 self.element = element
51 baseui.StringForm.__init__(self, name, self.element.get_attr(self.attr))
52 def set_value(self, value):
53 baseui.StringForm.set_value(self, value)
54 self.element.set_attr(self.attr, value)
56 def RendimentoPJ(UI, rend):
58 form.append(AttrForm("Nome", "nomeFontePagadora", rend))
59 form.append(AttrForm("CNPJ", "NIFontePagadora", rend))
60 form.append(AttrForm("Rendimentos", "rendRecebidoPJ", rend))
61 form.append(AttrForm(u"Previdência", "contribuicaoPrevOficial", rend))
62 form.append(AttrForm("Imposto Retido", "impostoRetidoFonte", rend))
63 form.append(AttrForm(u"Décimo Terceiro", "decimoTerceiro", rend))
67 def List(UI, L, Edit, display):
72 ls.append(i.get_attr(display))
77 Edit(UI, L.new_item())
79 Edit(UI, L.items[r[0] - 1])
80 elif r[1] == 'delete':
81 L.remove_item(r[0] - 1)
84 def RendimentosPJ(UI, contrib):
85 rend = rendimentoPJ.RendimentosPJ(contrib)
86 return List(UI, rend, RendimentoPJ, "nomeFontePagadora")
88 def DadosPessoais(UI, contrib):
90 ocup = ocupacoes.Ocupacoes()
91 form.append(ContribuinteForm("Nome", "nome", contrib))
92 form.append(OcupacaoForm(ocup, contrib))
93 for i in contribuinte.contribuinte_attributes:
94 form.append(ContribuinteForm(i, i, contrib))
98 def menu(UI, contrib):
99 m = [ "Sair", "Dados Pessoais", "Rendimentos PJ" ]
100 f = [ None, DadosPessoais, RendimentosPJ ]
113 cpf = UI.get_string("Digite seu CPF: ")
115 contrib = contribuinte.Contribuinte(cpf)
116 ret = menu(UI, contrib)
117 except RuntimeError, e:
120 if __name__ == '__main__':
123 # vim:tabstop=4:expandtab:smartindent