Separa declarações e contribuinte.
[cascardo/irpf-gui.git] / src / declaracoes.py
diff --git a/src/declaracoes.py b/src/declaracoes.py
new file mode 100644 (file)
index 0000000..170563f
--- /dev/null
@@ -0,0 +1,67 @@
+# coding=utf-8
+#
+#   Copyright 2013-2014 Thadeu Lima de Souza Cascardo <cascardo@cascardo.info>
+#
+#   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 <http://www.gnu.org/licenses/>.
+# -*- mode: python; encoding: utf-8; -*-
+
+import xml.dom.minidom
+import dirs
+import os
+import items
+
+class Declaracoes(items.Items):
+    def __init__(self):
+        irpf_dir = dirs.get_default_irpf_dir()
+
+        if not os.path.exists(irpf_dir.get_resource_dir()):
+            raise RuntimeError("O caminho para o resource não existe: " + \
+                    irpf_dir.get_resource_dir())
+
+        if not os.path.exists(irpf_dir.get_userdata_dir()):
+            raise RuntimeError("O caminho para os dados não existe: " + \
+                    irpf_dir.get_userdata_dir())
+
+        self.iddecl_file = irpf_dir.get_userdata_file("iddeclaracoes.xml")
+        self.declaracoes = xml.dom.minidom.parse(self.iddecl_file)
+        classe = self.declaracoes.getElementsByTagName("classe")[0]
+        items.Items.__init__(self, classe)
+
+    def save(self):
+        self.declaracoes.writexml(open(self.iddecl_file, "w"))
+
+    attributes = [
+            "dataUltimoAcesso",
+            "declaracaoRetificadora",
+            "enderecoDiferente",
+            "enderecoMACRede",
+            "exercicio",
+            "nome",
+            "numReciboDecRetif",
+            "numeroReciboDecAnterior",
+            "resultadoDeclaracao",
+            "tipoDeclaracao",
+            "tipoDeclaracaoAES",
+            "transmitida",
+            "versaoBeta"
+            ]
+
+if __name__ == '__main__':
+    import sys
+    dec = Declaracoes()
+
+    for i in dec.items:
+        print i.get_attr("cpf") + " " + i.get_attr("nome")
+
+# vim:tabstop=4:expandtab:smartindent