Permite escolher entre declaração completa e simplificada.
[cascardo/declara.git] / lib / base.c
index f15c4ea..7c55b85 100644 (file)
@@ -24,6 +24,7 @@
 #include "rendimento.h"
 #include "pagamento.h"
 #include "bem.h"
+#include "totais.h"
 #include "util.h"
 
 SET_INT(ano);
@@ -62,6 +63,16 @@ static int run_resumo(struct declaracao *dec, char **args, int argc)
        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("hash: %010ld\n", dec->hash);
        return 0;
 }
 
@@ -105,6 +116,22 @@ static int run_salva(struct declaracao *dec, char **args, int argc)
        return 0;
 }
 
+static int run_simples(struct declaracao *dec, char **args, int argc)
+{
+       if (argc != 1)
+               return -EINVAL;
+       dec->tipo = FORCA_SIMPLES;
+       return 0;
+}
+
+static int run_completa(struct declaracao *dec, char **args, int argc)
+{
+       if (argc != 1)
+               return -EINVAL;
+       dec->tipo = FORCA_COMPLETA;
+       return 0;
+}
+
 static struct cmd cmd_salva = {
        .name = "salva",
        .run = run_salva,
@@ -115,6 +142,16 @@ static struct cmd cmd_resumo = {
        .run = run_resumo,
 };
 
+static struct cmd cmd_simples = {
+       .name = "simples",
+       .run = run_simples,
+};
+
+static struct cmd cmd_completa = {
+       .name = "completa",
+       .run = run_completa,
+};
+
 int base_cmd_init(void)
 {
        cmd_add(&cmd_salva);
@@ -131,5 +168,8 @@ int base_cmd_init(void)
        cmd_add(&cmd_contacorrente);
        cmd_add(&cmd_dvconta);
 
+       cmd_add(&cmd_simples);
+       cmd_add(&cmd_completa);
+
        return 0;
 }