diff options
Diffstat (limited to 'Gestor.Application/ViewModels/Generic/BaseApoliceViewModel.cs')
| -rw-r--r-- | Gestor.Application/ViewModels/Generic/BaseApoliceViewModel.cs | 6893 |
1 files changed, 0 insertions, 6893 deletions
diff --git a/Gestor.Application/ViewModels/Generic/BaseApoliceViewModel.cs b/Gestor.Application/ViewModels/Generic/BaseApoliceViewModel.cs deleted file mode 100644 index 5bb2e93..0000000 --- a/Gestor.Application/ViewModels/Generic/BaseApoliceViewModel.cs +++ /dev/null @@ -1,6893 +0,0 @@ -using Gestor.Application.Actions;
-using Gestor.Application.Drawers;
-using Gestor.Application.Helpers;
-using Gestor.Application.Servicos;
-using Gestor.Application.Servicos.Ferramentas;
-using Gestor.Application.Servicos.Generic;
-using Gestor.Application.Servicos.Seguros;
-using Gestor.Application.Servicos.Seguros.Itens;
-using Gestor.Application.ViewModels;
-using Gestor.Application.ViewModels.Seguros;
-using Gestor.Common.Validation;
-using Gestor.Model.Common;
-using Gestor.Model.Domain.Common;
-using Gestor.Model.Domain.Configuracoes;
-using Gestor.Model.Domain.Ferramentas;
-using Gestor.Model.Domain.Generic;
-using Gestor.Model.Domain.Seguros;
-using Gestor.Model.Helper;
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Diagnostics;
-using System.Linq;
-using System.Runtime.CompilerServices;
-using System.Threading.Tasks;
-using System.Windows;
-
-namespace Gestor.Application.ViewModels.Generic
-{
- public class BaseApoliceViewModel : BaseSegurosViewModel
- {
- internal ApoliceServico Servico;
-
- internal Gestor.Application.Servicos.Seguros.PerfilServico PerfilServico;
-
- internal Gestor.Application.Servicos.Ferramentas.RamoServico RamoServico;
-
- internal Gestor.Application.Servicos.Ferramentas.SeguradoraServico SeguradoraServico;
-
- internal Gestor.Application.Servicos.Ferramentas.VendedorServico VendedorServico;
-
- internal Gestor.Application.Servicos.ParcelaServico ParcelaServico;
-
- internal Gestor.Application.Servicos.Ferramentas.ProdutoServico ProdutoServico;
-
- internal Gestor.Application.Servicos.Ferramentas.EstipulanteServico EstipulanteServico;
-
- internal Gestor.Application.Servicos.TarefaServico TarefaServico;
-
- private bool _invoke = true;
-
- public bool UpdatePremio;
-
- private bool _enableControle = true;
-
- private bool _apelido;
-
- private bool _controleAdm;
-
- private Documento _selectedDocumento;
-
- private Visibility _visibilityExcluirParcela = Visibility.Collapsed;
-
- private Visibility _visibilityReplicarFatura = Visibility.Collapsed;
-
- private Visibility _visibilityAlterarVencimento;
-
- private string _importado = "CLIQUE PARA VER INFORMAÇÕES SOBRE A INCLUSÃO";
-
- private string _codigoDocumento;
-
- private DateTime? _emissaoDocumento;
-
- private DateTime? _transmissaoDocumento;
-
- private bool _editandoParcela;
-
- private bool _botoesParcelaEnabled = true;
-
- private List<Vendedor> _vendedores;
-
- private List<Vendedor> _todosVendedores;
-
- private ObservableCollection<VendedorParcela> _pagamentos;
-
- private ObservableCollection<TipoSeguro> _situacao = new ObservableCollection<TipoSeguro>(new List<TipoSeguro>()
- {
- 1,
- 2,
- 5
- });
-
- private ObservableCollection<TipoEndosso> _tipoEndosso = new ObservableCollection<TipoEndosso>(new List<TipoEndosso>()
- {
- 0,
- 1,
- 2,
- 4,
- 3
- });
-
- private Parcela _selectedParcela;
-
- private bool _coCorretagem;
-
- private Visibility _baixarParcelaVisibility = Visibility.Collapsed;
-
- private ObservableCollection<Parcela> _parcelas;
-
- private decimal _gerada;
-
- private decimal _comissOriginal;
-
- private Visibility _comissOriginalVisibility = Visibility.Collapsed;
-
- private decimal _recebida;
-
- private decimal _pendente;
-
- private decimal _repasse;
-
- private Visibility _recusaVisibility;
-
- private string _excluirParcelaLabel = "EXCLUIR BAIXA";
-
- private bool _isEnableSituacao;
-
- private List<Produto> _produtos = Recursos.Produtos;
-
- private List<Gestor.Model.Domain.Seguros.Status> _status = Recursos.Status;
-
- private List<Ramo> _ramos;
-
- private List<Seguradora> _seguradorasAnteriores;
-
- private List<Seguradora> _seguradoras;
-
- private Visibility _isRenovacaoVisibility = Visibility.Collapsed;
-
- private bool _isEndosso;
-
- private bool _enableAlterarSituacao;
-
- private string _assinada = "PROPOSTA ASSINADA";
-
- private string _conferida = "APÓLICE CONFERIDA";
-
- private string _transmissao = "TRANSMISSÃO DE PROPOSTA";
-
- private string _emissao = "EMISSÃO DA APÓLICE";
-
- private List<TipoVendedor> _tiposVendedor;
-
- private List<Estipulante> _estipulantes;
-
- public Documento CancelDocumento;
-
- private List<VendedorParcela> _repasses;
-
- private List<Gestor.Model.Domain.Seguros.Repasse> _repassesVendedores;
-
- private List<Gestor.Model.Domain.Seguros.Repasse> _repassesVendedor;
-
- private VendedorParcela _selectedPagamento;
-
- private bool _baixarParcelas;
-
- private bool _isFatura;
-
- private bool _ultimaFatura;
-
- private bool _allowEditVendedor;
-
- private bool _alteracaoEnabled;
-
- private bool _allowEditEmissao;
-
- private bool _allowEditApolice;
-
- private bool _allowVigenciaFinal;
-
- private bool _novaApolice;
-
- private bool _renovar;
-
- public decimal Tolerancia;
-
- private bool _enableRepasse;
-
- private bool _bloquearObservacao;
-
- private string _editarParcelasLabel;
-
- private string _anotacoes;
-
- private int _quantidadeFaturas;
-
- private double _tamanhoGrid;
-
- private bool _inclusao;
-
- private bool _criandoParcelaEspecial;
-
- private bool _visibilityLogAntigo;
-
- public AcessoApolice Acesso
- {
- get;
- set;
- }
-
- public bool AllowEditApolice
- {
- get
- {
- return this._allowEditApolice;
- }
- set
- {
- this._allowEditApolice = value;
- this.AllowVigenciaFinal = (value ? true : this.IsFatura);
- base.OnPropertyChanged("AllowEditApolice");
- }
- }
-
- public bool AllowEditEmissao
- {
- get
- {
- return this._allowEditEmissao;
- }
- set
- {
- this._allowEditEmissao = value;
- base.OnPropertyChanged("AllowEditEmissao");
- }
- }
-
- public bool AllowEditVendedor
- {
- get
- {
- return this._allowEditVendedor;
- }
- set
- {
- this._allowEditVendedor = this._incluirPermissEnabled & value;
- base.OnPropertyChanged("AllowEditVendedor");
- }
- }
-
- public bool AllowVigenciaFinal
- {
- get
- {
- return this._allowVigenciaFinal;
- }
- set
- {
- this._allowVigenciaFinal = value;
- base.OnPropertyChanged("AllowVigenciaFinal");
- }
- }
-
- public bool AlteracaoEnabled
- {
- get
- {
- return this._alteracaoEnabled;
- }
- set
- {
- this._alteracaoEnabled = value;
- base.OnPropertyChanged("AlteracaoEnabled");
- }
- }
-
- public new string Anotacoes
- {
- get
- {
- return this._anotacoes;
- }
- set
- {
- this._anotacoes = value;
- base.OnPropertyChanged("Anotacoes");
- }
- }
-
- public bool Apelido
- {
- get
- {
- return this._apelido;
- }
- set
- {
- this._apelido = value;
- base.OnPropertyChanged("Apelido");
- }
- }
-
- public string Assinada
- {
- get
- {
- return this._assinada;
- }
- set
- {
- this._assinada = value;
- base.OnPropertyChanged("Assinada");
- }
- }
-
- public bool BaixarParcelas
- {
- get
- {
- return this._baixarParcelas;
- }
- set
- {
- this._baixarParcelas = value;
- base.OnPropertyChanged("BaixarParcelas");
- }
- }
-
- public Visibility BaixarParcelaVisibility
- {
- get
- {
- return this._baixarParcelaVisibility;
- }
- set
- {
- if (base.Restricao(15))
- {
- return;
- }
- this._baixarParcelaVisibility = value;
- base.OnPropertyChanged("BaixarParcelaVisibility");
- }
- }
-
- public bool BloquearObservacao
- {
- get
- {
- return this._bloquearObservacao;
- }
- set
- {
- this._bloquearObservacao = value;
- base.OnPropertyChanged("BloquearObservacao");
- }
- }
-
- public bool BotoesParcelaEnabled
- {
- get
- {
- return this._botoesParcelaEnabled;
- }
- set
- {
- this._botoesParcelaEnabled = value;
- base.OnPropertyChanged("BotoesParcelaEnabled");
- }
- }
-
- public bool CoCorretagem
- {
- get
- {
- return this._coCorretagem;
- }
- set
- {
- if (this.SelectedPagamento != null)
- {
- this.SelectedPagamento.set_CoCorretagem(value);
- }
- this._coCorretagem = value;
- base.OnPropertyChanged("CoCorretagem");
- }
- }
-
- public string CodigoDocumento
- {
- get
- {
- return this._codigoDocumento;
- }
- set
- {
- this._codigoDocumento = value;
- base.OnPropertyChanged("CodigoDocumento");
- }
- }
-
- public decimal ComissOriginal
- {
- get
- {
- return this._comissOriginal;
- }
- set
- {
- this.ComissOriginalVisibility = (this.VerificaCoCorretagem() ? Visibility.Visible : Visibility.Collapsed);
- this._comissOriginal = value;
- base.OnPropertyChanged("ComissOriginal");
- }
- }
-
- public Visibility ComissOriginalVisibility
- {
- get
- {
- return this._comissOriginalVisibility;
- }
- set
- {
- this._comissOriginalVisibility = value;
- base.OnPropertyChanged("ComissOriginalVisibility");
- }
- }
-
- public string Conferida
- {
- get
- {
- return this._conferida;
- }
- set
- {
- this._conferida = value;
- base.OnPropertyChanged("Conferida");
- }
- }
-
- public bool ControleAdm
- {
- get
- {
- return this._controleAdm;
- }
- set
- {
- this._controleAdm = value;
- base.OnPropertyChanged("ControleAdm");
- }
- }
-
- public bool CriandoParcelaEspecial
- {
- get
- {
- return this._criandoParcelaEspecial;
- }
- set
- {
- this._criandoParcelaEspecial = value;
- }
- }
-
- private Documento DocumentoRenovado
- {
- get;
- set;
- }
-
- internal Documento DocumentoSelecionado
- {
- get;
- set;
- }
-
- public bool EditandoParcela
- {
- get
- {
- return this._editandoParcela;
- }
- set
- {
- this._editandoParcela = value;
- base.OnPropertyChanged("EditandoParcela");
- }
- }
-
- public string EditarParcelasLabel
- {
- get
- {
- return this._editarParcelasLabel;
- }
- set
- {
- this._editarParcelasLabel = value;
- base.OnPropertyChanged("EditarParcelasLabel");
- }
- }
-
- public string Emissao
- {
- get
- {
- return this._emissao;
- }
- set
- {
- this._emissao = value;
- base.OnPropertyChanged("Emissao");
- }
- }
-
- public DateTime? EmissaoDocumento
- {
- get
- {
- return this._emissaoDocumento;
- }
- set
- {
- this._emissaoDocumento = value;
- base.OnPropertyChanged("EmissaoDocumento");
- }
- }
-
- public bool EnableAlterarSituacao
- {
- get
- {
- return this._enableAlterarSituacao;
- }
- set
- {
- this._enableAlterarSituacao = value;
- base.OnPropertyChanged("EnableAlterarSituacao");
- }
- }
-
- public bool EnableControle
- {
- get
- {
- return this._enableControle;
- }
- set
- {
- this._enableControle = value;
- base.OnPropertyChanged("EnableControle");
- }
- }
-
- public bool EnableRepasse
- {
- get
- {
- return this._enableRepasse;
- }
- set
- {
- this._enableRepasse = value;
- base.OnPropertyChanged("EnableRepasse");
- }
- }
-
- public List<Estipulante> Estipulantes
- {
- get
- {
- return this._estipulantes;
- }
- set
- {
- this._estipulantes = value;
- base.OnPropertyChanged("Estipulantes");
- }
- }
-
- public string ExcluirParcelaLabel
- {
- get
- {
- return this._excluirParcelaLabel;
- }
- set
- {
- this._excluirParcelaLabel = value;
- base.OnPropertyChanged("ExcluirParcelaLabel");
- }
- }
-
- public decimal Gerada
- {
- get
- {
- return this._gerada;
- }
- set
- {
- this._gerada = value;
- base.OnPropertyChanged("Gerada");
- }
- }
-
- public string Importado
- {
- get
- {
- return this._importado;
- }
- set
- {
- this._importado = value;
- base.OnPropertyChanged("Importado");
- }
- }
-
- public Gestor.Model.Domain.Ferramentas.Imposto Imposto
- {
- get;
- set;
- }
-
- public bool Inclusao
- {
- get
- {
- return this._inclusao;
- }
- set
- {
- this._inclusao = value;
- base.OnPropertyChanged("Inclusao");
- }
- }
-
- public bool Invoke
- {
- get
- {
- return this._invoke;
- }
- set
- {
- this._invoke = value;
- base.OnPropertyChanged("Invoke");
- }
- }
-
- public bool IsEnableSituacao
- {
- get
- {
- return this._isEnableSituacao;
- }
- set
- {
- this._isEnableSituacao = value;
- base.OnPropertyChanged("IsEnableSituacao");
- }
- }
-
- public bool IsEndosso
- {
- get
- {
- return this._isEndosso;
- }
- set
- {
- this._isEndosso = value;
- this.WorkOnSelectedTipo(value);
- base.OnPropertyChanged("IsEndosso");
- }
- }
-
- public bool IsFatura
- {
- get
- {
- return this._isFatura;
- }
- set
- {
- this._isFatura = value;
- base.OnPropertyChanged("IsFatura");
- }
- }
-
- public Visibility IsRenovacaoVisibility
- {
- get
- {
- return this._isRenovacaoVisibility;
- }
- set
- {
- this._isRenovacaoVisibility = value;
- base.OnPropertyChanged("IsRenovacaoVisibility");
- }
- }
-
- public bool Loaded
- {
- get;
- set;
- }
-
- public bool NovaApolice
- {
- get
- {
- return this._novaApolice;
- }
- set
- {
- this._novaApolice = value;
- base.OnPropertyChanged("NovaApolice");
- }
- }
-
- public ObservableCollection<VendedorParcela> Pagamentos
- {
- get
- {
- return this._pagamentos;
- }
- set
- {
- this._pagamentos = value;
- base.OnPropertyChanged("Pagamentos");
- }
- }
-
- public ObservableCollection<Parcela> Parcelas
- {
- get
- {
- return this._parcelas;
- }
- set
- {
- this._parcelas = value;
- if (value != null && value.Count == 0)
- {
- this.VisibilityExcluirParcela = Visibility.Collapsed;
- this.VisibilityReplicarFatura = Visibility.Collapsed;
- this.BaixarParcelaVisibility = Visibility.Collapsed;
- this.VisibilityAlterarVencimento = Visibility.Collapsed;
- }
- base.OnPropertyChanged("Parcelas");
- }
- }
-
- internal long ParcelaSelecionada
- {
- get;
- set;
- }
-
- public decimal Pendente
- {
- get
- {
- return this._pendente;
- }
- set
- {
- this._pendente = value;
- base.OnPropertyChanged("Pendente");
- }
- }
-
- public List<Produto> Produtos
- {
- get
- {
- return this._produtos;
- }
- set
- {
- this._produtos = value;
- base.OnPropertyChanged("Produtos");
- }
- }
-
- public int QuantidadeFaturas
- {
- get
- {
- return this._quantidadeFaturas;
- }
- set
- {
- if (value < 0)
- {
- value = 0;
- }
- if (value > 12)
- {
- value = 12;
- }
- this._quantidadeFaturas = value;
- base.OnPropertyChanged("QuantidadeFaturas");
- }
- }
-
- public List<Ramo> Ramos
- {
- get
- {
- return this._ramos;
- }
- set
- {
- this._ramos = value;
- base.OnPropertyChanged("Ramos");
- }
- }
-
- public decimal Recebida
- {
- get
- {
- return this._recebida;
- }
- set
- {
- this._recebida = value;
- base.OnPropertyChanged("Recebida");
- }
- }
-
- public Visibility RecusaVisibility
- {
- get
- {
- return this._recusaVisibility;
- }
- set
- {
- this._recusaVisibility = (!base.Restricao(18) ? value : Visibility.Collapsed);
- base.OnPropertyChanged("RecusaVisibility");
- }
- }
-
- public bool Renovar
- {
- get
- {
- return this._renovar;
- }
- set
- {
- this._renovar = value;
- base.OnPropertyChanged("Renovar");
- }
- }
-
- public decimal Repasse
- {
- get
- {
- return this._repasse;
- }
- set
- {
- this._repasse = value;
- base.OnPropertyChanged("Repasse");
- }
- }
-
- public List<VendedorParcela> Repasses
- {
- get
- {
- return this._repasses;
- }
- set
- {
- this._repasses = value;
- base.OnPropertyChanged("Repasses");
- }
- }
-
- public List<Gestor.Model.Domain.Seguros.Repasse> RepassesVendedor
- {
- get
- {
- return this._repassesVendedor;
- }
- set
- {
- this._repassesVendedor = value;
- this.EnableRepasse = (value == null ? false : value.Count > 0);
- base.OnPropertyChanged("RepassesVendedor");
- }
- }
-
- public List<Gestor.Model.Domain.Seguros.Repasse> RepassesVendedores
- {
- get
- {
- return this._repassesVendedores;
- }
- set
- {
- this._repassesVendedores = value;
- base.OnPropertyChanged("RepassesVendedores");
- }
- }
-
- public List<Seguradora> Seguradoras
- {
- get
- {
- return this._seguradoras;
- }
- set
- {
- this._seguradoras = value;
- base.OnPropertyChanged("Seguradoras");
- }
- }
-
- public List<Seguradora> SeguradorasAnteriores
- {
- get
- {
- return this._seguradorasAnteriores;
- }
- set
- {
- this._seguradorasAnteriores = value;
- base.OnPropertyChanged("SeguradorasAnteriores");
- }
- }
-
- public Documento SelectedDocumento
- {
- get
- {
- return this._selectedDocumento;
- }
- set
- {
- DateTime networkTime;
- long? nullable;
- bool flag;
- DateTime? emissao;
- DateTime? remessa;
- Visibility visibility;
- long? nullable1;
- string apolice;
- if (value != null && value.get_Id() == 0)
- {
- this.VisibilityLogAntigo = false;
- }
- this._selectedDocumento = value;
- this.Anotacoes = string.Empty;
- base.EnableButtons = (value == null ? false : value.get_Id() > (long)0);
- base.EnableIncluir = (value == null ? true : value.get_Id() > (long)0);
- bool flag1 = Recursos.Configuracoes.Any<ConfiguracaoSistema>((ConfiguracaoSistema x) => x.get_Configuracao() == 13);
- if (value == null || value.get_Id() <= (long)0)
- {
- flag = false;
- }
- else if (flag1)
- {
- flag = true;
- }
- else
- {
- flag = (string.IsNullOrWhiteSpace(value.get_Apolice()) || string.IsNullOrWhiteSpace(value.get_Proposta()) ? false : value.get_Emissao().HasValue);
- }
- base.EnableEndossar = flag;
- base.EnableRenovar = (value == null || value.get_Id() <= (long)0 || !value.get_Vigencia2().HasValue ? false : !string.IsNullOrWhiteSpace(value.get_Apolice()));
- if (value == null || value.get_Id() == 0)
- {
- this.ZeraComissao();
- }
- this.CodigoDocumento = (this.SelectedDocumento == null || this.SelectedDocumento.get_Id() == 0 ? "" : string.Format("{0}", this.SelectedDocumento.get_Id()));
- if (value != null && value.get_Status() == null && this.Status.First<Gestor.Model.Domain.Seguros.Status>().get_Nome() == "SEM STATUS")
- {
- value.set_Status(this.Status.First<Gestor.Model.Domain.Seguros.Status>());
- }
- if (value == null || !value.get_Emissao().HasValue)
- {
- networkTime = Funcoes.GetNetworkTime();
- emissao = new DateTime?(networkTime.Date);
- }
- else
- {
- emissao = value.get_Emissao();
- }
- this.EmissaoDocumento = emissao;
- if (value == null || !value.get_Remessa().HasValue)
- {
- networkTime = Funcoes.GetNetworkTime();
- remessa = new DateTime?(networkTime.Date);
- }
- else
- {
- remessa = value.get_Remessa();
- }
- this.TransmissaoDocumento = remessa;
- if (Recursos.Configuracoes.Any<ConfiguracaoSistema>((ConfiguracaoSistema x) => x.get_Configuracao() == 19))
- {
- if (value != null)
- {
- apolice = value.get_Apolice();
- }
- else
- {
- apolice = null;
- }
- if (string.IsNullOrWhiteSpace(apolice) || !value.get_Emissao().HasValue)
- {
- visibility = Visibility.Visible;
- this.RecusaVisibility = visibility;
- if (value != null)
- {
- nullable1 = new long?(value.get_Id());
- }
- else
- {
- nullable = null;
- nullable1 = nullable;
- }
- base.VerificarEnables(nullable1);
- base.OnPropertyChanged("SelectedDocumento");
- return;
- }
- visibility = Visibility.Collapsed;
- this.RecusaVisibility = visibility;
- if (value != null)
- {
- nullable1 = new long?(value.get_Id());
- }
- else
- {
- nullable = null;
- nullable1 = nullable;
- }
- base.VerificarEnables(nullable1);
- base.OnPropertyChanged("SelectedDocumento");
- return;
- }
- visibility = Visibility.Visible;
- this.RecusaVisibility = visibility;
- if (value != null)
- {
- nullable1 = new long?(value.get_Id());
- }
- else
- {
- nullable = null;
- nullable1 = nullable;
- }
- base.VerificarEnables(nullable1);
- base.OnPropertyChanged("SelectedDocumento");
- }
- }
-
- public VendedorParcela SelectedPagamento
- {
- get
- {
- return this._selectedPagamento;
- }
- set
- {
- this._selectedPagamento = value;
- base.OnPropertyChanged("SelectedPagamento");
- }
- }
-
- public Parcela SelectedParcela
- {
- get
- {
- return this._selectedParcela;
- }
- set
- {
- this._selectedParcela = value;
- this.WorkOnSelectedParcela(value);
- base.OnPropertyChanged("SelectedParcela");
- }
- }
-
- public ObservableCollection<TipoSeguro> Situacao
- {
- get
- {
- return this._situacao;
- }
- set
- {
- this._situacao = value;
- base.OnPropertyChanged("Situacao");
- }
- }
-
- public List<Gestor.Model.Domain.Seguros.Status> Status
- {
- get
- {
- return this._status;
- }
- set
- {
- if (value.All<Gestor.Model.Domain.Seguros.Status>((Gestor.Model.Domain.Seguros.Status x) => x.get_Nome() != "SEM STATUS"))
- {
- Gestor.Model.Domain.Seguros.Status statu = new Gestor.Model.Domain.Seguros.Status();
- statu.set_Nome("SEM STATUS");
- statu.set_Id((long)0);
- statu.set_Ativo(true);
- value.Insert(0, statu);
- }
- this._status = value;
- base.OnPropertyChanged("Status");
- }
- }
-
- public double TamanhoGrid
- {
- get
- {
- return this._tamanhoGrid;
- }
- set
- {
- this._tamanhoGrid = value;
- base.OnPropertyChanged("TamanhoGrid");
- }
- }
-
- public ObservableCollection<TipoEndosso> TipoEndossoList
- {
- get
- {
- return this._tipoEndosso;
- }
- set
- {
- this._tipoEndosso = value;
- base.OnPropertyChanged("TipoEndossoList");
- }
- }
-
- public List<TipoVendedor> TiposVendedor
- {
- get
- {
- return this._tiposVendedor;
- }
- set
- {
- this._tiposVendedor = value;
- base.OnPropertyChanged("TiposVendedor");
- }
- }
-
- public List<Vendedor> TodosVendedores
- {
- get
- {
- return this._todosVendedores;
- }
- set
- {
- this._todosVendedores = value;
- base.OnPropertyChanged("TodosVendedores");
- }
- }
-
- public string Transmissao
- {
- get
- {
- return this._transmissao;
- }
- set
- {
- this._transmissao = value;
- base.OnPropertyChanged("Transmissao");
- }
- }
-
- public DateTime? TransmissaoDocumento
- {
- get
- {
- return this._transmissaoDocumento;
- }
- set
- {
- this._transmissaoDocumento = value;
- base.OnPropertyChanged("TransmissaoDocumento");
- }
- }
-
- public bool UltimaFatura
- {
- get
- {
- return this._ultimaFatura;
- }
- set
- {
- this._ultimaFatura = value;
- base.OnPropertyChanged("UltimaFatura");
- }
- }
-
- public List<Vendedor> Vendedores
- {
- get
- {
- return this._vendedores;
- }
- set
- {
- this._vendedores = value;
- base.OnPropertyChanged("Vendedores");
- }
- }
-
- public Visibility VisibilityAlterarVencimento
- {
- get
- {
- return this._visibilityAlterarVencimento;
- }
- set
- {
- this._visibilityAlterarVencimento = value;
- base.OnPropertyChanged("VisibilityAlterarVencimento");
- }
- }
-
- public Visibility VisibilityExcluirParcela
- {
- get
- {
- return this._visibilityExcluirParcela;
- }
- set
- {
- this._visibilityExcluirParcela = value;
- base.OnPropertyChanged("VisibilityExcluirParcela");
- }
- }
-
- public bool VisibilityLogAntigo
- {
- get
- {
- return this._visibilityLogAntigo;
- }
- set
- {
- this._visibilityLogAntigo = value;
- base.OnPropertyChanged("VisibilityLogAntigo");
- }
- }
-
- public Visibility VisibilityReplicarFatura
- {
- get
- {
- return this._visibilityReplicarFatura;
- }
- set
- {
- this._visibilityReplicarFatura = value;
- base.OnPropertyChanged("VisibilityReplicarFatura");
- }
- }
-
- public BaseApoliceViewModel()
- {
- this._invoke = true;
- this._enableControle = true;
- this._visibilityExcluirParcela = Visibility.Collapsed;
- this._visibilityReplicarFatura = Visibility.Collapsed;
- this._importado = "CLIQUE PARA VER INFORMAÇÕES SOBRE A INCLUSÃO";
- this._botoesParcelaEnabled = true;
- this._situacao = new ObservableCollection<TipoSeguro>(new List<TipoSeguro>()
- {
- 1,
- 2,
- 5
- });
- this._tipoEndosso = new ObservableCollection<TipoEndosso>(new List<TipoEndosso>()
- {
- 0,
- 1,
- 2,
- 4,
- 3
- });
- this._baixarParcelaVisibility = Visibility.Collapsed;
- this._comissOriginalVisibility = Visibility.Collapsed;
- this._excluirParcelaLabel = "EXCLUIR BAIXA";
- this._produtos = Recursos.Produtos;
- this._status = Recursos.Status;
- this._isRenovacaoVisibility = Visibility.Collapsed;
- this._assinada = "PROPOSTA ASSINADA";
- this._conferida = "APÓLICE CONFERIDA";
- this._transmissao = "TRANSMISSÃO DE PROPOSTA";
- this._emissao = "EMISSÃO DA APÓLICE";
- List<TipoVendedor> tipoVendedor = Recursos.TipoVendedor;
- if (tipoVendedor != null)
- {
- list = tipoVendedor.Where<TipoVendedor>((TipoVendedor x) => {
- if (!x.get_Ativo().HasValue)
- {
- return true;
- }
- return x.get_Ativo().Value;
- }).ToList<TipoVendedor>();
- }
- else
- {
- list = null;
- }
- this._tiposVendedor = list;
- this._allowEditVendedor = true;
- this._alteracaoEnabled = true;
- this._allowEditEmissao = true;
- this._allowEditApolice = true;
- this._allowVigenciaFinal = true;
- this._bloquearObservacao = Recursos.Configuracoes.Any<ConfiguracaoSistema>((ConfiguracaoSistema x) => x.get_Configuracao() == 39);
- this._editarParcelasLabel = "EDITAR PARCELAS";
- this._visibilityLogAntigo = Recursos.Configuracoes.Any<ConfiguracaoSistema>((ConfiguracaoSistema x) => x.get_Configuracao() == 22);
- base();
- List<TipoVendedor> list;
- this.Servico = new ApoliceServico();
- this.VendedorServico = new Gestor.Application.Servicos.Ferramentas.VendedorServico();
- this.ParcelaServico = new Gestor.Application.Servicos.ParcelaServico();
- this.RamoServico = new Gestor.Application.Servicos.Ferramentas.RamoServico();
- this.SeguradoraServico = new Gestor.Application.Servicos.Ferramentas.SeguradoraServico();
- this.ProdutoServico = new Gestor.Application.Servicos.Ferramentas.ProdutoServico();
- this.EstipulanteServico = new Gestor.Application.Servicos.Ferramentas.EstipulanteServico();
- this.TarefaServico = new Gestor.Application.Servicos.TarefaServico();
- this.PerfilServico = new Gestor.Application.Servicos.Seguros.PerfilServico();
- this.Apelido = Recursos.Configuracoes.Any<ConfiguracaoSistema>((ConfiguracaoSistema x) => x.get_Configuracao() == 6);
- this.ControleAdm = (Recursos.Configuracoes.All<ConfiguracaoSistema>((ConfiguracaoSistema x) => x.get_Configuracao() != 33) ? true : Recursos.Usuario.get_Administrador());
- }
-
- public Documento AbrirDetalhes()
- {
- Documento selectedDocumento = this.SelectedDocumento;
- selectedDocumento.set_Parcelas(this.Parcelas);
- selectedDocumento.set_Pagamentos(this.Repasses);
- return selectedDocumento;
- }
-
- public Parcela AbrirDetalhesParcela()
- {
- Parcela selectedParcela = this.SelectedParcela;
- selectedParcela.set_Vendedores(this.Pagamentos);
- return selectedParcela;
- }
-
- public async void AbrirLogAntigo()
- {
- base.Loading(true);
- string str = await this.Servico.BuscarLogAntigo(this.SelectedDocumento.get_Id());
- base.Loading(false);
- if (!string.IsNullOrEmpty(str))
- {
- base.ShowDrawer(new LogSistemaAntigo(this.SelectedDocumento.get_Id(), str), 0, false);
- }
- else
- {
- await base.ShowMessage("NÃO HÁ LOG PARA ESSE DOCUMENTO", "OK", "", false);
- }
- }
-
- public async void AbrirLogAntigoParcela()
- {
- base.Loading(true);
- string str = "";
- foreach (Parcela parcela in await this.ParcelaServico.BuscarParcelas(this.SelectedDocumento.get_Id()))
- {
- string str1 = str;
- string str2 = await this.ParcelaServico.BuscarLogAntigo(parcela.get_Id());
- str = string.Concat(str1, str2);
- str1 = null;
- }
- base.Loading(false);
- if (!string.IsNullOrEmpty(str))
- {
- base.ShowDrawer(new LogSistemaAntigo(this.SelectedDocumento.get_Id(), str), 0, false);
- }
- else
- {
- await base.ShowMessage("NÃO HÁ LOG PARA PARCELAS", "OK", "", false);
- }
- str = null;
- }
-
- public async Task AdicionarParcelaEspecial()
- {
- long num;
- DateTime? nullable;
- DateTime valueOrDefault;
- string str;
- long num1;
- DateTime? nullable1;
- DateTime? nullable2;
- DateTime? nullable3;
- DateTime? nullable4;
- DateTime? nullable5;
- DateTime? nullable6;
- string str1;
- string str2;
- string str3;
- if (this.SelectedParcela != null && !this.CriandoParcelaEspecial)
- {
- this.CriandoParcelaEspecial = true;
- if (this.SelectedPagamento == null || this.SelectedPagamento.get_Vendedor().get_Corretora())
- {
- this.SelectedPagamento = this.PropriaCorretora();
- }
- else
- {
- List<KeyValuePair<string, string>> keyValuePairs = await this.AdicionarVendedorParcelaEspecial();
- if (keyValuePairs.Count > 0)
- {
- this._criandoParcelaEspecial = false;
- await base.ShowMessage(keyValuePairs, " PROCESSO INTERROMPIDO, PARCELA/FATURA SEM VENDENDEDOR", "OK", "");
- return;
- }
- }
- this.SelectedParcela.set_Documento(this.SelectedDocumento);
- DateTime vencimento = this.SelectedParcela.get_Vencimento();
- DateTime? dataRecebimento = this.SelectedParcela.get_DataRecebimento();
- DateTime? dataCredito = this.SelectedParcela.get_DataCredito();
- DateTime? dataControle = this.SelectedParcela.get_DataControle();
- int numeroParcela = this.SelectedParcela.get_NumeroParcela();
- DateTime? vigenciaIncial = this.SelectedParcela.get_VigenciaIncial();
- DateTime? vigenciaFinal = this.SelectedParcela.get_VigenciaFinal();
- DateTime? emissao = this.SelectedParcela.get_Emissao();
- str = (string.IsNullOrWhiteSpace(Gestor.Common.Validation.ValidationHelper.OnlyNumber(this.SelectedParcela.get_Fatura())) ? "1" : Gestor.Common.Validation.ValidationHelper.OnlyNumber(this.SelectedParcela.get_Fatura()));
- num1 = (long.TryParse(str, out num) ? num : (long)1);
- long num2 = num1;
- if (this.QuantidadeFaturas == 0 || !this.IsFatura)
- {
- this.QuantidadeFaturas = 1;
- }
- if (this.QuantidadeFaturas <= 12)
- {
- for (int i = 0; i < this.QuantidadeFaturas; i++)
- {
- this.SelectedParcela.set_Vencimento(vencimento.AddMonths(i));
- Parcela selectedParcela = this.SelectedParcela;
- ref Nullable nullablePointer = ref vigenciaIncial;
- if (nullablePointer.HasValue)
- {
- valueOrDefault = nullablePointer.GetValueOrDefault();
- nullable1 = new DateTime?(valueOrDefault.AddMonths(i));
- }
- else
- {
- nullable = null;
- nullable1 = nullable;
- }
- selectedParcela.set_VigenciaIncial(nullable1);
- Parcela parcela = this.SelectedParcela;
- ref Nullable nullablePointer1 = ref vigenciaFinal;
- if (nullablePointer1.HasValue)
- {
- valueOrDefault = nullablePointer1.GetValueOrDefault();
- nullable2 = new DateTime?(valueOrDefault.AddMonths(i));
- }
- else
- {
- nullable = null;
- nullable2 = nullable;
- }
- parcela.set_VigenciaFinal(nullable2);
- Parcela selectedParcela1 = this.SelectedParcela;
- ref Nullable nullablePointer2 = ref emissao;
- if (nullablePointer2.HasValue)
- {
- valueOrDefault = nullablePointer2.GetValueOrDefault();
- nullable3 = new DateTime?(valueOrDefault.AddMonths(i));
- }
- else
- {
- nullable = null;
- nullable3 = nullable;
- }
- selectedParcela1.set_Emissao(nullable3);
- Parcela parcela1 = this.SelectedParcela;
- ref Nullable nullablePointer3 = ref dataRecebimento;
- if (nullablePointer3.HasValue)
- {
- valueOrDefault = nullablePointer3.GetValueOrDefault();
- nullable4 = new DateTime?(valueOrDefault.AddMonths(i));
- }
- else
- {
- nullable = null;
- nullable4 = nullable;
- }
- parcela1.set_DataRecebimento(nullable4);
- Parcela selectedParcela2 = this.SelectedParcela;
- ref Nullable nullablePointer4 = ref dataCredito;
- if (nullablePointer4.HasValue)
- {
- valueOrDefault = nullablePointer4.GetValueOrDefault();
- nullable5 = new DateTime?(valueOrDefault.AddMonths(i));
- }
- else
- {
- nullable = null;
- nullable5 = nullable;
- }
- selectedParcela2.set_DataCredito(nullable5);
- Parcela parcela2 = this.SelectedParcela;
- ref Nullable nullablePointer5 = ref dataControle;
- if (nullablePointer5.HasValue)
- {
- valueOrDefault = nullablePointer5.GetValueOrDefault();
- nullable6 = new DateTime?(valueOrDefault.AddMonths(i));
- }
- else
- {
- nullable = null;
- nullable6 = nullable;
- }
- parcela2.set_DataControle(nullable6);
- this.SelectedParcela.set_NumeroParcela(numeroParcela + i);
- if (i > 0)
- {
- num2 += (long)1;
- this.SelectedParcela.set_Fatura(string.Format("{0}", num2));
- nullable = null;
- this.SelectedParcela.set_DataQuitacao(nullable);
- }
- List<VendedorParcela> repasses = this.Repasses;
- if (repasses != null)
- {
- repasses.ForEach((VendedorParcela x) => {
- if (x.get_Repasse() == null)
- {
- return;
- }
- if (x.get_Repasse().get_Forma().GetValueOrDefault() == 1)
- {
- x.set_DataPrePagamento(this.SelectedParcela.get_DataRecebimento());
- }
- x.set_Parcela(this.SelectedParcela);
- BaseRepasse? @base = x.get_Repasse().get_Base();
- if (@base.HasValue)
- {
- switch (@base.GetValueOrDefault())
- {
- case 1:
- {
- x.set_DataPrePagamento((this.SelectedDocumento.get_TipoRecebimento().GetValueOrDefault() == 2 ? x.get_Parcela().get_VigenciaIncial() : new DateTime?(this.SelectedDocumento.get_Vigencia1())));
- return;
- }
- case 2:
- {
- x.set_DataPrePagamento(x.get_Parcela().get_DataCriacao());
- return;
- }
- case 3:
- {
- x.set_DataPrePagamento(new DateTime?((x.get_Parcela().get_Vencimento() == DateTime.MinValue ? this.SelectedDocumento.get_Vigencia1() : x.get_Parcela().get_Vencimento())));
- return;
- }
- case 4:
- {
- x.set_DataPrePagamento((this.SelectedDocumento.get_TipoRecebimento().GetValueOrDefault() == 2 ? x.get_Parcela().get_Emissao() : this.SelectedDocumento.get_Emissao()));
- return;
- }
- case 5:
- {
- x.set_DataPrePagamento((this.SelectedDocumento.get_TipoRecebimento().GetValueOrDefault() == 2 ? x.get_Parcela().get_Emissao() : this.SelectedDocumento.get_Remessa()));
- break;
- }
- default:
- {
- return;
- }
- }
- }
- });
- }
- else
- {
- }
- if (this.Repasses == null)
- {
- this.Repasses = new List<VendedorParcela>()
- {
- this.PropriaCorretora()
- };
- }
- List<VendedorParcela> vendedorParcelas = this.Repasses;
- if (vendedorParcelas.All<VendedorParcela>((VendedorParcela x) => x.get_TipoVendedor().get_Id() != (long)1))
- {
- this.Repasses.Add(this.PropriaCorretora());
- }
- Parcela parcela3 = await this.ParcelaServico.Save(this.SelectedParcela, this.Parcelas.ToList<Parcela>(), this.Repasses, true);
- if (i == this.QuantidadeFaturas - 1)
- {
- this.SelectedParcela = parcela3;
- }
- }
- this.QuantidadeFaturas = 0;
- if (this.SelectedDocumento.get_Tipo() == 0 && string.IsNullOrEmpty(this.SelectedDocumento.get_Apolice()))
- {
- str1 = string.Concat("NA PROPOSTA \"", this.SelectedDocumento.get_Proposta(), "\"");
- }
- else if (this.SelectedDocumento.get_Tipo() != 0 || string.IsNullOrEmpty(this.SelectedDocumento.get_Apolice()))
- {
- str1 = (string.IsNullOrEmpty(this.SelectedDocumento.get_Endosso()) ? string.Concat("NA PROPOSTA DE ENDOSSO \"", this.SelectedDocumento.get_PropostaEndosso(), "\"") : string.Concat("NO ENDOSSO \"", this.SelectedDocumento.get_Endosso(), "\""));
- }
- else
- {
- str1 = string.Concat("NA APÓLICE \"", this.SelectedDocumento.get_Apolice(), "\"");
- }
- string str4 = str1;
- str2 = (this.SelectedDocumento.get_TipoRecebimento().GetValueOrDefault() == 1 ? string.Concat("PARCELA ESPECIAL ADICIONADA, ", str4) : string.Concat("FATURA ", this.SelectedParcela.get_Fatura(), " ADICIONADA, ", str4));
- string str5 = str2;
- base.RegistrarAcao(str5, this.SelectedParcela.get_Id(), new TipoTela?(5), this.GerarObs(this.SelectedDocumento));
- if (this.ParcelaServico.Sucesso)
- {
- BaseApoliceViewModel baseApoliceViewModel = this;
- str3 = (this.SelectedDocumento.get_TipoRecebimento().GetValueOrDefault() == 1 ? "PARCELA ESPECIAL ADICIONADA COM SUCESSO" : "FATURA ADICIONADA COM SUCESSO");
- baseApoliceViewModel.ToggleSnackBar(str3, true);
- }
- await this.CarregarParcelas(this.SelectedDocumento);
- await this.CarregaRepasse(this.SelectedDocumento.get_Id());
- BaseApoliceViewModel baseApoliceViewModel1 = this;
- Parcela selectedParcela3 = this.SelectedParcela;
- if (selectedParcela3 == null)
- {
- selectedParcela3 = this.Parcelas.FirstOrDefault<Parcela>();
- }
- await baseApoliceViewModel1.SelecionaParcela(selectedParcela3);
- this.CalculaComissao(this.SelectedDocumento, this.Parcelas);
- this.BaixarParcelas = false;
- this.CriandoParcelaEspecial = false;
- }
- else
- {
- this.CriandoParcelaEspecial = false;
- await base.ShowMessage("NÃO É POSSIVEL REPLICAR MAIS QUE 12 VEZES A MESMA FATURA. PROCESSO CANCELADO", "OK", "", false);
- }
- }
- }
-
- public async Task<List<KeyValuePair<string, string>>> AdicionarVendedor()
- {
- //
- // Current member / type: System.Threading.Tasks.Task`1<System.Collections.Generic.List`1<System.Collections.Generic.KeyValuePair`2<System.String,System.String>>> Gestor.Application.ViewModels.Generic.BaseApoliceViewModel::AdicionarVendedor()
- // File path: C:\AggerSeguros\Gestor.Application.exe
- //
- // Product version: 0.0.0.0
- // Exception in: System.Threading.Tasks.Task<System.Collections.Generic.List<System.Collections.Generic.KeyValuePair<System.String,System.String>>> AdicionarVendedor()
- //
- // 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.DecompileStateMachine(MethodBody body, DecompilationContext enclosingContext, BaseStateMachineRemoverStep removeStateMachineStep, Func`2 stateMachineDataSelector, DecompilationContext& decompilationContext) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\Extensions.cs:line 104
- // at Telerik.JustDecompiler.Decompiler.Extensions.DecompileAsyncStateMachine(MethodBody body, DecompilationContext enclosingContext, AsyncData& asyncData) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\Extensions.cs:line 150
- // at Telerik.JustDecompiler.Steps.RebuildAsyncStatementsStep.GetMoveNextStatements() in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Steps\RebuildAsyncStatementsStep.cs:line 155
- // at Telerik.JustDecompiler.Steps.RebuildAsyncStatementsStep.Match() in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Steps\RebuildAsyncStatementsStep.cs:line 60
- // at Telerik.JustDecompiler.Steps.RebuildAsyncStatementsStep.Process(DecompilationContext context, BlockStatement body) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Steps\RebuildAsyncStatementsStep.cs:line 31
- // 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.RunPipeline(DecompilationPipeline pipeline, ILanguage language, MethodBody body, DecompilationContext& context) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\Extensions.cs:line 95
- // 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 118
- //
- // mailto: JustDecompilePublicFeedback@telerik.com
-
- }
-
- public async Task<List<KeyValuePair<string, string>>> AdicionarVendedorParcelaEspecial()
- {
- List<KeyValuePair<string, string>> keyValuePairs;
- List<VinculoRepasse> list;
- bool valueOrDefault;
- bool flag;
- bool flag1;
- string str1;
- DateTime? nullable;
- DateTime dateTime;
- DateTime? nullable1;
- DateTime? nullable2;
- bool flag2;
- decimal num;
- List<VinculoRepasse> vinculoRepasses;
- List<VendedorParcela> vendedorParcelas;
- List<KeyValuePair<string, string>> keyValuePairs1 = new List<KeyValuePair<string, string>>();
- if (this.SelectedPagamento == null)
- {
- keyValuePairs1.Add(new KeyValuePair<string, string>("SelectedPagamento|PAGAMENTO", "ERRO AO INCLUIR VENDEDOR."));
- keyValuePairs = keyValuePairs1;
- }
- else if (this.SelectedPagamento.get_Repasse() != null)
- {
- this.SelectedPagamento.set_Parcela(this.SelectedParcela);
- if (this.SelectedDocumento.get_TipoRecebimento().GetValueOrDefault() != 2 || this.SelectedPagamento.get_Repasse().get_Forma().GetValueOrDefault() != 3)
- {
- Gestor.Model.Domain.Seguros.Repasse repasse = this.SelectedPagamento.get_Repasse();
- if (repasse != null)
- {
- List<VinculoRepasse> vinculo = repasse.get_Vinculo();
- if (vinculo != null)
- {
- list = (
- from x in vinculo
- where x.get_TipoVendedor().get_Id() == this.SelectedPagamento.get_TipoVendedor().get_Id()
- select x).ToList<VinculoRepasse>();
- }
- else
- {
- list = null;
- }
- }
- else
- {
- list = null;
- }
- vinculoRepasses = list;
- vendedorParcelas = new List<VendedorParcela>()
- {
- this.SelectedPagamento
- };
- if (this.SelectedDocumento.get_NegocioCorretora().HasValue)
- {
- NegocioCorretora? negocioCorretora = this.SelectedDocumento.get_NegocioCorretora();
- valueOrDefault = negocioCorretora.GetValueOrDefault() == 1;
- }
- else if (this.SelectedDocumento.get_Situacao() != 2 || !this.SelectedDocumento.get_Negocio().HasValue)
- {
- valueOrDefault = false;
- }
- else
- {
- Negocio? negocio = this.SelectedDocumento.get_Negocio();
- valueOrDefault = negocio.GetValueOrDefault() == 1;
- }
- bool flag3 = valueOrDefault;
- flag = (vinculoRepasses == null ? false : vinculoRepasses.Count > 0);
- bool flag4 = flag;
- if (flag4)
- {
- flag4 = await base.ShowMessage("DESEJA ADICIONAR OS REPASSES VINCULADOS?", "SIM", "NÃO", false);
- }
- if (flag4)
- {
- foreach (VinculoRepasse vinculoRepasse in vinculoRepasses)
- {
- Gestor.Model.Domain.Seguros.Repasse repasseVinculo = vinculoRepasse.get_RepasseVinculo();
- Parcela parcela = this.SelectedPagamento.get_Parcela();
- flag2 = (this.SelectedPagamento.get_Parcela() == null ? true : this.SelectedPagamento.get_Parcela().get_SubTipo() == 1);
- decimal num1 = Funcoes.CalculaRepasse(repasseVinculo, parcela, flag2);
- VendedorParcela vendedorParcela = new VendedorParcela();
- vendedorParcela.set_TipoVendedor(vinculoRepasse.get_TipoVendedorVinculo());
- vendedorParcela.set_Vendedor(vinculoRepasse.get_RepasseVinculo().get_Vendedor());
- vendedorParcela.set_Repasse(vinculoRepasse.get_RepasseVinculo());
- vendedorParcela.set_Documento(this.SelectedPagamento.get_Documento());
- vendedorParcela.set_Parcela(this.SelectedPagamento.get_Parcela());
- num = (flag3 ? vinculoRepasse.get_RepasseVinculo().get_ValorRenovacao() : vinculoRepasse.get_RepasseVinculo().get_ValorNovo());
- vendedorParcela.set_PorcentagemRepasse(new decimal?(num));
- vendedorParcela.set_ValorRepasse(new decimal?(num1));
- vendedorParcela.set_ValorTotal(new decimal?(num1));
- vendedorParcelas.Add(vendedorParcela);
- }
- }
- foreach (VendedorParcela vendedorParcela1 in vendedorParcelas)
- {
- VendedorParcela vendedorParcela2 = vendedorParcela1;
- keyValuePairs1 = vendedorParcela2.Validate();
- keyValuePairs1.AddRange(this.ValidateEspecial(vendedorParcela2));
- if (keyValuePairs1.Count <= 0)
- {
- if (vendedorParcela2.get_Repasse() != null)
- {
- BaseRepasse? @base = vendedorParcela2.get_Repasse().get_Base();
- if (@base.HasValue)
- {
- switch (@base.GetValueOrDefault())
- {
- case 1:
- {
- VendedorParcela vendedorParcela3 = vendedorParcela2;
- nullable = (this.SelectedDocumento.get_TipoRecebimento().GetValueOrDefault() == 2 ? vendedorParcela2.get_Parcela().get_VigenciaIncial() : new DateTime?(this.SelectedDocumento.get_Vigencia1()));
- vendedorParcela3.set_DataPrePagamento(nullable);
- break;
- }
- case 2:
- {
- vendedorParcela2.set_DataPrePagamento(vendedorParcela2.get_Parcela().get_DataCriacao());
- break;
- }
- case 3:
- {
- VendedorParcela vendedorParcela4 = vendedorParcela2;
- dateTime = (vendedorParcela2.get_Parcela().get_Vencimento() == DateTime.MinValue ? this.SelectedDocumento.get_Vigencia1() : vendedorParcela2.get_Parcela().get_Vencimento());
- vendedorParcela4.set_DataPrePagamento(new DateTime?(dateTime));
- break;
- }
- case 4:
- {
- VendedorParcela vendedorParcela5 = vendedorParcela2;
- nullable1 = (this.SelectedDocumento.get_TipoRecebimento().GetValueOrDefault() == 2 ? vendedorParcela2.get_Parcela().get_Emissao() : this.SelectedDocumento.get_Emissao());
- vendedorParcela5.set_DataPrePagamento(nullable1);
- break;
- }
- case 5:
- {
- VendedorParcela vendedorParcela6 = vendedorParcela2;
- nullable2 = (this.SelectedDocumento.get_TipoRecebimento().GetValueOrDefault() == 2 ? vendedorParcela2.get_Parcela().get_Emissao() : this.SelectedDocumento.get_Remessa());
- vendedorParcela6.set_DataPrePagamento(nullable2);
- break;
- }
- }
- }
- }
- if (this.Pagamentos == null)
- {
- this.Pagamentos = new ObservableCollection<VendedorParcela>();
- }
- VendedorParcela vendedorParcela7 = this.Repasses.FirstOrDefault<VendedorParcela>((VendedorParcela x) => {
- if (x.get_Parcela().get_Id() != this.SelectedParcela.get_Id() || x.get_TipoVendedor().get_Id() != (long)1)
- {
- return false;
- }
- return x.get_Vendedor().get_Corretora();
- });
- flag1 = (vendedorParcela2.get_TipoVendedor().get_Id() != (long)1 ? false : vendedorParcela7 != null);
- bool flag5 = flag1;
- if (this.SelectedParcela.get_Id() != 0)
- {
- if (vendedorParcela2.get_Repasse().get_Forma().GetValueOrDefault() == 1)
- {
- vendedorParcela2.set_DataPrePagamento(this.SelectedParcela.get_DataRecebimento());
- }
- List<VendedorParcela> vendedorParcelas1 = new List<VendedorParcela>()
- {
- vendedorParcela2
- };
- vendedorParcelas1 = await this.Servico.IncluirVendedores(vendedorParcelas1);
- if (this.SelectedDocumento.get_Tipo() == 0 && string.IsNullOrEmpty(this.SelectedDocumento.get_Apolice()))
- {
- str1 = string.Concat("NA PROPOSTA \"", this.SelectedDocumento.get_Proposta(), "\"");
- }
- else if (this.SelectedDocumento.get_Tipo() != 0 || string.IsNullOrEmpty(this.SelectedDocumento.get_Apolice()))
- {
- str1 = (string.IsNullOrEmpty(this.SelectedDocumento.get_Endosso()) ? string.Concat("NA PROPOSTA DE ENDOSSO \"", this.SelectedDocumento.get_PropostaEndosso(), "\"") : string.Concat("NO ENDOSSO \"", this.SelectedDocumento.get_Endosso(), "\""));
- }
- else
- {
- str1 = string.Concat("NA APÓLICE \"", this.SelectedDocumento.get_Apolice(), "\"");
- }
- string str2 = str1;
- if (vendedorParcelas1 != null)
- {
- vendedorParcelas1.ForEach((VendedorParcela x) => {
- string str = string.Concat("VENDEDOR ", x.get_Vendedor().get_Nome(), " ADICIONADO A PARCELA ESPECIAL, ", str2);
- base.RegistrarAcao(str, x.get_Id(), new TipoTela?(37), string.Format("{0}{1}VENDEDOR: {2}{3}COMISSÃO TOTAL: {4:C2}", new object[] { this.GerarObs(this.SelectedDocumento), Environment.NewLine, x.get_Vendedor().get_Nome(), Environment.NewLine, x.get_ValorTotal() }));
- });
- }
- this.Repasses.AddRange(vendedorParcelas1);
- if (flag5)
- {
- await this.ExcluirVendedor(vendedorParcela7, false);
- }
- this.Repasses = await this.VendedorServico.BuscaRepasse(this.SelectedDocumento.get_Id());
- BaseApoliceViewModel baseApoliceViewModel = this;
- Parcela selectedParcela = this.SelectedParcela;
- if (selectedParcela == null)
- {
- selectedParcela = this.Parcelas.FirstOrDefault<Parcela>();
- }
- await baseApoliceViewModel.SelecionaParcela(selectedParcela);
- this.SelectedPagamento = null;
- vendedorParcela7 = null;
- }
- else
- {
- this.Repasses.Add(vendedorParcela2);
- this.Pagamentos.Add(vendedorParcela2);
- this.SelectedPagamento = null;
- if (!this.IsFatura && this.SelectedParcela.get_SubTipo() == 1 || !flag5)
- {
- continue;
- }
- await this.ExcluirVendedor(vendedorParcela7, false);
- }
- }
- else
- {
- if (this.SelectedPagamento == null)
- {
- this.SelectedPagamento = vendedorParcela2;
- }
- keyValuePairs = keyValuePairs1;
- vinculoRepasses = null;
- vendedorParcelas = null;
- return keyValuePairs;
- }
- }
- base.ToggleSnackBar("VENDEDOR ADICIONADO COM SUCESSO", true);
- keyValuePairs = null;
- }
- else
- {
- base.ShowMessage("NÃO É POSSÍVEL ADICIONAR UM VENDEDOR COM A FORMA DE PAGAMENTO À PRAZO EM DOCUMENTOS DO TIPO FATURA", "OK", "", false);
- keyValuePairs = null;
- }
- }
- else
- {
- keyValuePairs1.Add(new KeyValuePair<string, string>("Repasse|REPASSE", "ERRO AO INCLUIR VENDEDOR."));
- keyValuePairs = keyValuePairs1;
- }
- vinculoRepasses = null;
- vendedorParcelas = null;
- return keyValuePairs;
- }
-
- public async void AjustaParcelasCoCorretagem()
- {
- int num = 0;
- try
- {
- ObservableCollection<Parcela> parcelas = this.Parcelas;
- foreach (Parcela parcela in parcelas)
- {
- if (parcela.get_NumeroParcela() != 999)
- {
- parcela.set_Comissao(this.SelectedDocumento.get_Comissao());
- }
- else
- {
- return;
- }
- }
- this.Parcelas = new ObservableCollection<Parcela>(await this.ParcelaServico.SaveRange(parcelas.ToList<Parcela>()));
- await this.CarregarParcelas(this.SelectedDocumento);
- }
- catch
- {
- num = 1;
- }
- if (num == 1)
- {
- await base.ShowMessage("NÃO FOI POSSÍVEL SALVAR AS PARCELAS", "OK", "", false);
- }
- }
-
- public async Task AjusteComissãoCoCorretagem(bool removido = false)
- {
- decimal? nullable;
- decimal valorNovo;
- decimal? comissaoTotal;
- int num = 0;
- try
- {
- if (!removido)
- {
- VendedorParcela selectedPagamento = this.SelectedPagamento;
- if (selectedPagamento != null)
- {
- valorNovo = selectedPagamento.get_Repasse().get_ValorNovo();
- }
- else
- {
- valorNovo = decimal.Zero;
- }
- decimal num1 = valorNovo;
- decimal comissao = this.SelectedDocumento.get_Comissao();
- this.SelectedDocumento.set_ComissaoTotal(new decimal?(comissao));
- this.SelectedDocumento.set_Comissao(Math.Round(comissao - (comissao * num1 * new decimal(1, 0, 0, false, 2)), 2));
- this.SelectedDocumento = await this.Servico.Save(this.SelectedDocumento, false, false);
- this.AjustaParcelasCoCorretagem();
- this.CalculaComissao(this.SelectedDocumento, this.Parcelas);
- }
- else
- {
- Documento selectedDocumento = this.SelectedDocumento;
- Documento documento = this.SelectedDocumento;
- if (documento != null)
- {
- comissaoTotal = documento.get_ComissaoTotal();
- }
- else
- {
- nullable = null;
- comissaoTotal = nullable;
- }
- nullable = comissaoTotal;
- selectedDocumento.set_Comissao(nullable.GetValueOrDefault());
- this.SelectedDocumento = await this.Servico.Save(this.SelectedDocumento, false, false);
- this.AjustaParcelasCoCorretagem();
- this.CalculaComissao(this.SelectedDocumento, this.Parcelas);
- return;
- }
- }
- catch
- {
- num = 1;
- }
- if (num == 1)
- {
- await base.ShowMessage("NÃO FOI POSSÍVEL ALTERAR A COMISSÃO DA CO-CORRETAGEM", "OK", "", false);
- }
- }
-
- public async Task AlterarVencimento()
- {
- //
- // Current member / type: System.Threading.Tasks.Task Gestor.Application.ViewModels.Generic.BaseApoliceViewModel::AlterarVencimento()
- // File path: C:\AggerSeguros\Gestor.Application.exe
- //
- // Product version: 0.0.0.0
- // Exception in: System.Threading.Tasks.Task AlterarVencimento()
- //
- // An item with the same key has already been added. Key: Label0
- // at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
- // at System.Collections.Generic.Dictionary`2.System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<TKey,TValue>>.Add(KeyValuePair`2 keyValuePair)
- // at Telerik.JustDecompiler.Common.Extensions.AddRange[TKey,TValue](IDictionary`2 self, IDictionary`2 source) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Common\Extensions.cs:line 99
- // at Telerik.JustDecompiler.Steps.RebuildAnonymousDelegatesStep.AnonymousDelegateRebuilder.VisitObjectCreationExpression(ObjectCreationExpression node) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Steps\RebuildAnonymousDelegatesStep.cs:line 332
- // at Telerik.JustDecompiler.Ast.BaseCodeTransformer.Visit(ICodeNode node) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Ast\BaseCodeTransformer.cs:line 273
- // at Telerik.JustDecompiler.Ast.BaseCodeTransformer.Visit[TCollection,TElement](TCollection original) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Ast\BaseCodeTransformer.cs:line 312
- // at Telerik.JustDecompiler.Ast.BaseCodeTransformer.VisitMethodInvocationExpression(MethodInvocationExpression node) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Ast\BaseCodeTransformer.cs:line 500
- // at Telerik.JustDecompiler.Ast.BaseCodeTransformer.Visit(ICodeNode node) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Ast\BaseCodeTransformer.cs:line 273
- // at Telerik.JustDecompiler.Ast.BaseCodeTransformer.VisitExpressionStatement(ExpressionStatement node) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Ast\BaseCodeTransformer.cs:line 384
- // at Telerik.JustDecompiler.Ast.BaseCodeTransformer.Visit(ICodeNode node) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Ast\BaseCodeTransformer.cs:line 273
- // at Telerik.JustDecompiler.Steps.RebuildAnonymousDelegatesStep.AnonymousDelegateRebuilder.Match(BlockStatement theBlock, Int32 index) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Steps\RebuildAnonymousDelegatesStep.cs:line 74
- // at Telerik.JustDecompiler.Steps.RebuildAnonymousDelegatesStep.VisitBlockStatement(BlockStatement node) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Steps\RebuildAnonymousDelegatesStep.cs:line 30
- // at Telerik.JustDecompiler.Ast.BaseCodeVisitor.Visit(ICodeNode node) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Ast\BaseCodeVisitor.cs:line 351
- // at Telerik.JustDecompiler.Ast.BaseCodeVisitor.VisitIfStatement(IfStatement node) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Ast\BaseCodeVisitor.cs:line 409
- // at Telerik.JustDecompiler.Ast.BaseCodeVisitor.Visit(ICodeNode node) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Ast\BaseCodeVisitor.cs:line 351
- // at Telerik.JustDecompiler.Ast.BaseCodeVisitor.Visit(IEnumerable collection) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Ast\BaseCodeVisitor.cs:line 384
- // at Telerik.JustDecompiler.Steps.RebuildAnonymousDelegatesStep.VisitBlockStatement(BlockStatement node) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Steps\RebuildAnonymousDelegatesStep.cs:line 33
- // at Telerik.JustDecompiler.Ast.BaseCodeVisitor.Visit(ICodeNode node) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Ast\BaseCodeVisitor.cs:line 351
- // at Telerik.JustDecompiler.Ast.BaseCodeVisitor.VisitIfStatement(IfStatement node) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Ast\BaseCodeVisitor.cs:line 408
- // at Telerik.JustDecompiler.Ast.BaseCodeVisitor.Visit(ICodeNode node) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Ast\BaseCodeVisitor.cs:line 351
- // at Telerik.JustDecompiler.Ast.BaseCodeVisitor.Visit(IEnumerable collection) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Ast\BaseCodeVisitor.cs:line 384
- // at Telerik.JustDecompiler.Steps.RebuildAnonymousDelegatesStep.VisitBlockStatement(BlockStatement node) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Steps\RebuildAnonymousDelegatesStep.cs:line 33
- // at Telerik.JustDecompiler.Steps.RebuildAnonymousDelegatesStep.Process(DecompilationContext context, BlockStatement body) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Steps\RebuildAnonymousDelegatesStep.cs:line 21
- // 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.RunPipeline(DecompilationPipeline pipeline, ILanguage language, MethodBody body, DecompilationContext& context) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\Extensions.cs:line 95
- // 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 118
- //
- // mailto: JustDecompilePublicFeedback@telerik.com
-
- }
-
- private void AtualizaValores(bool renovacao)
- {
- this.Repasses.ForEach((VendedorParcela x) => {
- decimal? nullable;
- decimal? comissaoTotal;
- if (x.get_Repasse() == null)
- {
- return;
- }
- if (x.get_Repasse().get_Tipo().GetValueOrDefault() == 1)
- {
- return;
- }
- Parcela parcela = x.get_Parcela();
- if (parcela.get_SubTipo() != 1)
- {
- return;
- }
- parcela.set_Documento(this.SelectedDocumento);
- decimal numeroParcelas = Funcoes.CalculaRepasse(x.get_Repasse(), parcela, true);
- decimal valorNovo = (renovacao ? x.get_Repasse().get_ValorRenovacao() : x.get_Repasse().get_ValorNovo());
- if (x.get_CoCorretagem())
- {
- valorNovo = x.get_Repasse().get_ValorNovo();
- }
- if (x.get_Repasse().get_Forma().GetValueOrDefault() == 3)
- {
- numeroParcelas /= this.SelectedDocumento.get_NumeroParcelas();
- }
- if (x.get_CoCorretagem())
- {
- decimal comissao = this.SelectedDocumento.get_Comissao();
- Documento selectedDocumento = this.SelectedDocumento;
- if (selectedDocumento != null)
- {
- comissaoTotal = selectedDocumento.get_ComissaoTotal();
- }
- else
- {
- nullable = null;
- comissaoTotal = nullable;
- }
- nullable = comissaoTotal;
- decimal valueOrDefault = nullable.GetValueOrDefault();
- numeroParcelas = this.SelectedDocumento.get_PremioLiquido() * ((valueOrDefault - comissao) / new decimal(100));
- }
- x.set_PorcentagemRepasse(new decimal?(valorNovo));
- x.set_ValorRepasse(new decimal?(numeroParcelas));
- x.set_ValorTotal(new decimal?(numeroParcelas));
- });
- decimal num = (this.Parcelas.Count<Parcela>((Parcela x) => x.get_SubTipo() == 1) > 0 ? this.SelectedDocumento.get_PremioTotal() / this.Parcelas.Count<Parcela>((Parcela x) => x.get_SubTipo() == 1) : decimal.Zero);
- (
- from x in this.Parcelas
- where x.get_SubTipo() == 1
- select x).ToList<Parcela>().ForEach((Parcela x) => {
- x.set_Valor(num);
- x.set_Comissao(this.SelectedDocumento.get_Comissao());
- x.set_Vendedores(new ObservableCollection<VendedorParcela>(
- from r in this.Repasses
- where r.get_Parcela().get_Id() == x.get_Id()
- select r));
- });
- }
-
- internal async Task BaixarComissao()
- {
- decimal? nullable;
- bool valueOrDefault;
- decimal? tolerancia;
- decimal num;
- bool tipo;
- bool flag;
- string endosso;
- string propostaEndosso;
- string str;
- bool valueOrDefault1;
- string str1;
- bool flag1;
- long? nullable1;
- if (this.SelectedParcela != null)
- {
- base.Loading(true);
- if (!this.IsFatura)
- {
- valueOrDefault = false;
- }
- else
- {
- ObservableCollection<Parcela> parcelas = this.Parcelas;
- IOrderedEnumerable<Parcela> numeroParcela =
- from x in parcelas
- orderby x.get_NumeroParcela()
- select x;
- Parcela parcela = numeroParcela.LastOrDefault<Parcela>((Parcela x) => x.get_SubTipo() == 1);
- if (parcela != null)
- {
- nullable1 = new long?(parcela.get_Id());
- }
- else
- {
- nullable1 = null;
- }
- long? nullable2 = nullable1;
- long id = this.SelectedParcela.get_Id();
- valueOrDefault = nullable2.GetValueOrDefault() == id & nullable2.HasValue;
- }
- bool flag2 = valueOrDefault;
- this.SelectedParcela.set_Documento(this.SelectedDocumento);
- Parcela selectedParcela = this.SelectedParcela;
- List<Parcela> list = this.Parcelas.ToList<Parcela>();
- List<VendedorParcela> repasses = this.Repasses;
- Documento selectedDocumento = this.SelectedDocumento;
- if (selectedDocumento != null)
- {
- Controle controle = selectedDocumento.get_Controle();
- if (controle != null)
- {
- Seguradora seguradora = controle.get_Seguradora();
- if (seguradora != null)
- {
- tolerancia = seguradora.get_Tolerancia();
- }
- else
- {
- nullable = null;
- tolerancia = nullable;
- }
- }
- else
- {
- nullable = null;
- tolerancia = nullable;
- }
- }
- else
- {
- nullable = null;
- tolerancia = nullable;
- }
- decimal? nullable3 = tolerancia;
- num = (nullable3.HasValue ? nullable3.GetValueOrDefault() : this.Tolerancia);
- this.SelectedParcela = await Funcoes.BaixarComissao(selectedParcela, list, repasses, num, false);
- Documento documento = this.SelectedDocumento;
- if (documento != null)
- {
- tipo = documento.get_Tipo() == 0;
- }
- else
- {
- tipo = false;
- }
- if (!tipo || !string.IsNullOrEmpty(this.SelectedDocumento.get_Apolice()))
- {
- Documento selectedDocumento1 = this.SelectedDocumento;
- if (selectedDocumento1 != null)
- {
- flag = selectedDocumento1.get_Tipo() == 0;
- }
- else
- {
- flag = false;
- }
- if (!flag || string.IsNullOrEmpty(this.SelectedDocumento.get_Apolice()))
- {
- Documento documento1 = this.SelectedDocumento;
- if (documento1 != null)
- {
- endosso = documento1.get_Endosso();
- }
- else
- {
- endosso = null;
- }
- if (string.IsNullOrEmpty(endosso))
- {
- Documento selectedDocumento2 = this.SelectedDocumento;
- if (selectedDocumento2 != null)
- {
- propostaEndosso = selectedDocumento2.get_PropostaEndosso();
- }
- else
- {
- propostaEndosso = null;
- }
- str = string.Concat("PROPOSTA DE ENDOSSO ", propostaEndosso);
- }
- else
- {
- str = string.Concat("ENDOSSO ", this.SelectedDocumento.get_Endosso());
- }
- }
- else
- {
- str = string.Concat("APÓLICE ", this.SelectedDocumento.get_Apolice());
- }
- }
- else
- {
- str = string.Concat("PROPOSTA ", this.SelectedDocumento.get_Proposta());
- }
- string str2 = str;
- Documento documento2 = this.SelectedDocumento;
- if (documento2 != null)
- {
- valueOrDefault1 = documento2.get_TipoRecebimento().GetValueOrDefault() == 1;
- }
- else
- {
- valueOrDefault1 = false;
- }
- str1 = (valueOrDefault1 ? string.Format("PARCELA {0} BAIXADA, {1}", this.SelectedParcela.get_NumeroParcela(), str2) : string.Concat("FATURA ", this.SelectedParcela.get_Fatura(), " BAIXADA, ", str2));
- string str3 = str1;
- base.RegistrarAcao(str3, this.SelectedParcela.get_Id(), new TipoTela?(5), this.GerarObs(this.SelectedDocumento));
- if (this.SelectedDocumento != null)
- {
- await this.CarregarParcelas(this.SelectedDocumento);
- await this.CarregaRepasse(this.SelectedDocumento.get_Id());
- this.CalculaComissao(this.SelectedDocumento, this.Parcelas);
- }
- BaseApoliceViewModel baseApoliceViewModel = this;
- Parcela selectedParcela1 = this.SelectedParcela;
- if (selectedParcela1 == null)
- {
- selectedParcela1 = this.Parcelas.FirstOrDefault<Parcela>();
- }
- await baseApoliceViewModel.SelecionaParcela(selectedParcela1);
- this.BaixarParcelas = false;
- BaseApoliceViewModel baseApoliceViewModel1 = this;
- ObservableCollection<Parcela> observableCollection = this.Parcelas;
- IEnumerable<Parcela> subTipo =
- from x in observableCollection
- where x.get_SubTipo() == 1
- select x;
- if (!subTipo.All<Parcela>((Parcela x) => !x.get_DataRecebimento().HasValue))
- {
- flag1 = false;
- }
- else
- {
- List<VendedorParcela> vendedorParcelas = this.Repasses;
- IEnumerable<VendedorParcela> subTipo1 =
- from x in vendedorParcelas
- where x.get_Parcela().get_SubTipo() == 1
- select x;
- flag1 = subTipo1.All<VendedorParcela>((VendedorParcela x) => !x.get_DataPagamento().HasValue);
- }
- baseApoliceViewModel1.AllowEditApolice = flag1;
- base.Loading(false);
- bool flag3 = flag2;
- if (flag3)
- {
- flag3 = await base.ShowMessage("DESEJA INCLUIR A PRÓXIMA FATURA?", "SIM", "NÃO", false);
- }
- if (flag3)
- {
- this.UltimaFatura = true;
- }
- base.ToggleSnackBar("PARCELA BAIXADA COM SUCESSO", true);
- }
- }
-
- public async Task BuscarVendedores(bool verificarRamo = true)
- {
- List<Vendedor> vendedors1;
- List<Vendedor> vendedores;
- bool ramo;
- bool id;
- Func<Gestor.Model.Domain.Seguros.Repasse, bool> func = null;
- if (this.RepassesVendedores == null)
- {
- this.RepassesVendedores = await this.VendedorServico.BuscaRepasses();
- BaseApoliceViewModel list = this;
- List<Gestor.Model.Domain.Seguros.Repasse> repassesVendedores = this.RepassesVendedores;
- IEnumerable<IGrouping<long, Gestor.Model.Domain.Seguros.Repasse>> groupings =
- from x in repassesVendedores
- group x by x.get_Vendedor().get_Id();
- IEnumerable<Vendedor> vendedor =
- from x in groupings
- select x.First<Gestor.Model.Domain.Seguros.Repasse>().get_Vendedor();
- list.TodosVendedores = (
- from x in vendedor
- orderby x.get_Nome()
- select x).ToList<Vendedor>();
- }
- Documento selectedDocumento = this.SelectedDocumento;
- if (selectedDocumento != null)
- {
- vendedores = selectedDocumento.get_Vendedores();
- }
- else
- {
- vendedores = null;
- }
- List<Vendedor> vendedors2 = vendedores;
- if (vendedors2 == null)
- {
- Documento documento = this.SelectedDocumento;
- if (documento != null)
- {
- id = documento.get_Id() > (long)0;
- }
- else
- {
- id = false;
- }
- if (!id)
- {
- vendedors1 = new List<Vendedor>();
- }
- else
- {
- vendedors1 = await this.ParcelaServico.BuscarVendedores(this.SelectedDocumento.get_Id());
- }
- vendedors2 = vendedors1;
- }
- List<Vendedor> vendedors3 = vendedors2;
- this.Vendedores = this.TodosVendedores.Where<Vendedor>((Vendedor x) => {
- if (x.get_IdEmpresa() != Recursos.Usuario.get_IdEmpresa())
- {
- List<Vendedor> vendedors = vendedors3;
- Func<Vendedor, long> u003cu003e9_1475 = BaseApoliceViewModel.u003cu003ec.u003cu003e9__147_5;
- if (u003cu003e9_1475 == null)
- {
- u003cu003e9_1475 = (Vendedor y) => y.get_Id();
- BaseApoliceViewModel.u003cu003ec.u003cu003e9__147_5 = u003cu003e9_1475;
- }
- if (!vendedors.Select<Vendedor, long>(u003cu003e9_1475).Contains<long>(x.get_Id()))
- {
- return false;
- }
- }
- if (x.get_Ativo())
- {
- return !x.get_Corretora();
- }
- return false;
- }).ToList<Vendedor>();
- List<VendedorUsuario> vendedorUsuarios = await base.VerificaVinculoVendedor(Recursos.Usuario);
- if (vendedorUsuarios.Count > 0)
- {
- vendedorUsuarios.ForEach((VendedorUsuario x) => vendedors3.Add(x.get_Vendedor()));
- this.Vendedores = vendedors3;
- }
- if (verificarRamo)
- {
- Documento selectedDocumento1 = this.SelectedDocumento;
- if (selectedDocumento1 != null)
- {
- Controle controle = selectedDocumento1.get_Controle();
- if (controle != null)
- {
- ramo = controle.get_Ramo();
- }
- else
- {
- ramo = false;
- }
- }
- else
- {
- ramo = false;
- }
- if (ramo)
- {
- for (int i = this.Vendedores.Count - 1; i >= 0; i--)
- {
- List<Gestor.Model.Domain.Seguros.Repasse> repasses = this.GetRepasses(this.Vendedores[i]);
- List<Gestor.Model.Domain.Seguros.Repasse> repasses1 = repasses;
- if (!repasses1.Any<Gestor.Model.Domain.Seguros.Repasse>((Gestor.Model.Domain.Seguros.Repasse x) => x.get_Ramo() == null))
- {
- List<Gestor.Model.Domain.Seguros.Repasse> repasses2 = repasses;
- Func<Gestor.Model.Domain.Seguros.Repasse, bool> func1 = func;
- if (func1 == null)
- {
- Func<Gestor.Model.Domain.Seguros.Repasse, bool> id1 = (Gestor.Model.Domain.Seguros.Repasse x) => x.get_Ramo().get_Id() != this.SelectedDocumento.get_Controle().get_Ramo().get_Id();
- Func<Gestor.Model.Domain.Seguros.Repasse, bool> func2 = id1;
- func = id1;
- func1 = func2;
- }
- if (repasses2.All<Gestor.Model.Domain.Seguros.Repasse>(func1))
- {
- this.Vendedores.Remove(this.Vendedores[i]);
- }
- }
- }
- }
- }
- }
-
- private void CalculaComissao(Documento documento, ObservableCollection<Parcela> parcelas)
- {
- decimal? nullable;
- decimal? comissaoTotal;
- decimal num = (documento.get_AdicionalComiss() ? documento.get_PremioLiquido() + documento.get_PremioAdicional() : documento.get_PremioLiquido());
- decimal comissao = documento.get_Comissao() * new decimal(1, 0, 0, false, 2);
- this.Gerada = num * comissao;
- this.Recebida = (Recursos.Configuracoes.Any<ConfiguracaoSistema>((ConfiguracaoSistema x) => x.get_Configuracao() == 32) ? parcelas.Where<Parcela>((Parcela x) => {
- if (x.get_SubTipo() == 1)
- {
- return true;
- }
- return x.get_SubTipo() == 6;
- }).Sum<Parcela>((Parcela x) => x.get_ValorComissao()) : (
- from x in parcelas
- where x.get_SubTipo() == 1
- select x).Sum<Parcela>((Parcela x) => x.get_ValorComissao()));
- this.Pendente = this.Gerada - this.Recebida;
- this.Pendente = (this.Pendente < new decimal(1, 0, 0, false, 2) ? new decimal(0, 0, 0, false, 2) : this.Pendente);
- this.Repasse = this.Repasses.Where<VendedorParcela>((VendedorParcela x) => {
- if (!x.get_DataPrePagamento().HasValue)
- {
- return false;
- }
- return !x.get_CoCorretagem();
- }).Sum<VendedorParcela>((VendedorParcela x) => x.get_ValorRepasse().GetValueOrDefault());
- if (this.Pendente < this.Tolerancia)
- {
- this.Pendente = decimal.Zero;
- }
- if (this.VerificaCoCorretagem())
- {
- Documento selectedDocumento = this.SelectedDocumento;
- if (selectedDocumento != null)
- {
- comissaoTotal = selectedDocumento.get_ComissaoTotal();
- }
- else
- {
- nullable = null;
- comissaoTotal = nullable;
- }
- nullable = comissaoTotal;
- this.ComissOriginal = nullable.GetValueOrDefault();
- }
- }
-
- public VendedorParcela CalculaRepasse(Gestor.Model.Domain.Seguros.Repasse repasse, TipoVendedor tipoVendedor)
- {
- NegocioCorretora? negocioCorretora = this.SelectedDocumento.get_NegocioCorretora();
- bool valueOrDefault = negocioCorretora.GetValueOrDefault() == 1;
- if (this.SelectedParcela == null)
- {
- Parcela parcela = new Parcela();
- parcela.set_SubTipo(1);
- parcela.set_IdEmpresa(this.SelectedDocumento.get_Controle().get_IdEmpresa());
- this.SelectedParcela = parcela;
- }
- this.SelectedParcela.set_Documento(this.SelectedDocumento);
- decimal num = Funcoes.CalculaRepasse(repasse, this.SelectedParcela, true);
- VendedorParcela vendedorParcela = new VendedorParcela();
- vendedorParcela.set_Repasse(repasse);
- vendedorParcela.set_ValorRepasse(new decimal?(num));
- vendedorParcela.set_ValorTotal(new decimal?(num));
- vendedorParcela.set_Vendedor(repasse.get_Vendedor());
- vendedorParcela.set_PorcentagemRepasse(new decimal?((valueOrDefault ? repasse.get_ValorRenovacao() : repasse.get_ValorNovo())));
- vendedorParcela.set_TipoVendedor(tipoVendedor);
- vendedorParcela.set_CoCorretagem((repasse != null ? repasse.get_Tipo().GetValueOrDefault() == 3 : false));
- return vendedorParcela;
- }
-
- public async Task CancelarAlteracao()
- {
- this.Acesso = 0;
- if (this.CancelDocumento == null || this.CancelDocumento.get_Id() == 0)
- {
- this.SelectedDocumento = null;
- }
- else
- {
- await this.SelecionaDocumento(this.CancelDocumento);
- }
- this.Anotacoes = string.Empty;
- base.EnableFields = false;
- Action<bool> enableMainMenu = Gestor.Application.Actions.Actions.EnableMainMenu;
- if (enableMainMenu != null)
- {
- enableMainMenu(true);
- }
- else
- {
- }
- Action<bool> enableMenu = Gestor.Application.Actions.Actions.EnableMenu;
- if (enableMenu != null)
- {
- enableMenu(true);
- }
- else
- {
- }
- Action<bool> enablePesquisarClientes = Gestor.Application.Actions.Actions.EnablePesquisarClientes;
- if (enablePesquisarClientes != null)
- {
- enablePesquisarClientes(true);
- }
- else
- {
- }
- }
-
- public async void CancelPagamento()
- {
- ObservableCollection<Parcela> observableCollection;
- this.BaixarParcelas = false;
- this.SelectedParcela.set_Baixando(false);
- ObservableCollection<Parcela> observableCollection1 = await this.ParcelaServico.BuscarParcelasAsync(this.SelectedDocumento.get_Id());
- BaseApoliceViewModel baseApoliceViewModel = this;
- if (this.IsFatura)
- {
- ObservableCollection<Parcela> observableCollection2 = observableCollection1;
- observableCollection = new ObservableCollection<Parcela>(
- from x in observableCollection2
- orderby x.get_NumeroParcela() descending
- select x);
- }
- else
- {
- observableCollection = observableCollection1;
- }
- baseApoliceViewModel.Parcelas = observableCollection;
- await this.CarregaRepasse(this.SelectedDocumento.get_Id());
- await this.SelecionaParcela(this.Parcelas.FirstOrDefault<Parcela>());
- }
-
- public async Task CarregaRepasse(long id)
- {
- this.Repasses = await this.VendedorServico.BuscaRepasse(id);
- BaseApoliceViewModel baseApoliceViewModel = this;
- Parcela selectedParcela = this.SelectedParcela;
- if (selectedParcela == null)
- {
- selectedParcela = this.Parcelas.FirstOrDefault<Parcela>();
- }
- await baseApoliceViewModel.SelecionaParcela(selectedParcela);
- }
-
- public async Task CarregarImposto()
- {
- List<Gestor.Model.Domain.Ferramentas.Imposto> impostos = await (new ImpostoServico()).Buscar(new bool?(true));
- Gestor.Model.Domain.Ferramentas.Imposto imposto = impostos.FirstOrDefault<Gestor.Model.Domain.Ferramentas.Imposto>((Gestor.Model.Domain.Ferramentas.Imposto x) => {
- if (x.get_Seguradora() == null || x.get_Seguradora().get_Id() != this.SelectedDocumento.get_Controle().get_Seguradora().get_Id() || x.get_Ramo() == null)
- {
- return false;
- }
- return x.get_Ramo().get_Id() == this.SelectedDocumento.get_Controle().get_Ramo().get_Id();
- });
- if (imposto == null)
- {
- imposto = impostos.FirstOrDefault<Gestor.Model.Domain.Ferramentas.Imposto>((Gestor.Model.Domain.Ferramentas.Imposto x) => {
- if (x.get_Seguradora() == null || x.get_Seguradora().get_Id() != this.SelectedDocumento.get_Controle().get_Seguradora().get_Id())
- {
- return false;
- }
- return x.get_Ramo() == null;
- });
- }
- if (imposto == null)
- {
- imposto = impostos.FirstOrDefault<Gestor.Model.Domain.Ferramentas.Imposto>((Gestor.Model.Domain.Ferramentas.Imposto x) => {
- if (x.get_Seguradora() != null || x.get_Ramo() == null)
- {
- return false;
- }
- return x.get_Ramo().get_Id() == this.SelectedDocumento.get_Controle().get_Ramo().get_Id();
- });
- }
- if (imposto == null)
- {
- List<Gestor.Model.Domain.Ferramentas.Imposto> impostos1 = impostos;
- imposto = impostos1.FirstOrDefault<Gestor.Model.Domain.Ferramentas.Imposto>((Gestor.Model.Domain.Ferramentas.Imposto x) => {
- if (x.get_Seguradora() != null)
- {
- return false;
- }
- return x.get_Ramo() == null;
- });
- }
- Gestor.Model.Domain.Ferramentas.Imposto imposto1 = imposto;
- BaseApoliceViewModel baseApoliceViewModel = this;
- Gestor.Model.Domain.Ferramentas.Imposto imposto2 = imposto1;
- if (imposto2 == null)
- {
- imposto2 = new Gestor.Model.Domain.Ferramentas.Imposto();
- }
- baseApoliceViewModel.Imposto = imposto2;
- }
-
- public async Task CarregarParcelas(Documento documento)
- {
- ObservableCollection<Parcela> observableCollection;
- if (documento != null)
- {
- ObservableCollection<Parcela> observableCollection1 = await this.ParcelaServico.BuscarParcelasPorDocumento(documento);
- BaseApoliceViewModel baseApoliceViewModel = this;
- if (this.IsFatura)
- {
- ObservableCollection<Parcela> observableCollection2 = observableCollection1;
- observableCollection = new ObservableCollection<Parcela>(
- from x in observableCollection2
- orderby x.get_NumeroParcela() descending
- select x);
- }
- else
- {
- observableCollection = observableCollection1;
- }
- baseApoliceViewModel.Parcelas = observableCollection;
- if (this.Invoke)
- {
- Action<Documento> recarregarParcelas = Gestor.Application.Actions.Actions.RecarregarParcelas;
- if (recarregarParcelas != null)
- {
- recarregarParcelas(this.SelectedDocumento);
- }
- else
- {
- }
- }
- }
- }
-
- public bool CompararValores()
- {
- if (this.SelectedDocumento.get_Id() == 0 || this.SelectedDocumento.HasChange("PremioLiquido") || this.SelectedDocumento.HasChange("PremioAdicional") || this.SelectedDocumento.HasChange("Comissao") || this.SelectedDocumento.HasChange("Iof"))
- {
- return true;
- }
- return this.SelectedDocumento.HasChange("AdicionalComiss");
- }
-
- private void CriarParcelas(bool insert)
- {
- if (this.Repasses == null)
- {
- this.Repasses = new List<VendedorParcela>();
- }
- var list = this.Repasses.Where<VendedorParcela>((VendedorParcela x) => {
- if (insert)
- {
- return true;
- }
- return x.get_Parcela().get_SubTipo() == 1;
- }).GroupBy((VendedorParcela x) => new { Repasse = x.get_Repasse(), TipoVendedor = x.get_TipoVendedor() }).Distinct().ToList();
- List<VendedorParcela> vendedorParcelas = new List<VendedorParcela>();
- list.ForEach((x) => {
- decimal num;
- if (x.Key.Repasse == null)
- {
- return;
- }
- VendedorParcela vendedorParcela = this.CalculaRepasse(x.Key.Repasse, x.Key.TipoVendedor);
- if (vendedorParcela.get_Repasse().get_Forma().GetValueOrDefault() == 3)
- {
- VendedorParcela vendedorParcela1 = vendedorParcela;
- decimal? valorRepasse = vendedorParcela1.get_ValorRepasse();
- num = (this.SelectedDocumento.get_NumeroParcelas() > decimal.Zero ? this.SelectedDocumento.get_NumeroParcelas() : decimal.One);
- vendedorParcela1.set_ValorRepasse((valorRepasse.HasValue ? new decimal?(valorRepasse.GetValueOrDefault() / num) : null));
- }
- vendedorParcelas.Add(vendedorParcela);
- });
- if (vendedorParcelas.All<VendedorParcela>((VendedorParcela x) => x.get_TipoVendedor().get_Id() != (long)1))
- {
- vendedorParcelas.Add(this.PropriaCorretora());
- }
- this.Parcelas = new ObservableCollection<Parcela>(this.CriarParcelas(vendedorParcelas));
- }
-
- private List<Parcela> CriarParcelas(List<VendedorParcela> vendedores)
- {
- TipoPagamento tipoPagamento;
- List<Parcela> parcelas = new List<Parcela>();
- if (this.SelectedDocumento.get_NumeroParcelas() == decimal.Zero)
- {
- return parcelas;
- }
- decimal premioTotal = this.SelectedDocumento.get_PremioTotal() / this.SelectedDocumento.get_NumeroParcelas();
- FormaPagamento? formaPagamento = this.SelectedDocumento.get_FormaPagamento();
- if (!formaPagamento.HasValue)
- {
- this.SelectedDocumento.set_FormaPagamento(new FormaPagamento?(0));
- }
- for (int i = 1; i <= this.SelectedDocumento.get_NumeroParcelas(); i++)
- {
- Parcela parcela = new Parcela();
- parcela.set_IdEmpresa(this.SelectedDocumento.get_Controle().get_IdEmpresa());
- parcela.set_NumeroParcela(i);
- parcela.set_Valor(premioTotal);
- parcela.set_Comissao(this.SelectedDocumento.get_Comissao());
- DateTime vigencia1 = this.SelectedDocumento.get_Vigencia1();
- parcela.set_Vencimento(vigencia1.AddMonths(i - 1));
- parcela.set_SubTipo(1);
- parcela.set_Vendedores(new ObservableCollection<VendedorParcela>((i == 1 ? vendedores : vendedores.Where<VendedorParcela>((VendedorParcela x) => {
- Gestor.Model.Domain.Seguros.Repasse repasse = x.get_Repasse();
- if (repasse == null)
- {
- return false;
- }
- return repasse.get_Forma().GetValueOrDefault() == 3;
- }).ToList<VendedorParcela>())));
- formaPagamento = this.SelectedDocumento.get_FormaPagamento();
- if (formaPagamento.GetValueOrDefault() == 0 & formaPagamento.HasValue)
- {
- tipoPagamento = 7;
- }
- else
- {
- formaPagamento = this.SelectedDocumento.get_FormaPagamento();
- if (formaPagamento.GetValueOrDefault() == 1)
- {
- tipoPagamento = 3;
- }
- else
- {
- formaPagamento = this.SelectedDocumento.get_FormaPagamento();
- if (formaPagamento.GetValueOrDefault() == 2)
- {
- tipoPagamento = 15;
- }
- else
- {
- formaPagamento = this.SelectedDocumento.get_FormaPagamento();
- tipoPagamento = (formaPagamento.GetValueOrDefault() != 3 || i != 1 ? 7 : 15);
- }
- }
- }
- parcela.set_TipoPagamento(tipoPagamento);
- parcela.set_DataCriacao(new DateTime?(Funcoes.GetNetworkTime()));
- parcela.set_UsuarioCriacao(Recursos.Usuario.get_Id());
- parcelas.Add(parcela);
- }
- return parcelas;
- }
-
- private List<VendedorParcela> CriarRepasses(VendedorParcela repasse)
- {
- decimal? nullable;
- if (this.Parcelas == null || this.Parcelas.Count == 0 || this.SelectedDocumento == null)
- {
- return null;
- }
- List<VendedorParcela> vendedorParcelas = new List<VendedorParcela>();
- VendedorParcela vendedorParcela1 = repasse;
- if (repasse.get_Repasse().get_Forma().GetValueOrDefault() == 3)
- {
- decimal? valorRepasse = repasse.get_ValorRepasse();
- decimal numeroParcelas = this.SelectedDocumento.get_NumeroParcelas();
- if (valorRepasse.HasValue)
- {
- nullable = new decimal?(valorRepasse.GetValueOrDefault() / numeroParcelas);
- }
- else
- {
- nullable = null;
- }
- }
- else
- {
- nullable = repasse.get_ValorRepasse();
- }
- vendedorParcela1.set_ValorRepasse(nullable);
- this.Parcelas.ToList<Parcela>().ForEach((Parcela x) => {
- if (repasse.get_Repasse().get_Forma().GetValueOrDefault() != 3 && x.get_NumeroParcela() > 1)
- {
- return;
- }
- VendedorParcela vendedorParcela = (VendedorParcela)repasse.Clone();
- if (repasse.get_Repasse().get_Forma().GetValueOrDefault() == 3)
- {
- vendedorParcela.set_DataPrePagamento(new DateTime?(x.get_Vencimento()));
- }
- vendedorParcela.set_Parcela(x);
- vendedorParcelas.Add(vendedorParcela);
- });
- return vendedorParcelas;
- }
-
- private async Task DesfazerAlteracoes()
- {
- IEnumerable<!0> list;
- ItemServico itemServico = new ItemServico();
- IList<Documento> documentos = this.SelectedDocumento.get_Controle().get_Documentos();
- ObservableCollection<Item> observableCollection = await itemServico.BuscarItems(documentos.FirstOrDefault<Documento>((Documento x) => {
- if (x.get_Excluido() || x.get_Situacao() == 7)
- {
- return false;
- }
- return x.get_Ordem() == 0;
- }).get_Id(), 2, false);
- ObservableCollection<Item> observableCollection1 = await (new ItemServico()).BuscarItems(this.SelectedDocumento.get_Id(), 2, false);
- ObservableCollection<Item> observableCollection2 = observableCollection1;
- List<Item> items = observableCollection.Where<Item>((Item x) => {
- long? idDocumentoCancelado = x.get_IdDocumentoCancelado();
- long id = this.SelectedDocumento.get_Id();
- return idDocumentoCancelado.GetValueOrDefault() == id & idDocumentoCancelado.HasValue;
- }).ToList<Item>();
- List<Item> items1 = items;
- IEnumerable<Item> items2 = observableCollection.Where<Item>((Item x) => {
- long? nullable;
- long? nullable1 = x.get_Substituido();
- if (!nullable1.HasValue)
- {
- return false;
- }
- nullable1 = x.get_Substituido();
- Item item = observableCollection2.FirstOrDefault<Item>((Item d) => {
- long id = d.get_Id();
- long? substituido = x.get_Substituido();
- return id == substituido.GetValueOrDefault() & substituido.HasValue;
- });
- if (item != null)
- {
- nullable = new long?(item.get_Id());
- }
- else
- {
- nullable = null;
- }
- long? nullable2 = nullable;
- return nullable1.GetValueOrDefault() == nullable2.GetValueOrDefault() & nullable1.HasValue == nullable2.HasValue;
- });
- if (items2 != null)
- {
- list = items2.ToList<Item>();
- }
- else
- {
- list = null;
- }
- items1.AddRange(list);
- if (items.Count == 0)
- {
- items = observableCollection.Where<Item>((Item x) => {
- if (x.get_Status() == null || Gestor.Common.Validation.ValidationHelper.IsNullOrEmpty(x.get_Status()) || !x.get_Status().Contains("ORDEM"))
- {
- return false;
- }
- return x.get_Status().Replace("ORDEM", "-").Split(new char[] { '-' })[1].Trim().Equals(string.Format("{0}", this.SelectedDocumento.get_Ordem()));
- }).ToList<Item>();
- }
- foreach (Item item1 in items)
- {
- await (new ItemServico()).Reativar(item1, "");
- }
- observableCollection = null;
- }
-
- public void EditarParcelaEspecial()
- {
- this.AllowEditVendedor = true;
- }
-
- public async Task EditarParcelas()
- {
- if (this.DocumentoSelecionado == null)
- {
- this.DocumentoSelecionado = this.SelectedDocumento;
- }
- await base.ShowEditarParcelasDialog(this.DocumentoSelecionado);
- await this.CarregarParcelas(this.DocumentoSelecionado);
- }
-
- public async Task ExcluirApolice()
- {
- string str;
- int ordem;
- string str1;
- string str2;
- TipoSeguro value;
- int? nullable;
- Documento selectedDocumento;
- string str3;
- string str4;
- if (this.SelectedDocumento != null)
- {
- if (this.AllowEditApolice)
- {
- ObservableCollection<Parcela> parcelas = this.Parcelas;
- if (!parcelas.Any<Parcela>((Parcela x) => x.get_DataRecebimento().HasValue))
- {
- List<VendedorParcela> repasses = this.Repasses;
- if (!repasses.Any<VendedorParcela>((VendedorParcela x) => x.get_DataPagamento().HasValue))
- {
- if (this.SelectedDocumento.get_Tipo() <= 0 || !this.SelectedDocumento.get_Sinistro())
- {
- selectedDocumento = this.SelectedDocumento;
- if (selectedDocumento.get_Tipo() != 0 || !string.IsNullOrEmpty(selectedDocumento.get_Apolice()))
- {
- str = (selectedDocumento.get_Tipo() != 0 || string.IsNullOrEmpty(selectedDocumento.get_Apolice()) ? "O ENDOSSO SELECIONADO" : "A APÓLICE SELECIONADA");
- }
- else
- {
- str = "A PROPOSTA SELECIONADA";
- }
- str3 = str;
- int num = this.SelectedDocumento.get_Ordem();
- IList<Documento> documentos = this.SelectedDocumento.get_Controle().get_Documentos();
- Documento documento = (
- from x in documentos
- orderby x.get_Ordem() descending
- select x).FirstOrDefault<Documento>((Documento x) => {
- if (!x.get_Excluido() && x.get_Situacao() != 7)
- {
- return true;
- }
- return x.get_Id() == this.SelectedDocumento.get_Id();
- });
- if (documento != null)
- {
- ordem = documento.get_Ordem();
- }
- else
- {
- ordem = this.SelectedDocumento.get_Ordem();
- }
- if (num == ordem)
- {
- string[] newLine = new string[] { "DESEJA REALMENTE EXCLUIR ", str3, "?", Environment.NewLine, "ESSE PROCEDIMENTO É IRREVERSÍVEL." };
- if (await base.ShowMessage(string.Concat(newLine), "SIM", "NÃO", false))
- {
- bool hasValue = selectedDocumento.get_TipoEndosso().HasValue;
- if (hasValue)
- {
- hasValue = await base.ShowMessage("DESEJA DESFAZER AS ALTERAÇOES NOS ITENS VINCULADOS A ESSE ENDOSSO ?", "SIM", "NÃO", false);
- }
- if (hasValue)
- {
- IList<Documento> documentos1 = this.SelectedDocumento.get_Controle().get_Documentos();
- Documento documento1 = (
- from x in documentos1
- orderby x.get_Ordem() descending
- select x).FirstOrDefault<Documento>((Documento x) => {
- if (x.get_Excluido() || x.get_Situacao() == 7)
- {
- return false;
- }
- return x.get_Ordem() > this.SelectedDocumento.get_Ordem();
- });
- if (documento1 != null)
- {
- nullable = new int?(documento1.get_Ordem());
- }
- else
- {
- nullable = null;
- }
- int? nullable1 = nullable;
- int ordem1 = this.SelectedDocumento.get_Ordem();
- if (!(nullable1.GetValueOrDefault() > ordem1 & nullable1.HasValue))
- {
- await this.DesfazerAlteracoes();
- }
- else
- {
- await base.ShowMessage(string.Concat("NÃO É POSSIVEL DESFAZER AS ALTERAÇÕES, POIS ", str3, " POSSUE ENDOSSOS ATIVOS ACIMA."), "OK", "", false);
- selectedDocumento = null;
- str3 = null;
- str4 = null;
- return;
- }
- }
- if (selectedDocumento.get_Tipo() == 0 && string.IsNullOrEmpty(selectedDocumento.get_Apolice()))
- {
- str1 = string.Concat("EXCLUIU PROPOSTA ", selectedDocumento.get_Proposta());
- }
- else if (selectedDocumento.get_Tipo() != 0 || string.IsNullOrEmpty(selectedDocumento.get_Apolice()))
- {
- str1 = (string.IsNullOrEmpty(selectedDocumento.get_Endosso()) ? string.Concat("EXCLUIU PROPOSTA DE ENDOSSO ", selectedDocumento.get_PropostaEndosso()) : string.Concat("EXCLUIU ENDOSSO ", selectedDocumento.get_Endosso()));
- }
- else
- {
- str1 = string.Concat("EXCLUIU APÓLICE ", selectedDocumento.get_Apolice());
- }
- string str5 = str1;
- base.RegistrarAcao(str5, this.SelectedDocumento.get_Id(), new TipoTela?(2), this.GerarObs(selectedDocumento));
- base.Loading(true);
- if (selectedDocumento.get_Tipo() != 0 || !string.IsNullOrEmpty(selectedDocumento.get_Apolice()))
- {
- str2 = (selectedDocumento.get_Tipo() != 0 || string.IsNullOrEmpty(selectedDocumento.get_Apolice()) ? "ENDOSSO EXCLUÍDO" : "APÓLICE EXCLUÍDA");
- }
- else
- {
- str2 = "PROPOSTA EXCLUÍDA";
- }
- str4 = str2;
- selectedDocumento.set_Excluido(true);
- this.Servico.Sucesso = true;
- await this.Servico.ExcluirCritica(selectedDocumento.get_Id());
- if (this.Servico.Sucesso)
- {
- Gestor.Application.Servicos.TarefaServico tarefaServico = this.TarefaServico;
- hasValue = await this.TarefaServico.ExcluirTarefasDocumento(selectedDocumento.get_Id());
- tarefaServico.Sucesso = hasValue;
- tarefaServico = null;
- if (this.TarefaServico.Sucesso)
- {
- this.Servico.Sucesso = true;
- if (selectedDocumento.get_TipoEndosso().HasValue && selectedDocumento.get_TipoEndosso().GetValueOrDefault() == 2)
- {
- IList<Documento> documentos2 = this.CancelDocumento.get_Controle().get_Documentos();
- Documento documento2 = documentos2.FirstOrDefault<Documento>((Documento x) => {
- if (x.get_Tipo() != 0)
- {
- return false;
- }
- return !x.get_Excluido();
- });
- IList<Documento> documentos3 = this.CancelDocumento.get_Controle().get_Documentos();
- List<Documento> list = documentos3.Where<Documento>((Documento x) => {
- if (x.get_Tipo() != 1)
- {
- return false;
- }
- return !x.get_Excluido();
- }).ToList<Documento>();
- if (documento2 != null)
- {
- Documento documento3 = documento2;
- if (!documento2.get_SituacaoAnterior().HasValue || documento2.get_SituacaoAnterior().GetValueOrDefault() == 3)
- {
- value = (documento2.get_NegocioCorretora().GetValueOrDefault() == 1 ? 2 : 1);
- }
- else
- {
- value = documento2.get_SituacaoAnterior().Value;
- }
- documento3.set_Situacao(value);
- await this.Servico.Save(documento2, false, false);
- foreach (Documento documento4 in list)
- {
- documento4.set_Situacao(documento2.get_Situacao());
- await this.Servico.Save(documento4, false, false);
- }
- }
- documento2 = null;
- list = null;
- }
- await this.Servico.Excluir(selectedDocumento);
- if (this.Servico.Sucesso)
- {
- if (selectedDocumento.get_Tipo() > 0)
- {
- await Funcoes.OrganizarDocumentos(selectedDocumento.get_Controle().get_Id());
- await Funcoes.InativarItens(selectedDocumento.get_Id(), selectedDocumento.get_Controle().get_Ramo().get_Id(), true);
- }
- if (this.Invoke)
- {
- ConsultaViewModel.DocumentoSelecionado = null;
- Action<Documento> recarregarDocumentos = Gestor.Application.Actions.Actions.RecarregarDocumentos;
- if (recarregarDocumentos != null)
- {
- recarregarDocumentos(null);
- }
- else
- {
- }
- }
- base.Loading(false);
- base.ToggleSnackBar(string.Concat(str4, " COM SUCESSO"), true);
- if (this.Invoke)
- {
- Action<TipoTela, string> acessaTela = Gestor.Application.Actions.Actions.AcessaTela;
- if (acessaTela != null)
- {
- acessaTela(21, "");
- }
- else
- {
- }
- }
- selectedDocumento = null;
- str3 = null;
- str4 = null;
- return;
- }
- else
- {
- base.Loading(false);
- selectedDocumento = null;
- str3 = null;
- str4 = null;
- return;
- }
- }
- else
- {
- base.Loading(false);
- selectedDocumento = null;
- str3 = null;
- str4 = null;
- return;
- }
- }
- else
- {
- base.Loading(false);
- selectedDocumento = null;
- str3 = null;
- str4 = null;
- return;
- }
- }
- else
- {
- selectedDocumento = null;
- str3 = null;
- str4 = null;
- return;
- }
- }
- else
- {
- await base.ShowMessage(string.Concat(str3, " NÃO PODE SER EXCLUÍDO(A) POIS POSSUEM DOCUMENTOS ATIVOS ACIMA."), "OK", "", false);
- selectedDocumento = null;
- str3 = null;
- str4 = null;
- return;
- }
- }
- else
- {
- await base.ShowMessage("DOCUMENTO NÃO PODE SER EXCLUÍDO POIS POSSUI SINISTROS PARA UM OU MAIS DE SEUS ITENS.", "OK", "", false);
- selectedDocumento = null;
- str3 = null;
- str4 = null;
- return;
- }
- }
- }
- }
- await base.ShowMessage("DOCUMENTO NÃO PODE SER EXCLUÍDO POIS POSSUI BAIXAS DE COMISSÃO OU PAGAMENTO DE VENDEDORES.", "OK", "", false);
- }
- selectedDocumento = null;
- str3 = null;
- str4 = null;
- }
-
- internal async Task ExcluirBaixa()
- {
- string str;
- string str1;
- bool flag;
- if (this.SelectedParcela != null)
- {
- if (await base.ShowMessage(string.Concat("DESEJA REALMENTE EXCLUIR A BAIXA DA PARCELA SELECIONADA?", Environment.NewLine, "ESSE PROCEDIMENTO É IRREVERSÍVEL."), "SIM", "NÃO", false))
- {
- base.Loading(true);
- this.SelectedParcela.set_Documento(this.SelectedDocumento);
- this.SelectedParcela = await Funcoes.ExcluirBaixa(this.SelectedParcela, this.Repasses, this.Parcelas.ToList<Parcela>());
- if (this.SelectedDocumento.get_Tipo() == 0 && string.IsNullOrEmpty(this.SelectedDocumento.get_Apolice()))
- {
- str = string.Concat("PROPOSTA ", this.SelectedDocumento.get_Proposta());
- }
- else if (this.SelectedDocumento.get_Tipo() != 0 || string.IsNullOrEmpty(this.SelectedDocumento.get_Apolice()))
- {
- str = (string.IsNullOrEmpty(this.SelectedDocumento.get_Endosso()) ? string.Concat("PROPOSTA DE ENDOSSO ", this.SelectedDocumento.get_PropostaEndosso()) : string.Concat("ENDOSSO ", this.SelectedDocumento.get_Endosso()));
- }
- else
- {
- str = string.Concat("APÓLICE ", this.SelectedDocumento.get_Apolice());
- }
- string str2 = str;
- str1 = (this.SelectedDocumento.get_TipoRecebimento().GetValueOrDefault() == 1 ? string.Format("BAIXA DA PARCELA {0} EXCLUÍDA, {1}", this.SelectedParcela.get_NumeroParcela(), str2) : string.Concat("BAIXA DA FATURA ", this.SelectedParcela.get_Fatura(), " EXCLUÍDA, ", str2));
- string str3 = str1;
- base.RegistrarAcao(str3, this.SelectedParcela.get_Id(), new TipoTela?(5), this.GerarObs(this.SelectedDocumento));
- await this.CarregarParcelas(this.SelectedDocumento);
- await this.CarregaRepasse(this.SelectedDocumento.get_Id());
- this.CalculaComissao(this.SelectedDocumento, this.Parcelas);
- BaseApoliceViewModel baseApoliceViewModel = this;
- Parcela selectedParcela = this.SelectedParcela;
- if (selectedParcela == null)
- {
- selectedParcela = this.Parcelas.FirstOrDefault<Parcela>();
- }
- await baseApoliceViewModel.SelecionaParcela(selectedParcela);
- this.BaixarParcelas = false;
- BaseApoliceViewModel baseApoliceViewModel1 = this;
- ObservableCollection<Parcela> parcelas = this.Parcelas;
- IEnumerable<Parcela> subTipo =
- from x in parcelas
- where x.get_SubTipo() == 1
- select x;
- if (!subTipo.All<Parcela>((Parcela x) => !x.get_DataRecebimento().HasValue))
- {
- flag = false;
- }
- else
- {
- List<VendedorParcela> repasses = this.Repasses;
- IEnumerable<VendedorParcela> vendedorParcelas =
- from x in repasses
- where x.get_Parcela().get_SubTipo() == 1
- select x;
- flag = vendedorParcelas.All<VendedorParcela>((VendedorParcela x) => !x.get_DataPagamento().HasValue);
- }
- baseApoliceViewModel1.AllowEditApolice = flag;
- base.Loading(false);
- base.ToggleSnackBar("BAIXA EXCLUÍDA COM SUCESSO", true);
- }
- }
- }
-
- public async Task ExcluirPagamento(VendedorParcela pagamento)
- {
- bool flag;
- string str;
- base.Loading(true);
- if (await Funcoes.ExcluirPagamento(pagamento))
- {
- base.ToggleSnackBar("PAGAMENTO EXCLUÍDO COM SUCESSO", true);
- if (this.SelectedDocumento.get_Tipo() == 0 && string.IsNullOrEmpty(this.SelectedDocumento.get_Apolice()))
- {
- str = string.Concat("NA PROPOSTA \"", this.SelectedDocumento.get_Proposta(), "\"");
- }
- else if (this.SelectedDocumento.get_Tipo() != 0 || string.IsNullOrEmpty(this.SelectedDocumento.get_Apolice()))
- {
- str = (string.IsNullOrEmpty(this.SelectedDocumento.get_Endosso()) ? string.Concat("NA PROPOSTA DE ENDOSSO \"", this.SelectedDocumento.get_PropostaEndosso(), "\"") : string.Concat("NO ENDOSSO \"", this.SelectedDocumento.get_Endosso(), "\""));
- }
- else
- {
- str = string.Concat("NA APÓLICE \"", this.SelectedDocumento.get_Apolice(), "\"");
- }
- string str1 = str;
- string str2 = string.Concat("PAGAMENTO DO VENDEDOR ", pagamento.get_Vendedor().get_Nome(), " EXCLUÍDO, ", str1);
- long id = pagamento.get_Id();
- TipoTela? nullable = new TipoTela?(37);
- object[] objArray = new object[] { this.GerarObs(this.SelectedDocumento), Environment.NewLine, pagamento.get_Vendedor().get_Nome(), Environment.NewLine, pagamento.get_ValorTotal() };
- base.RegistrarAcao(str2, id, nullable, string.Format("{0}{1}VENDEDOR: {2}{3}COMISSÃO TOTAL: {4:C2}", objArray));
- }
- await this.CarregarParcelas(this.SelectedDocumento);
- await this.CarregaRepasse(this.SelectedDocumento.get_Id());
- await this.SelecionaParcela(this.Parcelas.FirstOrDefault<Parcela>());
- BaseApoliceViewModel baseApoliceViewModel = this;
- ObservableCollection<Parcela> parcelas = this.Parcelas;
- IEnumerable<Parcela> subTipo =
- from x in parcelas
- where x.get_SubTipo() == 1
- select x;
- if (!subTipo.All<Parcela>((Parcela x) => !x.get_DataRecebimento().HasValue))
- {
- flag = false;
- }
- else
- {
- List<VendedorParcela> repasses = this.Repasses;
- IEnumerable<VendedorParcela> vendedorParcelas =
- from x in repasses
- where x.get_Parcela().get_SubTipo() == 1
- select x;
- flag = vendedorParcelas.All<VendedorParcela>((VendedorParcela x) => !x.get_DataPagamento().HasValue);
- }
- baseApoliceViewModel.AllowEditApolice = flag;
- this.BaixarParcelas = false;
- base.Loading(false);
- }
-
- public async Task ExcluirParcela()
- {
- string str;
- string str1;
- string str2;
- if (this.SelectedParcela != null)
- {
- if (this.SelectedParcela.get_SubTipo() != 1 || this.SelectedDocumento.get_TipoRecebimento().GetValueOrDefault() != 1)
- {
- if (this.SelectedParcela.get_SubTipo() == 1)
- {
- ObservableCollection<Parcela> parcelas = this.Parcelas;
- IOrderedEnumerable<Parcela> numeroParcela =
- from x in parcelas
- orderby x.get_NumeroParcela()
- select x;
- Parcela parcela = numeroParcela.Last<Parcela>((Parcela x) => x.get_SubTipo() == 1);
- if (this.SelectedParcela.get_Id() != parcela.get_Id())
- {
- await base.ShowMessage("A FATURA NÃO PODE SER EXCLUÍDA POIS HÁ FATURAS CADASTRADAS ACIMA DA SELECIONADA.", "OK", "", false);
- return;
- }
- }
- if (await base.ShowMessage(string.Concat("DESEJA REALMENTE EXCLUIR A PARCELA SELECIONADA?", Environment.NewLine, "ESSE PROCEDIMENTO É IRREVERSÍVEL."), "SIM", "NÃO", false))
- {
- base.Loading(true);
- if (await this.ParcelaServico.Delete(this.SelectedParcela, this.Parcelas.ToList<Parcela>()))
- {
- BaseApoliceViewModel baseApoliceViewModel = this;
- str = (this.SelectedDocumento.get_TipoRecebimento().GetValueOrDefault() == 1 ? "PARCELA EXCLUÍDA COM SUCESSO" : "FATURA EXCLUÍDA COM SUCESSO");
- baseApoliceViewModel.ToggleSnackBar(str, true);
- if (this.SelectedDocumento.get_Tipo() == 0 && string.IsNullOrEmpty(this.SelectedDocumento.get_Apolice()))
- {
- str1 = string.Concat("PROPOSTA ", this.SelectedDocumento.get_Proposta());
- }
- else if (this.SelectedDocumento.get_Tipo() != 0 || string.IsNullOrEmpty(this.SelectedDocumento.get_Apolice()))
- {
- str1 = (string.IsNullOrEmpty(this.SelectedDocumento.get_Endosso()) ? string.Concat("PROPOSTA DE ENDOSSO ", this.SelectedDocumento.get_PropostaEndosso()) : string.Concat("ENDOSSO ", this.SelectedDocumento.get_Endosso()));
- }
- else
- {
- str1 = string.Concat("APÓLICE ", this.SelectedDocumento.get_Apolice());
- }
- string str3 = str1;
- str2 = (this.SelectedDocumento.get_TipoRecebimento().GetValueOrDefault() == 1 ? string.Format("PARCELA {0} EXCLUÍDA, {1}", this.SelectedParcela.get_NumeroParcela(), str3) : string.Concat("FATURA ", this.SelectedParcela.get_Fatura(), " EXCLUÍDA, ", str3));
- string str4 = str2;
- base.RegistrarAcao(str4, this.SelectedParcela.get_Id(), new TipoTela?(5), this.GerarObs(this.SelectedDocumento));
- }
- await this.CarregarParcelas(this.SelectedDocumento);
- await this.CarregaRepasse(this.SelectedDocumento.get_Id());
- await this.SelecionaParcela(this.Parcelas.FirstOrDefault<Parcela>());
- this.BaixarParcelas = false;
- if (this.Parcelas == null || this.Parcelas.Count == 0)
- {
- this.VisibilityExcluirParcela = Visibility.Collapsed;
- this.VisibilityReplicarFatura = Visibility.Collapsed;
- this.BaixarParcelaVisibility = Visibility.Collapsed;
- }
- base.Loading(false);
- this.AllowEditVendedor = this.Parcelas.Any<Parcela>();
- }
- }
- }
- }
-
- public async Task ExcluirVendedor(VendedorParcela pagamento, bool incluirCorretora = true)
- {
- List<VendedorParcela> vendedorParcelas;
- bool flag;
- Vendedor vendedor;
- string str1;
- List<VendedorParcela> list;
- if (this.IsEndosso && this.SelectedDocumento.get_Id() == 0)
- {
- this.RemoverVendedor(pagamento.get_Vendedor().get_Id());
- base.ToggleSnackBar("VENDEDOR EXCLUÍDO COM SUCESSO", true);
- }
- else if (!this.AllowEditApolice && !this.IsFatura && this.SelectedParcela.get_SubTipo() == 1)
- {
- string[] upper = new string[] { "O VENDEDOR ", pagamento.get_Vendedor().get_Nome().ToUpper(), " NÃO PODE SER EXCLUÍDO.", Environment.NewLine, "JÁ EXISTEM RECEBIMENTOS OU PAGAMENTOS DE COMISSÃO PARA ESSE DOCUMENTO." };
- await base.ShowMessage(string.Concat(upper), "OK", "", false);
- }
- else if (this.SelectedDocumento.get_Id() > (long)0 && (this.IsFatura || this.SelectedParcela.get_SubTipo() != 1) && (this.SelectedParcela.get_Id() > (long)0 && this.SelectedParcela.get_DataRecebimento().HasValue || this.Repasses.Any<VendedorParcela>((VendedorParcela x) => {
- if (x.get_Parcela().get_Id() != this.SelectedParcela.get_Id())
- {
- return false;
- }
- return x.get_DataPagamento().HasValue;
- })))
- {
- string[] strArrays = new string[] { "O VENDEDOR ", pagamento.get_Vendedor().get_Nome().ToUpper(), " NÃO PODE SER EXCLUÍDO.", Environment.NewLine, "JÁ EXISTEM RECEBIMENTOS OU PAGAMENTOS DE COMISSÃO PARA ESSA FATURA." };
- await base.ShowMessage(string.Concat(strArrays), "OK", "", false);
- }
- else if (this.SelectedDocumento.get_Id() != 0)
- {
- vendedorParcelas = (this.SelectedParcela.get_SubTipo() != 1 || this.IsFatura ? this.Repasses.Where<VendedorParcela>((VendedorParcela x) => {
- if (x.get_Vendedor().get_Id() != pagamento.get_Vendedor().get_Id())
- {
- return false;
- }
- return x.get_Parcela().get_Id() == this.SelectedParcela.get_Id();
- }).ToList<VendedorParcela>() : this.Repasses.Where<VendedorParcela>((VendedorParcela x) => {
- if (x.get_Vendedor().get_Id() != pagamento.get_Vendedor().get_Id())
- {
- return false;
- }
- return x.get_Parcela().get_NumeroParcela() != 999;
- }).ToList<VendedorParcela>());
- list = vendedorParcelas.Distinct<VendedorParcela>().ToList<VendedorParcela>();
- if (await this.Servico.ExcluirPagamento(list))
- {
- if (this.SelectedParcela.get_Id() > (long)0)
- {
- if (this.SelectedDocumento.get_Tipo() == 0 && string.IsNullOrEmpty(this.SelectedDocumento.get_Apolice()))
- {
- str1 = string.Concat("NA PROPOSTA \"", this.SelectedDocumento.get_Proposta(), "\"");
- }
- else if (this.SelectedDocumento.get_Tipo() != 0 || string.IsNullOrEmpty(this.SelectedDocumento.get_Apolice()))
- {
- str1 = (string.IsNullOrEmpty(this.SelectedDocumento.get_Endosso()) ? string.Concat("NA PROPOSTA DE ENDOSSO \"", this.SelectedDocumento.get_PropostaEndosso(), "\"") : string.Concat("NO ENDOSSO \"", this.SelectedDocumento.get_Endosso(), "\""));
- }
- else
- {
- str1 = string.Concat("NA APÓLICE \"", this.SelectedDocumento.get_Apolice(), "\"");
- }
- string str2 = str1;
- list.ForEach((VendedorParcela x) => {
- string str = string.Concat("VENDEDOR ", x.get_Vendedor().get_Nome(), " EXCLUÍDO, ", str2);
- base.RegistrarAcao(str, x.get_Id(), new TipoTela?(37), string.Format("{0}{1}VENDEDOR: {2}{3}COMISSÃO TOTAL: {4:C2}", new object[] { this.GerarObs(this.SelectedDocumento), Environment.NewLine, x.get_Vendedor().get_Nome(), Environment.NewLine, x.get_ValorTotal() }));
- });
- }
- this.RemoverVendedor(pagamento.get_Vendedor().get_Id());
- if (this.IsFatura || this.SelectedParcela.get_SubTipo() != 1)
- {
- flag = this.Repasses.Any<VendedorParcela>((VendedorParcela x) => {
- if (x.get_Parcela().get_Id() != this.SelectedParcela.get_Id())
- {
- return false;
- }
- return x.get_TipoVendedor().get_Id() == (long)1;
- });
- }
- else
- {
- List<VendedorParcela> repasses = this.Repasses;
- flag = repasses.Any<VendedorParcela>((VendedorParcela x) => {
- if (x.get_Parcela().get_SubTipo() != 1 || x.get_TipoVendedor().get_Id() != (long)1)
- {
- return false;
- }
- return !x.get_CoCorretagem();
- });
- }
- bool flag1 = flag;
- if (pagamento.get_TipoVendedor().get_Id() == (long)1 & incluirCorretora && !flag1)
- {
- VendedorParcela vendedorParcela = await this.IncluirPropriaCorretora();
- if (vendedorParcela != null)
- {
- this.Repasses.Add(vendedorParcela);
- Documento selectedDocumento = this.SelectedDocumento;
- List<VendedorParcela> repasses1 = this.Repasses;
- VendedorParcela vendedorParcela1 = repasses1.FirstOrDefault<VendedorParcela>((VendedorParcela x) => x.get_TipoVendedor().get_Id() == (long)1);
- if (vendedorParcela1 != null)
- {
- vendedor = vendedorParcela1.get_Vendedor();
- }
- else
- {
- vendedor = null;
- }
- selectedDocumento.set_VendedorPrincipal(vendedor);
- }
- }
- if (this.Repasses != null)
- {
- this.Pagamentos = new ObservableCollection<VendedorParcela>((
- from x in this.Repasses
- where x.get_Parcela().get_Id() == this.SelectedParcela.get_Id()
- select x).ToList<VendedorParcela>());
- }
- base.ToggleSnackBar("VENDEDOR EXCLUÍDO COM SUCESSO", true);
- this.CalculaComissao(this.SelectedDocumento, this.Parcelas);
- }
- else
- {
- BaseApoliceViewModel baseApoliceViewModel = this;
- Parcela selectedParcela = this.SelectedParcela;
- if (selectedParcela == null)
- {
- selectedParcela = this.Parcelas.FirstOrDefault<Parcela>();
- }
- await baseApoliceViewModel.SelecionaParcela(selectedParcela);
- }
- }
- else
- {
- this.RemoverVendedor(pagamento.get_Vendedor().get_Id());
- base.ToggleSnackBar("VENDEDOR EXCLUÍDO COM SUCESSO", true);
- }
- list = null;
- }
-
- public void FiltrarRepasse(Vendedor vendedor)
- {
- if (this.SelectedPagamento == null)
- {
- this.SelectedPagamento = new VendedorParcela();
- }
- this.SelectedPagamento.set_Vendedor(vendedor);
- this.RepassesVendedor = this.GetRepasses(vendedor);
- }
-
- public string GerarObs(Documento doc)
- {
- if (doc.get_Tipo() == 0)
- {
- return string.Format("CLIENTE: {0}{1}CÓDIGO: {2}{3}PROPOSTA: {4}{5}APÓLICE: {6}", new object[] { doc.get_Controle().get_Cliente().get_Nome(), Environment.NewLine, doc.get_Id(), Environment.NewLine, doc.get_Proposta(), Environment.NewLine, doc.get_Apolice() });
- }
- return string.Format("CLIENTE: {0}{1}CÓDIGO: {2}{3}PROPOSTA: {4}{5}APÓLICE: {6}{7}PROPOSTA DE ENDOSSO: {8}{9}ENDOSSO: {10}", new object[] { doc.get_Controle().get_Cliente().get_Nome(), Environment.NewLine, doc.get_Id(), Environment.NewLine, doc.get_Proposta(), Environment.NewLine, doc.get_Apolice(), Environment.NewLine, doc.get_PropostaEndosso(), Environment.NewLine, doc.get_Endosso() });
- }
-
- public List<Gestor.Model.Domain.Seguros.Repasse> GetRepasses(Vendedor vendedor)
- {
- List<Gestor.Model.Domain.Seguros.Repasse> repasses;
- if (this.CoCorretagem)
- {
- IEnumerable<Gestor.Model.Domain.Seguros.Repasse> repassesVendedores =
- from x in this.RepassesVendedores
- where x.get_Vendedor().get_Id() == vendedor.get_Id()
- select x;
- if (repassesVendedores == null)
- {
- return null;
- }
- IEnumerable<Gestor.Model.Domain.Seguros.Repasse> valueOrDefault =
- from x in repassesVendedores
- where x.get_Tipo().GetValueOrDefault() == 3
- select x;
- if (valueOrDefault == null)
- {
- return null;
- }
- return (
- from x in valueOrDefault
- orderby x.get_ValorNovo()
- select x).ToList<Gestor.Model.Domain.Seguros.Repasse>();
- }
- if (Recursos.Configuracoes.All<ConfiguracaoSistema>((ConfiguracaoSistema x) => x.get_Configuracao() != 20))
- {
- IEnumerable<Gestor.Model.Domain.Seguros.Repasse> repassesVendedores1 =
- from x in this.RepassesVendedores
- where x.get_Vendedor().get_Id() == vendedor.get_Id()
- select x;
- if (repassesVendedores1 == null)
- {
- return null;
- }
- return (
- from x in repassesVendedores1
- where x.get_Tipo().GetValueOrDefault() != 3
- orderby x.get_ValorNovo()
- select x).ToList<Gestor.Model.Domain.Seguros.Repasse>();
- }
- repasses = (!this.RepassesVendedores.Any<Gestor.Model.Domain.Seguros.Repasse>((Gestor.Model.Domain.Seguros.Repasse x) => {
- if (x.get_Vendedor().get_Id() != vendedor.get_Id() || x.get_Ramo() == null)
- {
- return false;
- }
- return x.get_Ramo().get_Id() == this.SelectedDocumento.get_Controle().get_Ramo().get_Id();
- }) ? this.RepassesVendedores.Where<Gestor.Model.Domain.Seguros.Repasse>((Gestor.Model.Domain.Seguros.Repasse x) => {
- if (x.get_Vendedor().get_Id() != vendedor.get_Id())
- {
- return false;
- }
- return x.get_Ramo() == null;
- }).OrderBy<Gestor.Model.Domain.Seguros.Repasse, decimal>((Gestor.Model.Domain.Seguros.Repasse x) => x.get_ValorNovo()).ToList<Gestor.Model.Domain.Seguros.Repasse>() : this.RepassesVendedores.Where<Gestor.Model.Domain.Seguros.Repasse>((Gestor.Model.Domain.Seguros.Repasse x) => {
- if (x.get_Vendedor().get_Id() != vendedor.get_Id() || x.get_Ramo() == null)
- {
- return false;
- }
- return x.get_Ramo().get_Id() == this.SelectedDocumento.get_Controle().get_Ramo().get_Id();
- }).OrderBy<Gestor.Model.Domain.Seguros.Repasse, decimal>((Gestor.Model.Domain.Seguros.Repasse x) => x.get_ValorNovo()).ToList<Gestor.Model.Domain.Seguros.Repasse>());
- return repasses;
- }
-
- public List<KeyValuePair<string, string>> HabilitarVendedor(int editarParcelaTipo = 0)
- {
- IEnumerable<!0> u00210s;
- List<KeyValuePair<string, string>> keyValuePairs = new List<KeyValuePair<string, string>>();
- if (editarParcelaTipo != 4)
- {
- keyValuePairs.AddRange(this.SelectedDocumento.Validate(this.IsEndosso, Recursos.Configuracoes.Any<ConfiguracaoSistema>((ConfiguracaoSistema c) => c.get_Configuracao() == 11)));
- }
- else if (this.SelectedParcela != null)
- {
- List<KeyValuePair<string, string>> keyValuePairs1 = keyValuePairs;
- Parcela selectedParcela = this.SelectedParcela;
- if (selectedParcela != null)
- {
- u00210s = selectedParcela.Validate(Recursos.Configuracoes.Any<ConfiguracaoSistema>((ConfiguracaoSistema x) => x.get_Configuracao() == 9), Recursos.Configuracoes.Any<ConfiguracaoSistema>((ConfiguracaoSistema y) => y.get_Configuracao() == 11), this.EditandoParcela, Recursos.Configuracoes.Any<ConfiguracaoSistema>((ConfiguracaoSistema x) => x.get_Configuracao() == 16));
- }
- else
- {
- u00210s = null;
- }
- keyValuePairs1.AddRange(u00210s);
- }
- return keyValuePairs;
- }
-
- public async Task Importacao()
- {
- DateTime? dataCriacao;
- DateTime? dataImportacao;
- RegistroLog registroLog;
- DateTime? nullable;
- object nome;
- string str;
- object obj;
- string str1;
- bool flag;
- string str2;
- DateTime? nullable1;
- object nome1;
- bool flag1;
- string str3;
- DateTime? nullable2;
- object obj1;
- string str4;
- string str5;
- List<CriticaApolice> criticaApolices = await (new CriticaApoliceServico()).BuscarImportacao(this.SelectedDocumento.get_Id());
- List<RegistroLog> list = await (new LogServico()).FindByEntityId(2, this.SelectedDocumento.get_Id()).ToList<RegistroLog>();
- if (list.Count > 0)
- {
- registroLog = list.Last<RegistroLog>();
- }
- else
- {
- registroLog = null;
- }
- RegistroLog registroLog1 = registroLog;
- switch (criticaApolices.Count)
- {
- case 0:
- {
- BaseApoliceViewModel baseApoliceViewModel = this;
- dataCriacao = this.SelectedDocumento.get_DataCriacao();
- if (!dataCriacao.HasValue)
- {
- if (registroLog1 != null)
- {
- nome = registroLog1.get_Usuario().get_Nome();
- }
- else
- {
- nome = null;
- }
- if (registroLog1 != null)
- {
- nullable = new DateTime?(registroLog1.get_DataHora());
- }
- else
- {
- dataCriacao = null;
- nullable = dataCriacao;
- }
- str = string.Format("CADASTRO MANUAL: {0} - {1:dd/MM/yyyy 'ÀS' HH:mm:ss}", nome, nullable);
- }
- else
- {
- Usuario usuarioCriacao = this.SelectedDocumento.get_UsuarioCriacao();
- if (usuarioCriacao != null)
- {
- obj = usuarioCriacao.get_Nome();
- }
- else
- {
- obj = null;
- }
- str = string.Format("CADASTRO MANUAL: {0} - {1:dd/MM/yyyy 'ÀS' HH:mm:ss}", obj, this.SelectedDocumento.get_DataCriacao());
- }
- baseApoliceViewModel.Importado = str;
- break;
- }
- case 1:
- {
- if (string.IsNullOrWhiteSpace(criticaApolices[0].get_Tipo()) || criticaApolices[0].get_Tipo() == "0")
- {
- BaseApoliceViewModel baseApoliceViewModel1 = this;
- str1 = (!criticaApolices[0].get_Aggilizador().HasValue || !criticaApolices[0].get_Aggilizador().Value ? string.Format("IMPORTAÇÃO DA PROPOSTA: {0} - {1:dd/MM/yyyy 'ÀS' HH:mm:ss}", criticaApolices[0].get_UsuarioImportacao().get_Nome(), criticaApolices[0].get_DataImportacao()) : string.Format("IMPORTAÇÃO DA PROPOSTA VIA AGGILIZADOR: {0} - {1:dd/MM/yyyy 'ÀS' HH:mm:ss}", criticaApolices[0].get_UsuarioImportacao().get_Nome(), criticaApolices[0].get_DataImportacao()));
- baseApoliceViewModel1.Importado = str1;
- }
- if (criticaApolices[0].get_Tipo() == "1")
- {
- dataCriacao = this.SelectedDocumento.get_DataCriacao();
- if (dataCriacao.HasValue)
- {
- dataCriacao = criticaApolices[0].get_DataImportacao();
- if (dataCriacao.HasValue)
- {
- dataCriacao = this.SelectedDocumento.get_DataCriacao();
- DateTime value = dataCriacao.Value;
- dataCriacao = criticaApolices[0].get_DataImportacao();
- if (DateTime.Compare(value, dataCriacao.Value) < 0)
- {
- this.Importado = string.Format("CADASTRO MANUAL DA PROPOSTA: {0} - {1:dd/MM/yyyy 'ÀS' HH:mm:ss}\n", this.SelectedDocumento.get_UsuarioCriacao(), this.SelectedDocumento.get_DataCriacao());
- }
- }
- }
- else
- {
- BaseApoliceViewModel baseApoliceViewModel2 = this;
- if (registroLog1 != null)
- {
- obj1 = registroLog1.get_Usuario().get_Nome();
- }
- else
- {
- obj1 = null;
- }
- if (registroLog1 != null)
- {
- nullable2 = new DateTime?(registroLog1.get_DataHora());
- }
- else
- {
- dataCriacao = null;
- nullable2 = dataCriacao;
- }
- baseApoliceViewModel2.Importado = string.Format("CADASTRO MANUAL DA PROPOSTA: {0} - {1:dd/MM/yyyy 'ÀS' HH:mm:ss}\n", obj1, nullable2);
- }
- dataCriacao = this.SelectedDocumento.get_DataCriacao();
- dataImportacao = criticaApolices[0].get_DataImportacao();
- flag1 = (dataCriacao.HasValue & dataImportacao.HasValue ? dataCriacao.GetValueOrDefault() <= dataImportacao.GetValueOrDefault() : false);
- if (flag1)
- {
- BaseApoliceViewModel baseApoliceViewModel3 = this;
- str3 = (!criticaApolices[0].get_Aggilizador().HasValue || !criticaApolices[0].get_Aggilizador().Value ? string.Format("IMPORTAÇÃO DA APÓLICE: {0} - {1:dd/MM/yyyy 'ÀS' HH:mm:ss}", criticaApolices[0].get_UsuarioImportacao().get_Nome(), criticaApolices[0].get_DataImportacao()) : string.Format("IMPORTAÇÃO DA APÓLICE VIA AGGILIZADOR: {0} - {1:dd/MM/yyyy 'ÀS' HH:mm:ss}", criticaApolices[0].get_UsuarioImportacao().get_Nome(), criticaApolices[0].get_DataImportacao()));
- baseApoliceViewModel3.Importado = str3;
- }
- }
- if (criticaApolices[0].get_Tipo() != "2")
- {
- break;
- }
- dataImportacao = this.SelectedDocumento.get_DataCriacao();
- if (dataImportacao.HasValue)
- {
- dataImportacao = criticaApolices[0].get_DataImportacao();
- if (dataImportacao.HasValue)
- {
- dataImportacao = this.SelectedDocumento.get_DataCriacao();
- DateTime dateTime = dataImportacao.Value;
- dataImportacao = criticaApolices[0].get_DataImportacao();
- if (DateTime.Compare(dateTime, dataImportacao.Value) < 0)
- {
- this.Importado = string.Format("CADASTRO MANUAL DA PROPOSTA: {0} - {1:dd/MM/yyyy 'ÀS' HH:mm:ss}\n", this.SelectedDocumento.get_UsuarioCriacao(), this.SelectedDocumento.get_DataCriacao());
- }
- }
- }
- else
- {
- BaseApoliceViewModel baseApoliceViewModel4 = this;
- if (registroLog1 != null)
- {
- nome1 = registroLog1.get_Usuario().get_Nome();
- }
- else
- {
- nome1 = null;
- }
- if (registroLog1 != null)
- {
- nullable1 = new DateTime?(registroLog1.get_DataHora());
- }
- else
- {
- dataImportacao = null;
- nullable1 = dataImportacao;
- }
- baseApoliceViewModel4.Importado = string.Format("CADASTRO MANUAL DA PROPOSTA: {0} - {1:dd/MM/yyyy 'ÀS' HH:mm:ss}\n", nome1, nullable1);
- }
- dataImportacao = this.SelectedDocumento.get_DataCriacao();
- dataCriacao = criticaApolices[0].get_DataImportacao();
- flag = (dataImportacao.HasValue & dataCriacao.HasValue ? dataImportacao.GetValueOrDefault() <= dataCriacao.GetValueOrDefault() : false);
- if (!flag)
- {
- break;
- }
- BaseApoliceViewModel baseApoliceViewModel5 = this;
- str2 = (!criticaApolices[0].get_Aggilizador().HasValue || !criticaApolices[0].get_Aggilizador().Value ? string.Format("IMPORTAÇÃO DO ENDOSSO: {0} - {1:dd/MM/yyyy 'ÀS' HH:mm:ss}", criticaApolices[0].get_UsuarioImportacao().get_Nome(), criticaApolices[0].get_DataImportacao()) : string.Format("IMPORTAÇÃO DO ENDOSSO VIA AGGILIZADOR: {0} - {1:dd/MM/yyyy 'ÀS' HH:mm:ss}", criticaApolices[0].get_UsuarioImportacao().get_Nome(), criticaApolices[0].get_DataImportacao()));
- baseApoliceViewModel5.Importado = str2;
- break;
- }
- case 2:
- case 3:
- {
- List<CriticaApolice> criticaApolices1 = criticaApolices;
- CriticaApolice criticaApolouse = criticaApolices1.Find((CriticaApolice x) => {
- if (string.IsNullOrWhiteSpace(x.get_Tipo()))
- {
- return true;
- }
- return x.get_Tipo() == "0";
- });
- List<CriticaApolice> criticaApolices2 = criticaApolices;
- CriticaApolice criticaApolouse1 = criticaApolices2.Find((CriticaApolice x) => x.get_Tipo() == "1");
- BaseApoliceViewModel baseApoliceViewModel6 = this;
- str4 = (!criticaApolouse.get_Aggilizador().HasValue || !criticaApolouse.get_Aggilizador().Value ? string.Format("IMPORTAÇÃO DA PROPOSTA: {0} - {1:dd/MM/yyyy 'ÀS' HH:mm:ss}\n", criticaApolouse.get_UsuarioImportacao().get_Nome(), criticaApolouse.get_DataImportacao()) : string.Format("IMPORTAÇÃO DA PROPOSTA VIA AGGILIZADOR: {0} - {1:dd/MM/yyyy 'ÀS' HH:mm:ss}\n", criticaApolouse.get_UsuarioImportacao().get_Nome(), criticaApolouse.get_DataImportacao()));
- baseApoliceViewModel6.Importado = str4;
- if (criticaApolouse1 == null)
- {
- break;
- }
- BaseApoliceViewModel baseApoliceViewModel7 = this;
- string importado = this.Importado;
- str5 = (!criticaApolouse1.get_Aggilizador().HasValue || !criticaApolouse1.get_Aggilizador().Value ? string.Format("IMPORTAÇÃO DA APÓLICE: {0} - {1:dd/MM/yyyy 'ÀS' HH:mm:ss}", criticaApolouse1.get_UsuarioImportacao().get_Nome(), criticaApolouse1.get_DataImportacao()) : string.Format("IMPORTAÇÃO DA APÓLICE VIA AGGILIZADOR: {0} - {1:dd/MM/yyyy 'ÀS' HH:mm:ss}", criticaApolouse1.get_UsuarioImportacao().get_Nome(), criticaApolouse1.get_DataImportacao()));
- baseApoliceViewModel7.Importado = string.Concat(importado, str5);
- break;
- }
- }
- criticaApolices = null;
- }
-
- public async Task<bool> IncluirApolice(bool renovar = false)
- {
- bool flag;
- DateTime? emissao;
- FormaPagamento? nullable1;
- List<Vendedor> list;
- List<Vendedor> vendedors;
- DateTime dateTime;
- ObservableCollection<VendedorParcela> observableCollection;
- Documento documento;
- if (renovar)
- {
- if (!string.IsNullOrWhiteSpace(this.SelectedDocumento.get_Apolice()))
- {
- emissao = this.SelectedDocumento.get_Emissao();
- if (emissao.HasValue)
- {
- goto Label1;
- }
- }
- await base.ShowMessage("PROPOSTA NÃO PODE SER RENOVADA. NECESSÁRIO PREENCHER O NÚMERO DA APÓLICE E DATA DE EMISSÃO ANTES DE PROSSEGUIR.", "OK", "", false);
- flag = false;
- documento = null;
- return flag;
- }
- Label1:
- List<Seguradora> seguradoras = Recursos.Seguradoras;
- IEnumerable<Seguradora> ativo =
- from x in seguradoras
- where x.get_Ativo()
- select x;
- List<Seguradora> list1 = (
- from x in ativo
- orderby x.get_Nome()
- select x).ToList<Seguradora>();
- this.Seguradoras = list1;
- this.SeguradorasAnteriores = Recursos.Seguradoras;
- List<Ramo> ramos = Recursos.Ramos;
- IEnumerable<Ramo> ativo1 =
- from x in ramos
- where x.get_Ativo()
- select x;
- List<Ramo> ramos1 = (
- from x in ativo1
- orderby x.get_Nome()
- select x).ToList<Ramo>();
- this.Ramos = ramos1;
- List<Produto> produtos = Recursos.Produtos;
- List<Produto> produtos1 = (
- from x in produtos
- where x.get_Ativo()
- select x).ToList<Produto>();
- this.Produtos = produtos1;
- List<Gestor.Model.Domain.Seguros.Status> status = Recursos.Status;
- List<Gestor.Model.Domain.Seguros.Status> statuses = (
- from x in status
- where x.get_Ativo()
- select x).ToList<Gestor.Model.Domain.Seguros.Status>();
- this.Status = statuses;
- DateTime date = Funcoes.GetNetworkTime().Date;
- if (!renovar)
- {
- this.Inclusao = true;
- BaseApoliceViewModel baseApoliceViewModel = this;
- List<ConfiguracaoSistema> configuracoes = Recursos.Configuracoes;
- if (configuracoes.All<ConfiguracaoSistema>((ConfiguracaoSistema x) => x.get_Configuracao() != 20))
- {
- List<Vendedor> todosVendedores = this.TodosVendedores;
- list = todosVendedores.Where<Vendedor>((Vendedor x) => {
- if (x.get_IdEmpresa() != MainViewModel.ClienteSelecionado.get_IdEmpresa() || !x.get_Ativo())
- {
- return false;
- }
- return !x.get_Corretora();
- }).ToList<Vendedor>();
- }
- else
- {
- list = new List<Vendedor>();
- }
- baseApoliceViewModel.Vendedores = list;
- BaseApoliceViewModel baseApoliceViewModel1 = this;
- List<Estipulante> estipulantes = Recursos.Estipulantes;
- baseApoliceViewModel1.Estipulantes = estipulantes.Where<Estipulante>((Estipulante x) => {
- if (x.get_IdEmpresa() != MainViewModel.ClienteSelecionado.get_IdEmpresa())
- {
- return false;
- }
- return x.get_Ativo();
- }).ToList<Estipulante>();
- Documento documento1 = new Documento();
- Controle controle = new Controle();
- controle.set_Cliente(MainViewModel.ClienteSelecionado);
- controle.set_IdEmpresa(MainViewModel.ClienteSelecionado.get_IdEmpresa());
- documento1.set_Controle(controle);
- documento1.set_Ordem(0);
- documento1.set_Tipo(0);
- documento1.set_NegocioCorretora(new NegocioCorretora?(0));
- documento1.set_Situacao(1);
- documento1.set_TipoRecebimento(new TipoRecebimento?(1));
- documento1.set_Vigencia1(date);
- documento1.set_Vigencia2(new DateTime?(date.AddYears(1)));
- documento1.set_ApoliceConferida(false);
- documento1.set_PropostaAssinada(false);
- documento1.set_AdicionalComiss(false);
- documento1.set_Excluido(false);
- nullable1 = null;
- documento1.set_FormaPagamento(nullable1);
- documento = documento1;
- this.Pagamentos = null;
- this.Repasses = null;
- }
- else
- {
- this.SelectedDocumento = await this.Servico.BuscarApoliceAsync(this.SelectedDocumento.get_Id(), false, false);
- this.DocumentoRenovado = this.SelectedDocumento;
- if (this.Seguradoras.All<Seguradora>((Seguradora x) => x.get_Id() != this.SelectedDocumento.get_Controle().get_Seguradora().get_Id()))
- {
- this.Seguradoras.Add(this.SelectedDocumento.get_Controle().get_Seguradora());
- }
- if (this.SelectedDocumento.get_Controle().get_Produto() != null && this.Produtos.All<Produto>((Produto x) => x.get_Id() != this.SelectedDocumento.get_Controle().get_Produto().get_Id()))
- {
- this.Seguradoras.Add(this.SelectedDocumento.get_Controle().get_Seguradora());
- }
- if (this.SelectedDocumento.get_Controle().get_Ramo() != null && this.Ramos.All<Ramo>((Ramo x) => x.get_Id() != this.SelectedDocumento.get_Controle().get_Ramo().get_Id()))
- {
- this.Seguradoras.Add(this.SelectedDocumento.get_Controle().get_Seguradora());
- }
- BaseApoliceViewModel baseApoliceViewModel2 = this;
- List<ConfiguracaoSistema> configuracaoSistemas = Recursos.Configuracoes;
- vendedors = (configuracaoSistemas.All<ConfiguracaoSistema>((ConfiguracaoSistema x) => x.get_Configuracao() != 20) ? this.TodosVendedores.Where<Vendedor>((Vendedor x) => {
- if (x.get_IdEmpresa() != this.SelectedDocumento.get_Controle().get_IdEmpresa() || !x.get_Ativo())
- {
- return false;
- }
- return !x.get_Corretora();
- }).ToList<Vendedor>() : new List<Vendedor>());
- baseApoliceViewModel2.Vendedores = vendedors;
- this.Estipulantes = Recursos.Estipulantes.Where<Estipulante>((Estipulante x) => {
- if (x.get_IdEmpresa() != this.SelectedDocumento.get_Controle().get_IdEmpresa())
- {
- return false;
- }
- return x.get_Ativo();
- }).ToList<Estipulante>();
- Documento documento2 = new Documento();
- Controle controle1 = new Controle();
- controle1.set_Cliente(MainViewModel.ClienteSelecionado);
- controle1.set_IdEmpresa(this.SelectedDocumento.get_Controle().get_IdEmpresa());
- controle1.set_Ramo(this.SelectedDocumento.get_Controle().get_Ramo());
- controle1.set_Seguradora(this.SelectedDocumento.get_Controle().get_Seguradora());
- controle1.set_SeguradoraAnterior(this.SelectedDocumento.get_Controle().get_Seguradora());
- documento2.set_Controle(controle1);
- documento2.set_Ordem(0);
- documento2.set_Tipo(0);
- documento2.set_NegocioCorretora(new NegocioCorretora?(1));
- documento2.set_Situacao(2);
- documento2.set_Negocio(new Negocio?(1));
- documento2.set_TipoRecebimento(new TipoRecebimento?(1));
- emissao = this.SelectedDocumento.get_Vigencia2();
- documento2.set_Vigencia1(emissao.GetValueOrDefault(date));
- emissao = this.SelectedDocumento.get_Vigencia2();
- dateTime = (emissao.HasValue ? emissao.GetValueOrDefault().AddYears(1) : date.AddYears(1));
- documento2.set_Vigencia2(new DateTime?(dateTime));
- documento2.set_ApoliceConferida(false);
- documento2.set_PropostaAssinada(false);
- documento2.set_AdicionalComiss(false);
- documento2.set_Excluido(false);
- documento2.set_ApoliceAnterior(this.SelectedDocumento.get_Apolice());
- nullable1 = null;
- documento2.set_FormaPagamento(nullable1);
- documento = documento2;
- this.EmissaoDocumento = new DateTime?(date);
- this.TransmissaoDocumento = new DateTime?(date);
- if (!await base.ShowMessage("DESEJA MANTER OS VENDEDORES DA APÓLICE ANTERIOR?", "SIM", "NÃO", false))
- {
- this.Pagamentos = new ObservableCollection<VendedorParcela>()
- {
- this.PropriaCorretora()
- };
- this.Repasses = null;
- }
- else
- {
- ObservableCollection<VendedorParcela> pagamentos = this.Pagamentos;
- if (pagamentos != null)
- {
- List<VendedorParcela> vendedorParcelas = pagamentos.ToList<VendedorParcela>();
- vendedorParcelas.ForEach((VendedorParcela x) => {
- x.set_Documento(null);
- x.set_ValorRepasse(new decimal?(new decimal()));
- x.set_ValorTotal(null);
- DateTime? nullable = null;
- x.set_DataPagamento(nullable);
- nullable = null;
- x.set_DataPagamento(nullable);
- });
- }
- else
- {
- }
- }
- BaseApoliceViewModel baseApoliceViewModel3 = this;
- observableCollection = (this.Pagamentos != null ? new ObservableCollection<VendedorParcela>(this.Pagamentos) : new ObservableCollection<VendedorParcela>());
- baseApoliceViewModel3.Pagamentos = observableCollection;
- }
- this.IsFatura = false;
- this.SelectedParcela = null;
- this.SelectedDocumento = null;
- this.SelectedPagamento = null;
- this.Parcelas = null;
- this.SelectedDocumento = documento;
- this.IsEndosso = false;
- this.NovaApolice = true;
- this.Renovar = renovar;
- this.EnableAlterarSituacao = true;
- this.AllowEditVendedor = !renovar;
- this.AllowEditApolice = true;
- base.IsEnabledEdit = true;
- base.IsEnabledEditEndosso = true;
- base.AllowEditParcela = false;
- base.EnableFields = true;
- base.EnableIncluir = false;
- Action<bool> enableMainMenu = Gestor.Application.Actions.Actions.EnableMainMenu;
- if (enableMainMenu != null)
- {
- enableMainMenu(false);
- }
- else
- {
- }
- flag = true;
- documento = null;
- return flag;
- }
-
- public async Task<bool> IncluirEndosso()
- {
- bool flag;
- ObservableCollection<TipoEndosso> observableCollection;
- NegocioCorretora valueOrDefault;
- TipoEndosso tipoEndosso;
- List<ConfiguracaoSistema> configuracoes = Recursos.Configuracoes;
- if (configuracoes.Any<ConfiguracaoSistema>((ConfiguracaoSistema x) => x.get_Configuracao() == 13) || !string.IsNullOrWhiteSpace(this.SelectedDocumento.get_Apolice()))
- {
- if (this.SelectedDocumento.get_TipoRecebimento().GetValueOrDefault() == 2)
- {
- observableCollection = new ObservableCollection<TipoEndosso>(new List<TipoEndosso>()
- {
- 2,
- 1,
- 4
- });
- }
- else
- {
- List<TipoEndosso> tipoEndossos = new List<TipoEndosso>()
- {
- 0,
- 1,
- 2,
- 4
- };
- observableCollection = new ObservableCollection<TipoEndosso>(tipoEndossos);
- }
- ObservableCollection<TipoEndosso> observableCollection1 = observableCollection;
- if (this.SelectedDocumento.get_Situacao() == 3)
- {
- observableCollection1 = new ObservableCollection<TipoEndosso>(new List<TipoEndosso>()
- {
- 3
- });
- }
- this.TipoEndossoList = observableCollection1;
- Documento documento = new Documento();
- documento.set_Controle(this.SelectedDocumento.get_Controle());
- documento.set_Tipo(1);
- IList<Documento> documentos = this.SelectedDocumento.get_Controle().get_Documentos();
- IEnumerable<Documento> excluido =
- from x in documentos
- where !x.get_Excluido()
- select x;
- documento.set_Ordem(excluido.Max<Documento>((Documento x) => x.get_Ordem()) + 1);
- NegocioCorretora? negocioCorretora = this.SelectedDocumento.get_NegocioCorretora();
- if (negocioCorretora.HasValue)
- {
- valueOrDefault = negocioCorretora.GetValueOrDefault();
- }
- else
- {
- valueOrDefault = (this.SelectedDocumento.get_Situacao() != 2 || !this.SelectedDocumento.get_Negocio().HasValue || this.SelectedDocumento.get_Negocio().GetValueOrDefault() != 1 ? 0 : 1);
- }
- documento.set_NegocioCorretora(new NegocioCorretora?(valueOrDefault));
- documento.set_Situacao(this.SelectedDocumento.get_Situacao());
- documento.set_Negocio(this.SelectedDocumento.get_Negocio());
- documento.set_TipoRecebimento(this.SelectedDocumento.get_TipoRecebimento());
- documento.set_Vigencia1(Funcoes.GetNetworkTime().Date);
- documento.set_Vigencia2(this.SelectedDocumento.get_Vigencia2());
- documento.set_ApoliceConferida(false);
- documento.set_PropostaAssinada(false);
- documento.set_AdicionalComiss(false);
- documento.set_Excluido(false);
- documento.set_Apolice(this.SelectedDocumento.get_Apolice());
- documento.set_Proposta(this.SelectedDocumento.get_Proposta());
- tipoEndosso = (this.SelectedDocumento.get_TipoRecebimento().GetValueOrDefault() == 2 ? 2 : 0);
- documento.set_TipoEndosso(new TipoEndosso?(tipoEndosso));
- documento.set_Comissao(this.SelectedDocumento.get_Comissao());
- documento.set_Estipulante1(this.SelectedDocumento.get_Estipulante1());
- documento.set_Estipulante2(this.SelectedDocumento.get_Estipulante2());
- documento.set_Estipulante3(this.SelectedDocumento.get_Estipulante3());
- documento.set_Estipulante4(this.SelectedDocumento.get_Estipulante4());
- documento.set_Estipulante5(this.SelectedDocumento.get_Estipulante5());
- Documento documento1 = documento;
- this.SelectedParcela = null;
- this.SelectedDocumento = null;
- this.SelectedPagamento = null;
- if (documento1.get_TipoRecebimento().GetValueOrDefault() != 1)
- {
- this.Pagamentos = null;
- this.Repasses = null;
- }
- else
- {
- List<VendedorParcela> repasses = this.Repasses;
- List<VendedorParcela> list = (
- from x in repasses
- where x.get_Parcela().get_SubTipo() == 1
- select x).ToList<VendedorParcela>();
- List<VendedorParcela> vendedorParcelas = (
- from x in list
- group x by x.get_Vendedor().get_Id()).Select<IGrouping<long, VendedorParcela>, VendedorParcela>((IGrouping<long, VendedorParcela> x) => {
- VendedorParcela vendedorParcela = new VendedorParcela();
- vendedorParcela.set_Repasse(x.First<VendedorParcela>().get_Repasse());
- vendedorParcela.set_Parcela(this.SelectedParcela);
- vendedorParcela.set_Documento(this.SelectedDocumento);
- vendedorParcela.set_ValorRepasse(new decimal?(new decimal()));
- vendedorParcela.set_Vendedor(x.First<VendedorParcela>().get_Vendedor());
- vendedorParcela.set_PorcentagemRepasse(x.First<VendedorParcela>().get_PorcentagemRepasse());
- vendedorParcela.set_TipoVendedor(x.First<VendedorParcela>().get_TipoVendedor());
- return vendedorParcela;
- }).ToList<VendedorParcela>();
- this.Pagamentos = new ObservableCollection<VendedorParcela>(vendedorParcelas);
- this.Repasses = vendedorParcelas;
- }
- this.Parcelas = null;
- this.SelectedDocumento = documento1;
- this.NovaApolice = true;
- this.AllowEditVendedor = false;
- this.AllowEditApolice = true;
- this.IsEndosso = true;
- base.IsEnabledEditEndosso = true;
- base.EnableFields = true;
- base.EnableIncluir = false;
- this.AllowEditEmissao = true;
- Action<bool> enableMainMenu = Gestor.Application.Actions.Actions.EnableMainMenu;
- if (enableMainMenu != null)
- {
- enableMainMenu(false);
- }
- else
- {
- }
- flag = true;
- }
- else
- {
- await base.ShowMessage("PROPOSTA NÃO PODE SER ENDOSSADA. NECESSÁRIO PREENCHER O NÚMERO DA APÓLICE E DATA DE EMISSÃO ANTES DE PROSSEGUIR.", "OK", "", false);
- flag = false;
- }
- return flag;
- }
-
- public void IncluirFatura()
- {
- long? nullable1;
- int numeroParcela;
- decimal comissao;
- long id;
- long? nullable2;
- Parcela parcela = (
- from x in this.Parcelas
- orderby x.get_NumeroParcela()
- select x).LastOrDefault<Parcela>((Parcela x) => x.get_SubTipo() == 1);
- if (parcela != null)
- {
- numeroParcela = parcela.get_NumeroParcela();
- }
- else
- {
- numeroParcela = 0;
- }
- int num = numeroParcela + 1;
- if (parcela != null)
- {
- comissao = parcela.get_Comissao();
- }
- else
- {
- comissao = decimal.Zero;
- }
- decimal num1 = comissao;
- Parcela selectedParcela = this.SelectedParcela;
- if (selectedParcela != null)
- {
- id = selectedParcela.get_Id();
- }
- else
- {
- ObservableCollection<Parcela> parcelas = this.Parcelas;
- if (parcelas != null)
- {
- Parcela parcela1 = (
- from x in parcelas
- orderby x.get_NumeroParcela()
- select x).LastOrDefault<Parcela>((Parcela x) => x.get_SubTipo() == 1);
- if (parcela1 != null)
- {
- nullable2 = new long?(parcela1.get_Id());
- }
- else
- {
- nullable1 = null;
- nullable2 = nullable1;
- }
- }
- else
- {
- nullable1 = null;
- nullable2 = nullable1;
- }
- nullable1 = nullable2;
- id = nullable1.GetValueOrDefault();
- }
- long num2 = id;
- DateTime networkTime = Funcoes.GetNetworkTime();
- Parcela parcela2 = new Parcela();
- parcela2.set_IdEmpresa(this.SelectedDocumento.get_Controle().get_IdEmpresa());
- parcela2.set_Documento(this.SelectedDocumento);
- parcela2.set_Vencimento(Funcoes.GetNetworkTime().Date);
- parcela2.set_Comissao(num1);
- parcela2.set_SubTipo(1);
- parcela2.set_NumeroParcela(num);
- parcela2.set_DataCriacao(new DateTime?(networkTime));
- parcela2.set_UsuarioCriacao(Recursos.Usuario.get_Id());
- this.SelectedParcela = parcela2;
- if (num2 == 0)
- {
- return;
- }
- List<VendedorParcela> list = (
- from x in this.Repasses
- where x.get_Parcela().get_Id() == num2
- select x).ToList<VendedorParcela>();
- list.ForEach((VendedorParcela x) => {
- decimal zero;
- x.set_Id((long)0);
- x.set_Parcela(this.SelectedParcela);
- DateTime? nullable = null;
- x.set_DataPrePagamento(nullable);
- nullable = null;
- x.set_DataPagamento(nullable);
- VendedorParcela vendedorParcela = x;
- if (x.get_Repasse() != null)
- {
- NegocioCorretora? negocioCorretora = this.SelectedDocumento.get_NegocioCorretora();
- zero = (negocioCorretora.GetValueOrDefault() == 0 & negocioCorretora.HasValue ? x.get_Repasse().get_ValorNovo() : x.get_Repasse().get_ValorRenovacao());
- }
- else
- {
- zero = decimal.Zero;
- }
- vendedorParcela.set_PorcentagemRepasse(new decimal?(zero));
- });
- this.Repasses = list;
- this.RecalculaRepasse();
- }
-
- public void IncluirParcelaEspecial()
- {
- Parcela parcela;
- Parcela parcela1 = new Parcela();
- parcela1.set_IdEmpresa(this.SelectedDocumento.get_Controle().get_IdEmpresa());
- parcela1.set_Documento(this.SelectedDocumento);
- parcela1.set_Vencimento(Funcoes.GetNetworkTime().Date);
- parcela1.set_Comissao(new decimal(100));
- parcela1.set_SubTipo(3);
- parcela1.set_NumeroParcela(999);
- parcela1.set_DataCriacao(new DateTime?(Funcoes.GetNetworkTime()));
- parcela1.set_UsuarioCriacao(Recursos.Usuario.get_Id());
- this.SelectedParcela = parcela1;
- ObservableCollection<Parcela> parcelas = this.Parcelas;
- if (parcelas != null)
- {
- parcela = parcelas.FirstOrDefault<Parcela>((Parcela x) => x.get_SubTipo() == 1);
- }
- else
- {
- parcela = null;
- }
- Parcela parcela2 = parcela;
- if (parcela2 == null)
- {
- this.Repasses = new List<VendedorParcela>();
- return;
- }
- List<VendedorParcela> list = (
- from x in this.Repasses
- where x.get_Parcela().get_Id() == parcela2.get_Id()
- select x).ToList<VendedorParcela>();
- list.ForEach((VendedorParcela x) => {
- x.set_Id((long)0);
- x.set_Parcela(this.SelectedParcela);
- DateTime? nullable = null;
- x.set_DataPrePagamento(nullable);
- nullable = null;
- x.set_DataPagamento(nullable);
- x.set_ValorRepasse(new decimal?(new decimal()));
- nullable = null;
- x.set_DataPagamento(nullable);
- });
- this.Repasses = list;
- this.RecalculaRepasse();
- }
-
- private async Task<VendedorParcela> IncluirPropriaCorretora()
- {
- VendedorParcela vendedorParcela;
- Parcela selectedParcela;
- if (this.Parcelas.Count != 0)
- {
- VendedorParcela vendedorParcela1 = this.PropriaCorretora();
- if (this.SelectedParcela.get_SubTipo() != 1 || this.IsFatura)
- {
- selectedParcela = this.SelectedParcela;
- }
- else
- {
- ObservableCollection<Parcela> parcelas = this.Parcelas;
- selectedParcela = parcelas.FirstOrDefault<Parcela>((Parcela x) => x.get_NumeroParcela() == 1);
- }
- Parcela parcela = selectedParcela;
- vendedorParcela1.set_Parcela(parcela);
- vendedorParcela1.set_Documento(this.SelectedDocumento);
- if (parcela == null || parcela.get_Id() != 0)
- {
- vendedorParcela = await this.Servico.IncluirVendedor(vendedorParcela1);
- }
- else
- {
- vendedorParcela = vendedorParcela1;
- }
- }
- else
- {
- vendedorParcela = null;
- }
- return vendedorParcela;
- }
-
- public void IncluirVendedor()
- {
- VendedorParcela vendedorParcela = new VendedorParcela();
- vendedorParcela.set_Documento(this.SelectedDocumento);
- this.SelectedPagamento = vendedorParcela;
- }
-
- public async Task LimparRepasses()
- {
- bool count;
- bool flag;
- if (this.Pagamentos != null)
- {
- ObservableCollection<VendedorParcela> pagamentos = this.Pagamentos;
- if (pagamentos != null)
- {
- count = pagamentos.Count == 0;
- }
- else
- {
- count = false;
- }
- if (!count && this.Repasses != null)
- {
- List<VendedorParcela> repasses = this.Repasses;
- if (repasses != null)
- {
- flag = repasses.Count == 0;
- }
- else
- {
- flag = false;
- }
- if (!flag && this.SelectedDocumento.get_Id() == 0)
- {
- if (!base.EnableFields || !this.AllowEditApolice || !this.AlteracaoEnabled)
- {
- return;
- }
- else
- {
- await base.ShowMessage("REPASSES ADICIONADOS NÃO PERTENCEM AO RAMO SELECIONADO E SERÃO EXCLUÍDOS.", "OK", "", false);
- this.Pagamentos.Clear();
- this.Repasses.Clear();
- return;
- }
- }
- }
- }
- }
-
- public void ManutecaoItens()
- {
- if (!this.Invoke)
- {
- return;
- }
- Action<TipoTela, string> acessaTela = Gestor.Application.Actions.Actions.AcessaTela;
- if (acessaTela == null)
- {
- return;
- }
- acessaTela(3, "Manutencao");
- }
-
- public async Task<bool> PagamentoVendedor(Parcela parcela)
- {
- return await this.ParcelaServico.TemPagamento(parcela.get_Id());
- }
-
- private void PreLoad()
- {
- this.Ramos = Recursos.Ramos;
- this.Seguradoras = Recursos.Seguradoras;
- this.Produtos = Recursos.Produtos;
- this.Status = Recursos.Status;
- this.SeguradorasAnteriores = Recursos.Seguradoras;
- this.TipoEndossoList = new ObservableCollection<TipoEndosso>(new List<TipoEndosso>()
- {
- 0,
- 1,
- 2,
- 4,
- 3
- });
- }
-
- private VendedorParcela PropriaCorretora()
- {
- VendedorParcela vendedorParcela = new VendedorParcela();
- vendedorParcela.set_Repasse(null);
- decimal num = new decimal();
- vendedorParcela.set_ValorRepasse(new decimal?(num));
- vendedorParcela.set_Documento(this.SelectedDocumento);
- vendedorParcela.set_Vendedor(Recursos.Vendedores.FirstOrDefault<Vendedor>((Vendedor x) => {
- long? nullable;
- long? nullable1;
- long idEmpresa = x.get_IdEmpresa();
- Documento selectedDocumento = this.SelectedDocumento;
- if (selectedDocumento != null)
- {
- Controle controle = selectedDocumento.get_Controle();
- if (controle != null)
- {
- nullable1 = new long?(controle.get_IdEmpresa());
- }
- else
- {
- nullable = null;
- nullable1 = nullable;
- }
- }
- else
- {
- nullable = null;
- nullable1 = nullable;
- }
- long? nullable2 = nullable1;
- if (idEmpresa != (nullable2.HasValue ? nullable2.GetValueOrDefault() : Recursos.Empresa.get_Id()))
- {
- return false;
- }
- return x.get_Corretora();
- }));
- num = new decimal();
- vendedorParcela.set_PorcentagemRepasse(new decimal?(num));
- vendedorParcela.set_TipoVendedor(Recursos.TipoVendedor.First<TipoVendedor>((TipoVendedor x) => x.get_Id() == (long)1));
- return vendedorParcela;
- }
-
- public void RecalculaRepasse()
- {
- List<!0> list;
- if (!this.IsFatura && this.BaixarParcelas && this.SelectedParcela.get_SubTipo() == 1)
- {
- return;
- }
- if (this.Repasses == null || this.Repasses.Count == 0)
- {
- return;
- }
- if (this.SelectedParcela.get_Id() == 0)
- {
- this.Repasses.ForEach((VendedorParcela x) => {
- decimal? porcentagemRepasse;
- bool valueOrDefault;
- decimal? nullable;
- bool flag;
- if (x.get_DataPagamento().HasValue)
- {
- return;
- }
- Gestor.Model.Domain.Seguros.Repasse repasse = x.get_Repasse();
- valueOrDefault = (repasse != null ? repasse.get_Tipo().GetValueOrDefault() == 3 : false);
- if (valueOrDefault)
- {
- return;
- }
- Parcela parcela = x.get_Parcela() ?? this.SelectedParcela;
- parcela.set_Documento(this.SelectedDocumento);
- if (x.get_Repasse() != null)
- {
- Gestor.Model.Domain.Seguros.Repasse repasse1 = x.get_Repasse();
- porcentagemRepasse = x.get_PorcentagemRepasse();
- repasse1.set_ValorNovo((porcentagemRepasse.HasValue ? porcentagemRepasse.GetValueOrDefault() : x.get_Repasse().get_ValorNovo()));
- Gestor.Model.Domain.Seguros.Repasse repasse2 = x.get_Repasse();
- porcentagemRepasse = x.get_PorcentagemRepasse();
- repasse2.set_ValorRenovacao((porcentagemRepasse.HasValue ? porcentagemRepasse.GetValueOrDefault() : x.get_Repasse().get_ValorRenovacao()));
- }
- decimal num = Funcoes.CalculaRepasse(x.get_Repasse(), parcela, true);
- VendedorParcela vendedorParcela = x;
- if (this.SelectedDocumento.get_NumeroParcelas() > decimal.Zero && !this.SelectedParcela.get_NumeroParcela().Equals(999))
- {
- Gestor.Model.Domain.Seguros.Repasse repasse3 = x.get_Repasse();
- flag = (repasse3 != null ? repasse3.get_Forma().GetValueOrDefault() == 3 : false);
- if (!flag)
- {
- nullable = new decimal?(num);
- vendedorParcela.set_ValorRepasse(nullable);
- x.set_ValorTotal(new decimal?(num));
- return;
- }
- porcentagemRepasse = x.get_ValorTotal();
- decimal numeroParcelas = this.SelectedDocumento.get_NumeroParcelas();
- if (porcentagemRepasse.HasValue)
- {
- nullable = new decimal?(porcentagemRepasse.GetValueOrDefault() / numeroParcelas);
- vendedorParcela.set_ValorRepasse(nullable);
- x.set_ValorTotal(new decimal?(num));
- return;
- }
- else
- {
- nullable = null;
- vendedorParcela.set_ValorRepasse(nullable);
- x.set_ValorTotal(new decimal?(num));
- return;
- }
- }
- nullable = new decimal?(num);
- vendedorParcela.set_ValorRepasse(nullable);
- x.set_ValorTotal(new decimal?(num));
- });
- this.Pagamentos = new ObservableCollection<VendedorParcela>(this.Repasses);
- return;
- }
- List<VendedorParcela> repasses = this.Repasses;
- if (repasses != null)
- {
- repasses.Where<VendedorParcela>((VendedorParcela x) => {
- if (this.SelectedParcela.get_Id() <= (long)0)
- {
- return false;
- }
- return x.get_Parcela().get_Id() == this.SelectedParcela.get_Id();
- }).ToList<VendedorParcela>().ForEach((VendedorParcela x) => {
- decimal? porcentagemRepasse;
- bool valueOrDefault;
- decimal? nullable;
- VendedorParcela vendedorParcela;
- decimal? nullable1;
- bool flag;
- if (x.get_DataPagamento().HasValue)
- {
- return;
- }
- Gestor.Model.Domain.Seguros.Repasse repasse = x.get_Repasse();
- valueOrDefault = (repasse != null ? repasse.get_Tipo().GetValueOrDefault() == 3 : false);
- if (valueOrDefault)
- {
- return;
- }
- Parcela selectedParcela = this.SelectedParcela;
- selectedParcela.set_Documento(this.SelectedDocumento);
- if (x.get_Repasse() != null)
- {
- Gestor.Model.Domain.Seguros.Repasse repasse1 = x.get_Repasse();
- porcentagemRepasse = x.get_PorcentagemRepasse();
- repasse1.set_ValorNovo((porcentagemRepasse.HasValue ? porcentagemRepasse.GetValueOrDefault() : x.get_Repasse().get_ValorNovo()));
- Gestor.Model.Domain.Seguros.Repasse repasse2 = x.get_Repasse();
- porcentagemRepasse = x.get_PorcentagemRepasse();
- repasse2.set_ValorRenovacao((porcentagemRepasse.HasValue ? porcentagemRepasse.GetValueOrDefault() : x.get_Repasse().get_ValorRenovacao()));
- }
- decimal num = Funcoes.CalculaRepasse(x.get_Repasse(), selectedParcela, true);
- VendedorParcela vendedorParcela1 = x;
- if (this.SelectedDocumento.get_NumeroParcelas() > decimal.Zero && !this.SelectedParcela.get_NumeroParcela().Equals(999))
- {
- Gestor.Model.Domain.Seguros.Repasse repasse3 = x.get_Repasse();
- flag = (repasse3 != null ? repasse3.get_Forma().GetValueOrDefault() == 3 : false);
- if (!flag)
- {
- nullable = new decimal?(num);
- vendedorParcela1.set_ValorRepasse(nullable);
- vendedorParcela = x;
- nullable1 = (this.SelectedDocumento.get_TipoRecebimento().GetValueOrDefault() != 1 || this.SelectedParcela.get_SubTipo() != 1 ? x.get_ValorTotal() : new decimal?(num));
- vendedorParcela.set_ValorTotal(nullable1);
- return;
- }
- porcentagemRepasse = x.get_ValorTotal();
- decimal numeroParcelas = this.SelectedDocumento.get_NumeroParcelas();
- if (porcentagemRepasse.HasValue)
- {
- nullable = new decimal?(porcentagemRepasse.GetValueOrDefault() / numeroParcelas);
- vendedorParcela1.set_ValorRepasse(nullable);
- vendedorParcela = x;
- nullable1 = (this.SelectedDocumento.get_TipoRecebimento().GetValueOrDefault() != 1 || this.SelectedParcela.get_SubTipo() != 1 ? x.get_ValorTotal() : new decimal?(num));
- vendedorParcela.set_ValorTotal(nullable1);
- return;
- }
- else
- {
- nullable = null;
- vendedorParcela1.set_ValorRepasse(nullable);
- vendedorParcela = x;
- nullable1 = (this.SelectedDocumento.get_TipoRecebimento().GetValueOrDefault() != 1 || this.SelectedParcela.get_SubTipo() != 1 ? x.get_ValorTotal() : new decimal?(num));
- vendedorParcela.set_ValorTotal(nullable1);
- return;
- }
- }
- nullable = new decimal?(num);
- vendedorParcela1.set_ValorRepasse(nullable);
- vendedorParcela = x;
- nullable1 = (this.SelectedDocumento.get_TipoRecebimento().GetValueOrDefault() != 1 || this.SelectedParcela.get_SubTipo() != 1 ? x.get_ValorTotal() : new decimal?(num));
- vendedorParcela.set_ValorTotal(nullable1);
- });
- }
- else
- {
- }
- List<VendedorParcela> vendedorParcelas = this.Repasses;
- if (vendedorParcelas != null)
- {
- list = vendedorParcelas.Where<VendedorParcela>((VendedorParcela x) => {
- if (this.SelectedParcela.get_Id() <= (long)0)
- {
- return false;
- }
- return x.get_Parcela().get_Id() == this.SelectedParcela.get_Id();
- }).ToList<VendedorParcela>();
- }
- else
- {
- list = null;
- }
- this.Pagamentos = new ObservableCollection<VendedorParcela>(list);
- }
-
- public async void RecalculaRepasses()
- {
- bool flag;
- if (this.Repasses != null)
- {
- if (this.SelectedDocumento.get_NegocioCorretora().HasValue)
- {
- NegocioCorretora? negocioCorretora = this.SelectedDocumento.get_NegocioCorretora();
- flag = negocioCorretora.GetValueOrDefault() == 1;
- }
- else if (this.SelectedDocumento.get_Situacao() != 2 || !this.SelectedDocumento.get_Negocio().HasValue)
- {
- flag = false;
- }
- else
- {
- Negocio? negocio = this.SelectedDocumento.get_Negocio();
- flag = negocio.GetValueOrDefault() == 1;
- }
- bool flag1 = flag;
- List<VendedorParcela> repasses = this.Repasses;
- if (repasses != null)
- {
- repasses.Where<VendedorParcela>((VendedorParcela x) => {
- if (this.NovaApolice)
- {
- return true;
- }
- return x.get_Parcela().get_SubTipo() == 1;
- }).ToList<VendedorParcela>().ForEach((VendedorParcela x) => {
- decimal? valorTotal;
- decimal numeroParcelas;
- decimal? nullable;
- decimal valorRenovacao;
- decimal? nullable1;
- decimal? nullable2;
- decimal? nullable3;
- bool valueOrDefault;
- if (x.get_Parcela() == null)
- {
- return;
- }
- if (x.get_Repasse() == null)
- {
- return;
- }
- if (x.get_DataPagamento().HasValue)
- {
- return;
- }
- Parcela parcela = x.get_Parcela();
- parcela.set_Documento(this.SelectedDocumento);
- decimal num = Funcoes.CalculaRepasse(x.get_Repasse(), parcela, true);
- VendedorParcela vendedorParcela = x;
- if (flag1)
- {
- Gestor.Model.Domain.Seguros.Repasse repasse = x.get_Repasse();
- valueOrDefault = (repasse != null ? repasse.get_Tipo().GetValueOrDefault() != 3 : true);
- if (!valueOrDefault)
- {
- goto Label1;
- }
- valorRenovacao = x.get_Repasse().get_ValorRenovacao();
- goto Label0;
- }
- Label1:
- valorRenovacao = x.get_Repasse().get_ValorNovo();
- Label0:
- vendedorParcela.set_PorcentagemRepasse(new decimal?(valorRenovacao));
- if (x.get_Repasse().get_Forma().GetValueOrDefault() == 3)
- {
- valorTotal = x.get_ValorTotal();
- numeroParcelas = this.SelectedDocumento.get_NumeroParcelas();
- if (valorTotal.HasValue)
- {
- nullable1 = new decimal?(valorTotal.GetValueOrDefault() / numeroParcelas);
- }
- else
- {
- nullable = null;
- nullable1 = nullable;
- }
- }
- else
- {
- nullable1 = new decimal?(num);
- }
- decimal? nullable4 = nullable1;
- if (x.get_CoCorretagem())
- {
- numeroParcelas = this.SelectedDocumento.get_PremioLiquido();
- decimal? comissaoTotal = this.SelectedDocumento.get_ComissaoTotal();
- decimal comissao = this.SelectedDocumento.get_Comissao();
- nullable = (comissaoTotal.HasValue ? new decimal?(comissaoTotal.GetValueOrDefault() - comissao) : null);
- decimal num1 = 100;
- if (nullable.HasValue)
- {
- nullable2 = new decimal?(nullable.GetValueOrDefault() / num1);
- }
- else
- {
- comissaoTotal = null;
- nullable2 = comissaoTotal;
- }
- valorTotal = nullable2;
- if (valorTotal.HasValue)
- {
- nullable3 = new decimal?(numeroParcelas * valorTotal.GetValueOrDefault());
- }
- else
- {
- nullable = null;
- nullable3 = nullable;
- }
- nullable4 = nullable3;
- }
- x.set_ValorRepasse(nullable4);
- x.set_ValorTotal(new decimal?(num));
- });
- }
- else
- {
- }
- if (!this.NovaApolice)
- {
- BaseApoliceViewModel baseApoliceViewModel = this;
- Parcela selectedParcela = this.SelectedParcela;
- if (selectedParcela == null)
- {
- selectedParcela = this.Parcelas.FirstOrDefault<Parcela>();
- }
- await baseApoliceViewModel.SelecionaParcela(selectedParcela);
- this.CalculaComissao(this.SelectedDocumento, this.Parcelas);
- }
- else
- {
- BaseApoliceViewModel observableCollection = this;
- List<VendedorParcela> vendedorParcelas = this.Repasses;
- observableCollection.Pagamentos = new ObservableCollection<VendedorParcela>(
- from x in vendedorParcelas
- orderby x.get_TipoVendedor().get_Id()
- select x);
- }
- }
- }
-
- public async Task RecusarApolice()
- {
- bool flag;
- IList<Documento> list;
- string str;
- string str1;
- string str2;
- if (this.SelectedDocumento != null)
- {
- bool[] flagArray = await Funcoes.VerificarPagamento(this.SelectedDocumento.get_Id());
- List<ConfiguracaoSistema> configuracoes = Recursos.Configuracoes;
- if (configuracoes.All<ConfiguracaoSistema>((ConfiguracaoSistema x) => x.get_Configuracao() != 23))
- {
- bool[] flagArray1 = flagArray;
- if (((IEnumerable<bool>)flagArray1).Any<bool>((bool x) => x))
- {
- await base.ShowMessage("NÃO É POSSÍVEL RECURSAR UM APÓLICE ENQUANTO HOUVER RECEBIMENTO DE COMISSÃO OU PAGAMENTO DE VENDEDORES PARA A APÓLICE", "OK", "", false);
- str2 = null;
- return;
- }
- }
- List<ConfiguracaoSistema> configuracaoSistemas = Recursos.Configuracoes;
- flag = (!configuracaoSistemas.Any<ConfiguracaoSistema>((ConfiguracaoSistema x) => x.get_Configuracao() == 23) ? false : flagArray[1]);
- bool flag1 = flag;
- if (flag1)
- {
- flag1 = await base.ShowMessage("EXISTEM PAGAMENTOS PARA OS VENDEDORES DO CONTRATO, DESEJA CRIAR ESTORNOS PARA ESSES PAGAMENTOS?", "SIM", "NÃO", false);
- }
- bool flag2 = flag1;
- Documento documento = await this.Servico.BuscarApoliceAsync(this.DocumentoSelecionado.get_Id(), false, false);
- if (documento.get_Controle().get_Documentos().Count > 1)
- {
- IList<Documento> documentos = documento.get_Controle().get_Documentos();
- IEnumerable<Documento> excluido =
- from x in documentos
- where !x.get_Excluido()
- select x;
- list = (
- from x in excluido
- orderby x.get_Ordem()
- select x).ToList<Documento>();
- }
- else
- {
- list = documento.get_Controle().get_Documentos();
- }
- IList<Documento> documentos1 = list;
- if (documentos1.Count > 1)
- {
- IList<Documento> documentos2 = documentos1;
- if (documentos2.Last<Documento>((Documento x) => x.get_Situacao() != 7).get_Id() != this.DocumentoSelecionado.get_Id())
- {
- await base.ShowMessage("NÃO É POSSÍVEL RECUSAR UM DOCUMENTO ENQUANTO HOUVER ENDOSSOS EM CIMA DO MESMO.", "OK", "", false);
- str2 = null;
- return;
- }
- }
- if (documento.get_Situacao() != 7)
- {
- if (this.SelectedDocumento.get_Tipo() != 0 || !string.IsNullOrEmpty(this.SelectedDocumento.get_Apolice()))
- {
- str = (this.SelectedDocumento.get_Tipo() != 0 || string.IsNullOrEmpty(this.SelectedDocumento.get_Apolice()) ? "O ENDOSSO SELECIONADO" : "A APÓLICE SELECIONADA");
- }
- else
- {
- str = "A PROPOSTA SELECIONADA";
- }
- string str3 = str;
- string[] newLine = new string[] { "DESEJA REALMENTE RECUSAR ", str3, "? ", Environment.NewLine, "ESSE PROCEDIMENTO É IRREVERSÍVEL." };
- if (await base.ShowMessage(string.Concat(newLine), "SIM", "NÃO", false))
- {
- str2 = null;
- str2 = await base.ShowObservacaoDialog();
- if (str2 != null)
- {
- base.Loading(true);
- await Funcoes.RecusarApolice(this.SelectedDocumento, str2, flag2);
- if (this.SelectedDocumento.get_Tipo() == 0 && string.IsNullOrEmpty(this.SelectedDocumento.get_Apolice()))
- {
- str1 = string.Concat("A PROPOSTA \"", this.SelectedDocumento.get_Proposta(), "\"");
- }
- else if (this.SelectedDocumento.get_Tipo() != 0 || string.IsNullOrEmpty(this.SelectedDocumento.get_Apolice()))
- {
- str1 = (string.IsNullOrEmpty(this.SelectedDocumento.get_Endosso()) ? string.Concat("A PROPOSTA DE ENDOSSO \"", this.SelectedDocumento.get_PropostaEndosso(), "\"") : string.Concat("O ENDOSSO \"", this.SelectedDocumento.get_Endosso(), "\""));
- }
- else
- {
- str1 = string.Concat("A APÓLICE \"", this.SelectedDocumento.get_Apolice(), "\"");
- }
- string str4 = str1;
- base.RegistrarAcao(string.Concat("RECUSOU ", str4), this.SelectedDocumento.get_Id(), new TipoTela?(2), string.Concat(this.GerarObs(this.SelectedDocumento), Environment.NewLine, "MOTIVO: ", str2));
- base.Loading(false);
- }
- }
- }
- else
- {
- await base.ShowMessage("NÃO É POSSÍVEL RECUSAR UM DOCUMENTO JÁ RECUSADO.", "OK", "", false);
- }
- }
- str2 = null;
- }
-
- private void RemoverVendedor(long id)
- {
- ((this.SelectedDocumento.get_Id() == 0 || this.SelectedParcela.get_SubTipo() == 1 && !this.IsFatura ? (
- from x in this.Repasses
- where x.get_Vendedor().get_Id() == id
- select x).ToList<VendedorParcela>() : this.Repasses.Where<VendedorParcela>((VendedorParcela x) => {
- if (x.get_Vendedor().get_Id() != id)
- {
- return false;
- }
- return x.get_Parcela().get_Id() == this.SelectedParcela.get_Id();
- }).ToList<VendedorParcela>())).ForEach((VendedorParcela x) => this.Repasses.Remove(x));
- ((this.SelectedDocumento.get_Id() == 0 || this.SelectedParcela.get_SubTipo() == 1 && !this.IsFatura ? (
- from x in this.Pagamentos
- where x.get_Vendedor().get_Id() == id
- select x).ToList<VendedorParcela>() : this.Pagamentos.Where<VendedorParcela>((VendedorParcela x) => {
- long num;
- if (x.get_Vendedor().get_Id() != id)
- {
- return false;
- }
- Parcela parcela = x.get_Parcela();
- num = (parcela != null ? parcela.get_Id() : (long)0);
- return num == this.SelectedParcela.get_Id();
- }).ToList<VendedorParcela>())).ForEach((VendedorParcela x) => this.Pagamentos.Remove(x));
- }
-
- public async Task ReplicarFatura()
- {
- DateTime? emissao;
- int num;
- decimal comissao;
- DateTime? vigenciaFinal;
- DateTime dateTime;
- DateTime? nullable1;
- DateTime dateTime1;
- DateTime date;
- decimal valor;
- decimal valorLiquidoFatura;
- if (this.Parcelas != null)
- {
- ObservableCollection<Parcela> parcelas = this.Parcelas;
- IOrderedEnumerable<Parcela> numeroParcela =
- from x in parcelas
- orderby x.get_NumeroParcela()
- select x;
- Parcela parcela = numeroParcela.LastOrDefault<Parcela>((Parcela x) => x.get_SubTipo() == 1);
- if (parcela == null || parcela.get_NumeroParcela() != 999)
- {
- num = (parcela != null ? parcela.get_NumeroParcela() : 0);
- int num1 = num + 1;
- Parcela selectedParcela = this.SelectedParcela;
- if (selectedParcela != null)
- {
- comissao = selectedParcela.get_Comissao();
- }
- else
- {
- comissao = decimal.Zero;
- }
- decimal num2 = comissao;
- ObservableCollection<Parcela> observableCollection = this.Parcelas;
- Parcela parcela1 = observableCollection.First<Parcela>((Parcela x) => x.get_SubTipo() == 1);
- DateTime networkTime = Funcoes.GetNetworkTime();
- Parcela parcela2 = parcela1;
- if (parcela2 != null)
- {
- vigenciaFinal = parcela2.get_VigenciaFinal();
- }
- else
- {
- emissao = null;
- vigenciaFinal = emissao;
- }
- DateTime? nullable2 = vigenciaFinal;
- dateTime = (nullable2.HasValue ? nullable2.GetValueOrDefault() : networkTime.Date);
- DateTime dateTime2 = dateTime;
- Parcela parcela3 = parcela1;
- if (parcela3 != null)
- {
- emissao = parcela3.get_Emissao();
- if (emissao.HasValue)
- {
- DateTime valueOrDefault = emissao.GetValueOrDefault();
- nullable1 = new DateTime?(valueOrDefault.AddMonths(1));
- }
- else
- {
- nullable1 = null;
- }
- }
- else
- {
- emissao = null;
- nullable1 = emissao;
- }
- nullable2 = nullable1;
- dateTime1 = (nullable2.HasValue ? nullable2.GetValueOrDefault() : networkTime.Date);
- DateTime dateTime3 = dateTime1;
- Parcela parcela4 = parcela1;
- if (parcela4 != null)
- {
- date = parcela4.get_Vencimento().AddMonths(1);
- }
- else
- {
- date = networkTime.Date;
- }
- DateTime dateTime4 = date;
- DateTime dateTime5 = dateTime2.AddMonths(1);
- Parcela parcela5 = parcela1;
- if (parcela5 != null)
- {
- valor = parcela5.get_Valor();
- }
- else
- {
- valor = decimal.Zero;
- }
- decimal num3 = valor;
- Parcela parcela6 = parcela1;
- if (parcela6 != null)
- {
- valorLiquidoFatura = parcela6.get_ValorLiquidoFatura();
- }
- else
- {
- valorLiquidoFatura = decimal.Zero;
- }
- decimal num4 = valorLiquidoFatura;
- IEnumerable<VendedorParcela> vendedorParcelas = this.Repasses.Where<VendedorParcela>((VendedorParcela x) => {
- if (parcela1 == null)
- {
- return false;
- }
- return x.get_Parcela().get_Id() == parcela1.get_Id();
- });
- List<VendedorParcela> list = Funcoes.DistinctBy(vendedorParcelas, (VendedorParcela x) => new { Id = x.get_Parcela().get_Id(), vendedor = x.get_Vendedor().get_Id(), tipovendedor = x.get_TipoVendedor().get_Id() }).ToList<VendedorParcela>();
- Parcela parcela7 = new Parcela();
- parcela7.set_IdEmpresa(this.SelectedDocumento.get_Controle().get_IdEmpresa());
- parcela7.set_Documento(this.SelectedDocumento);
- parcela7.set_Vencimento(dateTime4);
- parcela7.set_Comissao(num2);
- parcela7.set_SubTipo(1);
- parcela7.set_NumeroParcela(num1);
- parcela7.set_VigenciaIncial(new DateTime?(dateTime2));
- parcela7.set_VigenciaFinal(new DateTime?(dateTime5));
- parcela7.set_Valor(num3);
- parcela7.set_Emissao(new DateTime?(dateTime3));
- parcela7.set_DataCriacao(new DateTime?(networkTime));
- parcela7.set_ValorLiquidoFatura(num4);
- this.SelectedParcela = parcela7;
- list.ForEach((VendedorParcela x) => {
- decimal zero;
- x.set_Id((long)0);
- x.set_Parcela(this.SelectedParcela);
- DateTime? nullable = null;
- x.set_DataPrePagamento(nullable);
- nullable = null;
- x.set_DataPagamento(nullable);
- VendedorParcela vendedorParcela = x;
- if (x.get_Repasse() != null)
- {
- NegocioCorretora? negocioCorretora = this.SelectedDocumento.get_NegocioCorretora();
- zero = (negocioCorretora.GetValueOrDefault() == 0 & negocioCorretora.HasValue ? x.get_Repasse().get_ValorNovo() : x.get_Repasse().get_ValorRenovacao());
- }
- else
- {
- zero = decimal.Zero;
- }
- vendedorParcela.set_PorcentagemRepasse(new decimal?(zero));
- });
- this.Repasses = list;
- }
- else
- {
- await base.ShowMessage("PARCELA ESPECIAL NÃO PODE SER REPLICADA.", "OK", "", false);
- return;
- }
- }
- this.RecalculaRepasse();
- }
-
- public async Task<List<KeyValuePair<string, string>>> Salvar(bool critica = false)
- {
- List<KeyValuePair<string, string>> list;
- NegocioCorretora? negocioCorretora;
- NegocioCorretora? nullable;
- bool id;
- bool vendedor;
- bool updatePremio;
- bool flag2;
- bool flag3;
- List<VendedorParcela> vendedorParcelas;
- bool flag4;
- Vendedor vendedor1;
- Documento documento;
- string str;
- string str1;
- bool valueOrDefault;
- long? nullable1;
- bool flag5;
- NegocioCorretora negocioCorretora1;
- string str2;
- NegocioCorretora negocioCorretora2;
- FormaPagamento formaPagamento;
- bool vendedor2;
- Negocio negocio;
- object obj = null;
- if (this.SelectedDocumento.get_Situacao() == 2)
- {
- Documento selectedDocumento = this.SelectedDocumento;
- negocioCorretora = this.SelectedDocumento.get_NegocioCorretora();
- negocio = (negocioCorretora.GetValueOrDefault() == 0 & negocioCorretora.HasValue ? 2 : 1);
- selectedDocumento.set_Negocio(new Negocio?(negocio));
- }
- Gestor.Model.Domain.Seguros.Status status = this.SelectedDocumento.get_Status();
- if (status != null)
- {
- id = status.get_Id() == (long)0;
- }
- else
- {
- id = false;
- }
- if (id)
- {
- this.SelectedDocumento.set_Status(null);
- }
- this.ZerarValores();
- Documento selectedDocumento1 = this.SelectedDocumento;
- bool isEndosso = this.IsEndosso;
- List<ConfiguracaoSistema> configuracaoSistemas1 = Recursos.Configuracoes;
- List<KeyValuePair<string, string>> keyValuePairs1 = selectedDocumento1.Validate(isEndosso, configuracaoSistemas1.Any<ConfiguracaoSistema>((ConfiguracaoSistema c) => c.get_Configuracao() == 11));
- if (this.SelectedDocumento.get_Comissao() > new decimal(100))
- {
- this.SelectedDocumento.set_Comissao(new decimal(100));
- }
- bool id1 = this.SelectedDocumento.get_Id() == (long)0;
- VendedorParcela selectedPagamento = this.SelectedPagamento;
- if (selectedPagamento != null)
- {
- vendedor = selectedPagamento.get_Vendedor();
- }
- else
- {
- vendedor = false;
- }
- if (vendedor && this.SelectedDocumento.get_Vendedores() == null)
- {
- Documento documento1 = this.SelectedDocumento;
- List<Vendedor> vendedors = new List<Vendedor>()
- {
- this.TodosVendedores.First<Vendedor>((Vendedor x) => {
- if (!x.get_Corretora())
- {
- return false;
- }
- return x.get_IdEmpresa() == this.SelectedDocumento.get_Controle().get_IdEmpresa();
- })
- };
- documento1.set_Vendedores(vendedors);
- }
- if (id1)
- {
- VendedorParcela vendedorParcela = this.SelectedPagamento;
- if (vendedorParcela != null)
- {
- vendedor2 = vendedorParcela.get_Vendedor();
- }
- else
- {
- vendedor2 = false;
- }
- if (vendedor2 && this.SelectedDocumento.get_Vendedores() != null)
- {
- List<KeyValuePair<string, string>> keyValuePairs2 = keyValuePairs1;
- List<KeyValuePair<string, string>> keyValuePairs3 = await this.AdicionarVendedor();
- List<KeyValuePair<string, string>> keyValuePairs4 = keyValuePairs2;
- List<KeyValuePair<string, string>> keyValuePairs5 = keyValuePairs3;
- if (keyValuePairs5 == null)
- {
- keyValuePairs5 = new List<KeyValuePair<string, string>>();
- }
- keyValuePairs4.AddRange(keyValuePairs5);
- keyValuePairs2 = null;
- }
- }
- if (keyValuePairs1.Count <= 0)
- {
- bool tipo = this.SelectedDocumento.get_Tipo() == 0;
- if (tipo)
- {
- tipo = !await this.VerificarVigencia(this.SelectedDocumento);
- }
- if (tipo)
- {
- if (critica)
- {
- keyValuePairs1.Add(new KeyValuePair<string, string>("Vigencia2", "VIGENCIANAOACEITA"));
- }
- list = keyValuePairs1;
- }
- else if (this.SelectedDocumento.get_TipoEndosso().GetValueOrDefault() == 3 || this.SelectedDocumento.get_Situacao() != 3 || this.SelectedDocumento.get_Id() != 0)
- {
- if (this.SelectedDocumento.get_TipoEndosso().HasValue && this.SelectedDocumento.get_TipoEndosso().GetValueOrDefault() == 3)
- {
- this.SelectedDocumento.set_Situacao(4);
- }
- Documento selectedDocumento2 = this.SelectedDocumento;
- base.Alterar(false);
- if (!selectedDocumento2.get_FormaPagamento().HasValue)
- {
- Documento documento2 = selectedDocumento2;
- List<ConfiguracaoSistema> configuracaoSistemas2 = Recursos.Configuracoes;
- formaPagamento = (configuracaoSistemas2.Any<ConfiguracaoSistema>((ConfiguracaoSistema y) => y.get_Configuracao() == 21) ? 4 : 0);
- documento2.set_FormaPagamento(new FormaPagamento?(formaPagamento));
- }
- this.Acesso = 0;
- if (selectedDocumento2.get_Id() <= (long)0 || !this.AllowEditApolice)
- {
- updatePremio = false;
- }
- else
- {
- if (!(this.CancelDocumento.get_PremioLiquido() != selectedDocumento2.get_PremioLiquido()) && this.CancelDocumento.get_AdicionalComiss() == selectedDocumento2.get_AdicionalComiss() && (!selectedDocumento2.get_AdicionalComiss() || !(this.CancelDocumento.get_PremioAdicional() != selectedDocumento2.get_PremioAdicional())) && !(this.CancelDocumento.get_Comissao() != selectedDocumento2.get_Comissao()))
- {
- negocioCorretora = this.CancelDocumento.get_NegocioCorretora();
- nullable = selectedDocumento2.get_NegocioCorretora();
- if (negocioCorretora.GetValueOrDefault() != nullable.GetValueOrDefault() | negocioCorretora.HasValue != nullable.HasValue || this.CancelDocumento.get_Diferenca() != selectedDocumento2.get_Diferenca() || this.CancelDocumento.get_Iof() != selectedDocumento2.get_Iof())
- {
- goto Label1;
- }
- updatePremio = this.UpdatePremio;
- goto Label0;
- }
- Label1:
- updatePremio = true;
- }
- Label0:
- bool flag6 = updatePremio;
- if (selectedDocumento2.get_TipoRecebimento().GetValueOrDefault() == 2)
- {
- flag2 = false;
- }
- else
- {
- flag2 = (selectedDocumento2.get_Id() == 0 || this.CancelDocumento.get_NumeroParcelas() != selectedDocumento2.get_NumeroParcelas() ? true : selectedDocumento2.get_NumeroParcelas() != this.Parcelas.Count<Parcela>((Parcela x) => x.get_SubTipo() == 1));
- }
- bool flag7 = flag2;
- nullable = selectedDocumento2.get_NegocioCorretora();
- bool valueOrDefault1 = nullable.GetValueOrDefault() == 1;
- if (flag7 && selectedDocumento2.get_TipoRecebimento().GetValueOrDefault() == 1)
- {
- this.CriarParcelas(id1);
- this.Parcelas.ToList<Parcela>().ForEach((Parcela x) => {
- x.set_Documento(selectedDocumento2);
- List<KeyValuePair<string, string>> keyValuePairs = keyValuePairs1;
- Parcela parcela = x;
- List<ConfiguracaoSistema> configuracoes = Recursos.Configuracoes;
- Func<ConfiguracaoSistema, bool> u003cu003e9_29911 = BaseApoliceViewModel.u003cu003ec.u003cu003e9__299_11;
- if (u003cu003e9_29911 == null)
- {
- u003cu003e9_29911 = (ConfiguracaoSistema y) => y.get_Configuracao() == 9;
- BaseApoliceViewModel.u003cu003ec.u003cu003e9__299_11 = u003cu003e9_29911;
- }
- bool flag = configuracoes.Any<ConfiguracaoSistema>(u003cu003e9_29911);
- List<ConfiguracaoSistema> configuracaoSistemas = Recursos.Configuracoes;
- Func<ConfiguracaoSistema, bool> u003cu003e9_29912 = BaseApoliceViewModel.u003cu003ec.u003cu003e9__299_12;
- if (u003cu003e9_29912 == null)
- {
- u003cu003e9_29912 = (ConfiguracaoSistema y) => y.get_Configuracao() == 11;
- BaseApoliceViewModel.u003cu003ec.u003cu003e9__299_12 = u003cu003e9_29912;
- }
- bool flag1 = configuracaoSistemas.Any<ConfiguracaoSistema>(u003cu003e9_29912);
- bool editandoParcela = this.EditandoParcela;
- List<ConfiguracaoSistema> configuracoes1 = Recursos.Configuracoes;
- Func<ConfiguracaoSistema, bool> u003cu003e9_29913 = BaseApoliceViewModel.u003cu003ec.u003cu003e9__299_13;
- if (u003cu003e9_29913 == null)
- {
- u003cu003e9_29913 = (ConfiguracaoSistema r) => r.get_Configuracao() == 16;
- BaseApoliceViewModel.u003cu003ec.u003cu003e9__299_13 = u003cu003e9_29913;
- }
- keyValuePairs.AddRange(parcela.Validate(flag, flag1, editandoParcela, configuracoes1.Any<ConfiguracaoSistema>(u003cu003e9_29913)));
- });
- if (keyValuePairs1.Count > 0)
- {
- base.Alterar(true);
- list = keyValuePairs1.Distinct<KeyValuePair<string, string>>().ToList<KeyValuePair<string, string>>();
- return list;
- }
- }
- if (this.Parcelas == null || this.Parcelas.Count == 0)
- {
- this.Pagamentos = new ObservableCollection<VendedorParcela>();
- }
- if (flag6 && !flag7)
- {
- this.AtualizaValores(valueOrDefault1);
- }
- if (this.SelectedDocumento.get_Situacao() == 5 && this.SelectedDocumento.get_Controle().get_Documentos() != null && this.SelectedDocumento.get_Controle().get_Documentos().Count > 0)
- {
- IList<Documento> documentos = this.SelectedDocumento.get_Controle().get_Documentos();
- foreach (Documento documento3 in documentos.Where<Documento>((Documento x) => {
- if (x.get_Tipo() == 0)
- {
- return false;
- }
- return !x.get_Excluido();
- }))
- {
- if (documento3.get_Situacao() == 3)
- {
- continue;
- }
- documento3.set_SituacaoAnterior(new TipoSeguro?(documento3.get_Situacao()));
- documento3.set_Situacao(5);
- await this.Servico.Save(documento3, false, false);
- }
- }
- if (this.SelectedDocumento.get_Id() != 0 && this.SelectedDocumento.get_Tipo() == 0 && this.SelectedDocumento.get_Controle().get_Documentos() != null && this.SelectedDocumento.get_Controle().get_Documentos().Count > 0)
- {
- IList<Documento> documentos1 = this.SelectedDocumento.get_Controle().get_Documentos();
- if (documentos1.Where<Documento>((Documento x) => {
- if (x.get_Tipo() == 0)
- {
- return false;
- }
- return !x.get_Excluido();
- }).Any<Documento>((Documento x) => {
- if (x.get_Apolice() != this.SelectedDocumento.get_Apolice())
- {
- return true;
- }
- return x.get_Proposta() != this.SelectedDocumento.get_Proposta();
- }))
- {
- IList<Documento> documentos2 = this.SelectedDocumento.get_Controle().get_Documentos();
- foreach (Documento documento4 in documentos2.Where<Documento>((Documento x) => {
- if (x.get_Tipo() == 0)
- {
- return false;
- }
- return !x.get_Excluido();
- }))
- {
- documento4.set_Apolice(this.SelectedDocumento.get_Apolice());
- documento4.set_Proposta(this.SelectedDocumento.get_Proposta());
- await this.Servico.Save(documento4, false, false);
- base.ToggleSnackBar("NUMERO DA PROPOSTA/APOLICE ATUALIZADOS NO ENDOSSO", true);
- }
- }
- }
- if (this.Renovar)
- {
- nullable = this.CancelDocumento.get_NegocioCorretora();
- if (!nullable.HasValue)
- {
- Documento cancelDocumento = this.CancelDocumento;
- negocioCorretora2 = (!this.CancelDocumento.get_Negocio().HasValue || this.CancelDocumento.get_Negocio().GetValueOrDefault() != 1 ? 0 : 1);
- cancelDocumento.set_NegocioCorretora(new NegocioCorretora?(negocioCorretora2));
- }
- this.CancelDocumento.set_Situacao(5);
- IList<Documento> documentos3 = this.CancelDocumento.get_Controle().get_Documentos();
- IEnumerable<Documento> documentos4 = documentos3.Where<Documento>((Documento d) => {
- if (d.get_Tipo() != 1)
- {
- return false;
- }
- if (d.get_Situacao() == 1 || d.get_Situacao() == 2)
- {
- return true;
- }
- return d.get_Situacao() == 4;
- });
- foreach (Documento documento5 in documentos4)
- {
- documento5.set_Situacao(5);
- await this.Servico.Save(documento5, false, false);
- }
- this.Servico.Sucesso = true;
- await this.Servico.Save(this.CancelDocumento, false, false);
- if (!this.Servico.Sucesso)
- {
- await base.ShowMessage("NÃO FOI POSSÍVEL ALTERAR O STATUS DO DOCUMENTO RENOVADO, POR FAVOR VERIFIQUE APÓS O PROCEDIMENTO SER CONCLUÍDO.", "OK", "", false);
- }
- str2 = (string.IsNullOrEmpty(this.CancelDocumento.get_Apolice()) ? string.Concat("A PROPOSTA \"", this.CancelDocumento.get_Proposta(), "\"") : string.Concat("A APÓLICE \"", this.CancelDocumento.get_Apolice(), "\""));
- string str3 = str2;
- base.RegistrarAcao(string.Concat("RENOVOU ", str3), this.CancelDocumento.get_Id(), new TipoTela?(2), this.GerarObs(this.CancelDocumento));
- }
- if (selectedDocumento2.get_TipoEndosso().HasValue && selectedDocumento2.get_TipoEndosso().GetValueOrDefault() == 4 && this.SelectedDocumento.get_Vigencia2().HasValue)
- {
- ApoliceServico servico = this.Servico;
- long num = this.SelectedDocumento.get_Controle().get_Id();
- DateTime? vigencia2 = this.SelectedDocumento.get_Vigencia2();
- if (!await servico.Prorrogar(num, vigencia2.Value))
- {
- await base.ShowMessage("NÃO FOI POSSÍVEL ALTERAR A VIGÊNCIA FINAL DA APÓLICE, POR FAVOR VERIFIQUE APÓS O PROCEDIMENTO SER CONCLUÍDO.", "OK", "", false);
- }
- }
- if (selectedDocumento2.get_TipoEndosso().HasValue && selectedDocumento2.get_TipoEndosso().GetValueOrDefault() == 3)
- {
- if (!await this.Servico.Reabilitar(this.SelectedDocumento.get_Controle().get_Id()))
- {
- await base.ShowMessage("NÃO FOI POSSÍVEL ALTERAR O STATUS DA APÓLICE, POR FAVOR VERIFIQUE APÓS O PROCEDIMENTO SER CONCLUÍDO.", "OK", "", false);
- }
- }
- if (selectedDocumento2.get_TipoEndosso().HasValue && selectedDocumento2.get_TipoEndosso().GetValueOrDefault() == 2)
- {
- IList<Documento> documentos5 = this.CancelDocumento.get_Controle().get_Documentos();
- Documento documento6 = documentos5.FirstOrDefault<Documento>((Documento x) => x.get_Tipo() == 0);
- documento6.set_Situacao(3);
- IList<Documento> documentos6 = this.CancelDocumento.get_Controle().get_Documentos();
- IEnumerable<Documento> tipo1 =
- from x in documentos6
- where x.get_Tipo() == 1
- select x;
- foreach (Documento documento7 in tipo1)
- {
- documento7.set_Situacao(3);
- await this.Servico.Save(documento7, false, false);
- }
- nullable = documento6.get_NegocioCorretora();
- if (!nullable.HasValue)
- {
- Documento documento8 = documento6;
- negocioCorretora1 = (!documento6.get_Negocio().HasValue || documento6.get_Negocio().GetValueOrDefault() != 1 ? 0 : 1);
- documento8.set_NegocioCorretora(new NegocioCorretora?(negocioCorretora1));
- }
- selectedDocumento2.set_Situacao(3);
- this.Servico.Sucesso = true;
- await this.Servico.Save(documento6, false, false);
- if (!this.Servico.Sucesso)
- {
- await base.ShowMessage("NÃO FOI POSSÍVEL ALTERAR O STATUS DO DOCUMENTO CANCELADO, POR FAVOR VERIFIQUE APÓS O PROCEDIMENTO SER CONCLUÍDO.", "OK", "", false);
- }
- tipo = id1;
- if (tipo)
- {
- tipo = await base.ShowMessage("DESEJA BAIXAR AS PARCELAS PENDENTES ABAIXO DESSE DOCUMENTO?", "SIM", "NÃO", false);
- }
- if (tipo)
- {
- bool flag8 = true;
- foreach (Documento documento9 in documento6.get_Controle().get_Documentos())
- {
- tipo = await this.Servico.BaixarParcelasCancelamento(documento9, false);
- flag8 = tipo & flag8;
- }
- if (!flag8)
- {
- await base.ShowMessage("NÃO FOI POSSÍVEL AS PARCELAS DO DOCUMENTO CANCELADO, POR FAVOR VERIFIQUE APÓS O PROCEDIMENTO SER CONCLUÍDO.", "OK", "", false);
- }
- }
- string str4 = string.Concat("A APÓLICE \"", documento6.get_Apolice(), "\"");
- base.RegistrarAcao(string.Concat("CANCELOU ", str4), documento6.get_Id(), new TipoTela?(2), this.GerarObs(documento6));
- documento6 = null;
- }
- if (this.Parcelas != null)
- {
- Documento documento10 = selectedDocumento2;
- ObservableCollection<Parcela> parcelas = this.Parcelas;
- documento10.set_Parcelas(new ObservableCollection<Parcela>(
- from x in parcelas
- where x.get_SubTipo() == 1
- select x));
- }
- if (!string.IsNullOrWhiteSpace(this.Anotacoes))
- {
- Documento documento11 = selectedDocumento2;
- object[] nome = new object[] { Recursos.Usuario.get_Nome(), Recursos.Usuario.get_Id(), Funcoes.GetNetworkTime(), Environment.NewLine, this.Anotacoes, Environment.NewLine, Environment.NewLine, selectedDocumento2.get_Observacao() };
- documento11.set_Observacao(string.Format("{0}, ID: {1}, {2:g}{3}{4}{5}{6}{7}", nome));
- }
- Documento documentoSelecionado = this.DocumentoSelecionado;
- if (documentoSelecionado != null)
- {
- documentoSelecionado.get_Situacao();
- flag3 = true;
- }
- else
- {
- flag3 = false;
- }
- if (flag3 && this.DocumentoSelecionado.get_Situacao() == 7 && this.DocumentoSelecionado.get_Situacao() != selectedDocumento2.get_Situacao())
- {
- ObservableCollection<Parcela> observableCollection = selectedDocumento2.get_Parcelas();
- if (observableCollection != null)
- {
- flag5 = (
- from x in observableCollection
- where x.get_DataRecebimento().HasValue
- select x).Count<Parcela>() >= 1;
- }
- else
- {
- flag5 = false;
- }
- if (flag5)
- {
- await base.ShowMessage("O DOCUMENTO TEM PARCELAS BAIXADAS DEVIDO A RECUSA. CASO NECESSÁRIO, REALIZE A EXCLUSÃO DAS BAIXAS MANUALMENTE.", "OK", "", false);
- base.Alterar(true);
- list = null;
- return list;
- }
- }
- this.Servico.Sucesso = true;
- if (selectedDocumento2.get_Id() == 0)
- {
- selectedDocumento2.set_DataCriacao(new DateTime?(Funcoes.GetNetworkTime()));
- selectedDocumento2.set_UsuarioCriacao(Recursos.Usuario);
- }
- selectedDocumento2.set_SituacaoAnterior(new TipoSeguro?(selectedDocumento2.get_Situacao()));
- Documento documento12 = await this.Servico.Save(selectedDocumento2, flag6, flag7);
- Documento documento13 = documento12;
- ObservableCollection<VendedorParcela> pagamentos = this.Pagamentos;
- if (pagamentos != null)
- {
- vendedorParcelas = pagamentos.Where<VendedorParcela>((VendedorParcela p) => {
- if (documento13.get_TipoRecebimento().GetValueOrDefault() != 1 || p.get_Repasse() == null || p.get_Repasse().get_Base().GetValueOrDefault() != 1 && p.get_Repasse().get_Base().GetValueOrDefault() != 4 && p.get_Repasse().get_Base().GetValueOrDefault() != 5)
- {
- return false;
- }
- return !p.get_DataPagamento().HasValue;
- }).ToList<VendedorParcela>();
- }
- else
- {
- vendedorParcelas = null;
- }
- List<VendedorParcela> vendedorParcelas1 = vendedorParcelas;
- if (vendedorParcelas1 != null && vendedorParcelas1.Count > 0)
- {
- List<VendedorParcela> vendedorParcelas2 = new List<VendedorParcela>();
- if (vendedorParcelas1 != null)
- {
- vendedorParcelas1.ForEach((VendedorParcela p) => {
- DateTime? dataPrePagamento;
- DateTime? emissao;
- BaseRepasse? @base = p.get_Repasse().get_Base();
- if (@base.HasValue)
- {
- switch (@base.GetValueOrDefault())
- {
- case 1:
- {
- dataPrePagamento = p.get_DataPrePagamento();
- DateTime vigencia1 = documento13.get_Vigencia1();
- if ((dataPrePagamento.HasValue ? dataPrePagamento.GetValueOrDefault() == vigencia1 : false))
- {
- return;
- }
- p.set_DataPrePagamento(new DateTime?(documento13.get_Vigencia1()));
- vendedorParcelas2.Add(p);
- return;
- }
- case 2:
- case 3:
- {
- break;
- }
- case 4:
- {
- dataPrePagamento = p.get_DataPrePagamento();
- emissao = documento13.get_Emissao();
- if ((dataPrePagamento.HasValue == emissao.HasValue ? (dataPrePagamento.HasValue ? dataPrePagamento.GetValueOrDefault() == emissao.GetValueOrDefault() : true) : false))
- {
- return;
- }
- p.set_DataPrePagamento(documento13.get_Emissao());
- vendedorParcelas2.Add(p);
- return;
- }
- case 5:
- {
- emissao = p.get_DataPrePagamento();
- dataPrePagamento = documento13.get_Remessa();
- if ((emissao.HasValue == dataPrePagamento.HasValue ? (emissao.HasValue ? emissao.GetValueOrDefault() == dataPrePagamento.GetValueOrDefault() : true) : false))
- {
- return;
- }
- p.set_DataPrePagamento(documento13.get_Remessa());
- vendedorParcelas2.Add(p);
- break;
- }
- default:
- {
- return;
- }
- }
- }
- });
- }
- if (vendedorParcelas2.Count > 0)
- {
- await (new Gestor.Application.Servicos.ParcelaServico()).SaveRange(vendedorParcelas2.ToList<VendedorParcela>());
- }
- }
- if (this.Servico.Sucesso)
- {
- Documento documentoSelecionado1 = this.DocumentoSelecionado;
- if (documentoSelecionado1 != null)
- {
- documentoSelecionado1.get_Situacao();
- flag4 = true;
- }
- else
- {
- flag4 = false;
- }
- if (flag4 && this.DocumentoSelecionado.get_Situacao() == 7 && selectedDocumento2.get_Situacao() != this.DocumentoSelecionado.get_Situacao())
- {
- Action<TipoTela, string> acessaTela = Gestor.Application.Actions.Actions.AcessaTela;
- if (acessaTela != null)
- {
- acessaTela(21, "");
- }
- else
- {
- }
- }
- this.SelectedDocumento = await this.Servico.BuscarApoliceAsync(documento13.get_Id(), false, false);
- this.SelectedDocumento.Initialize();
- await this.CarregarParcelas(this.SelectedDocumento);
- await this.CarregaRepasse(this.SelectedDocumento.get_Id());
- this.SelectedParcela = this.Parcelas.FirstOrDefault<Parcela>();
- Documento selectedDocumento3 = this.SelectedDocumento;
- List<VendedorParcela> repasses = this.Repasses;
- VendedorParcela vendedorParcela1 = repasses.FirstOrDefault<VendedorParcela>((VendedorParcela x) => x.get_TipoVendedor().get_Id() == (long)1);
- if (vendedorParcela1 != null)
- {
- vendedor1 = vendedorParcela1.get_Vendedor();
- }
- else
- {
- vendedor1 = null;
- }
- selectedDocumento3.set_VendedorPrincipal(vendedor1);
- bool renovar = this.Renovar;
- documento = (renovar ? this.DocumentoRenovado : ConsultaViewModel.DocumentoSelecionado);
- ConsultaViewModel.DocumentoRenovado = documento;
- this.NovaApolice = false;
- this.Renovar = false;
- if (id1)
- {
- this.AllowEditApolice = true;
- base.IsEnabledEdit = true;
- base.IsEnabledEditEndosso = true;
- if (this.Invoke)
- {
- ConsultaViewModel.DocumentoSelecionado = this.SelectedDocumento;
- }
- if (this.Invoke)
- {
- Action<Documento> recarregarDocumentos = Gestor.Application.Actions.Actions.RecarregarDocumentos;
- if (recarregarDocumentos != null)
- {
- recarregarDocumentos(this.SelectedDocumento);
- }
- else
- {
- }
- }
- if (this.Invoke)
- {
- Action<Documento> updateDocumento = Gestor.Application.Actions.Actions.UpdateDocumento;
- if (updateDocumento != null)
- {
- updateDocumento(this.SelectedDocumento);
- }
- else
- {
- }
- }
- }
- else if (this.Invoke)
- {
- long num1 = this.SelectedDocumento.get_Id();
- Documento documentoSelecionado2 = ConsultaViewModel.DocumentoSelecionado;
- if (documentoSelecionado2 != null)
- {
- nullable1 = new long?(documentoSelecionado2.get_Id());
- }
- else
- {
- nullable1 = null;
- }
- long? nullable2 = nullable1;
- if (num1 != nullable2.GetValueOrDefault() | !nullable2.HasValue)
- {
- ConsultaViewModel.DocumentoSelecionado = this.SelectedDocumento;
- }
- }
- if (this.Parcelas.Count == 0)
- {
- this.AllowEditVendedor = false;
- }
- base.AllowEditParcela = true;
- base.ToggleSnackBar("DOCUMENTO SALVO COM SUCESSO", true);
- Action<bool> enableMainMenu = Gestor.Application.Actions.Actions.EnableMainMenu;
- if (enableMainMenu != null)
- {
- enableMainMenu(true);
- }
- else
- {
- }
- Action<bool> enableMenu = Gestor.Application.Actions.Actions.EnableMenu;
- if (enableMenu != null)
- {
- enableMenu(true);
- }
- else
- {
- }
- if (renovar)
- {
- if (await base.ShowMessage("DESEJA MANTER OS DADOS DO PERFIL DA APÓLICE ANTERIOR?", "SIM", "NÃO", false))
- {
- List<Perfil> perfils = await this.PerfilServico.BuscarPerfis(this.CancelDocumento.get_Controle().get_Id());
- int num2 = 0;
- try
- {
- foreach (Perfil perfil in perfils.ToList<Perfil>())
- {
- Perfil perfil1 = new Perfil();
- perfil1.set_Id((long)0);
- perfil1.set_AntiFurto(perfil.get_AntiFurto());
- perfil1.set_CepCirculacao(Gestor.Model.Helper.ValidationHelper.FormataCep(perfil.get_CepCirculacao()));
- perfil1.set_CepPernoite(Gestor.Model.Helper.ValidationHelper.FormataCep(perfil.get_CepPernoite()));
- perfil1.set_Cliente(perfil.get_Cliente());
- Controle controle = new Controle();
- controle.set_AssistenciaId(perfil.get_Controle().get_AssistenciaId());
- controle.set_Cliente(perfil.get_Controle().get_Cliente());
- controle.set_Documentos(perfil.get_Controle().get_Documentos());
- controle.set_Id(this.SelectedDocumento.get_Controle().get_Id());
- controle.set_IdEmpresa(perfil.get_Controle().get_IdEmpresa());
- controle.set_Item(perfil.get_Controle().get_Item());
- controle.set_Produto(perfil.get_Controle().get_Produto());
- controle.set_Ramo(perfil.get_Controle().get_Ramo());
- controle.set_Seguradora(perfil.get_Controle().get_Seguradora());
- controle.set_SeguradoraAnterior(perfil.get_Controle().get_SeguradoraAnterior());
- perfil1.set_Controle(controle);
- perfil1.set_Cpf(perfil.get_Cpf());
- perfil1.set_DistanciaResidenciaTrabalho(perfil.get_DistanciaResidenciaTrabalho());
- perfil1.set_EstadoCivil(perfil.get_EstadoCivil());
- perfil1.set_EstenderCobertura(perfil.get_EstenderCobertura());
- perfil1.set_GaragemEstudo(perfil.get_GaragemEstudo());
- perfil1.set_GaragemResidencia(perfil.get_GaragemResidencia());
- perfil1.set_GaragemTrabalho(perfil.get_GaragemTrabalho());
- perfil1.set_Habilitacao(perfil.get_Habilitacao());
- perfil1.set_Isencao(perfil.get_Isencao());
- perfil1.set_KmMensal(perfil.get_KmMensal());
- perfil1.set_Nascimento(perfil.get_Nascimento());
- perfil1.set_Nome(perfil.get_Nome());
- perfil1.set_Ocupacao(perfil.get_Ocupacao());
- perfil1.set_Relacao(perfil.get_Relacao());
- perfil1.set_SeguroVida(perfil.get_SeguroVida());
- perfil1.set_Sexo(perfil.get_Sexo());
- perfil1.set_TempoHabilitacao(perfil.get_TempoHabilitacao());
- perfil1.set_TipoResidencia(perfil.get_TipoResidencia());
- perfil1.set_UsoDependentes(perfil.get_UsoDependentes());
- perfil1.set_UsoProfissional(perfil.get_UsoProfissional());
- perfil1.set_VeiculoResidencia(perfil.get_VeiculoResidencia());
- await this.PerfilServico.Save(perfil1);
- }
- }
- catch (Exception exception)
- {
- obj = exception;
- num2 = 1;
- }
- if (num2 == 1)
- {
- Exception exception1 = (Exception)obj;
- await base.ShowMessage("NÃO FOI POSSÍVEL MANTER OS DADOS DO PERFIL DA APÓLICE ANTERIOR, POR FAVOR VERIFIQUE APÓS O PROCEDIMENTO SER CONCLUÍDO.", "OK", "", false);
- }
- obj = null;
- }
- }
- this.CancelDocumento = (Documento)this.SelectedDocumento.Clone();
- BaseApoliceViewModel baseApoliceViewModel = this;
- str = (this.SelectedDocumento.get_TipoRecebimento().GetValueOrDefault() == 2 ? "EDITAR FATURAS" : "EDITAR PARCELAS");
- baseApoliceViewModel.EditarParcelasLabel = str;
- base.EnableFields = false;
- this.CalculaComissao(this.SelectedDocumento, this.Parcelas);
- string str5 = (id1 ? "INCLUIU" : "ALTEROU");
- if (this.SelectedDocumento.get_Tipo() == 0 && string.IsNullOrEmpty(this.SelectedDocumento.get_Apolice()))
- {
- str1 = string.Concat("A PROPOSTA \"", this.SelectedDocumento.get_Proposta(), "\"");
- }
- else if (this.SelectedDocumento.get_Tipo() != 0 || string.IsNullOrEmpty(this.SelectedDocumento.get_Apolice()))
- {
- str1 = (string.IsNullOrEmpty(this.SelectedDocumento.get_Endosso()) ? string.Concat("A PROPOSTA DE ENDOSSO \"", this.SelectedDocumento.get_PropostaEndosso(), "\"") : string.Concat("O ENDOSSO \"", this.SelectedDocumento.get_Endosso(), "\""));
- }
- else
- {
- str1 = string.Concat("A APÓLICE \"", this.SelectedDocumento.get_Apolice(), "\"");
- }
- string str6 = str1;
- base.RegistrarAcao(string.Concat(str5, " ", str6), this.SelectedDocumento.get_Id(), new TipoTela?(2), this.GerarObs(this.SelectedDocumento));
- if (renovar)
- {
- valueOrDefault = true;
- }
- else if (!this.IsEndosso)
- {
- valueOrDefault = false;
- }
- else
- {
- TipoEndosso? tipoEndosso = this.SelectedDocumento.get_TipoEndosso();
- valueOrDefault = tipoEndosso.GetValueOrDefault() != 2;
- }
- if (valueOrDefault & id1)
- {
- Action<TipoTela, string> action = Gestor.Application.Actions.Actions.AcessaTela;
- if (action != null)
- {
- action(3, (renovar ? "Renovação" : "Endosso"));
- }
- else
- {
- }
- list = null;
- }
- else if (this.SelectedDocumento.get_TipoEndosso().GetValueOrDefault() != 2)
- {
- tipo = (!this.Invoke ? true : !id1);
- if (!tipo)
- {
- tipo = !await base.ShowMessage("DESEJA INCLUIR O ITEM AGORA?", "SIM", "NÃO", false);
- }
- if (!tipo)
- {
- Action<TipoTela, string> acessaTela1 = Gestor.Application.Actions.Actions.AcessaTela;
- if (acessaTela1 != null)
- {
- acessaTela1(3, "");
- }
- else
- {
- }
- list = null;
- }
- else
- {
- list = null;
- }
- }
- else
- {
- list = null;
- }
- }
- else
- {
- base.Alterar(true);
- list = null;
- }
- }
- else
- {
- await base.ShowMessage("EM DOCUMENTOS CANCELADOS SÓ É POSSIVEL INCLUIR ENDOSSO DE REABILITAÇÃO.", "OK", "", false);
- base.Alterar(true);
- list = null;
- }
- }
- else
- {
- list = keyValuePairs1;
- }
- return list;
- }
-
- public async Task<List<KeyValuePair<string, string>>> SalvarParcelas(int tipo)
- {
- List<KeyValuePair<string, string>> keyValuePairs;
- decimal num;
- int num1;
- bool flag;
- if (this.SelectedParcela.get_Documento() == null)
- {
- this.SelectedParcela.set_Documento(this.SelectedDocumento);
- }
- this.SelectedParcela.get_Documento().set_Parcelas(this.Parcelas);
- if (this.SelectedDocumento.get_TipoRecebimento().GetValueOrDefault() == 1 && this.SelectedParcela.get_SubTipo() == 1 && this.SelectedParcela.get_Comissao() == decimal.Zero)
- {
- this.SelectedParcela.set_Comissao(this.SelectedDocumento.get_Comissao());
- }
- Parcela selectedParcela = this.SelectedParcela;
- List<ConfiguracaoSistema> configuracoes = Recursos.Configuracoes;
- bool flag1 = configuracoes.Any<ConfiguracaoSistema>((ConfiguracaoSistema x) => x.get_Configuracao() == 9);
- List<ConfiguracaoSistema> configuracaoSistemas = Recursos.Configuracoes;
- bool flag2 = configuracaoSistemas.Any<ConfiguracaoSistema>((ConfiguracaoSistema y) => y.get_Configuracao() == 11);
- bool editandoParcela = this.EditandoParcela;
- List<ConfiguracaoSistema> configuracoes1 = Recursos.Configuracoes;
- List<KeyValuePair<string, string>> keyValuePairs1 = selectedParcela.Validate(flag1, flag2, editandoParcela, configuracoes1.Any<ConfiguracaoSistema>((ConfiguracaoSistema x) => x.get_Configuracao() == 16));
- keyValuePairs1.AddRange(this.ValidaParcelaEspecial(tipo));
- num = (this.SelectedParcela.get_ValorExtrato() == decimal.Zero ? this.SelectedParcela.get_ValorLiquidoFatura() : this.SelectedParcela.get_ValorExtrato());
- decimal num2 = num;
- num1 = (num2 > decimal.Zero ? num2.CompareTo(this.SelectedParcela.get_ValorComissao()) : this.SelectedParcela.get_ValorComissao().CompareTo(num2));
- int num3 = num1;
- flag = (keyValuePairs1.Count != 1 || 2 != this.SelectedDocumento.get_TipoRecebimento().GetValueOrDefault() ? false : num3 < 0);
- bool flag3 = flag;
- if (flag3)
- {
- flag3 = await base.ShowMessage("VALOR RECEBIMENTO MAIOR QUE VALOR PARCELA, CONTINUAR?", "SIM", "NÃO", false);
- }
- if (flag3)
- {
- keyValuePairs1.Clear();
- }
- if (keyValuePairs1.Count <= 0)
- {
- this.SelectedParcela.set_Baixando(false);
- List<ConfiguracaoSistema> configuracaoSistemas1 = Recursos.Configuracoes;
- if (!configuracaoSistemas1.Any<ConfiguracaoSistema>((ConfiguracaoSistema x) => x.get_Configuracao() == 5) && (this.SelectedParcela.get_Iss() > decimal.Zero || this.SelectedParcela.get_Irr() > decimal.Zero || this.SelectedParcela.get_Outros() > decimal.Zero || this.SelectedParcela.get_Desconto() > decimal.Zero))
- {
- this.SelectedParcela.set_Iss(decimal.Zero);
- this.SelectedParcela.set_Irr(decimal.Zero);
- this.SelectedParcela.set_Outros(decimal.Zero);
- this.SelectedParcela.set_Desconto(decimal.Zero);
- this.SelectedParcela.set_ValorComDesconto(this.SelectedParcela.get_ValorComissao());
- }
- switch (tipo)
- {
- case 1:
- {
- await this.AlterarVencimento();
- break;
- }
- case 2:
- {
- await this.BaixarComissao();
- break;
- }
- case 3:
- case 4:
- {
- await this.AdicionarParcelaEspecial();
- break;
- }
- }
- keyValuePairs = null;
- }
- else
- {
- keyValuePairs = keyValuePairs1;
- }
- keyValuePairs1 = null;
- return keyValuePairs;
- }
-
- public async void Seleciona(Documento documento)
- {
- base.Loading(true);
- await base.PermissaoTela(2);
- await base.PermissaoTela(5);
- if (documento == null || (object)documento != (object)this.SelectedDocumento)
- {
- await this.SelecionaDocumento(documento);
- }
- Action<bool> redimencionar = Gestor.Application.Actions.Actions.Redimencionar;
- if (redimencionar != null)
- {
- redimencionar(this.Invoke);
- }
- else
- {
- }
- base.Loading(false);
- }
-
- public async Task SelecionaDocumento(Documento documento)
- {
- long? nullable;
- base.Loading(true);
- base.IsEnabled = false;
- await this.BuscarVendedores(false);
- List<Estipulante> estipulantes = await (new BaseServico()).BuscarEstipulantes();
- BaseApoliceViewModel list = this;
- IEnumerable<Estipulante> estipulantes1 = estipulantes.Where<Estipulante>((Estipulante x) => {
- if (documento == null)
- {
- return x.get_IdEmpresa() == Recursos.Usuario.get_IdEmpresa();
- }
- if (x.get_IdEmpresa() != documento.get_Controle().get_IdEmpresa())
- {
- return false;
- }
- return x.get_Ativo();
- });
- list.Estipulantes = (
- from x in estipulantes1
- orderby x.get_Nome()
- select x).ToList<Estipulante>();
- this.SelectedDocumento = null;
- this.PreLoad();
- if (documento != null)
- {
- await this.WorkOnSelectedDocumento(documento);
- if (this.Invoke)
- {
- long id = this.SelectedDocumento.get_Id();
- Documento documentoSelecionado = ConsultaViewModel.DocumentoSelecionado;
- if (documentoSelecionado != null)
- {
- nullable = new long?(documentoSelecionado.get_Id());
- }
- else
- {
- nullable = null;
- }
- long? nullable1 = nullable;
- if (id != nullable1.GetValueOrDefault() | !nullable1.HasValue)
- {
- ConsultaViewModel.DocumentoSelecionado = this.SelectedDocumento;
- }
- }
- if (this.Acesso == 1 && this.ParcelaSelecionada != 0)
- {
- await this.SelecionaParcela(this.Parcelas.FirstOrDefault<Parcela>((Parcela x) => x.get_Id() == this.ParcelaSelecionada));
- }
- if (this.Invoke)
- {
- this.Loaded = true;
- }
- base.IsEnabled = true;
- base.Loading(false);
- }
- else
- {
- base.EnableFields = false;
- base.Loading(false);
- }
- }
-
- public async Task SelecionaParcela(Parcela parcela)
- {
- bool flag;
- bool flag1;
- this.SelectedParcela = parcela;
- if (parcela != null && parcela.get_Id() != 0 && this.SelectedDocumento != null)
- {
- if (this.Repasses == null)
- {
- await this.CarregaRepasse(this.SelectedDocumento.get_Id());
- }
- List<VendedorParcela> list = (
- from x in this.Repasses
- where x.get_Parcela().get_Id() == parcela.get_Id()
- select x).ToList<VendedorParcela>();
- if (this.IsFatura || parcela.get_SubTipo() != 1)
- {
- BaseApoliceViewModel baseApoliceViewModel = this;
- flag = (parcela.get_DataRecebimento().HasValue ? false : list.All<VendedorParcela>((VendedorParcela x) => {
- if (x.get_Parcela().get_Id() != parcela.get_Id())
- {
- return false;
- }
- return !x.get_DataPagamento().HasValue;
- }));
- baseApoliceViewModel.AllowEditVendedor = flag;
- }
- if (!this.IsFatura && parcela.get_SubTipo() == 1)
- {
- BaseApoliceViewModel baseApoliceViewModel1 = this;
- if (parcela.get_NumeroParcela() != 1 || parcela.get_DataRecebimento().HasValue)
- {
- flag1 = false;
- }
- else
- {
- List<VendedorParcela> vendedorParcelas = list;
- flag1 = vendedorParcelas.All<VendedorParcela>((VendedorParcela x) => {
- if (x.get_Parcela().get_SubTipo() != 1)
- {
- return false;
- }
- return !x.get_DataPagamento().HasValue;
- });
- }
- baseApoliceViewModel1.AllowEditVendedor = flag1;
- }
- BaseApoliceViewModel observableCollection = this;
- List<VendedorParcela> vendedorParcelas1 = list;
- observableCollection.Pagamentos = new ObservableCollection<VendedorParcela>(
- from x in vendedorParcelas1
- orderby x.get_TipoVendedor().get_Id()
- select x);
- }
- }
-
- public void SelecionaPrimeiraParcela()
- {
- this.SelectedParcela = this.SelectedParcela ?? this.Parcelas.FirstOrDefault<Parcela>();
- }
-
- public async Task<bool> SelecionarParcelaBaixa()
- {
- bool flag;
- decimal num;
- decimal num1;
- Parcela parcela;
- if (this.SelectedParcela == null || this.SelectedDocumento == null)
- {
- flag = false;
- }
- else if (this.SelectedParcela.get_SubTipo() != 1 && !this.SelectedParcela.get_DataRecebimento().HasValue)
- {
- Parcela selectedParcela = this.SelectedParcela;
- decimal premioLiquido = this.SelectedDocumento.get_PremioLiquido();
- num1 = (this.SelectedDocumento.get_NumeroParcelas() > decimal.Zero ? this.SelectedDocumento.get_NumeroParcelas() : decimal.One);
- selectedParcela.set_ValorLiquidoFatura(premioLiquido / num1);
- this.SelectedParcela.set_Baixando(true);
- flag = true;
- }
- else if (this.IsFatura && !this.SelectedParcela.get_DataRecebimento().HasValue)
- {
- this.SelectedParcela.set_Baixando(true);
- flag = true;
- }
- else if (this.Parcelas == null || !this.Parcelas.Any<Parcela>())
- {
- flag = false;
- }
- else
- {
- ObservableCollection<Parcela> parcelas = this.Parcelas;
- IOrderedEnumerable<Parcela> numeroParcela =
- from x in parcelas
- orderby x.get_NumeroParcela()
- select x;
- parcela = numeroParcela.FirstOrDefault<Parcela>((Parcela x) => {
- if (x.get_DataRecebimento().HasValue)
- {
- return false;
- }
- return x.get_SubTipo() == 1;
- });
- if (parcela != null && !this.IsFatura && this.SelectedDocumento.get_NumeroParcelas() > decimal.Zero)
- {
- Parcela parcela1 = parcela;
- num = (this.SelectedDocumento.get_AdicionalComiss() ? (this.SelectedDocumento.get_PremioLiquido() + this.SelectedDocumento.get_PremioAdicional()) / this.SelectedDocumento.get_NumeroParcelas() : this.SelectedDocumento.get_PremioLiquido() / this.SelectedDocumento.get_NumeroParcelas());
- parcela1.set_ValorLiquidoFatura(num);
- }
- BaseApoliceViewModel baseApoliceViewModel = this;
- Parcela selectedParcela1 = parcela;
- if (selectedParcela1 == null)
- {
- selectedParcela1 = this.SelectedParcela;
- }
- baseApoliceViewModel.SelectedParcela = selectedParcela1;
- if (parcela == null)
- {
- await base.ShowMessage("NÃO HÁ MAIS NENHUMA PARCELA A SER BAIXADA", "OK", "", false);
- }
- if (parcela != null)
- {
- this.SelectedParcela.set_Baixando(true);
- }
- flag = parcela != null;
- }
- parcela = null;
- return flag;
- }
-
- public void SelecionarVendedor()
- {
- VendedorParcela vendedorParcela;
- ObservableCollection<VendedorParcela> pagamentos = this.Pagamentos;
- if (pagamentos != null)
- {
- vendedorParcela = pagamentos.FirstOrDefault<VendedorParcela>();
- }
- else
- {
- vendedorParcela = null;
- }
- this.SelectedPagamento = vendedorParcela;
- }
-
- public void ToggleSeguradoraAnterior(TipoSeguro situacao)
- {
- if (situacao != 2)
- {
- this.IsRenovacaoVisibility = Visibility.Collapsed;
- return;
- }
- this.IsRenovacaoVisibility = Visibility.Visible;
- }
-
- private List<KeyValuePair<string, string>> ValidaParcelaEspecial(int tipo)
- {
- List<KeyValuePair<string, string>> keyValuePairs = new List<KeyValuePair<string, string>>();
- if (tipo == 4 && this.SelectedParcela.get_SubTipo() == 1)
- {
- keyValuePairs.Add(new KeyValuePair<string, string>("SubTipo|TIPO", "A PARCELA ESPECIAL NÃO PODE SER DO TIPO PARCELA NORMAL"));
- }
- return keyValuePairs;
- }
-
- public List<KeyValuePair<string, string>> Validate(VendedorParcela pagamento)
- {
- long? nullable;
- bool count;
- List<KeyValuePair<string, string>> keyValuePairs = new List<KeyValuePair<string, string>>();
- if (pagamento == null || this.SelectedDocumento == null)
- {
- keyValuePairs.Add(new KeyValuePair<string, string>("pagamento|PAGAMENTO", "ERRO AO INSERIR VENDEDOR."));
- return keyValuePairs;
- }
- if (pagamento.get_TipoVendedor() == null || pagamento.get_Vendedor() == null)
- {
- return keyValuePairs;
- }
- if (this.Repasses == null)
- {
- this.Repasses = new List<VendedorParcela>();
- }
- if (this.Repasses.Count > 0)
- {
- if (this.Repasses.All<VendedorParcela>((VendedorParcela x) => x.get_Parcela() == null))
- {
- if (this.SelectedDocumento.get_Id() > (long)0)
- {
- ObservableCollection<Parcela> parcelas = this.Parcelas;
- if (parcelas != null)
- {
- count = parcelas.Count > 0;
- }
- else
- {
- count = false;
- }
- if (count)
- {
- keyValuePairs.Add(new KeyValuePair<string, string>("|PARCELA", "PARCELA DEVE SER SELECIONADA PARA A INCLUSÃO DO VENDEDOR."));
- return keyValuePairs;
- }
- }
- if (this.SelectedDocumento.get_Tipo() != 1)
- {
- goto Label1;
- }
- keyValuePairs.Add(new KeyValuePair<string, string>("|PARCELA", "PARCELA DEVE SER SELECIONADA PARA A INCLUSÃO DO VENDEDOR."));
- return keyValuePairs;
- }
- Label1:
- IEnumerable<VendedorParcela> vendedorParcelas = this.Repasses.Where<VendedorParcela>((VendedorParcela x) => {
- if (x.get_Parcela().get_SubTipo() != 1)
- {
- return false;
- }
- decimal? porcentagemRepasse = x.get_PorcentagemRepasse();
- if ((porcentagemRepasse.GetValueOrDefault() == 100) & porcentagemRepasse.HasValue)
- {
- return false;
- }
- return pagamento.get_Repasse().get_Forma().GetValueOrDefault() == 1;
- });
- decimal num = vendedorParcelas.Sum<VendedorParcela>((VendedorParcela x) => x.get_ValorRepasse().GetValueOrDefault()) + pagamento.get_ValorRepasse().GetValueOrDefault();
- decimal num1 = ((this.SelectedDocumento.get_AdicionalComiss() ? this.SelectedDocumento.get_PremioLiquido() + this.SelectedDocumento.get_PremioAdicional() : this.SelectedDocumento.get_PremioLiquido()) * this.SelectedDocumento.get_Comissao()) * new decimal(1, 0, 0, false, 2);
- if (Recursos.Configuracoes.All<ConfiguracaoSistema>((ConfiguracaoSistema x) => x.get_Configuracao() != 15) && Math.Abs(num) > (Math.Abs(num1) + this.Tolerancia))
- {
- keyValuePairs.Add(new KeyValuePair<string, string>("ValorRepasse|VALOR DO REPASSE", "O TOTAL DE COMISSÃO PAGA NÃO PODE SER SUPERIOR A COMISSÃO PREVISTA PARA RECEBIMENTO."));
- }
- if (this.Repasses.Where<VendedorParcela>((VendedorParcela vendedorParcela) => {
- if (vendedorParcela.get_Repasse() == null)
- {
- return false;
- }
- return vendedorParcela.get_Repasse().get_Tipo().GetValueOrDefault() != 3;
- }).Any<VendedorParcela>((VendedorParcela x) => {
- if (x.get_TipoVendedor().get_Id() != pagamento.get_TipoVendedor().get_Id() || x.get_Vendedor().get_Corretora())
- {
- return false;
- }
- return x.get_Parcela().get_SubTipo() == 1;
- }))
- {
- keyValuePairs.Add(new KeyValuePair<string, string>("TipoVendedor|TIPO VENDEDOR", string.Concat("JÁ EXISTE UM VENDEDOR DO TIPO ", pagamento.get_TipoVendedor().get_Descricao(), " ADICIONADO AO DOCUMENTO.")));
- }
- if (this.Repasses.Any<VendedorParcela>((VendedorParcela x) => {
- if (x.get_Vendedor().get_Id() != pagamento.get_Vendedor().get_Id())
- {
- return false;
- }
- return x.get_Parcela().get_SubTipo() == 1;
- }))
- {
- keyValuePairs.Add(new KeyValuePair<string, string>("Nome|VENDEDOR", string.Concat("VENDEDOR ", pagamento.get_Vendedor().get_Nome(), " JÁ ADICIONADO AO DOCUMENTO.")));
- }
- }
- long id = pagamento.get_Vendedor().get_Id();
- Gestor.Model.Domain.Seguros.Repasse repasse = pagamento.get_Repasse();
- if (repasse != null)
- {
- nullable = new long?(repasse.get_Vendedor().get_Id());
- }
- else
- {
- nullable = null;
- }
- long? nullable1 = nullable;
- if (id != nullable1.GetValueOrDefault() | !nullable1.HasValue)
- {
- keyValuePairs.Add(new KeyValuePair<string, string>("ValorRepasse|VALOR DO REPASSE", "PERCENTUAL DE REPASSE DEVE SER SELECIONADO"));
- }
- return keyValuePairs;
- }
-
- public List<KeyValuePair<string, string>> ValidateEspecial(VendedorParcela pagamento)
- {
- decimal? nullable2;
- List<KeyValuePair<string, string>> keyValuePairs = new List<KeyValuePair<string, string>>();
- if (this.SelectedParcela == null)
- {
- keyValuePairs.Add(new KeyValuePair<string, string>("SelectedParcela|PARCELA", "PARCELA DEVE SER SELECIONADA PARA A INCLUSÃO DO VENDEDOR."));
- return keyValuePairs;
- }
- if (this.Repasses == null)
- {
- this.Repasses = new List<VendedorParcela>();
- }
- decimal? nullable3 = (
- from x in this.Repasses
- where x.get_Parcela().get_Id() == pagamento.get_Parcela().get_Id()
- select x).Sum<VendedorParcela>((VendedorParcela x) => x.get_ValorRepasse());
- decimal? valorRepasse = pagamento.get_ValorRepasse();
- if (nullable3.HasValue & valorRepasse.HasValue)
- {
- nullable2 = new decimal?(nullable3.GetValueOrDefault() + valorRepasse.GetValueOrDefault());
- }
- else
- {
- nullable2 = null;
- }
- decimal? nullable4 = nullable2;
- decimal valor = this.SelectedParcela.get_Valor();
- decimal num = (this.SelectedParcela.get_DataRecebimento().HasValue ? this.SelectedParcela.get_ValorComDesconto() : (valor * this.SelectedParcela.get_Comissao()) * new decimal(1, 0, 0, false, 2));
- if (Recursos.Configuracoes.All<ConfiguracaoSistema>((ConfiguracaoSistema x) => x.get_Configuracao() != 15) && nullable4.HasValue && Math.Abs(nullable4.Value) > (Math.Abs(num) + this.Tolerancia))
- {
- keyValuePairs.Add(new KeyValuePair<string, string>("SelectedParcela|VALOR DO REPASSE", "O TOTAL DE COMISSÃO PAGA NÃO PODE SER SUPERIOR A COMISSÃO PREVISTA PARA RECEBIMENTO."));
- }
- if (pagamento.get_Parcela() == null)
- {
- if (this.Repasses.Any<VendedorParcela>((VendedorParcela x) => {
- if (x.get_TipoVendedor().get_Id() != pagamento.get_TipoVendedor().get_Id())
- {
- return false;
- }
- return !x.get_Vendedor().get_Corretora();
- }))
- {
- keyValuePairs.Add(new KeyValuePair<string, string>("TipoVendedor|TIPO VENDEDOR", string.Concat("JÁ EXISTE UM VENDEDOR DO TIPO ", pagamento.get_TipoVendedor().get_Descricao(), " ADICIONADO AO DOCUMENTO.")));
- }
- if (this.Repasses.Any<VendedorParcela>((VendedorParcela x) => x.get_Vendedor().get_Id() == pagamento.get_Vendedor().get_Id()))
- {
- keyValuePairs.Add(new KeyValuePair<string, string>("Nome|VENDEDOR", string.Concat("VENDEDOR ", pagamento.get_Vendedor().get_Nome(), " JÁ ADICIONADO AO DOCUMENTO")));
- }
- return keyValuePairs;
- }
- if (pagamento.get_Parcela().get_SubTipo() == 1)
- {
- if (this.Repasses.Any<VendedorParcela>((VendedorParcela x) => {
- long? nullable;
- long id = x.get_TipoVendedor().get_Id();
- TipoVendedor tipoVendedor = pagamento.get_TipoVendedor();
- if (tipoVendedor != null)
- {
- nullable = new long?(tipoVendedor.get_Id());
- }
- else
- {
- nullable = null;
- }
- long? nullable1 = nullable;
- if (!(id == nullable1.GetValueOrDefault() & nullable1.HasValue) || x.get_Vendedor().get_Corretora())
- {
- return false;
- }
- return x.get_Parcela().get_Id() == pagamento.get_Parcela().get_Id();
- }))
- {
- keyValuePairs.Add(new KeyValuePair<string, string>("TipoVendedor|TIPO VENDEDOR", string.Concat("JÁ EXISTE UM VENDEDOR DO TIPO ", pagamento.get_TipoVendedor().get_Descricao(), " ADICIONADO AO DOCUMENTO.")));
- }
- if (this.Repasses.Any<VendedorParcela>((VendedorParcela x) => {
- if (x.get_Vendedor().get_Id() != pagamento.get_Vendedor().get_Id())
- {
- return false;
- }
- return x.get_Parcela().get_Id() == pagamento.get_Parcela().get_Id();
- }))
- {
- keyValuePairs.Add(new KeyValuePair<string, string>("Nome|VENDEDOR", string.Concat("VENDEDOR ", pagamento.get_Vendedor().get_Nome(), " JÁ ADICIONADO AO DOCUMENTO")));
- }
- return keyValuePairs;
- }
- if (this.Repasses.Any<VendedorParcela>((VendedorParcela x) => {
- if (x.get_Parcela().get_Id() != pagamento.get_Parcela().get_Id() || x.get_TipoVendedor().get_Id() != pagamento.get_TipoVendedor().get_Id())
- {
- return false;
- }
- return !x.get_Vendedor().get_Corretora();
- }))
- {
- keyValuePairs.Add(new KeyValuePair<string, string>("TipoVendedor|TIPO VENDEDOR", string.Concat("JÁ EXISTE UM VENDEDOR DO TIPO ", pagamento.get_TipoVendedor().get_Descricao(), " ADICIONADO A PARCELA.")));
- }
- if (this.Repasses.Any<VendedorParcela>((VendedorParcela x) => {
- if (x.get_Parcela().get_Id() != pagamento.get_Parcela().get_Id())
- {
- return false;
- }
- return x.get_Vendedor().get_Id() == pagamento.get_Vendedor().get_Id();
- }))
- {
- keyValuePairs.Add(new KeyValuePair<string, string>("Nome|VENDEDOR", string.Concat("VENDEDOR ", pagamento.get_Vendedor().get_Nome(), " JÁ ADICIONADO A PARCELA")));
- }
- return keyValuePairs;
- }
-
- public List<Vendedor> VendedorCoCorretagem(bool coCorretagem = false)
- {
- List<Vendedor> vendedors;
- if (coCorretagem)
- {
- List<Vendedor> list = this.Vendedores.Where<Vendedor>((Vendedor vendedor) => {
- List<Gestor.Model.Domain.Seguros.Repasse> repassesVendedores = this.RepassesVendedores;
- if (repassesVendedores == null)
- {
- return false;
- }
- return repassesVendedores.FindAll((Gestor.Model.Domain.Seguros.Repasse repasse) => repasse.get_Vendedor().get_Id() == vendedor.get_Id()).Any<Gestor.Model.Domain.Seguros.Repasse>((Gestor.Model.Domain.Seguros.Repasse x) => x.get_Tipo().GetValueOrDefault() == 3);
- }).ToList<Vendedor>();
- vendedors = list;
- this.Vendedores = list;
- return vendedors;
- }
- List<Vendedor> list1 = Recursos.Vendedores.Where<Vendedor>((Vendedor vendedor) => {
- if (!vendedor.get_Ativo() || vendedor.get_Corretora())
- {
- return false;
- }
- return vendedor.get_IdEmpresa() == Recursos.Usuario.get_IdEmpresa();
- }).OrderBy<Vendedor, string>((Vendedor v) => v.get_Nome()).ToList<Vendedor>();
- vendedors = list1;
- this.Vendedores = list1;
- return vendedors;
- }
-
- public bool VerificaCoCorretagem()
- {
- List<VendedorParcela> repasses = this.Repasses;
- if (repasses == null)
- {
- return false;
- }
- return repasses.Any<VendedorParcela>((VendedorParcela x) => x.get_CoCorretagem());
- }
-
- public async Task<bool> VerificarVigencia(Documento documento)
- {
- bool flag;
- string str;
- if (documento.get_Vigencia2().HasValue)
- {
- DateTime? vigencia2 = documento.get_Vigencia2();
- TimeSpan timeSpan = DateTime.Parse(vigencia2.ToString()) - documento.get_Vigencia1();
- if (timeSpan.Days > 366)
- {
- str = "VIGÊNCIA FINAL MAIOR QUE 365 DIAS.\nDESEJA CONTINUAR?";
- }
- else
- {
- str = (timeSpan.Days < 365 ? "VIGÊNCIA FINAL MENOR QUE 365 DIAS.\nDESEJA CONTINUAR?" : "");
- }
- string str1 = str;
- if (str1 != "")
- {
- flag = await base.ShowMessage(str1, "SIM", "NÃO", false);
- }
- else
- {
- flag = true;
- }
- }
- else
- {
- flag = true;
- }
- return flag;
- }
-
- private async Task WorkOnSelectedDocumento(Documento value)
- {
- decimal? nullable;
- bool flag;
- bool flag1;
- bool seguradora;
- List<Seguradora> list;
- decimal? tolerancia;
- bool flag2;
- bool flag3;
- bool valueOrDefault;
- string str;
- NegocioCorretora negocioCorretora;
- Documento documento;
- BaseApoliceViewModel baseApoliceViewModel = this;
- flag = (value == null ? true : value.get_Id() == (long)0);
- baseApoliceViewModel.IsEnabledEdit = flag;
- BaseApoliceViewModel baseApoliceViewModel1 = this;
- flag1 = (value == null ? true : value.get_Id() == (long)0);
- baseApoliceViewModel1.IsEnabledEditEndosso = flag1;
- if (value != null && value.get_Id() != 0)
- {
- if (!this.Situacao.All<TipoSeguro>((TipoSeguro x) => x != value.get_Situacao()))
- {
- this.IsEnableSituacao = true;
- }
- else
- {
- List<TipoSeguro> tipoSeguros = new List<TipoSeguro>()
- {
- 1,
- 2,
- 5,
- value.get_Situacao()
- };
- this.Situacao = new ObservableCollection<TipoSeguro>(tipoSeguros);
- }
- Controle controle = value.get_Controle();
- if (controle != null)
- {
- seguradora = controle.get_Seguradora();
- }
- else
- {
- seguradora = false;
- }
- if (seguradora)
- {
- list = Recursos.Seguradoras.Where<Seguradora>((Seguradora x) => {
- if (x.get_Ativo())
- {
- return true;
- }
- return x.get_Id() == value.get_Controle().get_Seguradora().get_Id();
- }).ToList<Seguradora>();
- }
- else
- {
- List<Seguradora> seguradoras = Recursos.Seguradoras;
- list = (
- from x in seguradoras
- where x.get_Ativo()
- select x).ToList<Seguradora>();
- }
- this.Seguradoras = list;
- this.SeguradorasAnteriores = Recursos.Seguradoras;
- this.SelectedDocumento = await this.Servico.BuscarApoliceAsync(value.get_Id(), false, false);
- if (!this.SelectedDocumento.get_NegocioCorretora().HasValue)
- {
- Documento selectedDocumento = this.SelectedDocumento;
- negocioCorretora = (this.SelectedDocumento.get_Situacao() != 2 || !this.SelectedDocumento.get_Negocio().HasValue || this.SelectedDocumento.get_Negocio().GetValueOrDefault() != 1 ? 0 : 1);
- selectedDocumento.set_NegocioCorretora(new NegocioCorretora?(negocioCorretora));
- base.OnPropertyChanged("SelectedDocumento");
- }
- BaseApoliceViewModel valueOrDefault1 = this;
- Controle controle1 = this.SelectedDocumento.get_Controle();
- if (controle1 != null)
- {
- Seguradora seguradora1 = controle1.get_Seguradora();
- if (seguradora1 != null)
- {
- tolerancia = seguradora1.get_Tolerancia();
- }
- else
- {
- nullable = null;
- tolerancia = nullable;
- }
- }
- else
- {
- nullable = null;
- tolerancia = nullable;
- }
- nullable = tolerancia;
- valueOrDefault1.Tolerancia = nullable.GetValueOrDefault(new decimal(2));
- List<Produto> produtos = Recursos.Produtos.Where<Produto>((Produto x) => {
- if (x.get_Ativo())
- {
- return true;
- }
- if (this.SelectedDocumento.get_Controle().get_Produto() == null)
- {
- return false;
- }
- return x.get_Id() == this.SelectedDocumento.get_Controle().get_Produto().get_Id();
- }).ToList<Produto>();
- this.Produtos = produtos;
- if (this.Invoke)
- {
- ConsultaViewModel.DocumentoSelecionado = this.SelectedDocumento;
- }
- documento = (Documento)this.SelectedDocumento.Clone();
- await this.CarregarParcelas(documento);
- await this.CarregaRepasse(documento.get_Id());
- this.SelectedDocumento.Initialize();
- this.Initialized = true;
- if (this.Parcelas.Count == 0)
- {
- this.AllowEditVendedor = false;
- }
- BaseApoliceViewModel baseApoliceViewModel2 = this;
- ObservableCollection<Parcela> parcelas = this.Parcelas;
- IEnumerable<Parcela> subTipo =
- from x in parcelas
- where x.get_SubTipo() == 1
- select x;
- if (!subTipo.All<Parcela>((Parcela x) => !x.get_DataRecebimento().HasValue))
- {
- flag2 = false;
- }
- else
- {
- List<VendedorParcela> repasses = this.Repasses;
- IEnumerable<VendedorParcela> vendedorParcelas =
- from x in repasses
- where x.get_Parcela().get_SubTipo() == 1
- select x;
- flag2 = vendedorParcelas.All<VendedorParcela>((VendedorParcela x) => !x.get_DataPagamento().HasValue);
- }
- baseApoliceViewModel2.AllowEditApolice = flag2;
- BaseApoliceViewModel baseApoliceViewModel3 = this;
- if (this.SelectedDocumento.get_TipoRecebimento().GetValueOrDefault() == 2)
- {
- flag3 = true;
- }
- else
- {
- List<VendedorParcela> repasses1 = this.Repasses;
- IEnumerable<VendedorParcela> vendedorParcelas1 = repasses1.Where<VendedorParcela>((VendedorParcela x) => {
- if (x.get_Repasse() == null)
- {
- return false;
- }
- return x.get_Repasse().get_Base().GetValueOrDefault() == 4;
- });
- flag3 = vendedorParcelas1.All<VendedorParcela>((VendedorParcela x) => !x.get_DataPagamento().HasValue);
- }
- baseApoliceViewModel3.AllowEditEmissao = flag3;
- this.CalculaComissao(this.SelectedDocumento, this.Parcelas);
- this.IsEndosso = this.SelectedDocumento.get_Tipo() != 0;
- BaseApoliceViewModel baseApoliceViewModel4 = this;
- if (!this.SelectedDocumento.get_TipoEndosso().HasValue)
- {
- valueOrDefault = true;
- }
- else if (this.SelectedDocumento.get_TipoEndosso().GetValueOrDefault() == 2)
- {
- valueOrDefault = false;
- }
- else
- {
- TipoEndosso? tipoEndosso = this.SelectedDocumento.get_TipoEndosso();
- valueOrDefault = tipoEndosso.GetValueOrDefault() != 3;
- }
- baseApoliceViewModel4.EnableAlterarSituacao = valueOrDefault;
- BaseApoliceViewModel baseApoliceViewModel5 = this;
- str = (this.SelectedDocumento.get_TipoRecebimento().GetValueOrDefault() == 2 ? "EDITAR FATURAS" : "EDITAR PARCELAS");
- baseApoliceViewModel5.EditarParcelasLabel = str;
- base.AllowEditParcela = true;
- this.CancelDocumento = (Documento)this.SelectedDocumento.Clone();
- }
- documento = null;
- }
-
- private void WorkOnSelectedParcela(Parcela value)
- {
- bool? nullable;
- string str;
- Visibility visibility;
- int? nullable1;
- bool? nullable2;
- if (value == null || value.get_Id() == 0 || this.SelectedDocumento == null)
- {
- return;
- }
- bool flag = this.Repasses.Any<VendedorParcela>((VendedorParcela x) => {
- if (x.get_Parcela().get_Id() != this.SelectedParcela.get_Id())
- {
- return false;
- }
- return x.get_DataPagamento().HasValue;
- });
- if (this.SelectedDocumento.get_TipoRecebimento().GetValueOrDefault() == 2)
- {
- List<VendedorParcela> repasses = this.Repasses;
- if (repasses != null)
- {
- nullable2 = new bool?(repasses.Where<VendedorParcela>((VendedorParcela x) => {
- if (x.get_Parcela().get_Id() != this.SelectedParcela.get_Id() || x.get_Repasse() == null)
- {
- return false;
- }
- return x.get_Repasse().get_Base().GetValueOrDefault() == 4;
- }).All<VendedorParcela>((VendedorParcela x) => !x.get_DataPagamento().HasValue));
- }
- else
- {
- nullable = null;
- nullable2 = nullable;
- }
- nullable = nullable2;
- this.AllowEditEmissao = nullable.Value;
- }
- if (value.get_SubTipo() != 1 || this.SelectedDocumento.get_TipoRecebimento().GetValueOrDefault() != 1)
- {
- this.BaixarParcelaVisibility = (!value.get_DataRecebimento().HasValue ? Visibility.Visible : Visibility.Collapsed);
- this.VisibilityExcluirParcela = (flag ? Visibility.Collapsed : Visibility.Visible);
- if (value.get_DataRecebimento().HasValue)
- {
- str = "EXCLUIR BAIXA";
- }
- else
- {
- str = (this.SelectedDocumento.get_TipoRecebimento().GetValueOrDefault() == 1 ? "EXCLUIR PARCELA" : "EXCLUIR FATURA");
- }
- this.ExcluirParcelaLabel = str;
- }
- else
- {
- this.BaixarParcelaVisibility = (this.Parcelas.Any<Parcela>((Parcela x) => {
- if (x.get_DataRecebimento().HasValue)
- {
- return false;
- }
- return x.get_SubTipo() == 1;
- }) ? Visibility.Visible : Visibility.Collapsed);
- Parcela parcela = (
- from x in this.Parcelas
- orderby x.get_NumeroParcela()
- select x).LastOrDefault<Parcela>((Parcela x) => {
- if (!x.get_DataRecebimento().HasValue || x.get_SubTipo() != 1)
- {
- return false;
- }
- if (x.get_ValorComissao() != decimal.Zero)
- {
- return true;
- }
- return x.get_ValorRealizado() != decimal.Zero;
- });
- if (flag)
- {
- visibility = Visibility.Collapsed;
- }
- else
- {
- if (!value.get_DataRecebimento().HasValue || parcela != null)
- {
- if (parcela != null)
- {
- nullable1 = new int?(parcela.get_NumeroParcela());
- }
- else
- {
- nullable1 = null;
- }
- int? nullable3 = nullable1;
- int numeroParcela = value.get_NumeroParcela();
- if (nullable3.GetValueOrDefault() <= numeroParcela & nullable3.HasValue)
- {
- goto Label1;
- }
- visibility = Visibility.Collapsed;
- goto Label0;
- }
- Label1:
- visibility = Visibility.Visible;
- }
- Label0:
- this.VisibilityExcluirParcela = visibility;
- this.ExcluirParcelaLabel = "EXCLUIR BAIXA";
- }
- this.VisibilityReplicarFatura = (this.IsFatura ? Visibility.Visible : Visibility.Collapsed);
- }
-
- private void WorkOnSelectedTipo(bool value)
- {
- this.Assinada = (value ? "PROPOSTA DE ENDOSSO ASSINADA" : "PROPOSTA ASSINADA");
- this.Conferida = (value ? "ENDOSSO CONFERIDO" : "APÓLICE CONFERIDA");
- this.Transmissao = (value ? "TRANSMISSÃO DA PROPOSTA DE ENDOSSO" : "TRANSMISSÃO DA PROPOSTA");
- this.Emissao = (value ? "EMISSÃO DO ENDOSSO" : "EMISSÃO DA APÓLICE");
- }
-
- private void ZeraComissao()
- {
- this.Gerada = decimal.Zero;
- this.Recebida = decimal.Zero;
- this.Pendente = decimal.Zero;
- this.Repasse = decimal.Zero;
- this.ComissOriginal = decimal.Zero;
- }
-
- private void ZerarValores()
- {
- if (this.SelectedDocumento.get_TipoRecebimento().GetValueOrDefault() != 2)
- {
- return;
- }
- this.SelectedDocumento.set_PremioLiquido(decimal.Zero);
- this.SelectedDocumento.set_PremioAdicional(decimal.Zero);
- this.SelectedDocumento.set_PremioAdicional(decimal.Zero);
- this.SelectedDocumento.set_Iof(decimal.Zero);
- this.SelectedDocumento.set_Diferenca(decimal.Zero);
- this.SelectedDocumento.set_NumeroParcelas(decimal.Zero);
- }
- }
-}
\ No newline at end of file |