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 _saldos = new ObservableCollection(); private Saldo _selectedSaldo = new Saldo(); private ObservableCollection _lancamentos = new ObservableCollection(); private bool _dontSort; private ObservableCollection _lancamentosFiltrados = new ObservableCollection(); private ObservableCollection _lancamentosFiltradosCopia = new ObservableCollection(); private ObservableCollection _lancamentosVinculo = new ObservableCollection(); 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 _planosFiltro; private List _centroFiltro; private List _contaFiltro; private List _planos; private ObservableCollection _planosFiltrados; private List _contas; private ObservableCollection _contasFiltradas; private List _centros; private ObservableCollection _centrosFiltrados; private ObservableCollection _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 _filtroRelatorioPersonalizado; private List _filtros; private ObservableCollection _personalizadoSelecionado; private ObservableCollection _filtroRelatorioSelecionado = new ObservableCollection(); 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; private ObservableCollection _filtroPersonalizadoSelecionado = new ObservableCollection(); 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 Saldos { get { return _saldos; } set { _saldos = value; OnPropertyChanged("Saldos"); } } public Saldo SelectedSaldo { get { return _selectedSaldo; } set { _selectedSaldo = value; OnPropertyChanged("SelectedSaldo"); } } public ObservableCollection Lancamentos { get { return _lancamentos; } set { _lancamentos = value; OnPropertyChanged("Lancamentos"); } } public ObservableCollection 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 LancamentosFiltradosCopia { get { return _lancamentosFiltradosCopia; } set { _lancamentosFiltradosCopia = value; OnPropertyChanged("LancamentosFiltradosCopia"); } } private bool Salvando { get; set; } public ObservableCollection 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)PlanosFiltrados).FirstOrDefault((Func)((Planos x) => ((DomainBase)x).Id == value.IdPlano)) ?? ((PlanosFiltrados.Count == 1) ? PlanosFiltrados.First() : null)))); Centro = (Centro)((Importando && Centro != null) ? ((object)Centro) : ((object)(((IEnumerable)CentrosFiltrados).FirstOrDefault((Func)((Centro x) => ((DomainBase)x).Id == value.IdCentro)) ?? ((CentrosFiltrados.Count == 1) ? CentrosFiltrados.First() : null)))); Conta = (BancosContas)((Importando && Conta != null) ? ((object)Conta) : ((object)(((IEnumerable)ContasFiltradas).FirstOrDefault((Func)((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 PlanosFiltro { get { return _planosFiltro; } set { _planosFiltro = value; OnPropertyChanged("PlanosFiltro"); } } public List CentroFiltro { get { return _centroFiltro; } set { _centroFiltro = value; OnPropertyChanged("CentroFiltro"); } } public List ContaFiltro { get { return _contaFiltro; } set { _contaFiltro = value; OnPropertyChanged("ContaFiltro"); } } public List Planos { get { return _planos; } set { _planos = value; OnPropertyChanged("Planos"); } } public ObservableCollection PlanosFiltrados { get { return _planosFiltrados; } set { _planosFiltrados = value; OnPropertyChanged("PlanosFiltrados"); } } public List Contas { get { return _contas; } set { _contas = value; OnPropertyChanged("Contas"); } } public ObservableCollection ContasFiltradas { get { return _contasFiltradas; } set { _contasFiltradas = value; OnPropertyChanged("ContasFiltradas"); } } public List Centros { get { return _centros; } set { _centros = value; OnPropertyChanged("Centros"); } } public ObservableCollection CentrosFiltrados { get { return _centrosFiltrados; } set { _centrosFiltrados = value; OnPropertyChanged("CentrosFiltrados"); } } public ObservableCollection 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 RelatorioFiltroPersonalizado { get { return _filtroRelatorioPersonalizado; } set { _filtroRelatorioPersonalizado = value; OnPropertyChanged("RelatorioFiltroPersonalizado"); } } public List Filtros { get { return _filtros; } set { _filtros = value; OnPropertyChanged("Filtros"); } } public ObservableCollection PersonalizadoSelecionado { get { return _personalizadoSelecionado; } set { _personalizadoSelecionado = value; OnPropertyChanged("PersonalizadoSelecionado"); } } public ObservableCollection 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 { get { return _filtroPersonalizado; } set { _filtroPersonalizado = value; OnPropertyChanged("FiltroPersonalizado"); } } public ObservableCollection FiltroPersonalizadoSelecionado { get { return _filtroPersonalizadoSelecionado; } set { _filtroPersonalizadoSelecionado = value; OnPropertyChanged("FiltroPersonalizadoSelecionado"); } } public AutoCompleteFilterPredicate 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>> 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(Lancamentos.Where((Lancamento x) => !x.Baixado)); break; case 1: LancamentosFiltrados = new ObservableCollection(Lancamentos.Where((Lancamento x) => x.Baixado)); break; case 2: LancamentosFiltrados = new ObservableCollection(Lancamentos); break; } } public async Task CarregarSaldos() { Saldos = new ObservableCollection(); 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)PlanosFiltrados).FirstOrDefault((Func)((Planos x) => ((DomainBase)x).Id == ((DomainBase)lancamento.Controle.Plano).Id)) : null); Centro = ((IEnumerable)CentrosFiltrados).FirstOrDefault((Func)((Centro x) => ((DomainBase)x).Id == ((DomainBase)lancamento.Controle.Centro).Id)); Conta = ((lancamento.Conta != null) ? ((IEnumerable)ContasFiltradas).FirstOrDefault((Func)((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)ContasFiltradas).FirstOrDefault((Func)((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)PlanosFiltrados).FirstOrDefault((Func)((Planos x) => ((DomainBase)x).Id == ((DomainBase)lancamento.Controle.Plano).Id)) : null); Centro = ((IEnumerable)CentrosFiltrados).FirstOrDefault((Func)((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(from x in Planos where x.Ativo orderby x.Descricao select x); Contas = await new BancosContasServico().BuscarBancos(); ContasFiltradas = new ObservableCollection(from x in Contas where x.Ativo orderby x.Descricao select x); Centros = await new CentroServico().BuscarCentros(); CentrosFiltrados = new ObservableCollection(from x in Centros where x.Ativo orderby x.Descricao select x); PlanosFiltro = new List(Planos.OrderBy((Planos x) => x.Descricao)); ContaFiltro = new List(Contas.OrderBy((BancosContas x) => x.Descricao)); CentroFiltro = new List(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 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(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 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 source = await _servico.BuscarLancamentosPersonalizados(Inicio.Value, Fim.Value, SelectedStatus, SelectedFiltroData); List fornecedores = ((FiltroPersonalizadoSelecionado != null) ? (from x in FiltroPersonalizadoSelecionado where (int)x.Tipo == 0 select x.Id).ToList() : new List()); List centros = ((FiltroPersonalizadoSelecionado != null) ? (from x in FiltroPersonalizadoSelecionado where (int)x.Tipo == 2 select x.Id).ToList() : new List()); List planos = ((FiltroPersonalizadoSelecionado != null) ? (from x in FiltroPersonalizadoSelecionado where (int)x.Tipo == 1 select x.Id).ToList() : new List()); List contas = ((FiltroPersonalizadoSelecionado != null) ? (from x in FiltroPersonalizadoSelecionado where (int)x.Tipo == 3 select x.Id).ToList() : new List()); List sinal = ((FiltroPersonalizadoSelecionado != null) ? (from x in FiltroPersonalizadoSelecionado where (int)x.Tipo == 4 select x.Id).ToList() : new List()); 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(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)Saldos).FirstOrDefault((Func)((Saldo x) => ((DomainBase)x).Id == ((DomainBase)SelectedLancamento.Conta).Id)); obj = ((obj2 != null) ? obj2.DataInicio : null); } DateTime date = obj ?? SelectedLancamento.Vencimento.AddDays(-5.0); List source = await _servico.BuscarLancamentosPorFornecedor(FornecedorInclusao.Id, date, Sinal); List ids = Lancamentos.Select((Lancamento x) => ((DomainBase)x).Id).ToList(); source = source.Where((Lancamento x) => !ids.Contains(((DomainBase)x).Id)).ToList(); LancamentosVinculo = new ObservableCollection(source); } public void FiltrarPersonalizado() { List fornecedores = ((FiltroPersonalizadoSelecionado != null) ? (from x in FiltroPersonalizadoSelecionado where (int)x.Tipo == 0 select x.Id).ToList() : new List()); List centros = ((FiltroPersonalizadoSelecionado != null) ? (from x in FiltroPersonalizadoSelecionado where (int)x.Tipo == 2 select x.Id).ToList() : new List()); List planos = ((FiltroPersonalizadoSelecionado != null) ? (from x in FiltroPersonalizadoSelecionado where (int)x.Tipo == 1 select x.Id).ToList() : new List()); List contas = ((FiltroPersonalizadoSelecionado != null) ? (from x in FiltroPersonalizadoSelecionado where (int)x.Tipo == 3 select x.Id).ToList() : new List()); List sinal = ((FiltroPersonalizadoSelecionado != null) ? (from x in FiltroPersonalizadoSelecionado where (int)x.Tipo == 4 select x.Id).ToList() : new List()); List 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(list); LancamentosFiltradosCopia = LancamentosFiltrados; SelectedLancamento = LancamentosFiltrados.FirstOrDefault(); } public async Task ParseOfx(BancosContas conta) { SelectedStatusImportacao = (StatusLancamento)2; Importando = true; VisibleFiltros = (Visibility)2; List list = await ImportarOfx(); if (list == null || list.Count == 0) { Importando = false; return; } List codigoBanco = new List { "0237", "033" }; List lancamentos = new List(); foreach (OfxDocument x2 in list) { Tuple tuple = CorrigeLancamentos(x2, codigoBanco); x2.StatementStart = tuple.Item1; x2.StatementEnd = tuple.Item2; List 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)saved).FirstOrDefault((Func)((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(lancamentos); LancamentosFiltrados = Lancamentos; ExtensionMethods.ForEach((IEnumerable)LancamentosFiltrados, (Action)delegate(Lancamento x) { SelecionarLancamento(x); }); LancamentosFiltradosCopia = LancamentosFiltrados; } private Tuple CorrigeLancamentos(OfxDocument lancamentos, List 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(value, ((obj2 != null) ? new DateTime?(obj2.Date) : null).Value); } if (VerificaDataInvertida(lancamentos)) { return new Tuple(lancamentos.StatementEnd, lancamentos.StatementStart); } return new Tuple(lancamentos.StatementStart, lancamentos.StatementEnd); } private bool VerificaFiltroErrado(OfxDocument lancamentos) { List source = new List { "0237", "756" }; if (lancamentos.StatementStart == lancamentos.StatementEnd) { return source.Any((string idbanco) => idbanco == lancamentos.Account.BankId); } return false; } private bool VerificaDataInvertida(OfxDocument lancamentos) { List source = new List { "0104" }; if (lancamentos.StatementStart > lancamentos.StatementEnd) { return source.Any((string banco) => banco == lancamentos.Account.BankId); } return false; } public List FiltrarLancamento(long id) { LancamentosFiltrados = new ObservableCollection(Lancamentos.Where((Lancamento x) => ((DomainBase)x).Id == id)); return LancamentosFiltrados.ToList(); } public List FiltrarLancamento(Lancamento lancamento) { LancamentosFiltrados = new ObservableCollection(Lancamentos.Where((Lancamento x) => x.Valor == lancamento.Valor && x.Vencimento == lancamento.Vencimento && x.Historico == lancamento.Historico)); return LancamentosFiltrados.ToList(); } public async Task> FiltrarLancamento(string value) { return await Task.Run(() => Filtrar(value)); } public List Filtrar(string filter) { _dontSort = true; LancamentosFiltrados = (string.IsNullOrWhiteSpace(filter) ? Lancamentos : new ObservableCollection(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(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(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 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(list); LancamentosFiltradosCopia = LancamentosFiltrados; } private static List GerarRelatorio(List lancamentos) { return ((IEnumerable)lancamentos).Select((Func)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(x.Sinal)); val.Competencia = x.Competencia; return val; }).ToList(); } public async Task GerarExcel(List relatorioGrid) { bool agrupar = await ShowMessage("DESEJA AGRUPAR POR " + EnumHelper.GetDescription(SinteticoTipo), "SIM", "NÃO"); XLWorkbook xlWorkbook = new XLWorkbook(); string nome = "LANÇAMENTOS FINANCEIROS"; new List(); List lancamentosRelatorio = new List(); 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 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, SinteticoFinanceiro>)((IGrouping 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 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 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 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 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 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 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 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 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 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 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 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 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 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 GerarHtml(List 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 colunasOcultas = Funcoes.OcultarColunasDescricao(typeof(Sintetico), "FINANCEIRO"); List lancamentosRelatorio = new List(); 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 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, SinteticoFinanceiro>)((IGrouping 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(SinteticoTipo), body); List 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 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()); 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 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)PlanosFiltrados).FirstOrDefault((Func)((Planos x) => ((DomainBase)x).Id == fornecedor.IdPlano)) ?? PlanosFiltrados.FirstOrDefault()) : PlanosFiltrados.FirstOrDefault()); Fornecedor obj2 = fornecedor; BancosContas conta = ((obj2 != null && obj2.IdConta.HasValue) ? (((IEnumerable)ContasFiltradas).FirstOrDefault((Func)((BancosContas x) => ((DomainBase)x).Id == fornecedor.IdConta)) ?? ContasFiltradas.FirstOrDefault()) : ContasFiltradas.FirstOrDefault()); Fornecedor obj3 = fornecedor; Centro centro = ((obj3 != null && obj3.IdCentro.HasValue) ? (((IEnumerable)CentrosFiltrados).FirstOrDefault((Func)((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)LancamentosFiltrados).FirstOrDefault((Func)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 list = ((PersonalizadoSelecionado == null) ? new List() : 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 list2 = ((PersonalizadoSelecionado == null) ? new List() : 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(); } 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 property = PersonalizadoSelecionado.Where((FiltroPersonalizado x) => !x.Propriedade.Contains(".")).ToList(); List 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(lancamentos); } public async void PopularFiltro() { if (FiltroPersonalizado == null || FiltroPersonalizado.Count <= 0) { FiltroPersonalizado = new List(); List collection = ((IEnumerable)(await new BaseServico().BuscarFornecedor())).Select((Func)((Fornecedor x) => new FiltroPersonalizado { Tipo = (TipoFiltroFinanceiro)0, Descricao = x.Nome + " " + x.Documento, Id = x.Id })).ToList(); FiltroPersonalizado.AddRange(collection); collection = ((IEnumerable)Centros).Select((Func)((Centro x) => new FiltroPersonalizado { Tipo = (TipoFiltroFinanceiro)2, Descricao = x.Descricao, Id = ((DomainBase)x).Id })).ToList(); FiltroPersonalizado.AddRange(collection); collection = ((IEnumerable)Planos).Select((Func)((Planos x) => new FiltroPersonalizado { Tipo = (TipoFiltroFinanceiro)1, Descricao = x.Descricao, Id = ((DomainBase)x).Id })).ToList(); FiltroPersonalizado.AddRange(collection); collection = ((IEnumerable)Contas).Select((Func)((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)0), Id = 0L, Tipo = (TipoFiltroFinanceiro)4 }); FiltroPersonalizado.Add(new FiltroPersonalizado { Descricao = EnumHelper.GetDescription((Sinal)1), Id = 1L, Tipo = (TipoFiltroFinanceiro)4 }); } } internal async Task> FiltroPersonalizadoTask(string value) { return await Task.Run(() => FiltrarPersonalizado(value)); } public List 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(); } 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(); LancamentosFiltrados = new ObservableCollection(); 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(FiltroPersonalizadoSelecionado); FiltrarPersonalizado(); } public void LimparFiltros() { FiltroPersonalizadoSelecionado = null; VisibleFiltros = (Visibility)2; } public async Task>> Salvar(Transferencia transferencia) { List> errors = transferencia.Validate(); List> 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>> Validar(Transferencia transferencia) { List> errors = ValidationHelper.AddValue(); BancosContasServico servico = new BancosContasServico(); Transferencia obj = transferencia; if (((obj != null) ? obj.Origem : null) == null) { ValidationHelper.AddValue(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(errors, "DESTINO", "NÃO É POSSÍVEL FAZER UMA TRANSFERÊNCIA SEM BANDO DESTINO", true); return errors; } List ids = new List { ((DomainBase)transferencia.Origem).Id, ((DomainBase)transferencia.Destino).Id }; List saldos = await servico.BuscarSaldoAberto(ids); Saldo saldo2 = ((IEnumerable)saldos).FirstOrDefault((Func)((Saldo s) => ((DomainBase)s.Conta).Id == ((DomainBase)transferencia.Origem).Id)); if (saldo2 == null) { List 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(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)saldos).FirstOrDefault((Func)((Saldo s) => ((DomainBase)s.Conta).Id == ((DomainBase)transferencia.Destino).Id)); if (saldo2 == null || saldo2.DataInicio > transferencia.Data) { ValidationHelper.AddValue(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 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>> Salvar() { List> errors = SelectedLancamento.Validate() ?? new List>(); List> list = errors; list.AddRange(await Validar()); if (errors.Count > 0) { return errors; } if (((DomainBase)SelectedLancamento.Controle).Id == 0 && SelectedLancamento.Controle.Parcelas > 0) { List list2 = new List(); 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>> Validar() { List> errors = ValidationHelper.AddValue(); BancosContasServico servico = new BancosContasServico(); Saldo saldo = ((IEnumerable)(await servico.BuscarSaldoAberto(Contas.Select((BancosContas x) => ((DomainBase)x).Id).ToList()))).FirstOrDefault((Func)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 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>(); } ValidationHelper.AddValue(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)LancamentosFiltrados).FirstOrDefault((Func)((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 lancamentosInclusao = new List(); List list = LancamentosFiltrados.Where((Lancamento x) => x.Selecionado).Select((Func)((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 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 lancamentosExlusao = new List(); 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 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 lancamentosExlusao = new List(); List transferencias = LancamentosFiltrados.Where((Lancamento x) => x.Selecionado && x.Historico.Equals("TRANSFERÊNCIA ENTRE CONTAS")).ToList(); transferencias.ForEach(delegate(Lancamento x) { Lancamento y = ((IEnumerable)transferencias).FirstOrDefault((Func)((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 { 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 todosLancamentos = new List(); 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 VerificaSaldo(long contaId, bool reabrirSaldo) { Saldo saldo = ((IEnumerable)(await new BancosContasServico().BuscarSaldoAberto(Contas.Select((BancosContas x) => ((DomainBase)x).Id).ToList()))).FirstOrDefault((Func)((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 SalvarImportacao(List list) { List lancamentosAtualizar = new List(); List lancamentosBaixar = new List(); List lancamentosIncluir = new List(); List lancamentos = new List(); 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 list) { Loading(isLoading: true); List lancamentosAtualizar = new List(); List lancamentosBaixar = new List(); List lancamentos = new List(); 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> 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 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> 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(PlanosFiltro.Where((Planos x) => x.Selecionado), (Action)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.OrderBy((Planos x) => x.Descricao)); ExtensionMethods.ForEach(ContaFiltro.Where((BancosContas x) => x.Selecionado), (Action)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(Contas.OrderBy((BancosContas x) => x.Descricao)); ExtensionMethods.ForEach(CentroFiltro.Where((Centro x) => x.Selecionado), (Action)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(Centros.OrderBy((Centro x) => x.Descricao)); } }