Utiliza dicionário de totais no lugar de totalrendimento.
authorThadeu Lima de Souza Cascardo <cascardo@cascardo.eti.br>
Sat, 1 Aug 2015 14:55:43 +0000 (11:55 -0300)
committerThadeu Lima de Souza Cascardo <cascardo@cascardo.eti.br>
Sat, 1 Aug 2015 14:55:43 +0000 (11:55 -0300)
Elimina o membro totalrendimento da declaração e utiliza o total RENDPJ
em seu lugar. No futuro, outros valores serão tributáveis, e outro total
deve ser utilizado.

calcula.c
declaracao.c
declaracao.h
gera.c
rendimento.c

index d5daf76..44a3bf9 100644 (file)
--- a/calcula.c
+++ b/calcula.c
 #include "rendimento.h"
 #include "totais.h"
 
-static void total_rendimento(struct declaracao *dec)
-{
-       dec->totalrendimento = totais_get(dec, "RENDPJTIT");
-}
-
 static long long total_deducao(struct declaracao *dec)
 {
        long long td = 0;
@@ -83,8 +78,7 @@ static long long imposto_simples(struct declaracao *dec)
        struct taxtable *tt;
        long long tr, td;
        tt = table2015;
-       tr = dec->totalrendimento;
-       dec->totalrendimento = tr;
+       tr = totais_get(dec, "RENDPJ");
        if (tr / 5 < simples2015)
                td = tr / 5;
        else
@@ -101,7 +95,7 @@ static long long imposto_completa(struct declaracao *dec)
                return -EINVAL;
        }
        tt = table2015;
-       tr = dec->totalrendimento;
+       tr = totais_get(dec, "RENDPJ");
        td = total_deducao(dec);
        tr -= td;
        return imposto(tt, tr);
@@ -113,8 +107,7 @@ int calcula(struct declaracao *dec)
        if (dec->ano != 2015) {
                return -EINVAL;
        }
-       total_rendimento(dec);
-       if (dec->totalrendimento > obrigatoriedade2015)
+       if (totais_get(dec, "RENDPJ") > obrigatoriedade2015)
                dec->obrigatoria = 1;
        i_simples = imposto_simples(dec);
        i_completa = imposto_completa(dec);
index 3d58380..d52be42 100644 (file)
@@ -36,7 +36,6 @@ struct declaracao * declaracao_new(int ano)
        dec->totais = pmhash_new();
        if (!dec->totais)
                goto out_totais;
-       dec->totalrendimento = 0;
        dec->pago = 0;
        dec->devido = 0;
        dec->restituicao = 0;
index dab52ae..a5cb0b7 100644 (file)
@@ -33,7 +33,6 @@ struct declaracao {
        char *nome;
        struct list *rendimento;
        struct contribuinte contribuinte;
-       long long totalrendimento;
        long long pago;
        long long retido;
        long long devido;
diff --git a/gera.c b/gera.c
index f77c22b..5e78bc8 100644 (file)
--- a/gera.c
+++ b/gera.c
@@ -107,7 +107,7 @@ static void gera_header(struct declaracao *dec, FILE *f)
        fprintf(f, "%08d", 0); /* Data saída */
        fprintf(f, "%-11.11s", ""); /* CPF procurador */
        fprintf(f, "000"); /* TODO: criterio obrigatoriedade */
-       fprintf(f, "%013lld", dec->totalrendimento); /* Total tributavel */
+       fprintf(f, "%013lld", totais_get(dec, "RENDPJ")); /* Total tributavel */
        fprintf(f, "%-14.14s", ""); /* TODO: CNPJ previdencia */
        fprintf(f, "%-14.14s", ""); /* TODO: CNPJ previdencia 2 */
        fprintf(f, "%013lld", 0); /* TODO: Total isentos */
@@ -229,7 +229,7 @@ static void gera_totais_simples(struct declaracao *dec, FILE *f)
 {
        fprintf(f, "18");
        fprintf(f, "%s", dec->cpf); /* CPF: 11 dígitos */
-       fprintf(f, "%013lld", dec->totalrendimento); /* TODO: rendimentos tributáveis */
+       fprintf(f, "%013lld", totais_get(dec, "RENDPJ")); /* TODO: rendimentos tributáveis */
        fprintf(f, "%013lld", 0); /* TODO: desconto simplificado */
        fprintf(f, "%013lld", 0); /* TODO: base cálculo */
        fprintf(f, "%013lld", dec->devido); /* imposto devido */
@@ -354,7 +354,7 @@ static void gera_recibodetalhe(struct declaracao *dec, FILE *f)
        fprintf(f, "%-4.4s", dec->contribuinte.ddd);
        fprintf(f, "%-9.9s", dec->contribuinte.telefone);
        fprintf(f, "%s", dec->retifica ? "S" : "N"); /* Retificadora */
-       fprintf(f, "%013lld", dec->totalrendimento); /* Total tributavel */
+       fprintf(f, "%013lld", totais_get(dec, "RENDPJ")); /* Total tributavel */
        fprintf(f, "%013lld", dec->devido); /* Imposto devido */
        fprintf(f, "%013lld", dec->restituicao); /* Imposto a restituir */
        fprintf(f, "%013lld", dec->pagar); /* Imposto a pagar */
index c3b2025..3a3de23 100644 (file)
@@ -91,7 +91,8 @@ static int run_rendimento(struct declaracao *dec, char **args, int argc)
                rendimento_free(rendimento);
                return r;
        }
-       r = totais_add(dec, "RENDPJTIT", rendimento->rendimento);
+       r = totais_add(dec, "RENDPJ", rendimento->rendimento);
+       r += totais_add(dec, "RENDPJTIT", rendimento->rendimento);
        if (r) {
                rendimento_free(rendimento);
                return r;