From 8ad130ba92d8d4039ff6efc5eb0c113ebb56ef68 Mon Sep 17 00:00:00 2001 From: Thadeu Lima de Souza Cascardo Date: Mon, 13 May 2013 08:40:42 -0300 Subject: [PATCH] Rendimentos PJ: suporte inicial MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Lê fontes de rendimentos tributáveis de PJ. Mais campos precisam ser suportados, e suporte a escrita é necessário. --- src/rendimentoPJ.py | 67 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 src/rendimentoPJ.py diff --git a/src/rendimentoPJ.py b/src/rendimentoPJ.py new file mode 100644 index 0000000..ddd3318 --- /dev/null +++ b/src/rendimentoPJ.py @@ -0,0 +1,67 @@ +# +# Copyright 2013 Thadeu Lima de Souza Cascardo +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# -*- mode: python; encoding: utf-8; -*- +import xml.dom.minidom +from contribuinte import Contribuinte + +class RendimentoPJ: + def __init__(self, el): + self.rendimento = el + + def get_attr(self, attr): + if attr in self.rendimento.attributes.keys(): + return self.rendimento.attributes[attr].nodeValue + return None + + def set_attr(self, attr, val): + self.rendimento.attributes[attr].nodeValue = val + +class RendimentosPJ: + def __init__(self, contribuinte): + self.contribuinte = contribuinte + self.rend_PJ = self.contribuinte.dados.getElementsByTagName("rendPJ")[0] + self.colecao = self.rend_PJ.getElementsByTagName("colecaoRendPJTitular")[0] + self.items = [] + + for i in self.colecao.getElementsByTagName("item"): + self.items.append(RendimentoPJ(i)) + + def _get_attr(self, el, attr): + if attr in el.attributes.keys(): + return el.attributes[attr].nodeValue + return None + + def _set_attr(self, el, attr, val): + el.attributes[attr].nodeValue = val + + def get_colecao(self, attr): + return self._get_attr(self.colecao, attr) + + def set_colecao(self, attr, val): + self._set_attr(self.colecao, attr, val) + +if __name__ == '__main__': + import sys + + contribuinte = Contribuinte(sys.argv[1]) + rendimentos = RendimentosPJ(contribuinte) + print "maior fonte pagadora: " + rendimentos.get_colecao("niMaiorFontePagadora") + print "total rendimentos: " + rendimentos.get_colecao("totaisRendRecebidoPJ") + + for i in rendimentos.items: + print i.get_attr("nomeFontePagadora") + " " + i.get_attr("rendRecebidoPJ") + +# vim:tabstop=4:expandtab:smartindent -- 2.20.1