diff options
Diffstat (limited to 'Codemerx/Gestor.Application/ViewModels/Generic/ExtratoComissaoViewModel.cs')
| -rw-r--r-- | Codemerx/Gestor.Application/ViewModels/Generic/ExtratoComissaoViewModel.cs | 147 |
1 files changed, 147 insertions, 0 deletions
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<Seguradora> _seguradoras;
+
+ private DateTime _inicio;
+
+ private DateTime _fim;
+
+ private ObservableCollection<Extrato> _extratos;
+
+ public bool Apelido
+ {
+ get
+ {
+ return this._apelido;
+ }
+ set
+ {
+ this._apelido = value;
+ base.OnPropertyChanged("Apelido");
+ }
+ }
+
+ public ObservableCollection<Extrato> 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<Seguradora> Seguradoras
+ {
+ get
+ {
+ return this._seguradoras;
+ }
+ set
+ {
+ this._seguradoras = value;
+ base.OnPropertyChanged("Seguradoras");
+ }
+ }
+
+ public ExtratoComissaoViewModel(List<Seguradora> 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>((ConfiguracaoSistema x) => x.get_Configuracao() == 6);
+ this.Seguradoras = seguradoras;
+ }
+
+ public async Task CarregarExtratos(Seguradora seguradora, DateTime inicio, DateTime fim)
+ {
+ this.Extratos = new ObservableCollection<Extrato>(await this._servico.BuscarExtrato(seguradora.get_Id(), (long)0, 4, inicio, fim));
+ }
+
+ internal List<NotaFiscal> Selecionar()
+ {
+ if (this.Extratos == null)
+ {
+ return null;
+ }
+ return (
+ from x in this.Extratos
+ where x.get_Selecionado()
+ select x).Select<Extrato, NotaFiscal>((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<NotaFiscal>();
+ }
+
+ internal void SelecionarTudo()
+ {
+ if (this.Extratos == null)
+ {
+ return;
+ }
+ this.Extratos.ToList<Extrato>().ForEach((Extrato x) => x.set_Selecionado(!x.get_Selecionado()));
+ this.Extratos = new ObservableCollection<Extrato>(this.Extratos);
+ }
+ }
+}
\ No newline at end of file |