X-Git-Url: http://git.cascardo.eti.br/?p=cascardo%2Fdeclara.git;a=blobdiff_plain;f=lib%2Fgera.c;h=2628aa7ff1f4154e5b29c2c2906adcd5560585ae;hp=74329f3807683ed7997e5866a45978963fda0d57;hb=0e0f6f1266e18e02328daa805cf9e7be377ac664;hpb=dffc4ef96f8510607ff48d2cb1a95911cfd338c3 diff --git a/lib/gera.c b/lib/gera.c index 74329f3..2628aa7 100644 --- a/lib/gera.c +++ b/lib/gera.c @@ -33,6 +33,7 @@ #include "totais.h" #include "sistema.h" #include "ano.h" +#include "attr.h" static void gera_header(struct declaracao *dec, FILE *f) { @@ -41,30 +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 */ + + /* 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"); + 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 */ @@ -111,6 +113,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 +210,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 +246,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 +281,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 ?: ""); } } @@ -579,6 +590,11 @@ static void gera_23_lucrome(struct declaracao *dec, FILE *f) gera_isentos2(dec, f, 13, "LUCROME"); } +static void gera_23_outrosisentos(struct declaracao *dec, FILE *f) +{ + gera_isentos2(dec, f, 26, "OUTROSISENTOS"); +} + static void gera_exclusivos(struct declaracao *dec, FILE *f) { fprintf(f, "24"); @@ -717,7 +733,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 ?: ""); @@ -738,7 +757,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 ?: ""); } } @@ -867,6 +888,14 @@ static void gera_outrosisentos(struct declaracao *dec, FILE *f) fprintf(f, "%-60.60s", i->descricao); } +static void gera_outrosisentos2(struct declaracao *dec, FILE *f) +{ + struct isento *i; + i = dec->ctx; + gera_isento2(dec, f, 26, 26, 86); + fprintf(f, "%-60.60s", i->descricao); +} + static void gera_poupanca(struct declaracao *dec, FILE *f) { gera_isento(dec, f, 98); @@ -925,22 +954,22 @@ static void gera_bem(struct declaracao *dec, FILE *f) fprintf(f, "%013lld", b->valor); /* Imóvel */ - fprintf(f, "%-40.40s", b->logradouro ?: ""); - fprintf(f, "%-6.6s", b->numero ?: ""); - fprintf(f, "%-40.40s", b->complemento ?: ""); - fprintf(f, "%-40.40s", b->bairro ?: ""); - fprintf(f, "%-9.9s", b->cep ?: ""); - fprintf(f, "%-2.2s", b->uf ?: ""); - fprintf(f, "%04d", b->cd_municipio); - fprintf(f, "%-40.40s", b->municipio ?: ""); + attr_out(f, b->attr, "logradouro", 40); + attr_out(f, b->attr, "numero", 6); + attr_out(f, b->attr, "complemento", 40); + attr_out(f, b->attr, "bairro", 40); + attr_out(f, b->attr, "cep", 9); + attr_out(f, b->attr, "uf", 2); + 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", b->registro ? 1 : 2); - fprintf(f, "%-40.40s", b->matricula ?: ""); - fprintf(f, "%-40.40s", b->registro ?: ""); - fprintf(f, "%011lld", b->area); + 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_int(f, b->attr, "area", 11); /* FIXME: Area, M2 (0), Ha (1), Vazio (2) */ - fprintf(f, "%d", (b->area == 0) ? 2 : 0); - fprintf(f, "%-60.60s", b->cartorio ?: ""); + fprintf(f, "%d", attr_get(b->attr, "area") ? 0 : 2); + attr_out(f, b->attr, "cartorio", 60); /* Número de chave */ fprintf(f, "%05d", dec->linhas[27] + 1); @@ -955,11 +984,22 @@ static void gera_bem(struct declaracao *dec, FILE *f) fprintf(f, "%-30.30s", ""); /* TODO: Registro Capitania dos Portos */ fprintf(f, "%04d", 0); /* TODO: Agência bancária */ fprintf(f, "%-15.15s", ""); /* TODO: Conta bancária e dígito verificador */ - fprintf(f, "%-14.14s", ""); /* TODO: CPF ou CNPJ */ + attr_out(f, b->attr, "cnpj", 14); } if (dec->ano >= 2019) { - fprintf(f, "%-30.30s", ""); /* TODO: IPTU */ + attr_out(f, b->attr, "iptu", 30); + } + if (dec->ano >= 2020) { + attr_out_int(f, b->attr, "banco", 3); + fprintf(f, "%c", b->dependente ? 'D' : 'T'); + if (b->dependente) { + struct dependente *d; + d = list_get(dec->dependentes, b->dependente - 1); + fprintf(f, "%-11.11s", d ? d->cpf : ""); + } else { + fprintf(f, "%-11.11s", dec->cpf); + } } } @@ -1113,6 +1153,7 @@ static int gera(struct declaracao *dec, char *filename) } else { W(gera_23_poupanca); W(gera_23_lucrome); + W(gera_23_outrosisentos); W(gera_24_decimoterceiro); W(gera_24_aplicacoes); W(gera_24_plr); @@ -1152,6 +1193,7 @@ static int gera(struct declaracao *dec, char *filename) IW(gera_poupanca2, 12); //dec->linhas[12] = 0; IW(gera_lucrome2, 13); + IW(gera_outrosisentos2, 26); IW(gera_aplicacoes2, 6); //dec->linhas[99] = 0; IW(gera_plr2, 11);