Outros rendimentos exigem uma descrição, e a discriminação se são
isentos ou exclusivos.
Até então, rendimentos exclusivos utilizavam o comando isento e eram
distintos pelo seu código. O comando exclusivo utiliza o mesmo código,
mas permite a distinção pelo primeiro argumento, quando o código não o
permitir.
gera_isento(dec, f, 96);
}
gera_isento(dec, f, 96);
}
+static void gera_outrosisentos(struct declaracao *dec, FILE *f)
+{
+ struct isento *i;
+ int codigo = 97;
+ i = isento_get(dec, codigo, dec->linhas[codigo]);
+ gera_isento(dec, f, codigo);
+ fprintf(f, "%d", i->exclusivo == 0 ? 1 : 2);
+ fprintf(f, "%-60.60s", i->descricao);
+}
+
static void gera_poupanca(struct declaracao *dec, FILE *f)
{
gera_isento(dec, f, 98);
static void gera_poupanca(struct declaracao *dec, FILE *f)
{
gera_isento(dec, f, 98);
IW(gera_doacao, 82);
IW(gera_indenizacoes, 93);
IW(gera_plr, 96);
IW(gera_doacao, 82);
IW(gera_indenizacoes, 93);
IW(gera_plr, 96);
+ IW(gera_outrosisentos, 97);
IW(gera_poupanca, 98);
IW(gera_aplicacoes, 99);
IW(gera_poupanca, 98);
IW(gera_aplicacoes, 99);
int r = 0;
switch (isento->codigo) {
case 82:
int r = 0;
switch (isento->codigo) {
case 82:
r = totais_add(dec, "DOACOES", isento->valor);
r = totais_add(dec, "DOACOES", isento->valor);
- r += totais_add(dec, "ISENTOS", isento->valor);
- if (isento->dependente) {
- r += totais_add(dec, "ISENTOSDEP", isento->valor);
- } else {
- r += totais_add(dec, "ISENTOSTIT", isento->valor);
- }
r = totais_add(dec, "INDENIZACOES", isento->valor);
r = totais_add(dec, "INDENIZACOES", isento->valor);
- r += totais_add(dec, "ISENTOS", isento->valor);
- if (isento->dependente) {
- r += totais_add(dec, "ISENTOSDEP", isento->valor);
- } else {
- r += totais_add(dec, "ISENTOSTIT", isento->valor);
- }
r = totais_add(dec, "PLR", isento->valor);
r = totais_add(dec, "PLR", isento->valor);
- r += totais_add(dec, "EXCLUSIVOS", isento->valor);
- if (isento->dependente) {
- r += totais_add(dec, "EXCLUSIVOSDEP", isento->valor);
- } else {
- r += totais_add(dec, "EXCLUSIVOSTIT", isento->valor);
- }
r = totais_add(dec, "POUPANCA", isento->valor);
r = totais_add(dec, "POUPANCA", isento->valor);
- r += totais_add(dec, "ISENTOS", isento->valor);
- if (isento->dependente) {
- r += totais_add(dec, "ISENTOSDEP", isento->valor);
- } else {
- r += totais_add(dec, "ISENTOSTIT", isento->valor);
- }
r = totais_add(dec, "APLICACOES", isento->valor);
r = totais_add(dec, "APLICACOES", isento->valor);
+ break;
+ }
+ if (isento->exclusivo) {
r += totais_add(dec, "EXCLUSIVOS", isento->valor);
if (isento->dependente) {
r += totais_add(dec, "EXCLUSIVOSDEP", isento->valor);
} else {
r += totais_add(dec, "EXCLUSIVOSTIT", isento->valor);
}
r += totais_add(dec, "EXCLUSIVOS", isento->valor);
if (isento->dependente) {
r += totais_add(dec, "EXCLUSIVOSDEP", isento->valor);
} else {
r += totais_add(dec, "EXCLUSIVOSTIT", isento->valor);
}
+ } else {
+ r += totais_add(dec, "ISENTOS", isento->valor);
+ if (isento->dependente) {
+ r += totais_add(dec, "ISENTOSDEP", isento->valor);
+ } else {
+ r += totais_add(dec, "ISENTOSTIT", isento->valor);
+ }
free(isento->cnpj);
if (isento->nome)
free(isento->nome);
free(isento->cnpj);
if (isento->nome)
free(isento->nome);
+ if (isento->descricao)
+ free(isento->descricao);
{
struct isento *r1 = p1;
struct isento *r2 = p2;
{
struct isento *r1 = p1;
struct isento *r2 = p2;
+ if (r1->exclusivo != r2->exclusivo)
+ return r2->exclusivo - r1->exclusivo;
/* O rendimento maior vem primeiro. */
if (r1->valor > r2->valor)
return -1;
/* O rendimento maior vem primeiro. */
if (r1->valor > r2->valor)
return -1;
int r = 0;
isento = malloc(sizeof(*isento));
int r = 0;
isento = malloc(sizeof(*isento));
+ if (!strcmp(args[0], "exclusivo")) {
+ isento->exclusivo = 1;
+ }
+
r += set_int(args[1], &isento->codigo);
r += set_string(args[2], &isento->cnpj);
r += set_string(args[3], &isento->nome);
r += set_int(args[1], &isento->codigo);
r += set_string(args[2], &isento->cnpj);
r += set_string(args[3], &isento->nome);
isento_free(isento);
return NULL;
}
isento_free(isento);
return NULL;
}
+ if (argc == 7) {
+ r = set_string(args[6], &isento->descricao);
+ if (r < 0) {
+ isento_free(isento);
+ return NULL;
+ }
+ } else {
+ isento->descricao = NULL;
+ }
{
struct isento *isento;
int r;
{
struct isento *isento;
int r;
- if (argc != 5 && argc != 6)
+ if (argc < 5 || argc > 7)
return -EINVAL;
isento = isento_new(args, argc);
if (!isento)
return -EINVAL;
isento = isento_new(args, argc);
if (!isento)
{
int i;
struct isento *j;
{
int i;
struct isento *j;
- for (i = 0; j = list_get(dec->isentos, i); i++)
- fprintf(f, "isento %d \"%s\" \"%s\" %lld %d\n",
+ for (i = 0; j = list_get(dec->isentos, i); i++) {
+ if (j->codigo == 97 && j->exclusivo)
+ fprintf(f, "exclusivo ");
+ else
+ fprintf(f, "isento ");
+ fprintf(f, "%d \"%s\" \"%s\" %lld %d",
j->codigo, j->cnpj, j->nome, j->valor, j->dependente);
j->codigo, j->cnpj, j->nome, j->valor, j->dependente);
+ if (j->descricao)
+ fprintf(f, " \"%s\"", j->descricao);
+ fprintf(f, "\n");
+ }
}
static struct cmd cmd_isento = {
}
static struct cmd cmd_isento = {
+static struct cmd cmd_exclusivo = {
+ .name = "exclusivo",
+ .run = run_isento,
+};
+
int isento_cmd_init(void)
{
cmd_add(&cmd_isento);
int isento_cmd_init(void)
{
cmd_add(&cmd_isento);
+ cmd_add(&cmd_exclusivo);
char *nome;
long long valor;
int dependente;
char *nome;
long long valor;
int dependente;
+ int exclusivo;
+ char *descricao;
};
void isento_salva(struct declaracao *dec, FILE *f);
};
void isento_salva(struct declaracao *dec, FILE *f);