using Gestor.Model.Attributes; using Gestor.Model.Domain.Generic; using Gestor.Model.Domain.Seguros; using Gestor.Model.Helper; using Gestor.Model.Resources; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Globalization; using System.Runtime.CompilerServices; using System.Threading; namespace Gestor.Model.Domain.Ferramentas { public class NotaFiscal : DomainBase { private bool _selecionado; [Description("DATA")] [Log(true)] public DateTime? Data { get; set; } [Description("ESTIPULANTE")] [Log(true)] public Gestor.Model.Domain.Seguros.Estipulante Estipulante { get; set; } [Description("EXTRATO")] [Log(true)] public string Extrato { get; set; } [Log(true)] public long? IdExtrato { get; set; } [Description("IR")] [Log(true)] public decimal Ir { get; set; } [Description("ISS")] [Log(true)] public decimal Iss { get; set; } [Description("OBS")] [Log(true)] public string Obs { get; set; } [Log(true)] public Gestor.Model.Domain.Seguros.Seguradora Seguradora { get; set; } public bool Selecionado { get { return this._selecionado; } set { if (value == this._selecionado) { return; } this._selecionado = value; this.OnPropertyChanged("Selecionado"); } } [JsonIgnore] public Func>> ValidationEvent { get { return new Func>>(this.Validate); } } [Description("VALOR BRUTO")] [Log(true)] public decimal ValorBruto { get; set; } [Description("VALOR LÍQUIDO")] [Log(true)] public decimal ValorLiquido { get; set; } public NotaFiscal() { } public List Log() { string nome; string str; string shortDateString; List tupleLists = new List(); TupleList tupleList = new TupleList(); ObservableCollection> observableCollection = new ObservableCollection>() { new Tuple("SEGURADORA", (string.IsNullOrWhiteSpace(this.Seguradora.Nome) ? "" : this.Seguradora.Nome), "") }; Gestor.Model.Domain.Seguros.Estipulante estipulante = this.Estipulante; if (estipulante != null) { nome = estipulante.Nome; } else { nome = null; } if (string.IsNullOrWhiteSpace(nome)) { str = ""; } else { Gestor.Model.Domain.Seguros.Estipulante estipulante1 = this.Estipulante; if (estipulante1 != null) { str = estipulante1.Nome; } else { str = null; } } observableCollection.Add(new Tuple("ESTIPULANTE", str, "")); decimal iss = this.Iss; observableCollection.Add(new Tuple("ISS", iss.ToString("C", new CultureInfo("pt-BR", false)), "")); iss = this.ValorLiquido; observableCollection.Add(new Tuple("VALOR LÍQUIDO", iss.ToString("C", new CultureInfo("pt-BR", false)), "")); iss = this.ValorBruto; observableCollection.Add(new Tuple("VALOR BRUTO", iss.ToString("C", new CultureInfo("pt-BR", false)), "")); DateTime? data = this.Data; if (!data.HasValue) { shortDateString = ""; } else { data = this.Data; if (data.HasValue) { shortDateString = data.GetValueOrDefault().ToShortDateString(); } else { shortDateString = null; } } observableCollection.Add(new Tuple("DATA", shortDateString, "")); tupleList.Tuples = observableCollection; tupleLists.Add(tupleList); return tupleLists; } protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) { PropertyChangedEventHandler propertyChangedEventHandler = this.PropertyChanged; if (propertyChangedEventHandler == null) { return; } propertyChangedEventHandler(this, new PropertyChangedEventArgs(propertyName)); } public List> Validate() { List> keyValuePairs = ValidationHelper.AddValue(); if (this.Seguradora == null || string.IsNullOrEmpty(this.Seguradora.Nome)) { keyValuePairs.AddValue("Seguradora", Messages.Obrigatorio, true); } return keyValuePairs; } public event PropertyChangedEventHandler PropertyChanged; } }