Deduções pode ser maiores que rendimentos tributáveis.
[cascardo/declara.git] / lib / calcula.c
index fdf3b83..c928a02 100644 (file)
@@ -135,6 +135,8 @@ static long long imposto_simples(struct declaracao *dec)
                td = simples[ANO(dec->ano)];
        totais_add(dec, "DESCONTO", td);
        tr -= td;
+       if (tr < 0)
+               tr = 0;
        totais_add(dec, "BASESIMPLES", tr);
        if (dec->verbose) {
                printf("Desconto simplificado é "FMT_R"\n", R(td));
@@ -151,6 +153,8 @@ static long long imposto_completa(struct declaracao *dec)
        td = total_deducao(dec);
        totais_add(dec, "DEDUCOES", td);
        tr -= td;
+       if (tr < 0)
+               tr = 0;
        totais_add(dec, "BASECOMPLETA", tr);
        if (dec->verbose) {
                printf("Desconto completa é "FMT_R"\n", R(td));