summaryrefslogtreecommitdiff
path: root/Decompiler/Gestor.Application.ViewModels.Drawer/ImpostoViewModel.cs
diff options
context:
space:
mode:
authorLucas Faria Mendes <lucas.fariamo08@gmail.com>2026-03-30 15:29:41 +0000
committerLucas Faria Mendes <lucas.fariamo08@gmail.com>2026-03-30 15:29:41 +0000
commit225aa1499e37faf9d38257caabbadc68d78b427e (patch)
tree102bb7a40c58595348ae9d3c7076201759fe0720 /Decompiler/Gestor.Application.ViewModels.Drawer/ImpostoViewModel.cs
parent1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 (diff)
downloadgestor-225aa1499e37faf9d38257caabbadc68d78b427e.tar.gz
gestor-225aa1499e37faf9d38257caabbadc68d78b427e.zip
decompiler.com
Diffstat (limited to 'Decompiler/Gestor.Application.ViewModels.Drawer/ImpostoViewModel.cs')
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Drawer/ImpostoViewModel.cs314
1 files changed, 314 insertions, 0 deletions
diff --git a/Decompiler/Gestor.Application.ViewModels.Drawer/ImpostoViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Drawer/ImpostoViewModel.cs
new file mode 100644
index 0000000..a00c4be
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Drawer/ImpostoViewModel.cs
@@ -0,0 +1,314 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Threading.Tasks;
+using Gestor.Application.Helpers;
+using Gestor.Application.Servicos.Ferramentas;
+using Gestor.Application.ViewModels.Generic;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Configuracoes;
+using Gestor.Model.Domain.Ferramentas;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Seguros;
+
+namespace Gestor.Application.ViewModels.Drawer;
+
+public class ImpostoViewModel : BaseViewModel
+{
+ private bool _carregando;
+
+ private bool _apelido;
+
+ public int Tipo;
+
+ private List<Seguradora> _seguradoras;
+
+ private List<Ramo> _ramos;
+
+ private ObservableCollection<Imposto> _impostos = new ObservableCollection<Imposto>();
+
+ private Imposto _selectedImposto = new Imposto();
+
+ private Ramo _selectedRamo = new Ramo();
+
+ private Seguradora _selectedSeguradora = new Seguradora();
+
+ private ImpostoServico Servico { get; }
+
+ public bool? Ativo { get; set; } = true;
+
+
+ public bool Carregando
+ {
+ get
+ {
+ return _carregando;
+ }
+ set
+ {
+ _carregando = value;
+ base.IsEnabled = !value;
+ OnPropertyChanged("Carregando");
+ }
+ }
+
+ public bool Apelido
+ {
+ get
+ {
+ return _apelido;
+ }
+ set
+ {
+ _apelido = value;
+ OnPropertyChanged("Apelido");
+ }
+ }
+
+ public List<Seguradora> Seguradoras
+ {
+ get
+ {
+ return _seguradoras;
+ }
+ set
+ {
+ _seguradoras = value;
+ OnPropertyChanged("Seguradoras");
+ }
+ }
+
+ public List<Ramo> Ramos
+ {
+ get
+ {
+ return _ramos;
+ }
+ set
+ {
+ _ramos = value;
+ OnPropertyChanged("Ramos");
+ }
+ }
+
+ public ObservableCollection<Imposto> Impostos
+ {
+ get
+ {
+ return _impostos;
+ }
+ set
+ {
+ _impostos = value;
+ OnPropertyChanged("Impostos");
+ }
+ }
+
+ public Imposto SelectedImposto
+ {
+ get
+ {
+ return _selectedImposto;
+ }
+ set
+ {
+ _selectedImposto = value;
+ VerificarEnables((value != null) ? new long?(((DomainBase)value).Id) : null);
+ OnPropertyChanged("SelectedImposto");
+ }
+ }
+
+ public Ramo SelectedRamo
+ {
+ get
+ {
+ return _selectedRamo;
+ }
+ set
+ {
+ _selectedRamo = value;
+ OnPropertyChanged("SelectedRamo");
+ }
+ }
+
+ public Seguradora SelectedSeguradora
+ {
+ get
+ {
+ return _selectedSeguradora;
+ }
+ set
+ {
+ _selectedSeguradora = value;
+ OnPropertyChanged("SelectedSeguradora");
+ }
+ }
+
+ public ImpostoViewModel()
+ {
+ //IL_0018: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0022: Expected O, but got Unknown
+ //IL_0023: Unknown result type (might be due to invalid IL or missing references)
+ //IL_002d: Expected O, but got Unknown
+ //IL_002e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0038: Expected O, but got Unknown
+ Servico = new ImpostoServico();
+ Apelido = Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 6);
+ }
+
+ public async Task Carregar(int tipo, long id)
+ {
+ Tipo = tipo;
+ await PermissaoTela((TipoTela)56);
+ List<Seguradora> list = (from x in Recursos.Seguradoras
+ where x.Ativo || (tipo == 0 && ((DomainBase)x).Id == id)
+ orderby (!Apelido) ? x.Nome : x.NomeSocial
+ select x).ToList();
+ list.Insert(0, new Seguradora
+ {
+ Nome = "TODAS SEGURADORAS",
+ NomeSocial = "TODAS SEGURADORAS",
+ Id = 0L
+ });
+ Seguradoras = list;
+ SelectedSeguradora = Seguradoras.First();
+ List<Ramo> list2 = (from x in Recursos.Ramos
+ where x.Ativo || (tipo == 1 && ((DomainBase)x).Id == id)
+ orderby x.Nome
+ select x).ToList();
+ list2.Insert(0, new Ramo
+ {
+ Nome = "TODOS OS RAMOS",
+ Id = 0L
+ });
+ Ramos = list2;
+ SelectedRamo = Ramos.First();
+ string text = ((tipo == 1) ? ("O RAMO \"" + Ramos.First((Ramo x) => ((DomainBase)x).Id == id).Nome + "\"") : ("A SEGURADORA \"" + Seguradoras.First((Seguradora x) => ((DomainBase)x).Id == id).Nome + "\""));
+ RegistrarAcao("ACESSOU IMPOSTOS D" + text, id, (TipoTela)56, $"ID: {id}");
+ List<Imposto> source = await Servico.Buscar(true);
+ if (tipo != 1)
+ {
+ source = source.Where((Imposto x) => x.Seguradora != null && ((DomainBase)x.Seguradora).Id == id && x.Ramo == null).ToList();
+ SelectedSeguradora = Seguradoras.Find((Seguradora x) => ((DomainBase)x).Id == id);
+ }
+ else
+ {
+ source = source.Where((Imposto x) => x.Ramo != null && ((DomainBase)x.Ramo).Id == id && x.Seguradora == null).ToList();
+ SelectedRamo = Ramos.Find((Ramo x) => ((DomainBase)x).Id == id);
+ }
+ Impostos = new ObservableCollection<Imposto>(source.OrderByDescending((Imposto x) => x.Ativo));
+ SelectedImposto = Impostos.FirstOrDefault();
+ }
+
+ public async Task Carregar(long id = 0L)
+ {
+ List<Imposto> source = await Servico.Buscar(Ativo);
+ if (((DomainBase)SelectedSeguradora).Id == 0L)
+ {
+ source = source.Where((Imposto x) => x.Seguradora == null).ToList();
+ }
+ if (((DomainBase)SelectedSeguradora).Id > 0)
+ {
+ source = source.Where((Imposto x) => x.Seguradora != null && ((DomainBase)x.Seguradora).Id == ((DomainBase)SelectedSeguradora).Id).ToList();
+ }
+ if (((DomainBase)SelectedRamo).Id == 0L)
+ {
+ source = source.Where((Imposto x) => x.Ramo == null).ToList();
+ }
+ if (((DomainBase)SelectedRamo).Id > 0)
+ {
+ source = source.Where((Imposto x) => x.Ramo != null && ((DomainBase)x.Ramo).Id == ((DomainBase)SelectedRamo).Id).ToList();
+ }
+ Impostos = new ObservableCollection<Imposto>(source.Where((Imposto x) => !Ativo.HasValue || x.Ativo == Ativo.Value).ToList());
+ SelectedImposto = ((id == 0L) ? Impostos.FirstOrDefault() : ((IEnumerable<Imposto>)Impostos).FirstOrDefault((Func<Imposto, bool>)((Imposto x) => ((DomainBase)x).Id == id)));
+ }
+
+ public void Incluir()
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0006: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0024: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0042: Unknown result type (might be due to invalid IL or missing references)
+ //IL_004e: Expected O, but got Unknown
+ SelectedImposto = new Imposto
+ {
+ Seguradora = ((((DomainBase)SelectedSeguradora).Id > 0) ? SelectedSeguradora : null),
+ Ramo = ((((DomainBase)SelectedRamo).Id > 0) ? SelectedRamo : null),
+ Ativo = true
+ };
+ Alterar(alterar: true);
+ }
+
+ public void AlterarImposto()
+ {
+ Alterar(alterar: true);
+ }
+
+ public async Task Cancelar()
+ {
+ Imposto selectedImposto = SelectedImposto;
+ long id = ((selectedImposto != null) ? ((DomainBase)selectedImposto).Id : 0);
+ Alterar(alterar: false);
+ await Carregar(id);
+ }
+
+ public async Task<List<KeyValuePair<string, string>>> Salvar()
+ {
+ List<KeyValuePair<string, string>> list = SelectedImposto.Validate();
+ list.AddRange(Validate(SelectedImposto));
+ if (list.Count > 0)
+ {
+ return list;
+ }
+ string acao = ((((DomainBase)SelectedImposto).Id == 0L) ? "INCLUIU" : "ALTEROU");
+ Imposto val = await Servico.Salvar(SelectedImposto);
+ if (!Servico.Sucesso)
+ {
+ return new List<KeyValuePair<string, string>>
+ {
+ new KeyValuePair<string, string>("GRAVAR", "HOUVE UM ERRO AO SALVAR O IMPOSTO SELECIONADO.")
+ };
+ }
+ string text = ((val.Seguradora == null) ? "TODAS AS SEGURADORAS" : (" SEGURADORA " + val.Seguradora.Nome));
+ string text2 = ((val.Ramo == null) ? "TODOS OS RAMOS" : (" RAMO " + val.Ramo.Nome));
+ string text3 = " " + text + " E " + text2;
+ RegistrarAcao(acao + " IMPOSTO PARA " + text3, ((DomainBase)val).Id, (TipoTela)31, string.Format("ID: {0}{1}{2}\nSTATUS: {3}\nIR: {4:p2}\nISS: {5:p2}\nOUTROS: {6:p2}\nDESCONTO: {7:p2}", ((DomainBase)val).Id, text, text2, val.Ativo ? "ATIVO" : "INATIVO", val.Ir, val.Iss, val.Outros, val.Desconto));
+ Alterar(alterar: false);
+ await Carregar(((DomainBase)val).Id);
+ return null;
+ }
+
+ public List<KeyValuePair<string, string>> Validate(Imposto imposto)
+ {
+ List<KeyValuePair<string, string>> list = new List<KeyValuePair<string, string>>();
+ if (imposto == null)
+ {
+ return list;
+ }
+ if (imposto.Ativo && Impostos.Any(delegate(Imposto x)
+ {
+ if (((DomainBase)x).Id != ((DomainBase)imposto).Id)
+ {
+ Seguradora seguradora = x.Seguradora;
+ long? num = ((seguradora != null) ? new long?(((DomainBase)seguradora).Id) : null);
+ Seguradora seguradora2 = imposto.Seguradora;
+ if (num == ((seguradora2 != null) ? new long?(((DomainBase)seguradora2).Id) : null))
+ {
+ Ramo ramo = x.Ramo;
+ long? num2 = ((ramo != null) ? new long?(((DomainBase)ramo).Id) : null);
+ Ramo ramo2 = imposto.Ramo;
+ if (num2 == ((ramo2 != null) ? new long?(((DomainBase)ramo2).Id) : null))
+ {
+ return x.Ativo;
+ }
+ }
+ }
+ return false;
+ }))
+ {
+ list.Add(new KeyValuePair<string, string>("IMPOSTO DUPLICADO", "NÃO É POSSIVEL INSERIR UM NOVO PARAMETRO DE IMPOSTO, POIS JÁ EXISTEM PARAMETROS PARA A MESMA SEGURADORA E RAMO"));
+ }
+ return list.Distinct().ToList();
+ }
+}