O total de deduções por dependentes está presente na linha de totais.
Implementa uma função para obter o limite da dedução anual por
dependente e totaliza em um total DEPENDENTES.
#include "declaracao.h"
#include "cmd.h"
#include "rendimento.h"
-#include "dependente.h"
#include "totais.h"
static const long long dependente2015 = 215652;
+long long deducao_dependente(struct declaracao *dec)
+{
+ if (dec->ano == 2015)
+ return dependente2015;
+ return 0;
+}
+
/* Alguns totais precisam ser limitados. Portanto, um total de decuções
* precisa ser ajustado para tais limites. Esta função considerará tais
* limites no futuro. */
static long long total_deducao(struct declaracao *dec)
{
int i;
- long long dependentes = 0;
- struct dependente *dependente;
- for (i = 0; (dependente = list_get(dec->dependentes, i)); i++) {
- dependentes += dependente2015;
- }
- return dependentes +
+ return totais_get(dec, "DEPENDENTES") +
totais_get(dec, "INSS") +
totais_get(dec, "PAGAMENTOS");
}
#ifndef _CALCULA_H
#define _CALCULA_H
+#include "declaracao.h"
+
int calcula_cmd_init(void);
+long long deducao_dependente(struct declaracao *dec);
+
#endif
#include "cmd.h"
#include "list.h"
#include "util.h"
+#include "totais.h"
+#include "calcula.h"
void dependente_free(void *pointer)
{
dependente_free(dependente);
return r;
}
+ r = totais_add(dec, "DEPENDENTES", deducao_dependente(dec));
return 0;
}
fprintf(f, "%013lld", 0); /* TODO: rendimentos PF ext. depend. */
fprintf(f, "%013lld", 0); /* TODO: carnê-leão PF? */
fprintf(f, "%013lld", 0); /* TODO: carnê-leão dependentes */
- fprintf(f, "%013lld", 0); /* TODO: dedução dependentes */
+ fprintf(f, "%013lld", totais_get(dec, "DEPENDENTES")); /* TODO: dedução dependentes */
fprintf(f, "%013lld", 0); /* TODO: previdência RRA */
fprintf(f, "%013lld", 0); /* TODO: previdência RRA dependentes */
fprintf(f, "%013lld", 0); /* TODO: pensão RRA */