From f173c1f2238f4401952ac0c2d78834a49004baf6 Mon Sep 17 00:00:00 2001 From: Thadeu Lima de Souza Cascardo Date: Sat, 13 Jun 2020 01:18:02 -0300 Subject: [PATCH] Suporte inicial a 2020. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Valores iguais a anos anteriores e suporte inicial a novos campos nas linhas principais. Testado com declaração simples. --- lib/ano.h | 2 +- lib/calcula.c | 5 +++++ lib/gera.c | 24 +++++++++++++++++++++--- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/lib/ano.h b/lib/ano.h index c7aea14..711bebe 100644 --- 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)) diff --git a/lib/calcula.c b/lib/calcula.c index a691472..eba2abb 100644 --- a/lib/calcula.c +++ b/lib/calcula.c @@ -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) diff --git a/lib/gera.c b/lib/gera.c index 07692db..d57a321 100644 --- a/lib/gera.c +++ b/lib/gera.c @@ -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 ?: ""); } } -- 2.20.1