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 from form import AttrForm
27 class OcupacaoForm(form.OptionsForm):
28 def __init__(self, ocupacoes, contribuinte):
29 g = ocupacoes.groups()
33 o = map(lambda x: (x[0], x[3]), l)
34 form.OptionsForm.__init__(self, u"Ocupações", o, contribuinte.get_campo_contribuinte("ocupacaoPrincipal"))
35 self.ocupacoes = ocupacoes
36 self.contribuinte = contribuinte
37 def set_value(self, value):
38 form.OptionsForm.set_value(self, value)
39 self.contribuinte.set_campo_contribuinte("ocupacaoPrincipal", value)
41 class ContribuinteForm(form.StringForm):
42 def __init__(self, name, attr, contribuinte):
43 self.contribuinte = contribuinte
45 form.StringForm.__init__(self, name, self.contribuinte.get_campo_contribuinte(self.attr))
46 def set_value(self, value):
47 form.StringForm.set_value(self, value)
48 self.contribuinte.set_campo_contribuinte(self.attr, value)
50 def RendimentoPJ(UI, rend):
52 form.append(AttrForm("Nome", "nomeFontePagadora", rend))
53 form.append(AttrForm("CNPJ", "NIFontePagadora", rend))
54 form.append(AttrForm("Rendimentos", "rendRecebidoPJ", rend))
55 form.append(AttrForm(u"Previdência", "contribuicaoPrevOficial", rend))
56 form.append(AttrForm("Imposto Retido", "impostoRetidoFonte", rend))
57 form.append(AttrForm(u"Décimo Terceiro", "decimoTerceiro", rend))
61 def List(UI, L, Edit, display):
66 ls.append(i.get_attr(display))
71 Edit(UI, L.new_item())
73 Edit(UI, L.items[r[0] - 1])
74 elif r[1] == 'delete':
75 L.remove_item(r[0] - 1)
78 def RendimentosPJ(UI, contrib):
79 rend = rendimentoPJ.RendimentosPJ(contrib)
80 return List(UI, rend, RendimentoPJ, "nomeFontePagadora")
82 def DadosPessoais(UI, contrib):
84 ocup = ocupacoes.Ocupacoes()
85 form.append(ContribuinteForm("Nome", "nome", contrib))
86 form.append(OcupacaoForm(ocup, contrib))
87 for i in contribuinte.contribuinte_attributes:
88 form.append(ContribuinteForm(i, i, contrib))
92 def Salvar(UI, contrib):
95 def menu(UI, contrib):
96 m = [ "Sair", "Salvar", "Dados Pessoais", "Rendimentos PJ" ]
97 f = [ None, Salvar, DadosPessoais, RendimentosPJ ]
110 cpf = UI.get_string("Digite seu CPF: ")
112 contrib = contribuinte.Contribuinte(cpf)
113 ret = menu(UI, contrib)
114 except RuntimeError, e:
117 if __name__ == '__main__':
120 # vim:tabstop=4:expandtab:smartindent