diff options
| author | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 13:38:18 +0000 |
|---|---|---|
| committer | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 13:38:18 +0000 |
| commit | 1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 (patch) | |
| tree | e1c3b20ea08f0cf71122a1e73f0d395f8fd83874 /Codemerx/Gestor.Application/ViewModels/Financeiro/FinanceiroViewModel.cs | |
| parent | 674ca83ba9243a9e95a7568c797668dab6aee26a (diff) | |
| download | gestor-1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1.tar.gz gestor-1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1.zip | |
chore: location
Diffstat (limited to 'Codemerx/Gestor.Application/ViewModels/Financeiro/FinanceiroViewModel.cs')
| -rw-r--r-- | Codemerx/Gestor.Application/ViewModels/Financeiro/FinanceiroViewModel.cs | 5973 |
1 files changed, 5973 insertions, 0 deletions
diff --git a/Codemerx/Gestor.Application/ViewModels/Financeiro/FinanceiroViewModel.cs b/Codemerx/Gestor.Application/ViewModels/Financeiro/FinanceiroViewModel.cs new file mode 100644 index 0000000..630e3db --- /dev/null +++ b/Codemerx/Gestor.Application/ViewModels/Financeiro/FinanceiroViewModel.cs @@ -0,0 +1,5973 @@ +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;
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Diagnostics;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Forms;
+
+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.Collapsed;
+
+ private Visibility _isVisiblePersonalizado = Visibility.Collapsed;
+
+ private Visibility _isVisibleFiltros = Visibility.Collapsed;
+
+ private Visibility _isVisibleLancamento;
+
+ private Visibility _isvisibleStatus;
+
+ private FiltroLancamento _selectedFiltro;
+
+ private FiltroLancamentoData _selectedFiltroData;
+
+ private StatusLancamento _selectedStatus;
+
+ private StatusLancamento _selectedStatusImportacao = 2;
+
+ private Visibility _botaoSalvarVisibility;
+
+ private DateTime? _inicio = new DateTime?(Funcoes.GetNetworkTime());
+
+ private DateTime? _fim = new DateTime?(Funcoes.GetNetworkTime().AddDays(7));
+
+ private Fornecedor _selectedFornecedor;
+
+ private ObservableCollection<Saldo> _saldos = new ObservableCollection<Saldo>();
+
+ private Saldo _selectedSaldo = new Saldo();
+
+ private ObservableCollection<Lancamento> _lancamentos = new ObservableCollection<Lancamento>();
+
+ private bool _dontSort;
+
+ private ObservableCollection<Lancamento> _lancamentosFiltrados = new ObservableCollection<Lancamento>();
+
+ private ObservableCollection<Lancamento> _lancamentosFiltradosCopia = new ObservableCollection<Lancamento>();
+
+ private ObservableCollection<Lancamento> _lancamentosVinculo = new ObservableCollection<Lancamento>();
+
+ private Lancamento _lancamentoVinculo;
+
+ private Lancamento _selectedLancamento;
+
+ private Fornecedor _fornecedorInclusao;
+
+ private long _idLancamento;
+
+ private string _historico;
+
+ private string _observacao;
+
+ private string _documento;
+
+ private string _complemento;
+
+ private string _competencia;
+
+ private int _parcela;
+
+ private double _dropDownHeight;
+
+ private int _parcelas;
+
+ public bool VencimentoAlterado;
+
+ private DateTime _vencimento;
+
+ private DateTime? _baixa;
+
+ private DateTime? _pagamento;
+
+ private decimal _valor;
+
+ private decimal? _valorPago;
+
+ private Gestor.Model.Common.Sinal _sinal;
+
+ private Gestor.Model.Domain.Financeiro.Planos _plano;
+
+ private Gestor.Model.Domain.Financeiro.Centro _centro;
+
+ private BancosContas _conta;
+
+ private Gestor.Model.Common.TipoPagamento _tipoPagamento;
+
+ private List<Gestor.Model.Domain.Financeiro.Planos> _planosFiltro;
+
+ private List<Gestor.Model.Domain.Financeiro.Centro> _centroFiltro;
+
+ private List<BancosContas> _contaFiltro;
+
+ private List<Gestor.Model.Domain.Financeiro.Planos> _planos;
+
+ private ObservableCollection<Gestor.Model.Domain.Financeiro.Planos> _planosFiltrados;
+
+ private List<BancosContas> _contas;
+
+ private ObservableCollection<BancosContas> _contasFiltradas;
+
+ private List<Gestor.Model.Domain.Financeiro.Centro> _centros;
+
+ private ObservableCollection<Gestor.Model.Domain.Financeiro.Centro> _centrosFiltrados;
+
+ private ObservableCollection<Gestor.Model.Domain.Financeiro.SinteticoFinanceiro> _totalizacao;
+
+ private Visibility _visibilityFornecedor;
+
+ private Visibility _visibilityCentro;
+
+ private Visibility _visibilityConta;
+
+ private Visibility _alterando = Visibility.Collapsed;
+
+ private bool _buscaHabilitada = true;
+
+ private bool _alteracao = true;
+
+ private List<Gestor.Model.Domain.Relatorios.FiltroPersonalizado> _filtroRelatorioPersonalizado;
+
+ private List<Gestor.Model.Domain.Relatorios.FiltroPersonalizado> _filtros;
+
+ private ObservableCollection<Gestor.Model.Domain.Relatorios.FiltroPersonalizado> _personalizadoSelecionado;
+
+ private ObservableCollection<Gestor.Model.Domain.Relatorios.FiltroPersonalizado> _filtroRelatorioSelecionado = new ObservableCollection<Gestor.Model.Domain.Relatorios.FiltroPersonalizado>();
+
+ private Visibility _visibilitySemValor = Visibility.Collapsed;
+
+ private Gestor.Model.Domain.Relatorios.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<Gestor.Model.Domain.Financeiro.FiltroPersonalizado> _filtroPersonalizado;
+
+ private ObservableCollection<Gestor.Model.Domain.Financeiro.FiltroPersonalizado> _filtroPersonalizadoSelecionado = new ObservableCollection<Gestor.Model.Domain.Financeiro.FiltroPersonalizado>();
+
+ private Visibility _visibleFiltros = Visibility.Collapsed;
+
+ private Visibility _visibleOlho = Visibility.Collapsed;
+
+ private bool importando;
+
+ private bool _isExpanded;
+
+ public bool Alteracao
+ {
+ get
+ {
+ return this._alteracao;
+ }
+ set
+ {
+ this._alteracao = value;
+ base.OnPropertyChanged("Alteracao");
+ }
+ }
+
+ public Visibility Alterando
+ {
+ get
+ {
+ return this._alterando;
+ }
+ set
+ {
+ this._alterando = value;
+ base.OnPropertyChanged("Alterando");
+ }
+ }
+
+ public DateTime? Baixa
+ {
+ get
+ {
+ return this._baixa;
+ }
+ set
+ {
+ this._baixa = value;
+ base.OnPropertyChanged("Baixa");
+ }
+ }
+
+ public Visibility BotaoSalvarVisibility
+ {
+ get
+ {
+ return this._isvisibleStatus;
+ }
+ set
+ {
+ this._isvisibleStatus = value;
+ base.OnPropertyChanged("BotaoSalvarVisibility");
+ }
+ }
+
+ public bool BuscaHabilitada
+ {
+ get
+ {
+ return this._buscaHabilitada;
+ }
+ set
+ {
+ this._buscaHabilitada = value;
+ base.OnPropertyChanged("BuscaHabilitada");
+ }
+ }
+
+ private bool Carregar { get; set; } = true;
+
+ public Gestor.Model.Domain.Financeiro.Centro Centro
+ {
+ get
+ {
+ return this._centro;
+ }
+ set
+ {
+ this._centro = value;
+ base.OnPropertyChanged("Centro");
+ }
+ }
+
+ public List<Gestor.Model.Domain.Financeiro.Centro> CentroFiltro
+ {
+ get
+ {
+ return this._centroFiltro;
+ }
+ set
+ {
+ this._centroFiltro = value;
+ base.OnPropertyChanged("CentroFiltro");
+ }
+ }
+
+ public List<Gestor.Model.Domain.Financeiro.Centro> Centros
+ {
+ get
+ {
+ return this._centros;
+ }
+ set
+ {
+ this._centros = value;
+ base.OnPropertyChanged("Centros");
+ }
+ }
+
+ public ObservableCollection<Gestor.Model.Domain.Financeiro.Centro> CentrosFiltrados
+ {
+ get
+ {
+ return this._centrosFiltrados;
+ }
+ set
+ {
+ this._centrosFiltrados = value;
+ base.OnPropertyChanged("CentrosFiltrados");
+ }
+ }
+
+ public string CodigoBanco
+ {
+ get;
+ set;
+ }
+
+ public string Competencia
+ {
+ get
+ {
+ return this._competencia;
+ }
+ set
+ {
+ this._competencia = value;
+ base.OnPropertyChanged("Competencia");
+ }
+ }
+
+ public string Complemento
+ {
+ get
+ {
+ return this._complemento;
+ }
+ set
+ {
+ this._complemento = value;
+ base.OnPropertyChanged("Complemento");
+ }
+ }
+
+ public BancosContas Conta
+ {
+ get
+ {
+ return this._conta;
+ }
+ set
+ {
+ this._conta = value;
+ base.OnPropertyChanged("Conta");
+ }
+ }
+
+ public List<BancosContas> ContaFiltro
+ {
+ get
+ {
+ return this._contaFiltro;
+ }
+ set
+ {
+ this._contaFiltro = value;
+ base.OnPropertyChanged("ContaFiltro");
+ }
+ }
+
+ public List<BancosContas> Contas
+ {
+ get
+ {
+ return this._contas;
+ }
+ set
+ {
+ this._contas = value;
+ base.OnPropertyChanged("Contas");
+ }
+ }
+
+ public ObservableCollection<BancosContas> ContasFiltradas
+ {
+ get
+ {
+ return this._contasFiltradas;
+ }
+ set
+ {
+ this._contasFiltradas = value;
+ base.OnPropertyChanged("ContasFiltradas");
+ }
+ }
+
+ public string Documento
+ {
+ get
+ {
+ return this._documento;
+ }
+ set
+ {
+ this._documento = value;
+ base.OnPropertyChanged("Documento");
+ }
+ }
+
+ public double DropDownHeight
+ {
+ get
+ {
+ return this._dropDownHeight;
+ }
+ set
+ {
+ this._dropDownHeight = value;
+ base.OnPropertyChanged("DropDownHeight");
+ }
+ }
+
+ public bool EnableChanges
+ {
+ get
+ {
+ return this._enableChanges;
+ }
+ set
+ {
+ this._enableChanges = value;
+ base.OnPropertyChanged("EnableChanges");
+ }
+ }
+
+ public bool EnableIncluirNovo
+ {
+ get
+ {
+ return this._enableIncluirNovo;
+ }
+ set
+ {
+ this._enableIncluirNovo = value;
+ base.OnPropertyChanged("EnableIncluirNovo");
+ }
+ }
+
+ public Gestor.Model.Domain.Relatorios.FiltroPersonalizado Filtro
+ {
+ get
+ {
+ return this._filtro;
+ }
+ set
+ {
+ char chr;
+ this._filtro = value;
+ this.VisibilitySemValor = (value != null ? Visibility.Visible : Visibility.Collapsed);
+ base.OnPropertyChanged("Filtro");
+ if (value == null)
+ {
+ return;
+ }
+ string name = value.get_Tipo().Name;
+ if (name != null)
+ {
+ switch (name.Length)
+ {
+ case 3:
+ {
+ if (name == "int")
+ {
+ break;
+ }
+ return;
+ }
+ case 4:
+ {
+ chr = name[0];
+ if (chr == 'E')
+ {
+ if (name == "Enum")
+ {
+ this.ValorInicial = null;
+ this.ValorFinal = null;
+ return;
+ }
+ return;
+ }
+ else
+ {
+ if (chr != 'l')
+ {
+ return;
+ }
+ if (name == "long")
+ {
+ break;
+ }
+ return;
+ }
+ }
+ case 5:
+ {
+ chr = name[3];
+ if (chr == '3')
+ {
+ if (name == "int32")
+ {
+ break;
+ }
+ return;
+ }
+ else
+ {
+ if (chr != '6')
+ {
+ return;
+ }
+ if (name == "int64")
+ {
+ break;
+ }
+ return;
+ }
+ }
+ case 6:
+ {
+ if (name != "String")
+ {
+ return;
+ }
+ this.ValorInicial = "";
+ this.ValorFinal = "";
+ return;
+ }
+ case 7:
+ {
+ if (name != "Decimal")
+ {
+ return;
+ }
+ this.ValorInicial = "0,00";
+ this.ValorFinal = "0,00";
+ return;
+ }
+ case 8:
+ {
+ if (name == "DateTime")
+ {
+ this.ValorInicial = null;
+ this.ValorFinal = null;
+ return;
+ }
+ return;
+ }
+ default:
+ {
+ return;
+ }
+ }
+ this.ValorInicial = "0";
+ this.ValorFinal = "0";
+ }
+ }
+ }
+
+ public List<Gestor.Model.Domain.Financeiro.FiltroPersonalizado> FiltroPersonalizado
+ {
+ get
+ {
+ return this._filtroPersonalizado;
+ }
+ set
+ {
+ this._filtroPersonalizado = value;
+ base.OnPropertyChanged("FiltroPersonalizado");
+ }
+ }
+
+ public AutoCompleteFilterPredicate<object> FiltroPersonalizadoItemFilter
+ {
+ get
+ {
+ AutoCompleteFilterPredicate<object> u003cu003e9_3690 = FinanceiroViewModel.u003cu003ec.u003cu003e9__369_0;
+ if (u003cu003e9_3690 == null)
+ {
+ u003cu003e9_3690 = new AutoCompleteFilterPredicate<object>(FinanceiroViewModel.u003cu003ec.u003cu003e9, (string searchText, object obj) => ((Gestor.Model.Domain.Financeiro.FiltroPersonalizado)obj).get_Descricao().ToUpper().Contains(searchText.ToUpper()));
+ FinanceiroViewModel.u003cu003ec.u003cu003e9__369_0 = u003cu003e9_3690;
+ }
+ return u003cu003e9_3690;
+ }
+ }
+
+ public ObservableCollection<Gestor.Model.Domain.Financeiro.FiltroPersonalizado> FiltroPersonalizadoSelecionado
+ {
+ get
+ {
+ return this._filtroPersonalizadoSelecionado;
+ }
+ set
+ {
+ this._filtroPersonalizadoSelecionado = value;
+ base.OnPropertyChanged("FiltroPersonalizadoSelecionado");
+ }
+ }
+
+ public ObservableCollection<Gestor.Model.Domain.Relatorios.FiltroPersonalizado> FiltroRelatorioSelecionado
+ {
+ get
+ {
+ return this._filtroRelatorioSelecionado;
+ }
+ set
+ {
+ this._filtroRelatorioSelecionado = value;
+ base.OnPropertyChanged("FiltroRelatorioSelecionado");
+ }
+ }
+
+ public List<Gestor.Model.Domain.Relatorios.FiltroPersonalizado> Filtros
+ {
+ get
+ {
+ return this._filtros;
+ }
+ set
+ {
+ this._filtros = value;
+ base.OnPropertyChanged("Filtros");
+ }
+ }
+
+ public DateTime? Fim
+ {
+ get
+ {
+ return this._fim;
+ }
+ set
+ {
+ if (value.HasValue && value.Value < new DateTime(1754, 1, 1))
+ {
+ value = new DateTime?(new DateTime(1754, 1, 1));
+ }
+ if (value.HasValue && value.Value > new DateTime(9999, 12, 31))
+ {
+ value = new DateTime?(new DateTime(9999, 12, 31));
+ }
+ this._fim = value;
+ base.OnPropertyChanged("Fim");
+ }
+ }
+
+ public Fornecedor FornecedorInclusao
+ {
+ get
+ {
+ return this._fornecedorInclusao;
+ }
+ set
+ {
+ //
+ // Current member / type: System.Void Gestor.Application.ViewModels.Financeiro.FinanceiroViewModel::set_FornecedorInclusao(Gestor.Model.Domain.Financeiro.Fornecedor)
+ // File path: C:\AggerSeguros\Gestor.Application.exe
+ //
+ // Product version: 0.0.0.0
+ // Exception in: System.Void set_FornecedorInclusao(Gestor.Model.Domain.Financeiro.Fornecedor)
+ //
+ // Object reference not set to an instance of an object.
+ // at Telerik.JustDecompiler.Decompiler.TypeInference.TypeInferer.FindLowestCommonAncestor(ICollection`1 typeNodes) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\TypeInference\TypeInferer.cs:line 515
+ // at Telerik.JustDecompiler.Decompiler.TypeInference.TypeInferer.MergeWithLowestCommonAncestor() in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\TypeInference\TypeInferer.cs:line 459
+ // at Telerik.JustDecompiler.Decompiler.TypeInference.TypeInferer.ProcessSingleConstraints() in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\TypeInference\TypeInferer.cs:line 378
+ // at Telerik.JustDecompiler.Decompiler.TypeInference.TypeInferer.InferTypes() in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\TypeInference\TypeInferer.cs:line 331
+ // at Telerik.JustDecompiler.Decompiler.ExpressionDecompilerStep.Process(DecompilationContext theContext, BlockStatement body) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\ExpressionDecompilerStep.cs:line 104
+ // at Telerik.JustDecompiler.Decompiler.DecompilationPipeline.RunInternal(MethodBody body, BlockStatement block, ILanguage language) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\DecompilationPipeline.cs:line 100
+ // at Telerik.JustDecompiler.Decompiler.DecompilationPipeline.Run(MethodBody body, ILanguage language) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\DecompilationPipeline.cs:line 72
+ // at Telerik.JustDecompiler.Decompiler.PropertyDecompiler.DecompileMethod(MethodBody body, MethodSpecificContext& methodContext) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\PropertyDecompiler.cs:line 347
+ //
+ // mailto: JustDecompilePublicFeedback@telerik.com
+
+ }
+ }
+
+ public string Historico
+ {
+ get
+ {
+ return this._historico;
+ }
+ set
+ {
+ this._historico = value;
+ base.OnPropertyChanged("Historico");
+ }
+ }
+
+ public long IdLancamento
+ {
+ get
+ {
+ return this._idLancamento;
+ }
+ set
+ {
+ this._idLancamento = value;
+ base.OnPropertyChanged("IdLancamento");
+ }
+ }
+
+ public bool Importando
+ {
+ get
+ {
+ return this.importando;
+ }
+ set
+ {
+ this.importando = value;
+ base.OnPropertyChanged("Importando");
+ }
+ }
+
+ public DateTime? Inicio
+ {
+ get
+ {
+ return this._inicio;
+ }
+ set
+ {
+ if (value.HasValue && value.Value < new DateTime(1754, 1, 1))
+ {
+ value = new DateTime?(new DateTime(1754, 1, 1));
+ }
+ if (value.HasValue && value.Value > new DateTime(9999, 12, 31))
+ {
+ value = new DateTime?(new DateTime(9999, 12, 31));
+ }
+ this._inicio = value;
+ base.OnPropertyChanged("Inicio");
+ }
+ }
+
+ public bool IsExpanded
+ {
+ get
+ {
+ return this._isExpanded;
+ }
+ set
+ {
+ this._isExpanded = value;
+ base.OnPropertyChanged("IsExpanded");
+ }
+ }
+
+ public Visibility IsVisibleData
+ {
+ get
+ {
+ return this._isVisibleData;
+ }
+ set
+ {
+ this._isVisibleData = value;
+ base.OnPropertyChanged("IsVisibleData");
+ }
+ }
+
+ public Visibility IsVisibleFiltros
+ {
+ get
+ {
+ return this._isVisibleFiltros;
+ }
+ set
+ {
+ this._isVisibleFiltros = value;
+ base.OnPropertyChanged("IsVisibleFiltros");
+ }
+ }
+
+ public Visibility IsVisibleFornecedor
+ {
+ get
+ {
+ return this._isVisibleFornecedor;
+ }
+ set
+ {
+ this._isVisibleFornecedor = value;
+ base.OnPropertyChanged("IsVisibleFornecedor");
+ }
+ }
+
+ public Visibility IsVisibleLancamento
+ {
+ get
+ {
+ return this._isVisibleLancamento;
+ }
+ set
+ {
+ this._isVisibleLancamento = value;
+ base.OnPropertyChanged("IsVisibleLancamento");
+ }
+ }
+
+ public Visibility IsVisiblePersonalizado
+ {
+ get
+ {
+ return this._isVisiblePersonalizado;
+ }
+ set
+ {
+ this._isVisiblePersonalizado = value;
+ base.OnPropertyChanged("IsVisiblePersonalizado");
+ }
+ }
+
+ public Visibility IsvisibleStatus
+ {
+ get
+ {
+ return this._isvisibleStatus;
+ }
+ set
+ {
+ this._isvisibleStatus = value;
+ base.OnPropertyChanged("IsvisibleStatus");
+ }
+ }
+
+ public ObservableCollection<Lancamento> Lancamentos
+ {
+ get
+ {
+ return this._lancamentos;
+ }
+ set
+ {
+ this._lancamentos = value;
+ base.OnPropertyChanged("Lancamentos");
+ }
+ }
+
+ private Lancamento LancamentoSelecionado
+ {
+ get;
+ set;
+ }
+
+ public ObservableCollection<Lancamento> LancamentosFiltrados
+ {
+ get
+ {
+ return this._lancamentosFiltrados;
+ }
+ set
+ {
+ if (!this._dontSort)
+ {
+ Action saveSortLancamentos = Gestor.Application.Actions.Actions.SaveSortLancamentos;
+ if (saveSortLancamentos != null)
+ {
+ saveSortLancamentos();
+ }
+ else
+ {
+ }
+ }
+ this._lancamentosFiltrados = value;
+ this.Totalizar();
+ base.OnPropertyChanged("LancamentosFiltrados");
+ if (!this._dontSort)
+ {
+ Action sortLancamentos = Gestor.Application.Actions.Actions.SortLancamentos;
+ if (sortLancamentos == null)
+ {
+ return;
+ }
+ sortLancamentos();
+ }
+ }
+ }
+
+ public ObservableCollection<Lancamento> LancamentosFiltradosCopia
+ {
+ get
+ {
+ return this._lancamentosFiltradosCopia;
+ }
+ set
+ {
+ this._lancamentosFiltradosCopia = value;
+ base.OnPropertyChanged("LancamentosFiltradosCopia");
+ }
+ }
+
+ public ObservableCollection<Lancamento> LancamentosVinculo
+ {
+ get
+ {
+ return this._lancamentosVinculo;
+ }
+ set
+ {
+ this._lancamentosVinculo = value;
+ base.OnPropertyChanged("LancamentosVinculo");
+ }
+ }
+
+ public Lancamento LancamentoVinculo
+ {
+ get
+ {
+ return this._lancamentoVinculo;
+ }
+ set
+ {
+ this._lancamentoVinculo = value;
+ base.OnPropertyChanged("LancamentoVinculo");
+ }
+ }
+
+ public bool NotImportando
+ {
+ get
+ {
+ return !this.Importando;
+ }
+ }
+
+ public string Observacao
+ {
+ get
+ {
+ return this._observacao;
+ }
+ set
+ {
+ this._observacao = value;
+ base.OnPropertyChanged("Observacao");
+ }
+ }
+
+ public DateTime? Pagamento
+ {
+ get
+ {
+ return this._pagamento;
+ }
+ set
+ {
+ this._pagamento = value;
+ base.OnPropertyChanged("Pagamento");
+ }
+ }
+
+ public int Parcela
+ {
+ get
+ {
+ return this._parcela;
+ }
+ set
+ {
+ this._parcela = value;
+ base.OnPropertyChanged("Parcela");
+ }
+ }
+
+ public int Parcelas
+ {
+ get
+ {
+ return this._parcelas;
+ }
+ set
+ {
+ this._parcelas = value;
+ base.OnPropertyChanged("Parcelas");
+ }
+ }
+
+ public ObservableCollection<Gestor.Model.Domain.Relatorios.FiltroPersonalizado> PersonalizadoSelecionado
+ {
+ get
+ {
+ return this._personalizadoSelecionado;
+ }
+ set
+ {
+ this._personalizadoSelecionado = value;
+ base.OnPropertyChanged("PersonalizadoSelecionado");
+ }
+ }
+
+ public Gestor.Model.Domain.Financeiro.Planos Plano
+ {
+ get
+ {
+ return this._plano;
+ }
+ set
+ {
+ this._plano = value;
+ base.OnPropertyChanged("Plano");
+ if (value == null || value.get_Id() == 0)
+ {
+ return;
+ }
+ this.Sinal = (this.importando ? this.Sinal : value.get_Sinal());
+ }
+ }
+
+ public List<Gestor.Model.Domain.Financeiro.Planos> Planos
+ {
+ get
+ {
+ return this._planos;
+ }
+ set
+ {
+ this._planos = value;
+ base.OnPropertyChanged("Planos");
+ }
+ }
+
+ public ObservableCollection<Gestor.Model.Domain.Financeiro.Planos> PlanosFiltrados
+ {
+ get
+ {
+ return this._planosFiltrados;
+ }
+ set
+ {
+ this._planosFiltrados = value;
+ base.OnPropertyChanged("PlanosFiltrados");
+ }
+ }
+
+ public List<Gestor.Model.Domain.Financeiro.Planos> PlanosFiltro
+ {
+ get
+ {
+ return this._planosFiltro;
+ }
+ set
+ {
+ this._planosFiltro = value;
+ base.OnPropertyChanged("PlanosFiltro");
+ }
+ }
+
+ public List<Gestor.Model.Domain.Relatorios.FiltroPersonalizado> RelatorioFiltroPersonalizado
+ {
+ get
+ {
+ return this._filtroRelatorioPersonalizado;
+ }
+ set
+ {
+ this._filtroRelatorioPersonalizado = value;
+ base.OnPropertyChanged("RelatorioFiltroPersonalizado");
+ }
+ }
+
+ public ObservableCollection<Saldo> Saldos
+ {
+ get
+ {
+ return this._saldos;
+ }
+ set
+ {
+ this._saldos = value;
+ base.OnPropertyChanged("Saldos");
+ }
+ }
+
+ private bool Salvando
+ {
+ get;
+ set;
+ }
+
+ public FiltroLancamento SelectedFiltro
+ {
+ get
+ {
+ return this._selectedFiltro;
+ }
+ set
+ {
+ this._selectedFiltro = value;
+ this.LimparLancamentos();
+ base.OnPropertyChanged("SelectedFiltro");
+ }
+ }
+
+ public FiltroLancamentoData SelectedFiltroData
+ {
+ get
+ {
+ return this._selectedFiltroData;
+ }
+ set
+ {
+ this._selectedFiltroData = value;
+ this.LimparLancamentos();
+ base.OnPropertyChanged("SelectedFiltroData");
+ }
+ }
+
+ public Fornecedor SelectedFornecedor
+ {
+ get
+ {
+ return this._selectedFornecedor;
+ }
+ set
+ {
+ this._selectedFornecedor = value;
+ this.LimparLancamentos();
+ base.OnPropertyChanged("SelectedFornecedor");
+ }
+ }
+
+ public Lancamento SelectedLancamento
+ {
+ get
+ {
+ return this._selectedLancamento;
+ }
+ set
+ {
+ bool id;
+ bool flag;
+ bool id1;
+ if (value != null && value.get_Id() != 0)
+ {
+ this.IdLancamento = value.get_Id();
+ }
+ else if (this.importando)
+ {
+ this.IdLancamento = (long)0;
+ }
+ if (value == null || value.get_Id() <= (long)0)
+ {
+ id = false;
+ }
+ else
+ {
+ Usuario usuario = Recursos.Usuario;
+ if (usuario != null)
+ {
+ id = usuario.get_Id() > (long)0;
+ }
+ else
+ {
+ id = false;
+ }
+ }
+ this.EnableIncluirNovo = id;
+ this._selectedLancamento = value;
+ if (value == null || value.get_Id() <= (long)0)
+ {
+ flag = false;
+ }
+ else
+ {
+ Usuario usuario1 = Recursos.Usuario;
+ if (usuario1 != null)
+ {
+ flag = usuario1.get_Id() > (long)0;
+ }
+ else
+ {
+ flag = false;
+ }
+ }
+ base.EnableButtons = flag;
+ Usuario usuario2 = Recursos.Usuario;
+ if (usuario2 != null)
+ {
+ id1 = usuario2.get_Id() > (long)0;
+ }
+ else
+ {
+ id1 = false;
+ }
+ this.EnableChanges = id1;
+ this.Alteracao = (value == null ? false : value.get_Controle().get_Id() > (long)0);
+ base.OnPropertyChanged("SelectedLancamento");
+ this.Feed(value);
+ if (value == null || value.get_Id() == 0)
+ {
+ return;
+ }
+ this.LancamentoSelecionado = value;
+ }
+ }
+
+ public Saldo SelectedSaldo
+ {
+ get
+ {
+ return this._selectedSaldo;
+ }
+ set
+ {
+ this._selectedSaldo = value;
+ base.OnPropertyChanged("SelectedSaldo");
+ }
+ }
+
+ public StatusLancamento SelectedStatus
+ {
+ get
+ {
+ return this._selectedStatus;
+ }
+ set
+ {
+ this._selectedStatus = value;
+ this.LimparLancamentos();
+ base.OnPropertyChanged("SelectedStatus");
+ }
+ }
+
+ public StatusLancamento SelectedStatusImportacao
+ {
+ get
+ {
+ return this._selectedStatusImportacao;
+ }
+ set
+ {
+ this._selectedStatusImportacao = value;
+ base.OnPropertyChanged("SelectedStatusImportacao");
+ }
+ }
+
+ public bool SemValor
+ {
+ get
+ {
+ return this._semValor;
+ }
+ set
+ {
+ this._semValor = value;
+ if (value)
+ {
+ this.ValorInicial = null;
+ this.ValorFinal = null;
+ }
+ base.OnPropertyChanged("SemValor");
+ }
+ }
+
+ public Gestor.Model.Common.Sinal Sinal
+ {
+ get
+ {
+ return this._sinal;
+ }
+ set
+ {
+ this._sinal = value;
+ base.OnPropertyChanged("Sinal");
+ }
+ }
+
+ public SinteticoFinanceiroTipo SinteticoTipo
+ {
+ get
+ {
+ return this._sinteticoTipo;
+ }
+ set
+ {
+ this._sinteticoTipo = value;
+ base.OnPropertyChanged("SinteticoTipo");
+ }
+ }
+
+ public Type TipoDateTime
+ {
+ get
+ {
+ return this._tipoDateTime;
+ }
+ set
+ {
+ this._tipoDateTime = value;
+ base.OnPropertyChanged("TipoDateTime");
+ }
+ }
+
+ public Type TipoDecimal
+ {
+ get
+ {
+ return this._tipoDecimal;
+ }
+ set
+ {
+ this._tipoDecimal = value;
+ base.OnPropertyChanged("TipoDecimal");
+ }
+ }
+
+ public Type TipoEnum
+ {
+ get
+ {
+ return this._tipoEnum;
+ }
+ set
+ {
+ this._tipoEnum = value;
+ base.OnPropertyChanged("TipoEnum");
+ }
+ }
+
+ public Type TipoInt
+ {
+ get
+ {
+ return this._tipoInt;
+ }
+ set
+ {
+ this._tipoInt = value;
+ base.OnPropertyChanged("TipoInt");
+ }
+ }
+
+ public Type TipoLong
+ {
+ get
+ {
+ return this._tipoLong;
+ }
+ set
+ {
+ this._tipoLong = value;
+ base.OnPropertyChanged("TipoLong");
+ }
+ }
+
+ public Gestor.Model.Common.TipoPagamento TipoPagamento
+ {
+ get
+ {
+ return this._tipoPagamento;
+ }
+ set
+ {
+ this._tipoPagamento = value;
+ base.OnPropertyChanged("TipoPagamento");
+ }
+ }
+
+ public Type TipoString
+ {
+ get
+ {
+ return this._tipoString;
+ }
+ set
+ {
+ this._tipoString = value;
+ base.OnPropertyChanged("TipoString");
+ }
+ }
+
+ public ObservableCollection<Gestor.Model.Domain.Financeiro.SinteticoFinanceiro> Totalizacao
+ {
+ get
+ {
+ return this._totalizacao;
+ }
+ set
+ {
+ this._totalizacao = value;
+ base.OnPropertyChanged("Totalizacao");
+ }
+ }
+
+ public Func<List<KeyValuePair<string, string>>> ValidationEvent
+ {
+ get
+ {
+ return new Func<List<KeyValuePair<string, string>>>(this.ValidateIncluir);
+ }
+ }
+
+ public decimal Valor
+ {
+ get
+ {
+ return this._valor;
+ }
+ set
+ {
+ this._valor = value;
+ if (this.Vencimento <= Funcoes.GetNetworkTime().Date)
+ {
+ this.ValorPago = new decimal?(value);
+ }
+ base.OnPropertyChanged("Valor");
+ }
+ }
+
+ public string ValorFinal
+ {
+ get
+ {
+ return this._valorFinal;
+ }
+ set
+ {
+ this._valorFinal = value;
+ base.OnPropertyChanged("ValorFinal");
+ }
+ }
+
+ public string ValorInicial
+ {
+ get
+ {
+ return this._valorIncial;
+ }
+ set
+ {
+ this._valorIncial = value;
+ base.OnPropertyChanged("ValorInicial");
+ }
+ }
+
+ public decimal? ValorPago
+ {
+ get
+ {
+ return this._valorPago;
+ }
+ set
+ {
+ this._valorPago = value;
+ base.OnPropertyChanged("ValorPago");
+ }
+ }
+
+ public DateTime Vencimento
+ {
+ get
+ {
+ return this._vencimento;
+ }
+ set
+ {
+ if (this.Alterando == Visibility.Visible && value != this.VencimentoAnt)
+ {
+ this.VencimentoAlterado = true;
+ }
+ this.VencimentoAnt = value;
+ this._vencimento = value;
+ base.OnPropertyChanged("Vencimento");
+ }
+ }
+
+ public DateTime VencimentoAnt
+ {
+ get;
+ set;
+ }
+
+ public Visibility VisibilityCentro
+ {
+ get
+ {
+ return this._visibilityCentro;
+ }
+ set
+ {
+ this._visibilityCentro = value;
+ base.OnPropertyChanged("VisibilityCentro");
+ }
+ }
+
+ public Visibility VisibilityConta
+ {
+ get
+ {
+ return this._visibilityConta;
+ }
+ set
+ {
+ this._visibilityConta = value;
+ base.OnPropertyChanged("VisibilityConta");
+ }
+ }
+
+ public Visibility VisibilityFornecedor
+ {
+ get
+ {
+ return this._visibilityFornecedor;
+ }
+ set
+ {
+ this._visibilityFornecedor = value;
+ base.OnPropertyChanged("VisibilityFornecedor");
+ }
+ }
+
+ public Visibility VisibilitySemValor
+ {
+ get
+ {
+ return this._visibilitySemValor;
+ }
+ set
+ {
+ this._visibilitySemValor = value;
+ base.OnPropertyChanged("VisibilitySemValor");
+ }
+ }
+
+ public Visibility VisibleFiltros
+ {
+ get
+ {
+ return this._visibleFiltros;
+ }
+ set
+ {
+ this._visibleFiltros = value;
+ base.OnPropertyChanged("VisibleFiltros");
+ }
+ }
+
+ public Visibility VisibleOlho
+ {
+ get
+ {
+ return this._visibleOlho;
+ }
+ set
+ {
+ this._visibleOlho = value;
+ base.OnPropertyChanged("VisibleOlho");
+ }
+ }
+
+ public FinanceiroViewModel()
+ {
+ this._servico = new FinanceiroServico();
+ this.RelatorioFiltroPersonalizado = Funcoes.PopularFiltroFinanceiro();
+ this.BuscaInicial();
+ }
+
+ public async void AdcionarFiltroPersonalizado()
+ {
+ string str;
+ DateTime dateTime;
+ decimal num;
+ int num1;
+ long num2;
+ List<Gestor.Model.Domain.Relatorios.FiltroPersonalizado> filtroPersonalizados;
+ List<Gestor.Model.Domain.Relatorios.FiltroPersonalizado> filtroPersonalizados1;
+ if (this.Filtro != null)
+ {
+ if (this.SemValor)
+ {
+ filtroPersonalizados = (this.PersonalizadoSelecionado == null ? new List<Gestor.Model.Domain.Relatorios.FiltroPersonalizado>() : (
+ from x in this.PersonalizadoSelecionado
+ where x.get_Propriedade() == this.Filtro.get_Propriedade()
+ select x).ToList<Gestor.Model.Domain.Relatorios.FiltroPersonalizado>());
+ List<Gestor.Model.Domain.Relatorios.FiltroPersonalizado> filtroPersonalizados2 = filtroPersonalizados;
+ if (filtroPersonalizados2.Count > 0)
+ {
+ filtroPersonalizados2.ForEach((Gestor.Model.Domain.Relatorios.FiltroPersonalizado x) => this.PersonalizadoSelecionado.Remove(x));
+ }
+ str = string.Concat(this.Filtro.get_Nome(), ": EM BRANCO");
+ }
+ else
+ {
+ filtroPersonalizados1 = (this.PersonalizadoSelecionado == null ? new List<Gestor.Model.Domain.Relatorios.FiltroPersonalizado>() : this.PersonalizadoSelecionado.Where<Gestor.Model.Domain.Relatorios.FiltroPersonalizado>((Gestor.Model.Domain.Relatorios.FiltroPersonalizado x) => {
+ if (x.get_Propriedade() != this.Filtro.get_Propriedade())
+ {
+ return false;
+ }
+ return x.get_SemValor();
+ }).ToList<Gestor.Model.Domain.Relatorios.FiltroPersonalizado>());
+ List<Gestor.Model.Domain.Relatorios.FiltroPersonalizado> filtroPersonalizados3 = filtroPersonalizados1;
+ if (filtroPersonalizados3.Count > 0)
+ {
+ filtroPersonalizados3.ForEach((Gestor.Model.Domain.Relatorios.FiltroPersonalizado x) => this.PersonalizadoSelecionado.Remove(x));
+ }
+ string name = this.Filtro.get_Tipo().Name;
+ if (name == "DateTime")
+ {
+ if (!DateTime.TryParse(this.ValorInicial, out dateTime) || !DateTime.TryParse(this.ValorFinal, out dateTime) || DateTime.Parse(this.ValorInicial) > DateTime.Parse(this.ValorFinal))
+ {
+ await base.ShowMessage("O VALOR DE INTERVALO DEVE SER PREENCHIDO CORRETAMENTE.", "OK", "", false);
+ return;
+ }
+ else
+ {
+ str = string.Format("{0}: {1:d} até {2:d}", this.Filtro.get_Nome(), DateTime.Parse(this.ValorInicial), DateTime.Parse(this.ValorFinal));
+ }
+ }
+ else if (name == "Decimal")
+ {
+ if (!decimal.TryParse(this.ValorInicial, out num) || !decimal.TryParse(this.ValorFinal, out num) || Math.Abs(decimal.Parse(this.ValorInicial)) > Math.Abs(decimal.Parse(this.ValorFinal)))
+ {
+ await base.ShowMessage("O VALOR DE INTERVALO DEVE SER PREENCHIDO CORRETAMENTE.", "OK", "", false);
+ return;
+ }
+ else
+ {
+ str = string.Format("{0}: {1:n2} até {2:n2}", this.Filtro.get_Nome(), decimal.Parse(this.ValorInicial), decimal.Parse(this.ValorFinal));
+ }
+ }
+ else if (name == "Int32")
+ {
+ if (!int.TryParse(this.ValorInicial, out num1) || !int.TryParse(this.ValorFinal, out num1) || int.Parse(this.ValorInicial) > int.Parse(this.ValorFinal))
+ {
+ await base.ShowMessage("O VALOR DE INTERVALO DEVE SER PREENCHIDO CORRETAMENTE.", "OK", "", false);
+ return;
+ }
+ else
+ {
+ str = string.Format("{0}: {1:n0} até {2:n0}", this.Filtro.get_Nome(), int.Parse(this.ValorInicial), int.Parse(this.ValorFinal));
+ }
+ }
+ else if (name != "Int64")
+ {
+ if (!string.IsNullOrEmpty(this.ValorInicial))
+ {
+ str = string.Concat(this.Filtro.get_Nome(), " = ", this.ValorInicial);
+ }
+ else
+ {
+ await base.ShowMessage("O VALOR DEVE SER PREENCHIDO CORRETAMENTE.", "OK", "", false);
+ return;
+ }
+ }
+ else if (!long.TryParse(this.ValorInicial, out num2) || !long.TryParse(this.ValorFinal, out num2) || long.Parse(this.ValorInicial) > (long)int.Parse(this.ValorFinal))
+ {
+ await base.ShowMessage("O VALOR DE INTERVALO DEVE SER PREENCHIDO CORRETAMENTE.", "OK", "", false);
+ return;
+ }
+ else
+ {
+ str = string.Format("{0}: {1:n0} até {2:n0}", this.Filtro.get_Nome(), long.Parse(this.ValorInicial), long.Parse(this.ValorFinal));
+ }
+ }
+ if (this.PersonalizadoSelecionado == null)
+ {
+ this.PersonalizadoSelecionado = new ObservableCollection<Gestor.Model.Domain.Relatorios.FiltroPersonalizado>();
+ }
+ ObservableCollection<Gestor.Model.Domain.Relatorios.FiltroPersonalizado> personalizadoSelecionado = this.PersonalizadoSelecionado;
+ Gestor.Model.Domain.Relatorios.FiltroPersonalizado filtroPersonalizado = new Gestor.Model.Domain.Relatorios.FiltroPersonalizado();
+ filtroPersonalizado.set_Nome(this.Filtro.get_Nome());
+ filtroPersonalizado.set_Propriedade(this.Filtro.get_Propriedade());
+ filtroPersonalizado.set_Tipo(this.Filtro.get_Tipo());
+ filtroPersonalizado.set_ValorIncial(this.ValorInicial);
+ filtroPersonalizado.set_ValorFinal(this.ValorFinal);
+ filtroPersonalizado.set_SemValor(this.SemValor);
+ filtroPersonalizado.set_Descricao(str);
+ personalizadoSelecionado.Add(filtroPersonalizado);
+ this.Filtro = null;
+ this.ValorInicial = string.Empty;
+ this.ValorFinal = string.Empty;
+ this.PesquisaPersonalizada();
+ }
+ }
+
+ public void AdicionarFiltro(Gestor.Model.Domain.Financeiro.FiltroPersonalizado filtro)
+ {
+ if (filtro == null)
+ {
+ return;
+ }
+ if (this.FiltroPersonalizadoSelecionado == null)
+ {
+ this.FiltroPersonalizadoSelecionado = new ObservableCollection<Gestor.Model.Domain.Financeiro.FiltroPersonalizado>();
+ }
+ this.VisibleFiltros = Visibility.Visible;
+ if (this.FiltroPersonalizadoSelecionado.Any<Gestor.Model.Domain.Financeiro.FiltroPersonalizado>((Gestor.Model.Domain.Financeiro.FiltroPersonalizado x) => {
+ if (x.get_Id() != filtro.get_Id())
+ {
+ return false;
+ }
+ return x.get_Tipo() == filtro.get_Tipo();
+ }))
+ {
+ return;
+ }
+ this.FiltroPersonalizadoSelecionado.Add(filtro);
+ this.FiltrarPersonalizado();
+ }
+
+ public void AdicionarFiltros()
+ {
+ ExtensionMethods.ForEach<Gestor.Model.Domain.Financeiro.Planos>(
+ from x in this.PlanosFiltro
+ where x.get_Selecionado()
+ select x, (Gestor.Model.Domain.Financeiro.Planos x) => {
+ Gestor.Model.Domain.Financeiro.FiltroPersonalizado filtroPersonalizado = new Gestor.Model.Domain.Financeiro.FiltroPersonalizado();
+ filtroPersonalizado.set_Id(x.get_Id());
+ filtroPersonalizado.set_Tipo(1);
+ filtroPersonalizado.set_Descricao(x.get_Descricao());
+ this.AdicionarFiltro(filtroPersonalizado);
+ });
+ this.PlanosFiltro = new List<Gestor.Model.Domain.Financeiro.Planos>(
+ from x in this.Planos
+ orderby x.get_Descricao()
+ select x);
+ ExtensionMethods.ForEach<BancosContas>(
+ from x in this.ContaFiltro
+ where x.get_Selecionado()
+ select x, (BancosContas x) => {
+ Gestor.Model.Domain.Financeiro.FiltroPersonalizado filtroPersonalizado = new Gestor.Model.Domain.Financeiro.FiltroPersonalizado();
+ filtroPersonalizado.set_Id(x.get_Id());
+ filtroPersonalizado.set_Tipo(3);
+ filtroPersonalizado.set_Descricao(x.get_Descricao());
+ this.AdicionarFiltro(filtroPersonalizado);
+ });
+ this.ContaFiltro = new List<BancosContas>(
+ from x in this.Contas
+ orderby x.get_Descricao()
+ select x);
+ ExtensionMethods.ForEach<Gestor.Model.Domain.Financeiro.Centro>(
+ from x in this.CentroFiltro
+ where x.get_Selecionado()
+ select x, (Gestor.Model.Domain.Financeiro.Centro x) => {
+ Gestor.Model.Domain.Financeiro.FiltroPersonalizado filtroPersonalizado = new Gestor.Model.Domain.Financeiro.FiltroPersonalizado();
+ filtroPersonalizado.set_Id(x.get_Id());
+ filtroPersonalizado.set_Tipo(2);
+ filtroPersonalizado.set_Descricao(x.get_Descricao());
+ this.AdicionarFiltro(filtroPersonalizado);
+ x.set_Selecionado(false);
+ });
+ this.CentroFiltro = new List<Gestor.Model.Domain.Financeiro.Centro>(
+ from x in this.Centros
+ orderby x.get_Descricao()
+ select x);
+ }
+
+ private async Task AdicionarParcelaRange()
+ {
+ base.Loading(true);
+ List<Lancamento> lancamentos = new List<Lancamento>();
+ ObservableCollection<Lancamento> lancamentosFiltrados = this.LancamentosFiltrados;
+ IEnumerable<Lancamento> selecionado =
+ from x in lancamentosFiltrados
+ where x.get_Selecionado()
+ select x;
+ List<Lancamento> list = selecionado.Select<Lancamento, Lancamento>((Lancamento x) => {
+ Lancamento lancamento = new Lancamento();
+ ControleFinanceiro controleFinanceiro = new ControleFinanceiro();
+ controleFinanceiro.set_Centro(x.get_Controle().get_Centro());
+ controleFinanceiro.set_Fornecedor(x.get_Controle().get_Fornecedor());
+ controleFinanceiro.set_Historico(x.get_Controle().get_Historico());
+ controleFinanceiro.set_Id(x.get_Controle().get_Id());
+ controleFinanceiro.set_Parcelas(x.get_Controle().get_Parcelas() + 1);
+ controleFinanceiro.set_Plano(x.get_Controle().get_Plano());
+ lancamento.set_Controle(controleFinanceiro);
+ lancamento.set_Historico(x.get_Historico());
+ lancamento.set_Observacao(x.get_Observacao());
+ lancamento.set_Vencimento(x.get_Vencimento().AddMonths(1));
+ lancamento.set_Conta(x.get_Conta());
+ lancamento.set_Parcela(x.get_Parcela() + 1);
+ lancamento.set_Documento(x.get_Documento());
+ lancamento.set_Sinal(x.get_Sinal());
+ lancamento.set_TipoPagamento(x.get_TipoPagamento());
+ lancamento.set_Valor(x.get_Valor());
+ return lancamento;
+ }).ToList<Lancamento>();
+ foreach (Lancamento lancamento1 in list)
+ {
+ if (await this._servico.BuscarLancamento(lancamento1.get_Controle().get_Id(), lancamento1.get_Parcela()) != null)
+ {
+ continue;
+ }
+ lancamentos.Add(lancamento1);
+ }
+ await this._servico.IncluirRange(lancamentos);
+ if (this._servico.Sucesso)
+ {
+ await this.Buscar();
+ base.ToggleSnackBar("INCLUSÃO DE PARCELA REALIZADA COM SUCESSO", true);
+ base.Loading(false);
+ }
+ else
+ {
+ base.Loading(false);
+ }
+ lancamentos = null;
+ }
+
+ public async Task AlterarLancamentos(Lancamento lancamentoAtual, bool alterarVencimento, bool alterarValores)
+ {
+ Func<Lancamento, bool> func = null;
+ List<Lancamento> lancamentos = await this._servico.BuscarLancamentosPorControle(lancamentoAtual.get_Controle().get_Id());
+ int num = 1;
+ List<Lancamento> lancamentos1 = lancamentos;
+ Func<Lancamento, bool> func1 = func;
+ if (func1 == null)
+ {
+ Func<Lancamento, bool> parcela = (Lancamento l) => l.get_Parcela() > lancamentoAtual.get_Parcela();
+ Func<Lancamento, bool> func2 = parcela;
+ func = parcela;
+ func1 = func2;
+ }
+ foreach (Lancamento lancamento in lancamentos1.Where<Lancamento>(func1))
+ {
+ if (!lancamento.get_Baixado())
+ {
+ if (alterarVencimento)
+ {
+ lancamento.set_Vencimento(lancamentoAtual.get_Vencimento().AddMonths(num));
+ }
+ if (alterarValores)
+ {
+ lancamento.set_Valor(lancamentoAtual.get_Valor());
+ }
+ await this._servico.Save(lancamento);
+ }
+ num++;
+ }
+ this.SelectedLancamento = lancamentoAtual;
+ }
+
+ public async Task Atualizar(List<Lancamento> list)
+ {
+ DateTime? baixa;
+ DateTime? nullable;
+ string str;
+ bool flag;
+ base.Loading(true);
+ List<Lancamento> lancamentos = new List<Lancamento>();
+ List<Lancamento> lancamentos1 = new List<Lancamento>();
+ List<Lancamento> lancamentos2 = new List<Lancamento>();
+ foreach (Lancamento lancamento in list)
+ {
+ if (lancamento.get_Baixado())
+ {
+ continue;
+ }
+ if (!lancamento.get_Selecionado())
+ {
+ baixa = null;
+ lancamento.set_Baixa(baixa);
+ }
+ baixa = lancamento.get_Baixa();
+ if (baixa.HasValue)
+ {
+ Saldo saldo = await this.VerificaSaldo(lancamento.get_Conta().get_Id(), false);
+ if (saldo == null)
+ {
+ continue;
+ }
+ baixa = saldo.get_DataInicio();
+ nullable = lancamento.get_Baixa();
+ flag = (baixa.HasValue & nullable.HasValue ? baixa.GetValueOrDefault() > nullable.GetValueOrDefault() : false);
+ if (flag)
+ {
+ continue;
+ }
+ }
+ if (lancamento.get_Selecionado())
+ {
+ str = (lancamento.get_Observacao() == null ? "" : string.Concat("\n ", lancamento.get_Observacao()));
+ string str1 = str;
+ Lancamento lancamento1 = lancamento;
+ object[] id = new object[] { Recursos.Usuario.get_Id(), Recursos.Usuario.get_Nome(), null, null };
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ id[2] = networkTime.ToString("F").ToUpper();
+ id[3] = str1;
+ lancamento1.set_Observacao(string.Format("BAIXA AGRUPADA REALIZADA PELO USUARIO {0} {1} EM {2}{3}", id));
+ }
+ List<KeyValuePair<string, string>> keyValuePairs = lancamento.Validate();
+ if (keyValuePairs != null && keyValuePairs.Count > 0)
+ {
+ continue;
+ }
+ nullable = lancamento.get_Baixa();
+ if (!nullable.HasValue)
+ {
+ lancamentos.Add(lancamento);
+ }
+ else
+ {
+ lancamentos1.Add(lancamento);
+ }
+ lancamentos2.Add(lancamento);
+ }
+ if (lancamentos2.Count != 0)
+ {
+ object[] count = new object[] { lancamentos.Count, Environment.NewLine, lancamentos1.Count, Environment.NewLine, Environment.NewLine };
+ if (await base.ShowMessage(string.Format("{0} LANÇAMENTOS SERÃO ATUALIZADOS.{1}{2} LANÇAMENTOS SERÃO BAIXADOS.{3}{4}DESEJA REALMENTE PROSSEGUIR?", count), "SIM", "NÃO", false))
+ {
+ await this._servico.Atualizar(lancamentos2);
+ if (this._servico.Sucesso)
+ {
+ if (await base.ShowMessage("DESEJA GERAR O RELATÓRIO NOVAMENTE?", "SIM,", "NÃO", false))
+ {
+ await this.Buscar();
+ }
+ base.ToggleSnackBar("ATUALIZAÇÃO REALIZADA COM SUCESSO", true);
+ await this.CarregarSaldos();
+ base.Loading(false);
+ }
+ else
+ {
+ base.Loading(false);
+ }
+ }
+ else
+ {
+ base.Loading(false);
+ }
+ }
+ else
+ {
+ await base.ShowMessage("NÃO HÁ LANÇAMENTOS PARA SEREM ATUALIZADOS.", "OK", "", false);
+ base.Loading(false);
+ }
+ lancamentos = null;
+ lancamentos1 = null;
+ lancamentos2 = null;
+ }
+
+ public void Bind()
+ {
+ //
+ // Current member / type: System.Void Gestor.Application.ViewModels.Financeiro.FinanceiroViewModel::Bind()
+ // File path: C:\AggerSeguros\Gestor.Application.exe
+ //
+ // Product version: 0.0.0.0
+ // Exception in: System.Void Bind()
+ //
+ // Object reference not set to an instance of an object.
+ // at Telerik.JustDecompiler.Decompiler.TypeInference.TypeInferer.FindLowestCommonAncestor(ICollection`1 typeNodes) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\TypeInference\TypeInferer.cs:line 515
+ // at Telerik.JustDecompiler.Decompiler.TypeInference.TypeInferer.MergeWithLowestCommonAncestor() in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\TypeInference\TypeInferer.cs:line 459
+ // at Telerik.JustDecompiler.Decompiler.TypeInference.TypeInferer.ProcessSingleConstraints() in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\TypeInference\TypeInferer.cs:line 378
+ // at Telerik.JustDecompiler.Decompiler.TypeInference.TypeInferer.InferTypes() in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\TypeInference\TypeInferer.cs:line 331
+ // at Telerik.JustDecompiler.Decompiler.ExpressionDecompilerStep.Process(DecompilationContext theContext, BlockStatement body) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\ExpressionDecompilerStep.cs:line 104
+ // at Telerik.JustDecompiler.Decompiler.DecompilationPipeline.RunInternal(MethodBody body, BlockStatement block, ILanguage language) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\DecompilationPipeline.cs:line 100
+ // at Telerik.JustDecompiler.Decompiler.DecompilationPipeline.Run(MethodBody body, ILanguage language) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\DecompilationPipeline.cs:line 72
+ // at Telerik.JustDecompiler.Decompiler.Extensions.Decompile(MethodBody body, ILanguage language, DecompilationContext& context, TypeSpecificContext typeContext) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\Extensions.cs:line 61
+ // at Telerik.JustDecompiler.Decompiler.WriterContextServices.BaseWriterContextService.DecompileMethod(ILanguage language, MethodDefinition method, TypeSpecificContext typeContext) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\WriterContextServices\BaseWriterContextService.cs:line 133
+ //
+ // mailto: JustDecompilePublicFeedback@telerik.com
+
+ }
+
+ public void BindImportando()
+ {
+ //
+ // Current member / type: System.Void Gestor.Application.ViewModels.Financeiro.FinanceiroViewModel::BindImportando()
+ // File path: C:\AggerSeguros\Gestor.Application.exe
+ //
+ // Product version: 0.0.0.0
+ // Exception in: System.Void BindImportando()
+ //
+ // Object reference not set to an instance of an object.
+ // at Telerik.JustDecompiler.Decompiler.TypeInference.TypeInferer.FindLowestCommonAncestor(ICollection`1 typeNodes) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\TypeInference\TypeInferer.cs:line 515
+ // at Telerik.JustDecompiler.Decompiler.TypeInference.TypeInferer.MergeWithLowestCommonAncestor() in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\TypeInference\TypeInferer.cs:line 459
+ // at Telerik.JustDecompiler.Decompiler.TypeInference.TypeInferer.ProcessSingleConstraints() in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\TypeInference\TypeInferer.cs:line 378
+ // at Telerik.JustDecompiler.Decompiler.TypeInference.TypeInferer.InferTypes() in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\TypeInference\TypeInferer.cs:line 331
+ // at Telerik.JustDecompiler.Decompiler.ExpressionDecompilerStep.Process(DecompilationContext theContext, BlockStatement body) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\ExpressionDecompilerStep.cs:line 104
+ // at Telerik.JustDecompiler.Decompiler.DecompilationPipeline.RunInternal(MethodBody body, BlockStatement block, ILanguage language) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\DecompilationPipeline.cs:line 100
+ // at Telerik.JustDecompiler.Decompiler.DecompilationPipeline.Run(MethodBody body, ILanguage language) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\DecompilationPipeline.cs:line 72
+ // at Telerik.JustDecompiler.Decompiler.Extensions.Decompile(MethodBody body, ILanguage language, DecompilationContext& context, TypeSpecificContext typeContext) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\Extensions.cs:line 61
+ // at Telerik.JustDecompiler.Decompiler.WriterContextServices.BaseWriterContextService.DecompileMethod(ILanguage language, MethodDefinition method, TypeSpecificContext typeContext) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\WriterContextServices\BaseWriterContextService.cs:line 133
+ //
+ // mailto: JustDecompilePublicFeedback@telerik.com
+
+ }
+
+ private async void BuscaInicial()
+ {
+ base.Loading(true);
+ this.Planos = await (new PlanoServico()).BuscarPlanos();
+ FinanceiroViewModel observableCollection = this;
+ List<Gestor.Model.Domain.Financeiro.Planos> planos = this.Planos;
+ IEnumerable<Gestor.Model.Domain.Financeiro.Planos> ativo =
+ from x in planos
+ where x.get_Ativo()
+ select x;
+ observableCollection.PlanosFiltrados = new ObservableCollection<Gestor.Model.Domain.Financeiro.Planos>(
+ from x in ativo
+ orderby x.get_Descricao()
+ select x);
+ this.Contas = await (new BancosContasServico()).BuscarBancos();
+ FinanceiroViewModel financeiroViewModel = this;
+ List<BancosContas> contas = this.Contas;
+ IEnumerable<BancosContas> bancosContas =
+ from x in contas
+ where x.get_Ativo()
+ select x;
+ financeiroViewModel.ContasFiltradas = new ObservableCollection<BancosContas>(
+ from x in bancosContas
+ orderby x.get_Descricao()
+ select x);
+ this.Centros = await (new CentroServico()).BuscarCentros();
+ FinanceiroViewModel observableCollection1 = this;
+ List<Gestor.Model.Domain.Financeiro.Centro> centros = this.Centros;
+ IEnumerable<Gestor.Model.Domain.Financeiro.Centro> ativo1 =
+ from x in centros
+ where x.get_Ativo()
+ select x;
+ observableCollection1.CentrosFiltrados = new ObservableCollection<Gestor.Model.Domain.Financeiro.Centro>(
+ from x in ativo1
+ orderby x.get_Descricao()
+ select x);
+ FinanceiroViewModel planos1 = this;
+ List<Gestor.Model.Domain.Financeiro.Planos> planos2 = this.Planos;
+ planos1.PlanosFiltro = new List<Gestor.Model.Domain.Financeiro.Planos>(
+ from x in planos2
+ orderby x.get_Descricao()
+ select x);
+ FinanceiroViewModel bancosContas1 = this;
+ List<BancosContas> contas1 = this.Contas;
+ bancosContas1.ContaFiltro = new List<BancosContas>(
+ from x in contas1
+ orderby x.get_Descricao()
+ select x);
+ FinanceiroViewModel centros1 = this;
+ List<Gestor.Model.Domain.Financeiro.Centro> centros2 = this.Centros;
+ centros1.CentroFiltro = new List<Gestor.Model.Domain.Financeiro.Centro>(
+ from x in centros2
+ orderby x.get_Descricao()
+ select x);
+ this.PopularFiltro();
+ await this.Buscar();
+ base.Loading(false);
+ }
+
+ public async Task Buscar()
+ {
+ List<Lancamento> list;
+ bool flag;
+ List<long> nums;
+ List<long> list1;
+ List<long> nums1;
+ List<long> list2;
+ List<long> nums2;
+ this.Importando = false;
+ DateTime? inicio = this.Inicio;
+ if (inicio.HasValue)
+ {
+ inicio = this.Fim;
+ if (inicio.HasValue)
+ {
+ inicio = this.Inicio;
+ DateTime? fim = this.Fim;
+ flag = (inicio.HasValue & fim.HasValue ? inicio.GetValueOrDefault() > fim.GetValueOrDefault() : false);
+ if (!flag)
+ {
+ this.PersonalizadoSelecionado = null;
+ switch (this.SelectedFiltro)
+ {
+ case 1:
+ {
+ FinanceiroServico financeiroServico = this._servico;
+ fim = this.Inicio;
+ DateTime value = fim.Value;
+ fim = this.Fim;
+ list = await financeiroServico.BuscarLancamentosPorBaixa(value, fim.Value);
+ break;
+ }
+ case 2:
+ {
+ FinanceiroServico financeiroServico1 = this._servico;
+ fim = this.Inicio;
+ DateTime dateTime = fim.Value;
+ fim = this.Fim;
+ list = await financeiroServico1.BuscarLancamentosPorPagamento(dateTime, fim.Value);
+ break;
+ }
+ case 3:
+ {
+ if (this.SelectedFornecedor != null)
+ {
+ list = await this._servico.BuscarLancamentosPorFornecedor(this.SelectedFornecedor.get_Id(), this.SelectedStatus);
+ break;
+ }
+ else
+ {
+ return;
+ }
+ }
+ case 4:
+ {
+ FinanceiroServico financeiroServico2 = this._servico;
+ fim = this.Inicio;
+ DateTime value1 = fim.Value;
+ fim = this.Fim;
+ list = await financeiroServico2.BuscarLancamentosPorLancamento(value1, fim.Value, this.SelectedStatus);
+ break;
+ }
+ case 5:
+ {
+ FinanceiroServico financeiroServico3 = this._servico;
+ fim = this.Inicio;
+ DateTime dateTime1 = fim.Value;
+ fim = this.Fim;
+ List<Lancamento> lancamentos = await financeiroServico3.BuscarLancamentosPersonalizados(dateTime1, fim.Value, this.SelectedStatus, this.SelectedFiltroData);
+ if (this.FiltroPersonalizadoSelecionado != null)
+ {
+ ObservableCollection<Gestor.Model.Domain.Financeiro.FiltroPersonalizado> filtroPersonalizadoSelecionado = this.FiltroPersonalizadoSelecionado;
+ IEnumerable<Gestor.Model.Domain.Financeiro.FiltroPersonalizado> tipo =
+ from x in filtroPersonalizadoSelecionado
+ where x.get_Tipo() == 0
+ select x;
+ nums = (
+ from x in tipo
+ select x.get_Id()).ToList<long>();
+ }
+ else
+ {
+ nums = new List<long>();
+ }
+ List<long> nums3 = nums;
+ if (this.FiltroPersonalizadoSelecionado != null)
+ {
+ ObservableCollection<Gestor.Model.Domain.Financeiro.FiltroPersonalizado> observableCollection = this.FiltroPersonalizadoSelecionado;
+ IEnumerable<Gestor.Model.Domain.Financeiro.FiltroPersonalizado> filtroPersonalizados =
+ from x in observableCollection
+ where x.get_Tipo() == 2
+ select x;
+ list1 = (
+ from x in filtroPersonalizados
+ select x.get_Id()).ToList<long>();
+ }
+ else
+ {
+ list1 = new List<long>();
+ }
+ List<long> nums4 = list1;
+ if (this.FiltroPersonalizadoSelecionado != null)
+ {
+ ObservableCollection<Gestor.Model.Domain.Financeiro.FiltroPersonalizado> filtroPersonalizadoSelecionado1 = this.FiltroPersonalizadoSelecionado;
+ IEnumerable<Gestor.Model.Domain.Financeiro.FiltroPersonalizado> tipo1 =
+ from x in filtroPersonalizadoSelecionado1
+ where x.get_Tipo() == 1
+ select x;
+ nums1 = (
+ from x in tipo1
+ select x.get_Id()).ToList<long>();
+ }
+ else
+ {
+ nums1 = new List<long>();
+ }
+ List<long> nums5 = nums1;
+ if (this.FiltroPersonalizadoSelecionado != null)
+ {
+ ObservableCollection<Gestor.Model.Domain.Financeiro.FiltroPersonalizado> observableCollection1 = this.FiltroPersonalizadoSelecionado;
+ IEnumerable<Gestor.Model.Domain.Financeiro.FiltroPersonalizado> filtroPersonalizados1 =
+ from x in observableCollection1
+ where x.get_Tipo() == 3
+ select x;
+ list2 = (
+ from x in filtroPersonalizados1
+ select x.get_Id()).ToList<long>();
+ }
+ else
+ {
+ list2 = new List<long>();
+ }
+ List<long> nums6 = list2;
+ if (this.FiltroPersonalizadoSelecionado != null)
+ {
+ ObservableCollection<Gestor.Model.Domain.Financeiro.FiltroPersonalizado> filtroPersonalizadoSelecionado2 = this.FiltroPersonalizadoSelecionado;
+ IEnumerable<Gestor.Model.Domain.Financeiro.FiltroPersonalizado> tipo2 =
+ from x in filtroPersonalizadoSelecionado2
+ where x.get_Tipo() == 4
+ select x;
+ nums2 = (
+ from x in tipo2
+ select x.get_Id()).ToList<long>();
+ }
+ else
+ {
+ nums2 = new List<long>();
+ }
+ List<long> nums7 = nums2;
+ list = lancamentos.Where<Lancamento>((Lancamento x) => {
+ if (nums3.Count != 0 && (x.get_Controle().get_Fornecedor() == null || !nums3.Contains(x.get_Controle().get_Fornecedor().get_Id())) || nums4.Count != 0 && (x.get_Controle().get_Centro() == null || !nums4.Contains(x.get_Controle().get_Centro().get_Id())) || nums5.Count != 0 && (x.get_Controle().get_Plano() == null || !nums5.Contains(x.get_Controle().get_Plano().get_Id())) || nums6.Count != 0 && (x.get_Conta() == null || !nums6.Contains(x.get_Conta().get_Id())))
+ {
+ return false;
+ }
+ if (nums7.Count == 0)
+ {
+ return true;
+ }
+ return nums7.Contains((long)x.get_Sinal());
+ }).ToList<Lancamento>();
+ break;
+ }
+ default:
+ {
+ FinanceiroServico financeiroServico4 = this._servico;
+ fim = this.Inicio;
+ DateTime value2 = fim.Value;
+ fim = this.Fim;
+ list = await financeiroServico4.BuscarLancamentos(value2, fim.Value, this.SelectedStatus);
+ break;
+ }
+ }
+ List<Lancamento> lancamentos1 = list;
+ lancamentos1.ForEach((Lancamento x) => x.Initialize());
+ this.Lancamentos = new ObservableCollection<Lancamento>(list);
+ this.LancamentosFiltrados = this.Lancamentos;
+ this.LancamentosFiltradosCopia = this.LancamentosFiltrados;
+ this.SelectedLancamento = this.LancamentosFiltrados.FirstOrDefault<Lancamento>();
+ await this.CarregarSaldos();
+ return;
+ }
+ else
+ {
+ await base.ShowMessage("A DATA DE INÍCIO NÃO PODE SER SUPERIOR A DATA FINAL.", "OK", "", false);
+ return;
+ }
+ }
+ }
+ await base.ShowMessage("NECESSÁRIO PREENCHER TANTO A DATA DE INÍCIO QUANTO A DATA FINAL PARA REALIZAR A PESQUISA.", "OK", "", false);
+ }
+
+ internal async Task BuscarLancamentosVinculo()
+ {
+ DateTime vencimento;
+ DateTime? dataInicio;
+ DateTime valueOrDefault;
+ if (this.SelectedLancamento.get_Conta() != null)
+ {
+ Saldo saldo = this.Saldos.FirstOrDefault<Saldo>((Saldo x) => x.get_Id() == this.SelectedLancamento.get_Conta().get_Id());
+ if (saldo != null)
+ {
+ dataInicio = saldo.get_DataInicio();
+ }
+ else
+ {
+ dataInicio = null;
+ }
+ }
+ else
+ {
+ vencimento = this.SelectedLancamento.get_Vencimento();
+ dataInicio = new DateTime?(vencimento.AddDays(-5));
+ }
+ DateTime? nullable = dataInicio;
+ if (nullable.HasValue)
+ {
+ valueOrDefault = nullable.GetValueOrDefault();
+ }
+ else
+ {
+ vencimento = this.SelectedLancamento.get_Vencimento();
+ valueOrDefault = vencimento.AddDays(-5);
+ }
+ DateTime dateTime = valueOrDefault;
+ List<Lancamento> list = await this._servico.BuscarLancamentosPorFornecedor(this.FornecedorInclusao.get_Id(), dateTime, this.Sinal);
+ ObservableCollection<Lancamento> lancamentos = this.Lancamentos;
+ List<long> nums = (
+ from x in lancamentos
+ select x.get_Id()).ToList<long>();
+ list = (
+ from x in list
+ where !nums.Contains(x.get_Id())
+ select x).ToList<Lancamento>();
+ this.LancamentosVinculo = new ObservableCollection<Lancamento>(list);
+ }
+
+ public void CancelarAlteracao()
+ {
+ this.LancamentosFiltrados = this.LancamentosFiltradosCopia;
+ this.SelectedLancamento = this.LancamentosFiltrados.FirstOrDefault<Lancamento>((Lancamento x) => {
+ long? nullable;
+ long id = x.get_Id();
+ Lancamento lancamentoSelecionado = this.LancamentoSelecionado;
+ if (lancamentoSelecionado != null)
+ {
+ nullable = new long?(lancamentoSelecionado.get_Id());
+ }
+ else
+ {
+ nullable = null;
+ }
+ long? nullable1 = nullable;
+ return id == nullable1.GetValueOrDefault() & nullable1.HasValue;
+ });
+ }
+
+ public async Task CarregarSaldos()
+ {
+ this.Saldos = new ObservableCollection<Saldo>();
+ BancosContasServico bancosContasServico = new BancosContasServico();
+ foreach (BancosContas contasFiltrada in this.ContasFiltradas)
+ {
+ Saldo saldo = await bancosContasServico.BuscarSaldoAberto(contasFiltrada.get_Id());
+ if (saldo == null)
+ {
+ continue;
+ }
+ DateTime date = Funcoes.GetNetworkTime().Date;
+ saldo.set_DataFinal(new DateTime?(date.AddDays(1)));
+ saldo = await bancosContasServico.FecharSaldo(saldo);
+ this.Saldos.Add(saldo);
+ }
+ this.SelectedSaldo = this.Saldos.FirstOrDefault<Saldo>();
+ bancosContasServico = null;
+ }
+
+ private Tuple<DateTime, DateTime> CorrigeLancamentos(OfxDocument lancamentos, List<string> codigoBanco)
+ {
+ DateTime? nullable;
+ DateTime? nullable1;
+ DateTime? nullable2;
+ if (!this.VerificaFiltroErrado(lancamentos))
+ {
+ if (this.VerificaDataInvertida(lancamentos))
+ {
+ return new Tuple<DateTime, DateTime>(lancamentos.get_StatementEnd(), lancamentos.get_StatementStart());
+ }
+ return new Tuple<DateTime, DateTime>(lancamentos.get_StatementStart(), lancamentos.get_StatementEnd());
+ }
+ Transaction transaction = (
+ from lanc in lancamentos.get_Transactions()
+ orderby lanc.get_Date()
+ select lanc).First<Transaction>();
+ if (transaction != null)
+ {
+ nullable1 = new DateTime?(transaction.get_Date());
+ }
+ else
+ {
+ nullable = null;
+ nullable1 = nullable;
+ }
+ nullable = nullable1;
+ DateTime value = nullable.Value;
+ Transaction transaction1 = (
+ from lanc in lancamentos.get_Transactions()
+ orderby lanc.get_Date() descending
+ select lanc).First<Transaction>();
+ if (transaction1 != null)
+ {
+ nullable2 = new DateTime?(transaction1.get_Date());
+ }
+ else
+ {
+ nullable = null;
+ nullable2 = nullable;
+ }
+ nullable = nullable2;
+ return new Tuple<DateTime, DateTime>(value, nullable.Value);
+ }
+
+ public void DeSelecionarLancamento(Lancamento lancamento)
+ {
+ Lancamento lancamento1 = (lancamento.get_Id() > (long)0 ? this.LancamentosFiltrados.First<Lancamento>((Lancamento x) => x.get_Id() == lancamento.get_Id()) : this.LancamentosFiltrados.First<Lancamento>((Lancamento x) => {
+ long? nullable;
+ long? nullable1;
+ long? nullable2;
+ long? nullable3;
+ long? nullable4;
+ if (x.get_Id() == lancamento.get_Id())
+ {
+ ControleFinanceiro controle = x.get_Controle();
+ if (controle != null)
+ {
+ Fornecedor fornecedor = controle.get_Fornecedor();
+ if (fornecedor != null)
+ {
+ nullable1 = new long?(fornecedor.get_Id());
+ }
+ else
+ {
+ nullable = null;
+ nullable1 = nullable;
+ }
+ }
+ else
+ {
+ nullable = null;
+ nullable1 = nullable;
+ }
+ long? nullable5 = nullable1;
+ ControleFinanceiro controleFinanceiro = lancamento.get_Controle();
+ if (controleFinanceiro != null)
+ {
+ Fornecedor fornecedor1 = controleFinanceiro.get_Fornecedor();
+ if (fornecedor1 != null)
+ {
+ nullable2 = new long?(fornecedor1.get_Id());
+ }
+ else
+ {
+ nullable = null;
+ nullable2 = nullable;
+ }
+ }
+ else
+ {
+ nullable = null;
+ nullable2 = nullable;
+ }
+ long? nullable6 = nullable2;
+ if (nullable5.GetValueOrDefault() == nullable6.GetValueOrDefault() & nullable5.HasValue == nullable6.HasValue && x.get_Valor() == lancamento.get_Valor() && x.get_Vencimento() == lancamento.get_Vencimento())
+ {
+ ControleFinanceiro controle1 = x.get_Controle();
+ if (controle1 != null)
+ {
+ Gestor.Model.Domain.Financeiro.Planos plano = controle1.get_Plano();
+ if (plano != null)
+ {
+ nullable3 = new long?(plano.get_Id());
+ }
+ else
+ {
+ nullable = null;
+ nullable3 = nullable;
+ }
+ }
+ else
+ {
+ nullable = null;
+ nullable3 = nullable;
+ }
+ nullable6 = nullable3;
+ ControleFinanceiro controleFinanceiro1 = lancamento.get_Controle();
+ if (controleFinanceiro1 != null)
+ {
+ Gestor.Model.Domain.Financeiro.Planos plano1 = controleFinanceiro1.get_Plano();
+ if (plano1 != null)
+ {
+ nullable4 = new long?(plano1.get_Id());
+ }
+ else
+ {
+ nullable = null;
+ nullable4 = nullable;
+ }
+ }
+ else
+ {
+ nullable = null;
+ nullable4 = nullable;
+ }
+ nullable5 = nullable4;
+ return nullable6.GetValueOrDefault() == nullable5.GetValueOrDefault() & nullable6.HasValue == nullable5.HasValue;
+ }
+ }
+ return false;
+ }));
+ lancamento1.set_Selecionado(false);
+ if (!lancamento1.get_Baixado())
+ {
+ DateTime? nullable7 = null;
+ lancamento1.set_Baixa(nullable7);
+ nullable7 = null;
+ lancamento1.set_Pagamento(nullable7);
+ lancamento1.set_ValorPago(new decimal?(new decimal()));
+ }
+ this.LancamentosFiltradosCopia = this.LancamentosFiltrados;
+ this.Totalizar();
+ }
+
+ public async Task Excluir()
+ {
+ bool flag;
+ long? nullable;
+ object historico;
+ bool flag1;
+ long num;
+ Lancamento lancamento;
+ if (this.SelectedLancamento != null && this.SelectedLancamento.get_Id() != 0)
+ {
+ base.Loading(true);
+ lancamento = await this._servico.BuscarLancamento(this.SelectedLancamento.get_Id());
+ Saldo saldo = await this.VerificaSaldo(this.SelectedLancamento.get_Conta().get_Id(), true);
+ if (saldo != null)
+ {
+ DateTime? dataInicio = saldo.get_DataInicio();
+ DateTime? baixa = lancamento.get_Baixa();
+ flag = (dataInicio.HasValue & baixa.HasValue ? dataInicio.GetValueOrDefault() > baixa.GetValueOrDefault() : false);
+ if (flag)
+ {
+ await base.ShowMessage("LANÇAMENTO NÃO PODE SER EXCLUÍDO POIS NÃO POSSUI SALDO ABERTO PARA O PERÍODO.", "OK", "", false);
+ base.Loading(false);
+ }
+ else if (!await base.ShowMessage("DESEJA REAMENTE EXCLUIR O LANÇAMENTO SELECIONADO?", "SIM", "NÃO", false))
+ {
+ base.Loading(false);
+ }
+ else if (await this._servico.Excluir(this.SelectedLancamento))
+ {
+ FinanceiroViewModel financeiroViewModel = this;
+ Lancamento selectedLancamento = this.SelectedLancamento;
+ if (selectedLancamento != null)
+ {
+ nullable = new long?(selectedLancamento.get_Id());
+ }
+ else
+ {
+ nullable = null;
+ }
+ object obj = nullable;
+ Lancamento selectedLancamento1 = this.SelectedLancamento;
+ if (selectedLancamento1 != null)
+ {
+ historico = selectedLancamento1.get_Historico();
+ }
+ else
+ {
+ historico = null;
+ }
+ string str = string.Format("EXCLUIU O LANÇAMENTO DO ID {0} HISTORICO: {1}", obj, historico);
+ Lancamento lancamento1 = this.SelectedLancamento;
+ if (lancamento1 != null)
+ {
+ lancamento1.get_Id();
+ flag1 = false;
+ }
+ else
+ {
+ flag1 = true;
+ }
+ num = (flag1 ? (long)0 : this.SelectedLancamento.get_Id());
+ financeiroViewModel.RegistrarAcao(str, num, new TipoTela?(25), null);
+ base.ToggleSnackBar("EXCLUSÃO REALIZADA COM SUCESSO", true);
+ await this.Buscar();
+ base.Loading(false);
+ }
+ else
+ {
+ base.Loading(false);
+ }
+ }
+ }
+ lancamento = null;
+ }
+
+ public async Task ExcluirBaixa()
+ {
+ bool flag;
+ if (this.SelectedLancamento != null && this.SelectedLancamento.get_Id() != 0)
+ {
+ base.Loading(true);
+ DateTime? baixa = await this._servico.BuscarLancamento(this.SelectedLancamento.get_Id()).get_Baixa();
+ if (!baixa.HasValue)
+ {
+ await base.ShowMessage("LANÇAMENTO AINDA NÃO BAIXADO. PROCESSO INTERROMPIDO", "OK", "", false);
+ base.Loading(false);
+ }
+ else if (await base.ShowMessage("DESEJA REAMENTE EXCLUIR A BAIXA DO LANÇAMENTO SELECIONADO?", "SIM", "NÃO", false))
+ {
+ Saldo saldo = await this.VerificaSaldo(this.SelectedLancamento.get_Conta().get_Id(), true);
+ if (saldo != null)
+ {
+ baixa = saldo.get_DataInicio();
+ DateTime? nullable = this.SelectedLancamento.get_Baixa();
+ flag = (baixa.HasValue & nullable.HasValue ? baixa.GetValueOrDefault() > nullable.GetValueOrDefault() : false);
+ if (!flag)
+ {
+ nullable = null;
+ this.SelectedLancamento.set_Baixa(nullable);
+ this.SelectedLancamento.set_ValorPago(new decimal?(new decimal()));
+ nullable = null;
+ this.SelectedLancamento.set_Pagamento(nullable);
+ this.SelectedLancamento.set_Baixado(false);
+ this.SelectedLancamento = await this._servico.Save(this.SelectedLancamento);
+ if (this.importando)
+ {
+ this.BindImportando();
+ this.LancamentosFiltrados = this.Lancamentos;
+ base.Loading(false);
+ }
+ else if (this._servico.Sucesso)
+ {
+ base.ToggleSnackBar("EXCLUSÃO DE BAIXA REALIZADA COM SUCESSO", true);
+ await this.Buscar();
+ base.Loading(false);
+ }
+ }
+ else
+ {
+ await base.ShowMessage("LANÇAMENTO NÃO PODE TER SUA BAIXA EXCLUÍDA POIS NÃO POSSUI SALDO ABERTO PARA O PERÍODO.", "OK", "", false);
+ base.Loading(false);
+ }
+ }
+ }
+ else
+ {
+ base.Loading(false);
+ }
+ }
+ }
+
+ public async Task ExcluirBaixaRange()
+ {
+ bool flag;
+ List<Lancamento> lancamentos;
+ ObservableCollection<Lancamento> lancamentosFiltrados = this.LancamentosFiltrados;
+ List<Lancamento> list = lancamentosFiltrados.Where<Lancamento>((Lancamento x) => {
+ if (x.get_Selecionado() && x.get_Controle().get_Plano() != null)
+ {
+ return true;
+ }
+ if (!x.get_Historico().Equals("TRANSFERÊNCIA ENTRE CONTAS") || !x.get_Selecionado())
+ {
+ return false;
+ }
+ return x.get_Controle().get_Plano() == null;
+ }).ToList<Lancamento>();
+ if (list.Count == 0)
+ {
+ await base.ShowMessage("NÃO HÁ LANÇAMENTOS SELECIONADOS, SELECIONE-OS ANTES DE EXCLUIR A BAIXA.", "OK", "", false);
+ }
+ else if (await base.ShowMessage("DESEJA REAMENTE EXCLUIR A BAIXA DOS LANÇAMENTOS SELECIONADOS?", "SIM", "NÃO", false))
+ {
+ base.Loading(true);
+ lancamentos = new List<Lancamento>();
+ bool flag1 = false;
+ foreach (Lancamento lancamento in list)
+ {
+ Saldo saldo = await this.VerificaSaldo(lancamento.get_Conta().get_Id(), false);
+ if (saldo == null || !lancamento.get_Baixado())
+ {
+ continue;
+ }
+ DateTime? dataInicio = saldo.get_DataInicio();
+ DateTime? baixa = lancamento.get_Baixa();
+ flag = (dataInicio.HasValue & baixa.HasValue ? dataInicio.GetValueOrDefault() > baixa.GetValueOrDefault() : false);
+ if (!flag)
+ {
+ baixa = null;
+ lancamento.set_Baixa(baixa);
+ lancamento.set_ValorPago(new decimal?(new decimal()));
+ baixa = null;
+ lancamento.set_Pagamento(baixa);
+ lancamentos.Add(lancamento);
+ lancamento = null;
+ }
+ else
+ {
+ flag1 = true;
+ }
+ }
+ if (lancamentos.Count != 0)
+ {
+ bool flag2 = flag1;
+ if (flag2)
+ {
+ flag2 = !await base.ShowMessage(string.Concat("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", false);
+ }
+ if (!flag2)
+ {
+ await this._servico.Atualizar(lancamentos);
+ if (this._servico.Sucesso)
+ {
+ base.ToggleSnackBar(string.Format("EXCLUSÃO DE BAIXA DE {0} DO TOTAL DE {1} LANÇAMENTOS SELECIONADOS REALIZADA COM SUCESSO.", lancamentos.Count, list.Count), true);
+ await this.Buscar();
+ base.Loading(false);
+ }
+ else
+ {
+ base.Loading(false);
+ }
+ }
+ else
+ {
+ base.Loading(false);
+ }
+ }
+ else
+ {
+ await base.ShowMessage("NÃO FOI POSSÍVEL FAZER A EXCLUSÃO, POIS NÃO HÁ LANÇAMENTOS BAIXADOS DENTRO DO ÚLTIMO SALDO ABERTO. PROCESSO INTERROMPIDO", "OK", "", false);
+ base.Loading(false);
+ }
+ }
+ list = null;
+ lancamentos = null;
+ }
+
+ public void ExcluirFiltro(Gestor.Model.Domain.Financeiro.FiltroPersonalizado filtro)
+ {
+ Gestor.Model.Domain.Financeiro.FiltroPersonalizado filtroPersonalizado = this.FiltroPersonalizadoSelecionado.First<Gestor.Model.Domain.Financeiro.FiltroPersonalizado>((Gestor.Model.Domain.Financeiro.FiltroPersonalizado x) => {
+ if (x.get_Id() != filtro.get_Id())
+ {
+ return false;
+ }
+ return x.get_Tipo() == filtro.get_Tipo();
+ });
+ this.FiltroPersonalizadoSelecionado.Remove(filtroPersonalizado);
+ this.FiltroPersonalizadoSelecionado = new ObservableCollection<Gestor.Model.Domain.Financeiro.FiltroPersonalizado>(this.FiltroPersonalizadoSelecionado);
+ this.FiltrarPersonalizado();
+ }
+
+ public async Task ExcluirRange()
+ {
+ int? nullable;
+ bool flag1;
+ List<Lancamento> lancamentos;
+ ObservableCollection<Lancamento> lancamentosFiltrados = this.LancamentosFiltrados;
+ List<Lancamento> list = (
+ from x in lancamentosFiltrados
+ where x.get_Selecionado()
+ select x).ToList<Lancamento>();
+ if (list.Count == 0)
+ {
+ await base.ShowMessage("NÃO HÁ LANÇAMENTOS SELECIONADOS, SELECIONE-OS ANTES DE EXCLUIR.", "OK", "", false);
+ }
+ else if (await base.ShowMessage("DESEJA REAMENTE EXCLUIR OS LANÇAMENTOS SELECIONADOS? ESSE PROCESSO É IRREVERSÍVEL.", "SIM", "NÃO", false))
+ {
+ base.Loading(true);
+ List<Lancamento> lancamentos1 = new List<Lancamento>();
+ ObservableCollection<Lancamento> observableCollection = this.LancamentosFiltrados;
+ List<Lancamento> list1 = observableCollection.Where<Lancamento>((Lancamento x) => {
+ if (!x.get_Selecionado())
+ {
+ return false;
+ }
+ return x.get_Historico().Equals("TRANSFERÊNCIA ENTRE CONTAS");
+ }).ToList<Lancamento>();
+ list1.ForEach((Lancamento x) => {
+ Lancamento lancamento = list1.FirstOrDefault<Lancamento>((Lancamento z) => {
+ if (z.get_Controle().get_Id() != this.x.get_Controle().get_Id() || !(this.x.get_Valor() == z.get_Valor()))
+ {
+ return false;
+ }
+ return this.x.get_Sinal() != z.get_Sinal();
+ });
+ if (lancamento == null || lancamentos1.Where<Lancamento>((Lancamento z) => {
+ if ((object)z == (object)x)
+ {
+ return true;
+ }
+ return (object)z == (object)lancamento;
+ }).ToList<Lancamento>().Count > 0)
+ {
+ return;
+ }
+ lancamentos1.AddRange(new List<Lancamento>()
+ {
+ x,
+ lancamento
+ });
+ });
+ List<Lancamento> lancamentos2 = list1;
+ if (lancamentos2 != null)
+ {
+ nullable = new int?(lancamentos2.Count);
+ }
+ else
+ {
+ nullable = null;
+ }
+ int? nullable1 = nullable;
+ int count = lancamentos1.Count;
+ bool valueOrDefault = !(nullable1.GetValueOrDefault() == count & nullable1.HasValue);
+ if (valueOrDefault)
+ {
+ valueOrDefault = !await base.ShowMessage(string.Concat("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", false);
+ }
+ if (!valueOrDefault)
+ {
+ bool flag2 = false;
+ lancamentos = new List<Lancamento>();
+ List<Lancamento> lancamentos3 = list;
+ IOrderedEnumerable<Lancamento> id =
+ from x in lancamentos3
+ orderby x.get_Controle().get_Id()
+ select x;
+ foreach (Lancamento lancamento1 in id.ThenByDescending<Lancamento, int>((Lancamento x) => x.get_Parcela()).ToList<Lancamento>())
+ {
+ if (lancamento1.get_Baixado())
+ {
+ Saldo saldo = await this.VerificaSaldo(lancamento1.get_Conta().get_Id(), false);
+ if (saldo == null)
+ {
+ continue;
+ }
+ DateTime? dataInicio = saldo.get_DataInicio();
+ DateTime? baixa = lancamento1.get_Baixa();
+ flag1 = (dataInicio.HasValue & baixa.HasValue ? dataInicio.GetValueOrDefault() > baixa.GetValueOrDefault() : false);
+ if (flag1)
+ {
+ flag2 = true;
+ continue;
+ }
+ }
+ Lancamento lancamento2 = await this._servico.BuscarLancamento(lancamento1.get_Controle().get_Id(), lancamento1.get_Parcela() + 1);
+ Lancamento lancamento3 = lancamento2;
+ if (lancamento3 != null)
+ {
+ List<Lancamento> lancamentos4 = await this._servico.BuscarLancamentosPorControle(lancamento1.get_Controle().get_Id());
+ lancamentos = lancamentos4.Where<Lancamento>((Lancamento c) => {
+ if (c.get_Baixado())
+ {
+ return false;
+ }
+ return c.get_Parcela() >= lancamento1.get_Parcela() + 1;
+ }).AsEnumerable<Lancamento>().ToList<Lancamento>();
+ }
+ if (lancamento3 == null || !lancamentos1.All<Lancamento>((Lancamento l) => l.get_Id() != lancamento3.get_Id()))
+ {
+ if (lancamento1.get_Controle().get_Plano() != null)
+ {
+ lancamentos1.Add(lancamento1);
+ }
+ }
+ else
+ {
+ flag2 = true;
+ }
+ }
+ if (lancamentos1.Count != 0 || lancamentos.Count != 0)
+ {
+ valueOrDefault = flag2;
+ if (valueOrDefault)
+ {
+ valueOrDefault = !await base.ShowMessage(string.Concat("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", false);
+ }
+ if (!valueOrDefault)
+ {
+ valueOrDefault = lancamentos.Count > 0;
+ if (valueOrDefault)
+ {
+ valueOrDefault = await base.ShowMessage("DESEJA EXCLUIR LANÇAMENTOS/PARCELAS CADASTRADOS ACIMA DAS SELECIONADAS.", "SIM", "NÃO", false);
+ }
+ if (valueOrDefault)
+ {
+ lancamentos1.AddRange(lancamentos);
+ }
+ if (await this._servico.Excluir(lancamentos1))
+ {
+ if (lancamentos1 != null && lancamentos1.Count > 0)
+ {
+ lancamentos1.ForEach((Lancamento x) => {
+ bool flag;
+ FinanceiroViewModel u003cu003e4_this = this;
+ string str = string.Format("EXCLUIU O LANÇAMENTO DO ID {0} HISTORICO: {1}", (x != null ? new long?(x.get_Id()) : null), (x != null ? x.get_Historico() : null));
+ if (x != null)
+ {
+ x.get_Id();
+ flag = false;
+ }
+ else
+ {
+ flag = true;
+ }
+ u003cu003e4_this.RegistrarAcao(str, (flag ? (long)0 : x.get_Id()), new TipoTela?(25), null);
+ });
+ }
+ base.ToggleSnackBar(string.Format("EXCLUSÃO DE {0} DO TOTAL DE {1} LANÇAMENTOS SELECIONADOS REALIZADA COM SUCESSO.", lancamentos1.Count, list.Count), true);
+ await this.Buscar();
+ base.Loading(false);
+ }
+ else
+ {
+ base.Loading(false);
+ }
+ }
+ else
+ {
+ base.Loading(false);
+ }
+ }
+ else
+ {
+ await base.ShowMessage("OS LANÇAMENTOS SELECIONADOS NÃO PODEM SER EXCLUÍDOS. NENHUMA ALTERAÇÃO FOI FEITA", "OK", "", false);
+ base.Loading(false);
+ }
+ }
+ else
+ {
+ base.Loading(false);
+ }
+ }
+ list = null;
+ lancamentos = null;
+ }
+
+ public void Feed(Lancamento lancamento)
+ {
+ bool id;
+ Fornecedor fornecedor;
+ Gestor.Model.Domain.Financeiro.Planos plano;
+ BancosContas bancosConta;
+ if (lancamento == null || this.Salvando)
+ {
+ return;
+ }
+ if (!this.importando && lancamento.get_Controle().get_Plano() == null)
+ {
+ return;
+ }
+ Fornecedor fornecedor1 = lancamento.get_Controle().get_Fornecedor();
+ if (fornecedor1 != null)
+ {
+ id = fornecedor1.get_Id() == (long)0;
+ }
+ else
+ {
+ id = false;
+ }
+ if (id)
+ {
+ fornecedor = null;
+ }
+ else
+ {
+ fornecedor = lancamento.get_Controle().get_Fornecedor();
+ }
+ this.FornecedorInclusao = fornecedor;
+ if (lancamento.get_Controle().get_Plano() != null)
+ {
+ plano = this.PlanosFiltrados.FirstOrDefault<Gestor.Model.Domain.Financeiro.Planos>((Gestor.Model.Domain.Financeiro.Planos x) => x.get_Id() == lancamento.get_Controle().get_Plano().get_Id());
+ }
+ else
+ {
+ plano = null;
+ }
+ this.Plano = plano;
+ this.Centro = this.CentrosFiltrados.FirstOrDefault<Gestor.Model.Domain.Financeiro.Centro>((Gestor.Model.Domain.Financeiro.Centro x) => x.get_Id() == lancamento.get_Controle().get_Centro().get_Id());
+ if (lancamento.get_Conta() != null)
+ {
+ bancosConta = this.ContasFiltradas.FirstOrDefault<BancosContas>((BancosContas x) => x.get_Id() == lancamento.get_Conta().get_Id());
+ }
+ else
+ {
+ bancosConta = null;
+ }
+ this.Conta = bancosConta;
+ this.TipoPagamento = lancamento.get_TipoPagamento();
+ this.Historico = lancamento.get_Historico();
+ this.Observacao = lancamento.get_Observacao();
+ this.Complemento = lancamento.get_Complemento();
+ this.Competencia = lancamento.get_Competencia();
+ this.Documento = lancamento.get_Documento();
+ this.Parcela = lancamento.get_Parcela();
+ this.Parcelas = lancamento.get_Controle().get_Parcelas();
+ this.Valor = lancamento.get_Valor();
+ this.ValorPago = lancamento.get_ValorPago();
+ this.Vencimento = lancamento.get_Vencimento();
+ this.Pagamento = lancamento.get_Pagamento();
+ this.Baixa = lancamento.get_Baixa();
+ this.Sinal = lancamento.get_Sinal();
+ this.CodigoBanco = lancamento.get_CodigoBanco();
+ }
+
+ public void FeedImportando(Lancamento lancamento)
+ {
+ BancosContas bancosConta;
+ Gestor.Model.Domain.Financeiro.Planos plano;
+ if (lancamento == null || this.Salvando)
+ {
+ return;
+ }
+ if (!this.importando && lancamento.get_Controle().get_Plano() == null)
+ {
+ return;
+ }
+ if (this.Conta == null)
+ {
+ bancosConta = this.ContasFiltradas.FirstOrDefault<BancosContas>((BancosContas x) => x.get_Id() == lancamento.get_Conta().get_Id());
+ }
+ else
+ {
+ bancosConta = null;
+ }
+ this.Conta = bancosConta;
+ this.SelectedLancamento.set_Id(lancamento.get_Id());
+ this.SelectedLancamento.get_Controle().set_Id(lancamento.get_Controle().get_Id());
+ this.SelectedLancamento.get_Controle().set_Historico(lancamento.get_Controle().get_Historico());
+ this.SelectedLancamento.set_Baixado(lancamento.get_Baixa().HasValue);
+ decimal? valorPago = this.SelectedLancamento.get_ValorPago();
+ this.IdLancamento = lancamento.get_Id();
+ if (lancamento.get_Controle().get_Plano() != null)
+ {
+ plano = this.PlanosFiltrados.FirstOrDefault<Gestor.Model.Domain.Financeiro.Planos>((Gestor.Model.Domain.Financeiro.Planos x) => x.get_Id() == lancamento.get_Controle().get_Plano().get_Id());
+ }
+ else
+ {
+ plano = null;
+ }
+ this.Plano = plano;
+ this.Centro = this.CentrosFiltrados.FirstOrDefault<Gestor.Model.Domain.Financeiro.Centro>((Gestor.Model.Domain.Financeiro.Centro x) => x.get_Id() == lancamento.get_Controle().get_Centro().get_Id());
+ this.TipoPagamento = lancamento.get_TipoPagamento();
+ this.Historico = lancamento.get_Historico();
+ this.Observacao = lancamento.get_Observacao();
+ this.Complemento = lancamento.get_Complemento();
+ this.Documento = lancamento.get_Documento();
+ this.Parcela = lancamento.get_Parcela();
+ this.Parcelas = lancamento.get_Controle().get_Parcelas();
+ this.Valor = lancamento.get_Valor();
+ this.ValorPago = valorPago;
+ this.Vencimento = lancamento.get_Vencimento();
+ this.Pagamento = (lancamento.get_Pagamento().HasValue ? lancamento.get_Pagamento() : this.Pagamento);
+ }
+
+ public List<Lancamento> Filtrar(string filter)
+ {
+ this._dontSort = true;
+ this.LancamentosFiltrados = (string.IsNullOrWhiteSpace(filter) ? this.Lancamentos : new ObservableCollection<Lancamento>(this.Lancamentos.Where<Lancamento>((Lancamento x) => {
+ bool plano;
+ bool centro;
+ bool fornecedor;
+ if ((x.get_Historico() == null || !Gestor.Common.Validation.ValidationHelper.RemoveDiacritics(x.get_Historico().Trim()).Contains(filter)) && (x.get_Documento() == null || !Gestor.Common.Validation.ValidationHelper.RemoveDiacritics(x.get_Documento().Trim()).Contains(filter)) && (x.get_Competencia() == null || !Gestor.Common.Validation.ValidationHelper.RemoveDiacritics(x.get_Competencia().Trim()).Contains(filter)) && (x.get_Complemento() == null || !Gestor.Common.Validation.ValidationHelper.RemoveDiacritics(x.get_Complemento().Trim()).Contains(filter)) && (x.get_Observacao() == null || !Gestor.Common.Validation.ValidationHelper.RemoveDiacritics(x.get_Observacao().Trim()).Contains(filter)) && !Gestor.Common.Validation.ValidationHelper.RemoveDiacritics(x.get_Vencimento().ToString(CultureInfo.CurrentCulture).Trim()).ToUpper().Contains(filter) && (!x.get_Baixa().HasValue || !Gestor.Common.Validation.ValidationHelper.RemoveDiacritics(x.get_Baixa().ToString().Trim()).ToUpper().Contains(filter)) && (!x.get_Pagamento().HasValue || !Gestor.Common.Validation.ValidationHelper.RemoveDiacritics(x.get_Pagamento().ToString().Trim()).ToUpper().Contains(filter)) && (x.get_Conta() == null || !Gestor.Common.Validation.ValidationHelper.RemoveDiacritics(x.get_Conta().get_Descricao().Trim()).ToUpper().Contains(filter)) && (x.get_Controle().get_Historico() == null || !Gestor.Common.Validation.ValidationHelper.RemoveDiacritics(x.get_Controle().get_Historico().Trim()).ToUpper().Contains(filter)) && !Gestor.Common.Validation.ValidationHelper.RemoveDiacritics(EnumHelper.GetDescription<Gestor.Model.Common.Sinal>(x.get_Sinal()).Trim()).Contains(filter))
+ {
+ ControleFinanceiro controle = x.get_Controle();
+ if (controle != null)
+ {
+ plano = controle.get_Plano();
+ }
+ else
+ {
+ plano = false;
+ }
+ if (!plano || !Gestor.Common.Validation.ValidationHelper.RemoveDiacritics(x.get_Controle().get_Plano().get_Descricao().Trim()).ToUpper().Contains(filter))
+ {
+ x.get_TipoPagamento();
+ if (!Gestor.Common.Validation.ValidationHelper.RemoveDiacritics(EnumHelper.GetDescription<Gestor.Model.Common.TipoPagamento>(x.get_TipoPagamento()).Trim()).ToUpper().Contains(filter))
+ {
+ ControleFinanceiro controleFinanceiro = x.get_Controle();
+ if (controleFinanceiro != null)
+ {
+ centro = controleFinanceiro.get_Centro();
+ }
+ else
+ {
+ centro = false;
+ }
+ if (!centro || !Gestor.Common.Validation.ValidationHelper.RemoveDiacritics(x.get_Controle().get_Centro().get_Descricao().Trim()).ToUpper().Contains(filter))
+ {
+ ControleFinanceiro controle1 = x.get_Controle();
+ if (controle1 != null)
+ {
+ fornecedor = controle1.get_Fornecedor();
+ }
+ else
+ {
+ fornecedor = false;
+ }
+ if (!fornecedor)
+ {
+ return false;
+ }
+ return Gestor.Common.Validation.ValidationHelper.RemoveDiacritics(x.get_Controle().get_Fornecedor().get_Nome().Trim()).ToUpper().Contains(filter);
+ }
+ }
+ }
+ }
+ return true;
+ })));
+ this._dontSort = false;
+ this.LancamentosFiltradosCopia = this.LancamentosFiltrados;
+ return this.LancamentosFiltrados.ToList<Lancamento>();
+ }
+
+ public List<Lancamento> FiltrarLancamento(long id)
+ {
+ this.LancamentosFiltrados = new ObservableCollection<Lancamento>(
+ from x in this.Lancamentos
+ where x.get_Id() == id
+ select x);
+ return this.LancamentosFiltrados.ToList<Lancamento>();
+ }
+
+ public List<Lancamento> FiltrarLancamento(Lancamento lancamento)
+ {
+ this.LancamentosFiltrados = new ObservableCollection<Lancamento>(this.Lancamentos.Where<Lancamento>((Lancamento x) => {
+ if (!(x.get_Valor() == lancamento.get_Valor()) || !(x.get_Vencimento() == lancamento.get_Vencimento()))
+ {
+ return false;
+ }
+ return x.get_Historico() == lancamento.get_Historico();
+ }));
+ return this.LancamentosFiltrados.ToList<Lancamento>();
+ }
+
+ public async Task<List<Lancamento>> FiltrarLancamento(string value)
+ {
+ List<Lancamento> lancamentos = await Task.Run<List<Lancamento>>(() => this.Filtrar(value));
+ return lancamentos;
+ }
+
+ public void FiltrarPersonalizado()
+ {
+ List<long> nums = (this.FiltroPersonalizadoSelecionado != null ? (
+ from x in this.FiltroPersonalizadoSelecionado
+ where x.get_Tipo() == 0
+ select x.get_Id()).ToList<long>() : new List<long>());
+ List<long> nums1 = (this.FiltroPersonalizadoSelecionado != null ? (
+ from x in this.FiltroPersonalizadoSelecionado
+ where x.get_Tipo() == 2
+ select x.get_Id()).ToList<long>() : new List<long>());
+ List<long> nums2 = (this.FiltroPersonalizadoSelecionado != null ? (
+ from x in this.FiltroPersonalizadoSelecionado
+ where x.get_Tipo() == 1
+ select x.get_Id()).ToList<long>() : new List<long>());
+ List<long> nums3 = (this.FiltroPersonalizadoSelecionado != null ? (
+ from x in this.FiltroPersonalizadoSelecionado
+ where x.get_Tipo() == 3
+ select x.get_Id()).ToList<long>() : new List<long>());
+ List<long> nums4 = (this.FiltroPersonalizadoSelecionado != null ? (
+ from x in this.FiltroPersonalizadoSelecionado
+ where x.get_Tipo() == 4
+ select x.get_Id()).ToList<long>() : new List<long>());
+ List<Lancamento> list = this.Lancamentos.Where<Lancamento>((Lancamento x) => {
+ if (nums.Count != 0 && (x.get_Controle().get_Fornecedor() == null || !nums.Contains(x.get_Controle().get_Fornecedor().get_Id())) || nums1.Count != 0 && (x.get_Controle().get_Centro() == null || !nums1.Contains(x.get_Controle().get_Centro().get_Id())) || nums2.Count != 0 && (x.get_Controle().get_Plano() == null || !nums2.Contains(x.get_Controle().get_Plano().get_Id())) || nums3.Count != 0 && (x.get_Conta() == null || !nums3.Contains(x.get_Conta().get_Id())))
+ {
+ return false;
+ }
+ if (nums4.Count == 0)
+ {
+ return true;
+ }
+ return nums4.Contains((long)x.get_Sinal());
+ }).ToList<Lancamento>();
+ this.LancamentosFiltrados = new ObservableCollection<Lancamento>(list);
+ this.LancamentosFiltradosCopia = this.LancamentosFiltrados;
+ this.SelectedLancamento = this.LancamentosFiltrados.FirstOrDefault<Lancamento>();
+ }
+
+ public List<Gestor.Model.Domain.Financeiro.FiltroPersonalizado> FiltrarPersonalizado(string filter)
+ {
+ if (this.FiltroPersonalizado == null)
+ {
+ this.PopularFiltro();
+ }
+ return (
+ from x in this.FiltroPersonalizado
+ where Gestor.Common.Validation.ValidationHelper.RemoveDiacritics(x.get_Descricao().Trim()).ToUpper().Contains(filter.ToUpper())
+ select x).ToList<Gestor.Model.Domain.Financeiro.FiltroPersonalizado>();
+ }
+
+ public void FiltroImportacao()
+ {
+ if (!this.importando)
+ {
+ return;
+ }
+ switch (this.SelectedStatusImportacao)
+ {
+ case 0:
+ {
+ this.LancamentosFiltrados = new ObservableCollection<Lancamento>(
+ from x in this.Lancamentos
+ where !x.get_Baixado()
+ select x);
+ return;
+ }
+ case 1:
+ {
+ this.LancamentosFiltrados = new ObservableCollection<Lancamento>(
+ from x in this.Lancamentos
+ where x.get_Baixado()
+ select x);
+ return;
+ }
+ case 2:
+ {
+ this.LancamentosFiltrados = new ObservableCollection<Lancamento>(this.Lancamentos);
+ return;
+ }
+ default:
+ {
+ return;
+ }
+ }
+ }
+
+ internal async Task<List<Gestor.Model.Domain.Financeiro.FiltroPersonalizado>> FiltroPersonalizadoTask(string value)
+ {
+ List<Gestor.Model.Domain.Financeiro.FiltroPersonalizado> filtroPersonalizados = await Task.Run<List<Gestor.Model.Domain.Financeiro.FiltroPersonalizado>>(() => this.FiltrarPersonalizado(value));
+ return filtroPersonalizados;
+ }
+
+ public async Task GerarExcel(List<Lancamento> relatorioGrid)
+ {
+ List<string> list;
+ string str1;
+ FinanceiroViewModel.u003cu003ec__DisplayClass266_0 variable;
+ bool flag = await base.ShowMessage(string.Concat("DESEJA AGRUPAR POR ", EnumHelper.GetDescription<SinteticoFinanceiroTipo>(this.SinteticoTipo)), "SIM", "NÃO", false);
+ XLWorkbook xLWorkbook = new XLWorkbook();
+ string str2 = "LANÇAMENTOS FINANCEIROS";
+ List<RelatorioLancamentos> relatorioLancamentos = new List<RelatorioLancamentos>();
+ List<Lancamento> lancamentos = new List<Lancamento>();
+ List<Lancamento> lancamentos1 = relatorioGrid;
+ bool flag1 = lancamentos1.Any<Lancamento>((Lancamento x) => x.get_Selecionado());
+ relatorioGrid.ToList<Lancamento>().ForEach((Lancamento lancamentoGrid) => {
+ decimal? valorPago;
+ if (flag1 && !lancamentoGrid.get_Selecionado())
+ {
+ return;
+ }
+ Lancamento lancamento2 = (Lancamento)lancamentoGrid.Clone();
+ lancamento2.set_Valor((lancamento2.get_Sinal() == 1 ? -lancamento2.get_Valor() : lancamento2.get_Valor()));
+ Lancamento lancamento1 = lancamento2;
+ if (lancamento2.get_Sinal() == 1)
+ {
+ decimal? nullable = lancamento2.get_ValorPago();
+ valorPago = (nullable.HasValue ? new decimal?(-nullable.GetValueOrDefault()) : null);
+ }
+ else
+ {
+ valorPago = lancamento2.get_ValorPago();
+ }
+ lancamento1.set_ValorPago(valorPago);
+ lancamentos.Add(lancamento2);
+ });
+ IEnumerable<IGrouping<string, Lancamento>> groupings = lancamentos.GroupBy<Lancamento, string>((Lancamento lancamento) => {
+ object descricao;
+ if (this.SinteticoTipo == 1)
+ {
+ Gestor.Model.Domain.Financeiro.Centro centro = lancamento.get_Controle().get_Centro();
+ if (centro != null)
+ {
+ descricao = centro.get_Descricao();
+ }
+ else
+ {
+ descricao = null;
+ }
+ if (descricao == null)
+ {
+ descricao = "";
+ }
+ }
+ else if (this.SinteticoTipo == null)
+ {
+ Gestor.Model.Domain.Financeiro.Planos plano = lancamento.get_Controle().get_Plano();
+ if (plano != null)
+ {
+ descricao = plano.get_Nome();
+ }
+ else
+ {
+ descricao = null;
+ }
+ if (descricao == null)
+ {
+ return "";
+ }
+ }
+ else
+ {
+ if (this.SinteticoTipo != 3)
+ {
+ Fornecedor fornecedor = lancamento.get_Controle().get_Fornecedor();
+ if (fornecedor != null)
+ {
+ return fornecedor.get_Nome();
+ }
+ return null;
+ }
+ BancosContas conta = lancamento.get_Conta();
+ if (conta != null)
+ {
+ descricao = conta.get_Descricao();
+ }
+ else
+ {
+ descricao = null;
+ }
+ if (descricao == null)
+ {
+ return "";
+ }
+ }
+ return descricao;
+ });
+ List<Gestor.Model.Domain.Relatorios.SinteticoFinanceiro> sinteticoFinanceiros = groupings.Select<IGrouping<string, Lancamento>, Gestor.Model.Domain.Relatorios.SinteticoFinanceiro>((IGrouping<string, Lancamento> lancamento) => {
+ Gestor.Model.Domain.Relatorios.SinteticoFinanceiro sinteticoFinanceiro = new Gestor.Model.Domain.Relatorios.SinteticoFinanceiro();
+ sinteticoFinanceiro.set_Agrupamento(lancamento.Key ?? "TRANSFERÊNCIAS");
+ sinteticoFinanceiro.set_Valor(new decimal?(lancamento.Sum<Lancamento>((Lancamento sintetic) => sintetic.get_Valor())));
+ sinteticoFinanceiro.set_ValorPago(new decimal?(lancamento.Sum<Lancamento>((Lancamento sintetic) => sintetic.get_ValorPago()).GetValueOrDefault()));
+ return sinteticoFinanceiro;
+ }).ToList<Gestor.Model.Domain.Relatorios.SinteticoFinanceiro>();
+ List<Gestor.Model.Domain.Relatorios.SinteticoFinanceiro> sinteticoFinanceiros1 = sinteticoFinanceiros;
+ sinteticoFinanceiros = (
+ from lancamento in sinteticoFinanceiros1
+ orderby lancamento.get_Agrupamento()
+ select lancamento).ToList<Gestor.Model.Domain.Relatorios.SinteticoFinanceiro>();
+ List<Gestor.Model.Domain.Relatorios.SinteticoFinanceiro> sinteticoFinanceiros2 = sinteticoFinanceiros;
+ Gestor.Model.Domain.Relatorios.SinteticoFinanceiro sinteticoFinanceiro1 = new Gestor.Model.Domain.Relatorios.SinteticoFinanceiro();
+ sinteticoFinanceiro1.set_Agrupamento("TOTAL");
+ List<Gestor.Model.Domain.Relatorios.SinteticoFinanceiro> sinteticoFinanceiros3 = sinteticoFinanceiros;
+ sinteticoFinanceiro1.set_Valor(sinteticoFinanceiros3.Sum<Gestor.Model.Domain.Relatorios.SinteticoFinanceiro>((Gestor.Model.Domain.Relatorios.SinteticoFinanceiro sintetic) => sintetic.get_Valor()));
+ List<Gestor.Model.Domain.Relatorios.SinteticoFinanceiro> sinteticoFinanceiros4 = sinteticoFinanceiros;
+ sinteticoFinanceiro1.set_ValorPago(sinteticoFinanceiros4.Sum<Gestor.Model.Domain.Relatorios.SinteticoFinanceiro>((Gestor.Model.Domain.Relatorios.SinteticoFinanceiro sintetic) => sintetic.get_ValorPago()));
+ sinteticoFinanceiros2.Add(sinteticoFinanceiro1);
+ xLWorkbook = await Funcoes.GerarXls<Gestor.Model.Domain.Relatorios.SinteticoFinanceiro>(xLWorkbook, "SINTÉTICO", sinteticoFinanceiros, null);
+ if (!flag)
+ {
+ relatorioLancamentos = FinanceiroViewModel.GerarRelatorio(lancamentos);
+ List<RelatorioLancamentos> relatorioLancamentos1 = relatorioLancamentos;
+ RelatorioLancamentos relatorioLancamento = new RelatorioLancamentos();
+ relatorioLancamento.set_Fornecedor("TOTAL");
+ List<RelatorioLancamentos> relatorioLancamentos2 = relatorioLancamentos;
+ relatorioLancamento.set_Valor(relatorioLancamentos2.Sum<RelatorioLancamentos>((RelatorioLancamentos lancamento) => lancamento.get_Valor()));
+ List<RelatorioLancamentos> relatorioLancamentos3 = relatorioLancamentos;
+ relatorioLancamento.set_ValorPago(relatorioLancamentos3.Sum<RelatorioLancamentos>((RelatorioLancamentos lancamento) => lancamento.get_ValorPago()));
+ relatorioLancamentos1.Add(relatorioLancamento);
+ xLWorkbook = await Funcoes.GerarXls<RelatorioLancamentos>(xLWorkbook, str2, relatorioLancamentos, null);
+ }
+ else
+ {
+ switch (this.SinteticoTipo)
+ {
+ case 0:
+ {
+ List<Lancamento> lancamentos2 = lancamentos;
+ list = lancamentos2.Select<Lancamento, string>((Lancamento x) => {
+ object descricao;
+ ControleFinanceiro controle = x.get_Controle();
+ if (controle != null)
+ {
+ Gestor.Model.Domain.Financeiro.Planos plano = controle.get_Plano();
+ if (plano != null)
+ {
+ descricao = plano.get_Descricao();
+ }
+ else
+ {
+ descricao = null;
+ }
+ }
+ else
+ {
+ descricao = null;
+ }
+ if (descricao == null)
+ {
+ descricao = "";
+ }
+ return descricao;
+ }).Distinct<string>().ToList<string>();
+ foreach (string str3 in list)
+ {
+ List<Lancamento> list1 = lancamentos.Where<Lancamento>((Lancamento lancamento) => {
+ string descricao;
+ string str;
+ if (string.IsNullOrWhiteSpace(str3))
+ {
+ ControleFinanceiro controle = lancamento.get_Controle();
+ if (controle != null)
+ {
+ Gestor.Model.Domain.Financeiro.Planos plano = controle.get_Plano();
+ if (plano != null)
+ {
+ str = plano.get_Descricao();
+ }
+ else
+ {
+ str = null;
+ }
+ }
+ else
+ {
+ str = null;
+ }
+ return string.IsNullOrEmpty(str);
+ }
+ ControleFinanceiro controleFinanceiro = lancamento.get_Controle();
+ if (controleFinanceiro != null)
+ {
+ Gestor.Model.Domain.Financeiro.Planos plano1 = controleFinanceiro.get_Plano();
+ if (plano1 != null)
+ {
+ descricao = plano1.get_Descricao();
+ }
+ else
+ {
+ descricao = null;
+ }
+ }
+ else
+ {
+ descricao = null;
+ }
+ return descricao == str3;
+ }).ToList<Lancamento>();
+ if (list1.Count == 0)
+ {
+ continue;
+ }
+ relatorioLancamentos = FinanceiroViewModel.GerarRelatorio(list1);
+ List<RelatorioLancamentos> relatorioLancamentos4 = relatorioLancamentos;
+ RelatorioLancamentos relatorioLancamento1 = new RelatorioLancamentos();
+ relatorioLancamento1.set_Fornecedor("TOTAL");
+ List<Lancamento> lancamentos3 = list1;
+ relatorioLancamento1.set_Valor(lancamentos3.Sum<Lancamento>((Lancamento lancamento) => lancamento.get_Valor()));
+ List<Lancamento> lancamentos4 = list1;
+ relatorioLancamento1.set_ValorPago(lancamentos4.Sum<Lancamento>((Lancamento lancamento) => lancamento.get_ValorPago()));
+ relatorioLancamentos4.Add(relatorioLancamento1);
+ str1 = (!string.IsNullOrWhiteSpace(str3) ? str3.ValidaNomePlanilha("", 0) : "TRANSFERENCIAS");
+ str2 = str1;
+ xLWorkbook = await Funcoes.GerarXls<RelatorioLancamentos>(xLWorkbook, str2, relatorioLancamentos, null);
+ }
+ break;
+ }
+ case 1:
+ {
+ List<Lancamento> lancamentos5 = lancamentos;
+ list = lancamentos5.Select<Lancamento, string>((Lancamento lancamento) => {
+ object descricao;
+ ControleFinanceiro controle = lancamento.get_Controle();
+ if (controle != null)
+ {
+ Gestor.Model.Domain.Financeiro.Centro centro = controle.get_Centro();
+ if (centro != null)
+ {
+ descricao = centro.get_Descricao();
+ }
+ else
+ {
+ descricao = null;
+ }
+ }
+ else
+ {
+ descricao = null;
+ }
+ if (descricao == null)
+ {
+ descricao = "";
+ }
+ return descricao;
+ }).Distinct<string>().ToList<string>();
+ foreach (string str4 in list)
+ {
+ List<Lancamento> list2 = lancamentos.Where<Lancamento>((Lancamento lanamento) => {
+ string descricao;
+ string str;
+ if (string.IsNullOrWhiteSpace(str4))
+ {
+ ControleFinanceiro controle = lanamento.get_Controle();
+ if (controle != null)
+ {
+ Gestor.Model.Domain.Financeiro.Centro centro = controle.get_Centro();
+ if (centro != null)
+ {
+ str = centro.get_Descricao();
+ }
+ else
+ {
+ str = null;
+ }
+ }
+ else
+ {
+ str = null;
+ }
+ return string.IsNullOrEmpty(str);
+ }
+ ControleFinanceiro controleFinanceiro = lanamento.get_Controle();
+ if (controleFinanceiro != null)
+ {
+ Gestor.Model.Domain.Financeiro.Centro centro1 = controleFinanceiro.get_Centro();
+ if (centro1 != null)
+ {
+ descricao = centro1.get_Descricao();
+ }
+ else
+ {
+ descricao = null;
+ }
+ }
+ else
+ {
+ descricao = null;
+ }
+ return descricao == str4;
+ }).ToList<Lancamento>();
+ if (list2.Count == 0)
+ {
+ continue;
+ }
+ relatorioLancamentos = FinanceiroViewModel.GerarRelatorio(list2);
+ List<RelatorioLancamentos> relatorioLancamentos5 = relatorioLancamentos;
+ RelatorioLancamentos relatorioLancamento2 = new RelatorioLancamentos();
+ relatorioLancamento2.set_Fornecedor("TOTAL");
+ List<Lancamento> lancamentos6 = list2;
+ relatorioLancamento2.set_Valor(lancamentos6.Sum<Lancamento>((Lancamento lancamento) => lancamento.get_Valor()));
+ List<Lancamento> lancamentos7 = list2;
+ relatorioLancamento2.set_ValorPago(lancamentos7.Sum<Lancamento>((Lancamento lancamento) => lancamento.get_ValorPago()));
+ relatorioLancamentos5.Add(relatorioLancamento2);
+ str2 = str4.ValidaNomePlanilha("", 0);
+ xLWorkbook = await Funcoes.GerarXls<RelatorioLancamentos>(xLWorkbook, str2, relatorioLancamentos, null);
+ }
+ break;
+ }
+ case 2:
+ {
+ List<Lancamento> lancamentos8 = lancamentos;
+ list = lancamentos8.Select<Lancamento, string>((Lancamento lancamento) => {
+ object nome;
+ ControleFinanceiro controle = lancamento.get_Controle();
+ if (controle != null)
+ {
+ Fornecedor fornecedor = controle.get_Fornecedor();
+ if (fornecedor != null)
+ {
+ nome = fornecedor.get_Nome();
+ }
+ else
+ {
+ nome = null;
+ }
+ }
+ else
+ {
+ nome = null;
+ }
+ if (nome == null)
+ {
+ nome = "";
+ }
+ return nome;
+ }).Distinct<string>().ToList<string>();
+ foreach (string str5 in list)
+ {
+ List<Lancamento> list3 = lancamentos.Where<Lancamento>((Lancamento lancamento) => {
+ string nome;
+ string str;
+ if (string.IsNullOrWhiteSpace(str5))
+ {
+ ControleFinanceiro controle = lancamento.get_Controle();
+ if (controle != null)
+ {
+ Fornecedor fornecedor = controle.get_Fornecedor();
+ if (fornecedor != null)
+ {
+ str = fornecedor.get_Nome();
+ }
+ else
+ {
+ str = null;
+ }
+ }
+ else
+ {
+ str = null;
+ }
+ return string.IsNullOrEmpty(str);
+ }
+ ControleFinanceiro controleFinanceiro = lancamento.get_Controle();
+ if (controleFinanceiro != null)
+ {
+ Fornecedor fornecedor1 = controleFinanceiro.get_Fornecedor();
+ if (fornecedor1 != null)
+ {
+ nome = fornecedor1.get_Nome();
+ }
+ else
+ {
+ nome = null;
+ }
+ }
+ else
+ {
+ nome = null;
+ }
+ return nome == str5;
+ }).ToList<Lancamento>();
+ if (list3.Count == 0)
+ {
+ continue;
+ }
+ relatorioLancamentos = FinanceiroViewModel.GerarRelatorio(list3);
+ List<RelatorioLancamentos> relatorioLancamentos6 = relatorioLancamentos;
+ RelatorioLancamentos relatorioLancamento3 = new RelatorioLancamentos();
+ relatorioLancamento3.set_Fornecedor("TOTAL");
+ List<Lancamento> lancamentos9 = list3;
+ relatorioLancamento3.set_Valor(lancamentos9.Sum<Lancamento>((Lancamento lancamento) => lancamento.get_Valor()));
+ List<Lancamento> lancamentos10 = list3;
+ relatorioLancamento3.set_ValorPago(lancamentos10.Sum<Lancamento>((Lancamento lancamento) => lancamento.get_ValorPago()));
+ relatorioLancamentos6.Add(relatorioLancamento3);
+ str2 = str5.ValidaNomePlanilha("", 0);
+ xLWorkbook = await Funcoes.GerarXls<RelatorioLancamentos>(xLWorkbook, str2, relatorioLancamentos, null);
+ }
+ break;
+ }
+ case 3:
+ {
+ List<Lancamento> lancamentos11 = lancamentos;
+ list = lancamentos11.Select<Lancamento, string>((Lancamento x) => {
+ object descricao;
+ BancosContas conta = x.get_Conta();
+ if (conta != null)
+ {
+ descricao = conta.get_Descricao();
+ }
+ else
+ {
+ descricao = null;
+ }
+ if (descricao == null)
+ {
+ descricao = "";
+ }
+ return descricao;
+ }).Distinct<string>().ToList<string>();
+ foreach (string str6 in list)
+ {
+ if (string.IsNullOrWhiteSpace(str6))
+ {
+ continue;
+ }
+ List<Lancamento> list4 = lancamentos.Where<Lancamento>((Lancamento lancamento) => {
+ string descricao;
+ string str;
+ if (string.IsNullOrWhiteSpace(str6))
+ {
+ BancosContas conta = lancamento.get_Conta();
+ if (conta != null)
+ {
+ str = conta.get_Descricao();
+ }
+ else
+ {
+ str = null;
+ }
+ return string.IsNullOrEmpty(str);
+ }
+ BancosContas bancosConta = lancamento.get_Conta();
+ if (bancosConta != null)
+ {
+ descricao = bancosConta.get_Descricao();
+ }
+ else
+ {
+ descricao = null;
+ }
+ return descricao == str6;
+ }).ToList<Lancamento>();
+ if (list4.Count == 0)
+ {
+ continue;
+ }
+ relatorioLancamentos = FinanceiroViewModel.GerarRelatorio(list4);
+ List<RelatorioLancamentos> relatorioLancamentos7 = relatorioLancamentos;
+ RelatorioLancamentos relatorioLancamento4 = new RelatorioLancamentos();
+ relatorioLancamento4.set_Fornecedor("TOTAL");
+ List<Lancamento> lancamentos12 = list4;
+ relatorioLancamento4.set_Valor(lancamentos12.Sum<Lancamento>((Lancamento lancamento) => lancamento.get_Valor()));
+ List<Lancamento> lancamentos13 = list4;
+ relatorioLancamento4.set_ValorPago(lancamentos13.Sum<Lancamento>((Lancamento lancamento) => lancamento.get_ValorPago()));
+ relatorioLancamentos7.Add(relatorioLancamento4);
+ str2 = str6.ValidaNomePlanilha("", 0);
+ xLWorkbook = await Funcoes.GerarXls<RelatorioLancamentos>(xLWorkbook, str2, relatorioLancamentos, null);
+ }
+ break;
+ }
+ }
+ }
+ string tempPath = "";
+ string str7 = "";
+ List<ConfiguracaoSistema> configuracoes = Recursos.Configuracoes;
+ if (!configuracoes.Any<ConfiguracaoSistema>((ConfiguracaoSistema x) => x.get_Configuracao() == 41))
+ {
+ tempPath = Path.GetTempPath();
+ str7 = string.Format("{0}{1}.xlsx", tempPath, Guid.NewGuid());
+ }
+ else
+ {
+ using (FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog())
+ {
+ if (DialogResult.OK == folderBrowserDialog.ShowDialog())
+ {
+ tempPath = string.Concat(folderBrowserDialog.SelectedPath, "\\");
+ Directory.CreateDirectory(tempPath);
+ }
+ else
+ {
+ variable = null;
+ str2 = null;
+ return;
+ }
+ }
+ string[] strArrays = new string[] { tempPath, str2, " ", null, null };
+ DateTime date = Functions.GetNetworkTime().Date;
+ strArrays[3] = date.ToShortDateString().Replace("/", "");
+ strArrays[4] = ".xlsx";
+ str7 = string.Concat(strArrays);
+ }
+ xLWorkbook.SaveAs(str7);
+ Process.Start(str7);
+ variable = null;
+ str2 = null;
+ }
+
+ private async Task<string> GerarHtml(List<Lancamento> relatorioGrid, bool posicao = false)
+ {
+ DateTime dateTime;
+ DateTime dateTime1;
+ int num;
+ string str1;
+ TipoRelatorio tipoRelatorio = new TipoRelatorio();
+ tipoRelatorio.set_Nome("RELATÓRIO FINANCEIRO");
+ DateTime? inicio = this.Inicio;
+ dateTime = (inicio.HasValue ? inicio.GetValueOrDefault() : DateTime.MinValue);
+ tipoRelatorio.set_Inicio(dateTime);
+ inicio = this.Fim;
+ dateTime1 = (inicio.HasValue ? inicio.GetValueOrDefault() : DateTime.MinValue);
+ tipoRelatorio.set_Fim(dateTime1);
+ TipoRelatorio tipoRelatorio1 = tipoRelatorio;
+ switch (this.SelectedFiltro)
+ {
+ case 0:
+ {
+ tipoRelatorio1.set_Nome("RELATORIO FINANCEIRO - VENCIMENTO");
+ break;
+ }
+ case 1:
+ {
+ tipoRelatorio1.set_Nome("RELATORIO FINANCEIRO - BAIXA");
+ break;
+ }
+ case 2:
+ {
+ tipoRelatorio1.set_Nome("RELATORIO FINANCEIRO - PAGAMENTO");
+ break;
+ }
+ case 3:
+ {
+ tipoRelatorio1.set_Nome(this.SelectedFornecedor.get_Nome());
+ tipoRelatorio1.set_Inicio(DateTime.MinValue);
+ tipoRelatorio1.set_Fim(DateTime.MinValue);
+ break;
+ }
+ }
+ List<string> strs = Funcoes.OcultarColunasDescricao(typeof(Sintetico), "FINANCEIRO");
+ List<Lancamento> lancamentos = new List<Lancamento>();
+ List<Lancamento> lancamentos1 = relatorioGrid;
+ bool flag = lancamentos1.Any<Lancamento>((Lancamento x) => x.get_Selecionado());
+ relatorioGrid.ToList<Lancamento>().ForEach((Lancamento lancamentoGrid) => {
+ decimal? valorPago;
+ if (flag && !lancamentoGrid.get_Selecionado())
+ {
+ return;
+ }
+ Lancamento lancamento2 = (Lancamento)lancamentoGrid.Clone();
+ lancamento2.set_Valor((lancamento2.get_Sinal() == 1 ? -lancamento2.get_Valor() : lancamento2.get_Valor()));
+ Lancamento lancamento1 = lancamento2;
+ if (lancamento2.get_Sinal() == 1)
+ {
+ decimal? nullable = lancamento2.get_ValorPago();
+ valorPago = (nullable.HasValue ? new decimal?(-nullable.GetValueOrDefault()) : null);
+ }
+ else
+ {
+ valorPago = lancamento2.get_ValorPago();
+ }
+ lancamento1.set_ValorPago(valorPago);
+ lancamentos.Add(lancamento2);
+ });
+ IEnumerable<IGrouping<string, Lancamento>> groupings = lancamentos.GroupBy<Lancamento, string>((Lancamento lancamento) => {
+ object descricao;
+ if (this.SinteticoTipo == 1)
+ {
+ Gestor.Model.Domain.Financeiro.Centro centro = lancamento.get_Controle().get_Centro();
+ if (centro != null)
+ {
+ descricao = centro.get_Descricao();
+ }
+ else
+ {
+ descricao = null;
+ }
+ if (descricao == null)
+ {
+ descricao = "";
+ }
+ }
+ else if (this.SinteticoTipo == null)
+ {
+ Gestor.Model.Domain.Financeiro.Planos plano = lancamento.get_Controle().get_Plano();
+ if (plano != null)
+ {
+ descricao = plano.get_Descricao();
+ }
+ else
+ {
+ descricao = null;
+ }
+ if (descricao == null)
+ {
+ return "";
+ }
+ }
+ else
+ {
+ if (this.SinteticoTipo != 3)
+ {
+ Fornecedor fornecedor = lancamento.get_Controle().get_Fornecedor();
+ if (fornecedor != null)
+ {
+ return fornecedor.get_Nome();
+ }
+ return null;
+ }
+ BancosContas conta = lancamento.get_Conta();
+ if (conta != null)
+ {
+ descricao = conta.get_Descricao();
+ }
+ else
+ {
+ descricao = null;
+ }
+ if (descricao == null)
+ {
+ return "";
+ }
+ }
+ return descricao;
+ });
+ List<Gestor.Model.Domain.Relatorios.SinteticoFinanceiro> list = groupings.Select<IGrouping<string, Lancamento>, Gestor.Model.Domain.Relatorios.SinteticoFinanceiro>((IGrouping<string, Lancamento> lancamento) => {
+ Gestor.Model.Domain.Relatorios.SinteticoFinanceiro sinteticoFinanceiro = new Gestor.Model.Domain.Relatorios.SinteticoFinanceiro();
+ sinteticoFinanceiro.set_Agrupamento(lancamento.Key ?? "TRANSFERÊNCIAS");
+ sinteticoFinanceiro.set_Valor(new decimal?(lancamento.Sum<Lancamento>((Lancamento sintetic) => sintetic.get_Valor())));
+ sinteticoFinanceiro.set_ValorPago(new decimal?(lancamento.Sum<Lancamento>((Lancamento sintetic) => sintetic.get_ValorPago()).GetValueOrDefault()));
+ return sinteticoFinanceiro;
+ }).ToList<Gestor.Model.Domain.Relatorios.SinteticoFinanceiro>();
+ List<Gestor.Model.Domain.Relatorios.SinteticoFinanceiro> sinteticoFinanceiros = list;
+ list = (
+ from lancamento in sinteticoFinanceiros
+ orderby lancamento.get_Agrupamento()
+ select lancamento).ToList<Gestor.Model.Domain.Relatorios.SinteticoFinanceiro>();
+ List<Gestor.Model.Domain.Relatorios.SinteticoFinanceiro> sinteticoFinanceiros1 = list;
+ Gestor.Model.Domain.Relatorios.SinteticoFinanceiro sinteticoFinanceiro1 = new Gestor.Model.Domain.Relatorios.SinteticoFinanceiro();
+ sinteticoFinanceiro1.set_Agrupamento("TOTAL");
+ List<Gestor.Model.Domain.Relatorios.SinteticoFinanceiro> sinteticoFinanceiros2 = list;
+ sinteticoFinanceiro1.set_Valor(sinteticoFinanceiros2.Sum<Gestor.Model.Domain.Relatorios.SinteticoFinanceiro>((Gestor.Model.Domain.Relatorios.SinteticoFinanceiro sintetic) => sintetic.get_Valor()));
+ List<Gestor.Model.Domain.Relatorios.SinteticoFinanceiro> sinteticoFinanceiros3 = list;
+ sinteticoFinanceiro1.set_ValorPago(sinteticoFinanceiros3.Sum<Gestor.Model.Domain.Relatorios.SinteticoFinanceiro>((Gestor.Model.Domain.Relatorios.SinteticoFinanceiro sintetic) => sintetic.get_ValorPago()));
+ sinteticoFinanceiros1.Add(sinteticoFinanceiro1);
+ string str2 = await Funcoes.GenerateTable<Gestor.Model.Domain.Relatorios.SinteticoFinanceiro>(list, strs, false, false, "", null);
+ string str3 = Funcoes.CreateCard(string.Concat("SINTÉTICO ", EnumHelper.GetDescription<SinteticoFinanceiroTipo>(this.SinteticoTipo)), str2, false);
+ IEnumerable<IGrouping<string, Lancamento>> groupings1 = lancamentos.GroupBy<Lancamento, string>((Lancamento lancamento) => {
+ object descricao;
+ if (this.SinteticoTipo == 1)
+ {
+ Gestor.Model.Domain.Financeiro.Centro centro = lancamento.get_Controle().get_Centro();
+ if (centro != null)
+ {
+ descricao = centro.get_Descricao();
+ }
+ else
+ {
+ descricao = null;
+ }
+ if (descricao == null)
+ {
+ descricao = "";
+ }
+ }
+ else if (this.SinteticoTipo == null)
+ {
+ Gestor.Model.Domain.Financeiro.Planos plano = lancamento.get_Controle().get_Plano();
+ if (plano != null)
+ {
+ descricao = plano.get_Nome();
+ }
+ else
+ {
+ descricao = null;
+ }
+ if (descricao == null)
+ {
+ return "";
+ }
+ }
+ else
+ {
+ if (this.SinteticoTipo != 3)
+ {
+ Fornecedor fornecedor = lancamento.get_Controle().get_Fornecedor();
+ if (fornecedor != null)
+ {
+ return fornecedor.get_Nome();
+ }
+ return null;
+ }
+ BancosContas conta = lancamento.get_Conta();
+ if (conta != null)
+ {
+ descricao = conta.get_Descricao();
+ }
+ else
+ {
+ descricao = null;
+ }
+ if (descricao == null)
+ {
+ return "";
+ }
+ }
+ return descricao;
+ });
+ List<string> list1 = (
+ from lancamento in groupings1
+ select lancamento.Key).Distinct<string>().ToList<string>();
+ foreach (string str4 in list1)
+ {
+ List<Lancamento> list2 = lancamentos.Where<Lancamento>((Lancamento lancamento) => {
+ string descricao;
+ string nome;
+ string str;
+ string nome1;
+ if (this.SinteticoTipo == 1)
+ {
+ Gestor.Model.Domain.Financeiro.Centro centro = lancamento.get_Controle().get_Centro();
+ if (centro != null)
+ {
+ descricao = centro.get_Descricao();
+ }
+ else
+ {
+ descricao = null;
+ }
+ return descricao == str4;
+ }
+ if (this.SinteticoTipo == null)
+ {
+ Gestor.Model.Domain.Financeiro.Planos plano = lancamento.get_Controle().get_Plano();
+ if (plano != null)
+ {
+ nome = plano.get_Nome();
+ }
+ else
+ {
+ nome = null;
+ }
+ return nome == str4;
+ }
+ if (this.SinteticoTipo == 3)
+ {
+ BancosContas conta = lancamento.get_Conta();
+ if (conta != null)
+ {
+ str = conta.get_Descricao();
+ }
+ else
+ {
+ str = null;
+ }
+ return str == str4;
+ }
+ Fornecedor fornecedor = lancamento.get_Controle().get_Fornecedor();
+ if (fornecedor != null)
+ {
+ nome1 = fornecedor.get_Nome();
+ }
+ else
+ {
+ nome1 = null;
+ }
+ return nome1 == str4;
+ }).ToList<Lancamento>();
+ if (list2.Count == 0)
+ {
+ continue;
+ }
+ List<Lancamento> lancamentos2 = list2;
+ Lancamento lancamento3 = new Lancamento();
+ ControleFinanceiro controleFinanceiro = new ControleFinanceiro();
+ Fornecedor fornecedor1 = new Fornecedor();
+ fornecedor1.set_Nome("TOTAL");
+ controleFinanceiro.set_Fornecedor(fornecedor1);
+ lancamento3.set_Controle(controleFinanceiro);
+ List<Lancamento> lancamentos3 = list2;
+ lancamento3.set_Valor(lancamentos3.Sum<Lancamento>((Lancamento lancamento) => lancamento.get_Valor()));
+ List<Lancamento> lancamentos4 = list2;
+ lancamento3.set_ValorPago(lancamentos4.Sum<Lancamento>((Lancamento lancamento) => lancamento.get_ValorPago()));
+ lancamentos2.Add(lancamento3);
+ string str5 = await Funcoes.GenerateTable<RelatorioLancamentos>(FinanceiroViewModel.GerarRelatorio(list2), new List<string>(), false, false, "", null);
+ str3 = string.Concat(str3, Funcoes.CreateCard(str4, str5, false));
+ }
+ List<ConfiguracaoSistema> configuracoes = Recursos.Configuracoes;
+ num = (configuracoes.Any<ConfiguracaoSistema>((ConfiguracaoSistema x) => x.get_Configuracao() == 14) ? 70 : 50);
+ int num1 = num;
+ TipoRelatorio tipoRelatorio2 = tipoRelatorio1;
+ string str6 = str3;
+ if (str6 == null)
+ {
+ str6 = "";
+ }
+ string str7 = num1.ToString();
+ str1 = (posicao ? "landscape" : "portrait");
+ string str8 = Funcoes.ExportarHtml(tipoRelatorio2, str6, str7, str1, false, "");
+ tipoRelatorio1 = null;
+ str3 = null;
+ return str8;
+ }
+
+ private static List<RelatorioLancamentos> GerarRelatorio(List<Lancamento> lancamentos)
+ {
+ return lancamentos.Select<Lancamento, RelatorioLancamentos>((Lancamento x) => {
+ string nome;
+ string descricao;
+ string str;
+ string descricao1;
+ string str1;
+ string nome1;
+ RelatorioLancamentos relatorioLancamento = new RelatorioLancamentos();
+ Fornecedor fornecedor = x.get_Controle().get_Fornecedor();
+ if (fornecedor != null)
+ {
+ nome = fornecedor.get_Nome();
+ }
+ else
+ {
+ nome = null;
+ }
+ relatorioLancamento.set_Fornecedor(nome);
+ relatorioLancamento.set_Historico(x.get_Historico());
+ relatorioLancamento.set_Observacao(x.get_Observacao());
+ relatorioLancamento.set_Documento(x.get_Documento());
+ relatorioLancamento.set_Parcela(x.get_Parcela());
+ relatorioLancamento.set_Vencimento(x.get_Vencimento());
+ relatorioLancamento.set_Valor(x.get_Valor());
+ relatorioLancamento.set_Baixa(x.get_Baixa());
+ relatorioLancamento.set_ValorPago(x.get_ValorPago());
+ relatorioLancamento.set_Pagamento(x.get_Pagamento());
+ Gestor.Model.Domain.Financeiro.Planos plano = x.get_Controle().get_Plano();
+ if (plano != null)
+ {
+ descricao = plano.get_Descricao();
+ }
+ else
+ {
+ descricao = null;
+ }
+ relatorioLancamento.set_Plano(descricao);
+ Gestor.Model.Domain.Financeiro.Planos plano1 = x.get_Controle().get_Plano();
+ if (plano1 != null)
+ {
+ str = plano1.get_Plano().get_Descricao();
+ }
+ else
+ {
+ str = null;
+ }
+ relatorioLancamento.set_Planos(str);
+ Gestor.Model.Domain.Financeiro.Centro centro = x.get_Controle().get_Centro();
+ if (centro != null)
+ {
+ descricao1 = centro.get_Descricao();
+ }
+ else
+ {
+ descricao1 = null;
+ }
+ relatorioLancamento.set_Centro(descricao1);
+ BancosContas conta = x.get_Conta();
+ if (conta != null)
+ {
+ str1 = conta.get_Descricao();
+ }
+ else
+ {
+ str1 = null;
+ }
+ relatorioLancamento.set_Conta(str1);
+ Fornecedor fornecedor1 = x.get_Controle().get_Fornecedor();
+ if (fornecedor1 != null)
+ {
+ nome1 = fornecedor1.get_Nome();
+ }
+ else
+ {
+ nome1 = null;
+ }
+ relatorioLancamento.set_Sinal((nome1 == "TOTAL" ? "" : EnumHelper.GetDescription<Gestor.Model.Common.Sinal>(x.get_Sinal())));
+ relatorioLancamento.set_Competencia(x.get_Competencia());
+ return relatorioLancamento;
+ }).ToList<RelatorioLancamentos>();
+ }
+
+ public void IncluirLancamento()
+ {
+ Gestor.Model.Common.TipoPagamento? nullable;
+ bool hasValue;
+ bool flag;
+ bool hasValue1;
+ Gestor.Model.Common.TipoPagamento? tipoPagamento;
+ Gestor.Model.Common.Sinal sinal;
+ this.Alterando = Visibility.Visible;
+ this.BuscaHabilitada = false;
+ Fornecedor selectedFornecedor = null;
+ if (this.SelectedFiltro == 3 && this.SelectedFornecedor != null && this.SelectedFornecedor.get_Id() > (long)0)
+ {
+ selectedFornecedor = this.SelectedFornecedor;
+ }
+ this.VisibilityFornecedor = (selectedFornecedor == null ? Visibility.Visible : Visibility.Collapsed);
+ Fornecedor fornecedor = selectedFornecedor;
+ if (fornecedor != null)
+ {
+ hasValue = fornecedor.get_IdPlano().HasValue;
+ }
+ else
+ {
+ hasValue = false;
+ }
+ Gestor.Model.Domain.Financeiro.Planos plano = (hasValue ? this.PlanosFiltrados.FirstOrDefault<Gestor.Model.Domain.Financeiro.Planos>((Gestor.Model.Domain.Financeiro.Planos x) => {
+ long id = x.get_Id();
+ long? idPlano = selectedFornecedor.get_IdPlano();
+ return id == idPlano.GetValueOrDefault() & idPlano.HasValue;
+ }) ?? this.PlanosFiltrados.FirstOrDefault<Gestor.Model.Domain.Financeiro.Planos>() : this.PlanosFiltrados.FirstOrDefault<Gestor.Model.Domain.Financeiro.Planos>());
+ Fornecedor fornecedor1 = selectedFornecedor;
+ if (fornecedor1 != null)
+ {
+ flag = fornecedor1.get_IdConta().HasValue;
+ }
+ else
+ {
+ flag = false;
+ }
+ BancosContas bancosConta = (flag ? this.ContasFiltradas.FirstOrDefault<BancosContas>((BancosContas x) => {
+ long id = x.get_Id();
+ long? idConta = selectedFornecedor.get_IdConta();
+ return id == idConta.GetValueOrDefault() & idConta.HasValue;
+ }) ?? this.ContasFiltradas.FirstOrDefault<BancosContas>() : this.ContasFiltradas.FirstOrDefault<BancosContas>());
+ Fornecedor fornecedor2 = selectedFornecedor;
+ if (fornecedor2 != null)
+ {
+ hasValue1 = fornecedor2.get_IdCentro().HasValue;
+ }
+ else
+ {
+ hasValue1 = false;
+ }
+ Gestor.Model.Domain.Financeiro.Centro centro = (hasValue1 ? this.CentrosFiltrados.FirstOrDefault<Gestor.Model.Domain.Financeiro.Centro>((Gestor.Model.Domain.Financeiro.Centro x) => {
+ long id = x.get_Id();
+ long? idCentro = selectedFornecedor.get_IdCentro();
+ return id == idCentro.GetValueOrDefault() & idCentro.HasValue;
+ }) ?? this.CentrosFiltrados.FirstOrDefault<Gestor.Model.Domain.Financeiro.Centro>() : this.CentrosFiltrados.FirstOrDefault<Gestor.Model.Domain.Financeiro.Centro>());
+ Fornecedor fornecedor3 = selectedFornecedor;
+ if (fornecedor3 != null)
+ {
+ tipoPagamento = fornecedor3.get_TipoPagamento();
+ }
+ else
+ {
+ nullable = null;
+ tipoPagamento = nullable;
+ }
+ nullable = tipoPagamento;
+ Gestor.Model.Common.TipoPagamento valueOrDefault = nullable.GetValueOrDefault();
+ DateTime date = Funcoes.GetNetworkTime().Date;
+ Lancamento lancamento = new Lancamento();
+ ControleFinanceiro controleFinanceiro = new ControleFinanceiro();
+ controleFinanceiro.set_Fornecedor(selectedFornecedor);
+ controleFinanceiro.set_Centro(centro);
+ controleFinanceiro.set_Plano(plano);
+ controleFinanceiro.set_Parcelas(1);
+ lancamento.set_Controle(controleFinanceiro);
+ lancamento.set_Conta(bancosConta);
+ lancamento.set_Vencimento(date);
+ lancamento.set_Parcela(1);
+ lancamento.set_TipoPagamento(valueOrDefault);
+ this.SelectedLancamento = lancamento;
+ this.FornecedorInclusao = selectedFornecedor ?? new Fornecedor();
+ this.Historico = "";
+ this.Documento = "";
+ this.Competencia = "";
+ this.Complemento = "";
+ this.Plano = plano;
+ this.Centro = centro;
+ this.Conta = bancosConta;
+ Gestor.Model.Domain.Financeiro.Planos plano1 = this.Plano;
+ if (plano1 != null)
+ {
+ sinal = plano1.get_Sinal();
+ }
+ else
+ {
+ sinal = 0;
+ }
+ this.Sinal = sinal;
+ this.Parcelas = 1;
+ this.Parcela = 0;
+ this.Vencimento = date;
+ this.Valor = decimal.Zero;
+ DateTime? nullable1 = null;
+ this.Baixa = nullable1;
+ this.ValorPago = new decimal?(new decimal());
+ nullable1 = null;
+ this.Pagamento = nullable1;
+ this.TipoPagamento = valueOrDefault;
+ this.Observacao = "";
+ this.Alteracao = false;
+ this.VisibilityCentro = (this.CentrosFiltrados.Count > 1 ? Visibility.Visible : Visibility.Collapsed);
+ this.VisibilityConta = (this.ContasFiltradas.Count > 1 ? Visibility.Visible : Visibility.Collapsed);
+ }
+
+ public async void IncluirParcela()
+ {
+ bool controle;
+ Visibility visibility;
+ Visibility visibility1;
+ ObservableCollection<Lancamento> lancamentosFiltrados = this.LancamentosFiltrados;
+ if (lancamentosFiltrados.Any<Lancamento>((Lancamento x) => x.get_Selecionado()))
+ {
+ ObservableCollection<Lancamento> observableCollection = this.LancamentosFiltrados;
+ if (observableCollection.Count<Lancamento>((Lancamento x) => x.get_Selecionado()) == 1)
+ {
+ FinanceiroViewModel financeiroViewModel = this;
+ ObservableCollection<Lancamento> lancamentosFiltrados1 = this.LancamentosFiltrados;
+ financeiroViewModel.SelectedLancamento = lancamentosFiltrados1.FirstOrDefault<Lancamento>((Lancamento x) => x.get_Selecionado());
+ }
+ ObservableCollection<Lancamento> observableCollection1 = this.LancamentosFiltrados;
+ if (observableCollection1.Count<Lancamento>((Lancamento x) => x.get_Selecionado()) <= 1)
+ {
+ Lancamento selectedLancamento = this.SelectedLancamento;
+ if (selectedLancamento != null)
+ {
+ controle = selectedLancamento.get_Controle();
+ }
+ else
+ {
+ controle = false;
+ }
+ if (controle && this.SelectedLancamento.get_Controle().get_Id() != 0)
+ {
+ this.VisibilityFornecedor = Visibility.Collapsed;
+ this.Alterando = Visibility.Visible;
+ this.BuscaHabilitada = false;
+ Lancamento lancamento = new Lancamento();
+ ControleFinanceiro controleFinanceiro = new ControleFinanceiro();
+ controleFinanceiro.set_Centro(this.SelectedLancamento.get_Controle().get_Centro());
+ controleFinanceiro.set_Fornecedor(this.SelectedLancamento.get_Controle().get_Fornecedor());
+ controleFinanceiro.set_Historico(this.SelectedLancamento.get_Controle().get_Historico());
+ controleFinanceiro.set_Id(this.SelectedLancamento.get_Controle().get_Id());
+ controleFinanceiro.set_Parcelas(this.SelectedLancamento.get_Controle().get_Parcelas() + 1);
+ controleFinanceiro.set_Plano(this.SelectedLancamento.get_Controle().get_Plano());
+ lancamento.set_Controle(controleFinanceiro);
+ lancamento.set_Historico(this.SelectedLancamento.get_Historico());
+ lancamento.set_Observacao(this.SelectedLancamento.get_Observacao());
+ DateTime vencimento = this.SelectedLancamento.get_Vencimento();
+ lancamento.set_Vencimento(vencimento.AddMonths(1));
+ lancamento.set_Conta(this.SelectedLancamento.get_Conta());
+ lancamento.set_Parcela(this.SelectedLancamento.get_Parcela() + 1);
+ lancamento.set_Documento(this.SelectedLancamento.get_Documento());
+ lancamento.set_Sinal(this.SelectedLancamento.get_Sinal());
+ lancamento.set_TipoPagamento(this.SelectedLancamento.get_TipoPagamento());
+ lancamento.set_Valor(this.SelectedLancamento.get_Valor());
+ this.SelectedLancamento = lancamento;
+ FinanceiroViewModel financeiroViewModel1 = this;
+ visibility = (this.CentrosFiltrados.Count > 1 ? Visibility.Visible : Visibility.Collapsed);
+ financeiroViewModel1.VisibilityCentro = visibility;
+ FinanceiroViewModel financeiroViewModel2 = this;
+ visibility1 = (this.ContasFiltradas.Count > 1 ? Visibility.Visible : Visibility.Collapsed);
+ financeiroViewModel2.VisibilityConta = visibility1;
+ }
+ }
+ else if (await base.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", false))
+ {
+ await this.AdicionarParcelaRange();
+ }
+ }
+ else
+ {
+ await base.ShowMessage("NECESSÁRIO SELECIONAR AO MENOS UM LANCAMENTOS PARA INCLUIR UMA NOVA PARCELA.", "OK", "", false);
+ }
+ }
+
+ public void LimparFiltros()
+ {
+ this.FiltroPersonalizadoSelecionado = null;
+ this.VisibleFiltros = Visibility.Collapsed;
+ }
+
+ public void LimparLancamentos()
+ {
+ this.Lancamentos = new ObservableCollection<Lancamento>();
+ this.LancamentosFiltrados = new ObservableCollection<Lancamento>();
+ this.LimparFiltros();
+ }
+
+ public async Task ParseOfx(BancosContas conta)
+ {
+ FinanceiroViewModel.u003cu003ec__DisplayClass256_1 variable = null;
+ Func<string, bool> func2 = null;
+ this.SelectedStatusImportacao = 2;
+ this.Importando = true;
+ this.VisibleFiltros = Visibility.Collapsed;
+ List<OfxDocument> ofxDocuments = await base.ImportarOfx();
+ if (ofxDocuments == null || ofxDocuments.Count == 0)
+ {
+ this.Importando = false;
+ }
+ else
+ {
+ List<string> strs = new List<string>()
+ {
+ "0237",
+ "033"
+ };
+ List<Lancamento> lancamentos = new List<Lancamento>();
+ foreach (OfxDocument ofxDocument in ofxDocuments)
+ {
+ Tuple<DateTime, DateTime> tuple = this.CorrigeLancamentos(ofxDocument, strs);
+ ofxDocument.set_StatementStart(tuple.Item1);
+ ofxDocument.set_StatementEnd(tuple.Item2);
+ FinanceiroServico financeiroServico = this._servico;
+ DateTime statementStart = ofxDocument.get_StatementStart();
+ DateTime dateTime2 = statementStart.AddDays(-5);
+ statementStart = ofxDocument.get_StatementEnd();
+ List<Lancamento> lancamentos1 = await financeiroServico.BuscarLancamentos(dateTime2, statementStart.AddDays(5), conta.get_Id());
+ List<Lancamento> lancamentos2 = lancamentos1;
+ ofxDocument.get_Transactions().ForEach((Transaction t) => {
+ DateTime dateTime1;
+ bool length;
+ string str;
+ string str1;
+ string str2;
+ string str3;
+ string str4;
+ if (t.get_Date() < ofxDocument.get_StatementStart().AddDays(-5) && t.get_Date() < ofxDocument.get_StatementEnd().AddDays(5))
+ {
+ List<string> cSu0024u003cu003e8_locals1 = strs;
+ Func<string, bool> u003cu003e9_2 = func2;
+ if (u003cu003e9_2 == null)
+ {
+ FinanceiroViewModel.u003cu003ec__DisplayClass256_1 cSu0024u003cu003e8_locals2 = variable;
+ Func<string, bool> func = (string c) => c == this.x.get_Account().get_BankId().Trim();
+ Func<string, bool> func1 = func;
+ cSu0024u003cu003e8_locals2.u003cu003e9__2 = func;
+ u003cu003e9_2 = func1;
+ }
+ if (!cSu0024u003cu003e8_locals1.Any<string>(u003cu003e9_2))
+ {
+ return;
+ }
+ }
+ Gestor.Model.Common.Sinal sinal = (t.get_Amount() < decimal.Zero ? 1 : 0);
+ Lancamento lancamento = lancamentos2.FirstOrDefault<Lancamento>((Lancamento l) => {
+ if ((!l.get_ValorPago().HasValue || !(Math.Abs(l.get_ValorPago().Value) > decimal.Zero) || !(Math.Abs(l.get_ValorPago().Value) == Math.Abs(t.get_Amount()))) && !(Math.Abs(l.get_Valor()) == Math.Abs(t.get_Amount())) || l.get_Sinal() != sinal || l.get_Documento() == null || !t.get_TransactionId().Contains(l.get_Documento()))
+ {
+ return false;
+ }
+ DateTime? pagamento = l.get_Pagamento();
+ DateTime date = t.get_Date();
+ if ((pagamento.HasValue ? pagamento.GetValueOrDefault() == date : false) || l.get_Vencimento() == t.get_Date())
+ {
+ return true;
+ }
+ DateTime vencimento = l.get_Vencimento();
+ date = t.get_Date();
+ if (vencimento < date.AddDays(-5))
+ {
+ return false;
+ }
+ DateTime dateTime = l.get_Vencimento();
+ date = t.get_Date();
+ return dateTime <= date.AddDays(5);
+ });
+ Gestor.Model.Common.TipoPagamento tipoPagamento = t.get_TransType().ParseTransactionType();
+ string transactionId = t.get_TransactionId();
+ length = (transactionId != null ? transactionId.Trim().Length > 50 : false);
+ if (length)
+ {
+ string transactionId1 = t.get_TransactionId();
+ if (transactionId1 != null)
+ {
+ string str5 = transactionId1.Trim();
+ if (str5 != null)
+ {
+ str = str5.Substring(0, 50);
+ }
+ else
+ {
+ str = null;
+ }
+ }
+ else
+ {
+ str = null;
+ }
+ }
+ else
+ {
+ string transactionId2 = t.get_TransactionId();
+ if (transactionId2 != null)
+ {
+ str = transactionId2.Trim();
+ }
+ else
+ {
+ str = null;
+ }
+ }
+ string str6 = str;
+ if (lancamento == null)
+ {
+ Lancamento lancamento1 = new Lancamento();
+ ControleFinanceiro controleFinanceiro = new ControleFinanceiro();
+ controleFinanceiro.set_Fornecedor(null);
+ controleFinanceiro.set_Centro(this.Centros.FirstOrDefault<Gestor.Model.Domain.Financeiro.Centro>());
+ controleFinanceiro.set_Plano(null);
+ controleFinanceiro.set_Parcelas(1);
+ string memo = t.get_Memo();
+ if (memo != null)
+ {
+ str1 = memo.Trim();
+ }
+ else
+ {
+ str1 = null;
+ }
+ controleFinanceiro.set_Historico(str1);
+ lancamento1.set_Controle(controleFinanceiro);
+ lancamento1.set_Valor(Math.Abs(t.get_Amount()));
+ lancamento1.set_ValorPago(new decimal?(Math.Abs(t.get_Amount())));
+ string memo1 = t.get_Memo();
+ if (memo1 != null)
+ {
+ str2 = memo1.Trim();
+ }
+ else
+ {
+ str2 = null;
+ }
+ lancamento1.set_Historico(str2);
+ lancamento1.set_Sinal((t.get_Amount() < decimal.Zero ? 1 : 0));
+ lancamento1.set_Conta(conta);
+ lancamento1.set_Vencimento(t.get_Date());
+ lancamento1.set_Baixa(new DateTime?(t.get_Date()));
+ lancamento1.set_Pagamento(new DateTime?(t.get_Date()));
+ string transactionId3 = t.get_TransactionId();
+ if (transactionId3 != null)
+ {
+ str3 = transactionId3.Trim();
+ }
+ else
+ {
+ str3 = null;
+ }
+ lancamento1.set_Documento(str3);
+ lancamento1.set_TipoPagamento(tipoPagamento);
+ dateTime1 = t.get_Date();
+ lancamento1.set_Competencia(dateTime1.ToString("MM/yyyy"));
+ lancamento1.set_Parcela(1);
+ string transactionId4 = t.get_TransactionId();
+ if (transactionId4 != null)
+ {
+ str4 = transactionId4.Trim();
+ }
+ else
+ {
+ str4 = null;
+ }
+ lancamento1.set_CodigoBanco(str4);
+ lancamento1.set_Baixado(false);
+ lancamento = lancamento1;
+ }
+ else
+ {
+ lancamento.set_Baixado(lancamento.get_Baixa().HasValue);
+ lancamento.set_Conta(conta);
+ lancamento.set_ValorPago(new decimal?(Math.Abs(t.get_Amount())));
+ dateTime1 = t.get_Date();
+ lancamento.set_Competencia(dateTime1.ToString("MM/yyyy"));
+ lancamento.set_Baixa((!lancamento.get_Baixa().HasValue ? new DateTime?(t.get_Date()) : lancamento.get_Baixa()));
+ lancamento.set_Pagamento((!lancamento.get_Pagamento().HasValue ? new DateTime?(t.get_Date()) : lancamento.get_Pagamento()));
+ lancamento.set_Documento(str6);
+ lancamento.set_CodigoBanco(t.get_TransactionId());
+ lancamento.set_TipoPagamento((lancamento.get_TipoPagamento() == null ? tipoPagamento : lancamento.get_TipoPagamento()));
+ }
+ lancamentos.Add(lancamento);
+ });
+ }
+ this.Lancamentos = new ObservableCollection<Lancamento>(lancamentos);
+ this.LancamentosFiltrados = this.Lancamentos;
+ ExtensionMethods.ForEach<Lancamento>(this.LancamentosFiltrados, (Lancamento x) => this.SelecionarLancamento(x));
+ this.LancamentosFiltradosCopia = this.LancamentosFiltrados;
+ }
+ }
+
+ public void PesquisaPersonalizada()
+ {
+ List<Gestor.Model.Domain.Relatorios.FiltroPersonalizado> list = (
+ from x in this.PersonalizadoSelecionado
+ where !x.get_Propriedade().Contains(".")
+ select x).ToList<Gestor.Model.Domain.Relatorios.FiltroPersonalizado>();
+ List<Lancamento> list1 = this.Lancamentos.ToList<Lancamento>().CustomWhere<Lancamento>(list, false);
+ (
+ from x in this.PersonalizadoSelecionado
+ where x.get_Propriedade().Contains(".")
+ select x).ToList<Gestor.Model.Domain.Relatorios.FiltroPersonalizado>().ForEach((Gestor.Model.Domain.Relatorios.FiltroPersonalizado x) => {
+ string str = x.get_Nome();
+ if (str == "FORNECEDOR")
+ {
+ list1 = list1.Where<Lancamento>((Lancamento l) => {
+ bool nomeSocial;
+ ControleFinanceiro controle = l.get_Controle();
+ if (controle != null)
+ {
+ Fornecedor fornecedor = controle.get_Fornecedor();
+ nomeSocial = (fornecedor != null ? fornecedor.get_NomeSocial() : false);
+ }
+ else
+ {
+ nomeSocial = false;
+ }
+ if (!nomeSocial)
+ {
+ return false;
+ }
+ return Gestor.Common.Validation.ValidationHelper.AlphanumericAndSpace(l.get_Controle().get_Fornecedor().get_NomeSocial().ToLower().Trim()).Contains(Gestor.Common.Validation.ValidationHelper.AlphanumericAndSpace(x.get_ValorIncial().ToLower().Trim()));
+ }).ToList<Lancamento>();
+ return;
+ }
+ if (str == "FORNECEDOR ATIVO")
+ {
+ if (x.get_ValorIncial().Trim().Equals("SIM"))
+ {
+ List<Lancamento> lancamentos = list1;
+ Func<Lancamento, bool> u003cu003e9_3584 = FinanceiroViewModel.u003cu003ec.u003cu003e9__358_4;
+ if (u003cu003e9_3584 == null)
+ {
+ u003cu003e9_3584 = (Lancamento l) => {
+ bool flag;
+ ControleFinanceiro controle = l.get_Controle();
+ if (controle != null)
+ {
+ Fornecedor fornecedor = controle.get_Fornecedor();
+ if (fornecedor != null)
+ {
+ fornecedor.get_Ativo();
+ flag = true;
+ }
+ else
+ {
+ flag = false;
+ }
+ }
+ else
+ {
+ flag = false;
+ }
+ if (!flag)
+ {
+ return false;
+ }
+ return l.get_Controle().get_Fornecedor().get_Ativo();
+ };
+ FinanceiroViewModel.u003cu003ec.u003cu003e9__358_4 = u003cu003e9_3584;
+ }
+ list1 = lancamentos.Where<Lancamento>(u003cu003e9_3584).ToList<Lancamento>();
+ return;
+ }
+ if (x.get_ValorIncial().Equals("NÃO"))
+ {
+ List<Lancamento> lancamentos1 = list1;
+ Func<Lancamento, bool> u003cu003e9_3585 = FinanceiroViewModel.u003cu003ec.u003cu003e9__358_5;
+ if (u003cu003e9_3585 == null)
+ {
+ u003cu003e9_3585 = (Lancamento l) => {
+ bool flag;
+ ControleFinanceiro controle = l.get_Controle();
+ if (controle != null)
+ {
+ Fornecedor fornecedor = controle.get_Fornecedor();
+ if (fornecedor != null)
+ {
+ fornecedor.get_Ativo();
+ flag = true;
+ }
+ else
+ {
+ flag = false;
+ }
+ }
+ else
+ {
+ flag = false;
+ }
+ if (!flag)
+ {
+ return false;
+ }
+ return !l.get_Controle().get_Fornecedor().get_Ativo();
+ };
+ FinanceiroViewModel.u003cu003ec.u003cu003e9__358_5 = u003cu003e9_3585;
+ }
+ list1 = lancamentos1.Where<Lancamento>(u003cu003e9_3585).ToList<Lancamento>();
+ return;
+ }
+ }
+ else
+ {
+ if (str == "CONTA")
+ {
+ list1 = list1.Where<Lancamento>((Lancamento l) => {
+ bool descricao;
+ BancosContas conta = l.get_Conta();
+ descricao = (conta != null ? conta.get_Descricao() : false);
+ if (!descricao)
+ {
+ return false;
+ }
+ return Gestor.Common.Validation.ValidationHelper.AlphanumericAndSpace(l.get_Conta().get_Descricao().ToLower().Trim()).Contains(Gestor.Common.Validation.ValidationHelper.AlphanumericAndSpace(x.get_ValorIncial().ToLower().Trim()));
+ }).ToList<Lancamento>();
+ return;
+ }
+ if (str == "PLANO DE CONTAS")
+ {
+ list1 = list1.Where<Lancamento>((Lancamento l) => {
+ bool descricao;
+ ControleFinanceiro controle = l.get_Controle();
+ if (controle != null)
+ {
+ Gestor.Model.Domain.Financeiro.Planos plano = controle.get_Plano();
+ descricao = (plano != null ? plano.get_Descricao() : false);
+ }
+ else
+ {
+ descricao = false;
+ }
+ if (!descricao)
+ {
+ return false;
+ }
+ return Gestor.Common.Validation.ValidationHelper.AlphanumericAndSpace(l.get_Controle().get_Plano().get_Descricao().ToLower().Trim()).Contains(Gestor.Common.Validation.ValidationHelper.AlphanumericAndSpace(x.get_ValorIncial().ToLower().Trim()));
+ }).ToList<Lancamento>();
+ return;
+ }
+ if (str == "CENTRO DE CUSTO")
+ {
+ list1 = list1.Where<Lancamento>((Lancamento l) => {
+ bool descricao;
+ ControleFinanceiro controle = l.get_Controle();
+ if (controle != null)
+ {
+ Gestor.Model.Domain.Financeiro.Centro centro = controle.get_Centro();
+ descricao = (centro != null ? centro.get_Descricao() : false);
+ }
+ else
+ {
+ descricao = false;
+ }
+ if (!descricao)
+ {
+ return false;
+ }
+ return Gestor.Common.Validation.ValidationHelper.AlphanumericAndSpace(l.get_Controle().get_Centro().get_Descricao().ToLower().Trim()).Contains(Gestor.Common.Validation.ValidationHelper.AlphanumericAndSpace(x.get_ValorIncial().ToLower().Trim()));
+ }).ToList<Lancamento>();
+ return;
+ }
+ if (str != "PLANO")
+ {
+ return;
+ }
+ list1 = list1.Where<Lancamento>((Lancamento l) => {
+ bool nome;
+ ControleFinanceiro controle = l.get_Controle();
+ if (controle != null)
+ {
+ Gestor.Model.Domain.Financeiro.Planos plano = controle.get_Plano();
+ nome = (plano != null ? plano.get_Nome() : false);
+ }
+ else
+ {
+ nome = false;
+ }
+ if (!nome)
+ {
+ return false;
+ }
+ return Gestor.Common.Validation.ValidationHelper.AlphanumericAndSpace(l.get_Controle().get_Plano().get_Nome().ToLower().Trim()).Contains(Gestor.Common.Validation.ValidationHelper.AlphanumericAndSpace(x.get_ValorIncial().ToLower().Trim()));
+ }).ToList<Lancamento>();
+ }
+ });
+ this.LancamentosFiltrados = new ObservableCollection<Lancamento>(list1);
+ }
+
+ public async void PopularFiltro()
+ {
+ if (this.FiltroPersonalizado == null || this.FiltroPersonalizado.Count <= 0)
+ {
+ this.FiltroPersonalizado = new List<Gestor.Model.Domain.Financeiro.FiltroPersonalizado>();
+ List<Fornecedor> fornecedors = await (new BaseServico()).BuscarFornecedor();
+ List<Gestor.Model.Domain.Financeiro.FiltroPersonalizado> list = fornecedors.Select<Fornecedor, Gestor.Model.Domain.Financeiro.FiltroPersonalizado>((Fornecedor x) => {
+ Gestor.Model.Domain.Financeiro.FiltroPersonalizado filtroPersonalizado = new Gestor.Model.Domain.Financeiro.FiltroPersonalizado();
+ filtroPersonalizado.set_Tipo(0);
+ filtroPersonalizado.set_Descricao(string.Concat(x.get_Nome(), " ", x.get_Documento()));
+ filtroPersonalizado.set_Id(x.get_Id());
+ return filtroPersonalizado;
+ }).ToList<Gestor.Model.Domain.Financeiro.FiltroPersonalizado>();
+ this.FiltroPersonalizado.AddRange(list);
+ List<Gestor.Model.Domain.Financeiro.Centro> centros = this.Centros;
+ list = centros.Select<Gestor.Model.Domain.Financeiro.Centro, Gestor.Model.Domain.Financeiro.FiltroPersonalizado>((Gestor.Model.Domain.Financeiro.Centro x) => {
+ Gestor.Model.Domain.Financeiro.FiltroPersonalizado filtroPersonalizado = new Gestor.Model.Domain.Financeiro.FiltroPersonalizado();
+ filtroPersonalizado.set_Tipo(2);
+ filtroPersonalizado.set_Descricao(x.get_Descricao());
+ filtroPersonalizado.set_Id(x.get_Id());
+ return filtroPersonalizado;
+ }).ToList<Gestor.Model.Domain.Financeiro.FiltroPersonalizado>();
+ this.FiltroPersonalizado.AddRange(list);
+ List<Gestor.Model.Domain.Financeiro.Planos> planos = this.Planos;
+ list = planos.Select<Gestor.Model.Domain.Financeiro.Planos, Gestor.Model.Domain.Financeiro.FiltroPersonalizado>((Gestor.Model.Domain.Financeiro.Planos x) => {
+ Gestor.Model.Domain.Financeiro.FiltroPersonalizado filtroPersonalizado = new Gestor.Model.Domain.Financeiro.FiltroPersonalizado();
+ filtroPersonalizado.set_Tipo(1);
+ filtroPersonalizado.set_Descricao(x.get_Descricao());
+ filtroPersonalizado.set_Id(x.get_Id());
+ return filtroPersonalizado;
+ }).ToList<Gestor.Model.Domain.Financeiro.FiltroPersonalizado>();
+ this.FiltroPersonalizado.AddRange(list);
+ List<BancosContas> contas = this.Contas;
+ list = contas.Select<BancosContas, Gestor.Model.Domain.Financeiro.FiltroPersonalizado>((BancosContas x) => {
+ Gestor.Model.Domain.Financeiro.FiltroPersonalizado filtroPersonalizado = new Gestor.Model.Domain.Financeiro.FiltroPersonalizado();
+ filtroPersonalizado.set_Tipo(3);
+ filtroPersonalizado.set_Descricao(x.get_Descricao());
+ filtroPersonalizado.set_Id(x.get_Id());
+ return filtroPersonalizado;
+ }).ToList<Gestor.Model.Domain.Financeiro.FiltroPersonalizado>();
+ this.FiltroPersonalizado.AddRange(list);
+ List<Gestor.Model.Domain.Financeiro.FiltroPersonalizado> filtroPersonalizados = this.FiltroPersonalizado;
+ Gestor.Model.Domain.Financeiro.FiltroPersonalizado filtroPersonalizado1 = new Gestor.Model.Domain.Financeiro.FiltroPersonalizado();
+ filtroPersonalizado1.set_Descricao(EnumHelper.GetDescription<Gestor.Model.Common.Sinal>(0));
+ filtroPersonalizado1.set_Id((long)0);
+ filtroPersonalizado1.set_Tipo(4);
+ filtroPersonalizados.Add(filtroPersonalizado1);
+ List<Gestor.Model.Domain.Financeiro.FiltroPersonalizado> filtroPersonalizados1 = this.FiltroPersonalizado;
+ Gestor.Model.Domain.Financeiro.FiltroPersonalizado filtroPersonalizado2 = new Gestor.Model.Domain.Financeiro.FiltroPersonalizado();
+ filtroPersonalizado2.set_Descricao(EnumHelper.GetDescription<Gestor.Model.Common.Sinal>(1));
+ filtroPersonalizado2.set_Id((long)1);
+ filtroPersonalizado2.set_Tipo(4);
+ filtroPersonalizados1.Add(filtroPersonalizado2);
+ }
+ }
+
+ public async Task Print(List<Lancamento> relatorioGrid, bool posicao = false)
+ {
+ string tempPath = Path.GetTempPath();
+ string str = await this.GerarHtml(relatorioGrid, posicao);
+ string str1 = string.Format("{0}RELATORIO FINANCEIRO_{1:ddMMyyyyhhmmss}.html", tempPath, Funcoes.GetNetworkTime());
+ StreamWriter streamWriter = new StreamWriter(str1, true, Encoding.UTF8);
+ streamWriter.Write(str);
+ streamWriter.Close();
+ Process.Start(str1);
+ tempPath = null;
+ }
+
+ public async Task<List<KeyValuePair<string, string>>> Salvar(Transferencia transferencia)
+ {
+ List<KeyValuePair<string, string>> keyValuePairs;
+ List<KeyValuePair<string, string>> keyValuePairs1 = transferencia.Validate();
+ List<KeyValuePair<string, string>> keyValuePairs2 = keyValuePairs1;
+ keyValuePairs2.AddRange(await this.Validar(transferencia));
+ keyValuePairs2 = null;
+ if (keyValuePairs1.Count <= 0)
+ {
+ ControleFinanceiro controleFinanceiro = new ControleFinanceiro();
+ controleFinanceiro.set_Historico("TRANSFERÊNCIA ENTRE CONTAS");
+ controleFinanceiro.set_Parcelas(2);
+ ControleFinanceiro controleFinanceiro1 = controleFinanceiro;
+ Lancamento lancamento = new Lancamento();
+ lancamento.set_Controle(controleFinanceiro1);
+ lancamento.set_Historico("TRANSFERÊNCIA ENTRE CONTAS");
+ lancamento.set_Vencimento(transferencia.get_Data());
+ lancamento.set_Conta(transferencia.get_Origem());
+ lancamento.set_Valor(transferencia.get_Valor());
+ lancamento.set_ValorPago(new decimal?(transferencia.get_Valor()));
+ lancamento.set_Pagamento(new DateTime?(transferencia.get_Data()));
+ lancamento.set_Baixa(new DateTime?(transferencia.get_Data()));
+ lancamento.set_Parcela(1);
+ lancamento.set_Sinal(1);
+ lancamento.set_TipoPagamento(11);
+ Lancamento lancamento1 = lancamento;
+ Lancamento lancamento2 = new Lancamento();
+ lancamento2.set_Controle(controleFinanceiro1);
+ lancamento2.set_Historico("TRANSFERÊNCIA ENTRE CONTAS");
+ lancamento2.set_Vencimento(transferencia.get_Data());
+ lancamento2.set_Conta(transferencia.get_Destino());
+ lancamento2.set_Valor(transferencia.get_Valor());
+ lancamento2.set_ValorPago(new decimal?(transferencia.get_Valor()));
+ lancamento2.set_Pagamento(new DateTime?(transferencia.get_Data()));
+ lancamento2.set_Baixa(new DateTime?(transferencia.get_Data()));
+ lancamento2.set_Parcela(2);
+ lancamento2.set_Sinal(0);
+ lancamento2.set_TipoPagamento(11);
+ if (await this._servico.Transferir(lancamento1, lancamento2))
+ {
+ await this.CarregarSaldos();
+ base.ToggleSnackBar("TRANSFERÊNCIA REALIZADA COM SUCESSO", true);
+ keyValuePairs = null;
+ }
+ else
+ {
+ keyValuePairs = null;
+ }
+ }
+ else
+ {
+ keyValuePairs = keyValuePairs1;
+ }
+ keyValuePairs1 = null;
+ return keyValuePairs;
+ }
+
+ public async Task<List<KeyValuePair<string, string>>> Salvar()
+ {
+ List<KeyValuePair<string, string>> keyValuePairs;
+ DateTime? nullable;
+ DateTime vencimento;
+ decimal? nullable1;
+ DateTime? pagamento;
+ DateTime? baixa;
+ string str;
+ long? nullable2;
+ object historico;
+ bool flag;
+ long num;
+ List<KeyValuePair<string, string>> keyValuePairs1 = this.SelectedLancamento.Validate();
+ if (keyValuePairs1 == null)
+ {
+ keyValuePairs1 = new List<KeyValuePair<string, string>>();
+ }
+ List<KeyValuePair<string, string>> keyValuePairs2 = keyValuePairs1;
+ List<KeyValuePair<string, string>> keyValuePairs3 = keyValuePairs2;
+ keyValuePairs3.AddRange(await this.Validar());
+ keyValuePairs3 = null;
+ if (keyValuePairs2.Count > 0)
+ {
+ keyValuePairs = keyValuePairs2;
+ }
+ else if (this.SelectedLancamento.get_Controle().get_Id() != (long)0 || this.SelectedLancamento.get_Controle().get_Parcelas() <= 0)
+ {
+ if (this.SelectedLancamento.get_Controle().get_Id() == 0)
+ {
+ this.VencimentoAlterado = false;
+ }
+ this.SelectedLancamento = await this._servico.Save(this.SelectedLancamento);
+ if (this.VencimentoAlterado && this.SelectedLancamento.get_Controle().get_Parcelas() > 1)
+ {
+ if (await base.ShowMessage("DESEJA ALTERAR O VENCIMENTO PARA OS PRÓXIMOS LANÇAMENTOS?", "SIM", "NÃO", false))
+ {
+ await this.AlterarLancamentos(this.SelectedLancamento, true, false);
+ }
+ this.VencimentoAlterado = false;
+ }
+ if (this.SelectedLancamento.get_Controle().get_Parcelas() > 1)
+ {
+ if (await base.ShowMessage("DESEJA ALTERAR O VALOR PARA OS PRÓXIMOS LANÇAMENTOS?", "SIM", "NÃO", false))
+ {
+ await this.AlterarLancamentos(this.SelectedLancamento, false, true);
+ }
+ }
+ if (this._servico.Sucesso)
+ {
+ await this.Buscar();
+ base.ToggleSnackBar("LANÇAMENTO SALVO COM SUCESSO", true);
+ keyValuePairs = null;
+ }
+ else
+ {
+ keyValuePairs = null;
+ }
+ }
+ else
+ {
+ List<Lancamento> lancamentos = new List<Lancamento>();
+ for (int i = 1; i <= this.SelectedLancamento.get_Controle().get_Parcelas(); i++)
+ {
+ Lancamento lancamento = new Lancamento();
+ ControleFinanceiro controleFinanceiro = new ControleFinanceiro();
+ controleFinanceiro.set_Centro(this.SelectedLancamento.get_Controle().get_Centro());
+ controleFinanceiro.set_Fornecedor(this.SelectedLancamento.get_Controle().get_Fornecedor());
+ controleFinanceiro.set_Historico(this.SelectedLancamento.get_Controle().get_Historico());
+ controleFinanceiro.set_Id(this.SelectedLancamento.get_Controle().get_Id());
+ controleFinanceiro.set_Parcelas(this.SelectedLancamento.get_Controle().get_Parcelas());
+ controleFinanceiro.set_Plano(this.SelectedLancamento.get_Controle().get_Plano());
+ lancamento.set_Controle(controleFinanceiro);
+ lancamento.set_Historico(this.SelectedLancamento.get_Historico());
+ lancamento.set_Observacao(this.SelectedLancamento.get_Observacao());
+ lancamento.set_Complemento(this.SelectedLancamento.get_Complemento());
+ lancamento.set_Competencia(this.SelectedLancamento.get_Competencia());
+ if (i == 1)
+ {
+ vencimento = this.SelectedLancamento.get_Vencimento();
+ }
+ else
+ {
+ DateTime dateTime = this.SelectedLancamento.get_Vencimento();
+ vencimento = dateTime.AddMonths(i - 1);
+ }
+ lancamento.set_Vencimento(vencimento);
+ lancamento.set_Conta(this.SelectedLancamento.get_Conta());
+ nullable1 = (i == 1 ? this.SelectedLancamento.get_ValorPago() : new decimal?(new decimal()));
+ lancamento.set_ValorPago(nullable1);
+ if (i == 1)
+ {
+ pagamento = this.SelectedLancamento.get_Pagamento();
+ }
+ else
+ {
+ nullable = null;
+ pagamento = nullable;
+ }
+ lancamento.set_Pagamento(pagamento);
+ if (i == 1)
+ {
+ baixa = this.SelectedLancamento.get_Baixa();
+ }
+ else
+ {
+ nullable = null;
+ baixa = nullable;
+ }
+ lancamento.set_Baixa(baixa);
+ lancamento.set_Parcela(i);
+ str = (i == 1 ? this.SelectedLancamento.get_Documento() : "");
+ lancamento.set_Documento(str);
+ lancamento.set_Sinal(this.SelectedLancamento.get_Sinal());
+ lancamento.set_TipoPagamento(this.SelectedLancamento.get_TipoPagamento());
+ lancamento.set_Valor(this.SelectedLancamento.get_Valor());
+ lancamentos.Add(lancamento);
+ }
+ List<Lancamento> lancamentos1 = await this._servico.AddRange(lancamentos);
+ this.SelectedLancamento = lancamentos1.FirstOrDefault<Lancamento>();
+ FinanceiroViewModel financeiroViewModel = this;
+ Lancamento selectedLancamento = this.SelectedLancamento;
+ if (selectedLancamento != null)
+ {
+ nullable2 = new long?(selectedLancamento.get_Id());
+ }
+ else
+ {
+ nullable2 = null;
+ }
+ object obj = nullable2;
+ Lancamento selectedLancamento1 = this.SelectedLancamento;
+ if (selectedLancamento1 != null)
+ {
+ historico = selectedLancamento1.get_Historico();
+ }
+ else
+ {
+ historico = null;
+ }
+ string str1 = string.Format("INSERIU O LANÇAMENTO DO ID {0} HISTORICO: {1}", obj, historico);
+ Lancamento lancamento1 = this.SelectedLancamento;
+ if (lancamento1 != null)
+ {
+ lancamento1.get_Id();
+ flag = false;
+ }
+ else
+ {
+ flag = true;
+ }
+ num = (flag ? (long)0 : this.SelectedLancamento.get_Id());
+ financeiroViewModel.RegistrarAcao(str1, num, new TipoTela?(25), null);
+ this.VencimentoAlterado = false;
+ keyValuePairs = null;
+ }
+ keyValuePairs2 = null;
+ return keyValuePairs;
+ }
+
+ public async Task<bool> SalvarImportacao(List<Lancamento> list)
+ {
+ bool flag;
+ DateTime? baixa;
+ DateTime? nullable;
+ string[] strArrays;
+ bool flag1;
+ bool flag2;
+ string historico;
+ object obj;
+ bool flag3;
+ long num;
+ Lancamento lancamento = null;
+ List<Lancamento> lancamentos = new List<Lancamento>();
+ List<Lancamento> lancamentos1 = new List<Lancamento>();
+ List<Lancamento> lancamentos2 = new List<Lancamento>();
+ List<Lancamento> lancamentos3 = new List<Lancamento>();
+ foreach (Lancamento lancamento in list)
+ {
+ if (lancamento.get_Baixado())
+ {
+ continue;
+ }
+ if (!lancamento.get_Selecionado())
+ {
+ baixa = null;
+ lancamento.set_Baixa(baixa);
+ }
+ baixa = lancamento.get_Baixa();
+ if (baixa.HasValue)
+ {
+ Saldo saldo = await this.VerificaSaldo(lancamento.get_Conta().get_Id(), false);
+ if (saldo == null)
+ {
+ continue;
+ }
+ baixa = saldo.get_DataInicio();
+ nullable = lancamento.get_Baixa();
+ flag1 = (baixa.HasValue & nullable.HasValue ? baixa.GetValueOrDefault() > nullable.GetValueOrDefault() : false);
+ if (flag1)
+ {
+ continue;
+ }
+ }
+ string observacao = lancamento.get_Observacao();
+ if (observacao != null)
+ {
+ strArrays = observacao.Split(new char[] { '\n' });
+ }
+ else
+ {
+ strArrays = null;
+ }
+ string[] strArrays1 = strArrays;
+ StringBuilder stringBuilder = new StringBuilder();
+ string str = "IMPORTAÇÃO OFX REALIZADA PELO USUÁRIO";
+ if (strArrays1 != null)
+ {
+ string[] strArrays2 = strArrays1;
+ for (int i = 0; i < (int)strArrays2.Length; i++)
+ {
+ string str1 = strArrays2[i];
+ if (str1.IndexOf(str, StringComparison.InvariantCulture) != 0)
+ {
+ stringBuilder.Append(string.Concat(str1, "\n"));
+ }
+ }
+ }
+ Lancamento lancamento1 = lancamento;
+ object[] id = new object[] { stringBuilder, Recursos.Usuario.get_Id(), Recursos.Usuario.get_Nome(), null };
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ id[3] = networkTime.ToString("F").ToUpper();
+ lancamento1.set_Observacao(string.Format("{0}IMPORTAÇÃO OFX REALIZADA PELO USUÁRIO {1} {2} EM {3}", id));
+ if (lancamento.get_Id() <= (long)0)
+ {
+ lancamentos2.Add(lancamento);
+ }
+ else
+ {
+ nullable = lancamento.get_Baixa();
+ if (!nullable.HasValue)
+ {
+ lancamentos.Add(lancamento);
+ }
+ else
+ {
+ lancamentos1.Add(lancamento);
+ }
+ }
+ lancamentos3.Add(lancamento);
+ }
+ if (lancamentos3.Count != 0)
+ {
+ object[] count = new object[] { lancamentos2.Count, Environment.NewLine, lancamentos.Count, Environment.NewLine, lancamentos1.Count, Environment.NewLine, Environment.NewLine };
+ if (await base.ShowMessage(string.Format("{0} LANÇAMENTOS SERÃO CRIADOS.{1}{2} LANÇAMENTOS SERÃO ATUALIZADOS.{3}{4} LANÇAMENTOS SERÃO BAIXADOS.{5}{6}DESEJA REALMENTE PROSSEGUIR?", count), "SIM", "NÃO", false))
+ {
+ bool flag4 = true;
+ foreach (Lancamento lancamento2 in lancamentos3)
+ {
+ await this._servico.Save(lancamento2);
+ flag4 = (flag4 ? this._servico.Sucesso : false);
+ flag2 = (lancamento2 == null ? false : lancamento2.get_Id() != (long)0);
+ if (flag2 & flag4)
+ {
+ FinanceiroViewModel financeiroViewModel = this;
+ object id1 = lancamento2.get_Id();
+ Lancamento lancamento3 = lancamento2;
+ if (lancamento3 != null)
+ {
+ obj = lancamento3.get_Historico();
+ }
+ else
+ {
+ obj = null;
+ }
+ string str2 = string.Format("BAIXOU/ATUALIZOU O LANÇAMENTO DO ID {0}POR IMPORTAÇÃO HISTORICO: {1}", id1, obj);
+ Lancamento lancamento4 = lancamento2;
+ if (lancamento4 != null)
+ {
+ lancamento4.get_Id();
+ flag3 = false;
+ }
+ else
+ {
+ flag3 = true;
+ }
+ num = (flag3 ? (long)0 : lancamento2.get_Id());
+ financeiroViewModel.RegistrarAcao(str2, num, new TipoTela?(25), null);
+ }
+ else if (lancamento2 != null & flag4)
+ {
+ FinanceiroViewModel financeiroViewModel1 = this;
+ Lancamento lancamento5 = lancamento2;
+ if (lancamento5 != null)
+ {
+ historico = lancamento5.get_Historico();
+ }
+ else
+ {
+ historico = null;
+ }
+ financeiroViewModel1.RegistrarAcao(string.Concat("INSERIU O LANÇAMENTO POR IMPORTAÇÃO HISTORICO: ", historico), (long)0, new TipoTela?(25), null);
+ }
+ }
+ if (flag4)
+ {
+ await this.Buscar();
+ base.ToggleSnackBar("ATUALIZAÇÃO REALIZADA COM SUCESSO", true);
+ await this.CarregarSaldos();
+ flag = true;
+ }
+ else
+ {
+ await base.ShowMessage("HOUVERAM PROBLEMAS AO INCLUIR OU ATUALIZAR LANÇAMENTOS, FAVOR CONFERIR A IMPORTAÇÃO.", "OK", "", false);
+ flag = false;
+ }
+ }
+ else
+ {
+ base.Loading(false);
+ flag = false;
+ }
+ }
+ else
+ {
+ await base.ShowMessage("NÃO HÁ LANÇAMENTOS PARA SEREM ATUALIZADOS.", "OK", "", false);
+ base.Loading(false);
+ flag = false;
+ }
+ lancamentos = null;
+ lancamentos1 = null;
+ lancamentos2 = null;
+ lancamentos3 = null;
+ return flag;
+ }
+
+ public void SelecionarLancamento(Lancamento lancamento)
+ {
+ Lancamento lancamento1 = (lancamento.get_Id() > (long)0 ? this.LancamentosFiltrados.First<Lancamento>((Lancamento x) => x.get_Id() == lancamento.get_Id()) : this.LancamentosFiltrados.First<Lancamento>((Lancamento x) => {
+ long? nullable;
+ long? nullable1;
+ long? nullable2;
+ long? nullable3;
+ long? nullable4;
+ if (x.get_Id() == lancamento.get_Id())
+ {
+ ControleFinanceiro controle = x.get_Controle();
+ if (controle != null)
+ {
+ Fornecedor fornecedor = controle.get_Fornecedor();
+ if (fornecedor != null)
+ {
+ nullable1 = new long?(fornecedor.get_Id());
+ }
+ else
+ {
+ nullable = null;
+ nullable1 = nullable;
+ }
+ }
+ else
+ {
+ nullable = null;
+ nullable1 = nullable;
+ }
+ long? nullable5 = nullable1;
+ ControleFinanceiro controleFinanceiro = lancamento.get_Controle();
+ if (controleFinanceiro != null)
+ {
+ Fornecedor fornecedor1 = controleFinanceiro.get_Fornecedor();
+ if (fornecedor1 != null)
+ {
+ nullable2 = new long?(fornecedor1.get_Id());
+ }
+ else
+ {
+ nullable = null;
+ nullable2 = nullable;
+ }
+ }
+ else
+ {
+ nullable = null;
+ nullable2 = nullable;
+ }
+ long? nullable6 = nullable2;
+ if (nullable5.GetValueOrDefault() == nullable6.GetValueOrDefault() & nullable5.HasValue == nullable6.HasValue && x.get_Valor() == lancamento.get_Valor() && x.get_Vencimento() == lancamento.get_Vencimento())
+ {
+ ControleFinanceiro controle1 = x.get_Controle();
+ if (controle1 != null)
+ {
+ Gestor.Model.Domain.Financeiro.Planos plano = controle1.get_Plano();
+ if (plano != null)
+ {
+ nullable3 = new long?(plano.get_Id());
+ }
+ else
+ {
+ nullable = null;
+ nullable3 = nullable;
+ }
+ }
+ else
+ {
+ nullable = null;
+ nullable3 = nullable;
+ }
+ nullable6 = nullable3;
+ ControleFinanceiro controleFinanceiro1 = lancamento.get_Controle();
+ if (controleFinanceiro1 != null)
+ {
+ Gestor.Model.Domain.Financeiro.Planos plano1 = controleFinanceiro1.get_Plano();
+ if (plano1 != null)
+ {
+ nullable4 = new long?(plano1.get_Id());
+ }
+ else
+ {
+ nullable = null;
+ nullable4 = nullable;
+ }
+ }
+ else
+ {
+ nullable = null;
+ nullable4 = nullable;
+ }
+ nullable5 = nullable4;
+ if (nullable6.GetValueOrDefault() == nullable5.GetValueOrDefault() & nullable6.HasValue == nullable5.HasValue)
+ {
+ return lancamento.get_Documento() == x.get_Documento();
+ }
+ }
+ }
+ return false;
+ }));
+ DateTime date = Funcoes.GetNetworkTime().Date;
+ lancamento1.set_Selecionado(true);
+ Lancamento lancamento2 = lancamento1;
+ DateTime? baixa = lancamento1.get_Baixa();
+ lancamento2.set_Baixa(new DateTime?((baixa.HasValue ? baixa.GetValueOrDefault() : lancamento1.get_Pagamento().GetValueOrDefault(date))));
+ baixa = lancamento1.get_Pagamento();
+ lancamento1.set_Pagamento(new DateTime?(baixa.GetValueOrDefault(date)));
+ Lancamento lancamento3 = lancamento1;
+ decimal? valorPago = lancamento1.get_ValorPago();
+ decimal num = new decimal();
+ lancamento3.set_ValorPago(((valorPago.GetValueOrDefault() == num) & valorPago.HasValue ? new decimal?(lancamento.get_Valor()) : lancamento1.get_ValorPago()));
+ this.LancamentosFiltradosCopia = this.LancamentosFiltrados;
+ this.Totalizar();
+ }
+
+ public void SelecionarTodos()
+ {
+ List<Lancamento> list = this.LancamentosFiltrados.ToList<Lancamento>();
+ list.ForEach((Lancamento x) => {
+ DateTime? baixa;
+ decimal num;
+ x.set_Selecionado(!x.get_Selecionado());
+ if (x.get_Baixado() || this.importando)
+ {
+ return;
+ }
+ if (!x.get_Selecionado())
+ {
+ baixa = null;
+ x.set_Baixa(baixa);
+ baixa = null;
+ x.set_Pagamento(baixa);
+ num = new decimal();
+ x.set_ValorPago(new decimal?(num));
+ return;
+ }
+ DateTime date = Funcoes.GetNetworkTime().Date;
+ Lancamento lancamento = x;
+ baixa = x.get_Baixa();
+ lancamento.set_Baixa((!baixa.HasValue ? new DateTime?(date) : x.get_Baixa()));
+ x.set_Baixa(new DateTime?(date));
+ Lancamento lancamento1 = x;
+ baixa = x.get_Pagamento();
+ lancamento1.set_Pagamento((!baixa.HasValue ? new DateTime?(date) : x.get_Pagamento()));
+ Lancamento lancamento2 = x;
+ decimal? valorPago = x.get_ValorPago();
+ num = new decimal();
+ lancamento2.set_ValorPago(((valorPago.GetValueOrDefault() == num) & valorPago.HasValue ? new decimal?(x.get_Valor()) : x.get_ValorPago()));
+ });
+ this.LancamentosFiltrados = new ObservableCollection<Lancamento>(list);
+ this.LancamentosFiltradosCopia = this.LancamentosFiltrados;
+ }
+
+ public void Sintetizar()
+ {
+ List<Sintetico> list;
+ switch (this.SinteticoTipo)
+ {
+ case 1:
+ {
+ list = (
+ from x in this.LancamentosFiltrados
+ where x.get_Controle().get_Plano() != null
+ group x by new { Id = x.get_Controle().get_Centro().get_Id(), Descricao = x.get_Controle().get_Centro().get_Descricao() }).Select((x) => {
+ Sintetico sintetico = new Sintetico();
+ sintetico.set_Agrupamento(x.Key.Descricao);
+ sintetico.set_Valor(new decimal?(x.Sum<Lancamento>((Lancamento s) => {
+ if (s.get_Sinal() == null)
+ {
+ return s.get_Valor();
+ }
+ return -s.get_Valor();
+ })));
+ sintetico.set_ValorPago(new decimal?(x.Sum<Lancamento>((Lancamento s) => {
+ decimal? valorPago;
+ decimal? nullable;
+ if (s.get_Sinal() == null)
+ {
+ valorPago = s.get_ValorPago();
+ return valorPago.GetValueOrDefault();
+ }
+ decimal? valorPago1 = s.get_ValorPago();
+ if (valorPago1.HasValue)
+ {
+ nullable = new decimal?(-valorPago1.GetValueOrDefault());
+ }
+ else
+ {
+ valorPago = null;
+ nullable = valorPago;
+ }
+ valorPago = nullable;
+ return valorPago.GetValueOrDefault();
+ })));
+ return sintetico;
+ }).ToList<Sintetico>();
+ break;
+ }
+ case 2:
+ {
+ list = (
+ from x in this.LancamentosFiltrados
+ where x.get_Controle().get_Plano() != null
+ group x by new { Id = x.get_Controle().get_Fornecedor().get_Id(), Nome = x.get_Controle().get_Fornecedor().get_Nome() }).Select((x) => {
+ Sintetico sintetico = new Sintetico();
+ sintetico.set_Agrupamento(x.Key.Nome);
+ sintetico.set_Valor(new decimal?(x.Sum<Lancamento>((Lancamento s) => {
+ if (s.get_Sinal() == null)
+ {
+ return s.get_Valor();
+ }
+ return -s.get_Valor();
+ })));
+ sintetico.set_ValorPago(new decimal?(x.Sum<Lancamento>((Lancamento s) => {
+ decimal? valorPago;
+ decimal? nullable;
+ if (s.get_Sinal() == null)
+ {
+ valorPago = s.get_ValorPago();
+ return valorPago.GetValueOrDefault();
+ }
+ decimal? valorPago1 = s.get_ValorPago();
+ if (valorPago1.HasValue)
+ {
+ nullable = new decimal?(-valorPago1.GetValueOrDefault());
+ }
+ else
+ {
+ valorPago = null;
+ nullable = valorPago;
+ }
+ valorPago = nullable;
+ return valorPago.GetValueOrDefault();
+ })));
+ return sintetico;
+ }).ToList<Sintetico>();
+ break;
+ }
+ case 3:
+ {
+ list = (
+ from x in this.LancamentosFiltrados
+ where x.get_Controle().get_Plano() != null
+ group x by new { Id = x.get_Conta().get_Id(), Descricao = x.get_Conta().get_Descricao() }).Select((x) => {
+ Sintetico sintetico = new Sintetico();
+ sintetico.set_Agrupamento(x.Key.Descricao);
+ sintetico.set_Valor(new decimal?(x.Sum<Lancamento>((Lancamento s) => {
+ if (s.get_Sinal() == null)
+ {
+ return s.get_Valor();
+ }
+ return -s.get_Valor();
+ })));
+ sintetico.set_ValorPago(new decimal?(x.Sum<Lancamento>((Lancamento s) => {
+ decimal? valorPago;
+ decimal? nullable;
+ if (s.get_Sinal() == null)
+ {
+ valorPago = s.get_ValorPago();
+ return valorPago.GetValueOrDefault();
+ }
+ decimal? valorPago1 = s.get_ValorPago();
+ if (valorPago1.HasValue)
+ {
+ nullable = new decimal?(-valorPago1.GetValueOrDefault());
+ }
+ else
+ {
+ valorPago = null;
+ nullable = valorPago;
+ }
+ valorPago = nullable;
+ return valorPago.GetValueOrDefault();
+ })));
+ return sintetico;
+ }).ToList<Sintetico>();
+ break;
+ }
+ case 4:
+ {
+ list = this.LancamentosFiltrados.Where<Lancamento>((Lancamento x) => {
+ if (x.get_Controle().get_Plano() == null)
+ {
+ return false;
+ }
+ return x.get_Controle().get_Plano().get_Plano() != null;
+ }).GroupBy((Lancamento x) => new { Id = x.get_Controle().get_Plano().get_Plano().get_Id(), Descricao = x.get_Controle().get_Plano().get_Plano().get_Descricao() }).Select((x) => {
+ Sintetico sintetico = new Sintetico();
+ sintetico.set_Agrupamento(x.Key.Descricao);
+ sintetico.set_Valor(new decimal?(x.Sum<Lancamento>((Lancamento s) => {
+ if (s.get_Sinal() == null)
+ {
+ return s.get_Valor();
+ }
+ return -s.get_Valor();
+ })));
+ sintetico.set_ValorPago(new decimal?(x.Sum<Lancamento>((Lancamento s) => {
+ decimal? valorPago;
+ decimal? nullable;
+ if (s.get_Sinal() == null)
+ {
+ valorPago = s.get_ValorPago();
+ return valorPago.GetValueOrDefault();
+ }
+ decimal? valorPago1 = s.get_ValorPago();
+ if (valorPago1.HasValue)
+ {
+ nullable = new decimal?(-valorPago1.GetValueOrDefault());
+ }
+ else
+ {
+ valorPago = null;
+ nullable = valorPago;
+ }
+ valorPago = nullable;
+ return valorPago.GetValueOrDefault();
+ })));
+ return sintetico;
+ }).ToList<Sintetico>();
+ break;
+ }
+ default:
+ {
+ list = (
+ from x in this.LancamentosFiltrados
+ where x.get_Controle().get_Plano() != null
+ group x by new { Id = x.get_Controle().get_Plano().get_Id(), Descricao = x.get_Controle().get_Plano().get_Descricao() }).Select((x) => {
+ Sintetico sintetico = new Sintetico();
+ sintetico.set_Agrupamento(x.Key.Descricao);
+ sintetico.set_Valor(new decimal?(x.Sum<Lancamento>((Lancamento s) => {
+ if (s.get_Sinal() == null)
+ {
+ return s.get_Valor();
+ }
+ return -s.get_Valor();
+ })));
+ sintetico.set_ValorPago(new decimal?(x.Sum<Lancamento>((Lancamento s) => {
+ decimal? valorPago;
+ decimal? nullable;
+ if (s.get_Sinal() == null)
+ {
+ valorPago = s.get_ValorPago();
+ return valorPago.GetValueOrDefault();
+ }
+ decimal? valorPago1 = s.get_ValorPago();
+ if (valorPago1.HasValue)
+ {
+ nullable = new decimal?(-valorPago1.GetValueOrDefault());
+ }
+ else
+ {
+ valorPago = null;
+ nullable = valorPago;
+ }
+ valorPago = nullable;
+ return valorPago.GetValueOrDefault();
+ })));
+ return sintetico;
+ }).ToList<Sintetico>();
+ break;
+ }
+ }
+ if (list.Count == 0)
+ {
+ return;
+ }
+ (new SinteticoView(list, "RELATORIO FINANCEIRO", this.Inicio, this.Fim)).Show();
+ }
+
+ public void Totalizar()
+ {
+ if (this.LancamentosFiltrados == null)
+ {
+ this.Totalizacao = null;
+ return;
+ }
+ List<Gestor.Model.Domain.Financeiro.SinteticoFinanceiro> list = (
+ from x in this.LancamentosFiltrados
+ where x.get_Conta() != null
+ group x by new { Id = x.get_Conta().get_Id(), Descricao = x.get_Conta().get_Descricao() }).Select((x) => {
+ Gestor.Model.Domain.Financeiro.SinteticoFinanceiro sinteticoFinanceiro = new Gestor.Model.Domain.Financeiro.SinteticoFinanceiro();
+ BancosContas bancosConta = new BancosContas();
+ bancosConta.set_Id(x.Key.Id);
+ bancosConta.set_Descricao(x.Key.Descricao);
+ sinteticoFinanceiro.set_Conta(bancosConta);
+ sinteticoFinanceiro.set_Filtrados(x.Count<Lancamento>());
+ sinteticoFinanceiro.set_Credito(x.Sum<Lancamento>((Lancamento s) => {
+ if (s.get_Sinal() != null)
+ {
+ return decimal.Zero;
+ }
+ return s.get_Valor();
+ }));
+ sinteticoFinanceiro.set_Debito(x.Sum<Lancamento>((Lancamento s) => {
+ if (s.get_Sinal() == null)
+ {
+ return decimal.Zero;
+ }
+ return -s.get_Valor();
+ }));
+ sinteticoFinanceiro.set_Liquido(x.Sum<Lancamento>((Lancamento s) => {
+ if (s.get_Sinal() == null)
+ {
+ return s.get_Valor();
+ }
+ return -s.get_Valor();
+ }));
+ sinteticoFinanceiro.set_LiquidoPago(x.Sum<Lancamento>((Lancamento s) => {
+ if (s.get_Sinal() == null)
+ {
+ return s.get_ValorPago();
+ }
+ decimal? valorPago = s.get_ValorPago();
+ if (!valorPago.HasValue)
+ {
+ return null;
+ }
+ return new decimal?(-valorPago.GetValueOrDefault());
+ }).GetValueOrDefault());
+ sinteticoFinanceiro.set_Selecionados(x.Count<Lancamento>((Lancamento s) => s.get_Selecionado()));
+ sinteticoFinanceiro.set_LiquidoSelecionados((
+ from s in x
+ where s.get_Selecionado()
+ select s).Sum<Lancamento>((Lancamento s) => {
+ decimal? valorPago;
+ decimal? nullable;
+ if (s.get_Sinal() == null)
+ {
+ valorPago = s.get_ValorPago();
+ return valorPago.GetValueOrDefault();
+ }
+ decimal? valorPago1 = s.get_ValorPago();
+ if (valorPago1.HasValue)
+ {
+ nullable = new decimal?(-valorPago1.GetValueOrDefault());
+ }
+ else
+ {
+ valorPago = null;
+ nullable = valorPago;
+ }
+ valorPago = nullable;
+ return valorPago.GetValueOrDefault();
+ }));
+ return sinteticoFinanceiro;
+ }).ToList<Gestor.Model.Domain.Financeiro.SinteticoFinanceiro>();
+ if (list.Count > 1)
+ {
+ List<Gestor.Model.Domain.Financeiro.SinteticoFinanceiro> sinteticoFinanceiros = list;
+ Gestor.Model.Domain.Financeiro.SinteticoFinanceiro sinteticoFinanceiro1 = new Gestor.Model.Domain.Financeiro.SinteticoFinanceiro();
+ BancosContas bancosConta1 = new BancosContas();
+ bancosConta1.set_Id((long)0);
+ bancosConta1.set_Descricao("TOTAL");
+ sinteticoFinanceiro1.set_Conta(bancosConta1);
+ sinteticoFinanceiro1.set_Filtrados(list.Sum<Gestor.Model.Domain.Financeiro.SinteticoFinanceiro>((Gestor.Model.Domain.Financeiro.SinteticoFinanceiro x) => x.get_Filtrados()));
+ sinteticoFinanceiro1.set_Credito(list.Sum<Gestor.Model.Domain.Financeiro.SinteticoFinanceiro>((Gestor.Model.Domain.Financeiro.SinteticoFinanceiro x) => x.get_Credito()));
+ sinteticoFinanceiro1.set_Debito(list.Sum<Gestor.Model.Domain.Financeiro.SinteticoFinanceiro>((Gestor.Model.Domain.Financeiro.SinteticoFinanceiro x) => x.get_Debito()));
+ sinteticoFinanceiro1.set_Liquido(list.Sum<Gestor.Model.Domain.Financeiro.SinteticoFinanceiro>((Gestor.Model.Domain.Financeiro.SinteticoFinanceiro x) => x.get_Liquido()));
+ sinteticoFinanceiro1.set_LiquidoPago(list.Sum<Gestor.Model.Domain.Financeiro.SinteticoFinanceiro>((Gestor.Model.Domain.Financeiro.SinteticoFinanceiro x) => x.get_LiquidoPago()));
+ sinteticoFinanceiro1.set_Selecionados(list.Sum<Gestor.Model.Domain.Financeiro.SinteticoFinanceiro>((Gestor.Model.Domain.Financeiro.SinteticoFinanceiro x) => x.get_Selecionados()));
+ sinteticoFinanceiro1.set_LiquidoSelecionados(list.Sum<Gestor.Model.Domain.Financeiro.SinteticoFinanceiro>((Gestor.Model.Domain.Financeiro.SinteticoFinanceiro x) => x.get_LiquidoSelecionados()));
+ sinteticoFinanceiros.Add(sinteticoFinanceiro1);
+ }
+ this.Totalizacao = new ObservableCollection<Gestor.Model.Domain.Financeiro.SinteticoFinanceiro>(list);
+ }
+
+ private async Task<List<KeyValuePair<string, string>>> Validar(Transferencia transferencia)
+ {
+ List<KeyValuePair<string, string>> keyValuePairs;
+ DateTime? dataFinal;
+ DateTime data;
+ bool origem;
+ bool destino;
+ bool flag;
+ bool flag1;
+ bool flag2;
+ bool hasValue;
+ List<Saldo> saldos1;
+ Saldo saldo;
+ List<KeyValuePair<string, string>> keyValuePairs1 = Gestor.Model.Helper.ValidationHelper.AddValue();
+ BancosContasServico bancosContasServico = new BancosContasServico();
+ Transferencia transferencium = transferencia;
+ if (transferencium != null)
+ {
+ origem = transferencium.get_Origem();
+ }
+ else
+ {
+ origem = false;
+ }
+ if (origem)
+ {
+ Transferencia transferencium1 = transferencia;
+ if (transferencium1 != null)
+ {
+ destino = transferencium1.get_Destino();
+ }
+ else
+ {
+ destino = false;
+ }
+ if (destino)
+ {
+ List<long> nums = new List<long>()
+ {
+ transferencia.get_Origem().get_Id(),
+ transferencia.get_Destino().get_Id()
+ };
+ saldos1 = await bancosContasServico.BuscarSaldoAberto(nums);
+ saldo = saldos1.FirstOrDefault<Saldo>((Saldo s) => s.get_Conta().get_Id() == transferencia.get_Origem().get_Id());
+ if (saldo == null)
+ {
+ List<Saldo> saldos2 = await bancosContasServico.BuscarSaldos(transferencia.get_Origem().get_Id());
+ List<Saldo> saldos3 = saldos2;
+ Saldo saldo1 = saldos3.Find((Saldo x) => {
+ DateTime? dataInicio = x.get_DataInicio();
+ List<Saldo> saldos = saldos3;
+ Func<Saldo, DateTime?> u003cu003e9_3863 = FinanceiroViewModel.u003cu003ec.u003cu003e9__386_3;
+ if (u003cu003e9_3863 == null)
+ {
+ u003cu003e9_3863 = (Saldo r) => r.get_DataInicio();
+ FinanceiroViewModel.u003cu003ec.u003cu003e9__386_3 = u003cu003e9_3863;
+ }
+ DateTime? nullable = saldos.Max<Saldo, DateTime?>(u003cu003e9_3863);
+ if (dataInicio.HasValue != nullable.HasValue)
+ {
+ return false;
+ }
+ if (!dataInicio.HasValue)
+ {
+ return true;
+ }
+ return dataInicio.GetValueOrDefault() == nullable.GetValueOrDefault();
+ });
+ dataFinal = saldo1.get_DataInicio();
+ data = transferencia.get_Data();
+ flag2 = (dataFinal.HasValue ? dataFinal.GetValueOrDefault() <= data : false);
+ if (!flag2)
+ {
+ hasValue = false;
+ }
+ else
+ {
+ dataFinal = saldo1.get_DataFinal();
+ hasValue = dataFinal.HasValue;
+ }
+ bool flag3 = hasValue;
+ if (flag3)
+ {
+ flag3 = await base.ShowMessage("O ÚLTIMO SALDO NÃO ESTÁ ABERTO. DESEJA ABRÍ-LO AGORA E CONTINUAR?", "SIM", "NÃO", false);
+ }
+ if (flag3)
+ {
+ dataFinal = null;
+ saldo1.set_DataFinal(dataFinal);
+ saldo1.set_ValorFinal(null);
+ saldo = await bancosContasServico.Save(saldo1);
+ }
+ saldo1 = null;
+ }
+ if (saldo != null)
+ {
+ dataFinal = saldo.get_DataInicio();
+ data = transferencia.get_Data();
+ flag1 = (dataFinal.HasValue ? dataFinal.GetValueOrDefault() > data : false);
+ if (!flag1)
+ {
+ goto Label0;
+ }
+ }
+ Gestor.Model.Helper.ValidationHelper.AddValue<string, string>(keyValuePairs1, "SALDO", string.Concat("NÃO É POSSÍVEL REALIZAR A BAIXA DO LANÇAMENTO POIS NÃO HÁ SALDO ABERTO NO PERÍODO PARA A CONTA ", transferencia.get_Origem().get_Descricao(), "."), true);
+ Label0:
+ saldo = saldos1.FirstOrDefault<Saldo>((Saldo s) => s.get_Conta().get_Id() == transferencia.get_Destino().get_Id());
+ if (saldo != null)
+ {
+ dataFinal = saldo.get_DataInicio();
+ data = transferencia.get_Data();
+ flag = (dataFinal.HasValue ? dataFinal.GetValueOrDefault() > data : false);
+ if (!flag)
+ {
+ goto Label1;
+ }
+ }
+ Gestor.Model.Helper.ValidationHelper.AddValue<string, string>(keyValuePairs1, "SALDO", string.Concat("NÃO É POSSÍVEL REALIZAR A BAIXA DO LANÇAMENTO POIS NÃO HÁ SALDO ABERTO NO PERÍODO PARA A CONTA ", transferencia.get_Destino().get_Descricao(), "."), true);
+ Label1:
+ keyValuePairs = keyValuePairs1;
+ }
+ else
+ {
+ Gestor.Model.Helper.ValidationHelper.AddValue<string, string>(keyValuePairs1, "DESTINO", "NÃO É POSSÍVEL FAZER UMA TRANSFERÊNCIA SEM BANDO DESTINO", true);
+ keyValuePairs = keyValuePairs1;
+ }
+ }
+ else
+ {
+ Gestor.Model.Helper.ValidationHelper.AddValue<string, string>(keyValuePairs1, "ORIGEM", "NÃO É POSSÍVEL FAZER UMA TRANSFERÊNCIA SEM BANDO ORIGEM", true);
+ keyValuePairs = keyValuePairs1;
+ }
+ keyValuePairs1 = null;
+ bancosContasServico = null;
+ saldos1 = null;
+ saldo = null;
+ return keyValuePairs;
+ }
+
+ private async Task<List<KeyValuePair<string, string>>> Validar()
+ {
+ List<KeyValuePair<string, string>> keyValuePairs;
+ DateTime? baixa;
+ DateTime? dataFinal;
+ bool flag;
+ bool flag1;
+ bool flag2;
+ bool hasValue;
+ List<KeyValuePair<string, string>> keyValuePairs1 = Gestor.Model.Helper.ValidationHelper.AddValue();
+ BancosContasServico bancosContasServico = new BancosContasServico();
+ BancosContasServico bancosContasServico1 = bancosContasServico;
+ List<BancosContas> contas = this.Contas;
+ List<Saldo> saldos1 = await bancosContasServico1.BuscarSaldoAberto((
+ from x in contas
+ select x.get_Id()).ToList<long>());
+ Saldo saldo = saldos1.FirstOrDefault<Saldo>((Saldo s) => {
+ long? nullable;
+ long? nullable1;
+ long id = s.get_Conta().get_Id();
+ Lancamento selectedLancamento = this.SelectedLancamento;
+ if (selectedLancamento != null)
+ {
+ BancosContas conta = selectedLancamento.get_Conta();
+ if (conta != null)
+ {
+ nullable1 = new long?(conta.get_Id());
+ }
+ else
+ {
+ nullable = null;
+ nullable1 = nullable;
+ }
+ }
+ else
+ {
+ nullable = null;
+ nullable1 = nullable;
+ }
+ long? nullable2 = nullable1;
+ return id == nullable2.GetValueOrDefault() & nullable2.HasValue;
+ });
+ if (saldo == null)
+ {
+ Lancamento lancamento = this.SelectedLancamento;
+ if (lancamento != null)
+ {
+ flag1 = lancamento.get_Conta();
+ }
+ else
+ {
+ flag1 = false;
+ }
+ if (flag1)
+ {
+ List<Saldo> saldos2 = await bancosContasServico.BuscarSaldos(this.SelectedLancamento.get_Conta().get_Id());
+ List<Saldo> saldos3 = saldos2;
+ Saldo saldo1 = saldos3.Find((Saldo x) => {
+ DateTime? dataInicio = x.get_DataInicio();
+ List<Saldo> saldos = saldos3;
+ Func<Saldo, DateTime?> u003cu003e9_3893 = FinanceiroViewModel.u003cu003ec.u003cu003e9__389_3;
+ if (u003cu003e9_3893 == null)
+ {
+ u003cu003e9_3893 = (Saldo r) => r.get_DataInicio();
+ FinanceiroViewModel.u003cu003ec.u003cu003e9__389_3 = u003cu003e9_3893;
+ }
+ DateTime? nullable = saldos.Max<Saldo, DateTime?>(u003cu003e9_3893);
+ if (dataInicio.HasValue != nullable.HasValue)
+ {
+ return false;
+ }
+ if (!dataInicio.HasValue)
+ {
+ return true;
+ }
+ return dataInicio.GetValueOrDefault() == nullable.GetValueOrDefault();
+ });
+ baixa = saldo1.get_DataInicio();
+ dataFinal = this.SelectedLancamento.get_Baixa();
+ flag2 = (baixa.HasValue & dataFinal.HasValue ? baixa.GetValueOrDefault() <= dataFinal.GetValueOrDefault() : false);
+ if (!flag2)
+ {
+ hasValue = false;
+ }
+ else
+ {
+ dataFinal = saldo1.get_DataFinal();
+ hasValue = dataFinal.HasValue;
+ }
+ bool flag3 = hasValue;
+ if (flag3)
+ {
+ flag3 = await base.ShowMessage("O ÚLTIMO SALDO NÃO ESTÁ ABERTO. DESEJA ABRÍ-LO AGORA E CONTINUAR?", "SIM", "NÃO", false);
+ }
+ if (flag3)
+ {
+ dataFinal = null;
+ saldo1.set_DataFinal(dataFinal);
+ saldo1.set_ValorFinal(null);
+ saldo = await bancosContasServico.Save(saldo1);
+ }
+ saldo1 = null;
+ }
+ }
+ if (saldo != null)
+ {
+ dataFinal = saldo.get_DataInicio();
+ baixa = this.SelectedLancamento.get_Baixa();
+ flag = (dataFinal.HasValue & baixa.HasValue ? dataFinal.GetValueOrDefault() > baixa.GetValueOrDefault() : false);
+ if (!flag)
+ {
+ keyValuePairs = new List<KeyValuePair<string, string>>();
+ keyValuePairs1 = null;
+ bancosContasServico = null;
+ saldo = null;
+ return keyValuePairs;
+ }
+ }
+ Gestor.Model.Helper.ValidationHelper.AddValue<string, string>(keyValuePairs1, "SALDO", "NÃO É POSSÍVEL REALIZAR A BAIXA DO LANÇAMENTO POIS NÃO HÁ SALDO ABERTO NO PERÍODO.", true);
+ keyValuePairs = keyValuePairs1;
+ keyValuePairs1 = null;
+ bancosContasServico = null;
+ saldo = null;
+ return keyValuePairs;
+ }
+
+ public List<KeyValuePair<string, string>> ValidateIncluir()
+ {
+ //
+ // Current member / type: System.Collections.Generic.List`1<System.Collections.Generic.KeyValuePair`2<System.String,System.String>> Gestor.Application.ViewModels.Financeiro.FinanceiroViewModel::ValidateIncluir()
+ // File path: C:\AggerSeguros\Gestor.Application.exe
+ //
+ // Product version: 0.0.0.0
+ // Exception in: System.Collections.Generic.List<System.Collections.Generic.KeyValuePair<System.String,System.String>> ValidateIncluir()
+ //
+ // Object reference not set to an instance of an object.
+ // at Telerik.JustDecompiler.Decompiler.TypeInference.TypeInferer.FindLowestCommonAncestor(ICollection`1 typeNodes) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\TypeInference\TypeInferer.cs:line 515
+ // at Telerik.JustDecompiler.Decompiler.TypeInference.TypeInferer.MergeWithLowestCommonAncestor() in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\TypeInference\TypeInferer.cs:line 459
+ // at Telerik.JustDecompiler.Decompiler.TypeInference.TypeInferer.ProcessSingleConstraints() in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\TypeInference\TypeInferer.cs:line 378
+ // at Telerik.JustDecompiler.Decompiler.TypeInference.TypeInferer.InferTypes() in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\TypeInference\TypeInferer.cs:line 331
+ // at Telerik.JustDecompiler.Decompiler.ExpressionDecompilerStep.Process(DecompilationContext theContext, BlockStatement body) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\ExpressionDecompilerStep.cs:line 104
+ // at Telerik.JustDecompiler.Decompiler.DecompilationPipeline.RunInternal(MethodBody body, BlockStatement block, ILanguage language) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\DecompilationPipeline.cs:line 100
+ // at Telerik.JustDecompiler.Decompiler.DecompilationPipeline.Run(MethodBody body, ILanguage language) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\DecompilationPipeline.cs:line 72
+ // at Telerik.JustDecompiler.Decompiler.Extensions.Decompile(MethodBody body, ILanguage language, DecompilationContext& context, TypeSpecificContext typeContext) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\Extensions.cs:line 61
+ // at Telerik.JustDecompiler.Decompiler.WriterContextServices.BaseWriterContextService.DecompileMethod(ILanguage language, MethodDefinition method, TypeSpecificContext typeContext) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\WriterContextServices\BaseWriterContextService.cs:line 133
+ //
+ // mailto: JustDecompilePublicFeedback@telerik.com
+
+ }
+
+ private bool VerificaDataInvertida(OfxDocument lancamentos)
+ {
+ List<string> strs = new List<string>()
+ {
+ "0104"
+ };
+ if (lancamentos.get_StatementStart() <= lancamentos.get_StatementEnd())
+ {
+ return false;
+ }
+ return strs.Any<string>((string banco) => banco == lancamentos.get_Account().get_BankId());
+ }
+
+ private bool VerificaFiltroErrado(OfxDocument lancamentos)
+ {
+ List<string> strs = new List<string>()
+ {
+ "0237",
+ "756"
+ };
+ if (lancamentos.get_StatementStart() != lancamentos.get_StatementEnd())
+ {
+ return false;
+ }
+ return strs.Any<string>((string idbanco) => idbanco == lancamentos.get_Account().get_BankId());
+ }
+
+ private async Task<Saldo> VerificaSaldo(long contaId, bool reabrirSaldo)
+ {
+ BancosContasServico bancosContasServico = new BancosContasServico();
+ List<BancosContas> contas = this.Contas;
+ List<Saldo> saldos = await bancosContasServico.BuscarSaldoAberto((
+ from x in contas
+ select x.get_Id()).ToList<long>());
+ Saldo saldo = saldos.FirstOrDefault<Saldo>((Saldo s) => s.get_Conta().get_Id() == contaId);
+ if (saldo == null & reabrirSaldo)
+ {
+ await base.ShowMessage("NÃO FOI ENCONTRADO UM SALDO ABERTO PARA FAZER A EXCLUSÃO.", "OK", "", false);
+ }
+ Saldo saldo1 = saldo;
+ saldo = null;
+ return saldo1;
+ }
+ }
+}
\ No newline at end of file |