X-Git-Url: http://git.cascardo.eti.br/?p=cascardo%2Fdeclara.git;a=blobdiff_plain;f=lib%2Fgera.c;h=15872683d83abce1029be5cd3a09cd1440ffcff4;hp=c706c0cd18235eacecfed902822f13696087c2d0;hb=a5b1b6551514ac3b013b48bce06578704ab89ccf;hpb=86afb849c3c78b6ba7e6e1427fc57ff863042569 diff --git a/lib/gera.c b/lib/gera.c index c706c0c..1587268 100644 --- a/lib/gera.c +++ b/lib/gera.c @@ -42,34 +42,31 @@ static void gera_header(struct declaracao *dec, FILE *f) fprintf(f, "IRPF "); fprintf(f, "%04d", dec->ano); /* Exercício */ fprintf(f, "%04d", dec->ano - 1); /* Ano base */ - if (dec->ano == 2015) - fprintf(f, "2500"); /* Código */ - else if (dec->ano == 2016) - fprintf(f, "2600"); /* Código */ - else if (dec->ano == 2017) - fprintf(f, "2700"); /* Código */ - else if (dec->ano == 2018) - fprintf(f, "2800"); /* Código */ - else if (dec->ano == 2019) - fprintf(f, "2900"); /* Código */ - else if (dec->ano == 2020) - fprintf(f, "3000"); + + /* Código Receitanet */ + fprintf(f, "%04d", (dec->ano - 1990) * 100); + fprintf(f, "%s", dec->retifica ? "1" : "0"); /* Retificadora */ fprintf(f, "%s", dec->cpf); /* CPF: 11 dígitos */ fprintf(f, " "); /* Filler */ fprintf(f, "1"); /* Tipo NI: Pessoa Física (1) */ + + /* Versão IRPF */ if (dec->ano == 2015) - fprintf(f, "130"); /* Versão IRPF */ + fprintf(f, "130"); else if (dec->ano == 2016) - fprintf(f, "110"); /* Versão IRPF */ + fprintf(f, "110"); else if (dec->ano == 2017) - fprintf(f, "130"); /* Versão IRPF */ + fprintf(f, "130"); else if (dec->ano == 2018) - fprintf(f, "160"); /* Versão IRPF */ + fprintf(f, "160"); else if (dec->ano == 2019) - fprintf(f, "150"); /* Versão IRPF */ + fprintf(f, "150"); else if (dec->ano == 2020) - fprintf(f, "180"); /* Versão IRPF */ + fprintf(f, "180"); + else if (dec->ano == 2021) + fprintf(f, "120"); + fprintf(f, "%-60.60s", dec->nome); fprintf(f, "%-2.2s", dec->contribuinte.uf ?: ""); fprintf(f, "%s", "0000000000"); /* FIXME: hash */ @@ -166,7 +163,11 @@ static void gera_header(struct declaracao *dec, FILE *f) fprintf(f, "%013lld", totais_get(dec, "EXCLUSIVOS")); /* Total pagamentos */ fprintf(f, "%013lld", totais_get(dec, "PAGAMENTOS")); - fprintf(f, "%-13.13s", dec->contacorrente ? : ""); /* numero conta */ + if (dec->ano < 2021) { + fprintf(f, "%-13.13s", dec->contacorrente ? : ""); /* numero conta */ + } else { + fprintf(f, "%-13.13s", ""); /* FILLER */ + } fprintf(f, "%-2.2s", dec->dvconta ? : ""); /* DV conta */ fprintf(f, "0"); /* TODO: revalidar DV conta */ @@ -216,6 +217,12 @@ static void gera_header(struct declaracao *dec, FILE *f) if (dec->ano >= 2020) fprintf(f, "%-13.13s", dec->contribuinte.titulo_eleitor ?: ""); + if (dec->ano >= 2021) { + fprintf(f, "1"); /* TODO: Tipo conta */ + fprintf(f, "%-20.20s", dec->contacorrente ? : ""); /* conta */ + fprintf(f, "1"); /* TODO: indicador devolver auxílio emergencial */ + } + fprintf(f, " "); /* Teste PGD, FILLER2 */ } @@ -269,7 +276,11 @@ static void gera_contribuinte(struct declaracao *dec, FILE *f) fprintf(f, "%-4.4s", dec->agencia ? : "0000"); /* agência */ fprintf(f, "N"); /* TODO: deficiência */ fprintf(f, "0"); /* FILLER: pré-preenchida */ - fprintf(f, "%-13.13s", dec->contacorrente ? : ""); /* conta */ + if (dec->ano < 2021) { + fprintf(f, "%-13.13s", dec->contacorrente ? : ""); /* conta */ + } else { + fprintf(f, "%-13.13s", ""); /* FILLER */ + } fprintf(f, "%-2.2s", dec->dvconta ? : ""); /* DV conta */ fprintf(f, "N"); /* TODO: débito automático */ fprintf(f, "0"); /* TODO: débito primeira quota */ @@ -289,6 +300,10 @@ static void gera_contribuinte(struct declaracao *dec, FILE *f) } else if (dec->ano >= 2018) { fprintf(f, "%-2.2s%-9.9s", dec->contribuinte.ddd ?: "", dec->contribuinte.telefone ?: ""); } + if (dec->ano >= 2021) { + fprintf(f, "1"); /* TODO: Tipo conta */ + fprintf(f, "%-20.20s", dec->contacorrente ? : ""); /* conta */ + } } static void gera_simples(struct declaracao *dec, FILE *f) @@ -757,7 +772,11 @@ static void gera_recibodetalhe(struct declaracao *dec, FILE *f) fprintf(f, " "); /* FILLER */ fprintf(f, "%d", 0); /* TODO: debito primeira quota */ fprintf(f, "%013lld", 0); /* TODO: imposto pago ganho de capital */ - fprintf(f, "%-13.13s", dec->contacorrente ? : ""); /* numero conta */ + if (dec->ano < 2021) { + fprintf(f, "%-13.13s", dec->contacorrente ? : ""); /* numero conta */ + } else { + fprintf(f, "%-13.13s", ""); /* FILLER */ + } fprintf(f, "%-2.2s", dec->dvconta ? : ""); /* DV conta */ fprintf(f, "%013lld", 0); /* TODO: imposto alienacao moeda estrangeira em especie */ if (dec->ano >= 2020) { @@ -765,6 +784,9 @@ static void gera_recibodetalhe(struct declaracao *dec, FILE *f) } else if (dec->ano >= 2018) { fprintf(f, "%-2.2s%-9.9s", dec->contribuinte.ddd ?: "", dec->contribuinte.telefone ?: ""); } + if (dec->ano >= 2021) { + fprintf(f, "%-20.20s", dec->contacorrente ? : ""); /* numero conta */ + } } static void gera_recibotrailler(struct declaracao *dec, FILE *f) @@ -963,13 +985,13 @@ static void gera_bem(struct declaracao *dec, FILE *f) attr_out(f, b->attr, "bairro", 40); attr_out(f, b->attr, "cep", 9); attr_out(f, b->attr, "uf", 2); - attr_out(f, b->attr, "cd_municipio", 4); + attr_out_int(f, b->attr, "cd_municipio", 4); attr_out(f, b->attr, "municipio", 40); /* FIXME: Registro de imóveis, Nao (0), Sim (1), Vazio (2) */ fprintf(f, "%d", attr_get(b->attr, "registro") ? 1 : 2); attr_out(f, b->attr, "matricula", 40); attr_out(f, b->attr, "registro", 40); - attr_out(f, b->attr, "area", 11); + attr_out_int(f, b->attr, "area", 11); /* FIXME: Area, M2 (0), Ha (1), Vazio (2) */ fprintf(f, "%d", attr_get(b->attr, "area") ? 0 : 2); attr_out(f, b->attr, "cartorio", 60); @@ -994,7 +1016,7 @@ static void gera_bem(struct declaracao *dec, FILE *f) attr_out(f, b->attr, "iptu", 30); } if (dec->ano >= 2020) { - fprintf(f, "%-3.3s", ""); /* TODO: Banco */ + attr_out_int(f, b->attr, "banco", 3); fprintf(f, "%c", b->dependente ? 'D' : 'T'); if (b->dependente) { struct dependente *d;