Escapa o carectere %.
[cascardo/declara.git] / lib / base.c
index c2f88b9..8007d12 100644 (file)
@@ -22,6 +22,7 @@
 #include <string.h>
 #include <errno.h>
 #include "rendimento.h"
+#include "carne.h"
 #include "pagamento.h"
 #include "bem.h"
 #include "isento.h"
@@ -56,30 +57,37 @@ static int run_resumo(struct declaracao *dec, char **args, int argc)
                printf("completa\n");
                break;
        }
-       printf("pago: %lld.%02d\n", reais(dec->pago), centavos(dec->pago));
-       printf("retido: %lld.%02d\n", reais(dec->retido),
-                                     centavos(dec->retido));
-       printf("devido: %lld.%02d\n", reais(dec->devido),
-                                     centavos(dec->devido));
+       printf("pago: "FMT_R"\n", R(dec->pago));
+       printf("retido: "FMT_R"\n", R(dec->retido));
+       printf("devido: "FMT_R"\n", R(dec->devido));
        if (dec->restituicao > 0)
-               printf("restituicao: %lld.%02d\n", reais(dec->restituicao),
-                                                  centavos(dec->restituicao));
+               printf("restituicao: "FMT_R"\n", R(dec->restituicao));
        if (dec->pagar > 0)
-               printf("a pagar: %lld.%02d\n", reais(dec->pagar),
-                                              centavos(dec->pagar));
-       printf("base de cálculo: %lld.%02d\n",
-               reais(totais_get(dec, "BASE")),
-               centavos(totais_get(dec, "BASE")));
-       printf("isentos: %lld.%02d\n",
-               reais(totais_get(dec, "ISENTOS")),
-               centavos(totais_get(dec, "ISENTOS")));
-       printf("exclusivos: %lld.%02d\n",
-               reais(totais_get(dec, "EXCLUSIVOS")),
-               centavos(totais_get(dec, "EXCLUSIVOS")));
+               printf("a pagar: "FMT_R"\n", R(dec->pagar));
+       printf("base de cálculo: "FMT_R"\n",
+               R(totais_get(dec, "BASE")));
+       printf("isentos: "FMT_R"\n",
+               R(totais_get(dec, "ISENTOS")));
+       printf("exclusivos: "FMT_R"\n",
+               R(totais_get(dec, "EXCLUSIVOS")));
+       printf("bens: "FMT_R"\n",
+               R(totais_get(dec, "BENS")));
+       printf("bens: "FMT_R"\n",
+               R(totais_get(dec, "BENSANTERIOR")));
+       printf("aliquota efetiva: "FMT_R"%%\n",
+               R(dec->aliquota_efetiva));
        printf("hash: %010ld\n", dec->hash);
        return 0;
 }
 
+static int run_verbose(struct declaracao *dec, char **args, int argc)
+{
+       if (argc != 1)
+               return -EINVAL;
+       dec->verbose = 1;
+       return 0;
+}
+
 static void salva(struct declaracao *dec, FILE *f)
 {
        fprintf(f, "ano %d\n", dec->ano);
@@ -101,6 +109,7 @@ static void salva(struct declaracao *dec, FILE *f)
                fprintf(f, "dvconta \"%s\"\n", dec->dvconta);
        contribuinte_salva(dec, f);
        rendimento_salva(dec, f);
+       carne_salva(dec, f);
        pagamento_salva(dec, f);
        bem_salva(dec, f);
        isento_salva(dec, f);
@@ -150,6 +159,11 @@ static struct cmd cmd_resumo = {
        .run = run_resumo,
 };
 
+static struct cmd cmd_verbose = {
+       .name = "verbose",
+       .run = run_verbose,
+};
+
 static struct cmd cmd_simples = {
        .name = "simples",
        .run = run_simples,
@@ -176,6 +190,7 @@ int base_cmd_init(void)
        cmd_add(&cmd_contacorrente);
        cmd_add(&cmd_dvconta);
 
+       cmd_add(&cmd_verbose);
        cmd_add(&cmd_simples);
        cmd_add(&cmd_completa);