diff options
| author | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 13:35:25 +0000 |
|---|---|---|
| committer | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 13:35:25 +0000 |
| commit | 674ca83ba9243a9e95a7568c797668dab6aee26a (patch) | |
| tree | 4a905b3fb1d827665a34d63f67bc5559f8e7235b /Gestor.Application/ViewModels/Drawer/ValoresApoliceViewModel.cs | |
| download | gestor-674ca83ba9243a9e95a7568c797668dab6aee26a.tar.gz gestor-674ca83ba9243a9e95a7568c797668dab6aee26a.zip | |
feat: upload files
Diffstat (limited to 'Gestor.Application/ViewModels/Drawer/ValoresApoliceViewModel.cs')
| -rw-r--r-- | Gestor.Application/ViewModels/Drawer/ValoresApoliceViewModel.cs | 345 |
1 files changed, 345 insertions, 0 deletions
diff --git a/Gestor.Application/ViewModels/Drawer/ValoresApoliceViewModel.cs b/Gestor.Application/ViewModels/Drawer/ValoresApoliceViewModel.cs new file mode 100644 index 0000000..df49b81 --- /dev/null +++ b/Gestor.Application/ViewModels/Drawer/ValoresApoliceViewModel.cs @@ -0,0 +1,345 @@ +using Gestor.Application.ViewModels.Generic;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Seguros;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Runtime.CompilerServices;
+using System.Windows;
+
+namespace Gestor.Application.ViewModels.Drawer
+{
+ public class ValoresApoliceViewModel : BaseSegurosViewModel
+ {
+ private Visibility _isVisibleEspecial;
+
+ private Visibility _isVisibleVendedores;
+
+ private decimal _prevista;
+
+ 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 Documento _selectedDocumento;
+
+ private ObservableCollection<VendedorParcela> _pagamentos;
+
+ public string ApoliceDescricao
+ {
+ get
+ {
+ return this._apoliceDescricao;
+ }
+ set
+ {
+ this._apoliceDescricao = value;
+ base.OnPropertyChanged("ApoliceDescricao");
+ }
+ }
+
+ public string ApoliceLabel
+ {
+ get
+ {
+ return this._apoliceLabel;
+ }
+ set
+ {
+ this._apoliceLabel = value;
+ base.OnPropertyChanged("ApoliceLabel");
+ }
+ }
+
+ public Visibility IsVisibleEspecial
+ {
+ get
+ {
+ return this._isVisibleEspecial;
+ }
+ set
+ {
+ this._isVisibleEspecial = value;
+ base.OnPropertyChanged("IsVisibleEspecial");
+ }
+ }
+
+ public Visibility IsVisibleVendedores
+ {
+ get
+ {
+ return this._isVisibleVendedores;
+ }
+ set
+ {
+ this._isVisibleVendedores = value;
+ base.OnPropertyChanged("IsVisibleVendedores");
+ }
+ }
+
+ public decimal Paga
+ {
+ get
+ {
+ return this._paga;
+ }
+ set
+ {
+ this._paga = value;
+ base.OnPropertyChanged("Paga");
+ }
+ }
+
+ public decimal PagaEspecial
+ {
+ get
+ {
+ return this._pagaEspecial;
+ }
+ set
+ {
+ this._pagaEspecial = value;
+ base.OnPropertyChanged("PagaEspecial");
+ }
+ }
+
+ public ObservableCollection<VendedorParcela> Pagamentos
+ {
+ get
+ {
+ return this._pagamentos;
+ }
+ set
+ {
+ this._pagamentos = value;
+ base.OnPropertyChanged("Pagamentos");
+ }
+ }
+
+ public decimal Pendente
+ {
+ get
+ {
+ return this._pendente;
+ }
+ set
+ {
+ this._pendente = value;
+ base.OnPropertyChanged("Pendente");
+ }
+ }
+
+ public decimal Prevista
+ {
+ get
+ {
+ return this._prevista;
+ }
+ set
+ {
+ this._prevista = value;
+ base.OnPropertyChanged("Prevista");
+ }
+ }
+
+ public decimal Recebida
+ {
+ get
+ {
+ return this._recebida;
+ }
+ set
+ {
+ this._recebida = value;
+ base.OnPropertyChanged("Recebida");
+ }
+ }
+
+ public decimal RecebidaEspecial
+ {
+ get
+ {
+ return this._recebidaEspecial;
+ }
+ set
+ {
+ this._recebidaEspecial = value;
+ base.OnPropertyChanged("RecebidaEspecial");
+ }
+ }
+
+ public decimal Repasse
+ {
+ get
+ {
+ return this._repasse;
+ }
+ set
+ {
+ this._repasse = value;
+ base.OnPropertyChanged("Repasse");
+ }
+ }
+
+ public decimal RepasseEspecial
+ {
+ get
+ {
+ return this._repasseEspecial;
+ }
+ set
+ {
+ this._repasseEspecial = value;
+ base.OnPropertyChanged("RepasseEspecial");
+ }
+ }
+
+ public Documento SelectedDocumento
+ {
+ get
+ {
+ return this._selectedDocumento;
+ }
+ set
+ {
+ this._selectedDocumento = value;
+ base.OnPropertyChanged("SelectedDocumento");
+ }
+ }
+
+ public ValoresApoliceViewModel(Documento documento)
+ {
+ base.EnableMenu = true;
+ this.Seleciona(documento);
+ }
+
+ private void CalculaComissao()
+ {
+ if (this.SelectedDocumento.get_TipoRecebimento().GetValueOrDefault() != 1)
+ {
+ this.Prevista = (
+ from x in this.SelectedDocumento.get_Parcelas()
+ where x.get_SubTipo() == 1
+ select x).Sum<Parcela>((Parcela x) => x.get_ValorLiquidoFatura() * (x.get_Comissao() < decimal.One ? x.get_Comissao() : (x.get_Comissao() > new decimal(100) ? decimal.One : x.get_Comissao() * new decimal(1, 0, 0, false, 2))));
+ }
+ else
+ {
+ decimal num = (this.SelectedDocumento.get_AdicionalComiss() ? this.SelectedDocumento.get_PremioLiquido() + this.SelectedDocumento.get_PremioAdicional() : this.SelectedDocumento.get_PremioLiquido());
+ decimal comissao = this.SelectedDocumento.get_Comissao() * new decimal(1, 0, 0, false, 2);
+ this.Prevista = num * comissao;
+ }
+ this.Recebida = (
+ from x in this.SelectedDocumento.get_Parcelas()
+ where x.get_SubTipo() == 1
+ select x).Sum<Parcela>((Parcela x) => x.get_ValorComissao());
+ this.Pendente = this.Prevista - this.Recebida;
+ this.Repasse = (
+ from x in this.SelectedDocumento.get_Pagamentos()
+ where x.get_Parcela().get_SubTipo() == 1
+ select x).Sum<VendedorParcela>((VendedorParcela x) => x.get_ValorRepasse().GetValueOrDefault());
+ this.Paga = this.SelectedDocumento.get_Pagamentos().Where<VendedorParcela>((VendedorParcela x) => {
+ if (x.get_Parcela().get_SubTipo() != 1)
+ {
+ return false;
+ }
+ return x.get_DataPrePagamento().HasValue;
+ }).Sum<VendedorParcela>((VendedorParcela x) => x.get_ValorRepasse().GetValueOrDefault());
+ }
+
+ private void CalculaEspecial()
+ {
+ if (this.SelectedDocumento.get_Parcelas().All<Parcela>((Parcela x) => x.get_SubTipo() == 1))
+ {
+ this.IsVisibleEspecial = Visibility.Collapsed;
+ return;
+ }
+ this.RecebidaEspecial = (
+ from x in this.SelectedDocumento.get_Parcelas()
+ where x.get_SubTipo() != 1
+ select x).Sum<Parcela>((Parcela x) => x.get_ValorComissao());
+ this.RepasseEspecial = (
+ from x in this.SelectedDocumento.get_Pagamentos()
+ where x.get_Parcela().get_SubTipo() != 1
+ select x).Sum<VendedorParcela>((VendedorParcela x) => x.get_ValorRepasse().GetValueOrDefault());
+ this.PagaEspecial = this.SelectedDocumento.get_Pagamentos().Where<VendedorParcela>((VendedorParcela x) => {
+ if (x.get_Parcela().get_SubTipo() == 1)
+ {
+ return false;
+ }
+ return x.get_DataPrePagamento().HasValue;
+ }).Sum<VendedorParcela>((VendedorParcela x) => x.get_ValorRepasse().GetValueOrDefault());
+ }
+
+ private void CalculaRepasse()
+ {
+ if (this.SelectedDocumento.get_Pagamentos().All<VendedorParcela>((VendedorParcela x) => x.get_Vendedor().get_Corretora()))
+ {
+ this.IsVisibleVendedores = Visibility.Collapsed;
+ return;
+ }
+ List<VendedorParcela> list = (
+ from x in this.SelectedDocumento.get_Pagamentos()
+ where !x.get_Vendedor().get_Corretora()
+ 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_Documento(this.SelectedDocumento);
+ vendedorParcela.set_ValorTotal(x.First<VendedorParcela>().get_ValorTotal());
+ vendedorParcela.set_Vendedor(x.First<VendedorParcela>().get_Vendedor());
+ vendedorParcela.set_ValorTotalPago(x.Where<VendedorParcela>((VendedorParcela y) => {
+ if (y.get_Parcela().get_SubTipo() != 1)
+ {
+ return false;
+ }
+ return y.get_DataPrePagamento().HasValue;
+ }).Sum<VendedorParcela>((VendedorParcela y) => y.get_ValorRepasse()));
+ vendedorParcela.set_ValorRepasseB((
+ from y in x
+ where y.get_Parcela().get_SubTipo() != 1
+ select y).Sum<VendedorParcela>((VendedorParcela y) => y.get_ValorRepasse()));
+ vendedorParcela.set_ValorRepasse(x.Where<VendedorParcela>((VendedorParcela y) => {
+ if (y.get_Parcela().get_SubTipo() == 1)
+ {
+ return false;
+ }
+ return y.get_DataPrePagamento().HasValue;
+ }).Sum<VendedorParcela>((VendedorParcela y) => y.get_ValorRepasse()));
+ decimal? porcentagemRepasse = x.First<VendedorParcela>().get_PorcentagemRepasse();
+ vendedorParcela.set_PorcentagemRepasse((porcentagemRepasse.HasValue ? new decimal?(porcentagemRepasse.GetValueOrDefault() / 100) : null));
+ vendedorParcela.set_TipoVendedor(x.First<VendedorParcela>().get_TipoVendedor());
+ return vendedorParcela;
+ }).ToList<VendedorParcela>();
+ this.Pagamentos = new ObservableCollection<VendedorParcela>(list);
+ }
+
+ public void Seleciona(Documento documento)
+ {
+ this.SelectedDocumento = documento;
+ if (this.SelectedDocumento.get_Tipo() != 1)
+ {
+ this.ApoliceLabel = (!this.SelectedDocumento.get_Emissao().HasValue ? string.Concat("VALORES DA PROPOSTA ", this.SelectedDocumento.get_Proposta()) : string.Concat("VALORES DA APÓLICE ", this.SelectedDocumento.get_Apolice()));
+ this.ApoliceDescricao = (!this.SelectedDocumento.get_Emissao().HasValue ? string.Concat("VALORES BASEADOS NA PROPOSTA ", this.SelectedDocumento.get_Proposta(), " ATÉ O MOMENTO, OS VALORES PODEM SER DIFERENTES EM CASO DE ALTERAÇÕES POR OUTROS USUÁRIOS.") : string.Concat("VALORES BASEADOS NA APÓLICE ", this.SelectedDocumento.get_Apolice(), " ATÉ O MOMENTO, OS VALORES PODEM SER DIFERENTES EM CASO DE ALTERAÇÕES POR OUTROS USUÁRIOS."));
+ }
+ this.CalculaComissao();
+ this.CalculaEspecial();
+ this.CalculaRepasse();
+ base.RegistrarAcao(string.Format("CONSULTOU MAIS INFORMAÇÕES DOS VALORES DO DOCUMENTO DE ID {0}", documento.get_Id()), documento.get_Id(), new TipoTela?(21), null);
+ }
+ }
+}
\ No newline at end of file |