Rendimentos PJ: permite adicionar fonte pagadora
[cascardo/irpf-gui.git] / src / rendimentoPJ.py
index ddd3318..64d5844 100644 (file)
@@ -18,8 +18,11 @@ import xml.dom.minidom
 from contribuinte import Contribuinte
 
 class RendimentoPJ:
-    def __init__(self, el):
-        self.rendimento = el
+    def __init__(self, el = None):
+        if el == None:
+            self.rendimento = xml.dom.minidom.Element("item")
+        else:
+            self.rendimento = el
 
     def get_attr(self, attr):
         if attr in self.rendimento.attributes.keys():
@@ -27,7 +30,7 @@ class RendimentoPJ:
         return None
 
     def set_attr(self, attr, val):
-        self.rendimento.attributes[attr].nodeValue = val
+        self.rendimento.setAttribute(attr, val)
 
 class RendimentosPJ:
     def __init__(self, contribuinte):
@@ -53,6 +56,10 @@ class RendimentosPJ:
     def set_colecao(self, attr, val):
         self._set_attr(self.colecao, attr, val)
 
+    def add_item(self, item):
+        self.items.append(item)
+        self.colecao.appendChild(item.rendimento)
+
 if __name__ == '__main__':
     import sys