Calcula alíquota efetiva.
[cascardo/declara.git] / lib / calcula.c
index ac2ed73..ade9be2 100644 (file)
@@ -73,6 +73,7 @@ static void calculo_instrucao(struct declaracao *dec)
                        }
                }
                if (instrucao_dependente) {
+                       /* Conta número de dependentes com instrução. */
                        totais_add(dec, "DEPSINSTRUCAO", 1);
                        if (dec->verbose) {
                                printf("Dependente %s (%d) tem instrução\n", d->nome, i);
@@ -100,6 +101,8 @@ static long long total_deducao(struct declaracao *dec)
                printf("\tDependentes: "FMT_R"\n", R(totais_get(dec, "DEPENDENTES")));
                printf("\tINSS: "FMT_R"\n", R(totais_get(dec, "INSS")));
                printf("\tInstrução: "FMT_R"\n", R(totais_get(dec, "INSTRUCAO")));
+               printf("\tMédicas: "FMT_R"\n", R(totais_get(dec, "MEDICAS")));
+               printf("\tPrevidência: "FMT_R"\n", R(totais_get(dec, "PREVIDENCIA")));
                printf("\tPagamentos: "FMT_R"\n", R(totais_get(dec, "PAGAMENTOS")));
                printf("\tReembolsos: -"FMT_R"\n", R(totais_get(dec, "REEMBOLSOS")));
        }
@@ -114,7 +117,8 @@ static void total_pago(struct declaracao *dec)
 {
        struct rendimento *rendimento;
        int i;
-       dec->pago = dec->retido = 0;
+       dec->pago = dec->retido = totais_get(dec, "PAGO");
+       dec->retido -= totais_get(dec, "CARNE");
        for (i = 0; rendimento = list_get(dec->rendimento, i); i++) {
                dec->pago += rendimento->imposto;
                dec->retido += rendimento->imposto;
@@ -265,6 +269,7 @@ int calcula(struct declaracao *dec)
                dec->restituicao = dec->pago - dec->devido;
        else
                dec->pagar = dec->devido - dec->pago;
+       dec->aliquota_efetiva = dec->devido * 10000 / totais_get(dec, "RENDTRIB");
        return 0;
 }