From d0a19f44adcb1766c8f5784e858935adc3a9813c Mon Sep 17 00:00:00 2001 From: Thadeu Lima de Souza Cascardo Date: Sun, 2 Aug 2015 09:39:05 -0300 Subject: [PATCH] Gera linha de pagamento. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit No momento, está restrito a pagamentos feitos a CNPJ, pelo e para o titular. --- lib/gera.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/lib/gera.c b/lib/gera.c index bf11b39..09c1bdd 100644 --- a/lib/gera.c +++ b/lib/gera.c @@ -17,13 +17,14 @@ */ #include "gera.h" -#include "declaracao.h" -#include "cmd.h" -#include "rendimento.h" #include #include #include #include +#include "declaracao.h" +#include "cmd.h" +#include "rendimento.h" +#include "pagamento.h" #include "totais.h" static void gera_header(struct declaracao *dec, FILE *f) @@ -414,6 +415,28 @@ static void gera_rendimento(struct declaracao *dec, FILE *f) fprintf(f, "\r\n"); } +static void gera_pagamento(struct declaracao *dec, FILE *f) +{ + struct pagamento *p; + p = list_get(dec->pagamentos, dec->linhas[26]); + fprintf(f, "26"); + fprintf(f, "%s", dec->cpf); + fprintf(f, "%02d", p->codigo); + fprintf(f, "%05d", 0); /* TODO: chave dependente */ + fprintf(f, "%-14.14s", p->cnpj); + fprintf(f, "%-60.60s", p->nome); + fprintf(f, "%-11.11s", ""); /* TODO: NIT */ + fprintf(f, "%013lld", p->pagamento); + fprintf(f, "%013lld", p->reembolso); + /* CPF (1?) ou CNPJ (2), FIXME */ + fprintf(f, "2"); + /* Titular (T), Dependente (D), Alimentando (A), FIXME */ + fprintf(f, "T"); + fprintf(f, "%-10.10s", "0000000000"); /* FIXME: controle */ + fprintf(f, "\r\n"); +} + + typedef void (gera_linha)(struct declaracao *dec, FILE *f); static int wrap(gera_linha fn, struct declaracao *dec, FILE *f) @@ -445,6 +468,7 @@ static int gera(struct declaracao *dec, char *filename) int r; int i; struct rendimento *rendimento; + struct pagamento *pagamento; #define W(fn, dec, f) \ do { \ @@ -469,6 +493,9 @@ static int gera(struct declaracao *dec, char *filename) for (i = 0; rendimento = list_get(dec->rendimento, i); i++) { W(gera_rendimento, dec, f); } + for (i = 0; (pagamento = list_get(dec->pagamentos, i)); i++) { + W(gera_pagamento, dec, f); + } W(gera_trailler, dec, f); W(gera_reciboheader, dec, f); W(gera_recibodetalhe, dec, f); -- 2.20.1