Suporte inicial a 2020.
[cascardo/declara.git] / lib / gera.c
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 */
                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 */
        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 */
                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 */
        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, " "); /* 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 */
        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 */
 
 
        /* Fim das mudanças de 2016 */
 
+       if (dec->ano >= 2020)
+               fprintf(f, "%-13.13s", dec->contribuinte.titulo_eleitor ?: "");
+
        fprintf(f, "   "); /* Teste PGD, FILLER2 */
 }
 
        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 ?: "");
        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 */
        }
        } 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");
        }
                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 ?: "");
        }
 }
                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 */
        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 ?: "");
                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 */
        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 ?: "");
        }
 }
                fprintf(f, "%-2.2s%-9.9s", dec->contribuinte.ddd ?: "", dec->contribuinte.telefone ?: "");
        }
 }