Suporte testado para rendimentos de pessoa jurídica.
#define _ANO_H
#define PRIMEIRO_ANO 2015
#define _ANO_H
#define PRIMEIRO_ANO 2015
#define MAX_ANOS (ULTIMO_ANO + 1)
#define ANO(ano) (ano - PRIMEIRO_ANO)
#define ANO_VALIDO(ano) (ANO(ano) >= 0 && ANO(ano) < ANO(MAX_ANOS))
#define MAX_ANOS (ULTIMO_ANO + 1)
#define ANO(ano) (ano - PRIMEIRO_ANO)
#define ANO_VALIDO(ano) (ANO(ano) >= 0 && ANO(ano) < ANO(MAX_ANOS))
[ANO(2015)] = 215652,
[ANO(2016)] = 227508,
[ANO(2017)] = 227508,
[ANO(2015)] = 215652,
[ANO(2016)] = 227508,
[ANO(2017)] = 227508,
};
static const long long instrucao[ANO(MAX_ANOS)] = {
[ANO(2015)] = 337583,
[ANO(2016)] = 356150,
[ANO(2017)] = 356150,
};
static const long long instrucao[ANO(MAX_ANOS)] = {
[ANO(2015)] = 337583,
[ANO(2016)] = 356150,
[ANO(2017)] = 356150,
};
long long deducao_dependente(struct declaracao *dec)
};
long long deducao_dependente(struct declaracao *dec)
[ANO(2015)] = table2015,
[ANO(2016)] = table2016,
[ANO(2017)] = table2017,
[ANO(2015)] = table2015,
[ANO(2016)] = table2016,
[ANO(2017)] = table2017,
+ [ANO(2018)] = table2017,
};
static const long long simples[ANO(MAX_ANOS)] = {
[ANO(2015)] = 1588089,
[ANO(2016)] = 1675434,
[ANO(2017)] = 1675434,
};
static const long long simples[ANO(MAX_ANOS)] = {
[ANO(2015)] = 1588089,
[ANO(2016)] = 1675434,
[ANO(2017)] = 1675434,
};
static const long long obrigatoriedade[ANO(MAX_ANOS)] = {
[ANO(2015)] = 2681655,
[ANO(2016)] = 2812391,
[ANO(2017)] = 2855970, /* De acordo com IN 1671/2016 */
};
static const long long obrigatoriedade[ANO(MAX_ANOS)] = {
[ANO(2015)] = 2681655,
[ANO(2016)] = 2812391,
[ANO(2017)] = 2855970, /* De acordo com IN 1671/2016 */
};
static long long imposto(struct taxtable *tt, long long tr, int verbose)
};
static long long imposto(struct taxtable *tt, long long tr, int verbose)
fprintf(f, "2600"); /* Código */
else if (dec->ano == 2017)
fprintf(f, "2700"); /* Código */
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 */
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 */
fprintf(f, "110"); /* Versão IRPF */
else if (dec->ano == 2017)
fprintf(f, "110"); /* Versão IRPF */
fprintf(f, "110"); /* Versão IRPF */
else if (dec->ano == 2017)
fprintf(f, "110"); /* Versão IRPF */
+ else if (dec->ano == 2018)
+ fprintf(f, "100"); /* 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 */
fprintf(f, "%-11.11s", ""); /* CPF inventariante */
fprintf(f, "%-40.40s", dec->contribuinte.municipio);
fprintf(f, "%-60.60s", dec->nome);
fprintf(f, "%-11.11s", ""); /* CPF inventariante */
fprintf(f, "%-40.40s", dec->contribuinte.municipio);
fprintf(f, "%-60.60s", dec->nome);
fprintf(f, "%010u ", crc32(0, dec->cpf, 11)); /* hash CPF */
else
fprintf(f, "%-11.11s", ""); /* CPF empregada, FILLER */
fprintf(f, "%010u ", crc32(0, dec->cpf, 11)); /* hash CPF */
else
fprintf(f, "%-11.11s", ""); /* CPF empregada, FILLER */
/* CPF do cônjuge */
fprintf(f, "%-11.11s", dec->conjuge.cpf ?: "");
}
/* CPF do cônjuge */
fprintf(f, "%-11.11s", dec->conjuge.cpf ?: "");
}
- 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 {
+ fprintf(f, "%-13.13s", ""); /* FILLER */
+ }
fprintf(f, "%-8.8s", dec->contribuinte.dn);
fprintf(f, "%-13.13s", dec->contribuinte.titulo_eleitor ?: "");
fprintf(f, "%03d", dec->contribuinte.ocupacao_principal);
fprintf(f, "%-8.8s", dec->contribuinte.dn);
fprintf(f, "%-13.13s", dec->contribuinte.titulo_eleitor ?: "");
fprintf(f, "%03d", dec->contribuinte.ocupacao_principal);
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) {
+ fprintf(f, "%-2.2s%-9.9s", dec->contribuinte.ddd ?: "", dec->contribuinte.telefone ?: "");
+ }
}
static void gera_simples(struct declaracao *dec, FILE *f)
}
static void gera_simples(struct declaracao *dec, FILE *f)
fprintf(f, "%013lld", 0); /* TODO: imposto ganho líquido renda variável */
fprintf(f, "%013lld", 0); /* TODO: imposto devido ganho capital moeda estrangeira */
fprintf(f, "%013lld", 0); /* TODO: imposto pago exterior */
fprintf(f, "%013lld", 0); /* TODO: imposto ganho líquido renda variável */
fprintf(f, "%013lld", 0); /* TODO: imposto devido ganho capital moeda estrangeira */
fprintf(f, "%013lld", 0); /* TODO: imposto pago exterior */
+ if (dec->ano >= 2018) {
+ fprintf(f, "%05lld", dec->aliquota_efetiva);
+ }
}
static void gera_completa(struct declaracao *dec, FILE *f)
}
static void gera_completa(struct declaracao *dec, FILE *f)
static int is_trailler_filler(int ano, int i)
{
static int is_trailler_filler(int ano, int i)
{
+ if (ano >= 2018) {
+ return i == 29 || i == 31 || i == 33 || i == 36 || i == 37 || i == 44 || i == 82;
+ }
return i == 44;
/* Ano 2016, linha 29 é um FILLER, mas preenchida com múltiplos
* 0s. Como esta linha não é gerada na declaração de 2016, não
return i == 44;
/* Ano 2016, linha 29 é um FILLER, mas preenchida com múltiplos
* 0s. Como esta linha não é gerada na declaração de 2016, não
/* || (ano == 2016 && i == 29); */
}
/* || (ano == 2016 && i == 29); */
}
+static int is_trailler_spaces(int ano, int i)
+{
+ return (ano == 2018 && i > 92);
+}
+
static int is_trailler_empty(int ano, int i)
{
return (i == 57 || i == 64 || i == 79) ||
static int is_trailler_empty(int ano, int i)
{
return (i == 57 || i == 64 || i == 79) ||
for (i = 16; i < 100; i++) {
if (is_trailler_filler(dec->ano, i))
fprintf(f, "%-5.5s", "0"); /* FILLER */
for (i = 16; i < 100; i++) {
if (is_trailler_filler(dec->ano, i))
fprintf(f, "%-5.5s", "0"); /* FILLER */
+ else if (is_trailler_spaces(dec->ano, i))
+ fprintf(f, "%-5.5s", "");
else if (is_trailler_empty(dec->ano, i))
;
else if (is_trailler_empty(dec->ano, i))
;
+ else if (dec->ano == 2018 && i == 92)
+ fprintf(f, "%-5s", "0");
else
fprintf(f, "%05d", dec->linhas[i]);
}
else
fprintf(f, "%05d", dec->linhas[i]);
}
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) {
+ fprintf(f, "%-2.2s%-9.9s", dec->contribuinte.ddd ?: "", dec->contribuinte.telefone ?: "");
+ }
}
static void gera_recibotrailler(struct declaracao *dec, FILE *f)
}
static void gera_recibotrailler(struct declaracao *dec, FILE *f)