using Gestor.Model.Attributes; using Gestor.Model.Common; using Gestor.Model.Domain.Generic; using Gestor.Model.Helper; using Gestor.Model.Resources; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.ComponentModel; using System.Runtime.CompilerServices; namespace Gestor.Model.Domain.Seguros { public class VendedorParcela : DomainBase, IDomain { private string _vCondRep; public bool CoCorretagem { get; set; } public Gestor.Model.Domain.Seguros.CondicaoRepasse CondicaoRepasse { get; set; } [Description("DATA DO PAGAMENTO")] [Log(true)] public DateTime? DataPagamento { get; set; } [Description("DATA PREVISÃO DE PAGAMENTO")] [Log(true)] public DateTime? DataPrePagamento { get; set; } [Log(false)] public Gestor.Model.Domain.Seguros.Documento Documento { get; set; } [Log(false)] public Gestor.Model.Domain.Seguros.Parcela Parcela { get; set; } [Description("PORCENTAGEM REPASSE")] [Log(true)] public decimal? PorcentagemRepasse { get; set; } public decimal? PorcentagemRepasseB { get; set; } public string RecebidoPorCompleto { get; set; } public Gestor.Model.Domain.Seguros.Repasse Repasse { get; set; } public bool Selecionado { get; set; } public Gestor.Model.Domain.Seguros.TipoVendedor TipoVendedor { get; set; } [JsonIgnore] public Func>> ValidationEvent { get { VendedorParcela vendedorParcela = this; return new Func>>(vendedorParcela.Validate); } } [Description("VALOR REPASSE")] [Log(true)] public decimal? ValorRepasse { get; set; } public decimal? ValorRepasseB { get; set; } public decimal? ValorTotal { get; set; } public decimal? ValorTotalPago { get; set; } public string VCondRep { get { string str = this._vCondRep; if (str != null) { return str.ToUpper(); } return null; } set { this._vCondRep = value; } } [Log(true)] public Gestor.Model.Domain.Seguros.Vendedor Vendedor { get; set; } public VendedorParcela() { } public List> Validate() { decimal num; List> keyValuePairs = ValidationHelper.AddValue(); if (this.DataPagamento.HasValue && (DateTime.Compare(this.DataPagamento.Value, new DateTime(1753, 1, 1)) < 0 || DateTime.Compare(this.DataPagamento.Value, new DateTime(9999, 12, 31)) > 0)) { keyValuePairs.AddValue("DataPagamento", string.Format(Messages.DataInvalida, Array.Empty()), true); } if (this.DataPrePagamento.HasValue && (DateTime.Compare(this.DataPrePagamento.Value, new DateTime(1753, 1, 1)) < 0 || DateTime.Compare(this.DataPrePagamento.Value, new DateTime(9999, 12, 31)) > 0)) { keyValuePairs.AddValue("DataPrePagamento", string.Format(Messages.DataInvalida, Array.Empty()), true); } if (this.Vendedor == null) { keyValuePairs.AddValue("Vendedor", Messages.Obrigatorio, true); } if (this.Documento == null) { keyValuePairs.AddValue("Documento", Messages.Obrigatorio, true); } if (this.Documento != null && this.Documento.Id > (long)0 && this.Parcela == null) { keyValuePairs.AddValue("Parcela", Messages.Obrigatorio, true); } if (this.Repasse == null) { keyValuePairs.AddValue("Repasse", Messages.Obrigatorio, true); } if (this.TipoVendedor == null && !this.CoCorretagem) { keyValuePairs.AddValue("TipoVendedor", Messages.Obrigatorio, true); } decimal? porcentagemRepasse = this.PorcentagemRepasse; if (!porcentagemRepasse.HasValue && !this.CoCorretagem) { keyValuePairs.AddValue("PorcentagemRepasse", Messages.Obrigatorio, true); } porcentagemRepasse = this.ValorRepasse; if (!porcentagemRepasse.HasValue) { keyValuePairs.AddValue("ValorRepasse", Messages.Obrigatorio, true); } if (this.Vendedor == null || this.Vendedor.Corretora) { return keyValuePairs; } porcentagemRepasse = this.PorcentagemRepasse; if (porcentagemRepasse.HasValue) { porcentagemRepasse = this.PorcentagemRepasse; num = new decimal(); if ((porcentagemRepasse.GetValueOrDefault() <= num) & porcentagemRepasse.HasValue) { keyValuePairs.AddValue("PorcentagemRepasse", Messages.Invalido, true); } } porcentagemRepasse = this.ValorRepasse; if (porcentagemRepasse.HasValue) { porcentagemRepasse = this.ValorRepasse; num = new decimal(); if ((porcentagemRepasse.GetValueOrDefault() == num) & porcentagemRepasse.HasValue && !this.CoCorretagem) { keyValuePairs.AddValue("ValorRepasse", Messages.Invalido, true); } } if (this.Repasse != null && this.Documento != null && this.Documento.TipoRecebimento.GetValueOrDefault() == TipoRecebimento.Parcela && this.Repasse.Base.GetValueOrDefault() == BaseRepasse.Transmissao && (!this.Documento.Remessa.HasValue || DateTime.Compare(this.Documento.Remessa.Value, new DateTime(1753, 1, 1)) < 0 || DateTime.Compare(this.Documento.Remessa.Value, new DateTime(9999, 12, 31)) > 0)) { keyValuePairs.AddValue("TRANSMISSÃO DA PROPOSTA", string.Format(Messages.DataInvalida, Array.Empty()), true); } return keyValuePairs; } } }