Suporte inicial a 2020.
authorThadeu Lima de Souza Cascardo <cascardo@cascardo.eti.br>
Sat, 13 Jun 2020 04:18:02 +0000 (01:18 -0300)
committerThadeu Lima de Souza Cascardo <cascardo@cascardo.eti.br>
Sun, 28 Jun 2020 14:21:24 +0000 (11:21 -0300)
Valores iguais a anos anteriores e suporte inicial a novos campos nas linhas
principais. Testado com declaração simples.

lib/ano.h
lib/calcula.c
lib/gera.c

index c7aea14..711bebe 100644 (file)
--- a/lib/ano.h
+++ b/lib/ano.h
@@ -20,7 +20,7 @@
 #define _ANO_H
 
 #define PRIMEIRO_ANO 2015
-#define ULTIMO_ANO 2019
+#define ULTIMO_ANO 2020
 #define MAX_ANOS (ULTIMO_ANO + 1)
 #define ANO(ano) (ano - PRIMEIRO_ANO)
 #define ANO_VALIDO(ano) (ANO(ano) >= 0 && ANO(ano) < ANO(MAX_ANOS))
index a691472..eba2abb 100644 (file)
@@ -34,6 +34,7 @@ static const long long dependente[ANO(MAX_ANOS)] = {
        [ANO(2017)] = 227508,
        [ANO(2018)] = 227508,
        [ANO(2019)] = 227508,
+       [ANO(2020)] = 227508,
 };
 
 static const long long instrucao[ANO(MAX_ANOS)] = {
@@ -42,6 +43,7 @@ static const long long instrucao[ANO(MAX_ANOS)] = {
        [ANO(2017)] = 356150,
        [ANO(2018)] = 356150,
        [ANO(2019)] = 356150,
+       [ANO(2020)] = 356150,
 };
 
 long long deducao_dependente(struct declaracao *dec)
@@ -172,6 +174,7 @@ static struct taxtable *table[ANO(MAX_ANOS)] = {
        [ANO(2017)] = table2017,
        [ANO(2018)] = table2017,
        [ANO(2019)] = table2017,
+       [ANO(2020)] = table2017,
 };
 
 static const long long simples[ANO(MAX_ANOS)] = {
@@ -180,6 +183,7 @@ static const long long simples[ANO(MAX_ANOS)] = {
        [ANO(2017)] = 1675434,
        [ANO(2018)] = 1675434,
        [ANO(2019)] = 1675434,
+       [ANO(2020)] = 1675434,
 };
 
 static const long long obrigatoriedade[ANO(MAX_ANOS)] = {
@@ -188,6 +192,7 @@ static const long long obrigatoriedade[ANO(MAX_ANOS)] = {
        [ANO(2017)] = 2855970, /* De acordo com IN 1671/2016 */
        [ANO(2018)] = 2855970,
        [ANO(2019)] = 2855970,
+       [ANO(2020)] = 2855970,
 };
 
 static long long imposto(struct taxtable *tt, long long tr, int verbose)
index 07692db..d57a321 100644 (file)
@@ -51,6 +51,8 @@ static void gera_header(struct declaracao *dec, FILE *f)
                fprintf(f, "2800"); /* Código */
        else if (dec->ano == 2019)
                fprintf(f, "2900"); /* Código */
+       else if (dec->ano == 2020)
+               fprintf(f, "3000");
        fprintf(f, "%s", dec->retifica ? "1" : "0"); /* Retificadora */
        fprintf(f, "%s", dec->cpf); /* CPF: 11 dígitos */
        fprintf(f, "   "); /* Filler */
@@ -65,6 +67,8 @@ static void gera_header(struct declaracao *dec, FILE *f)
                fprintf(f, "160"); /* Versão IRPF */
        else if (dec->ano == 2019)
                fprintf(f, "150"); /* Versão IRPF */
+       else if (dec->ano == 2020)
+               fprintf(f, "180"); /* Versão IRPF */
        fprintf(f, "%-60.60s", dec->nome);
        fprintf(f, "%-2.2s", dec->contribuinte.uf ?: "");
        fprintf(f, "%s", "0000000000"); /* FIXME: hash */
@@ -111,6 +115,7 @@ static void gera_header(struct declaracao *dec, FILE *f)
        fprintf(f, " "); /* RRA4 */
        fprintf(f, "%-11.11s", ""); /* CPF RRA4 */
        fprintf(f, "0000000000000"); /* TODO: Doacao ECA */
+       fprintf(f, "0000000000000"); /* TODO: Doacao Idoso */
        fprintf(f, "%-14.14s", rendimento_cnpj_ordenado(dec, 0)); /* CNPJ maior */
        fprintf(f, "%-14.14s", rendimento_cnpj_ordenado(dec, 1)); /* CNPJ maior 2 */
        fprintf(f, "%-14.14s", rendimento_cnpj_ordenado(dec, 2)); /* CNPJ maior 3 */
@@ -207,6 +212,9 @@ static void gera_header(struct declaracao *dec, FILE *f)
 
        /* Fim das mudanças de 2016 */
 
+       if (dec->ano >= 2020)
+               fprintf(f, "%-13.13s", dec->contribuinte.titulo_eleitor ?: "");
+
        fprintf(f, "   "); /* Teste PGD, FILLER2 */
 }
 
@@ -240,6 +248,9 @@ static void gera_contribuinte(struct declaracao *dec, FILE *f)
        if (dec->ano <= 2017) {
                fprintf(f, "%-4.4s", dec->contribuinte.ddd ?: "");
                fprintf(f, "%-9.9s", dec->contribuinte.telefone ?: "");
+       } else if (dec->ano >= 2020) {
+               fprintf(f, "%-4.4s", dec->contribuinte.ddd ?: "");
+               fprintf(f, "%-9.9s", "");
        } else {
                fprintf(f, "%-13.13s", ""); /* FILLER */
        }
@@ -272,7 +283,9 @@ static void gera_contribuinte(struct declaracao *dec, FILE *f)
                fprintf(f, "%-11.11s", dec->contribuinte.celular ?: ""); /* celular */
                fprintf(f, "%s", dec->conjuge.cpf ? "S" : "N");
        }
-       if (dec->ano >= 2018) {
+       if (dec->ano >= 2020) {
+               fprintf(f, "%-11.11s", dec->contribuinte.telefone ?: "");
+       } else if (dec->ano >= 2018) {
                fprintf(f, "%-2.2s%-9.9s", dec->contribuinte.ddd ?: "", dec->contribuinte.telefone ?: "");
        }
 }
@@ -722,7 +735,10 @@ static void gera_recibodetalhe(struct declaracao *dec, FILE *f)
        fprintf(f, "%-100.100s", ""); /* FILLER */
        fprintf(f, "%-4.4s", ""); /* FILLER */
        fprintf(f, "%-8.8s", ""); /* FILLER */
-       if (dec->ano >= 2018) {
+       if (dec->ano >= 2020) {
+               fprintf(f, "%-4.4s", dec->contribuinte.ddd ?: "");
+               fprintf(f, "%-9.9s", "");
+       } else if (dec->ano >= 2018) {
                fprintf(f, "%-13.13s", "");
        } else {
                fprintf(f, "%-4.4s", dec->contribuinte.ddd ?: "");
@@ -743,7 +759,9 @@ static void gera_recibodetalhe(struct declaracao *dec, FILE *f)
        fprintf(f, "%-13.13s", dec->contacorrente ? : ""); /* numero conta */
        fprintf(f, "%-2.2s", dec->dvconta ? : ""); /* DV conta */
        fprintf(f, "%013lld", 0); /* TODO: imposto alienacao moeda estrangeira em especie */
-       if (dec->ano >= 2018) {
+       if (dec->ano >= 2020) {
+               fprintf(f, "%-11.11s", dec->contribuinte.telefone ?: "");
+       } else if (dec->ano >= 2018) {
                fprintf(f, "%-2.2s%-9.9s", dec->contribuinte.ddd ?: "", dec->contribuinte.telefone ?: "");
        }
 }