summaryrefslogtreecommitdiff
path: root/Decompiler/Gestor.Application.ViewModels.Financeiro
diff options
context:
space:
mode:
Diffstat (limited to 'Decompiler/Gestor.Application.ViewModels.Financeiro')
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Financeiro/BancosContasViewModel.cs542
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Financeiro/CentroDeCustoViewmodel.cs219
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Financeiro/ContasDialogModel.cs46
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Financeiro/CopiarClienteViewModel.cs22
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Financeiro/ExtratoContaViewModel.cs408
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Financeiro/FinanceiroViewModel.cs4400
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Financeiro/FornecedorViewModel.cs477
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Financeiro/InfoExtratoViewModel.cs64
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Financeiro/MenuFinanceiroViewModel.cs24
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Financeiro/PlanoViewModel.cs129
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Financeiro/PlanosViewModel.cs252
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Financeiro/TranferenciaViewModel.cs66
12 files changed, 6649 insertions, 0 deletions
diff --git a/Decompiler/Gestor.Application.ViewModels.Financeiro/BancosContasViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Financeiro/BancosContasViewModel.cs
new file mode 100644
index 0000000..579dbd1
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Financeiro/BancosContasViewModel.cs
@@ -0,0 +1,542 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows.Media;
+using Gestor.Application.Helpers;
+using Gestor.Application.Servicos.Financeiro;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Application.ViewModels.Generic;
+using Gestor.Common.Validation;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Financeiro;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Seguros;
+using Gestor.Model.Helper;
+
+namespace Gestor.Application.ViewModels.Financeiro;
+
+public class BancosContasViewModel : BaseFinanceiroViewModel
+{
+ private readonly BancosContasServico _bancosContasServico;
+
+ public BancosContas CancelBancosContas;
+
+ private long _ultimoId;
+
+ private BancosContas _selectedBancosContas;
+
+ private SolidColorBrush _corDoSaldo = new SolidColorBrush(Colors.Green);
+
+ private ObservableCollection<BancosContas> _bancosContasFiltrados = new ObservableCollection<BancosContas>();
+
+ private bool _isExpanded;
+
+ private ObservableCollection<Saldo> _saldos = new ObservableCollection<Saldo>();
+
+ private bool _habilitarFecharSaldo;
+
+ private Saldo _selectedSaldo = new Saldo();
+
+ private string _saldoAtual;
+
+ private decimal? _valorAbertura;
+
+ private DateTime? _dataAbertura;
+
+ private bool _incluindo;
+
+ public List<BancosContas> BancosContas { get; set; }
+
+ public BancosContas SelectedBancosContas
+ {
+ get
+ {
+ return _selectedBancosContas;
+ }
+ set
+ {
+ _selectedBancosContas = value;
+ CarregarSaldos(value);
+ VerificarEnables((value != null) ? new long?(((DomainBase)value).Id) : null);
+ Incluindo = value != null && ((DomainBase)value).Id == 0;
+ OnPropertyChanged("SelectedBancosContas");
+ }
+ }
+
+ public SolidColorBrush CorDoSaldo
+ {
+ get
+ {
+ return _corDoSaldo;
+ }
+ set
+ {
+ _corDoSaldo = value;
+ OnPropertyChanged("CorDoSaldo");
+ }
+ }
+
+ public ObservableCollection<BancosContas> BancosContasFiltrados
+ {
+ get
+ {
+ return _bancosContasFiltrados;
+ }
+ set
+ {
+ _bancosContasFiltrados = value;
+ IsExpanded = value != null && value.Count > 0;
+ OnPropertyChanged("BancosContasFiltrados");
+ }
+ }
+
+ public bool IsExpanded
+ {
+ get
+ {
+ return _isExpanded;
+ }
+ set
+ {
+ _isExpanded = value;
+ OnPropertyChanged("IsExpanded");
+ }
+ }
+
+ public ObservableCollection<Saldo> Saldos
+ {
+ get
+ {
+ return _saldos;
+ }
+ set
+ {
+ _saldos = value;
+ if (value != null && value.Count > 0)
+ {
+ SelectedSaldo = ((IEnumerable<Saldo>)value).FirstOrDefault((Func<Saldo, bool>)((Saldo x) => !x.DataFinal.HasValue));
+ if (SelectedSaldo == null)
+ {
+ UltimoSladoNaoAberto();
+ }
+ }
+ OnPropertyChanged("Saldos");
+ }
+ }
+
+ public bool HabilitarFecharSaldo
+ {
+ get
+ {
+ return _habilitarFecharSaldo;
+ }
+ set
+ {
+ _habilitarFecharSaldo = value;
+ OnPropertyChanged("HabilitarFecharSaldo");
+ }
+ }
+
+ public Saldo SelectedSaldo
+ {
+ get
+ {
+ return _selectedSaldo;
+ }
+ set
+ {
+ _selectedSaldo = value;
+ int habilitarFecharSaldo;
+ if (value != null && !value.DataFinal.HasValue)
+ {
+ Usuario usuario = Recursos.Usuario;
+ habilitarFecharSaldo = ((usuario != null && ((DomainBase)usuario).Id > 0) ? 1 : 0);
+ }
+ else
+ {
+ habilitarFecharSaldo = 0;
+ }
+ HabilitarFecharSaldo = (byte)habilitarFecharSaldo != 0;
+ OnPropertyChanged("SelectedSaldo");
+ Saldo selectedSaldo = SelectedSaldo;
+ if (selectedSaldo != null)
+ {
+ ((DomainBase)selectedSaldo).Initialize();
+ }
+ }
+ }
+
+ public string SaldoAtual
+ {
+ get
+ {
+ return _saldoAtual;
+ }
+ set
+ {
+ _saldoAtual = value;
+ OnPropertyChanged("SaldoAtual");
+ }
+ }
+
+ public decimal? ValorAbertura
+ {
+ get
+ {
+ return _valorAbertura;
+ }
+ set
+ {
+ _valorAbertura = value;
+ OnPropertyChanged("ValorAbertura");
+ }
+ }
+
+ public DateTime? DataAbertura
+ {
+ get
+ {
+ return _dataAbertura;
+ }
+ set
+ {
+ _dataAbertura = value;
+ OnPropertyChanged("DataAbertura");
+ }
+ }
+
+ public bool Incluindo
+ {
+ get
+ {
+ return _incluindo;
+ }
+ set
+ {
+ _incluindo = value;
+ OnPropertyChanged("Incluindo");
+ }
+ }
+
+ public BancosContasViewModel()
+ {
+ //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_0010: Expected O, but got Unknown
+ //IL_0027: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0031: Expected O, but got Unknown
+ _bancosContasServico = new BancosContasServico();
+ Seleciona();
+ }
+
+ public async void CarregarSaldos(BancosContas banco)
+ {
+ if (banco == null || ((DomainBase)banco).Id == 0L)
+ {
+ return;
+ }
+ List<Saldo> source = await _bancosContasServico.BuscarSaldos(((DomainBase)banco).Id);
+ CorDoSaldo = new SolidColorBrush(Colors.Green);
+ SaldoAtual = string.Empty;
+ Saldos = new ObservableCollection<Saldo>(source.OrderByDescending((Saldo x) => x.DataInicio));
+ if (Saldos.FirstOrDefault() != null)
+ {
+ Saldo saldo = new Saldo
+ {
+ Conta = Saldos.First().Conta,
+ ValorInicio = Saldos.First().ValorInicio,
+ DataInicio = Saldos.First().DataInicio,
+ DataFinal = Funcoes.GetNetworkTime()
+ };
+ saldo = await _bancosContasServico.FecharSaldo(saldo);
+ decimal? valorFinal = saldo.ValorFinal;
+ if ((valorFinal.GetValueOrDefault() < default(decimal)) & valorFinal.HasValue)
+ {
+ CorDoSaldo = new SolidColorBrush(Colors.Red);
+ }
+ SaldoAtual = $"SALDO: {Math.Round(saldo.ValorFinal.GetValueOrDefault(), 2):c}";
+ }
+ }
+
+ private async void UltimoSladoNaoAberto()
+ {
+ Saldo ultimoSaldo = Saldos.ToList().Find(delegate(Saldo x)
+ {
+ DateTime? dataInicio = x.DataInicio;
+ DateTime? dateTime = Saldos.Max((Saldo r) => r.DataInicio);
+ if (dataInicio.HasValue != dateTime.HasValue)
+ {
+ return false;
+ }
+ return !dataInicio.HasValue || dataInicio.GetValueOrDefault() == dateTime.GetValueOrDefault();
+ });
+ bool flag = ultimoSaldo.DataFinal.HasValue;
+ if (flag)
+ {
+ flag = await ShowMessage("O ÚLTIMO SALDO NÃO ESTÁ ABERTO. DESEJA ABRÍ-LO AGORA?", "SIM", "NÃO");
+ }
+ if (flag)
+ {
+ ultimoSaldo.DataFinal = null;
+ ultimoSaldo.ValorFinal = null;
+ SelectedSaldo = await _bancosContasServico.Save(ultimoSaldo);
+ SelectedBancosContas = SelectedBancosContas;
+ }
+ }
+
+ private async void Seleciona()
+ {
+ Loading(isLoading: true);
+ await PermissaoTela((TipoTela)26);
+ await SelecionaBancosDeContas();
+ Loading(isLoading: false);
+ }
+
+ private async Task SelecionaBancosDeContas()
+ {
+ Loading(isLoading: true);
+ List<BancosContas> list = await _bancosContasServico.BuscarBancos();
+ BancosContas = (from x in list
+ orderby x.Ativo descending, x.Descricao
+ select x).ToList();
+ BancosContasFiltrados = new ObservableCollection<BancosContas>(BancosContas);
+ if (BancosContasFiltrados.Count > 0)
+ {
+ SelecionaBancosContas(BancosContasFiltrados.First());
+ }
+ else
+ {
+ SelectedBancosContas = new BancosContas();
+ Saldos = new ObservableCollection<Saldo>();
+ DataAbertura = null;
+ ValorAbertura = default(decimal);
+ SaldoAtual = "";
+ Alterar(alterar: false);
+ base.EnableMenu = false;
+ }
+ Recursos.BancosContas = list;
+ Loading(isLoading: false);
+ }
+
+ public void Incluir()
+ {
+ //IL_0040: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0045: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0051: Expected O, but got Unknown
+ _ultimoId = ((DomainBase)SelectedBancosContas).Id;
+ DataAbertura = null;
+ ValorAbertura = default(decimal);
+ SaldoAtual = "";
+ SelectedBancosContas = new BancosContas
+ {
+ Ativo = true
+ };
+ Saldos = new ObservableCollection<Saldo>();
+ SelectedSaldo = null;
+ Alterar(alterar: true);
+ }
+
+ public async Task<List<KeyValuePair<string, string>>> Salvar()
+ {
+ List<KeyValuePair<string, string>> list = SelectedBancosContas.Validate();
+ list.AddRange(Validate());
+ if (list.Count > 0)
+ {
+ return list;
+ }
+ BancosContas conta = await _bancosContasServico.Save(SelectedBancosContas);
+ if (!_bancosContasServico.Sucesso)
+ {
+ return null;
+ }
+ if (((DomainBase)SelectedBancosContas).Id == 0L && DataAbertura.HasValue && ValorAbertura.HasValue)
+ {
+ Saldo saldo = new Saldo
+ {
+ Conta = conta,
+ DataInicio = DataAbertura.Value,
+ ValorInicio = ValorAbertura.Value
+ };
+ await _bancosContasServico.Save(saldo);
+ if (!_bancosContasServico.Sucesso)
+ {
+ return null;
+ }
+ }
+ await SelecionaBancosDeContas();
+ SelecionaBancosContas(conta);
+ Recursos.BancosContas = BancosContas;
+ Alterar(alterar: false);
+ ToggleSnackBar("CONTA SALVA COM SUCESSO");
+ return null;
+ }
+
+ public List<KeyValuePair<string, string>> Validate()
+ {
+ List<KeyValuePair<string, string>> list = new List<KeyValuePair<string, string>>();
+ if (BancosContas.Where((BancosContas x) => x.Descricao == SelectedBancosContas.Descricao && ((DomainBase)x).Id != ((DomainBase)SelectedBancosContas).Id).Any())
+ {
+ ValidationHelper.AddValue<string, string>(list, "Descricao|DESCRIÇÃO", "NÃO É POSSÍVEL SALVAR MAIS DE UMA CONTA COM A MESMA DESCRIÇÃO.", true);
+ }
+ if (((DomainBase)SelectedBancosContas).Id == 0L)
+ {
+ if (!DataAbertura.HasValue)
+ {
+ ValidationHelper.AddValue<string, string>(list, "DataAbertura|ABERTURA", "É NECESSÁRIO PREENCHER A DATA DE ABERTURA DA CONTA.", true);
+ }
+ else if (DateTime.Compare(DataAbertura.Value, new DateTime(1753, 1, 1)) < 0 || DateTime.Compare(DataAbertura.Value, new DateTime(9999, 12, 31)) > 0)
+ {
+ ValidationHelper.AddValue<string, string>(list, "DataAbertura|ABERTURA", "DATA INVÁLIDA", true);
+ }
+ if (!ValorAbertura.HasValue)
+ {
+ ValidationHelper.AddValue<string, string>(list, "ValorAbertura|VALOR", "É NECESSÁRIO PREENCHER O VALOR DE ABERTURA DA CONTA.", true);
+ }
+ }
+ return list;
+ }
+
+ public async void CancelarAlteracao()
+ {
+ Loading(isLoading: true);
+ if (((DomainBase)SelectedBancosContas).Id > 0)
+ {
+ await SelecionaBancosDeContas();
+ }
+ SelecionaBancosContas(((IEnumerable<BancosContas>)BancosContasFiltrados).FirstOrDefault((Func<BancosContas, bool>)((BancosContas x) => ((DomainBase)x).Id == _ultimoId)) ?? BancosContasFiltrados.FirstOrDefault());
+ Alterar(alterar: false);
+ Loading(isLoading: false);
+ }
+
+ public async void Excluir()
+ {
+ if (SelectedBancosContas == null || ((DomainBase)SelectedBancosContas).Id == 0L)
+ {
+ return;
+ }
+ if (await new BaseServico().BancosContasUtilizado(((DomainBase)SelectedBancosContas).Id))
+ {
+ await ShowMessage("NÃO PODE SER EXCLUÍDO POIS ESTÁ SENDO UTILIZADO EM UM LANÇAMENTO.");
+ }
+ else if (await ShowMessage("DESEJA REALMENTE EXCLUIR A CONTA " + SelectedBancosContas.Descricao + " PERMANENTEMENTE?", "SIM", "NÃO"))
+ {
+ Loading(isLoading: true);
+ if (!(await _bancosContasServico.Delete(SelectedBancosContas)))
+ {
+ Loading(isLoading: false);
+ return;
+ }
+ await SelecionaBancosDeContas();
+ Loading(isLoading: false);
+ ToggleSnackBar("CONTA EXCLUÍDA COM SUCESSO");
+ }
+ }
+
+ public async void ExcluirSaldo()
+ {
+ if (SelectedSaldo == null || ((DomainBase)SelectedSaldo).Id == 0L)
+ {
+ return;
+ }
+ if (Saldos.Count <= 1)
+ {
+ await ShowMessage("NÃO É POSSÍVEL EXCLUIR O SALDO INICIAL DA CONTA.");
+ }
+ else
+ {
+ if (!(await ShowMessage("DESEJA REALMENTE EXCLUIR O SALDO PERMANENTEMENTE?", "SIM", "NÃO")))
+ {
+ return;
+ }
+ Loading(isLoading: true);
+ Saldo val = ((IEnumerable<Saldo>)Saldos).FirstOrDefault((Func<Saldo, bool>)delegate(Saldo x)
+ {
+ DateTime? dataFinal = x.DataFinal;
+ DateTime? dataInicio = SelectedSaldo.DataInicio;
+ if (dataFinal.HasValue != dataInicio.HasValue)
+ {
+ return false;
+ }
+ return !dataFinal.HasValue || dataFinal.GetValueOrDefault() == dataInicio.GetValueOrDefault();
+ });
+ if (val == null)
+ {
+ Loading(isLoading: false);
+ await ShowMessage("NÃO É POSSÍVEL EXCLUIR O SALDO DA CONTA.");
+ return;
+ }
+ val.DataFinal = null;
+ val.ValorFinal = null;
+ await _bancosContasServico.Save(val);
+ if (!_bancosContasServico.Sucesso)
+ {
+ Loading(isLoading: false);
+ return;
+ }
+ if (!(await _bancosContasServico.DeleteSaldo(SelectedSaldo)))
+ {
+ Loading(isLoading: false);
+ return;
+ }
+ CarregarSaldos(SelectedBancosContas);
+ Loading(isLoading: false);
+ ToggleSnackBar("SALDO EXCLUÍDO COM SUCESSO");
+ Loading(isLoading: false);
+ }
+ }
+
+ public void SelecionaBancosContas(BancosContas bancosContas)
+ {
+ Loading(isLoading: true);
+ SelectedBancosContas = ((IEnumerable<BancosContas>)BancosContasFiltrados).FirstOrDefault((Func<BancosContas, bool>)((BancosContas x) => ((DomainBase)x).Id == ((DomainBase)bancosContas).Id));
+ Loading(isLoading: false);
+ }
+
+ internal async Task<List<BancosContas>> Filtrar(string value)
+ {
+ return await Task.Run(() => FiltrarBancosContas(value));
+ }
+
+ public List<BancosContas> FiltrarBancosContas(string filter)
+ {
+ BancosContasFiltrados = (string.IsNullOrWhiteSpace(filter) ? new ObservableCollection<BancosContas>(BancosContas) : new ObservableCollection<BancosContas>(from x in BancosContas
+ where ValidationHelper.RemoveDiacritics(x.Descricao.Trim()).ToUpper().Contains(ValidationHelper.RemoveDiacritics(filter))
+ orderby x.Ativo descending, x.Descricao
+ select x));
+ return BancosContasFiltrados.ToList();
+ }
+
+ public async Task FecharSaldo()
+ {
+ SelectedSaldo = await _bancosContasServico.Save(SelectedSaldo);
+ if (!_bancosContasServico.Sucesso)
+ {
+ return;
+ }
+ if (SelectedSaldo.DataFinal.HasValue && SelectedSaldo.ValorFinal.HasValue)
+ {
+ Saldo saldo = new Saldo
+ {
+ Conta = SelectedSaldo.Conta,
+ DataFinal = null,
+ DataInicio = SelectedSaldo.DataFinal.Value,
+ ValorFinal = null,
+ ValorInicio = SelectedSaldo.ValorFinal.Value
+ };
+ await _bancosContasServico.Save(saldo);
+ if (!_bancosContasServico.Sucesso)
+ {
+ return;
+ }
+ }
+ CarregarSaldos(SelectedBancosContas);
+ ToggleSnackBar("SALDO FECHADO COM SUCESSO");
+ }
+
+ public async Task<decimal> CalcularValor()
+ {
+ return (await _bancosContasServico.FecharSaldo(SelectedSaldo)).ValorFinal.GetValueOrDefault();
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Financeiro/CentroDeCustoViewmodel.cs b/Decompiler/Gestor.Application.ViewModels.Financeiro/CentroDeCustoViewmodel.cs
new file mode 100644
index 0000000..8f7427a
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Financeiro/CentroDeCustoViewmodel.cs
@@ -0,0 +1,219 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Threading.Tasks;
+using Gestor.Application.Servicos.Financeiro;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Application.ViewModels.Generic;
+using Gestor.Common.Validation;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Financeiro;
+using Gestor.Model.Domain.Generic;
+
+namespace Gestor.Application.ViewModels.Financeiro;
+
+public class CentroDeCustoViewmodel : BaseFinanceiroViewModel
+{
+ private readonly CentroServico _centroServico;
+
+ private ObservableCollection<Centro> _centrosFiltrados = new ObservableCollection<Centro>();
+
+ private bool _isExpanded;
+
+ private Centro _selectedCentro;
+
+ private bool _ativo;
+
+ private long _ultimoId;
+
+ public Centro CancelCentro;
+
+ public List<Centro> Centros { get; set; }
+
+ public ObservableCollection<Centro> CentrosFiltrados
+ {
+ get
+ {
+ return _centrosFiltrados;
+ }
+ set
+ {
+ _centrosFiltrados = value;
+ IsExpanded = value != null && value.Count > 0;
+ OnPropertyChanged("CentrosFiltrados");
+ }
+ }
+
+ public bool IsExpanded
+ {
+ get
+ {
+ return _isExpanded;
+ }
+ set
+ {
+ _isExpanded = value;
+ OnPropertyChanged("IsExpanded");
+ }
+ }
+
+ public Centro SelectedCentro
+ {
+ get
+ {
+ return _selectedCentro;
+ }
+ set
+ {
+ _selectedCentro = value;
+ if (((DomainBase)value).Id > 0)
+ {
+ _ultimoId = ((DomainBase)value).Id;
+ }
+ VerificarEnables(((DomainBase)value).Id);
+ OnPropertyChanged("SelectedCentro");
+ }
+ }
+
+ public bool Ativo
+ {
+ get
+ {
+ return _ativo;
+ }
+ set
+ {
+ _ativo = bool.Parse(value.ToString());
+ OnPropertyChanged("Ativo");
+ }
+ }
+
+ public CentroDeCustoViewmodel()
+ {
+ _centroServico = new CentroServico();
+ base.EnableMenu = true;
+ Seleciona();
+ }
+
+ private async void Seleciona()
+ {
+ Loading(isLoading: true);
+ await PermissaoTela((TipoTela)29);
+ await SelecionaCentro();
+ await SelecionaCentro(CentrosFiltrados.FirstOrDefault());
+ Loading(isLoading: false);
+ }
+
+ private async Task SelecionaCentro(Centro centros)
+ {
+ if (centros == null)
+ {
+ Alterar(alterar: false);
+ base.EnableMenu = false;
+ base.EnableAlterar = false;
+ return;
+ }
+ Loading(isLoading: true);
+ List<Centro> source = await new BaseServico().BuscarCentroAsync();
+ DomainBase.Copy<Centro, Centro>(CentrosFiltrados.First((Centro x) => ((DomainBase)x).Id == ((DomainBase)centros).Id), source.First((Centro x) => ((DomainBase)x).Id == ((DomainBase)centros).Id));
+ SelectedCentro = CentrosFiltrados.First((Centro x) => ((DomainBase)x).Id == ((DomainBase)centros).Id);
+ Loading(isLoading: false);
+ }
+
+ public void SelecionaCentroDeCusto(Centro centro)
+ {
+ SelectedCentro = CentrosFiltrados.First((Centro x) => ((DomainBase)x).Id == ((DomainBase)centro).Id);
+ }
+
+ public void Incluir()
+ {
+ //IL_001a: Unknown result type (might be due to invalid IL or missing references)
+ //IL_001f: Unknown result type (might be due to invalid IL or missing references)
+ //IL_002b: Expected O, but got Unknown
+ Centro selectedCentro = SelectedCentro;
+ _ultimoId = ((selectedCentro != null) ? ((DomainBase)selectedCentro).Id : 0);
+ SelectedCentro = new Centro
+ {
+ Ativo = true
+ };
+ Alterar(alterar: true);
+ }
+
+ public async Task<List<KeyValuePair<string, string>>> Validate()
+ {
+ List<KeyValuePair<string, string>> errors = new List<KeyValuePair<string, string>>();
+ bool valida = true;
+ List<Centro> list = await new BaseServico().BuscarCentroAsync();
+ if (list.Count > 0)
+ {
+ list.ForEach(delegate(Centro x)
+ {
+ if (((DomainBase)x).Id != ((DomainBase)SelectedCentro).Id && x.Descricao == SelectedCentro.Descricao && x.IdEmpresa == SelectedCentro.IdEmpresa)
+ {
+ valida = false;
+ }
+ });
+ }
+ if (!valida)
+ {
+ errors.Add(new KeyValuePair<string, string>("Descricao", "UM CENTRO COM ESSE NOME JÁ EXISTE."));
+ }
+ return errors;
+ }
+
+ public async Task<List<KeyValuePair<string, string>>> Salvar()
+ {
+ List<KeyValuePair<string, string>> errorMessages = SelectedCentro.Validate();
+ List<KeyValuePair<string, string>> list = errorMessages;
+ list.AddRange(await Validate());
+ if (errorMessages.Count > 0)
+ {
+ return errorMessages;
+ }
+ SelectedCentro = await _centroServico.Save(SelectedCentro);
+ if (!_centroServico.Sucesso)
+ {
+ return null;
+ }
+ await SelecionaCentro();
+ await SelecionaCentro(CentrosFiltrados.First((Centro x) => ((DomainBase)x).Id == ((DomainBase)SelectedCentro).Id));
+ Alterar(alterar: false);
+ ToggleSnackBar("CENTRO DE CUSTO SALVO COM SUCESSO");
+ return null;
+ }
+
+ public async void CancelarAlteracao()
+ {
+ Loading(isLoading: true);
+ Alterar(alterar: false);
+ if (((DomainBase)SelectedCentro).Id > 0)
+ {
+ await SelecionaCentro();
+ }
+ await SelecionaCentro(((IEnumerable<Centro>)CentrosFiltrados).FirstOrDefault((Func<Centro, bool>)((Centro x) => ((DomainBase)x).Id == _ultimoId)));
+ Loading(isLoading: false);
+ }
+
+ private async Task SelecionaCentro()
+ {
+ Centros = (from x in await new BaseServico().BuscarCentroAsync()
+ orderby x.Ativo descending, x.Descricao, x.Descricao
+ select x).ToList();
+ CentrosFiltrados = new ObservableCollection<Centro>(Centros);
+ }
+
+ public async Task<List<Centro>> Filtrar(string value)
+ {
+ return await Task.Run(() => FiltrarCentro(value));
+ }
+
+ public List<Centro> FiltrarCentro(string filter)
+ {
+ CentrosFiltrados = (string.IsNullOrWhiteSpace(filter) ? new ObservableCollection<Centro>(Centros) : new ObservableCollection<Centro>(from x in Centros
+ where ValidationHelper.RemoveDiacritics(x.Descricao.Trim()).ToUpper().Contains(ValidationHelper.RemoveDiacritics(filter))
+ orderby Ativo descending, x.Descricao
+ select x));
+ return CentrosFiltrados.ToList();
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Financeiro/ContasDialogModel.cs b/Decompiler/Gestor.Application.ViewModels.Financeiro/ContasDialogModel.cs
new file mode 100644
index 0000000..16dc049
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Financeiro/ContasDialogModel.cs
@@ -0,0 +1,46 @@
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using Gestor.Application.ViewModels.Generic;
+using Gestor.Model.Domain.Financeiro;
+
+namespace Gestor.Application.ViewModels.Financeiro;
+
+public class ContasDialogModel : BaseViewModel
+{
+ private ObservableCollection<BancosContas> _contasFiltradas;
+
+ private BancosContas _conta;
+
+ public ObservableCollection<BancosContas> ContasFiltradas
+ {
+ get
+ {
+ return _contasFiltradas;
+ }
+ set
+ {
+ _contasFiltradas = value;
+ OnPropertyChanged("ContasFiltradas");
+ }
+ }
+
+ public BancosContas Conta
+ {
+ get
+ {
+ return _conta;
+ }
+ set
+ {
+ _conta = value;
+ OnPropertyChanged("Conta");
+ }
+ }
+
+ public ContasDialogModel(List<BancosContas> contas)
+ {
+ ContasFiltradas = new ObservableCollection<BancosContas>(contas);
+ Conta = ContasFiltradas.FirstOrDefault();
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Financeiro/CopiarClienteViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Financeiro/CopiarClienteViewModel.cs
new file mode 100644
index 0000000..d6702d5
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Financeiro/CopiarClienteViewModel.cs
@@ -0,0 +1,22 @@
+using Gestor.Application.ViewModels.Generic;
+using Gestor.Model.Domain.Seguros;
+
+namespace Gestor.Application.ViewModels.Financeiro;
+
+public class CopiarClienteViewModel : BaseSegurosViewModel
+{
+ private Cliente _selectedCliente;
+
+ public Cliente SelectedCliente
+ {
+ get
+ {
+ return _selectedCliente;
+ }
+ set
+ {
+ _selectedCliente = value;
+ OnPropertyChanged("SelectedCliente");
+ }
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Financeiro/ExtratoContaViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Financeiro/ExtratoContaViewModel.cs
new file mode 100644
index 0000000..6c57232
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Financeiro/ExtratoContaViewModel.cs
@@ -0,0 +1,408 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Forms;
+using System.Windows.Media;
+using ClosedXML.Excel;
+using Gestor.Application.Helpers;
+using Gestor.Application.Servicos.Financeiro;
+using Gestor.Application.ViewModels.Generic;
+using Gestor.Common.Helpers;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Configuracoes;
+using Gestor.Model.Domain.Financeiro;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Relatorios;
+
+namespace Gestor.Application.ViewModels.Financeiro;
+
+public class ExtratoContaViewModel : BaseFinanceiroViewModel
+{
+ private Geometry _maximizeRestore = Geometry.Parse((string)Application.Current.Resources[(object)"Restore"]);
+
+ private string _head;
+
+ private readonly FinanceiroServico _servico;
+
+ private ObservableCollection<BancosContas> _contas;
+
+ private ObservableCollection<BancosContas> _contasFilter;
+
+ private BancosContas _selectedConta;
+
+ private DateTime? _inicio = new DateTime(Funcoes.GetNetworkTime().Date.Year, Funcoes.GetNetworkTime().Date.Month, 1);
+
+ private DateTime? _fim = Funcoes.GetNetworkTime();
+
+ private static ObservableCollection<string> _bancosContas = new ObservableCollection<string> { "TODOS", "ATIVOS", "INATIVOS" };
+
+ private string _selectedBancosContas = "TODOS";
+
+ private ObservableCollection<ExtratoConta> _extrato;
+
+ private bool _saldoFinal;
+
+ private bool _naoHaDados;
+
+ public Geometry MaximizeRestore
+ {
+ get
+ {
+ return _maximizeRestore;
+ }
+ set
+ {
+ _maximizeRestore = value;
+ OnPropertyChanged("MaximizeRestore");
+ }
+ }
+
+ public string Head
+ {
+ get
+ {
+ return _head;
+ }
+ set
+ {
+ _head = value;
+ OnPropertyChanged("Head");
+ }
+ }
+
+ public ObservableCollection<BancosContas> Contas
+ {
+ get
+ {
+ return _contas;
+ }
+ set
+ {
+ _contas = value;
+ OnPropertyChanged("Contas");
+ }
+ }
+
+ public ObservableCollection<BancosContas> ContasFilter
+ {
+ get
+ {
+ return _contasFilter;
+ }
+ set
+ {
+ _contasFilter = value;
+ OnPropertyChanged("ContasFilter");
+ }
+ }
+
+ public BancosContas SelectedConta
+ {
+ get
+ {
+ return _selectedConta;
+ }
+ set
+ {
+ _selectedConta = value;
+ OnPropertyChanged("SelectedConta");
+ }
+ }
+
+ public DateTime? Inicio
+ {
+ get
+ {
+ return _inicio;
+ }
+ set
+ {
+ _inicio = value;
+ OnPropertyChanged("Inicio");
+ }
+ }
+
+ public DateTime? Fim
+ {
+ get
+ {
+ return _fim;
+ }
+ set
+ {
+ _fim = value;
+ OnPropertyChanged("Fim");
+ }
+ }
+
+ public ObservableCollection<string> BancosContas
+ {
+ get
+ {
+ return _bancosContas;
+ }
+ set
+ {
+ _bancosContas = value;
+ OnPropertyChanged("BancosContas");
+ }
+ }
+
+ public string SelectedBancosContas
+ {
+ get
+ {
+ return _selectedBancosContas;
+ }
+ set
+ {
+ _selectedBancosContas = value;
+ if (value == null || Contas == null || Contas.Count <= 0)
+ {
+ return;
+ }
+ switch (value)
+ {
+ case "TODOS":
+ ContasFilter = Contas;
+ break;
+ case "ATIVOS":
+ ContasFilter = new ObservableCollection<BancosContas>(Contas.Where((BancosContas x) => x.Ativo).ToList());
+ break;
+ case "INATIVOS":
+ ContasFilter = new ObservableCollection<BancosContas>(Contas.Where((BancosContas x) => !x.Ativo).ToList());
+ break;
+ }
+ OnPropertyChanged("SelectedBancosContas");
+ }
+ }
+
+ public ObservableCollection<ExtratoConta> Extrato
+ {
+ get
+ {
+ return _extrato;
+ }
+ set
+ {
+ _extrato = value;
+ NaoHaDados = value == null || value.Count == 0;
+ OnPropertyChanged("Extrato");
+ }
+ }
+
+ public bool SaldoFinal
+ {
+ get
+ {
+ return _saldoFinal;
+ }
+ set
+ {
+ _saldoFinal = value;
+ OnPropertyChanged("SaldoFinal");
+ }
+ }
+
+ public bool NaoHaDados
+ {
+ get
+ {
+ return _naoHaDados;
+ }
+ set
+ {
+ _naoHaDados = value;
+ OnPropertyChanged("NaoHaDados");
+ }
+ }
+
+ public ExtratoContaViewModel(long id)
+ {
+ _servico = new FinanceiroServico();
+ BuscaInicial(id);
+ }
+
+ private async void BuscaInicial(long id)
+ {
+ Loading(isLoading: true);
+ List<BancosContas> source = await new BancosContasServico().BuscarBancos();
+ Contas = new ObservableCollection<BancosContas>(source.OrderBy((BancosContas x) => x.Descricao));
+ ContasFilter = new ObservableCollection<BancosContas>(source.OrderBy((BancosContas x) => x.Descricao));
+ SelectedConta = ((id > 0) ? ((IEnumerable<BancosContas>)Contas).FirstOrDefault((Func<BancosContas, bool>)((BancosContas x) => ((DomainBase)x).Id == id)) : Contas.FirstOrDefault());
+ await GerarRelatorio();
+ Loading(isLoading: false);
+ }
+
+ public void LimparRelatorio()
+ {
+ Extrato = null;
+ }
+
+ public async Task GerarRelatorio()
+ {
+ if (SelectedConta == null || ((DomainBase)SelectedConta).Id == 0L || !Inicio.HasValue || !Fim.HasValue)
+ {
+ return;
+ }
+ BancosContasServico servico = new BancosContasServico();
+ Saldo val = await servico.BuscarSaldoInicial(((DomainBase)SelectedConta).Id);
+ if (((val != null) ? val.DataInicio : null) > Inicio)
+ {
+ ShowMessage("DATA DE INÍCIO É MENOR QUE A CRIAÇÃO DA CONTA " + val.Conta.Descricao + ",\nDATA DE ABERTURA " + val.DataInicio?.ToString("dd/MM/yyyy"));
+ NaoHaDados = true;
+ return;
+ }
+ List<ExtratoConta> lancamentos = await _servico.BuscarLancamentosPorConta(Inicio.Value, Fim.Value, ((DomainBase)SelectedConta).Id);
+ Saldo val2 = await servico.BuscarSaldo(Inicio.Value, ((DomainBase)SelectedConta).Id);
+ if (lancamentos.Count == 0)
+ {
+ NaoHaDados = true;
+ return;
+ }
+ if (val2 == null)
+ {
+ val2 = new Saldo
+ {
+ Conta = SelectedConta,
+ DataInicio = Inicio,
+ ValorInicio = 0m
+ };
+ }
+ val2.DataFinal = Inicio.Value;
+ val2.ValorFinal = default(decimal);
+ val2 = await servico.FecharSaldo(val2);
+ List<ExtratoConta> extrato = new List<ExtratoConta>();
+ ExtratoConta val3 = new ExtratoConta
+ {
+ Baixa = Inicio.Value,
+ Fornecedor = "SALDO INICIAL",
+ Valor = val2.ValorFinal.GetValueOrDefault(),
+ Sinal = (Sinal)((val2.ValorFinal.GetValueOrDefault() < 0m) ? 1 : 0),
+ Bold = true
+ };
+ extrato.Add(val3);
+ decimal? saldoDia = val3.Valor;
+ (from x in lancamentos
+ orderby x.Baixa
+ group x by x.Baixa).ToList().ForEach(delegate(IGrouping<DateTime?, ExtratoConta> g)
+ {
+ //IL_002a: Unknown result type (might be due to invalid IL or missing references)
+ //IL_002f: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0040: Unknown result type (might be due to invalid IL or missing references)
+ //IL_004b: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00b4: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0143: Unknown result type (might be due to invalid IL or missing references)
+ //IL_014b: Expected O, but got Unknown
+ List<ExtratoConta> list2 = lancamentos.Where(delegate(ExtratoConta x)
+ {
+ DateTime? baixa = x.Baixa;
+ DateTime? key = g.Key;
+ if (baixa.HasValue != key.HasValue)
+ {
+ return false;
+ }
+ return !baixa.HasValue || baixa.GetValueOrDefault() == key.GetValueOrDefault();
+ }).ToList();
+ ExtratoConta val5 = new ExtratoConta
+ {
+ Baixa = g.Key,
+ Fornecedor = "SALDO FINAL DO DIA",
+ Valor = saldoDia + list2.Sum((ExtratoConta x) => x.Valor)
+ };
+ decimal? num2 = saldoDia + list2.Sum((ExtratoConta x) => x.Valor);
+ val5.Sinal = (Sinal)(((num2.GetValueOrDefault() < default(decimal)) & num2.HasValue) ? 1 : 0);
+ val5.Bold = true;
+ ExtratoConta val6 = val5;
+ if (!SaldoFinal)
+ {
+ extrato.AddRange(list2);
+ }
+ extrato.Add(val6);
+ saldoDia = val6.Valor;
+ });
+ List<ExtratoConta> list = extrato;
+ ExtratoConta val4 = new ExtratoConta
+ {
+ Baixa = Fim.Value,
+ Fornecedor = "SALDO FINAL",
+ Valor = saldoDia
+ };
+ decimal? num = saldoDia;
+ val4.Sinal = (Sinal)(((num.GetValueOrDefault() < default(decimal)) & num.HasValue) ? 1 : 0);
+ val4.Bold = true;
+ list.Add(val4);
+ Extrato = new ObservableCollection<ExtratoConta>(extrato);
+ }
+
+ public async Task Print()
+ {
+ if (Extrato == null || Extrato.Count == 0)
+ {
+ ShowMessage("NÃO HÁ DADOS PARA A IMPRESSÃO");
+ return;
+ }
+ string dados = await Funcoes.GenerateTable(Extrato.ToList(), new List<string>());
+ TipoRelatorio val = new TipoRelatorio
+ {
+ Nome = "EXTRATO CONTA - " + SelectedConta.Descricao,
+ Inicio = (Inicio ?? DateTime.MinValue),
+ Fim = (Fim ?? DateTime.MinValue)
+ };
+ val.Nome = ((val.Nome.Length < 30) ? val.Nome : val.Nome.Substring(0, 30));
+ string value = Funcoes.ExportarHtml(val, dados, "60", "portrait");
+ string tempPath = Path.GetTempPath();
+ string text = string.Format("{0}{1}_{2:ddMMyyyyhhmmss}.html", tempPath, new Regex("[" + Regex.Escape(new string(Path.GetInvalidFileNameChars()) + new string(Path.GetInvalidPathChars())) + "]").Replace(val.Nome, ""), Funcoes.GetNetworkTime());
+ StreamWriter streamWriter = new StreamWriter(text, append: true, Encoding.UTF8);
+ streamWriter.Write(value);
+ streamWriter.Close();
+ Process.Start(text);
+ }
+
+ public async Task GerarExcel()
+ {
+ if (Extrato == null || Extrato.Count == 0)
+ {
+ ShowMessage("NÃO HÁ DADOS PARA A IMPRESSÃO EM EXCEL");
+ return;
+ }
+ List<ExtratoConta> analitico = Extrato.ToList();
+ string text = "";
+ string fileName;
+ if (Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 41))
+ {
+ FolderBrowserDialog val = new FolderBrowserDialog();
+ try
+ {
+ if (1 != (int)((CommonDialog)val).ShowDialog())
+ {
+ return;
+ }
+ text = val.SelectedPath + "\\";
+ Directory.CreateDirectory(text);
+ }
+ finally
+ {
+ ((IDisposable)val)?.Dispose();
+ }
+ fileName = text + "EXTRATO CONTA - " + SelectedConta.Descricao + " " + Functions.GetNetworkTime().Date.ToShortDateString().Replace("/", "") + ".xlsx";
+ }
+ else
+ {
+ text = Path.GetTempPath();
+ fileName = $"{text}{Guid.NewGuid()}.xlsx";
+ }
+ XLWorkbook val2 = new XLWorkbook();
+ string text2 = "EXTRATO CONTA - " + SelectedConta.Descricao;
+ text2 = ((text2.Length < 30) ? text2 : text2.Substring(0, 30));
+ (await Funcoes.GerarXls(val2, text2, analitico, new List<string>())).SaveAs(fileName);
+ Process.Start(fileName);
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Financeiro/FinanceiroViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Financeiro/FinanceiroViewModel.cs
new file mode 100644
index 0000000..61db9ae
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Financeiro/FinanceiroViewModel.cs
@@ -0,0 +1,4400 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Diagnostics;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Forms;
+using ClosedXML.Excel;
+using CsQuery.ExtensionMethods;
+using Gestor.Application.Actions;
+using Gestor.Application.Helpers;
+using Gestor.Application.Servicos.Financeiro;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Application.ViewModels.Generic;
+using Gestor.Application.Views.Relatorios;
+using Gestor.Common.Helpers;
+using Gestor.Common.Validation;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Configuracoes;
+using Gestor.Model.Domain.Financeiro;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Relatorios;
+using Gestor.Model.Domain.Seguros;
+using Gestor.Model.Helper;
+using OfxSharpLib;
+
+namespace Gestor.Application.ViewModels.Financeiro;
+
+public class FinanceiroViewModel : BaseFinanceiroViewModel
+{
+ private readonly FinanceiroServico _servico;
+
+ private bool _enableIncluirNovo;
+
+ private bool _enableChanges;
+
+ private SinteticoFinanceiroTipo _sinteticoTipo;
+
+ private Visibility _isVisibleData;
+
+ private Visibility _isVisibleFornecedor = (Visibility)2;
+
+ private Visibility _isVisiblePersonalizado = (Visibility)2;
+
+ private Visibility _isVisibleFiltros = (Visibility)2;
+
+ private Visibility _isVisibleLancamento;
+
+ private Visibility _isvisibleStatus;
+
+ private FiltroLancamento _selectedFiltro;
+
+ private FiltroLancamentoData _selectedFiltroData;
+
+ private StatusLancamento _selectedStatus;
+
+ private StatusLancamento _selectedStatusImportacao = (StatusLancamento)2;
+
+ private Visibility _botaoSalvarVisibility;
+
+ private DateTime? _inicio = Funcoes.GetNetworkTime();
+
+ private DateTime? _fim = Funcoes.GetNetworkTime().AddDays(7.0);
+
+ private Fornecedor _selectedFornecedor;
+
+ private ObservableCollection<Saldo> _saldos = new ObservableCollection<Saldo>();
+
+ private Saldo _selectedSaldo = new Saldo();
+
+ private ObservableCollection<Lancamento> _lancamentos = new ObservableCollection<Lancamento>();
+
+ private bool _dontSort;
+
+ private ObservableCollection<Lancamento> _lancamentosFiltrados = new ObservableCollection<Lancamento>();
+
+ private ObservableCollection<Lancamento> _lancamentosFiltradosCopia = new ObservableCollection<Lancamento>();
+
+ private ObservableCollection<Lancamento> _lancamentosVinculo = new ObservableCollection<Lancamento>();
+
+ private Lancamento _lancamentoVinculo;
+
+ private Lancamento _selectedLancamento;
+
+ private Fornecedor _fornecedorInclusao;
+
+ private long _idLancamento;
+
+ private string _historico;
+
+ private string _observacao;
+
+ private string _documento;
+
+ private string _complemento;
+
+ private string _competencia;
+
+ private int _parcela;
+
+ private double _dropDownHeight;
+
+ private int _parcelas;
+
+ public bool VencimentoAlterado;
+
+ private DateTime _vencimento;
+
+ private DateTime? _baixa;
+
+ private DateTime? _pagamento;
+
+ private decimal _valor;
+
+ private decimal? _valorPago;
+
+ private Sinal _sinal;
+
+ private Planos _plano;
+
+ private Centro _centro;
+
+ private BancosContas _conta;
+
+ private TipoPagamento _tipoPagamento;
+
+ private List<Planos> _planosFiltro;
+
+ private List<Centro> _centroFiltro;
+
+ private List<BancosContas> _contaFiltro;
+
+ private List<Planos> _planos;
+
+ private ObservableCollection<Planos> _planosFiltrados;
+
+ private List<BancosContas> _contas;
+
+ private ObservableCollection<BancosContas> _contasFiltradas;
+
+ private List<Centro> _centros;
+
+ private ObservableCollection<Centro> _centrosFiltrados;
+
+ private ObservableCollection<SinteticoFinanceiro> _totalizacao;
+
+ private Visibility _visibilityFornecedor;
+
+ private Visibility _visibilityCentro;
+
+ private Visibility _visibilityConta;
+
+ private Visibility _alterando = (Visibility)2;
+
+ private bool _buscaHabilitada = true;
+
+ private bool _alteracao = true;
+
+ private List<FiltroPersonalizado> _filtroRelatorioPersonalizado;
+
+ private List<FiltroPersonalizado> _filtros;
+
+ private ObservableCollection<FiltroPersonalizado> _personalizadoSelecionado;
+
+ private ObservableCollection<FiltroPersonalizado> _filtroRelatorioSelecionado = new ObservableCollection<FiltroPersonalizado>();
+
+ private Visibility _visibilitySemValor = (Visibility)2;
+
+ private FiltroPersonalizado _filtro;
+
+ private Type _tipoString = typeof(string);
+
+ private Type _tipoEnum = typeof(Enum);
+
+ private Type _tipoDateTime = typeof(DateTime);
+
+ private Type _tipoDecimal = typeof(decimal);
+
+ private Type _tipoInt = typeof(int);
+
+ private Type _tipoLong = typeof(long);
+
+ private string _valorIncial = "";
+
+ private string _valorFinal = "";
+
+ private bool _semValor;
+
+ private List<FiltroPersonalizado> _filtroPersonalizado;
+
+ private ObservableCollection<FiltroPersonalizado> _filtroPersonalizadoSelecionado = new ObservableCollection<FiltroPersonalizado>();
+
+ private Visibility _visibleFiltros = (Visibility)2;
+
+ private Visibility _visibleOlho = (Visibility)2;
+
+ private bool importando;
+
+ private bool _isExpanded;
+
+ public bool EnableIncluirNovo
+ {
+ get
+ {
+ return _enableIncluirNovo;
+ }
+ set
+ {
+ _enableIncluirNovo = value;
+ OnPropertyChanged("EnableIncluirNovo");
+ }
+ }
+
+ public bool EnableChanges
+ {
+ get
+ {
+ return _enableChanges;
+ }
+ set
+ {
+ _enableChanges = value;
+ OnPropertyChanged("EnableChanges");
+ }
+ }
+
+ public SinteticoFinanceiroTipo SinteticoTipo
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _sinteticoTipo;
+ }
+ set
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0002: Unknown result type (might be due to invalid IL or missing references)
+ _sinteticoTipo = value;
+ OnPropertyChanged("SinteticoTipo");
+ }
+ }
+
+ public Visibility IsVisibleData
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _isVisibleData;
+ }
+ set
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0002: Unknown result type (might be due to invalid IL or missing references)
+ _isVisibleData = value;
+ OnPropertyChanged("IsVisibleData");
+ }
+ }
+
+ public Visibility IsVisibleFornecedor
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _isVisibleFornecedor;
+ }
+ set
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0002: Unknown result type (might be due to invalid IL or missing references)
+ _isVisibleFornecedor = value;
+ OnPropertyChanged("IsVisibleFornecedor");
+ }
+ }
+
+ public Visibility IsVisiblePersonalizado
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _isVisiblePersonalizado;
+ }
+ set
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0002: Unknown result type (might be due to invalid IL or missing references)
+ _isVisiblePersonalizado = value;
+ OnPropertyChanged("IsVisiblePersonalizado");
+ }
+ }
+
+ public Visibility IsVisibleFiltros
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _isVisibleFiltros;
+ }
+ set
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0002: Unknown result type (might be due to invalid IL or missing references)
+ _isVisibleFiltros = value;
+ OnPropertyChanged("IsVisibleFiltros");
+ }
+ }
+
+ public Visibility IsVisibleLancamento
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _isVisibleLancamento;
+ }
+ set
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0002: Unknown result type (might be due to invalid IL or missing references)
+ _isVisibleLancamento = value;
+ OnPropertyChanged("IsVisibleLancamento");
+ }
+ }
+
+ public Visibility IsvisibleStatus
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _isvisibleStatus;
+ }
+ set
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0002: Unknown result type (might be due to invalid IL or missing references)
+ _isvisibleStatus = value;
+ OnPropertyChanged("IsvisibleStatus");
+ }
+ }
+
+ public FiltroLancamento SelectedFiltro
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _selectedFiltro;
+ }
+ set
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0002: Unknown result type (might be due to invalid IL or missing references)
+ _selectedFiltro = value;
+ LimparLancamentos();
+ OnPropertyChanged("SelectedFiltro");
+ }
+ }
+
+ public FiltroLancamentoData SelectedFiltroData
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _selectedFiltroData;
+ }
+ set
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0002: Unknown result type (might be due to invalid IL or missing references)
+ _selectedFiltroData = value;
+ LimparLancamentos();
+ OnPropertyChanged("SelectedFiltroData");
+ }
+ }
+
+ public StatusLancamento SelectedStatus
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _selectedStatus;
+ }
+ set
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0002: Unknown result type (might be due to invalid IL or missing references)
+ _selectedStatus = value;
+ LimparLancamentos();
+ OnPropertyChanged("SelectedStatus");
+ }
+ }
+
+ public StatusLancamento SelectedStatusImportacao
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _selectedStatusImportacao;
+ }
+ set
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0002: Unknown result type (might be due to invalid IL or missing references)
+ _selectedStatusImportacao = value;
+ OnPropertyChanged("SelectedStatusImportacao");
+ }
+ }
+
+ public Visibility BotaoSalvarVisibility
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _isvisibleStatus;
+ }
+ set
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0002: Unknown result type (might be due to invalid IL or missing references)
+ _isvisibleStatus = value;
+ OnPropertyChanged("BotaoSalvarVisibility");
+ }
+ }
+
+ public DateTime? Inicio
+ {
+ get
+ {
+ return _inicio;
+ }
+ set
+ {
+ if (value.HasValue && value.Value < new DateTime(1754, 1, 1))
+ {
+ value = new DateTime(1754, 1, 1);
+ }
+ if (value.HasValue && value.Value > new DateTime(9999, 12, 31))
+ {
+ value = new DateTime(9999, 12, 31);
+ }
+ _inicio = value;
+ OnPropertyChanged("Inicio");
+ }
+ }
+
+ public DateTime? Fim
+ {
+ get
+ {
+ return _fim;
+ }
+ set
+ {
+ if (value.HasValue && value.Value < new DateTime(1754, 1, 1))
+ {
+ value = new DateTime(1754, 1, 1);
+ }
+ if (value.HasValue && value.Value > new DateTime(9999, 12, 31))
+ {
+ value = new DateTime(9999, 12, 31);
+ }
+ _fim = value;
+ OnPropertyChanged("Fim");
+ }
+ }
+
+ public Fornecedor SelectedFornecedor
+ {
+ get
+ {
+ return _selectedFornecedor;
+ }
+ set
+ {
+ _selectedFornecedor = value;
+ LimparLancamentos();
+ OnPropertyChanged("SelectedFornecedor");
+ }
+ }
+
+ public ObservableCollection<Saldo> Saldos
+ {
+ get
+ {
+ return _saldos;
+ }
+ set
+ {
+ _saldos = value;
+ OnPropertyChanged("Saldos");
+ }
+ }
+
+ public Saldo SelectedSaldo
+ {
+ get
+ {
+ return _selectedSaldo;
+ }
+ set
+ {
+ _selectedSaldo = value;
+ OnPropertyChanged("SelectedSaldo");
+ }
+ }
+
+ public ObservableCollection<Lancamento> Lancamentos
+ {
+ get
+ {
+ return _lancamentos;
+ }
+ set
+ {
+ _lancamentos = value;
+ OnPropertyChanged("Lancamentos");
+ }
+ }
+
+ public ObservableCollection<Lancamento> LancamentosFiltrados
+ {
+ get
+ {
+ return _lancamentosFiltrados;
+ }
+ set
+ {
+ if (!_dontSort)
+ {
+ Gestor.Application.Actions.Actions.SaveSortLancamentos?.Invoke();
+ }
+ _lancamentosFiltrados = value;
+ Totalizar();
+ OnPropertyChanged("LancamentosFiltrados");
+ if (!_dontSort)
+ {
+ Gestor.Application.Actions.Actions.SortLancamentos?.Invoke();
+ }
+ }
+ }
+
+ public ObservableCollection<Lancamento> LancamentosFiltradosCopia
+ {
+ get
+ {
+ return _lancamentosFiltradosCopia;
+ }
+ set
+ {
+ _lancamentosFiltradosCopia = value;
+ OnPropertyChanged("LancamentosFiltradosCopia");
+ }
+ }
+
+ private bool Salvando { get; set; }
+
+ public ObservableCollection<Lancamento> LancamentosVinculo
+ {
+ get
+ {
+ return _lancamentosVinculo;
+ }
+ set
+ {
+ _lancamentosVinculo = value;
+ OnPropertyChanged("LancamentosVinculo");
+ }
+ }
+
+ public Lancamento LancamentoVinculo
+ {
+ get
+ {
+ return _lancamentoVinculo;
+ }
+ set
+ {
+ _lancamentoVinculo = value;
+ OnPropertyChanged("LancamentoVinculo");
+ }
+ }
+
+ public Lancamento SelectedLancamento
+ {
+ get
+ {
+ return _selectedLancamento;
+ }
+ set
+ {
+ if (value != null && ((DomainBase)value).Id != 0L)
+ {
+ IdLancamento = ((DomainBase)value).Id;
+ }
+ else if (importando)
+ {
+ IdLancamento = 0L;
+ }
+ int enableIncluirNovo;
+ if (value != null && ((DomainBase)value).Id > 0)
+ {
+ Usuario usuario = Recursos.Usuario;
+ enableIncluirNovo = ((usuario != null && ((DomainBase)usuario).Id > 0) ? 1 : 0);
+ }
+ else
+ {
+ enableIncluirNovo = 0;
+ }
+ EnableIncluirNovo = (byte)enableIncluirNovo != 0;
+ _selectedLancamento = value;
+ int enableButtons;
+ if (value != null && ((DomainBase)value).Id > 0)
+ {
+ Usuario usuario2 = Recursos.Usuario;
+ enableButtons = ((usuario2 != null && ((DomainBase)usuario2).Id > 0) ? 1 : 0);
+ }
+ else
+ {
+ enableButtons = 0;
+ }
+ base.EnableButtons = (byte)enableButtons != 0;
+ Usuario usuario3 = Recursos.Usuario;
+ EnableChanges = usuario3 != null && ((DomainBase)usuario3).Id > 0;
+ Alteracao = value != null && ((DomainBase)value.Controle).Id > 0;
+ OnPropertyChanged("SelectedLancamento");
+ Feed(value);
+ if (value != null && ((DomainBase)value).Id != 0L)
+ {
+ LancamentoSelecionado = value;
+ }
+ }
+ }
+
+ public Fornecedor FornecedorInclusao
+ {
+ get
+ {
+ return _fornecedorInclusao;
+ }
+ set
+ {
+ //IL_017a: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0172: Unknown result type (might be due to invalid IL or missing references)
+ _fornecedorInclusao = value;
+ OnPropertyChanged("FornecedorInclusao");
+ Lancamento selectedLancamento = SelectedLancamento;
+ if ((selectedLancamento == null || ((DomainBase)selectedLancamento).Id <= 0) && value != null && value.Id != 0L && Carregar)
+ {
+ Plano = (Planos)((Importando && Plano != null) ? ((object)Plano) : ((object)(((IEnumerable<Planos>)PlanosFiltrados).FirstOrDefault((Func<Planos, bool>)((Planos x) => ((DomainBase)x).Id == value.IdPlano)) ?? ((PlanosFiltrados.Count == 1) ? PlanosFiltrados.First() : null))));
+ Centro = (Centro)((Importando && Centro != null) ? ((object)Centro) : ((object)(((IEnumerable<Centro>)CentrosFiltrados).FirstOrDefault((Func<Centro, bool>)((Centro x) => ((DomainBase)x).Id == value.IdCentro)) ?? ((CentrosFiltrados.Count == 1) ? CentrosFiltrados.First() : null))));
+ Conta = (BancosContas)((Importando && Conta != null) ? ((object)Conta) : ((object)(((IEnumerable<BancosContas>)ContasFiltradas).FirstOrDefault((Func<BancosContas, bool>)((BancosContas x) => ((DomainBase)x).Id == value.IdConta)) ?? ((ContasFiltradas.Count == 1) ? ContasFiltradas.First() : null))));
+ TipoPagamento = (Importando ? TipoPagamento : value.TipoPagamento.GetValueOrDefault());
+ }
+ }
+ }
+
+ public long IdLancamento
+ {
+ get
+ {
+ return _idLancamento;
+ }
+ set
+ {
+ _idLancamento = value;
+ OnPropertyChanged("IdLancamento");
+ }
+ }
+
+ public string Historico
+ {
+ get
+ {
+ return _historico;
+ }
+ set
+ {
+ _historico = value;
+ OnPropertyChanged("Historico");
+ }
+ }
+
+ public string Observacao
+ {
+ get
+ {
+ return _observacao;
+ }
+ set
+ {
+ _observacao = value;
+ OnPropertyChanged("Observacao");
+ }
+ }
+
+ public string Documento
+ {
+ get
+ {
+ return _documento;
+ }
+ set
+ {
+ _documento = value;
+ OnPropertyChanged("Documento");
+ }
+ }
+
+ public string Complemento
+ {
+ get
+ {
+ return _complemento;
+ }
+ set
+ {
+ _complemento = value;
+ OnPropertyChanged("Complemento");
+ }
+ }
+
+ public string Competencia
+ {
+ get
+ {
+ return _competencia;
+ }
+ set
+ {
+ _competencia = value;
+ OnPropertyChanged("Competencia");
+ }
+ }
+
+ public int Parcela
+ {
+ get
+ {
+ return _parcela;
+ }
+ set
+ {
+ _parcela = value;
+ OnPropertyChanged("Parcela");
+ }
+ }
+
+ public double DropDownHeight
+ {
+ get
+ {
+ return _dropDownHeight;
+ }
+ set
+ {
+ _dropDownHeight = value;
+ OnPropertyChanged("DropDownHeight");
+ }
+ }
+
+ public int Parcelas
+ {
+ get
+ {
+ return _parcelas;
+ }
+ set
+ {
+ _parcelas = value;
+ OnPropertyChanged("Parcelas");
+ }
+ }
+
+ public DateTime VencimentoAnt { get; set; }
+
+ public DateTime Vencimento
+ {
+ get
+ {
+ return _vencimento;
+ }
+ set
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ if ((int)Alterando == 0 && value != VencimentoAnt)
+ {
+ VencimentoAlterado = true;
+ }
+ VencimentoAnt = value;
+ _vencimento = value;
+ OnPropertyChanged("Vencimento");
+ }
+ }
+
+ public DateTime? Baixa
+ {
+ get
+ {
+ return _baixa;
+ }
+ set
+ {
+ _baixa = value;
+ OnPropertyChanged("Baixa");
+ }
+ }
+
+ public DateTime? Pagamento
+ {
+ get
+ {
+ return _pagamento;
+ }
+ set
+ {
+ _pagamento = value;
+ OnPropertyChanged("Pagamento");
+ }
+ }
+
+ public decimal Valor
+ {
+ get
+ {
+ return _valor;
+ }
+ set
+ {
+ _valor = value;
+ if (Vencimento <= Funcoes.GetNetworkTime().Date)
+ {
+ ValorPago = value;
+ }
+ OnPropertyChanged("Valor");
+ }
+ }
+
+ public decimal? ValorPago
+ {
+ get
+ {
+ return _valorPago;
+ }
+ set
+ {
+ _valorPago = value;
+ OnPropertyChanged("ValorPago");
+ }
+ }
+
+ public Sinal Sinal
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _sinal;
+ }
+ set
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0002: Unknown result type (might be due to invalid IL or missing references)
+ _sinal = value;
+ OnPropertyChanged("Sinal");
+ }
+ }
+
+ public Planos Plano
+ {
+ get
+ {
+ return _plano;
+ }
+ set
+ {
+ //IL_0030: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0028: Unknown result type (might be due to invalid IL or missing references)
+ _plano = value;
+ OnPropertyChanged("Plano");
+ if (value != null && ((DomainBase)value).Id != 0L)
+ {
+ Sinal = (importando ? Sinal : value.Sinal);
+ }
+ }
+ }
+
+ public Centro Centro
+ {
+ get
+ {
+ return _centro;
+ }
+ set
+ {
+ _centro = value;
+ OnPropertyChanged("Centro");
+ }
+ }
+
+ public BancosContas Conta
+ {
+ get
+ {
+ return _conta;
+ }
+ set
+ {
+ _conta = value;
+ OnPropertyChanged("Conta");
+ }
+ }
+
+ public TipoPagamento TipoPagamento
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _tipoPagamento;
+ }
+ set
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0002: Unknown result type (might be due to invalid IL or missing references)
+ _tipoPagamento = value;
+ OnPropertyChanged("TipoPagamento");
+ }
+ }
+
+ private bool Carregar { get; set; } = true;
+
+
+ public string CodigoBanco { get; set; }
+
+ public List<Planos> PlanosFiltro
+ {
+ get
+ {
+ return _planosFiltro;
+ }
+ set
+ {
+ _planosFiltro = value;
+ OnPropertyChanged("PlanosFiltro");
+ }
+ }
+
+ public List<Centro> CentroFiltro
+ {
+ get
+ {
+ return _centroFiltro;
+ }
+ set
+ {
+ _centroFiltro = value;
+ OnPropertyChanged("CentroFiltro");
+ }
+ }
+
+ public List<BancosContas> ContaFiltro
+ {
+ get
+ {
+ return _contaFiltro;
+ }
+ set
+ {
+ _contaFiltro = value;
+ OnPropertyChanged("ContaFiltro");
+ }
+ }
+
+ public List<Planos> Planos
+ {
+ get
+ {
+ return _planos;
+ }
+ set
+ {
+ _planos = value;
+ OnPropertyChanged("Planos");
+ }
+ }
+
+ public ObservableCollection<Planos> PlanosFiltrados
+ {
+ get
+ {
+ return _planosFiltrados;
+ }
+ set
+ {
+ _planosFiltrados = value;
+ OnPropertyChanged("PlanosFiltrados");
+ }
+ }
+
+ public List<BancosContas> Contas
+ {
+ get
+ {
+ return _contas;
+ }
+ set
+ {
+ _contas = value;
+ OnPropertyChanged("Contas");
+ }
+ }
+
+ public ObservableCollection<BancosContas> ContasFiltradas
+ {
+ get
+ {
+ return _contasFiltradas;
+ }
+ set
+ {
+ _contasFiltradas = value;
+ OnPropertyChanged("ContasFiltradas");
+ }
+ }
+
+ public List<Centro> Centros
+ {
+ get
+ {
+ return _centros;
+ }
+ set
+ {
+ _centros = value;
+ OnPropertyChanged("Centros");
+ }
+ }
+
+ public ObservableCollection<Centro> CentrosFiltrados
+ {
+ get
+ {
+ return _centrosFiltrados;
+ }
+ set
+ {
+ _centrosFiltrados = value;
+ OnPropertyChanged("CentrosFiltrados");
+ }
+ }
+
+ public ObservableCollection<SinteticoFinanceiro> Totalizacao
+ {
+ get
+ {
+ return _totalizacao;
+ }
+ set
+ {
+ _totalizacao = value;
+ OnPropertyChanged("Totalizacao");
+ }
+ }
+
+ public bool Importando
+ {
+ get
+ {
+ return importando;
+ }
+ set
+ {
+ importando = value;
+ OnPropertyChanged("Importando");
+ }
+ }
+
+ public bool NotImportando => !Importando;
+
+ public Visibility VisibilityFornecedor
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _visibilityFornecedor;
+ }
+ set
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0002: Unknown result type (might be due to invalid IL or missing references)
+ _visibilityFornecedor = value;
+ OnPropertyChanged("VisibilityFornecedor");
+ }
+ }
+
+ public Visibility VisibilityCentro
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _visibilityCentro;
+ }
+ set
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0002: Unknown result type (might be due to invalid IL or missing references)
+ _visibilityCentro = value;
+ OnPropertyChanged("VisibilityCentro");
+ }
+ }
+
+ public Visibility VisibilityConta
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _visibilityConta;
+ }
+ set
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0002: Unknown result type (might be due to invalid IL or missing references)
+ _visibilityConta = value;
+ OnPropertyChanged("VisibilityConta");
+ }
+ }
+
+ public Visibility Alterando
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _alterando;
+ }
+ set
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0002: Unknown result type (might be due to invalid IL or missing references)
+ _alterando = value;
+ OnPropertyChanged("Alterando");
+ }
+ }
+
+ public bool BuscaHabilitada
+ {
+ get
+ {
+ return _buscaHabilitada;
+ }
+ set
+ {
+ _buscaHabilitada = value;
+ OnPropertyChanged("BuscaHabilitada");
+ }
+ }
+
+ public bool Alteracao
+ {
+ get
+ {
+ return _alteracao;
+ }
+ set
+ {
+ _alteracao = value;
+ OnPropertyChanged("Alteracao");
+ }
+ }
+
+ public List<FiltroPersonalizado> RelatorioFiltroPersonalizado
+ {
+ get
+ {
+ return _filtroRelatorioPersonalizado;
+ }
+ set
+ {
+ _filtroRelatorioPersonalizado = value;
+ OnPropertyChanged("RelatorioFiltroPersonalizado");
+ }
+ }
+
+ public List<FiltroPersonalizado> Filtros
+ {
+ get
+ {
+ return _filtros;
+ }
+ set
+ {
+ _filtros = value;
+ OnPropertyChanged("Filtros");
+ }
+ }
+
+ public ObservableCollection<FiltroPersonalizado> PersonalizadoSelecionado
+ {
+ get
+ {
+ return _personalizadoSelecionado;
+ }
+ set
+ {
+ _personalizadoSelecionado = value;
+ OnPropertyChanged("PersonalizadoSelecionado");
+ }
+ }
+
+ public ObservableCollection<FiltroPersonalizado> FiltroRelatorioSelecionado
+ {
+ get
+ {
+ return _filtroRelatorioSelecionado;
+ }
+ set
+ {
+ _filtroRelatorioSelecionado = value;
+ OnPropertyChanged("FiltroRelatorioSelecionado");
+ }
+ }
+
+ public Visibility VisibilitySemValor
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _visibilitySemValor;
+ }
+ set
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0002: Unknown result type (might be due to invalid IL or missing references)
+ _visibilitySemValor = value;
+ OnPropertyChanged("VisibilitySemValor");
+ }
+ }
+
+ public FiltroPersonalizado Filtro
+ {
+ get
+ {
+ return _filtro;
+ }
+ set
+ {
+ _filtro = value;
+ VisibilitySemValor = (Visibility)((value == null) ? 2 : 0);
+ OnPropertyChanged("Filtro");
+ if (value == null)
+ {
+ return;
+ }
+ string name = value.Tipo.Name;
+ if (name == null)
+ {
+ return;
+ }
+ switch (name.Length)
+ {
+ default:
+ return;
+ case 4:
+ {
+ char c = name[0];
+ if (c != 'E')
+ {
+ if (c != 'l' || !(name == "long"))
+ {
+ return;
+ }
+ break;
+ }
+ if (!(name == "Enum"))
+ {
+ return;
+ }
+ goto IL_0121;
+ }
+ case 5:
+ switch (name[3])
+ {
+ default:
+ return;
+ case '3':
+ if (!(name == "int32"))
+ {
+ return;
+ }
+ break;
+ case '6':
+ if (!(name == "int64"))
+ {
+ return;
+ }
+ break;
+ }
+ break;
+ case 6:
+ if (name == "String")
+ {
+ ValorInicial = "";
+ ValorFinal = "";
+ }
+ return;
+ case 7:
+ if (name == "Decimal")
+ {
+ ValorInicial = "0,00";
+ ValorFinal = "0,00";
+ }
+ return;
+ case 8:
+ if (!(name == "DateTime"))
+ {
+ return;
+ }
+ goto IL_0121;
+ case 3:
+ {
+ if (!(name == "int"))
+ {
+ return;
+ }
+ break;
+ }
+ IL_0121:
+ ValorInicial = null;
+ ValorFinal = null;
+ return;
+ }
+ ValorInicial = "0";
+ ValorFinal = "0";
+ }
+ }
+
+ public Type TipoString
+ {
+ get
+ {
+ return _tipoString;
+ }
+ set
+ {
+ _tipoString = value;
+ OnPropertyChanged("TipoString");
+ }
+ }
+
+ public Type TipoEnum
+ {
+ get
+ {
+ return _tipoEnum;
+ }
+ set
+ {
+ _tipoEnum = value;
+ OnPropertyChanged("TipoEnum");
+ }
+ }
+
+ public Type TipoDateTime
+ {
+ get
+ {
+ return _tipoDateTime;
+ }
+ set
+ {
+ _tipoDateTime = value;
+ OnPropertyChanged("TipoDateTime");
+ }
+ }
+
+ public Type TipoDecimal
+ {
+ get
+ {
+ return _tipoDecimal;
+ }
+ set
+ {
+ _tipoDecimal = value;
+ OnPropertyChanged("TipoDecimal");
+ }
+ }
+
+ public Type TipoInt
+ {
+ get
+ {
+ return _tipoInt;
+ }
+ set
+ {
+ _tipoInt = value;
+ OnPropertyChanged("TipoInt");
+ }
+ }
+
+ public Type TipoLong
+ {
+ get
+ {
+ return _tipoLong;
+ }
+ set
+ {
+ _tipoLong = value;
+ OnPropertyChanged("TipoLong");
+ }
+ }
+
+ public string ValorInicial
+ {
+ get
+ {
+ return _valorIncial;
+ }
+ set
+ {
+ _valorIncial = value;
+ OnPropertyChanged("ValorInicial");
+ }
+ }
+
+ public string ValorFinal
+ {
+ get
+ {
+ return _valorFinal;
+ }
+ set
+ {
+ _valorFinal = value;
+ OnPropertyChanged("ValorFinal");
+ }
+ }
+
+ public bool SemValor
+ {
+ get
+ {
+ return _semValor;
+ }
+ set
+ {
+ _semValor = value;
+ if (value)
+ {
+ ValorInicial = null;
+ ValorFinal = null;
+ }
+ OnPropertyChanged("SemValor");
+ }
+ }
+
+ public List<FiltroPersonalizado> FiltroPersonalizado
+ {
+ get
+ {
+ return _filtroPersonalizado;
+ }
+ set
+ {
+ _filtroPersonalizado = value;
+ OnPropertyChanged("FiltroPersonalizado");
+ }
+ }
+
+ public ObservableCollection<FiltroPersonalizado> FiltroPersonalizadoSelecionado
+ {
+ get
+ {
+ return _filtroPersonalizadoSelecionado;
+ }
+ set
+ {
+ _filtroPersonalizadoSelecionado = value;
+ OnPropertyChanged("FiltroPersonalizadoSelecionado");
+ }
+ }
+
+ public AutoCompleteFilterPredicate<object> FiltroPersonalizadoItemFilter => (string searchText, object obj) => ((FiltroPersonalizado)obj).Descricao.ToUpper().Contains(searchText.ToUpper());
+
+ public Visibility VisibleFiltros
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _visibleFiltros;
+ }
+ set
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0002: Unknown result type (might be due to invalid IL or missing references)
+ _visibleFiltros = value;
+ OnPropertyChanged("VisibleFiltros");
+ }
+ }
+
+ public Visibility VisibleOlho
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _visibleOlho;
+ }
+ set
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0002: Unknown result type (might be due to invalid IL or missing references)
+ _visibleOlho = value;
+ OnPropertyChanged("VisibleOlho");
+ }
+ }
+
+ private Lancamento LancamentoSelecionado { get; set; }
+
+ public Func<List<KeyValuePair<string, string>>> ValidationEvent => ValidateIncluir;
+
+ public bool IsExpanded
+ {
+ get
+ {
+ return _isExpanded;
+ }
+ set
+ {
+ _isExpanded = value;
+ OnPropertyChanged("IsExpanded");
+ }
+ }
+
+ public FinanceiroViewModel()
+ {
+ //IL_0002: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0009: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0010: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0017: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0059: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0063: Expected O, but got Unknown
+ //IL_0098: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00b8: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0140: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0147: Unknown result type (might be due to invalid IL or missing references)
+ _servico = new FinanceiroServico();
+ RelatorioFiltroPersonalizado = Funcoes.PopularFiltroFinanceiro();
+ BuscaInicial();
+ }
+
+ public void FiltroImportacao()
+ {
+ //IL_000a: Unknown result type (might be due to invalid IL or missing references)
+ //IL_000f: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0010: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0022: Expected I4, but got Unknown
+ if (!importando)
+ {
+ return;
+ }
+ StatusLancamento selectedStatusImportacao = SelectedStatusImportacao;
+ switch ((int)selectedStatusImportacao)
+ {
+ case 0:
+ LancamentosFiltrados = new ObservableCollection<Lancamento>(Lancamentos.Where((Lancamento x) => !x.Baixado));
+ break;
+ case 1:
+ LancamentosFiltrados = new ObservableCollection<Lancamento>(Lancamentos.Where((Lancamento x) => x.Baixado));
+ break;
+ case 2:
+ LancamentosFiltrados = new ObservableCollection<Lancamento>(Lancamentos);
+ break;
+ }
+ }
+
+ public async Task CarregarSaldos()
+ {
+ Saldos = new ObservableCollection<Saldo>();
+ BancosContasServico bancoServico = new BancosContasServico();
+ foreach (BancosContas contasFiltrada in ContasFiltradas)
+ {
+ Saldo val = await bancoServico.BuscarSaldoAberto(((DomainBase)contasFiltrada).Id);
+ if (val != null)
+ {
+ val.DataFinal = Funcoes.GetNetworkTime().Date.AddDays(1.0);
+ val = await bancoServico.FecharSaldo(val);
+ Saldos.Add(val);
+ }
+ }
+ SelectedSaldo = Saldos.FirstOrDefault();
+ }
+
+ public void Feed(Lancamento lancamento)
+ {
+ //IL_00f7: Unknown result type (might be due to invalid IL or missing references)
+ //IL_01d9: Unknown result type (might be due to invalid IL or missing references)
+ if (lancamento != null && !Salvando && (importando || lancamento.Controle.Plano != null))
+ {
+ Fornecedor fornecedor = lancamento.Controle.Fornecedor;
+ FornecedorInclusao = ((fornecedor != null && fornecedor.Id == 0) ? null : lancamento.Controle.Fornecedor);
+ Plano = ((lancamento.Controle.Plano != null) ? ((IEnumerable<Planos>)PlanosFiltrados).FirstOrDefault((Func<Planos, bool>)((Planos x) => ((DomainBase)x).Id == ((DomainBase)lancamento.Controle.Plano).Id)) : null);
+ Centro = ((IEnumerable<Centro>)CentrosFiltrados).FirstOrDefault((Func<Centro, bool>)((Centro x) => ((DomainBase)x).Id == ((DomainBase)lancamento.Controle.Centro).Id));
+ Conta = ((lancamento.Conta != null) ? ((IEnumerable<BancosContas>)ContasFiltradas).FirstOrDefault((Func<BancosContas, bool>)((BancosContas x) => ((DomainBase)x).Id == ((DomainBase)lancamento.Conta).Id)) : null);
+ TipoPagamento = lancamento.TipoPagamento;
+ Historico = lancamento.Historico;
+ Observacao = lancamento.Observacao;
+ Complemento = lancamento.Complemento;
+ Competencia = lancamento.Competencia;
+ Documento = lancamento.Documento;
+ Parcela = lancamento.Parcela;
+ Parcelas = lancamento.Controle.Parcelas;
+ Valor = lancamento.Valor;
+ ValorPago = lancamento.ValorPago;
+ Vencimento = lancamento.Vencimento;
+ Pagamento = lancamento.Pagamento;
+ Baixa = lancamento.Baixa;
+ Sinal = lancamento.Sinal;
+ CodigoBanco = lancamento.CodigoBanco;
+ }
+ }
+
+ public void FeedImportando(Lancamento lancamento)
+ {
+ //IL_0148: Unknown result type (might be due to invalid IL or missing references)
+ if (lancamento != null && !Salvando && (importando || lancamento.Controle.Plano != null))
+ {
+ Conta = ((Conta == null) ? ((IEnumerable<BancosContas>)ContasFiltradas).FirstOrDefault((Func<BancosContas, bool>)((BancosContas x) => ((DomainBase)x).Id == ((DomainBase)lancamento.Conta).Id)) : null);
+ ((DomainBase)SelectedLancamento).Id = ((DomainBase)lancamento).Id;
+ ((DomainBase)SelectedLancamento.Controle).Id = ((DomainBase)lancamento.Controle).Id;
+ SelectedLancamento.Controle.Historico = lancamento.Controle.Historico;
+ SelectedLancamento.Baixado = lancamento.Baixa.HasValue;
+ decimal? valorPago = SelectedLancamento.ValorPago;
+ IdLancamento = ((DomainBase)lancamento).Id;
+ Plano = ((lancamento.Controle.Plano != null) ? ((IEnumerable<Planos>)PlanosFiltrados).FirstOrDefault((Func<Planos, bool>)((Planos x) => ((DomainBase)x).Id == ((DomainBase)lancamento.Controle.Plano).Id)) : null);
+ Centro = ((IEnumerable<Centro>)CentrosFiltrados).FirstOrDefault((Func<Centro, bool>)((Centro x) => ((DomainBase)x).Id == ((DomainBase)lancamento.Controle.Centro).Id));
+ TipoPagamento = lancamento.TipoPagamento;
+ Historico = lancamento.Historico;
+ Observacao = lancamento.Observacao;
+ Complemento = lancamento.Complemento;
+ Documento = lancamento.Documento;
+ Parcela = lancamento.Parcela;
+ Parcelas = lancamento.Controle.Parcelas;
+ Valor = lancamento.Valor;
+ ValorPago = valorPago;
+ Vencimento = lancamento.Vencimento;
+ Pagamento = (lancamento.Pagamento.HasValue ? lancamento.Pagamento : Pagamento);
+ }
+ }
+
+ public void BindImportando()
+ {
+ //IL_0045: Unknown result type (might be due to invalid IL or missing references)
+ //IL_004f: Expected O, but got Unknown
+ //IL_00dc: Unknown result type (might be due to invalid IL or missing references)
+ //IL_01a8: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0062: Unknown result type (might be due to invalid IL or missing references)
+ //IL_006c: Expected O, but got Unknown
+ Carregar = false;
+ object obj = FornecedorInclusao;
+ if (obj == null)
+ {
+ Lancamento selectedLancamento = SelectedLancamento;
+ if (selectedLancamento == null)
+ {
+ obj = null;
+ }
+ else
+ {
+ ControleFinanceiro controle = selectedLancamento.Controle;
+ obj = ((controle != null) ? controle.Fornecedor : null);
+ }
+ }
+ FornecedorInclusao = (Fornecedor)obj;
+ Carregar = true;
+ if (SelectedLancamento == null)
+ {
+ SelectedLancamento = new Lancamento();
+ }
+ if (SelectedLancamento.Controle == null)
+ {
+ SelectedLancamento.Controle = new ControleFinanceiro();
+ }
+ SelectedLancamento.Controle.Fornecedor = FornecedorInclusao;
+ SelectedLancamento.Controle.Plano = Plano;
+ SelectedLancamento.Controle.Centro = Centro;
+ SelectedLancamento.Controle.Parcelas = Parcelas;
+ SelectedLancamento.Conta = Conta;
+ SelectedLancamento.TipoPagamento = TipoPagamento;
+ SelectedLancamento.Historico = Historico;
+ SelectedLancamento.Observacao = Observacao;
+ SelectedLancamento.Complemento = Complemento;
+ SelectedLancamento.Competencia = Competencia;
+ SelectedLancamento.Documento = Documento;
+ SelectedLancamento.Parcela = Parcela;
+ SelectedLancamento.Valor = Valor;
+ SelectedLancamento.ValorPago = ValorPago;
+ SelectedLancamento.Vencimento = Vencimento;
+ SelectedLancamento.Pagamento = Pagamento;
+ SelectedLancamento.Baixa = Baixa;
+ SelectedLancamento.Sinal = Sinal;
+ SelectedLancamento.CodigoBanco = CodigoBanco;
+ }
+
+ public void Bind()
+ {
+ //IL_0045: Unknown result type (might be due to invalid IL or missing references)
+ //IL_004f: Expected O, but got Unknown
+ //IL_00ee: Unknown result type (might be due to invalid IL or missing references)
+ //IL_01ba: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0062: Unknown result type (might be due to invalid IL or missing references)
+ //IL_006c: Expected O, but got Unknown
+ Carregar = false;
+ object obj = FornecedorInclusao;
+ if (obj == null)
+ {
+ Lancamento selectedLancamento = SelectedLancamento;
+ if (selectedLancamento == null)
+ {
+ obj = null;
+ }
+ else
+ {
+ ControleFinanceiro controle = selectedLancamento.Controle;
+ obj = ((controle != null) ? controle.Fornecedor : null);
+ }
+ }
+ FornecedorInclusao = (Fornecedor)obj;
+ Carregar = true;
+ if (SelectedLancamento == null)
+ {
+ SelectedLancamento = new Lancamento();
+ }
+ if (SelectedLancamento.Controle == null)
+ {
+ SelectedLancamento.Controle = new ControleFinanceiro();
+ }
+ Salvando = true;
+ ((DomainBase)SelectedLancamento).Initialize();
+ SelectedLancamento.Controle.Fornecedor = FornecedorInclusao;
+ SelectedLancamento.Controle.Plano = Plano;
+ SelectedLancamento.Controle.Centro = Centro;
+ SelectedLancamento.Controle.Parcelas = Parcelas;
+ SelectedLancamento.Conta = Conta;
+ SelectedLancamento.TipoPagamento = TipoPagamento;
+ SelectedLancamento.Historico = Historico;
+ SelectedLancamento.Observacao = Observacao;
+ SelectedLancamento.Complemento = Complemento;
+ SelectedLancamento.Competencia = Competencia;
+ SelectedLancamento.Documento = Documento;
+ SelectedLancamento.Parcela = Parcela;
+ SelectedLancamento.Valor = Valor;
+ SelectedLancamento.ValorPago = ValorPago;
+ SelectedLancamento.Vencimento = Vencimento;
+ SelectedLancamento.Pagamento = Pagamento;
+ SelectedLancamento.Baixa = Baixa;
+ SelectedLancamento.Sinal = Sinal;
+ SelectedLancamento.CodigoBanco = CodigoBanco;
+ Salvando = false;
+ }
+
+ private async void BuscaInicial()
+ {
+ Loading(isLoading: true);
+ Planos = await new PlanoServico().BuscarPlanos();
+ PlanosFiltrados = new ObservableCollection<Planos>(from x in Planos
+ where x.Ativo
+ orderby x.Descricao
+ select x);
+ Contas = await new BancosContasServico().BuscarBancos();
+ ContasFiltradas = new ObservableCollection<BancosContas>(from x in Contas
+ where x.Ativo
+ orderby x.Descricao
+ select x);
+ Centros = await new CentroServico().BuscarCentros();
+ CentrosFiltrados = new ObservableCollection<Centro>(from x in Centros
+ where x.Ativo
+ orderby x.Descricao
+ select x);
+ PlanosFiltro = new List<Planos>(Planos.OrderBy((Planos x) => x.Descricao));
+ ContaFiltro = new List<BancosContas>(Contas.OrderBy((BancosContas x) => x.Descricao));
+ CentroFiltro = new List<Centro>(Centros.OrderBy((Centro x) => x.Descricao));
+ PopularFiltro();
+ await Buscar();
+ Loading(isLoading: false);
+ }
+
+ public void Totalizar()
+ {
+ //IL_0095: Unknown result type (might be due to invalid IL or missing references)
+ //IL_009a: Unknown result type (might be due to invalid IL or missing references)
+ //IL_009b: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00a0: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00a8: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00b8: Expected O, but got Unknown
+ //IL_00b8: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00e3: Unknown result type (might be due to invalid IL or missing references)
+ //IL_010e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0139: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0164: Unknown result type (might be due to invalid IL or missing references)
+ //IL_018f: Unknown result type (might be due to invalid IL or missing references)
+ //IL_01ba: Unknown result type (might be due to invalid IL or missing references)
+ //IL_01ea: Expected O, but got Unknown
+ if (LancamentosFiltrados == null)
+ {
+ Totalizacao = null;
+ return;
+ }
+ List<SinteticoFinanceiro> list = (from x in LancamentosFiltrados
+ where x.Conta != null
+ group x by new
+ {
+ ((DomainBase)x.Conta).Id,
+ x.Conta.Descricao
+ } into x
+ select new SinteticoFinanceiro
+ {
+ Conta = new BancosContas
+ {
+ Id = x.Key.Id,
+ Descricao = x.Key.Descricao
+ },
+ Filtrados = x.Count(),
+ Credito = x.Sum((Lancamento s) => ((int)s.Sinal != 0) ? 0m : s.Valor),
+ Debito = x.Sum((Lancamento s) => ((int)s.Sinal != 0) ? (-s.Valor) : 0m),
+ Liquido = x.Sum((Lancamento s) => ((int)s.Sinal != 0) ? (-s.Valor) : s.Valor),
+ LiquidoPago = x.Sum((Lancamento s) => ((int)s.Sinal != 0) ? (-s.ValorPago) : s.ValorPago).GetValueOrDefault(),
+ Selecionados = x.Count((Lancamento s) => s.Selecionado),
+ LiquidoSelecionados = x.Where((Lancamento s) => s.Selecionado).Sum((Lancamento s) => ((int)s.Sinal != 0) ? (-s.ValorPago).GetValueOrDefault() : s.ValorPago.GetValueOrDefault())
+ }).ToList();
+ if (list.Count > 1)
+ {
+ list.Add(new SinteticoFinanceiro
+ {
+ Conta = new BancosContas
+ {
+ Id = 0L,
+ Descricao = "TOTAL"
+ },
+ Filtrados = list.Sum((SinteticoFinanceiro x) => x.Filtrados),
+ Credito = list.Sum((SinteticoFinanceiro x) => x.Credito),
+ Debito = list.Sum((SinteticoFinanceiro x) => x.Debito),
+ Liquido = list.Sum((SinteticoFinanceiro x) => x.Liquido),
+ LiquidoPago = list.Sum((SinteticoFinanceiro x) => x.LiquidoPago),
+ Selecionados = list.Sum((SinteticoFinanceiro x) => x.Selecionados),
+ LiquidoSelecionados = list.Sum((SinteticoFinanceiro x) => x.LiquidoSelecionados)
+ });
+ }
+ Totalizacao = new ObservableCollection<SinteticoFinanceiro>(list);
+ }
+
+ public async Task Buscar()
+ {
+ Importando = false;
+ if (!Inicio.HasValue || !Fim.HasValue)
+ {
+ await ShowMessage("NECESSÁRIO PREENCHER TANTO A DATA DE INÍCIO QUANTO A DATA FINAL PARA REALIZAR A PESQUISA.");
+ return;
+ }
+ if (Inicio > Fim)
+ {
+ await ShowMessage("A DATA DE INÍCIO NÃO PODE SER SUPERIOR A DATA FINAL.");
+ return;
+ }
+ PersonalizadoSelecionado = null;
+ FiltroLancamento selectedFiltro = SelectedFiltro;
+ List<Lancamento> list;
+ switch (selectedFiltro - 1)
+ {
+ default:
+ list = await _servico.BuscarLancamentos(Inicio.Value, Fim.Value, SelectedStatus);
+ break;
+ case 2:
+ if (SelectedFornecedor == null)
+ {
+ return;
+ }
+ list = await _servico.BuscarLancamentosPorFornecedor(SelectedFornecedor.Id, SelectedStatus);
+ break;
+ case 0:
+ list = await _servico.BuscarLancamentosPorBaixa(Inicio.Value, Fim.Value);
+ break;
+ case 1:
+ list = await _servico.BuscarLancamentosPorPagamento(Inicio.Value, Fim.Value);
+ break;
+ case 3:
+ list = await _servico.BuscarLancamentosPorLancamento(Inicio.Value, Fim.Value, SelectedStatus);
+ break;
+ case 4:
+ {
+ List<Lancamento> source = await _servico.BuscarLancamentosPersonalizados(Inicio.Value, Fim.Value, SelectedStatus, SelectedFiltroData);
+ List<long> fornecedores = ((FiltroPersonalizadoSelecionado != null) ? (from x in FiltroPersonalizadoSelecionado
+ where (int)x.Tipo == 0
+ select x.Id).ToList() : new List<long>());
+ List<long> centros = ((FiltroPersonalizadoSelecionado != null) ? (from x in FiltroPersonalizadoSelecionado
+ where (int)x.Tipo == 2
+ select x.Id).ToList() : new List<long>());
+ List<long> planos = ((FiltroPersonalizadoSelecionado != null) ? (from x in FiltroPersonalizadoSelecionado
+ where (int)x.Tipo == 1
+ select x.Id).ToList() : new List<long>());
+ List<long> contas = ((FiltroPersonalizadoSelecionado != null) ? (from x in FiltroPersonalizadoSelecionado
+ where (int)x.Tipo == 3
+ select x.Id).ToList() : new List<long>());
+ List<long> sinal = ((FiltroPersonalizadoSelecionado != null) ? (from x in FiltroPersonalizadoSelecionado
+ where (int)x.Tipo == 4
+ select x.Id).ToList() : new List<long>());
+ list = source.Where((Lancamento x) => (fornecedores.Count == 0 || (x.Controle.Fornecedor != null && fornecedores.Contains(x.Controle.Fornecedor.Id))) && (centros.Count == 0 || (x.Controle.Centro != null && centros.Contains(((DomainBase)x.Controle.Centro).Id))) && (planos.Count == 0 || (x.Controle.Plano != null && planos.Contains(((DomainBase)x.Controle.Plano).Id))) && (contas.Count == 0 || (x.Conta != null && contas.Contains(((DomainBase)x.Conta).Id))) && (sinal.Count == 0 || sinal.Contains((long)x.Sinal))).ToList();
+ break;
+ }
+ }
+ list.ForEach(delegate(Lancamento x)
+ {
+ ((DomainBase)x).Initialize();
+ });
+ Lancamentos = new ObservableCollection<Lancamento>(list);
+ LancamentosFiltrados = Lancamentos;
+ LancamentosFiltradosCopia = LancamentosFiltrados;
+ SelectedLancamento = LancamentosFiltrados.FirstOrDefault();
+ await CarregarSaldos();
+ }
+
+ internal async Task BuscarLancamentosVinculo()
+ {
+ DateTime? obj;
+ if (SelectedLancamento.Conta == null)
+ {
+ obj = SelectedLancamento.Vencimento.AddDays(-5.0);
+ }
+ else
+ {
+ Saldo? obj2 = ((IEnumerable<Saldo>)Saldos).FirstOrDefault((Func<Saldo, bool>)((Saldo x) => ((DomainBase)x).Id == ((DomainBase)SelectedLancamento.Conta).Id));
+ obj = ((obj2 != null) ? obj2.DataInicio : null);
+ }
+ DateTime date = obj ?? SelectedLancamento.Vencimento.AddDays(-5.0);
+ List<Lancamento> source = await _servico.BuscarLancamentosPorFornecedor(FornecedorInclusao.Id, date, Sinal);
+ List<long> ids = Lancamentos.Select((Lancamento x) => ((DomainBase)x).Id).ToList();
+ source = source.Where((Lancamento x) => !ids.Contains(((DomainBase)x).Id)).ToList();
+ LancamentosVinculo = new ObservableCollection<Lancamento>(source);
+ }
+
+ public void FiltrarPersonalizado()
+ {
+ List<long> fornecedores = ((FiltroPersonalizadoSelecionado != null) ? (from x in FiltroPersonalizadoSelecionado
+ where (int)x.Tipo == 0
+ select x.Id).ToList() : new List<long>());
+ List<long> centros = ((FiltroPersonalizadoSelecionado != null) ? (from x in FiltroPersonalizadoSelecionado
+ where (int)x.Tipo == 2
+ select x.Id).ToList() : new List<long>());
+ List<long> planos = ((FiltroPersonalizadoSelecionado != null) ? (from x in FiltroPersonalizadoSelecionado
+ where (int)x.Tipo == 1
+ select x.Id).ToList() : new List<long>());
+ List<long> contas = ((FiltroPersonalizadoSelecionado != null) ? (from x in FiltroPersonalizadoSelecionado
+ where (int)x.Tipo == 3
+ select x.Id).ToList() : new List<long>());
+ List<long> sinal = ((FiltroPersonalizadoSelecionado != null) ? (from x in FiltroPersonalizadoSelecionado
+ where (int)x.Tipo == 4
+ select x.Id).ToList() : new List<long>());
+ List<Lancamento> list = Lancamentos.Where((Lancamento x) => (fornecedores.Count == 0 || (x.Controle.Fornecedor != null && fornecedores.Contains(x.Controle.Fornecedor.Id))) && (centros.Count == 0 || (x.Controle.Centro != null && centros.Contains(((DomainBase)x.Controle.Centro).Id))) && (planos.Count == 0 || (x.Controle.Plano != null && planos.Contains(((DomainBase)x.Controle.Plano).Id))) && (contas.Count == 0 || (x.Conta != null && contas.Contains(((DomainBase)x.Conta).Id))) && (sinal.Count == 0 || sinal.Contains((long)x.Sinal))).ToList();
+ LancamentosFiltrados = new ObservableCollection<Lancamento>(list);
+ LancamentosFiltradosCopia = LancamentosFiltrados;
+ SelectedLancamento = LancamentosFiltrados.FirstOrDefault();
+ }
+
+ public async Task ParseOfx(BancosContas conta)
+ {
+ SelectedStatusImportacao = (StatusLancamento)2;
+ Importando = true;
+ VisibleFiltros = (Visibility)2;
+ List<OfxDocument> list = await ImportarOfx();
+ if (list == null || list.Count == 0)
+ {
+ Importando = false;
+ return;
+ }
+ List<string> codigoBanco = new List<string> { "0237", "033" };
+ List<Lancamento> lancamentos = new List<Lancamento>();
+ foreach (OfxDocument x2 in list)
+ {
+ Tuple<DateTime, DateTime> tuple = CorrigeLancamentos(x2, codigoBanco);
+ x2.StatementStart = tuple.Item1;
+ x2.StatementEnd = tuple.Item2;
+ List<Lancamento> saved = await _servico.BuscarLancamentos(x2.StatementStart.AddDays(-5.0), x2.StatementEnd.AddDays(5.0), ((DomainBase)conta).Id);
+ x2.Transactions.ForEach(delegate(Transaction t)
+ {
+ //IL_00d9: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00fc: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0101: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0106: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0266: Unknown result type (might be due to invalid IL or missing references)
+ //IL_026b: Unknown result type (might be due to invalid IL or missing references)
+ //IL_026c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0271: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0278: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0298: Unknown result type (might be due to invalid IL or missing references)
+ //IL_029f: Unknown result type (might be due to invalid IL or missing references)
+ //IL_02a6: Unknown result type (might be due to invalid IL or missing references)
+ //IL_02c8: Expected O, but got Unknown
+ //IL_02c8: Unknown result type (might be due to invalid IL or missing references)
+ //IL_02de: Unknown result type (might be due to invalid IL or missing references)
+ //IL_02f9: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0316: Unknown result type (might be due to invalid IL or missing references)
+ //IL_024c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_025b: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0254: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0337: Unknown result type (might be due to invalid IL or missing references)
+ //IL_034d: Unknown result type (might be due to invalid IL or missing references)
+ //IL_035e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0374: Unknown result type (might be due to invalid IL or missing references)
+ //IL_038a: Unknown result type (might be due to invalid IL or missing references)
+ //IL_03a7: Unknown result type (might be due to invalid IL or missing references)
+ //IL_03a8: Unknown result type (might be due to invalid IL or missing references)
+ //IL_03ae: Unknown result type (might be due to invalid IL or missing references)
+ //IL_03cd: Unknown result type (might be due to invalid IL or missing references)
+ //IL_03d4: Unknown result type (might be due to invalid IL or missing references)
+ //IL_03f1: Unknown result type (might be due to invalid IL or missing references)
+ //IL_03f9: Expected O, but got Unknown
+ if (!(t.Date < x2.StatementStart.AddDays(-5.0)) || !(t.Date < x2.StatementEnd.AddDays(5.0)) || codigoBanco.Any((string c) => c == x2.Account.BankId.Trim()))
+ {
+ Sinal sinal = (Sinal)((t.Amount < 0m) ? 1 : 0);
+ Lancamento val = ((IEnumerable<Lancamento>)saved).FirstOrDefault((Func<Lancamento, bool>)((Lancamento l) => ((l.ValorPago.HasValue && Math.Abs(l.ValorPago.Value) > 0m && Math.Abs(l.ValorPago.Value) == Math.Abs(t.Amount)) || Math.Abs(l.Valor) == Math.Abs(t.Amount)) && l.Sinal == sinal && l.Documento != null && t.TransactionId.Contains(l.Documento) && (l.Pagamento == t.Date || l.Vencimento == t.Date || (l.Vencimento >= t.Date.AddDays(-5.0) && l.Vencimento <= t.Date.AddDays(5.0)))));
+ TipoPagamento val2 = t.TransType.ParseTransactionType();
+ string transactionId = t.TransactionId;
+ string documento = ((transactionId == null || transactionId.Trim().Length <= 50) ? t.TransactionId?.Trim() : t.TransactionId?.Trim()?.Substring(0, 50));
+ if (val != null)
+ {
+ val.Baixado = val.Baixa.HasValue;
+ val.Conta = conta;
+ val.ValorPago = Math.Abs(t.Amount);
+ val.Competencia = t.Date.ToString("MM/yyyy");
+ val.Baixa = ((!val.Baixa.HasValue) ? new DateTime?(t.Date) : val.Baixa);
+ val.Pagamento = ((!val.Pagamento.HasValue) ? new DateTime?(t.Date) : val.Pagamento);
+ val.Documento = documento;
+ val.CodigoBanco = t.TransactionId;
+ val.TipoPagamento = (((int)val.TipoPagamento == 0) ? val2 : val.TipoPagamento);
+ }
+ else
+ {
+ val = new Lancamento
+ {
+ Controle = new ControleFinanceiro
+ {
+ Fornecedor = null,
+ Centro = Centros.FirstOrDefault(),
+ Plano = null,
+ Parcelas = 1,
+ Historico = t.Memo?.Trim()
+ },
+ Valor = Math.Abs(t.Amount),
+ ValorPago = Math.Abs(t.Amount),
+ Historico = t.Memo?.Trim(),
+ Sinal = (Sinal)((t.Amount < 0m) ? 1 : 0),
+ Conta = conta,
+ Vencimento = t.Date,
+ Baixa = t.Date,
+ Pagamento = t.Date,
+ Documento = t.TransactionId?.Trim(),
+ TipoPagamento = val2,
+ Competencia = t.Date.ToString("MM/yyyy"),
+ Parcela = 1,
+ CodigoBanco = t.TransactionId?.Trim(),
+ Baixado = false
+ };
+ }
+ lancamentos.Add(val);
+ }
+ });
+ }
+ Lancamentos = new ObservableCollection<Lancamento>(lancamentos);
+ LancamentosFiltrados = Lancamentos;
+ ExtensionMethods.ForEach<Lancamento>((IEnumerable<Lancamento>)LancamentosFiltrados, (Action<Lancamento>)delegate(Lancamento x)
+ {
+ SelecionarLancamento(x);
+ });
+ LancamentosFiltradosCopia = LancamentosFiltrados;
+ }
+
+ private Tuple<DateTime, DateTime> CorrigeLancamentos(OfxDocument lancamentos, List<string> codigoBanco)
+ {
+ if (VerificaFiltroErrado(lancamentos))
+ {
+ Transaction obj = lancamentos.Transactions.OrderBy((Transaction lanc) => lanc.Date).First();
+ DateTime value = ((obj != null) ? new DateTime?(obj.Date) : null).Value;
+ Transaction obj2 = lancamentos.Transactions.OrderByDescending((Transaction lanc) => lanc.Date).First();
+ return new Tuple<DateTime, DateTime>(value, ((obj2 != null) ? new DateTime?(obj2.Date) : null).Value);
+ }
+ if (VerificaDataInvertida(lancamentos))
+ {
+ return new Tuple<DateTime, DateTime>(lancamentos.StatementEnd, lancamentos.StatementStart);
+ }
+ return new Tuple<DateTime, DateTime>(lancamentos.StatementStart, lancamentos.StatementEnd);
+ }
+
+ private bool VerificaFiltroErrado(OfxDocument lancamentos)
+ {
+ List<string> source = new List<string> { "0237", "756" };
+ if (lancamentos.StatementStart == lancamentos.StatementEnd)
+ {
+ return source.Any((string idbanco) => idbanco == lancamentos.Account.BankId);
+ }
+ return false;
+ }
+
+ private bool VerificaDataInvertida(OfxDocument lancamentos)
+ {
+ List<string> source = new List<string> { "0104" };
+ if (lancamentos.StatementStart > lancamentos.StatementEnd)
+ {
+ return source.Any((string banco) => banco == lancamentos.Account.BankId);
+ }
+ return false;
+ }
+
+ public List<Lancamento> FiltrarLancamento(long id)
+ {
+ LancamentosFiltrados = new ObservableCollection<Lancamento>(Lancamentos.Where((Lancamento x) => ((DomainBase)x).Id == id));
+ return LancamentosFiltrados.ToList();
+ }
+
+ public List<Lancamento> FiltrarLancamento(Lancamento lancamento)
+ {
+ LancamentosFiltrados = new ObservableCollection<Lancamento>(Lancamentos.Where((Lancamento x) => x.Valor == lancamento.Valor && x.Vencimento == lancamento.Vencimento && x.Historico == lancamento.Historico));
+ return LancamentosFiltrados.ToList();
+ }
+
+ public async Task<List<Lancamento>> FiltrarLancamento(string value)
+ {
+ return await Task.Run(() => Filtrar(value));
+ }
+
+ public List<Lancamento> Filtrar(string filter)
+ {
+ _dontSort = true;
+ LancamentosFiltrados = (string.IsNullOrWhiteSpace(filter) ? Lancamentos : new ObservableCollection<Lancamento>(Lancamentos.Where(delegate(Lancamento x)
+ {
+ //IL_01ea: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0252: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0259: Unknown result type (might be due to invalid IL or missing references)
+ if ((x.Historico == null || !ValidationHelper.RemoveDiacritics(x.Historico.Trim()).Contains(filter)) && (x.Documento == null || !ValidationHelper.RemoveDiacritics(x.Documento.Trim()).Contains(filter)) && (x.Competencia == null || !ValidationHelper.RemoveDiacritics(x.Competencia.Trim()).Contains(filter)) && (x.Complemento == null || !ValidationHelper.RemoveDiacritics(x.Complemento.Trim()).Contains(filter)) && (x.Observacao == null || !ValidationHelper.RemoveDiacritics(x.Observacao.Trim()).Contains(filter)) && !ValidationHelper.RemoveDiacritics(x.Vencimento.ToString(CultureInfo.CurrentCulture).Trim()).ToUpper().Contains(filter) && (!x.Baixa.HasValue || !ValidationHelper.RemoveDiacritics(x.Baixa.ToString().Trim()).ToUpper().Contains(filter)) && (!x.Pagamento.HasValue || !ValidationHelper.RemoveDiacritics(x.Pagamento.ToString().Trim()).ToUpper().Contains(filter)) && (x.Conta == null || !ValidationHelper.RemoveDiacritics(x.Conta.Descricao.Trim()).ToUpper().Contains(filter)) && (x.Controle.Historico == null || !ValidationHelper.RemoveDiacritics(x.Controle.Historico.Trim()).ToUpper().Contains(filter)) && !ValidationHelper.RemoveDiacritics(EnumHelper.GetDescription<Sinal>(x.Sinal).Trim()).Contains(filter))
+ {
+ ControleFinanceiro controle = x.Controle;
+ if (((controle != null) ? controle.Plano : null) == null || !ValidationHelper.RemoveDiacritics(x.Controle.Plano.Descricao.Trim()).ToUpper().Contains(filter))
+ {
+ _ = x.TipoPagamento;
+ if (!ValidationHelper.RemoveDiacritics(EnumHelper.GetDescription<TipoPagamento>(x.TipoPagamento).Trim()).ToUpper().Contains(filter))
+ {
+ ControleFinanceiro controle2 = x.Controle;
+ if (((controle2 != null) ? controle2.Centro : null) == null || !ValidationHelper.RemoveDiacritics(x.Controle.Centro.Descricao.Trim()).ToUpper().Contains(filter))
+ {
+ ControleFinanceiro controle3 = x.Controle;
+ if (((controle3 != null) ? controle3.Fornecedor : null) != null)
+ {
+ return ValidationHelper.RemoveDiacritics(x.Controle.Fornecedor.Nome.Trim()).ToUpper().Contains(filter);
+ }
+ return false;
+ }
+ }
+ }
+ }
+ return true;
+ })));
+ _dontSort = false;
+ LancamentosFiltradosCopia = LancamentosFiltrados;
+ return LancamentosFiltrados.ToList();
+ }
+
+ public void SelecionarTodos()
+ {
+ List<Lancamento> list = LancamentosFiltrados.ToList();
+ list.ForEach(delegate(Lancamento x)
+ {
+ x.Selecionado = !x.Selecionado;
+ if (!x.Baixado && !importando)
+ {
+ if (!x.Selecionado)
+ {
+ x.Baixa = null;
+ x.Pagamento = null;
+ x.ValorPago = default(decimal);
+ }
+ else
+ {
+ DateTime date = Funcoes.GetNetworkTime().Date;
+ x.Baixa = ((!x.Baixa.HasValue) ? new DateTime?(date) : x.Baixa);
+ x.Baixa = date;
+ x.Pagamento = ((!x.Pagamento.HasValue) ? new DateTime?(date) : x.Pagamento);
+ decimal? valorPago = x.ValorPago;
+ x.ValorPago = (((valorPago.GetValueOrDefault() == default(decimal)) & valorPago.HasValue) ? new decimal?(x.Valor) : x.ValorPago);
+ }
+ }
+ });
+ LancamentosFiltrados = new ObservableCollection<Lancamento>(list);
+ LancamentosFiltradosCopia = LancamentosFiltrados;
+ }
+
+ private static List<RelatorioLancamentos> GerarRelatorio(List<Lancamento> lancamentos)
+ {
+ return ((IEnumerable<Lancamento>)lancamentos).Select((Func<Lancamento, RelatorioLancamentos>)delegate(Lancamento x)
+ {
+ //IL_0000: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0005: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0022: Unknown result type (might be due to invalid IL or missing references)
+ //IL_002e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_003a: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0046: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0052: Unknown result type (might be due to invalid IL or missing references)
+ //IL_005e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_006a: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0076: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0082: Unknown result type (might be due to invalid IL or missing references)
+ //IL_008e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00ab: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00cd: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00ea: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0102: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0127: Unknown result type (might be due to invalid IL or missing references)
+ //IL_013d: Unknown result type (might be due to invalid IL or missing references)
+ //IL_014a: Expected O, but got Unknown
+ RelatorioLancamentos val = new RelatorioLancamentos();
+ Fornecedor fornecedor = x.Controle.Fornecedor;
+ val.Fornecedor = ((fornecedor != null) ? fornecedor.Nome : null);
+ val.Historico = x.Historico;
+ val.Observacao = x.Observacao;
+ val.Documento = x.Documento;
+ val.Parcela = x.Parcela;
+ val.Vencimento = x.Vencimento;
+ val.Valor = x.Valor;
+ val.Baixa = x.Baixa;
+ val.ValorPago = x.ValorPago;
+ val.Pagamento = x.Pagamento;
+ Planos plano = x.Controle.Plano;
+ val.Plano = ((plano != null) ? plano.Descricao : null);
+ Planos plano2 = x.Controle.Plano;
+ val.Planos = ((plano2 != null) ? plano2.Plano.Descricao : null);
+ Centro centro = x.Controle.Centro;
+ val.Centro = ((centro != null) ? centro.Descricao : null);
+ BancosContas conta = x.Conta;
+ val.Conta = ((conta != null) ? conta.Descricao : null);
+ Fornecedor fornecedor2 = x.Controle.Fornecedor;
+ val.Sinal = ((((fornecedor2 != null) ? fornecedor2.Nome : null) == "TOTAL") ? "" : EnumHelper.GetDescription<Sinal>(x.Sinal));
+ val.Competencia = x.Competencia;
+ return val;
+ }).ToList();
+ }
+
+ public async Task GerarExcel(List<Lancamento> relatorioGrid)
+ {
+ bool agrupar = await ShowMessage("DESEJA AGRUPAR POR " + EnumHelper.GetDescription<SinteticoFinanceiroTipo>(SinteticoTipo), "SIM", "NÃO");
+ XLWorkbook xlWorkbook = new XLWorkbook();
+ string nome = "LANÇAMENTOS FINANCEIROS";
+ new List<RelatorioLancamentos>();
+ List<Lancamento> lancamentosRelatorio = new List<Lancamento>();
+ bool selecionados = relatorioGrid.Any((Lancamento x) => x.Selecionado);
+ relatorioGrid.ToList().ForEach(delegate(Lancamento lancamentoGrid)
+ {
+ //IL_0017: Unknown result type (might be due to invalid IL or missing references)
+ //IL_001d: Expected O, but got Unknown
+ //IL_001f: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0025: Invalid comparison between Unknown and I4
+ //IL_0041: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0047: Invalid comparison between Unknown and I4
+ if (!selecionados || lancamentoGrid.Selecionado)
+ {
+ Lancamento val2 = (Lancamento)((DomainBase)lancamentoGrid).Clone();
+ val2.Valor = (((int)val2.Sinal == 1) ? (-val2.Valor) : val2.Valor);
+ val2.ValorPago = (((int)val2.Sinal != 1) ? val2.ValorPago : (-val2.ValorPago));
+ lancamentosRelatorio.Add(val2);
+ }
+ });
+ List<SinteticoFinanceiro> source = lancamentosRelatorio.GroupBy(delegate(Lancamento lancamento)
+ {
+ //IL_0006: Unknown result type (might be due to invalid IL or missing references)
+ //IL_000c: Invalid comparison between Unknown and I4
+ //IL_0014: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0021: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0027: Invalid comparison between Unknown and I4
+ object obj7;
+ if ((int)SinteticoTipo != 1)
+ {
+ if ((int)SinteticoTipo != 0)
+ {
+ if ((int)SinteticoTipo != 3)
+ {
+ Fornecedor fornecedor4 = lancamento.Controle.Fornecedor;
+ if (fornecedor4 == null)
+ {
+ return (string)null;
+ }
+ return fornecedor4.Nome;
+ }
+ BancosContas conta4 = lancamento.Conta;
+ obj7 = ((conta4 != null) ? conta4.Descricao : null);
+ if (obj7 == null)
+ {
+ return "";
+ }
+ }
+ else
+ {
+ Planos plano4 = lancamento.Controle.Plano;
+ obj7 = ((plano4 != null) ? plano4.Nome : null);
+ if (obj7 == null)
+ {
+ return "";
+ }
+ }
+ }
+ else
+ {
+ Centro centro4 = lancamento.Controle.Centro;
+ obj7 = ((centro4 != null) ? centro4.Descricao : null) ?? "";
+ }
+ return (string)obj7;
+ }).Select((Func<IGrouping<string, Lancamento>, SinteticoFinanceiro>)((IGrouping<string, Lancamento> lancamento) => new SinteticoFinanceiro
+ {
+ Agrupamento = (lancamento.Key ?? "TRANSFERÊNCIAS"),
+ Valor = lancamento.Sum((Lancamento sintetic) => sintetic.Valor),
+ ValorPago = lancamento.Sum((Lancamento sintetic) => sintetic.ValorPago).GetValueOrDefault()
+ })).ToList();
+ source = source.OrderBy((SinteticoFinanceiro lancamento) => lancamento.Agrupamento).ToList();
+ source.Add(new SinteticoFinanceiro
+ {
+ Agrupamento = "TOTAL",
+ Valor = source.Sum((SinteticoFinanceiro sintetic) => sintetic.Valor),
+ ValorPago = source.Sum((SinteticoFinanceiro sintetic) => sintetic.ValorPago)
+ });
+ xlWorkbook = await Funcoes.GerarXls(xlWorkbook, "SINTÉTICO", source);
+ if (agrupar)
+ {
+ SinteticoFinanceiroTipo sinteticoTipo = SinteticoTipo;
+ switch ((int)sinteticoTipo)
+ {
+ case 2:
+ {
+ List<string> list = lancamentosRelatorio.Select(delegate(Lancamento lancamento)
+ {
+ ControleFinanceiro controle6 = lancamento.Controle;
+ object obj4;
+ if (controle6 == null)
+ {
+ obj4 = null;
+ }
+ else
+ {
+ Fornecedor fornecedor3 = controle6.Fornecedor;
+ obj4 = ((fornecedor3 != null) ? fornecedor3.Nome : null);
+ }
+ if (obj4 == null)
+ {
+ obj4 = "";
+ }
+ return (string)obj4;
+ }).Distinct().ToList();
+ foreach (string grupo2 in list)
+ {
+ List<Lancamento> list5 = lancamentosRelatorio.Where(delegate(Lancamento lancamento)
+ {
+ if (string.IsNullOrWhiteSpace(grupo2))
+ {
+ ControleFinanceiro controle4 = lancamento.Controle;
+ object value2;
+ if (controle4 == null)
+ {
+ value2 = null;
+ }
+ else
+ {
+ Fornecedor fornecedor = controle4.Fornecedor;
+ value2 = ((fornecedor != null) ? fornecedor.Nome : null);
+ }
+ return string.IsNullOrEmpty((string?)value2);
+ }
+ ControleFinanceiro controle5 = lancamento.Controle;
+ object obj3;
+ if (controle5 == null)
+ {
+ obj3 = null;
+ }
+ else
+ {
+ Fornecedor fornecedor2 = controle5.Fornecedor;
+ obj3 = ((fornecedor2 != null) ? fornecedor2.Nome : null);
+ }
+ return (string?)obj3 == grupo2;
+ }).ToList();
+ if (list5.Count != 0)
+ {
+ List<RelatorioLancamentos> list3 = GerarRelatorio(list5);
+ list3.Add(new RelatorioLancamentos
+ {
+ Fornecedor = "TOTAL",
+ Valor = list5.Sum((Lancamento lancamento) => lancamento.Valor),
+ ValorPago = list5.Sum((Lancamento lancamento) => lancamento.ValorPago)
+ });
+ nome = grupo2.ValidaNomePlanilha();
+ xlWorkbook = await Funcoes.GerarXls(xlWorkbook, nome, list3);
+ }
+ }
+ break;
+ }
+ case 1:
+ {
+ List<string> list = lancamentosRelatorio.Select(delegate(Lancamento lancamento)
+ {
+ ControleFinanceiro controle9 = lancamento.Controle;
+ object obj6;
+ if (controle9 == null)
+ {
+ obj6 = null;
+ }
+ else
+ {
+ Centro centro3 = controle9.Centro;
+ obj6 = ((centro3 != null) ? centro3.Descricao : null);
+ }
+ if (obj6 == null)
+ {
+ obj6 = "";
+ }
+ return (string)obj6;
+ }).Distinct().ToList();
+ foreach (string grupo3 in list)
+ {
+ List<Lancamento> list4 = lancamentosRelatorio.Where(delegate(Lancamento lanamento)
+ {
+ if (string.IsNullOrWhiteSpace(grupo3))
+ {
+ ControleFinanceiro controle7 = lanamento.Controle;
+ object value3;
+ if (controle7 == null)
+ {
+ value3 = null;
+ }
+ else
+ {
+ Centro centro = controle7.Centro;
+ value3 = ((centro != null) ? centro.Descricao : null);
+ }
+ return string.IsNullOrEmpty((string?)value3);
+ }
+ ControleFinanceiro controle8 = lanamento.Controle;
+ object obj5;
+ if (controle8 == null)
+ {
+ obj5 = null;
+ }
+ else
+ {
+ Centro centro2 = controle8.Centro;
+ obj5 = ((centro2 != null) ? centro2.Descricao : null);
+ }
+ return (string?)obj5 == grupo3;
+ }).ToList();
+ if (list4.Count != 0)
+ {
+ List<RelatorioLancamentos> list3 = GerarRelatorio(list4);
+ list3.Add(new RelatorioLancamentos
+ {
+ Fornecedor = "TOTAL",
+ Valor = list4.Sum((Lancamento lancamento) => lancamento.Valor),
+ ValorPago = list4.Sum((Lancamento lancamento) => lancamento.ValorPago)
+ });
+ nome = grupo3.ValidaNomePlanilha();
+ xlWorkbook = await Funcoes.GerarXls(xlWorkbook, nome, list3);
+ }
+ }
+ break;
+ }
+ case 0:
+ {
+ List<string> list = lancamentosRelatorio.Select(delegate(Lancamento x)
+ {
+ ControleFinanceiro controle3 = x.Controle;
+ object obj2;
+ if (controle3 == null)
+ {
+ obj2 = null;
+ }
+ else
+ {
+ Planos plano3 = controle3.Plano;
+ obj2 = ((plano3 != null) ? plano3.Descricao : null);
+ }
+ if (obj2 == null)
+ {
+ obj2 = "";
+ }
+ return (string)obj2;
+ }).Distinct().ToList();
+ foreach (string grupo in list)
+ {
+ List<Lancamento> list6 = lancamentosRelatorio.Where(delegate(Lancamento lancamento)
+ {
+ if (string.IsNullOrWhiteSpace(grupo))
+ {
+ ControleFinanceiro controle = lancamento.Controle;
+ object value;
+ if (controle == null)
+ {
+ value = null;
+ }
+ else
+ {
+ Planos plano = controle.Plano;
+ value = ((plano != null) ? plano.Descricao : null);
+ }
+ return string.IsNullOrEmpty((string?)value);
+ }
+ ControleFinanceiro controle2 = lancamento.Controle;
+ object obj;
+ if (controle2 == null)
+ {
+ obj = null;
+ }
+ else
+ {
+ Planos plano2 = controle2.Plano;
+ obj = ((plano2 != null) ? plano2.Descricao : null);
+ }
+ return (string?)obj == grupo;
+ }).ToList();
+ if (list6.Count != 0)
+ {
+ List<RelatorioLancamentos> list3 = GerarRelatorio(list6);
+ list3.Add(new RelatorioLancamentos
+ {
+ Fornecedor = "TOTAL",
+ Valor = list6.Sum((Lancamento lancamento) => lancamento.Valor),
+ ValorPago = list6.Sum((Lancamento lancamento) => lancamento.ValorPago)
+ });
+ nome = ((!string.IsNullOrWhiteSpace(grupo)) ? grupo.ValidaNomePlanilha() : "TRANSFERENCIAS");
+ xlWorkbook = await Funcoes.GerarXls(xlWorkbook, nome, list3);
+ }
+ }
+ break;
+ }
+ case 3:
+ {
+ List<string> list = lancamentosRelatorio.Select(delegate(Lancamento x)
+ {
+ BancosContas conta3 = x.Conta;
+ return ((conta3 != null) ? conta3.Descricao : null) ?? "";
+ }).Distinct().ToList();
+ foreach (string grupo4 in list)
+ {
+ if (string.IsNullOrWhiteSpace(grupo4))
+ {
+ continue;
+ }
+ List<Lancamento> list2 = lancamentosRelatorio.Where(delegate(Lancamento lancamento)
+ {
+ if (string.IsNullOrWhiteSpace(grupo4))
+ {
+ BancosContas conta = lancamento.Conta;
+ return string.IsNullOrEmpty((conta != null) ? conta.Descricao : null);
+ }
+ BancosContas conta2 = lancamento.Conta;
+ return ((conta2 != null) ? conta2.Descricao : null) == grupo4;
+ }).ToList();
+ if (list2.Count != 0)
+ {
+ List<RelatorioLancamentos> list3 = GerarRelatorio(list2);
+ list3.Add(new RelatorioLancamentos
+ {
+ Fornecedor = "TOTAL",
+ Valor = list2.Sum((Lancamento lancamento) => lancamento.Valor),
+ ValorPago = list2.Sum((Lancamento lancamento) => lancamento.ValorPago)
+ });
+ nome = grupo4.ValidaNomePlanilha();
+ xlWorkbook = await Funcoes.GerarXls(xlWorkbook, nome, list3);
+ }
+ }
+ break;
+ }
+ }
+ }
+ else
+ {
+ List<RelatorioLancamentos> list3 = GerarRelatorio(lancamentosRelatorio);
+ list3.Add(new RelatorioLancamentos
+ {
+ Fornecedor = "TOTAL",
+ Valor = list3.Sum((RelatorioLancamentos lancamento) => lancamento.Valor),
+ ValorPago = list3.Sum((RelatorioLancamentos lancamento) => lancamento.ValorPago)
+ });
+ xlWorkbook = await Funcoes.GerarXls(xlWorkbook, nome, list3);
+ }
+ string text = "";
+ string text2;
+ if (Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 41))
+ {
+ FolderBrowserDialog val = new FolderBrowserDialog();
+ try
+ {
+ if (1 != (int)((CommonDialog)val).ShowDialog())
+ {
+ return;
+ }
+ text = val.SelectedPath + "\\";
+ Directory.CreateDirectory(text);
+ }
+ finally
+ {
+ ((IDisposable)val)?.Dispose();
+ }
+ text2 = text + nome + " " + Functions.GetNetworkTime().Date.ToShortDateString().Replace("/", "") + ".xlsx";
+ }
+ else
+ {
+ text = Path.GetTempPath();
+ text2 = $"{text}{Guid.NewGuid()}.xlsx";
+ }
+ xlWorkbook.SaveAs(text2);
+ Process.Start(text2);
+ }
+
+ private async Task<string> GerarHtml(List<Lancamento> relatorioGrid, bool posicao = false)
+ {
+ TipoRelatorio tipo = new TipoRelatorio
+ {
+ Nome = "RELATÓRIO FINANCEIRO",
+ Inicio = (Inicio ?? DateTime.MinValue),
+ Fim = (Fim ?? DateTime.MinValue)
+ };
+ FiltroLancamento selectedFiltro = SelectedFiltro;
+ switch ((int)selectedFiltro)
+ {
+ case 3:
+ tipo.Nome = SelectedFornecedor.Nome;
+ tipo.Inicio = DateTime.MinValue;
+ tipo.Fim = DateTime.MinValue;
+ break;
+ case 0:
+ tipo.Nome = "RELATORIO FINANCEIRO - VENCIMENTO";
+ break;
+ case 1:
+ tipo.Nome = "RELATORIO FINANCEIRO - BAIXA";
+ break;
+ case 2:
+ tipo.Nome = "RELATORIO FINANCEIRO - PAGAMENTO";
+ break;
+ }
+ List<string> colunasOcultas = Funcoes.OcultarColunasDescricao(typeof(Sintetico), "FINANCEIRO");
+ List<Lancamento> lancamentosRelatorio = new List<Lancamento>();
+ bool selecionados = relatorioGrid.Any((Lancamento x) => x.Selecionado);
+ relatorioGrid.ToList().ForEach(delegate(Lancamento lancamentoGrid)
+ {
+ //IL_0017: Unknown result type (might be due to invalid IL or missing references)
+ //IL_001d: Expected O, but got Unknown
+ //IL_001f: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0025: Invalid comparison between Unknown and I4
+ //IL_0041: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0047: Invalid comparison between Unknown and I4
+ if (!selecionados || lancamentoGrid.Selecionado)
+ {
+ Lancamento val = (Lancamento)((DomainBase)lancamentoGrid).Clone();
+ val.Valor = (((int)val.Sinal == 1) ? (-val.Valor) : val.Valor);
+ val.ValorPago = (((int)val.Sinal != 1) ? val.ValorPago : (-val.ValorPago));
+ lancamentosRelatorio.Add(val);
+ }
+ });
+ List<SinteticoFinanceiro> source = lancamentosRelatorio.GroupBy(delegate(Lancamento lancamento)
+ {
+ //IL_0006: Unknown result type (might be due to invalid IL or missing references)
+ //IL_000c: Invalid comparison between Unknown and I4
+ //IL_0014: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0021: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0027: Invalid comparison between Unknown and I4
+ object obj2;
+ if ((int)SinteticoTipo != 1)
+ {
+ if ((int)SinteticoTipo != 0)
+ {
+ if ((int)SinteticoTipo != 3)
+ {
+ Fornecedor fornecedor3 = lancamento.Controle.Fornecedor;
+ if (fornecedor3 == null)
+ {
+ return (string)null;
+ }
+ return fornecedor3.Nome;
+ }
+ BancosContas conta3 = lancamento.Conta;
+ obj2 = ((conta3 != null) ? conta3.Descricao : null);
+ if (obj2 == null)
+ {
+ return "";
+ }
+ }
+ else
+ {
+ Planos plano3 = lancamento.Controle.Plano;
+ obj2 = ((plano3 != null) ? plano3.Descricao : null);
+ if (obj2 == null)
+ {
+ return "";
+ }
+ }
+ }
+ else
+ {
+ Centro centro3 = lancamento.Controle.Centro;
+ obj2 = ((centro3 != null) ? centro3.Descricao : null) ?? "";
+ }
+ return (string)obj2;
+ }).Select((Func<IGrouping<string, Lancamento>, SinteticoFinanceiro>)((IGrouping<string, Lancamento> lancamento) => new SinteticoFinanceiro
+ {
+ Agrupamento = (lancamento.Key ?? "TRANSFERÊNCIAS"),
+ Valor = lancamento.Sum((Lancamento sintetic) => sintetic.Valor),
+ ValorPago = lancamento.Sum((Lancamento sintetic) => sintetic.ValorPago).GetValueOrDefault()
+ })).ToList();
+ source = source.OrderBy((SinteticoFinanceiro lancamento) => lancamento.Agrupamento).ToList();
+ source.Add(new SinteticoFinanceiro
+ {
+ Agrupamento = "TOTAL",
+ Valor = source.Sum((SinteticoFinanceiro sintetic) => sintetic.Valor),
+ ValorPago = source.Sum((SinteticoFinanceiro sintetic) => sintetic.ValorPago)
+ });
+ string body = await Funcoes.GenerateTable(source, colunasOcultas);
+ string relatorio = Funcoes.CreateCard("SINTÉTICO " + EnumHelper.GetDescription<SinteticoFinanceiroTipo>(SinteticoTipo), body);
+ List<string> list = (from lancamento in lancamentosRelatorio.GroupBy(delegate(Lancamento lancamento)
+ {
+ //IL_0006: Unknown result type (might be due to invalid IL or missing references)
+ //IL_000c: Invalid comparison between Unknown and I4
+ //IL_0014: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0021: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0027: Invalid comparison between Unknown and I4
+ object obj;
+ if ((int)SinteticoTipo != 1)
+ {
+ if ((int)SinteticoTipo != 0)
+ {
+ if ((int)SinteticoTipo != 3)
+ {
+ Fornecedor fornecedor2 = lancamento.Controle.Fornecedor;
+ if (fornecedor2 == null)
+ {
+ return (string)null;
+ }
+ return fornecedor2.Nome;
+ }
+ BancosContas conta2 = lancamento.Conta;
+ obj = ((conta2 != null) ? conta2.Descricao : null);
+ if (obj == null)
+ {
+ return "";
+ }
+ }
+ else
+ {
+ Planos plano2 = lancamento.Controle.Plano;
+ obj = ((plano2 != null) ? plano2.Nome : null);
+ if (obj == null)
+ {
+ return "";
+ }
+ }
+ }
+ else
+ {
+ Centro centro2 = lancamento.Controle.Centro;
+ obj = ((centro2 != null) ? centro2.Descricao : null) ?? "";
+ }
+ return (string)obj;
+ })
+ select lancamento.Key).Distinct().ToList();
+ foreach (string grupo in list)
+ {
+ List<Lancamento> list2 = lancamentosRelatorio.Where(delegate(Lancamento lancamento)
+ {
+ //IL_000b: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0011: Invalid comparison between Unknown and I4
+ //IL_0021: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0033: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0039: Invalid comparison between Unknown and I4
+ if ((int)SinteticoTipo != 1)
+ {
+ if ((int)SinteticoTipo != 0)
+ {
+ if ((int)SinteticoTipo != 3)
+ {
+ Fornecedor fornecedor = lancamento.Controle.Fornecedor;
+ return ((fornecedor != null) ? fornecedor.Nome : null) == grupo;
+ }
+ BancosContas conta = lancamento.Conta;
+ return ((conta != null) ? conta.Descricao : null) == grupo;
+ }
+ Planos plano = lancamento.Controle.Plano;
+ return ((plano != null) ? plano.Nome : null) == grupo;
+ }
+ Centro centro = lancamento.Controle.Centro;
+ return ((centro != null) ? centro.Descricao : null) == grupo;
+ }).ToList();
+ if (list2.Count != 0)
+ {
+ list2.Add(new Lancamento
+ {
+ Controle = new ControleFinanceiro
+ {
+ Fornecedor = new Fornecedor
+ {
+ Nome = "TOTAL"
+ }
+ },
+ Valor = list2.Sum((Lancamento lancamento) => lancamento.Valor),
+ ValorPago = list2.Sum((Lancamento lancamento) => lancamento.ValorPago)
+ });
+ string body2 = await Funcoes.GenerateTable(GerarRelatorio(list2), new List<string>());
+ relatorio += Funcoes.CreateCard(grupo, body2);
+ }
+ }
+ int num = (Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 14) ? 70 : 50);
+ return Funcoes.ExportarHtml(tipo, relatorio ?? "", num.ToString(), posicao ? "landscape" : "portrait");
+ }
+
+ public async Task Print(List<Lancamento> relatorioGrid, bool posicao = false)
+ {
+ string path = Path.GetTempPath();
+ string value = await GerarHtml(relatorioGrid, posicao);
+ string text = $"{path}RELATORIO FINANCEIRO_{Funcoes.GetNetworkTime():ddMMyyyyhhmmss}.html";
+ StreamWriter streamWriter = new StreamWriter(text, append: true, Encoding.UTF8);
+ streamWriter.Write(value);
+ streamWriter.Close();
+ Process.Start(text);
+ }
+
+ public void IncluirLancamento()
+ {
+ //IL_001c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0022: Invalid comparison between Unknown and I4
+ //IL_016b: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0170: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0183: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0188: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0189: Unknown result type (might be due to invalid IL or missing references)
+ //IL_018e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_019a: Unknown result type (might be due to invalid IL or missing references)
+ //IL_01a1: Unknown result type (might be due to invalid IL or missing references)
+ //IL_01a8: Unknown result type (might be due to invalid IL or missing references)
+ //IL_01b4: Expected O, but got Unknown
+ //IL_01b4: Unknown result type (might be due to invalid IL or missing references)
+ //IL_01bb: Unknown result type (might be due to invalid IL or missing references)
+ //IL_01c3: Unknown result type (might be due to invalid IL or missing references)
+ //IL_01ca: Unknown result type (might be due to invalid IL or missing references)
+ //IL_01cb: Unknown result type (might be due to invalid IL or missing references)
+ //IL_01d7: Expected O, but got Unknown
+ //IL_01e2: Unknown result type (might be due to invalid IL or missing references)
+ //IL_023b: Unknown result type (might be due to invalid IL or missing references)
+ //IL_029c: Unknown result type (might be due to invalid IL or missing references)
+ Alterando = (Visibility)0;
+ BuscaHabilitada = false;
+ Fornecedor fornecedor = null;
+ if ((int)SelectedFiltro == 3 && SelectedFornecedor != null && SelectedFornecedor.Id > 0)
+ {
+ fornecedor = SelectedFornecedor;
+ }
+ VisibilityFornecedor = (Visibility)((fornecedor != null) ? 2 : 0);
+ Fornecedor obj = fornecedor;
+ Planos plano = ((obj != null && obj.IdPlano.HasValue) ? (((IEnumerable<Planos>)PlanosFiltrados).FirstOrDefault((Func<Planos, bool>)((Planos x) => ((DomainBase)x).Id == fornecedor.IdPlano)) ?? PlanosFiltrados.FirstOrDefault()) : PlanosFiltrados.FirstOrDefault());
+ Fornecedor obj2 = fornecedor;
+ BancosContas conta = ((obj2 != null && obj2.IdConta.HasValue) ? (((IEnumerable<BancosContas>)ContasFiltradas).FirstOrDefault((Func<BancosContas, bool>)((BancosContas x) => ((DomainBase)x).Id == fornecedor.IdConta)) ?? ContasFiltradas.FirstOrDefault()) : ContasFiltradas.FirstOrDefault());
+ Fornecedor obj3 = fornecedor;
+ Centro centro = ((obj3 != null && obj3.IdCentro.HasValue) ? (((IEnumerable<Centro>)CentrosFiltrados).FirstOrDefault((Func<Centro, bool>)((Centro x) => ((DomainBase)x).Id == fornecedor.IdCentro)) ?? CentrosFiltrados.FirstOrDefault()) : CentrosFiltrados.FirstOrDefault());
+ Fornecedor obj4 = fornecedor;
+ TipoPagamento valueOrDefault = ((obj4 != null) ? obj4.TipoPagamento : null).GetValueOrDefault();
+ DateTime date = Funcoes.GetNetworkTime().Date;
+ SelectedLancamento = new Lancamento
+ {
+ Controle = new ControleFinanceiro
+ {
+ Fornecedor = fornecedor,
+ Centro = centro,
+ Plano = plano,
+ Parcelas = 1
+ },
+ Conta = conta,
+ Vencimento = date,
+ Parcela = 1,
+ TipoPagamento = valueOrDefault
+ };
+ FornecedorInclusao = (Fornecedor)(((object)fornecedor) ?? ((object)new Fornecedor()));
+ Historico = "";
+ Documento = "";
+ Competencia = "";
+ Complemento = "";
+ Plano = plano;
+ Centro = centro;
+ Conta = conta;
+ Planos plano2 = Plano;
+ Sinal = (Sinal)((plano2 != null) ? ((int)plano2.Sinal) : 0);
+ Parcelas = 1;
+ Parcela = 0;
+ Vencimento = date;
+ Valor = 0m;
+ Baixa = null;
+ ValorPago = default(decimal);
+ Pagamento = null;
+ TipoPagamento = valueOrDefault;
+ Observacao = "";
+ Alteracao = false;
+ VisibilityCentro = (Visibility)((CentrosFiltrados.Count <= 1) ? 2 : 0);
+ VisibilityConta = (Visibility)((ContasFiltradas.Count <= 1) ? 2 : 0);
+ }
+
+ public void CancelarAlteracao()
+ {
+ LancamentosFiltrados = LancamentosFiltradosCopia;
+ SelectedLancamento = ((IEnumerable<Lancamento>)LancamentosFiltrados).FirstOrDefault((Func<Lancamento, bool>)delegate(Lancamento x)
+ {
+ long id = ((DomainBase)x).Id;
+ Lancamento lancamentoSelecionado = LancamentoSelecionado;
+ return id == ((lancamentoSelecionado != null) ? new long?(((DomainBase)lancamentoSelecionado).Id) : null);
+ });
+ }
+
+ public void DeSelecionarLancamento(Lancamento lancamento)
+ {
+ Lancamento val = ((((DomainBase)lancamento).Id > 0) ? LancamentosFiltrados.First((Lancamento x) => ((DomainBase)x).Id == ((DomainBase)lancamento).Id) : LancamentosFiltrados.First(delegate(Lancamento x)
+ {
+ if (((DomainBase)x).Id == ((DomainBase)lancamento).Id)
+ {
+ ControleFinanceiro controle = x.Controle;
+ long? obj;
+ if (controle == null)
+ {
+ obj = null;
+ }
+ else
+ {
+ Fornecedor fornecedor = controle.Fornecedor;
+ obj = ((fornecedor != null) ? new long?(fornecedor.Id) : null);
+ }
+ long? num = obj;
+ ControleFinanceiro controle2 = lancamento.Controle;
+ long? obj2;
+ if (controle2 == null)
+ {
+ obj2 = null;
+ }
+ else
+ {
+ Fornecedor fornecedor2 = controle2.Fornecedor;
+ obj2 = ((fornecedor2 != null) ? new long?(fornecedor2.Id) : null);
+ }
+ if (num == obj2 && x.Valor == lancamento.Valor && x.Vencimento == lancamento.Vencimento)
+ {
+ ControleFinanceiro controle3 = x.Controle;
+ long? obj3;
+ if (controle3 == null)
+ {
+ obj3 = null;
+ }
+ else
+ {
+ Planos plano = controle3.Plano;
+ obj3 = ((plano != null) ? new long?(((DomainBase)plano).Id) : null);
+ }
+ long? num2 = obj3;
+ ControleFinanceiro controle4 = lancamento.Controle;
+ long? obj4;
+ if (controle4 == null)
+ {
+ obj4 = null;
+ }
+ else
+ {
+ Planos plano2 = controle4.Plano;
+ obj4 = ((plano2 != null) ? new long?(((DomainBase)plano2).Id) : null);
+ }
+ return num2 == obj4;
+ }
+ }
+ return false;
+ }));
+ val.Selecionado = false;
+ if (!val.Baixado)
+ {
+ val.Baixa = null;
+ val.Pagamento = null;
+ val.ValorPago = default(decimal);
+ }
+ LancamentosFiltradosCopia = LancamentosFiltrados;
+ Totalizar();
+ }
+
+ public void SelecionarLancamento(Lancamento lancamento)
+ {
+ Lancamento val = ((((DomainBase)lancamento).Id > 0) ? LancamentosFiltrados.First((Lancamento x) => ((DomainBase)x).Id == ((DomainBase)lancamento).Id) : LancamentosFiltrados.First(delegate(Lancamento x)
+ {
+ if (((DomainBase)x).Id == ((DomainBase)lancamento).Id)
+ {
+ ControleFinanceiro controle = x.Controle;
+ long? obj;
+ if (controle == null)
+ {
+ obj = null;
+ }
+ else
+ {
+ Fornecedor fornecedor = controle.Fornecedor;
+ obj = ((fornecedor != null) ? new long?(fornecedor.Id) : null);
+ }
+ long? num = obj;
+ ControleFinanceiro controle2 = lancamento.Controle;
+ long? obj2;
+ if (controle2 == null)
+ {
+ obj2 = null;
+ }
+ else
+ {
+ Fornecedor fornecedor2 = controle2.Fornecedor;
+ obj2 = ((fornecedor2 != null) ? new long?(fornecedor2.Id) : null);
+ }
+ if (num == obj2 && x.Valor == lancamento.Valor && x.Vencimento == lancamento.Vencimento)
+ {
+ ControleFinanceiro controle3 = x.Controle;
+ long? obj3;
+ if (controle3 == null)
+ {
+ obj3 = null;
+ }
+ else
+ {
+ Planos plano = controle3.Plano;
+ obj3 = ((plano != null) ? new long?(((DomainBase)plano).Id) : null);
+ }
+ long? num2 = obj3;
+ ControleFinanceiro controle4 = lancamento.Controle;
+ long? obj4;
+ if (controle4 == null)
+ {
+ obj4 = null;
+ }
+ else
+ {
+ Planos plano2 = controle4.Plano;
+ obj4 = ((plano2 != null) ? new long?(((DomainBase)plano2).Id) : null);
+ }
+ if (num2 == obj4)
+ {
+ return lancamento.Documento == x.Documento;
+ }
+ }
+ }
+ return false;
+ }));
+ DateTime date = Funcoes.GetNetworkTime().Date;
+ val.Selecionado = true;
+ val.Baixa = val.Baixa ?? val.Pagamento.GetValueOrDefault(date);
+ val.Pagamento = val.Pagamento.GetValueOrDefault(date);
+ decimal? valorPago = val.ValorPago;
+ val.ValorPago = (((valorPago.GetValueOrDefault() == default(decimal)) & valorPago.HasValue) ? new decimal?(lancamento.Valor) : val.ValorPago);
+ LancamentosFiltradosCopia = LancamentosFiltrados;
+ Totalizar();
+ }
+
+ public async void AdcionarFiltroPersonalizado()
+ {
+ if (Filtro == null)
+ {
+ return;
+ }
+ string descricao;
+ if (!SemValor)
+ {
+ List<FiltroPersonalizado> list = ((PersonalizadoSelecionado == null) ? new List<FiltroPersonalizado>() : PersonalizadoSelecionado.Where((FiltroPersonalizado x) => x.Propriedade == Filtro.Propriedade && x.SemValor).ToList());
+ if (list.Count > 0)
+ {
+ list.ForEach(delegate(FiltroPersonalizado x)
+ {
+ PersonalizadoSelecionado.Remove(x);
+ });
+ }
+ switch (Filtro.Tipo.Name)
+ {
+ default:
+ if (string.IsNullOrEmpty(ValorInicial))
+ {
+ await ShowMessage("O VALOR DEVE SER PREENCHIDO CORRETAMENTE.");
+ return;
+ }
+ descricao = Filtro.Nome + " = " + ValorInicial;
+ break;
+ case "DateTime":
+ {
+ if (!DateTime.TryParse(ValorInicial, out var result3) || !DateTime.TryParse(ValorFinal, out result3) || DateTime.Parse(ValorInicial) > DateTime.Parse(ValorFinal))
+ {
+ await ShowMessage("O VALOR DE INTERVALO DEVE SER PREENCHIDO CORRETAMENTE.");
+ return;
+ }
+ descricao = $"{Filtro.Nome}: {DateTime.Parse(ValorInicial):d} até {DateTime.Parse(ValorFinal):d}";
+ break;
+ }
+ case "Decimal":
+ {
+ if (!decimal.TryParse(ValorInicial, out var result2) || !decimal.TryParse(ValorFinal, out result2) || Math.Abs(decimal.Parse(ValorInicial)) > Math.Abs(decimal.Parse(ValorFinal)))
+ {
+ await ShowMessage("O VALOR DE INTERVALO DEVE SER PREENCHIDO CORRETAMENTE.");
+ return;
+ }
+ descricao = $"{Filtro.Nome}: {decimal.Parse(ValorInicial):n2} até {decimal.Parse(ValorFinal):n2}";
+ break;
+ }
+ case "Int32":
+ {
+ if (!int.TryParse(ValorInicial, out var result4) || !int.TryParse(ValorFinal, out result4) || int.Parse(ValorInicial) > int.Parse(ValorFinal))
+ {
+ await ShowMessage("O VALOR DE INTERVALO DEVE SER PREENCHIDO CORRETAMENTE.");
+ return;
+ }
+ descricao = $"{Filtro.Nome}: {int.Parse(ValorInicial):n0} até {int.Parse(ValorFinal):n0}";
+ break;
+ }
+ case "Int64":
+ {
+ if (!long.TryParse(ValorInicial, out var result) || !long.TryParse(ValorFinal, out result) || long.Parse(ValorInicial) > int.Parse(ValorFinal))
+ {
+ await ShowMessage("O VALOR DE INTERVALO DEVE SER PREENCHIDO CORRETAMENTE.");
+ return;
+ }
+ descricao = $"{Filtro.Nome}: {long.Parse(ValorInicial):n0} até {long.Parse(ValorFinal):n0}";
+ break;
+ }
+ }
+ }
+ else
+ {
+ List<FiltroPersonalizado> list2 = ((PersonalizadoSelecionado == null) ? new List<FiltroPersonalizado>() : PersonalizadoSelecionado.Where((FiltroPersonalizado x) => x.Propriedade == Filtro.Propriedade).ToList());
+ if (list2.Count > 0)
+ {
+ list2.ForEach(delegate(FiltroPersonalizado x)
+ {
+ PersonalizadoSelecionado.Remove(x);
+ });
+ }
+ descricao = Filtro.Nome + ": EM BRANCO";
+ }
+ if (PersonalizadoSelecionado == null)
+ {
+ PersonalizadoSelecionado = new ObservableCollection<FiltroPersonalizado>();
+ }
+ PersonalizadoSelecionado.Add(new FiltroPersonalizado
+ {
+ Nome = Filtro.Nome,
+ Propriedade = Filtro.Propriedade,
+ Tipo = Filtro.Tipo,
+ ValorIncial = ValorInicial,
+ ValorFinal = ValorFinal,
+ SemValor = SemValor,
+ Descricao = descricao
+ });
+ Filtro = null;
+ ValorInicial = string.Empty;
+ ValorFinal = string.Empty;
+ PesquisaPersonalizada();
+ }
+
+ public void PesquisaPersonalizada()
+ {
+ List<FiltroPersonalizado> property = PersonalizadoSelecionado.Where((FiltroPersonalizado x) => !x.Propriedade.Contains(".")).ToList();
+ List<Lancamento> lancamentos = Lancamentos.ToList().CustomWhere(property);
+ PersonalizadoSelecionado.Where((FiltroPersonalizado x) => x.Propriedade.Contains(".")).ToList().ForEach(delegate(FiltroPersonalizado x)
+ {
+ switch (x.Nome)
+ {
+ case "FORNECEDOR":
+ lancamentos = lancamentos.Where(delegate(Lancamento l)
+ {
+ ControleFinanceiro controle = l.Controle;
+ object obj;
+ if (controle == null)
+ {
+ obj = null;
+ }
+ else
+ {
+ Fornecedor fornecedor = controle.Fornecedor;
+ obj = ((fornecedor != null) ? fornecedor.NomeSocial : null);
+ }
+ return obj != null && ValidationHelper.AlphanumericAndSpace(l.Controle.Fornecedor.NomeSocial.ToLower().Trim()).Contains(ValidationHelper.AlphanumericAndSpace(x.ValorIncial.ToLower().Trim()));
+ }).ToList();
+ break;
+ case "FORNECEDOR ATIVO":
+ if (x.ValorIncial.Trim().Equals("SIM"))
+ {
+ lancamentos = lancamentos.Where(delegate(Lancamento l)
+ {
+ ControleFinanceiro controle3 = l.Controle;
+ if (controle3 != null)
+ {
+ Fornecedor fornecedor3 = controle3.Fornecedor;
+ if (fornecedor3 != null)
+ {
+ _ = fornecedor3.Ativo;
+ if (true)
+ {
+ return l.Controle.Fornecedor.Ativo;
+ }
+ }
+ }
+ return false;
+ }).ToList();
+ }
+ else if (x.ValorIncial.Equals("NÃO"))
+ {
+ lancamentos = lancamentos.Where(delegate(Lancamento l)
+ {
+ ControleFinanceiro controle2 = l.Controle;
+ if (controle2 != null)
+ {
+ Fornecedor fornecedor2 = controle2.Fornecedor;
+ if (fornecedor2 != null)
+ {
+ _ = fornecedor2.Ativo;
+ if (true)
+ {
+ return !l.Controle.Fornecedor.Ativo;
+ }
+ }
+ }
+ return false;
+ }).ToList();
+ }
+ break;
+ case "CONTA":
+ lancamentos = lancamentos.Where(delegate(Lancamento l)
+ {
+ BancosContas conta = l.Conta;
+ return ((conta != null) ? conta.Descricao : null) != null && ValidationHelper.AlphanumericAndSpace(l.Conta.Descricao.ToLower().Trim()).Contains(ValidationHelper.AlphanumericAndSpace(x.ValorIncial.ToLower().Trim()));
+ }).ToList();
+ break;
+ case "PLANO DE CONTAS":
+ lancamentos = lancamentos.Where(delegate(Lancamento l)
+ {
+ ControleFinanceiro controle4 = l.Controle;
+ object obj2;
+ if (controle4 == null)
+ {
+ obj2 = null;
+ }
+ else
+ {
+ Planos plano = controle4.Plano;
+ obj2 = ((plano != null) ? plano.Descricao : null);
+ }
+ return obj2 != null && ValidationHelper.AlphanumericAndSpace(l.Controle.Plano.Descricao.ToLower().Trim()).Contains(ValidationHelper.AlphanumericAndSpace(x.ValorIncial.ToLower().Trim()));
+ }).ToList();
+ break;
+ case "CENTRO DE CUSTO":
+ lancamentos = lancamentos.Where(delegate(Lancamento l)
+ {
+ ControleFinanceiro controle5 = l.Controle;
+ object obj3;
+ if (controle5 == null)
+ {
+ obj3 = null;
+ }
+ else
+ {
+ Centro centro = controle5.Centro;
+ obj3 = ((centro != null) ? centro.Descricao : null);
+ }
+ return obj3 != null && ValidationHelper.AlphanumericAndSpace(l.Controle.Centro.Descricao.ToLower().Trim()).Contains(ValidationHelper.AlphanumericAndSpace(x.ValorIncial.ToLower().Trim()));
+ }).ToList();
+ break;
+ case "PLANO":
+ lancamentos = lancamentos.Where(delegate(Lancamento l)
+ {
+ ControleFinanceiro controle6 = l.Controle;
+ object obj4;
+ if (controle6 == null)
+ {
+ obj4 = null;
+ }
+ else
+ {
+ Planos plano2 = controle6.Plano;
+ obj4 = ((plano2 != null) ? plano2.Nome : null);
+ }
+ return obj4 != null && ValidationHelper.AlphanumericAndSpace(l.Controle.Plano.Nome.ToLower().Trim()).Contains(ValidationHelper.AlphanumericAndSpace(x.ValorIncial.ToLower().Trim()));
+ }).ToList();
+ break;
+ }
+ });
+ LancamentosFiltrados = new ObservableCollection<Lancamento>(lancamentos);
+ }
+
+ public async void PopularFiltro()
+ {
+ if (FiltroPersonalizado == null || FiltroPersonalizado.Count <= 0)
+ {
+ FiltroPersonalizado = new List<FiltroPersonalizado>();
+ List<FiltroPersonalizado> collection = ((IEnumerable<Fornecedor>)(await new BaseServico().BuscarFornecedor())).Select((Func<Fornecedor, FiltroPersonalizado>)((Fornecedor x) => new FiltroPersonalizado
+ {
+ Tipo = (TipoFiltroFinanceiro)0,
+ Descricao = x.Nome + " " + x.Documento,
+ Id = x.Id
+ })).ToList();
+ FiltroPersonalizado.AddRange(collection);
+ collection = ((IEnumerable<Centro>)Centros).Select((Func<Centro, FiltroPersonalizado>)((Centro x) => new FiltroPersonalizado
+ {
+ Tipo = (TipoFiltroFinanceiro)2,
+ Descricao = x.Descricao,
+ Id = ((DomainBase)x).Id
+ })).ToList();
+ FiltroPersonalizado.AddRange(collection);
+ collection = ((IEnumerable<Planos>)Planos).Select((Func<Planos, FiltroPersonalizado>)((Planos x) => new FiltroPersonalizado
+ {
+ Tipo = (TipoFiltroFinanceiro)1,
+ Descricao = x.Descricao,
+ Id = ((DomainBase)x).Id
+ })).ToList();
+ FiltroPersonalizado.AddRange(collection);
+ collection = ((IEnumerable<BancosContas>)Contas).Select((Func<BancosContas, FiltroPersonalizado>)((BancosContas x) => new FiltroPersonalizado
+ {
+ Tipo = (TipoFiltroFinanceiro)3,
+ Descricao = x.Descricao,
+ Id = ((DomainBase)x).Id
+ })).ToList();
+ FiltroPersonalizado.AddRange(collection);
+ FiltroPersonalizado.Add(new FiltroPersonalizado
+ {
+ Descricao = EnumHelper.GetDescription<Sinal>((Sinal)0),
+ Id = 0L,
+ Tipo = (TipoFiltroFinanceiro)4
+ });
+ FiltroPersonalizado.Add(new FiltroPersonalizado
+ {
+ Descricao = EnumHelper.GetDescription<Sinal>((Sinal)1),
+ Id = 1L,
+ Tipo = (TipoFiltroFinanceiro)4
+ });
+ }
+ }
+
+ internal async Task<List<FiltroPersonalizado>> FiltroPersonalizadoTask(string value)
+ {
+ return await Task.Run(() => FiltrarPersonalizado(value));
+ }
+
+ public List<FiltroPersonalizado> FiltrarPersonalizado(string filter)
+ {
+ if (FiltroPersonalizado == null)
+ {
+ PopularFiltro();
+ }
+ return FiltroPersonalizado.Where((FiltroPersonalizado x) => ValidationHelper.RemoveDiacritics(x.Descricao.Trim()).ToUpper().Contains(filter.ToUpper())).ToList();
+ }
+
+ public void AdicionarFiltro(FiltroPersonalizado filtro)
+ {
+ if (filtro != null)
+ {
+ if (FiltroPersonalizadoSelecionado == null)
+ {
+ FiltroPersonalizadoSelecionado = new ObservableCollection<FiltroPersonalizado>();
+ }
+ VisibleFiltros = (Visibility)0;
+ if (!FiltroPersonalizadoSelecionado.Any((FiltroPersonalizado x) => x.Id == filtro.Id && x.Tipo == filtro.Tipo))
+ {
+ FiltroPersonalizadoSelecionado.Add(filtro);
+ FiltrarPersonalizado();
+ }
+ }
+ }
+
+ public void LimparLancamentos()
+ {
+ Lancamentos = new ObservableCollection<Lancamento>();
+ LancamentosFiltrados = new ObservableCollection<Lancamento>();
+ LimparFiltros();
+ }
+
+ public void ExcluirFiltro(FiltroPersonalizado filtro)
+ {
+ FiltroPersonalizado item = FiltroPersonalizadoSelecionado.First((FiltroPersonalizado x) => x.Id == filtro.Id && x.Tipo == filtro.Tipo);
+ FiltroPersonalizadoSelecionado.Remove(item);
+ FiltroPersonalizadoSelecionado = new ObservableCollection<FiltroPersonalizado>(FiltroPersonalizadoSelecionado);
+ FiltrarPersonalizado();
+ }
+
+ public void LimparFiltros()
+ {
+ FiltroPersonalizadoSelecionado = null;
+ VisibleFiltros = (Visibility)2;
+ }
+
+ public async Task<List<KeyValuePair<string, string>>> Salvar(Transferencia transferencia)
+ {
+ List<KeyValuePair<string, string>> errors = transferencia.Validate();
+ List<KeyValuePair<string, string>> list = errors;
+ list.AddRange(await Validar(transferencia));
+ if (errors.Count > 0)
+ {
+ return errors;
+ }
+ ControleFinanceiro controle = new ControleFinanceiro
+ {
+ Historico = "TRANSFERÊNCIA ENTRE CONTAS",
+ Parcelas = 2
+ };
+ Lancamento lancamentoOrigem = new Lancamento
+ {
+ Controle = controle,
+ Historico = "TRANSFERÊNCIA ENTRE CONTAS",
+ Vencimento = transferencia.Data,
+ Conta = transferencia.Origem,
+ Valor = transferencia.Valor,
+ ValorPago = transferencia.Valor,
+ Pagamento = transferencia.Data,
+ Baixa = transferencia.Data,
+ Parcela = 1,
+ Sinal = (Sinal)1,
+ TipoPagamento = (TipoPagamento)11
+ };
+ Lancamento lancamentoDestino = new Lancamento
+ {
+ Controle = controle,
+ Historico = "TRANSFERÊNCIA ENTRE CONTAS",
+ Vencimento = transferencia.Data,
+ Conta = transferencia.Destino,
+ Valor = transferencia.Valor,
+ ValorPago = transferencia.Valor,
+ Pagamento = transferencia.Data,
+ Baixa = transferencia.Data,
+ Parcela = 2,
+ Sinal = (Sinal)0,
+ TipoPagamento = (TipoPagamento)11
+ };
+ if (!(await _servico.Transferir(lancamentoOrigem, lancamentoDestino)))
+ {
+ return null;
+ }
+ await CarregarSaldos();
+ ToggleSnackBar("TRANSFERÊNCIA REALIZADA COM SUCESSO");
+ return null;
+ }
+
+ private async Task<List<KeyValuePair<string, string>>> Validar(Transferencia transferencia)
+ {
+ List<KeyValuePair<string, string>> errors = ValidationHelper.AddValue();
+ BancosContasServico servico = new BancosContasServico();
+ Transferencia obj = transferencia;
+ if (((obj != null) ? obj.Origem : null) == null)
+ {
+ ValidationHelper.AddValue<string, string>(errors, "ORIGEM", "NÃO É POSSÍVEL FAZER UMA TRANSFERÊNCIA SEM BANDO ORIGEM", true);
+ return errors;
+ }
+ Transferencia obj2 = transferencia;
+ if (((obj2 != null) ? obj2.Destino : null) == null)
+ {
+ ValidationHelper.AddValue<string, string>(errors, "DESTINO", "NÃO É POSSÍVEL FAZER UMA TRANSFERÊNCIA SEM BANDO DESTINO", true);
+ return errors;
+ }
+ List<long> ids = new List<long>
+ {
+ ((DomainBase)transferencia.Origem).Id,
+ ((DomainBase)transferencia.Destino).Id
+ };
+ List<Saldo> saldos = await servico.BuscarSaldoAberto(ids);
+ Saldo saldo2 = ((IEnumerable<Saldo>)saldos).FirstOrDefault((Func<Saldo, bool>)((Saldo s) => ((DomainBase)s.Conta).Id == ((DomainBase)transferencia.Origem).Id));
+ if (saldo2 == null)
+ {
+ List<Saldo> todosSaldos = await servico.BuscarSaldos(((DomainBase)transferencia.Origem).Id);
+ Saldo ultimoSaldo = todosSaldos.Find(delegate(Saldo x)
+ {
+ DateTime? dataInicio = x.DataInicio;
+ DateTime? dateTime = todosSaldos.Max((Saldo r) => r.DataInicio);
+ if (dataInicio.HasValue != dateTime.HasValue)
+ {
+ return false;
+ }
+ return !dataInicio.HasValue || dataInicio.GetValueOrDefault() == dateTime.GetValueOrDefault();
+ });
+ bool flag = ultimoSaldo.DataInicio <= transferencia.Data && ultimoSaldo.DataFinal.HasValue;
+ if (flag)
+ {
+ flag = await ShowMessage("O ÚLTIMO SALDO NÃO ESTÁ ABERTO. DESEJA ABRÍ-LO AGORA E CONTINUAR?", "SIM", "NÃO");
+ }
+ if (flag)
+ {
+ ultimoSaldo.DataFinal = null;
+ ultimoSaldo.ValorFinal = null;
+ saldo2 = await servico.Save(ultimoSaldo);
+ }
+ }
+ if (saldo2 == null || saldo2.DataInicio > transferencia.Data)
+ {
+ ValidationHelper.AddValue<string, string>(errors, "SALDO", "NÃO É POSSÍVEL REALIZAR A BAIXA DO LANÇAMENTO POIS NÃO HÁ SALDO ABERTO NO PERÍODO PARA A CONTA " + transferencia.Origem.Descricao + ".", true);
+ }
+ saldo2 = ((IEnumerable<Saldo>)saldos).FirstOrDefault((Func<Saldo, bool>)((Saldo s) => ((DomainBase)s.Conta).Id == ((DomainBase)transferencia.Destino).Id));
+ if (saldo2 == null || saldo2.DataInicio > transferencia.Data)
+ {
+ ValidationHelper.AddValue<string, string>(errors, "SALDO", "NÃO É POSSÍVEL REALIZAR A BAIXA DO LANÇAMENTO POIS NÃO HÁ SALDO ABERTO NO PERÍODO PARA A CONTA " + transferencia.Destino.Descricao + ".", true);
+ }
+ return errors;
+ }
+
+ public async Task AlterarLancamentos(Lancamento lancamentoAtual, bool alterarVencimento, bool alterarValores)
+ {
+ List<Lancamento> source = await _servico.BuscarLancamentosPorControle(((DomainBase)lancamentoAtual.Controle).Id);
+ int i = 1;
+ foreach (Lancamento item in source.Where((Lancamento l) => l.Parcela > lancamentoAtual.Parcela))
+ {
+ if (!item.Baixado)
+ {
+ if (alterarVencimento)
+ {
+ item.Vencimento = lancamentoAtual.Vencimento.AddMonths(i);
+ }
+ if (alterarValores)
+ {
+ item.Valor = lancamentoAtual.Valor;
+ }
+ await _servico.Save(item);
+ }
+ i++;
+ }
+ SelectedLancamento = lancamentoAtual;
+ }
+
+ public async Task<List<KeyValuePair<string, string>>> Salvar()
+ {
+ List<KeyValuePair<string, string>> errors = SelectedLancamento.Validate() ?? new List<KeyValuePair<string, string>>();
+ List<KeyValuePair<string, string>> list = errors;
+ list.AddRange(await Validar());
+ if (errors.Count > 0)
+ {
+ return errors;
+ }
+ if (((DomainBase)SelectedLancamento.Controle).Id == 0 && SelectedLancamento.Controle.Parcelas > 0)
+ {
+ List<Lancamento> list2 = new List<Lancamento>();
+ for (int i = 1; i <= SelectedLancamento.Controle.Parcelas; i++)
+ {
+ Lancamento item = new Lancamento
+ {
+ Controle = new ControleFinanceiro
+ {
+ Centro = SelectedLancamento.Controle.Centro,
+ Fornecedor = SelectedLancamento.Controle.Fornecedor,
+ Historico = SelectedLancamento.Controle.Historico,
+ Id = ((DomainBase)SelectedLancamento.Controle).Id,
+ Parcelas = SelectedLancamento.Controle.Parcelas,
+ Plano = SelectedLancamento.Controle.Plano
+ },
+ Historico = SelectedLancamento.Historico,
+ Observacao = SelectedLancamento.Observacao,
+ Complemento = SelectedLancamento.Complemento,
+ Competencia = SelectedLancamento.Competencia,
+ Vencimento = ((i == 1) ? SelectedLancamento.Vencimento : SelectedLancamento.Vencimento.AddMonths(i - 1)),
+ Conta = SelectedLancamento.Conta,
+ ValorPago = ((i == 1) ? SelectedLancamento.ValorPago : new decimal?(default(decimal))),
+ Pagamento = ((i == 1) ? SelectedLancamento.Pagamento : null),
+ Baixa = ((i == 1) ? SelectedLancamento.Baixa : null),
+ Parcela = i,
+ Documento = ((i == 1) ? SelectedLancamento.Documento : ""),
+ Sinal = SelectedLancamento.Sinal,
+ TipoPagamento = SelectedLancamento.TipoPagamento,
+ Valor = SelectedLancamento.Valor
+ };
+ list2.Add(item);
+ }
+ SelectedLancamento = (await _servico.AddRange(list2)).FirstOrDefault();
+ FinanceiroViewModel financeiroViewModel = this;
+ Lancamento selectedLancamento = SelectedLancamento;
+ object arg = ((selectedLancamento != null) ? new long?(((DomainBase)selectedLancamento).Id) : null);
+ Lancamento selectedLancamento2 = SelectedLancamento;
+ string descricao = $"INSERIU O LANÇAMENTO DO ID {arg} HISTORICO: {((selectedLancamento2 != null) ? selectedLancamento2.Historico : null)}";
+ Lancamento selectedLancamento3 = SelectedLancamento;
+ int num;
+ if (selectedLancamento3 == null)
+ {
+ num = 1;
+ }
+ else
+ {
+ _ = ((DomainBase)selectedLancamento3).Id;
+ num = 0;
+ }
+ financeiroViewModel.RegistrarAcao(descricao, (num != 0) ? 0 : ((DomainBase)SelectedLancamento).Id, (TipoTela)25);
+ VencimentoAlterado = false;
+ return null;
+ }
+ if (((DomainBase)SelectedLancamento.Controle).Id == 0L)
+ {
+ VencimentoAlterado = false;
+ }
+ SelectedLancamento = await _servico.Save(SelectedLancamento);
+ if (VencimentoAlterado && SelectedLancamento.Controle.Parcelas > 1)
+ {
+ if (await ShowMessage("DESEJA ALTERAR O VENCIMENTO PARA OS PRÓXIMOS LANÇAMENTOS?", "SIM", "NÃO"))
+ {
+ await AlterarLancamentos(SelectedLancamento, alterarVencimento: true, alterarValores: false);
+ }
+ VencimentoAlterado = false;
+ }
+ if (SelectedLancamento.Controle.Parcelas > 1 && await ShowMessage("DESEJA ALTERAR O VALOR PARA OS PRÓXIMOS LANÇAMENTOS?", "SIM", "NÃO"))
+ {
+ await AlterarLancamentos(SelectedLancamento, alterarVencimento: false, alterarValores: true);
+ }
+ if (!_servico.Sucesso)
+ {
+ return null;
+ }
+ await Buscar();
+ ToggleSnackBar("LANÇAMENTO SALVO COM SUCESSO");
+ return null;
+ }
+
+ private async Task<List<KeyValuePair<string, string>>> Validar()
+ {
+ List<KeyValuePair<string, string>> errors = ValidationHelper.AddValue();
+ BancosContasServico servico = new BancosContasServico();
+ Saldo saldo = ((IEnumerable<Saldo>)(await servico.BuscarSaldoAberto(Contas.Select((BancosContas x) => ((DomainBase)x).Id).ToList()))).FirstOrDefault((Func<Saldo, bool>)delegate(Saldo s)
+ {
+ long id = ((DomainBase)s.Conta).Id;
+ Lancamento selectedLancamento2 = SelectedLancamento;
+ long? obj;
+ if (selectedLancamento2 == null)
+ {
+ obj = null;
+ }
+ else
+ {
+ BancosContas conta = selectedLancamento2.Conta;
+ obj = ((conta != null) ? new long?(((DomainBase)conta).Id) : null);
+ }
+ return id == obj;
+ });
+ if (saldo == null)
+ {
+ Lancamento selectedLancamento = SelectedLancamento;
+ if (((selectedLancamento != null) ? selectedLancamento.Conta : null) != null)
+ {
+ List<Saldo> todosSaldos = await servico.BuscarSaldos(((DomainBase)SelectedLancamento.Conta).Id);
+ Saldo ultimoSaldo = todosSaldos.Find(delegate(Saldo x)
+ {
+ DateTime? dataInicio = x.DataInicio;
+ DateTime? dateTime = todosSaldos.Max((Saldo r) => r.DataInicio);
+ if (dataInicio.HasValue != dateTime.HasValue)
+ {
+ return false;
+ }
+ return !dataInicio.HasValue || dataInicio.GetValueOrDefault() == dateTime.GetValueOrDefault();
+ });
+ bool flag = ultimoSaldo.DataInicio <= SelectedLancamento.Baixa && ultimoSaldo.DataFinal.HasValue;
+ if (flag)
+ {
+ flag = await ShowMessage("O ÚLTIMO SALDO NÃO ESTÁ ABERTO. DESEJA ABRÍ-LO AGORA E CONTINUAR?", "SIM", "NÃO");
+ }
+ if (flag)
+ {
+ ultimoSaldo.DataFinal = null;
+ ultimoSaldo.ValorFinal = null;
+ saldo = await servico.Save(ultimoSaldo);
+ }
+ }
+ }
+ if (saldo != null && !(saldo.DataInicio > SelectedLancamento.Baixa))
+ {
+ return new List<KeyValuePair<string, string>>();
+ }
+ ValidationHelper.AddValue<string, string>(errors, "SALDO", "NÃO É POSSÍVEL REALIZAR A BAIXA DO LANÇAMENTO POIS NÃO HÁ SALDO ABERTO NO PERÍODO.", true);
+ return errors;
+ }
+
+ public async void IncluirParcela()
+ {
+ if (!LancamentosFiltrados.Any((Lancamento x) => x.Selecionado))
+ {
+ await ShowMessage("NECESSÁRIO SELECIONAR AO MENOS UM LANCAMENTOS PARA INCLUIR UMA NOVA PARCELA.");
+ return;
+ }
+ if (LancamentosFiltrados.Count((Lancamento x) => x.Selecionado) == 1)
+ {
+ SelectedLancamento = ((IEnumerable<Lancamento>)LancamentosFiltrados).FirstOrDefault((Func<Lancamento, bool>)((Lancamento x) => x.Selecionado));
+ }
+ if (LancamentosFiltrados.Count((Lancamento x) => x.Selecionado) > 1)
+ {
+ if (await ShowMessage("HÁ MAIS DE UM LANÇAMENTO SELECIONADO, DESEJA FAZER A INCLUSÃO DE NOVAS PARCELAS PARA TODOS OS LANÇAMENTOS SELECIONADOS?", "SIM", "NÃO"))
+ {
+ await AdicionarParcelaRange();
+ }
+ return;
+ }
+ Lancamento selectedLancamento = SelectedLancamento;
+ if (((selectedLancamento != null) ? selectedLancamento.Controle : null) != null && ((DomainBase)SelectedLancamento.Controle).Id != 0L)
+ {
+ VisibilityFornecedor = (Visibility)2;
+ Alterando = (Visibility)0;
+ BuscaHabilitada = false;
+ SelectedLancamento = new Lancamento
+ {
+ Controle = new ControleFinanceiro
+ {
+ Centro = SelectedLancamento.Controle.Centro,
+ Fornecedor = SelectedLancamento.Controle.Fornecedor,
+ Historico = SelectedLancamento.Controle.Historico,
+ Id = ((DomainBase)SelectedLancamento.Controle).Id,
+ Parcelas = SelectedLancamento.Controle.Parcelas + 1,
+ Plano = SelectedLancamento.Controle.Plano
+ },
+ Historico = SelectedLancamento.Historico,
+ Observacao = SelectedLancamento.Observacao,
+ Vencimento = SelectedLancamento.Vencimento.AddMonths(1),
+ Conta = SelectedLancamento.Conta,
+ Parcela = SelectedLancamento.Parcela + 1,
+ Documento = SelectedLancamento.Documento,
+ Sinal = SelectedLancamento.Sinal,
+ TipoPagamento = SelectedLancamento.TipoPagamento,
+ Valor = SelectedLancamento.Valor
+ };
+ VisibilityCentro = (Visibility)((CentrosFiltrados.Count <= 1) ? 2 : 0);
+ VisibilityConta = (Visibility)((ContasFiltradas.Count <= 1) ? 2 : 0);
+ }
+ }
+
+ private async Task AdicionarParcelaRange()
+ {
+ Loading(isLoading: true);
+ List<Lancamento> lancamentosInclusao = new List<Lancamento>();
+ List<Lancamento> list = LancamentosFiltrados.Where((Lancamento x) => x.Selecionado).Select((Func<Lancamento, Lancamento>)((Lancamento x) => new Lancamento
+ {
+ Controle = new ControleFinanceiro
+ {
+ Centro = x.Controle.Centro,
+ Fornecedor = x.Controle.Fornecedor,
+ Historico = x.Controle.Historico,
+ Id = ((DomainBase)x.Controle).Id,
+ Parcelas = x.Controle.Parcelas + 1,
+ Plano = x.Controle.Plano
+ },
+ Historico = x.Historico,
+ Observacao = x.Observacao,
+ Vencimento = x.Vencimento.AddMonths(1),
+ Conta = x.Conta,
+ Parcela = x.Parcela + 1,
+ Documento = x.Documento,
+ Sinal = x.Sinal,
+ TipoPagamento = x.TipoPagamento,
+ Valor = x.Valor
+ })).ToList();
+ foreach (Lancamento x2 in list)
+ {
+ if (await _servico.BuscarLancamento(((DomainBase)x2.Controle).Id, x2.Parcela) == null)
+ {
+ lancamentosInclusao.Add(x2);
+ }
+ }
+ await _servico.IncluirRange(lancamentosInclusao);
+ if (!_servico.Sucesso)
+ {
+ Loading(isLoading: false);
+ return;
+ }
+ await Buscar();
+ ToggleSnackBar("INCLUSÃO DE PARCELA REALIZADA COM SUCESSO");
+ Loading(isLoading: false);
+ }
+
+ public async Task ExcluirBaixaRange()
+ {
+ List<Lancamento> lancamentos = LancamentosFiltrados.Where((Lancamento x) => (x.Selecionado && x.Controle.Plano != null) || (x.Historico.Equals("TRANSFERÊNCIA ENTRE CONTAS") && x.Selecionado && x.Controle.Plano == null)).ToList();
+ if (lancamentos.Count == 0)
+ {
+ await ShowMessage("NÃO HÁ LANÇAMENTOS SELECIONADOS, SELECIONE-OS ANTES DE EXCLUIR A BAIXA.");
+ }
+ else
+ {
+ if (!(await ShowMessage("DESEJA REAMENTE EXCLUIR A BAIXA DOS LANÇAMENTOS SELECIONADOS?", "SIM", "NÃO")))
+ {
+ return;
+ }
+ Loading(isLoading: true);
+ List<Lancamento> lancamentosExlusao = new List<Lancamento>();
+ bool observacao = false;
+ foreach (Lancamento x2 in lancamentos)
+ {
+ Saldo val = await VerificaSaldo(((DomainBase)x2.Conta).Id, reabrirSaldo: false);
+ if (val != null && x2.Baixado)
+ {
+ if (val.DataInicio > x2.Baixa)
+ {
+ observacao = true;
+ continue;
+ }
+ x2.Baixa = null;
+ x2.ValorPago = default(decimal);
+ x2.Pagamento = null;
+ lancamentosExlusao.Add(x2);
+ }
+ }
+ if (lancamentosExlusao.Count == 0)
+ {
+ await ShowMessage("NÃO FOI POSSÍVEL FAZER A EXCLUSÃO, POIS NÃO HÁ LANÇAMENTOS BAIXADOS DENTRO DO ÚLTIMO SALDO ABERTO. PROCESSO INTERROMPIDO");
+ Loading(isLoading: false);
+ return;
+ }
+ bool flag = observacao;
+ if (flag)
+ {
+ flag = !(await ShowMessage("HÁ LANÇAMENTOS SELECIONADOS QUE NÃO PODERÃO TER A BAIXA EXCLUÍDA. " + Environment.NewLine + "DESEJA PROSSEGUIR COM A EXCLUSÃO DA BAIXA DOS DEMAIS LANÇAMENTOS?", "SIM", "NÃO"));
+ }
+ if (flag)
+ {
+ Loading(isLoading: false);
+ return;
+ }
+ await _servico.Atualizar(lancamentosExlusao);
+ if (!_servico.Sucesso)
+ {
+ Loading(isLoading: false);
+ return;
+ }
+ ToggleSnackBar($"EXCLUSÃO DE BAIXA DE {lancamentosExlusao.Count} DO TOTAL DE {lancamentos.Count} LANÇAMENTOS SELECIONADOS REALIZADA COM SUCESSO.");
+ await Buscar();
+ Loading(isLoading: false);
+ }
+ }
+
+ public async Task ExcluirBaixa()
+ {
+ if (SelectedLancamento == null || ((DomainBase)SelectedLancamento).Id == 0L)
+ {
+ return;
+ }
+ Loading(isLoading: true);
+ if (!(await _servico.BuscarLancamento(((DomainBase)SelectedLancamento).Id)).Baixa.HasValue)
+ {
+ await ShowMessage("LANÇAMENTO AINDA NÃO BAIXADO. PROCESSO INTERROMPIDO");
+ Loading(isLoading: false);
+ return;
+ }
+ if (!(await ShowMessage("DESEJA REAMENTE EXCLUIR A BAIXA DO LANÇAMENTO SELECIONADO?", "SIM", "NÃO")))
+ {
+ Loading(isLoading: false);
+ return;
+ }
+ Saldo val = await VerificaSaldo(((DomainBase)SelectedLancamento.Conta).Id, reabrirSaldo: true);
+ if (val == null)
+ {
+ return;
+ }
+ if (val.DataInicio > SelectedLancamento.Baixa)
+ {
+ await ShowMessage("LANÇAMENTO NÃO PODE TER SUA BAIXA EXCLUÍDA POIS NÃO POSSUI SALDO ABERTO PARA O PERÍODO.");
+ Loading(isLoading: false);
+ return;
+ }
+ SelectedLancamento.Baixa = null;
+ SelectedLancamento.ValorPago = default(decimal);
+ SelectedLancamento.Pagamento = null;
+ SelectedLancamento.Baixado = false;
+ SelectedLancamento = await _servico.Save(SelectedLancamento);
+ if (importando)
+ {
+ BindImportando();
+ LancamentosFiltrados = Lancamentos;
+ Loading(isLoading: false);
+ }
+ else if (_servico.Sucesso)
+ {
+ ToggleSnackBar("EXCLUSÃO DE BAIXA REALIZADA COM SUCESSO");
+ await Buscar();
+ Loading(isLoading: false);
+ }
+ }
+
+ public async Task ExcluirRange()
+ {
+ List<Lancamento> lancamentos = LancamentosFiltrados.Where((Lancamento x) => x.Selecionado).ToList();
+ if (lancamentos.Count == 0)
+ {
+ await ShowMessage("NÃO HÁ LANÇAMENTOS SELECIONADOS, SELECIONE-OS ANTES DE EXCLUIR.");
+ }
+ else
+ {
+ if (!(await ShowMessage("DESEJA REAMENTE EXCLUIR OS LANÇAMENTOS SELECIONADOS? ESSE PROCESSO É IRREVERSÍVEL.", "SIM", "NÃO")))
+ {
+ return;
+ }
+ Loading(isLoading: true);
+ List<Lancamento> lancamentosExlusao = new List<Lancamento>();
+ List<Lancamento> transferencias = LancamentosFiltrados.Where((Lancamento x) => x.Selecionado && x.Historico.Equals("TRANSFERÊNCIA ENTRE CONTAS")).ToList();
+ transferencias.ForEach(delegate(Lancamento x)
+ {
+ Lancamento y = ((IEnumerable<Lancamento>)transferencias).FirstOrDefault((Func<Lancamento, bool>)((Lancamento z) => ((DomainBase)z.Controle).Id == ((DomainBase)x.Controle).Id && x.Valor == z.Valor && x.Sinal != z.Sinal));
+ if (y != null && lancamentosExlusao.Where((Lancamento z) => z == x || z == y).ToList().Count <= 0)
+ {
+ lancamentosExlusao.AddRange(new List<Lancamento> { x, y });
+ }
+ });
+ bool flag = transferencias?.Count != lancamentosExlusao.Count;
+ if (flag)
+ {
+ flag = !(await ShowMessage("HÁ TRANSFERÊNCIA ENTRE CONTAS SELECIONADOS QUE NÃO PODERÃO TER A BAIXA EXCLUÍDA, PARA EXCLUIR É NECESSÁRIO SELECIONAR O DÉBITO E O CRÉDITO DA TRANSFERENCIA" + Environment.NewLine + "DESEJA PROSSEGUIR COM A EXCLUSÃO DOS DEMAIS LANÇAMENTOS?", "SIM", "NÃO"));
+ }
+ if (flag)
+ {
+ Loading(isLoading: false);
+ return;
+ }
+ bool observacao = false;
+ List<Lancamento> todosLancamentos = new List<Lancamento>();
+ foreach (Lancamento x2 in (from x in lancamentos
+ orderby ((DomainBase)x.Controle).Id, x.Parcela descending
+ select x).ToList())
+ {
+ if (x2.Baixado)
+ {
+ Saldo val = await VerificaSaldo(((DomainBase)x2.Conta).Id, reabrirSaldo: false);
+ if (val == null)
+ {
+ continue;
+ }
+ if (val.DataInicio > x2.Baixa)
+ {
+ observacao = true;
+ continue;
+ }
+ }
+ Lancamento lancamentoPosterior = await _servico.BuscarLancamento(((DomainBase)x2.Controle).Id, x2.Parcela + 1);
+ if (lancamentoPosterior != null)
+ {
+ todosLancamentos = (await _servico.BuscarLancamentosPorControle(((DomainBase)x2.Controle).Id)).Where((Lancamento c) => !c.Baixado && c.Parcela >= x2.Parcela + 1).AsEnumerable().ToList();
+ }
+ if (lancamentoPosterior != null && lancamentosExlusao.All((Lancamento l) => ((DomainBase)l).Id != ((DomainBase)lancamentoPosterior).Id))
+ {
+ observacao = true;
+ }
+ else if (x2.Controle.Plano != null)
+ {
+ lancamentosExlusao.Add(x2);
+ }
+ }
+ if (lancamentosExlusao.Count == 0 && todosLancamentos.Count == 0)
+ {
+ await ShowMessage("OS LANÇAMENTOS SELECIONADOS NÃO PODEM SER EXCLUÍDOS. NENHUMA ALTERAÇÃO FOI FEITA");
+ Loading(isLoading: false);
+ return;
+ }
+ flag = observacao;
+ if (flag)
+ {
+ flag = !(await ShowMessage("HÁ LANÇAMENTOS SELECIONADOS QUE NÃO PODERÃO SER EXCLUÍDOS. " + Environment.NewLine + "DESEJA PROSSEGUIR COM A EXCLUSÃO DOS DEMAIS LANÇAMENTOS?", "SIM", "NÃO"));
+ }
+ if (flag)
+ {
+ Loading(isLoading: false);
+ return;
+ }
+ flag = todosLancamentos.Count > 0;
+ if (flag)
+ {
+ flag = await ShowMessage("DESEJA EXCLUIR LANÇAMENTOS/PARCELAS CADASTRADOS ACIMA DAS SELECIONADAS.", "SIM", "NÃO");
+ }
+ if (flag)
+ {
+ lancamentosExlusao.AddRange(todosLancamentos);
+ }
+ if (!(await _servico.Excluir(lancamentosExlusao)))
+ {
+ Loading(isLoading: false);
+ return;
+ }
+ if (lancamentosExlusao != null && lancamentosExlusao.Count > 0)
+ {
+ lancamentosExlusao.ForEach(delegate(Lancamento x)
+ {
+ FinanceiroViewModel financeiroViewModel = this;
+ string descricao = $"EXCLUIU O LANÇAMENTO DO ID {((x != null) ? new long?(((DomainBase)x).Id) : null)} HISTORICO: {((x != null) ? x.Historico : null)}";
+ long entidadeId;
+ if (x != null)
+ {
+ _ = ((DomainBase)x).Id;
+ if (0 == 0)
+ {
+ entidadeId = ((DomainBase)x).Id;
+ goto IL_0054;
+ }
+ }
+ entidadeId = 0L;
+ goto IL_0054;
+ IL_0054:
+ financeiroViewModel.RegistrarAcao(descricao, entidadeId, (TipoTela)25);
+ });
+ }
+ ToggleSnackBar($"EXCLUSÃO DE {lancamentosExlusao.Count} DO TOTAL DE {lancamentos.Count} LANÇAMENTOS SELECIONADOS REALIZADA COM SUCESSO.");
+ await Buscar();
+ Loading(isLoading: false);
+ }
+ }
+
+ private async Task<Saldo> VerificaSaldo(long contaId, bool reabrirSaldo)
+ {
+ Saldo saldo = ((IEnumerable<Saldo>)(await new BancosContasServico().BuscarSaldoAberto(Contas.Select((BancosContas x) => ((DomainBase)x).Id).ToList()))).FirstOrDefault((Func<Saldo, bool>)((Saldo s) => ((DomainBase)s.Conta).Id == contaId));
+ if (saldo == null && reabrirSaldo)
+ {
+ await ShowMessage("NÃO FOI ENCONTRADO UM SALDO ABERTO PARA FAZER A EXCLUSÃO.");
+ }
+ return saldo;
+ }
+
+ public async Task Excluir()
+ {
+ if (SelectedLancamento == null || ((DomainBase)SelectedLancamento).Id == 0L)
+ {
+ return;
+ }
+ Loading(isLoading: true);
+ Lancamento lancamento = await _servico.BuscarLancamento(((DomainBase)SelectedLancamento).Id);
+ Saldo val = await VerificaSaldo(((DomainBase)SelectedLancamento.Conta).Id, reabrirSaldo: true);
+ if (val == null)
+ {
+ return;
+ }
+ if (val.DataInicio > lancamento.Baixa)
+ {
+ await ShowMessage("LANÇAMENTO NÃO PODE SER EXCLUÍDO POIS NÃO POSSUI SALDO ABERTO PARA O PERÍODO.");
+ Loading(isLoading: false);
+ return;
+ }
+ if (!(await ShowMessage("DESEJA REAMENTE EXCLUIR O LANÇAMENTO SELECIONADO?", "SIM", "NÃO")))
+ {
+ Loading(isLoading: false);
+ return;
+ }
+ if (!(await _servico.Excluir(SelectedLancamento)))
+ {
+ Loading(isLoading: false);
+ return;
+ }
+ FinanceiroViewModel financeiroViewModel = this;
+ Lancamento selectedLancamento = SelectedLancamento;
+ object arg = ((selectedLancamento != null) ? new long?(((DomainBase)selectedLancamento).Id) : null);
+ Lancamento selectedLancamento2 = SelectedLancamento;
+ string descricao = $"EXCLUIU O LANÇAMENTO DO ID {arg} HISTORICO: {((selectedLancamento2 != null) ? selectedLancamento2.Historico : null)}";
+ Lancamento selectedLancamento3 = SelectedLancamento;
+ int num;
+ if (selectedLancamento3 == null)
+ {
+ num = 1;
+ }
+ else
+ {
+ _ = ((DomainBase)selectedLancamento3).Id;
+ num = 0;
+ }
+ financeiroViewModel.RegistrarAcao(descricao, (num != 0) ? 0 : ((DomainBase)SelectedLancamento).Id, (TipoTela)25);
+ ToggleSnackBar("EXCLUSÃO REALIZADA COM SUCESSO");
+ await Buscar();
+ Loading(isLoading: false);
+ }
+
+ public async Task<bool> SalvarImportacao(List<Lancamento> list)
+ {
+ List<Lancamento> lancamentosAtualizar = new List<Lancamento>();
+ List<Lancamento> lancamentosBaixar = new List<Lancamento>();
+ List<Lancamento> lancamentosIncluir = new List<Lancamento>();
+ List<Lancamento> lancamentos = new List<Lancamento>();
+ foreach (Lancamento x2 in list)
+ {
+ if (x2.Baixado)
+ {
+ continue;
+ }
+ if (!x2.Selecionado)
+ {
+ x2.Baixa = null;
+ }
+ if (x2.Baixa.HasValue)
+ {
+ Saldo val = await VerificaSaldo(((DomainBase)x2.Conta).Id, reabrirSaldo: false);
+ if (val == null || val.DataInicio > x2.Baixa)
+ {
+ continue;
+ }
+ }
+ string[] array = x2.Observacao?.Split(new char[1] { '\n' });
+ StringBuilder stringBuilder = new StringBuilder();
+ string value = "IMPORTAÇÃO OFX REALIZADA PELO USUÁRIO";
+ if (array != null)
+ {
+ string[] array2 = array;
+ foreach (string text in array2)
+ {
+ if (text.IndexOf(value, StringComparison.InvariantCulture) != 0)
+ {
+ stringBuilder.Append(text + "\n");
+ }
+ }
+ }
+ x2.Observacao = string.Format("{0}IMPORTAÇÃO OFX REALIZADA PELO USUÁRIO {1} {2} EM {3}", stringBuilder, ((DomainBase)Recursos.Usuario).Id, Recursos.Usuario.Nome, Funcoes.GetNetworkTime().ToString("F").ToUpper());
+ if (((DomainBase)x2).Id > 0)
+ {
+ if (x2.Baixa.HasValue)
+ {
+ lancamentosBaixar.Add(x2);
+ }
+ else
+ {
+ lancamentosAtualizar.Add(x2);
+ }
+ }
+ else
+ {
+ lancamentosIncluir.Add(x2);
+ }
+ lancamentos.Add(x2);
+ }
+ if (lancamentos.Count == 0)
+ {
+ await ShowMessage("NÃO HÁ LANÇAMENTOS PARA SEREM ATUALIZADOS.");
+ Loading(isLoading: false);
+ return false;
+ }
+ if (!(await ShowMessage($"{lancamentosIncluir.Count} LANÇAMENTOS SERÃO CRIADOS.{Environment.NewLine}{lancamentosAtualizar.Count} LANÇAMENTOS SERÃO ATUALIZADOS.{Environment.NewLine}{lancamentosBaixar.Count} LANÇAMENTOS SERÃO BAIXADOS.{Environment.NewLine}{Environment.NewLine}DESEJA REALMENTE PROSSEGUIR?", "SIM", "NÃO")))
+ {
+ Loading(isLoading: false);
+ return false;
+ }
+ bool sucesso = true;
+ foreach (Lancamento x2 in lancamentos)
+ {
+ await _servico.Save(x2);
+ sucesso = sucesso && _servico.Sucesso;
+ if (x2 != null && ((DomainBase)x2).Id != 0 && sucesso)
+ {
+ FinanceiroViewModel financeiroViewModel = this;
+ object arg = ((DomainBase)x2).Id;
+ Lancamento obj = x2;
+ string descricao = $"BAIXOU/ATUALIZOU O LANÇAMENTO DO ID {arg}POR IMPORTAÇÃO HISTORICO: {((obj != null) ? obj.Historico : null)}";
+ Lancamento obj2 = x2;
+ int num;
+ if (obj2 == null)
+ {
+ num = 1;
+ }
+ else
+ {
+ _ = ((DomainBase)obj2).Id;
+ num = 0;
+ }
+ financeiroViewModel.RegistrarAcao(descricao, (num != 0) ? 0 : ((DomainBase)x2).Id, (TipoTela)25);
+ }
+ else if (x2 != null && sucesso)
+ {
+ FinanceiroViewModel financeiroViewModel2 = this;
+ Lancamento obj3 = x2;
+ financeiroViewModel2.RegistrarAcao("INSERIU O LANÇAMENTO POR IMPORTAÇÃO HISTORICO: " + ((obj3 != null) ? obj3.Historico : null), 0L, (TipoTela)25);
+ }
+ }
+ if (!sucesso)
+ {
+ await ShowMessage("HOUVERAM PROBLEMAS AO INCLUIR OU ATUALIZAR LANÇAMENTOS, FAVOR CONFERIR A IMPORTAÇÃO.");
+ return false;
+ }
+ await Buscar();
+ ToggleSnackBar("ATUALIZAÇÃO REALIZADA COM SUCESSO");
+ await CarregarSaldos();
+ return true;
+ }
+
+ public async Task Atualizar(List<Lancamento> list)
+ {
+ Loading(isLoading: true);
+ List<Lancamento> lancamentosAtualizar = new List<Lancamento>();
+ List<Lancamento> lancamentosBaixar = new List<Lancamento>();
+ List<Lancamento> lancamentos = new List<Lancamento>();
+ foreach (Lancamento x in list)
+ {
+ if (x.Baixado)
+ {
+ continue;
+ }
+ if (!x.Selecionado)
+ {
+ x.Baixa = null;
+ }
+ if (x.Baixa.HasValue)
+ {
+ Saldo val = await VerificaSaldo(((DomainBase)x.Conta).Id, reabrirSaldo: false);
+ if (val == null || val.DataInicio > x.Baixa)
+ {
+ continue;
+ }
+ }
+ if (x.Selecionado)
+ {
+ string text = ((x.Observacao == null) ? "" : ("\n " + x.Observacao));
+ x.Observacao = string.Format("BAIXA AGRUPADA REALIZADA PELO USUARIO {0} {1} EM {2}{3}", ((DomainBase)Recursos.Usuario).Id, Recursos.Usuario.Nome, Funcoes.GetNetworkTime().ToString("F").ToUpper(), text);
+ }
+ List<KeyValuePair<string, string>> list2 = x.Validate();
+ if (list2 == null || list2.Count <= 0)
+ {
+ if (x.Baixa.HasValue)
+ {
+ lancamentosBaixar.Add(x);
+ }
+ else
+ {
+ lancamentosAtualizar.Add(x);
+ }
+ lancamentos.Add(x);
+ }
+ }
+ if (lancamentos.Count == 0)
+ {
+ await ShowMessage("NÃO HÁ LANÇAMENTOS PARA SEREM ATUALIZADOS.");
+ Loading(isLoading: false);
+ return;
+ }
+ if (!(await ShowMessage($"{lancamentosAtualizar.Count} LANÇAMENTOS SERÃO ATUALIZADOS.{Environment.NewLine}{lancamentosBaixar.Count} LANÇAMENTOS SERÃO BAIXADOS.{Environment.NewLine}{Environment.NewLine}DESEJA REALMENTE PROSSEGUIR?", "SIM", "NÃO")))
+ {
+ Loading(isLoading: false);
+ return;
+ }
+ await _servico.Atualizar(lancamentos);
+ if (!_servico.Sucesso)
+ {
+ Loading(isLoading: false);
+ return;
+ }
+ if (await ShowMessage("DESEJA GERAR O RELATÓRIO NOVAMENTE?", "SIM,", "NÃO"))
+ {
+ await Buscar();
+ }
+ ToggleSnackBar("ATUALIZAÇÃO REALIZADA COM SUCESSO");
+ await CarregarSaldos();
+ Loading(isLoading: false);
+ }
+
+ public void Sintetizar()
+ {
+ //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_0007: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0009: Unknown result type (might be due to invalid IL or missing references)
+ //IL_001f: Expected I4, but got Unknown
+ SinteticoFinanceiroTipo sinteticoTipo = SinteticoTipo;
+ List<Sintetico> list = (sinteticoTipo - 1) switch
+ {
+ 3 => (from x in LancamentosFiltrados
+ where x.Controle.Plano != null && x.Controle.Plano.Plano != null
+ group x by new
+ {
+ ((DomainBase)x.Controle.Plano.Plano).Id,
+ x.Controle.Plano.Plano.Descricao
+ } into x
+ select new Sintetico
+ {
+ Agrupamento = x.Key.Descricao,
+ Valor = x.Sum((Lancamento s) => ((int)s.Sinal != 0) ? (-s.Valor) : s.Valor),
+ ValorPago = x.Sum((Lancamento s) => ((int)s.Sinal != 0) ? (-s.ValorPago).GetValueOrDefault() : s.ValorPago.GetValueOrDefault())
+ }).ToList(),
+ 0 => (from x in LancamentosFiltrados
+ where x.Controle.Plano != null
+ group x by new
+ {
+ ((DomainBase)x.Controle.Centro).Id,
+ x.Controle.Centro.Descricao
+ } into x
+ select new Sintetico
+ {
+ Agrupamento = x.Key.Descricao,
+ Valor = x.Sum((Lancamento s) => ((int)s.Sinal != 0) ? (-s.Valor) : s.Valor),
+ ValorPago = x.Sum((Lancamento s) => ((int)s.Sinal != 0) ? (-s.ValorPago).GetValueOrDefault() : s.ValorPago.GetValueOrDefault())
+ }).ToList(),
+ 2 => (from x in LancamentosFiltrados
+ where x.Controle.Plano != null
+ group x by new
+ {
+ ((DomainBase)x.Conta).Id,
+ x.Conta.Descricao
+ } into x
+ select new Sintetico
+ {
+ Agrupamento = x.Key.Descricao,
+ Valor = x.Sum((Lancamento s) => ((int)s.Sinal != 0) ? (-s.Valor) : s.Valor),
+ ValorPago = x.Sum((Lancamento s) => ((int)s.Sinal != 0) ? (-s.ValorPago).GetValueOrDefault() : s.ValorPago.GetValueOrDefault())
+ }).ToList(),
+ 1 => (from x in LancamentosFiltrados
+ where x.Controle.Plano != null
+ group x by new
+ {
+ x.Controle.Fornecedor.Id,
+ x.Controle.Fornecedor.Nome
+ } into x
+ select new Sintetico
+ {
+ Agrupamento = x.Key.Nome,
+ Valor = x.Sum((Lancamento s) => ((int)s.Sinal != 0) ? (-s.Valor) : s.Valor),
+ ValorPago = x.Sum((Lancamento s) => ((int)s.Sinal != 0) ? (-s.ValorPago).GetValueOrDefault() : s.ValorPago.GetValueOrDefault())
+ }).ToList(),
+ _ => (from x in LancamentosFiltrados
+ where x.Controle.Plano != null
+ group x by new
+ {
+ ((DomainBase)x.Controle.Plano).Id,
+ x.Controle.Plano.Descricao
+ } into x
+ select new Sintetico
+ {
+ Agrupamento = x.Key.Descricao,
+ Valor = x.Sum((Lancamento s) => ((int)s.Sinal != 0) ? (-s.Valor) : s.Valor),
+ ValorPago = x.Sum((Lancamento s) => ((int)s.Sinal != 0) ? (-s.ValorPago).GetValueOrDefault() : s.ValorPago.GetValueOrDefault())
+ }).ToList(),
+ };
+ if (list.Count != 0)
+ {
+ ((Window)new SinteticoView(list, "RELATORIO FINANCEIRO", Inicio, Fim)).Show();
+ }
+ }
+
+ public List<KeyValuePair<string, string>> ValidateIncluir()
+ {
+ //IL_0000: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0005: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0026: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0032: Unknown result type (might be due to invalid IL or missing references)
+ //IL_003e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_004a: Unknown result type (might be due to invalid IL or missing references)
+ //IL_004c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0056: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0062: Unknown result type (might be due to invalid IL or missing references)
+ //IL_006e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_007a: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0086: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0092: Unknown result type (might be due to invalid IL or missing references)
+ //IL_001c: Unknown result type (might be due to invalid IL or missing references)
+ Lancamento val = new Lancamento();
+ Lancamento selectedLancamento = SelectedLancamento;
+ val.Controle = (ControleFinanceiro)(((object)((selectedLancamento != null) ? selectedLancamento.Controle : null)) ?? ((object)new ControleFinanceiro()));
+ val.Historico = Historico;
+ val.Valor = Valor;
+ val.Conta = Conta;
+ val.TipoPagamento = TipoPagamento;
+ val.Documento = Documento;
+ val.Competencia = Competencia;
+ val.Complemento = Complemento;
+ val.Baixa = Baixa;
+ val.Vencimento = Vencimento;
+ val.Pagamento = Pagamento;
+ return val.Validate();
+ }
+
+ public void AdicionarFiltros()
+ {
+ ExtensionMethods.ForEach<Planos>(PlanosFiltro.Where((Planos x) => x.Selecionado), (Action<Planos>)delegate(Planos x)
+ {
+ //IL_0000: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0005: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0011: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0018: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0025: Expected O, but got Unknown
+ FiltroPersonalizado filtro3 = new FiltroPersonalizado
+ {
+ Id = ((DomainBase)x).Id,
+ Tipo = (TipoFiltroFinanceiro)1,
+ Descricao = x.Descricao
+ };
+ AdicionarFiltro(filtro3);
+ });
+ PlanosFiltro = new List<Planos>(Planos.OrderBy((Planos x) => x.Descricao));
+ ExtensionMethods.ForEach<BancosContas>(ContaFiltro.Where((BancosContas x) => x.Selecionado), (Action<BancosContas>)delegate(BancosContas x)
+ {
+ //IL_0000: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0005: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0011: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0018: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0025: Expected O, but got Unknown
+ FiltroPersonalizado filtro2 = new FiltroPersonalizado
+ {
+ Id = ((DomainBase)x).Id,
+ Tipo = (TipoFiltroFinanceiro)3,
+ Descricao = x.Descricao
+ };
+ AdicionarFiltro(filtro2);
+ });
+ ContaFiltro = new List<BancosContas>(Contas.OrderBy((BancosContas x) => x.Descricao));
+ ExtensionMethods.ForEach<Centro>(CentroFiltro.Where((Centro x) => x.Selecionado), (Action<Centro>)delegate(Centro x)
+ {
+ //IL_0000: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0005: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0011: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0018: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0025: Expected O, but got Unknown
+ FiltroPersonalizado filtro = new FiltroPersonalizado
+ {
+ Id = ((DomainBase)x).Id,
+ Tipo = (TipoFiltroFinanceiro)2,
+ Descricao = x.Descricao
+ };
+ AdicionarFiltro(filtro);
+ x.Selecionado = false;
+ });
+ CentroFiltro = new List<Centro>(Centros.OrderBy((Centro x) => x.Descricao));
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Financeiro/FornecedorViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Financeiro/FornecedorViewModel.cs
new file mode 100644
index 0000000..64f20d3
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Financeiro/FornecedorViewModel.cs
@@ -0,0 +1,477 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using Assinador.Infrastructure.Helpers;
+using ClosedXML.Excel;
+using Gestor.Application.Helpers;
+using Gestor.Application.Servicos.Financeiro;
+using Gestor.Application.ViewModels.Generic;
+using Gestor.Common.Validation;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Configuracoes;
+using Gestor.Model.Domain.Financeiro;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Seguros;
+using Gestor.Model.Helper;
+
+namespace Gestor.Application.ViewModels.Financeiro;
+
+public class FornecedorViewModel : BaseFinanceiroViewModel
+{
+ private readonly FornecedorServico _servico;
+
+ private List<Planos> _planos;
+
+ private ObservableCollection<Planos> _planosFiltrados;
+
+ private List<BancosContas> _contas;
+
+ private ObservableCollection<BancosContas> _contasFiltradas;
+
+ private List<Centro> _centros;
+
+ private ObservableCollection<Centro> _centrosFiltrados;
+
+ private ObservableCollection<Fornecedor> _fornecedorFiltrados = new ObservableCollection<Fornecedor>();
+
+ private bool _isExpanded;
+
+ private Fornecedor _selectedFornecedor;
+
+ private string _anotacoes;
+
+ private long _ultimoId;
+
+ public Fornecedor CancelProduto;
+
+ public List<Planos> Planos
+ {
+ get
+ {
+ return _planos;
+ }
+ set
+ {
+ _planos = value;
+ OnPropertyChanged("Planos");
+ }
+ }
+
+ public ObservableCollection<Planos> PlanosFiltrados
+ {
+ get
+ {
+ return _planosFiltrados;
+ }
+ set
+ {
+ _planosFiltrados = value;
+ OnPropertyChanged("PlanosFiltrados");
+ }
+ }
+
+ public List<BancosContas> Contas
+ {
+ get
+ {
+ return _contas;
+ }
+ set
+ {
+ _contas = value;
+ OnPropertyChanged("Contas");
+ }
+ }
+
+ public ObservableCollection<BancosContas> ContasFiltradas
+ {
+ get
+ {
+ return _contasFiltradas;
+ }
+ set
+ {
+ _contasFiltradas = value;
+ OnPropertyChanged("ContasFiltradas");
+ }
+ }
+
+ public List<Centro> Centros
+ {
+ get
+ {
+ return _centros;
+ }
+ set
+ {
+ _centros = value;
+ OnPropertyChanged("Centros");
+ }
+ }
+
+ public ObservableCollection<Centro> CentrosFiltrados
+ {
+ get
+ {
+ return _centrosFiltrados;
+ }
+ set
+ {
+ _centrosFiltrados = value;
+ OnPropertyChanged("CentrosFiltrados");
+ }
+ }
+
+ public ObservableCollection<Fornecedor> FornecedorFiltrados
+ {
+ get
+ {
+ return _fornecedorFiltrados;
+ }
+ set
+ {
+ _fornecedorFiltrados = value;
+ IsExpanded = value != null && value.Count > 0;
+ OnPropertyChanged("FornecedorFiltrados");
+ }
+ }
+
+ public bool IsExpanded
+ {
+ get
+ {
+ return _isExpanded;
+ }
+ set
+ {
+ _isExpanded = value;
+ OnPropertyChanged("IsExpanded");
+ }
+ }
+
+ public List<Fornecedor> Fornecedor { get; set; }
+
+ public Fornecedor SelectedFornecedor
+ {
+ get
+ {
+ return _selectedFornecedor;
+ }
+ set
+ {
+ _selectedFornecedor = value;
+ VerificarEnables((value != null) ? new long?(value.Id) : null);
+ Anotacoes = string.Empty;
+ _ultimoId = ((value != null && value.Id > 0) ? value.Id : _ultimoId);
+ OnPropertyChanged("SelectedFornecedor");
+ }
+ }
+
+ public string Anotacoes
+ {
+ get
+ {
+ return _anotacoes;
+ }
+ set
+ {
+ _anotacoes = value;
+ OnPropertyChanged("Anotacoes");
+ }
+ }
+
+ public FornecedorViewModel()
+ {
+ _servico = new FornecedorServico();
+ base.EnableMenu = true;
+ BuscaIncial();
+ }
+
+ internal async Task<List<Fornecedor>> Filtrar(string value)
+ {
+ return await Task.Run(() => FiltrarFornecedor(value));
+ }
+
+ public List<Fornecedor> FiltrarFornecedor(string filter)
+ {
+ FornecedorFiltrados = (string.IsNullOrWhiteSpace(filter) ? new ObservableCollection<Fornecedor>(Fornecedor) : new ObservableCollection<Fornecedor>(from x in Fornecedor
+ where ValidationHelper.RemoveDiacritics(x.Nome.Trim()).ToUpper().Contains(ValidationHelper.RemoveDiacritics(filter)) || (x.Documento != null && ValidationHelper.RemoveDiacritics(x.Documento.Trim()).Contains(filter)) || (x.Telefone1 != null && ValidationHelper.RemoveDiacritics(x.Telefone1.Trim()).Contains(filter)) || (x.Telefone2 != null && ValidationHelper.RemoveDiacritics(x.Telefone2.Trim()).Contains(filter)) || (x.Email != null && ValidationHelper.RemoveDiacritics(x.Email.Trim()).Contains(filter))
+ orderby x.Nome descending
+ select x));
+ if (FornecedorFiltrados.Count == 1)
+ {
+ SelectedFornecedor = FornecedorFiltrados.First();
+ }
+ return FornecedorFiltrados.ToList();
+ }
+
+ private async void BuscaIncial()
+ {
+ Loading(isLoading: true);
+ await PermissaoTela((TipoTela)24);
+ Planos = await new PlanoServico().BuscarPlanos();
+ PlanosFiltrados = new ObservableCollection<Planos>(from x in Planos
+ where x.Ativo
+ orderby x.Descricao
+ select x);
+ Contas = await new BancosContasServico().BuscarBancos();
+ ContasFiltradas = new ObservableCollection<BancosContas>(from x in Contas
+ where x.Ativo
+ orderby x.Descricao
+ select x);
+ Centros = await new CentroServico().BuscarCentros();
+ CentrosFiltrados = new ObservableCollection<Centro>(from x in Centros
+ where x.Ativo
+ orderby x.Descricao
+ select x);
+ await SelecionaFornecedor();
+ SelectedFornecedor = FornecedorFiltrados.FirstOrDefault();
+ Loading(isLoading: false);
+ }
+
+ private async Task SelecionaFornecedor()
+ {
+ Fornecedor = await _servico.BuscarFornecedores();
+ FornecedorFiltrados = new ObservableCollection<Fornecedor>(Fornecedor.OrderBy((Fornecedor x) => x.Nome));
+ }
+
+ public void Incluir()
+ {
+ //IL_001a: Unknown result type (might be due to invalid IL or missing references)
+ //IL_001f: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0027: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0033: Expected O, but got Unknown
+ Fornecedor selectedFornecedor = SelectedFornecedor;
+ _ultimoId = ((selectedFornecedor != null) ? selectedFornecedor.Id : 0);
+ SelectedFornecedor = new Fornecedor
+ {
+ IdEmpresa = 1L,
+ Ativo = true
+ };
+ Alterar(alterar: true);
+ }
+
+ public async void CancelarAlteracao()
+ {
+ Loading(isLoading: true);
+ Alterar(alterar: false);
+ if (SelectedFornecedor.Id > 0)
+ {
+ await SelecionaFornecedor();
+ }
+ SelectedFornecedor = ((IEnumerable<Fornecedor>)FornecedorFiltrados).FirstOrDefault((Func<Fornecedor, bool>)((Fornecedor x) => x.Id == _ultimoId));
+ Loading(isLoading: false);
+ }
+
+ public async Task<List<KeyValuePair<string, string>>> Salvar()
+ {
+ List<KeyValuePair<string, string>> erros = SelectedFornecedor.Validate();
+ List<KeyValuePair<string, string>> list = erros;
+ list.AddRange(await Validate());
+ if (erros.Count > 0)
+ {
+ return erros;
+ }
+ if (!SelectedFornecedor.TipoPagamento.HasValue)
+ {
+ SelectedFornecedor.TipoPagamento = (TipoPagamento)12;
+ }
+ if (!string.IsNullOrWhiteSpace(Anotacoes))
+ {
+ SelectedFornecedor.Observacao = $"{Recursos.Usuario.Nome}, ID: {((DomainBase)Recursos.Usuario).Id}, {Funcoes.GetNetworkTime():g}{Environment.NewLine}{Anotacoes}{Environment.NewLine}{Environment.NewLine}{SelectedFornecedor.Observacao}";
+ }
+ Fornecedor fornecedor = await _servico.Save(SelectedFornecedor);
+ if (!_servico.Sucesso)
+ {
+ return null;
+ }
+ await SelecionaFornecedor();
+ SelectedFornecedor = FornecedorFiltrados.First((Fornecedor x) => x.Id == fornecedor.Id);
+ ToggleSnackBar("FORNECEDOR SALVO COM SUCESSO");
+ Alterar(alterar: false);
+ return null;
+ }
+
+ public async Task<List<KeyValuePair<string, string>>> Validate()
+ {
+ List<KeyValuePair<string, string>> errors = ValidationHelper.AddValue();
+ if (!string.IsNullOrWhiteSpace(SelectedFornecedor.Documento))
+ {
+ List<Fornecedor> list = (await _servico.BuscarFornecedores()).Where((Fornecedor x) => x.Id != SelectedFornecedor.Id && ValidationHelper.DocumentoFornecedor(x.Documento) == ValidationHelper.DocumentoFornecedor(SelectedFornecedor.Documento)).ToList();
+ if (list.Count > 0)
+ {
+ ValidationHelper.AddValue<string, string>(errors, "DOCUMENTO", "DOCUMENTO JÁ CADASTRADO PARA OUTROS FORNECEDORES " + string.Join(" | ", list.Select((Fornecedor x) => x.Nome)), true);
+ }
+ }
+ return errors;
+ }
+
+ public async Task Delete()
+ {
+ if (SelectedFornecedor != null && SelectedFornecedor.Id != 0L && await ShowMessage("DESEJA REALMENTE EXCLUIR O FORNECEDOR " + SelectedFornecedor.Nome + "?", "SIM", "NÃO"))
+ {
+ Loading(isLoading: true);
+ if (await new FinanceiroServico().TemLancamentosPorFornecedor(SelectedFornecedor.Id))
+ {
+ await ShowMessage("IMPOSSÍVEL REAIZAR A EXCLUSÃO POIS EXISTEM LANCAMENTOS PARA ESSE FORNECEDOR. PROCESSO INTERROMPIDO");
+ Loading(isLoading: false);
+ return;
+ }
+ if (!(await _servico.Delete(SelectedFornecedor)))
+ {
+ Loading(isLoading: false);
+ return;
+ }
+ await SelecionaFornecedor();
+ SelectedFornecedor = FornecedorFiltrados.FirstOrDefault();
+ ToggleSnackBar("FORNECEDOR EXCLUÍDO COM SUCESSO");
+ Loading(isLoading: false);
+ }
+ }
+
+ public void Copiar(Cliente cliente)
+ {
+ if (SelectedFornecedor == null)
+ {
+ Incluir();
+ }
+ SelectedFornecedor.Nome = cliente.Nome;
+ SelectedFornecedor.Documento = cliente.Documento;
+ Fornecedor selectedFornecedor = SelectedFornecedor;
+ object cep;
+ if (cliente.Enderecos == null || !cliente.Enderecos.Any())
+ {
+ cep = null;
+ }
+ else
+ {
+ ClienteEndereco obj = cliente.Enderecos.First();
+ cep = ((obj == null) ? null : ((EnderecoBase)obj).Cep?.Trim());
+ }
+ ((EnderecoBase)selectedFornecedor).Cep = (string)cep;
+ Fornecedor selectedFornecedor2 = SelectedFornecedor;
+ object endereco;
+ if (cliente.Enderecos == null || !cliente.Enderecos.Any())
+ {
+ endereco = null;
+ }
+ else
+ {
+ ClienteEndereco obj2 = cliente.Enderecos.First();
+ endereco = ((obj2 == null) ? null : ((EnderecoBase)obj2).Endereco?.Trim());
+ }
+ ((EnderecoBase)selectedFornecedor2).Endereco = (string)endereco;
+ Fornecedor selectedFornecedor3 = SelectedFornecedor;
+ object numero;
+ if (cliente.Enderecos == null || !cliente.Enderecos.Any())
+ {
+ numero = null;
+ }
+ else
+ {
+ ClienteEndereco obj3 = cliente.Enderecos.First();
+ numero = ((obj3 == null) ? null : ((EnderecoBase)obj3).Numero?.Trim());
+ }
+ ((EnderecoBase)selectedFornecedor3).Numero = (string)numero;
+ Fornecedor selectedFornecedor4 = SelectedFornecedor;
+ object complemento;
+ if (cliente.Enderecos == null || !cliente.Enderecos.Any())
+ {
+ complemento = null;
+ }
+ else
+ {
+ ClienteEndereco obj4 = cliente.Enderecos.First();
+ complemento = ((obj4 == null) ? null : ((EnderecoBase)obj4).Complemento?.Trim());
+ }
+ ((EnderecoBase)selectedFornecedor4).Complemento = (string)complemento;
+ Fornecedor selectedFornecedor5 = SelectedFornecedor;
+ object bairro;
+ if (cliente.Enderecos == null || !cliente.Enderecos.Any())
+ {
+ bairro = null;
+ }
+ else
+ {
+ ClienteEndereco obj5 = cliente.Enderecos.First();
+ bairro = ((obj5 == null) ? null : ((EnderecoBase)obj5).Bairro?.Trim());
+ }
+ ((EnderecoBase)selectedFornecedor5).Bairro = (string)bairro;
+ Fornecedor selectedFornecedor6 = SelectedFornecedor;
+ object cidade;
+ if (cliente.Enderecos == null || !cliente.Enderecos.Any())
+ {
+ cidade = null;
+ }
+ else
+ {
+ ClienteEndereco obj6 = cliente.Enderecos.First();
+ cidade = ((obj6 == null) ? null : ((EnderecoBase)obj6).Cidade?.Trim());
+ }
+ ((EnderecoBase)selectedFornecedor6).Cidade = (string)cidade;
+ Fornecedor selectedFornecedor7 = SelectedFornecedor;
+ object estado;
+ if (cliente.Enderecos == null || !cliente.Enderecos.Any())
+ {
+ estado = null;
+ }
+ else
+ {
+ ClienteEndereco obj7 = cliente.Enderecos.First();
+ estado = ((obj7 == null) ? null : ((EnderecoBase)obj7).Estado?.Trim());
+ }
+ ((EnderecoBase)selectedFornecedor7).Estado = (string)estado;
+ SelectedFornecedor.TipoTelefone1 = ((cliente.Telefones != null && cliente.Telefones.Any()) ? ((TelefoneBase)cliente.Telefones.First()).Tipo : null);
+ SelectedFornecedor.Prefixo1 = ((cliente.Telefones == null || !cliente.Telefones.Any()) ? null : ((TelefoneBase)cliente.Telefones.First()).Prefixo?.Trim());
+ SelectedFornecedor.Telefone1 = ((cliente.Telefones == null || !cliente.Telefones.Any()) ? null : ((TelefoneBase)cliente.Telefones.First()).Numero?.Trim());
+ SelectedFornecedor.TipoTelefone2 = ((cliente.Telefones != null && cliente.Telefones.Any() && cliente.Telefones.Count > 2) ? ((TelefoneBase)cliente.Telefones[1]).Tipo : null);
+ SelectedFornecedor.Prefixo2 = ((cliente.Telefones == null || cliente.Telefones.Count <= 2) ? null : ((TelefoneBase)cliente.Telefones[1]).Prefixo?.Trim());
+ SelectedFornecedor.Telefone2 = ((cliente.Telefones == null || cliente.Telefones.Count <= 2) ? null : ((TelefoneBase)cliente.Telefones[1]).Numero?.Trim());
+ SelectedFornecedor.Email = ((cliente.Emails == null || !cliente.Emails.Any() || cliente.Emails.Count <= 0) ? null : ((EmailBase)cliente.Emails.First()).Email?.Trim());
+ OnPropertyChanged("SelectedFornecedor");
+ }
+
+ public async void Excel()
+ {
+ XLWorkbook xlWorkbook = new XLWorkbook();
+ string nome = "RELAÓRIO DE FORNECEDOR";
+ xlWorkbook = await Funcoes.GerarXls(xlWorkbook, nome, FornecedorFiltrados.ToList());
+ string text = "";
+ string text2;
+ if (Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 41))
+ {
+ FolderBrowserDialog val = new FolderBrowserDialog();
+ try
+ {
+ if (1 != (int)((CommonDialog)val).ShowDialog())
+ {
+ return;
+ }
+ text = val.SelectedPath + "\\";
+ Directory.CreateDirectory(text);
+ }
+ finally
+ {
+ ((IDisposable)val)?.Dispose();
+ }
+ text2 = text + nome + " " + Functions.GetNetworkTime().Date.ToShortDateString().Replace("/", "") + ".xlsx";
+ }
+ else
+ {
+ text = Path.GetTempPath();
+ text2 = $"{text}{Guid.NewGuid()}.xlsx";
+ }
+ xlWorkbook.SaveAs(text2);
+ Process.Start(text2);
+ }
+
+ public async void Imprimir()
+ {
+ await ImprimirFornecedor(FornecedorFiltrados.ToList());
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Financeiro/InfoExtratoViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Financeiro/InfoExtratoViewModel.cs
new file mode 100644
index 0000000..1cf33dc
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Financeiro/InfoExtratoViewModel.cs
@@ -0,0 +1,64 @@
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using Gestor.Application.Servicos.Financeiro;
+using Gestor.Application.ViewModels.Generic;
+using Gestor.Model.Domain.Financeiro;
+using Gestor.Model.Domain.Generic;
+
+namespace Gestor.Application.ViewModels.Financeiro;
+
+public class InfoExtratoViewModel : BaseFinanceiroViewModel
+{
+ private readonly BancosContasServico _saldoServico;
+
+ private Saldo _selectedSaldo;
+
+ public bool _telaBancos { get; set; }
+
+ public Saldo SelectedSaldo
+ {
+ get
+ {
+ return _selectedSaldo;
+ }
+ set
+ {
+ if (value != null && !_telaBancos)
+ {
+ value.DataFinal = null;
+ value.ValorFinal = null;
+ }
+ _selectedSaldo = value;
+ OnPropertyChanged("SelectedSaldo");
+ ((DomainBase)SelectedSaldo).Initialize();
+ }
+ }
+
+ public InfoExtratoViewModel(bool telaBancos)
+ {
+ _telaBancos = telaBancos;
+ _saldoServico = new BancosContasServico();
+ }
+
+ public async Task<List<KeyValuePair<string, string>>> Salvar()
+ {
+ List<KeyValuePair<string, string>> list = SelectedSaldo.Validate();
+ if (list.Count > 0)
+ {
+ return list;
+ }
+ if (!_telaBancos)
+ {
+ SelectedSaldo.DataFinal = null;
+ SelectedSaldo.ValorFinal = null;
+ }
+ SelectedSaldo = await _saldoServico.Save(SelectedSaldo);
+ if (!_saldoServico.Sucesso)
+ {
+ return null;
+ }
+ Alterar(alterar: false);
+ ToggleSnackBar("SALDO SALVO COM SUCESSO");
+ return null;
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Financeiro/MenuFinanceiroViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Financeiro/MenuFinanceiroViewModel.cs
new file mode 100644
index 0000000..826f92f
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Financeiro/MenuFinanceiroViewModel.cs
@@ -0,0 +1,24 @@
+using Gestor.Application.ViewModels.Generic;
+using Gestor.Application.Views.Financeiro;
+
+namespace Gestor.Application.ViewModels.Financeiro;
+
+public class MenuFinanceiroViewModel : BaseViewModel
+{
+ private object _content;
+
+ public FinanceiroView FinanceiroView;
+
+ public object Content
+ {
+ get
+ {
+ return _content;
+ }
+ set
+ {
+ _content = value;
+ OnPropertyChanged("Content");
+ }
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Financeiro/PlanoViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Financeiro/PlanoViewModel.cs
new file mode 100644
index 0000000..4218195
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Financeiro/PlanoViewModel.cs
@@ -0,0 +1,129 @@
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using Gestor.Application.Servicos.Financeiro;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Application.ViewModels.Generic;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Financeiro;
+using Gestor.Model.Domain.Generic;
+
+namespace Gestor.Application.ViewModels.Financeiro;
+
+public class PlanoViewModel : BaseFinanceiroViewModel
+{
+ private readonly PlanoServico _planoServico;
+
+ private Plano _selectedPlano;
+
+ public Plano Cancel;
+
+ public Plano SelectedPlano
+ {
+ get
+ {
+ return _selectedPlano;
+ }
+ set
+ {
+ _selectedPlano = value;
+ VerificarEnables((value != null) ? new long?(((DomainBase)value).Id) : null);
+ OnPropertyChanged("SelectedPlano");
+ }
+ }
+
+ public PlanoViewModel(Plano plano)
+ {
+ _planoServico = new PlanoServico();
+ Seleciona(plano);
+ }
+
+ private async void Seleciona(Plano plano)
+ {
+ Loading(isLoading: true);
+ await PermissaoTela((TipoTela)27);
+ if (plano == null)
+ {
+ SelectedPlano = new Plano
+ {
+ Descricao = "",
+ Ativo = true
+ };
+ }
+ else
+ {
+ SelectedPlano = plano;
+ }
+ Loading(isLoading: false);
+ }
+
+ public async Task<List<KeyValuePair<string, string>>> Salvar()
+ {
+ List<KeyValuePair<string, string>> errorMessages = SelectedPlano.Validate();
+ List<KeyValuePair<string, string>> list = errorMessages;
+ list.AddRange(await Validate());
+ if (errorMessages.Count > 0)
+ {
+ return errorMessages;
+ }
+ SelectedPlano = await _planoServico.Save(SelectedPlano);
+ if (!_planoServico.Sucesso)
+ {
+ return null;
+ }
+ Alterar(alterar: false);
+ ToggleSnackBar("PLANO SALVO COM SUCESSO");
+ return null;
+ }
+
+ public void Cancelar()
+ {
+ //IL_0015: Unknown result type (might be due to invalid IL or missing references)
+ //IL_001f: Expected O, but got Unknown
+ Loading(isLoading: true);
+ if (((DomainBase)SelectedPlano).Id == 0L)
+ {
+ SelectedPlano = new Plano();
+ Alterar(alterar: false);
+ Loading(isLoading: false);
+ }
+ else
+ {
+ Alterar(alterar: false);
+ Loading(isLoading: false);
+ }
+ }
+
+ public async Task<List<KeyValuePair<string, string>>> Validate()
+ {
+ List<KeyValuePair<string, string>> errors = new List<KeyValuePair<string, string>>();
+ bool valida = true;
+ List<Plano> list = await new BaseServico().BuscarPlanoAsync();
+ if (list.Count > 0)
+ {
+ list.ForEach(delegate(Plano x)
+ {
+ if (((DomainBase)x).Id != ((DomainBase)SelectedPlano).Id && x.Descricao == SelectedPlano.Descricao)
+ {
+ valida = false;
+ }
+ });
+ }
+ if (!valida)
+ {
+ errors.Add(new KeyValuePair<string, string>("Descricao", "UM PLANO COM ESSE NOME JÁ EXISTE."));
+ }
+ return errors;
+ }
+
+ 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_0012: Expected O, but got Unknown
+ SelectedPlano = new Plano
+ {
+ Ativo = true
+ };
+ Alterar(alterar: true);
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Financeiro/PlanosViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Financeiro/PlanosViewModel.cs
new file mode 100644
index 0000000..1ea9c15
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Financeiro/PlanosViewModel.cs
@@ -0,0 +1,252 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Threading.Tasks;
+using Gestor.Application.Servicos.Financeiro;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Application.ViewModels.Generic;
+using Gestor.Common.Validation;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Financeiro;
+using Gestor.Model.Domain.Generic;
+
+namespace Gestor.Application.ViewModels.Financeiro;
+
+public class PlanosViewModel : BaseFinanceiroViewModel
+{
+ private readonly PlanosServico _planosServico;
+
+ private ObservableCollection<Plano> _plano = new ObservableCollection<Plano>();
+
+ private ObservableCollection<Planos> _planosFiltrados = new ObservableCollection<Planos>();
+
+ private bool _isExpanded;
+
+ private Planos _selectedPlanos;
+
+ private Plano _selectedPlano;
+
+ private bool _ativo;
+
+ private long _ultimoId;
+
+ public List<Planos> Planos { get; set; }
+
+ public ObservableCollection<Plano> Plano
+ {
+ get
+ {
+ return _plano;
+ }
+ set
+ {
+ _plano = value;
+ OnPropertyChanged("Plano");
+ }
+ }
+
+ public ObservableCollection<Planos> PlanosFiltrados
+ {
+ get
+ {
+ return _planosFiltrados;
+ }
+ set
+ {
+ _planosFiltrados = value;
+ IsExpanded = value != null && value.Count > 0;
+ OnPropertyChanged("PlanosFiltrados");
+ }
+ }
+
+ public bool IsExpanded
+ {
+ get
+ {
+ return _isExpanded;
+ }
+ set
+ {
+ _isExpanded = value;
+ OnPropertyChanged("IsExpanded");
+ }
+ }
+
+ public Planos SelectedPlanos
+ {
+ get
+ {
+ return _selectedPlanos;
+ }
+ set
+ {
+ _selectedPlanos = value;
+ Planos obj = value;
+ SelectedPlano = ((((obj != null) ? obj.Plano : null) != null) ? ((IEnumerable<Plano>)Plano).FirstOrDefault((Func<Plano, bool>)((Plano x) => ((DomainBase)x).Id == ((DomainBase)value.Plano).Id)) : null);
+ Planos obj2 = value;
+ if (obj2 != null && ((DomainBase)obj2).Id > 0)
+ {
+ _ultimoId = ((DomainBase)value).Id;
+ }
+ Planos obj3 = value;
+ VerificarEnables((obj3 != null) ? new long?(((DomainBase)obj3).Id) : null);
+ OnPropertyChanged("SelectedPlanos");
+ }
+ }
+
+ public Plano SelectedPlano
+ {
+ get
+ {
+ return _selectedPlano;
+ }
+ set
+ {
+ _selectedPlano = value;
+ OnPropertyChanged("SelectedPlano");
+ }
+ }
+
+ public bool Ativo
+ {
+ get
+ {
+ return _ativo;
+ }
+ set
+ {
+ _ativo = value;
+ OnPropertyChanged("Ativo");
+ }
+ }
+
+ public PlanosViewModel()
+ {
+ _planosServico = new PlanosServico();
+ base.EnableMenu = true;
+ Seleciona();
+ }
+
+ private async void Seleciona()
+ {
+ Loading(isLoading: true);
+ await PermissaoTela((TipoTela)28);
+ await SelecionaPlanos();
+ await SelecionaPlanos(PlanosFiltrados.FirstOrDefault());
+ Loading(isLoading: false);
+ }
+
+ private async Task SelecionaPlanos()
+ {
+ Planos = (await new BaseServico().BuscarPlanosAsync()).OrderByDescending((Planos x) => x.Ativo).ThenBy(delegate(Planos x)
+ {
+ Plano plano = x.Plano;
+ return (plano == null) ? null : plano.Descricao;
+ }).ThenBy((Planos x) => x.Descricao)
+ .ToList();
+ PlanosFiltrados = new ObservableCollection<Planos>(Planos);
+ }
+
+ public async Task SelecionaPlanos(Planos planos)
+ {
+ if (planos == null)
+ {
+ Alterar(alterar: false);
+ base.EnableMenu = false;
+ base.EnableAlterar = false;
+ return;
+ }
+ Loading(isLoading: true);
+ ObservableCollection<Planos> source = await _planosServico.BuscarPlanos();
+ DomainBase.Copy<Planos, Planos>(PlanosFiltrados.First((Planos x) => ((DomainBase)x).Id == ((DomainBase)planos).Id), source.First((Planos x) => ((DomainBase)x).Id == ((DomainBase)planos).Id));
+ if (Plano == null)
+ {
+ Plano = new ObservableCollection<Plano>((from x in await new BaseServico().BuscarPlanoAsync()
+ orderby x.Ativo descending, x.Descricao
+ select x).ToList());
+ }
+ SelectedPlanos = PlanosFiltrados.First((Planos x) => ((DomainBase)x).Id == ((DomainBase)planos).Id);
+ Loading(isLoading: false);
+ }
+
+ public void Incluir()
+ {
+ //IL_0000: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0005: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0012: Expected O, but got Unknown
+ Planos selectedPlanos = new Planos
+ {
+ Plano = SelectedPlano
+ };
+ SelectedPlanos = selectedPlanos;
+ Alterar(alterar: true);
+ }
+
+ public async Task<List<KeyValuePair<string, string>>> Validate()
+ {
+ List<KeyValuePair<string, string>> errors = new List<KeyValuePair<string, string>>();
+ bool valida = true;
+ (await new BaseServico().BuscarPlanosAsync())?.ForEach(delegate(Planos x)
+ {
+ if (((DomainBase)x).Id != ((DomainBase)SelectedPlanos).Id && x.Descricao == SelectedPlanos.Descricao)
+ {
+ valida = false;
+ }
+ });
+ if (!valida)
+ {
+ errors.Add(new KeyValuePair<string, string>("Descricao", "UM SUBNÍVEL COM ESSE NOME JÁ EXISTE."));
+ }
+ return errors;
+ }
+
+ public async Task<List<KeyValuePair<string, string>>> Salvar()
+ {
+ SelectedPlanos.Plano = SelectedPlano;
+ List<KeyValuePair<string, string>> errorMessages = SelectedPlanos.Validate();
+ List<KeyValuePair<string, string>> list = errorMessages;
+ list.AddRange(await Validate());
+ if (errorMessages.Count > 0)
+ {
+ return errorMessages;
+ }
+ SelectedPlanos.Plano = SelectedPlano;
+ SelectedPlanos = await _planosServico.Save(SelectedPlanos);
+ if (!_planosServico.Sucesso)
+ {
+ return null;
+ }
+ await SelecionaPlanos();
+ await SelecionaPlanos(PlanosFiltrados.First((Planos x) => ((DomainBase)x).Id == ((DomainBase)SelectedPlanos).Id));
+ Alterar(alterar: false);
+ ToggleSnackBar("SUBNÍVEL SALVO COM SUCESSO");
+ return null;
+ }
+
+ public async void CancelarAlteracao()
+ {
+ Loading(isLoading: true);
+ Alterar(alterar: false);
+ if (((DomainBase)SelectedPlanos).Id > 0)
+ {
+ await SelecionaPlanos();
+ }
+ await SelecionaPlanos(((IEnumerable<Planos>)PlanosFiltrados).FirstOrDefault((Func<Planos, bool>)((Planos x) => ((DomainBase)x).Id == _ultimoId)));
+ Loading(isLoading: false);
+ }
+
+ public async Task<ObservableCollection<Planos>> Filtrar(string value)
+ {
+ return await Task.Run(() => FiltrarPlanos(value));
+ }
+
+ public ObservableCollection<Planos> FiltrarPlanos(string filter)
+ {
+ PlanosFiltrados = (string.IsNullOrWhiteSpace(filter) ? new ObservableCollection<Planos>(Planos) : new ObservableCollection<Planos>(from x in Planos
+ where ValidationHelper.RemoveDiacritics(x.Descricao.Trim()).ToUpper().Contains(ValidationHelper.RemoveDiacritics(filter))
+ orderby Ativo descending, x.Descricao
+ select x));
+ return PlanosFiltrados;
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Financeiro/TranferenciaViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Financeiro/TranferenciaViewModel.cs
new file mode 100644
index 0000000..fd7e8fb
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Financeiro/TranferenciaViewModel.cs
@@ -0,0 +1,66 @@
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using Gestor.Application.Servicos.Financeiro;
+using Gestor.Application.ViewModels.Generic;
+using Gestor.Model.Domain.Financeiro;
+using Gestor.Model.Domain.Generic;
+
+namespace Gestor.Application.ViewModels.Financeiro;
+
+public class TranferenciaViewModel : BaseViewModel
+{
+ private Transferencia _transferencia;
+
+ private ObservableCollection<BancosContas> _contas;
+
+ private BancosContasServico _servico { get; set; }
+
+ public Transferencia Transferencia
+ {
+ get
+ {
+ return _transferencia;
+ }
+ set
+ {
+ _transferencia = value;
+ OnPropertyChanged("Transferencia");
+ }
+ }
+
+ public ObservableCollection<BancosContas> Contas
+ {
+ get
+ {
+ return _contas;
+ }
+ set
+ {
+ _contas = value;
+ OnPropertyChanged("Contas");
+ }
+ }
+
+ public TranferenciaViewModel(Transferencia transferencia)
+ {
+ _servico = new BancosContasServico();
+ Carregar(transferencia);
+ }
+
+ private async void Carregar(Transferencia transferencia)
+ {
+ List<BancosContas> source = await _servico.BuscarBancos();
+ Contas = new ObservableCollection<BancosContas>(from x in source
+ where x.Ativo
+ orderby x.Descricao
+ select x);
+ Transferencia = new Transferencia
+ {
+ Origem = ((transferencia.Origem != null) ? source.First((BancosContas x) => ((DomainBase)x).Id == ((DomainBase)transferencia.Origem).Id) : null),
+ Data = transferencia.Data,
+ Valor = transferencia.Valor,
+ Destino = ((transferencia.Destino != null) ? source.First((BancosContas x) => ((DomainBase)x).Id == ((DomainBase)transferencia.Destino).Id) : null)
+ };
+ }
+}