Permite escolher entre declaração completa e simplificada.
[cascardo/declara.git] / lib / calcula.c
index 68ad6f1..9116868 100644 (file)
@@ -41,7 +41,8 @@ static long long total_deducao(struct declaracao *dec)
        int i;
        return totais_get(dec, "DEPENDENTES") +
               totais_get(dec, "INSS") +
-              totais_get(dec, "PAGAMENTOS");
+              totais_get(dec, "PAGAMENTOS") -
+              totais_get(dec, "REEMBOLSOS");
 }
 
 static void total_pago(struct declaracao *dec)
@@ -123,7 +124,8 @@ int calcula(struct declaracao *dec)
        i_simples = imposto_simples(dec);
        i_completa = imposto_completa(dec);
        total_pago(dec);
-       if (i_simples > i_completa) {
+       if (dec->tipo != FORCA_SIMPLES &&
+           (i_simples > i_completa || dec->tipo == FORCA_COMPLETA)) {
                dec->tipo = COMPLETA;
                dec->devido = i_completa;
        } else {