summaryrefslogtreecommitdiff
path: root/Decompiler/Gestor.Application.ViewModels.Drawer/ValoresParcelaViewModel.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Decompiler/Gestor.Application.ViewModels.Drawer/ValoresParcelaViewModel.cs')
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Drawer/ValoresParcelaViewModel.cs490
1 files changed, 490 insertions, 0 deletions
diff --git a/Decompiler/Gestor.Application.ViewModels.Drawer/ValoresParcelaViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Drawer/ValoresParcelaViewModel.cs
new file mode 100644
index 0000000..49cbccc
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Drawer/ValoresParcelaViewModel.cs
@@ -0,0 +1,490 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Windows;
+using Gestor.Application.Servicos;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Application.ViewModels.Generic;
+using Gestor.Common.Validation;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Aggilizador;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Seguros;
+
+namespace Gestor.Application.ViewModels.Drawer;
+
+public class ValoresParcelaViewModel : BaseSegurosViewModel
+{
+ private ParcelaPendente _pendecia;
+
+ private Visibility _isVisiblePendencia = (Visibility)2;
+
+ private Visibility _isVisibleFatura;
+
+ private Visibility _isVisibleVendedores;
+
+ private decimal _prevista;
+
+ private decimal _ir;
+
+ private decimal _iss;
+
+ private string _repassePago;
+
+ private decimal _recebidaLiquida;
+
+ private decimal _recebida;
+
+ private decimal _recebidaEspecial;
+
+ private decimal _pendente;
+
+ private decimal _repasse;
+
+ private decimal _repasseEspecial;
+
+ private decimal _paga;
+
+ private decimal _pagaEspecial;
+
+ private string _apoliceLabel = "DESCRIÇÃO DE VALORES";
+
+ private string _apoliceDescricao = "VALORES BASEADOS NO DOCUMENTO SELECIONADO ATÉ O MOMENTO, OS VALORES PODEM SER DIFERENTES EM CASO DE ALTERAÇÕES POR OUTROS USUÁRIOS.";
+
+ private Parcela _selectedParcela;
+
+ private string _statusBaixa;
+
+ private string _statusParc;
+
+ private Visibility _isVisiblestatusparc = (Visibility)2;
+
+ private ObservableCollection<VendedorParcela> _pagamentos;
+
+ public ParcelaPendente Pendecia
+ {
+ get
+ {
+ return _pendecia;
+ }
+ set
+ {
+ _pendecia = value;
+ IsVisiblePendencia = (Visibility)((value == null) ? 2 : 0);
+ OnPropertyChanged("Pendecia");
+ }
+ }
+
+ public Visibility IsVisiblePendencia
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _isVisiblePendencia;
+ }
+ set
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0002: Unknown result type (might be due to invalid IL or missing references)
+ _isVisiblePendencia = value;
+ OnPropertyChanged("IsVisiblePendencia");
+ }
+ }
+
+ public Visibility IsVisibleFatura
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _isVisibleFatura;
+ }
+ set
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0002: Unknown result type (might be due to invalid IL or missing references)
+ _isVisibleFatura = value;
+ OnPropertyChanged("IsVisibleFatura");
+ }
+ }
+
+ public Visibility IsVisibleVendedores
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _isVisibleVendedores;
+ }
+ set
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0002: Unknown result type (might be due to invalid IL or missing references)
+ _isVisibleVendedores = value;
+ OnPropertyChanged("IsVisibleVendedores");
+ }
+ }
+
+ public decimal Prevista
+ {
+ get
+ {
+ return _prevista;
+ }
+ set
+ {
+ _prevista = value;
+ OnPropertyChanged("Prevista");
+ }
+ }
+
+ public decimal Ir
+ {
+ get
+ {
+ return _ir;
+ }
+ set
+ {
+ _ir = value;
+ OnPropertyChanged("Ir");
+ }
+ }
+
+ public decimal Iss
+ {
+ get
+ {
+ return _iss;
+ }
+ set
+ {
+ _iss = value;
+ OnPropertyChanged("Iss");
+ }
+ }
+
+ public string RepassePago
+ {
+ get
+ {
+ return _repassePago;
+ }
+ set
+ {
+ _repassePago = value;
+ OnPropertyChanged("RepassePago");
+ }
+ }
+
+ public decimal RecebidaLiquida
+ {
+ get
+ {
+ return _recebidaLiquida;
+ }
+ set
+ {
+ _recebidaLiquida = value;
+ OnPropertyChanged("RecebidaLiquida");
+ }
+ }
+
+ public decimal Recebida
+ {
+ get
+ {
+ return _recebida;
+ }
+ set
+ {
+ _recebida = value;
+ OnPropertyChanged("Recebida");
+ }
+ }
+
+ public decimal RecebidaEspecial
+ {
+ get
+ {
+ return _recebidaEspecial;
+ }
+ set
+ {
+ _recebidaEspecial = value;
+ OnPropertyChanged("RecebidaEspecial");
+ }
+ }
+
+ public decimal Pendente
+ {
+ get
+ {
+ return _pendente;
+ }
+ set
+ {
+ if (value < 0.01m)
+ {
+ _pendente = default(decimal);
+ }
+ else
+ {
+ _pendente = value;
+ }
+ OnPropertyChanged("Pendente");
+ }
+ }
+
+ public decimal Repasse
+ {
+ get
+ {
+ return _repasse;
+ }
+ set
+ {
+ _repasse = value;
+ OnPropertyChanged("Repasse");
+ }
+ }
+
+ public decimal RepasseEspecial
+ {
+ get
+ {
+ return _repasseEspecial;
+ }
+ set
+ {
+ _repasseEspecial = value;
+ OnPropertyChanged("RepasseEspecial");
+ }
+ }
+
+ public decimal Paga
+ {
+ get
+ {
+ return _paga;
+ }
+ set
+ {
+ _paga = value;
+ OnPropertyChanged("Paga");
+ }
+ }
+
+ public decimal PagaEspecial
+ {
+ get
+ {
+ return _pagaEspecial;
+ }
+ set
+ {
+ _pagaEspecial = value;
+ OnPropertyChanged("PagaEspecial");
+ }
+ }
+
+ public string ApoliceLabel
+ {
+ get
+ {
+ return _apoliceLabel;
+ }
+ set
+ {
+ _apoliceLabel = value;
+ OnPropertyChanged("ApoliceLabel");
+ }
+ }
+
+ public string ApoliceDescricao
+ {
+ get
+ {
+ return _apoliceDescricao;
+ }
+ set
+ {
+ _apoliceDescricao = value;
+ OnPropertyChanged("ApoliceDescricao");
+ }
+ }
+
+ public Parcela SelectedParcela
+ {
+ get
+ {
+ return _selectedParcela;
+ }
+ set
+ {
+ _selectedParcela = value;
+ OnPropertyChanged("SelectedParcela");
+ }
+ }
+
+ public string StatusBaixa
+ {
+ get
+ {
+ return _statusBaixa;
+ }
+ set
+ {
+ _statusBaixa = value;
+ OnPropertyChanged("StatusBaixa");
+ }
+ }
+
+ public string StatusParc
+ {
+ get
+ {
+ return _statusParc;
+ }
+ set
+ {
+ _statusParc = value;
+ OnPropertyChanged("StatusParc");
+ }
+ }
+
+ public Visibility IsVisibleStatusParc
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _isVisiblestatusparc;
+ }
+ set
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0002: Unknown result type (might be due to invalid IL or missing references)
+ _isVisiblestatusparc = value;
+ OnPropertyChanged("IsVisibleStatusParc");
+ }
+ }
+
+ public ObservableCollection<VendedorParcela> Pagamentos
+ {
+ get
+ {
+ return _pagamentos;
+ }
+ set
+ {
+ _pagamentos = value;
+ OnPropertyChanged("Pagamentos");
+ }
+ }
+
+ public ValoresParcelaViewModel(Parcela parcela, Documento documento)
+ {
+ //IL_0002: Unknown result type (might be due to invalid IL or missing references)
+ //IL_001f: Unknown result type (might be due to invalid IL or missing references)
+ Seleciona(parcela, documento);
+ }
+
+ public async void Seleciona(Parcela parcela, Documento documento)
+ {
+ SelectedParcela = parcela;
+ IsVisibleFatura = (Visibility)(((int)SelectedParcela.Documento.TipoRecebimento.GetValueOrDefault() != 2) ? 2 : 0);
+ ApoliceLabel = $"VALORES DA PARCELA {SelectedParcela.NumeroParcela} VENCIMENTO {parcela.Vencimento:d}";
+ ApoliceDescricao = $"VALORES BASEADOS NA PARCELA {SelectedParcela.NumeroParcela} ATÉ O MOMENTO, OS VALORES PODEM SER DIFERENTES EM CASO DE ALTERAÇÕES POR OUTROS USUÁRIOS.";
+ StatusBaixa = "PENDENTE";
+ RepassePago = "REPASSE A SER PAGO";
+ if (SelectedParcela.DataRecebimento.HasValue)
+ {
+ StatusBaixa = (((int)SelectedParcela.Documento.TipoRecebimento.GetValueOrDefault() == 2) ? "BAIXA MANUAL" : ((SelectedParcela.ValorRealizado == 0m) ? "BAIXA ESGOTAMENTO" : "BAIXA MANUAL"));
+ DetalheExtrato val = await new ServicoExtrato().FindByParcelaId(((DomainBase)SelectedParcela).Id);
+ if (val != null)
+ {
+ StatusParcela? status = val.Status;
+ if (status.HasValue)
+ {
+ StatusParcela valueOrDefault = status.GetValueOrDefault();
+ if ((int)valueOrDefault != 1)
+ {
+ if ((int)valueOrDefault == 5)
+ {
+ goto IL_021c;
+ }
+ switch (valueOrDefault - 10)
+ {
+ case 0:
+ case 3:
+ break;
+ case 2:
+ goto IL_021c;
+ default:
+ goto IL_0232;
+ }
+ }
+ IsVisibleStatusParc = (Visibility)0;
+ StatusParc = ValidationHelper.GetDescription((Enum)(object)val.Status);
+ RepassePago = "REPASSE PAGO";
+ StatusBaixa = ((SelectedParcela.ValorRealizado == 0m) ? "BAIXA AUTOMATICA ESGOTAMENTO" : "BAIXA AUTOMATICA");
+ }
+ }
+ }
+ goto IL_0232;
+ IL_021c:
+ RepassePago = "REPASSE PAGO";
+ StatusBaixa = "BAIXA MANUAL";
+ goto IL_0232;
+ IL_0232:
+ CalculaComissao(documento);
+ CalculaRepasse();
+ if (SelectedParcela.IdParcelaPendente > 0 && SelectedParcela.StatusPagamento != (StatusPagamento?)0)
+ {
+ BuscarPendencia();
+ }
+ }
+
+ private async void BuscarPendencia()
+ {
+ Pendecia = await new BaseServico().BuscarParcelaPendente(SelectedParcela.IdParcelaPendente);
+ }
+
+ private void CalculaRepasse()
+ {
+ if (SelectedParcela.Vendedores.All((VendedorParcela x) => x.Vendedor.Corretora))
+ {
+ IsVisibleVendedores = (Visibility)2;
+ return;
+ }
+ List<VendedorParcela> list = (from x in SelectedParcela.Vendedores
+ where !x.Vendedor.Corretora
+ group x by ((DomainBase)x.Vendedor).Id).Select((Func<IGrouping<long, VendedorParcela>, VendedorParcela>)((IGrouping<long, VendedorParcela> x) => new VendedorParcela
+ {
+ Repasse = x.First().Repasse,
+ Documento = SelectedParcela.Documento,
+ ValorTotal = x.First().ValorTotal,
+ Vendedor = x.First().Vendedor,
+ ValorTotalPago = x.Where((VendedorParcela y) => (int)y.Parcela.SubTipo == 1 && y.DataPrePagamento.HasValue).Sum((VendedorParcela y) => y.ValorRepasse),
+ ValorRepasseB = x.Where((VendedorParcela y) => (int)y.Parcela.SubTipo != 1).Sum((VendedorParcela y) => y.ValorRepasse),
+ ValorRepasse = x.Where((VendedorParcela y) => (int)y.Parcela.SubTipo != 1 && y.DataPrePagamento.HasValue).Sum((VendedorParcela y) => y.ValorRepasse),
+ PorcentagemRepasse = x.First().PorcentagemRepasse / (decimal?)100,
+ TipoVendedor = x.First().TipoVendedor
+ })).ToList();
+ Pagamentos = new ObservableCollection<VendedorParcela>(list);
+ }
+
+ private void CalculaComissao(Documento documento)
+ {
+ //IL_0006: Unknown result type (might be due to invalid IL or missing references)
+ //IL_000c: Invalid comparison between Unknown and I4
+ decimal num = (((int)SelectedParcela.SubTipo != 1) ? SelectedParcela.Valor : ((documento.NumeroParcelas == 0m) ? 0m : (documento.AdicionalComiss ? ((documento.PremioLiquido + documento.PremioAdicional) / documento.NumeroParcelas) : (documento.PremioLiquido / documento.NumeroParcelas))));
+ Prevista = ((SelectedParcela.ValorLiquidoFatura != 0m) ? (SelectedParcela.ValorLiquidoFatura * SelectedParcela.Comissao * 0.01m) : (num * SelectedParcela.Comissao * 0.01m));
+ Recebida = SelectedParcela.ValorComissao;
+ Pendente = Prevista - Recebida;
+ Repasse = SelectedParcela.Vendedores.Where((VendedorParcela x) => ((int)SelectedParcela.SubTipo != 1) ? ((int)x.Parcela.SubTipo != 1) : ((int)x.Parcela.SubTipo == 1)).Sum((VendedorParcela x) => x.ValorRepasse.GetValueOrDefault());
+ Paga = SelectedParcela.Vendedores.Where((VendedorParcela x) => ((int)SelectedParcela.SubTipo != 1) ? ((int)x.Parcela.SubTipo != 1 && x.DataPrePagamento.HasValue) : ((int)x.Parcela.SubTipo == 1)).Sum((VendedorParcela x) => x.ValorRepasse.GetValueOrDefault());
+ Ir = SelectedParcela.Irr;
+ Iss = SelectedParcela.Iss;
+ RecebidaLiquida = SelectedParcela.ValorComDesconto;
+ }
+}