Utiliza atributos para bens.
[cascardo/declara.git] / lib / gera.c
index d57a321..214037c 100644 (file)
@@ -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)
 {
@@ -956,22 +957,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(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);
@@ -990,7 +991,7 @@ static void gera_bem(struct declaracao *dec, FILE *f)
        }
 
        if (dec->ano >= 2019) {
-               fprintf(f, "%-30.30s", ""); /* TODO: IPTU */
+               attr_out(f, b->attr, "iptu", 30);
        }
 }