Gera outros totais de declaração simplificada.
[cascardo/declara.git] / declaracao.c
index d52be42..53ff1e4 100644 (file)
@@ -21,6 +21,8 @@
 #include <string.h>
 #include "list.h"
 #include "rendimento.h"
+#include "pagamento.h"
+#include "pmhash.h"
 
 struct declaracao * declaracao_new(int ano)
 {
@@ -33,6 +35,9 @@ struct declaracao * declaracao_new(int ano)
        dec->rendimento = list_new();
        if (!dec->rendimento)
                goto out_rendimento;
+       dec->pagamentos = list_new();
+       if (!dec->pagamentos)
+               goto out_pagamentos;
        dec->totais = pmhash_new();
        if (!dec->totais)
                goto out_totais;
@@ -42,6 +47,8 @@ struct declaracao * declaracao_new(int ano)
        dec->tipo = SIMPLES;
        return dec;
 out_totais:
+       list_free(dec->pagamentos, pagamento_free);
+out_pagamentos:
        list_free(dec->rendimento, rendimento_free);
 out_rendimento:
        free(dec);
@@ -56,7 +63,7 @@ void declaracao_free(struct declaracao *dec)
                free(dec->nome);
        if (dec->recibo)
                free(dec->recibo);
-       if (dec->retifica);
+       if (dec->retifica)
                free(dec->retifica);
        if (dec->banco)
                free(dec->banco);
@@ -67,6 +74,7 @@ void declaracao_free(struct declaracao *dec)
        if (dec->dvconta)
                free(dec->dvconta);
        list_free(dec->rendimento, rendimento_free);
+       list_free(dec->pagamentos, pagamento_free);
        pmhash_del(dec->totais);
        free(dec);
 }