From 1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 Mon Sep 17 00:00:00 2001 From: Lucas Faria Mendes Date: Mon, 30 Mar 2026 10:38:18 -0300 Subject: chore: location --- .../ViewModels/Generic/ExtratoComissaoViewModel.cs | 147 +++++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 Codemerx/Gestor.Application/ViewModels/Generic/ExtratoComissaoViewModel.cs (limited to 'Codemerx/Gestor.Application/ViewModels/Generic/ExtratoComissaoViewModel.cs') diff --git a/Codemerx/Gestor.Application/ViewModels/Generic/ExtratoComissaoViewModel.cs b/Codemerx/Gestor.Application/ViewModels/Generic/ExtratoComissaoViewModel.cs new file mode 100644 index 0000000..7630bbd --- /dev/null +++ b/Codemerx/Gestor.Application/ViewModels/Generic/ExtratoComissaoViewModel.cs @@ -0,0 +1,147 @@ +using Gestor.Application.Helpers; +using Gestor.Application.Servicos; +using Gestor.Model.Domain.Configuracoes; +using Gestor.Model.Domain.Ferramentas; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Seguros; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Diagnostics; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Gestor.Application.ViewModels.Generic +{ + public class ExtratoComissaoViewModel : BaseViewModel + { + private ServicoExtrato _servico; + + private bool _apelido; + + private List _seguradoras; + + private DateTime _inicio; + + private DateTime _fim; + + private ObservableCollection _extratos; + + public bool Apelido + { + get + { + return this._apelido; + } + set + { + this._apelido = value; + base.OnPropertyChanged("Apelido"); + } + } + + public ObservableCollection Extratos + { + get + { + return this._extratos; + } + set + { + this._extratos = value; + base.OnPropertyChanged("Extratos"); + } + } + + public DateTime Fim + { + get + { + return this._fim; + } + set + { + this._fim = value; + base.OnPropertyChanged("Fim"); + } + } + + public DateTime Inicio + { + get + { + return this._inicio; + } + set + { + this._inicio = value; + base.OnPropertyChanged("Inicio"); + } + } + + public List Seguradoras + { + get + { + return this._seguradoras; + } + set + { + this._seguradoras = value; + base.OnPropertyChanged("Seguradoras"); + } + } + + public ExtratoComissaoViewModel(List seguradoras) + { + DateTime date = Funcoes.GetNetworkTime().Date; + int year = date.Year; + date = Funcoes.GetNetworkTime().Date; + this._inicio = new DateTime(year, date.Month, 1); + this._fim = Funcoes.GetNetworkTime().Date; + base(); + this._servico = new ServicoExtrato(); + this.Apelido = Recursos.Configuracoes.Any((ConfiguracaoSistema x) => x.get_Configuracao() == 6); + this.Seguradoras = seguradoras; + } + + public async Task CarregarExtratos(Seguradora seguradora, DateTime inicio, DateTime fim) + { + this.Extratos = new ObservableCollection(await this._servico.BuscarExtrato(seguradora.get_Id(), (long)0, 4, inicio, fim)); + } + + internal List Selecionar() + { + if (this.Extratos == null) + { + return null; + } + return ( + from x in this.Extratos + where x.get_Selecionado() + select x).Select((Extrato x) => { + NotaFiscal notaFiscal = new NotaFiscal(); + notaFiscal.set_IdExtrato(new long?(x.get_Id())); + notaFiscal.set_Seguradora(x.get_Seguradora()); + notaFiscal.set_Data(x.get_Data()); + notaFiscal.set_Iss(x.get_Iss().GetValueOrDefault()); + notaFiscal.set_Ir(x.get_Ir().GetValueOrDefault()); + notaFiscal.set_ValorBruto(x.get_Bruto().GetValueOrDefault()); + notaFiscal.set_ValorLiquido(x.get_Liquido().GetValueOrDefault()); + notaFiscal.set_Extrato(x.get_Numero()); + return notaFiscal; + }).ToList(); + } + + internal void SelecionarTudo() + { + if (this.Extratos == null) + { + return; + } + this.Extratos.ToList().ForEach((Extrato x) => x.set_Selecionado(!x.get_Selecionado())); + this.Extratos = new ObservableCollection(this.Extratos); + } + } +} \ No newline at end of file -- cgit v1.2.3