*/
#include "calcula.h"
+#include <errno.h>
+#include <stdio.h>
#include "declaracao.h"
#include "cmd.h"
#include "rendimento.h"
-#include <errno.h>
-#include <stdio.h>
-
-static long long total_rendimento(struct declaracao *dec)
-{
- long long tr = 0;
- struct rendimento *rendimento;
- int i;
- for (i = 0; rendimento = list_get(dec->rendimento, i); i++) {
- tr += rendimento->rendimento;
- }
- return tr;
-}
+#include "totais.h"
+/* 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)
{
- long long td = 0;
- struct rendimento *rendimento;
- int i;
- for (i = 0; rendimento = list_get(dec->rendimento, i); i++) {
- td += rendimento->previdencia;
- }
- return td;
+ return totais_get(dec, "INSS");
}
static void total_pago(struct declaracao *dec)
static const long long simples2015 = 1588089;
+static const long long obrigatoriedade2015 = 2681655;
+
static long long imposto(struct taxtable *tt, long long tr)
{
int i;
struct taxtable *tt;
long long tr, td;
tt = table2015;
- tr = total_rendimento(dec);
- dec->totalrendimento = tr;
+ tr = totais_get(dec, "RENDPJ");
if (tr / 5 < simples2015)
td = tr / 5;
else
return -EINVAL;
}
tt = table2015;
- tr = total_rendimento(dec);
+ tr = totais_get(dec, "RENDPJ");
td = total_deducao(dec);
- dec->totalrendimento = tr;
tr -= td;
return imposto(tt, tr);
}
if (dec->ano != 2015) {
return -EINVAL;
}
+ if (totais_get(dec, "RENDPJ") > obrigatoriedade2015)
+ dec->obrigatoria = 1;
i_simples = imposto_simples(dec);
i_completa = imposto_completa(dec);
total_pago(dec);