From 0827d2d304a7e4f5f0b46cb4a4fd8a5e28e3b61a Mon Sep 17 00:00:00 2001 From: Thadeu Lima de Souza Cascardo Date: Sat, 1 Aug 2015 11:55:43 -0300 Subject: [PATCH] =?utf8?q?Utiliza=20dicion=C3=A1rio=20de=20totais=20no=20l?= =?utf8?q?ugar=20de=20totalrendimento.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 | 13 +++---------- declaracao.c | 1 - declaracao.h | 1 - gera.c | 6 +++--- rendimento.c | 3 ++- 5 files changed, 8 insertions(+), 16 deletions(-) diff --git a/calcula.c b/calcula.c index d5daf76..44a3bf9 100644 --- a/calcula.c +++ b/calcula.c @@ -24,11 +24,6 @@ #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); diff --git a/declaracao.c b/declaracao.c index 3d58380..d52be42 100644 --- a/declaracao.c +++ b/declaracao.c @@ -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; diff --git a/declaracao.h b/declaracao.h index dab52ae..a5cb0b7 100644 --- a/declaracao.h +++ b/declaracao.h @@ -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 --- 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 */ diff --git a/rendimento.c b/rendimento.c index c3b2025..3a3de23 100644 --- a/rendimento.c +++ b/rendimento.c @@ -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; -- 2.20.1