#include "totais.h"
#include "sistema.h"
#include "ano.h"
+#include "attr.h"
static void gera_header(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(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(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);
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(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);
+ }
}
}