diff options
| author | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 17:17:46 +0000 |
|---|---|---|
| committer | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 17:17:46 +0000 |
| commit | 0440c722a221b8068bbf388c1c0c51f0faff0451 (patch) | |
| tree | 169cbf90c50ff7961db82ecb606c50c2a45a1688 /Gestor.Model/Gestor.Model.Domain.Financeiro/Fornecedor.cs | |
| parent | 225aa1499e37faf9d38257caabbadc68d78b427e (diff) | |
| download | gestor-0440c722a221b8068bbf388c1c0c51f0faff0451.tar.gz gestor-0440c722a221b8068bbf388c1c0c51f0faff0451.zip | |
Diffstat (limited to 'Gestor.Model/Gestor.Model.Domain.Financeiro/Fornecedor.cs')
| -rw-r--r-- | Gestor.Model/Gestor.Model.Domain.Financeiro/Fornecedor.cs | 238 |
1 files changed, 238 insertions, 0 deletions
diff --git a/Gestor.Model/Gestor.Model.Domain.Financeiro/Fornecedor.cs b/Gestor.Model/Gestor.Model.Domain.Financeiro/Fornecedor.cs new file mode 100644 index 0000000..aeef0de --- /dev/null +++ b/Gestor.Model/Gestor.Model.Domain.Financeiro/Fornecedor.cs @@ -0,0 +1,238 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using Gestor.Model.Attributes; +using Gestor.Model.Common; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Seguros; +using Gestor.Model.Helper; +using Gestor.Model.Resources; +using Gestor.Model.Validation; +using Newtonsoft.Json; + +namespace Gestor.Model.Domain.Financeiro; + +public class Fornecedor : EnderecoBase, IDomain +{ + private string _nome; + + private string _documento; + + private string _email; + + private string _observacao; + + public new long Id { get; set; } + + public long IdEmpresa { get; set; } + + public long? IdConta { get; set; } + + public long? IdCentro { get; set; } + + public long? IdPlano { get; set; } + + public TipoPagamento? TipoPagamento { get; set; } + + [Log(true)] + [Name(true)] + public string Nome + { + get + { + return _nome?.ToUpper(); + } + set + { + _nome = value; + NomeSocial = $"{value?.ToUpper()} - {Id}"; + } + } + + [Log(true)] + [Description("NOME SOCIAL")] + public string NomeSocial { get; set; } + + [Log(true)] + public string Documento + { + get + { + return _documento?.ToUpper().Trim(); + } + set + { + _documento = value; + } + } + + [Log(true)] + [Description("TIPO TELEFONE")] + public TipoTelefone? TipoTelefone1 { get; set; } + + [Log(true)] + [Description("PREFIXO 1")] + public string Prefixo1 { get; set; } + + [Log(true)] + [Description("TELEFONE 1")] + public string Telefone1 { get; set; } + + [Log(true)] + [Description("TIPO TELEFONE 2")] + public TipoTelefone? TipoTelefone2 { get; set; } + + [Log(true)] + [Description("PREFIXO 2")] + public string Prefixo2 { get; set; } + + [Log(true)] + [Description("TELEFONE 2")] + public string Telefone2 { get; set; } + + [Log(true)] + [Description("E-MAIL")] + public string Email + { + get + { + return _email?.ToLower(); + } + set + { + _email = value; + } + } + + [Log(true)] + [Description("OBSERVAÇÃO")] + public string Observacao + { + get + { + return _observacao?.ToUpper(); + } + set + { + _observacao = value; + } + } + + [Log(true)] + [Description("ATIVO")] + public bool Ativo { get; set; } + + [JsonIgnore] + public Func<List<KeyValuePair<string, string>>> ValidationEvent => Validate; + + public List<KeyValuePair<string, string>> Validate() + { + List<KeyValuePair<string, string>> list = ValidationHelper.AddValue(); + int? num = Nome?.Trim().Split(new char[1] { ' ' }).Length; + if (!num.HasValue) + { + list.AddValue("Nome", Messages.Obrigatorio); + } + else if (num <= 1) + { + list.AddValue("Nome", Messages.NomeInvalido); + } + if (!string.IsNullOrWhiteSpace(Nome) && Nome.Length > 60) + { + list.AddValue("Nome", string.Format(Messages.MaiorQueLimite, 60)); + } + if (!string.IsNullOrWhiteSpace(Documento) && !Documento.ValidacaoDocumento()) + { + list.AddValue("Documento", Messages.Invalido); + } + if (!string.IsNullOrWhiteSpace(Prefixo1) && !Prefixo1.ValidacaoPrefixo()) + { + list.AddValue("Prefixo1", Messages.Obrigatorio); + } + if (!string.IsNullOrWhiteSpace(Telefone1) && !Telefone1.ValidacaoTelefone()) + { + list.AddValue("Telefone1", Messages.Obrigatorio); + } + if (!string.IsNullOrWhiteSpace(Email) && !Email.ValidacaoEmail()) + { + list.AddValue("Email", Messages.Obrigatorio); + } + if (!string.IsNullOrWhiteSpace(base.Cidade) && base.Cidade.Length > 30) + { + list.AddValue("Cidade", string.Format(Messages.MaiorQueLimite, 30)); + } + if (!string.IsNullOrWhiteSpace(base.Bairro) && base.Bairro.Length > 60) + { + list.AddValue("Bairro", string.Format(Messages.MaiorQueLimite, 60)); + } + if (!string.IsNullOrWhiteSpace(base.Complemento) && base.Complemento.Length > 40) + { + list.AddValue("Complemento", string.Format(Messages.MaiorQueLimite, 40)); + } + return list; + } + + public List<TupleList> Log() + { + List<TupleList> list = new List<TupleList>(); + TupleList tupleList = new TupleList(); + ObservableCollection<Tuple<string, string, string>> obj = new ObservableCollection<Tuple<string, string, string>> + { + new Tuple<string, string, string>("NOME DO FORNECEDOR", string.IsNullOrWhiteSpace(Nome) ? "" : Nome, ""), + new Tuple<string, string, string>("DOCUMENTO", string.IsNullOrWhiteSpace(Documento) ? "" : Documento, ""), + new Tuple<string, string, string>("CEP", string.IsNullOrWhiteSpace(base.Cep) ? "" : base.Cep, ""), + new Tuple<string, string, string>("ENDEREÇO", string.IsNullOrWhiteSpace(base.Endereco) ? "" : base.Endereco, ""), + new Tuple<string, string, string>("NÚMERO", string.IsNullOrWhiteSpace(base.Numero) ? "" : base.Numero, ""), + new Tuple<string, string, string>("COMPLEMENTO", string.IsNullOrWhiteSpace(base.Complemento) ? "" : base.Complemento, ""), + new Tuple<string, string, string>("BAIRRO", string.IsNullOrWhiteSpace(base.Bairro) ? "" : base.Bairro, ""), + new Tuple<string, string, string>("CIDADE", string.IsNullOrWhiteSpace(base.Cidade) ? "" : base.Cidade, ""), + new Tuple<string, string, string>("ESTADO", string.IsNullOrWhiteSpace(base.Estado) ? "" : base.Estado, "") + }; + object item; + if (TipoTelefone1.HasValue) + { + TipoTelefone? tipoTelefone = TipoTelefone1; + item = (tipoTelefone.HasValue ? tipoTelefone.GetValueOrDefault().GetDescription() : null); + } + else + { + item = ""; + } + obj.Add(new Tuple<string, string, string>("TIPO DO PRIMEIRO TELEFONE", (string)item, "")); + obj.Add(new Tuple<string, string, string>("PRIMEIRO PREFIXO", string.IsNullOrWhiteSpace(Prefixo1) ? "" : Prefixo1, "")); + obj.Add(new Tuple<string, string, string>("PRIMEIRO TELEFONE", string.IsNullOrWhiteSpace(Telefone1) ? "" : Telefone1, "")); + object item2; + if (TipoTelefone2.HasValue) + { + TipoTelefone? tipoTelefone = TipoTelefone2; + item2 = (tipoTelefone.HasValue ? tipoTelefone.GetValueOrDefault().GetDescription() : null); + } + else + { + item2 = ""; + } + obj.Add(new Tuple<string, string, string>("TIPO DO SEGUNDO TELEFONE", (string)item2, "")); + obj.Add(new Tuple<string, string, string>("SEGUNDO PREFIXO", string.IsNullOrWhiteSpace(Prefixo2) ? "" : Prefixo2, "")); + obj.Add(new Tuple<string, string, string>("SEGUNDO TELEFONE", string.IsNullOrWhiteSpace(Telefone2) ? "" : Telefone2, "")); + obj.Add(new Tuple<string, string, string>("E-MAIL", string.IsNullOrWhiteSpace(Email) ? "" : Email, "")); + obj.Add(new Tuple<string, string, string>("PLANO DE CONTAS", (!IdPlano.HasValue) ? "" : IdPlano?.ToString(), "")); + obj.Add(new Tuple<string, string, string>("CENTRO DE CUSTO", (!IdCentro.HasValue) ? "" : IdCentro?.ToString(), "")); + obj.Add(new Tuple<string, string, string>("CONTA CORRENTE", (!IdConta.HasValue) ? "" : IdConta?.ToString(), "")); + object item3; + if (TipoPagamento.HasValue) + { + TipoPagamento? tipoPagamento = TipoPagamento; + item3 = (tipoPagamento.HasValue ? tipoPagamento.GetValueOrDefault().GetDescription() : null); + } + else + { + item3 = ""; + } + obj.Add(new Tuple<string, string, string>("TIPO DE PAGAMENTO", (string)item3, "")); + obj.Add(new Tuple<string, string, string>("OBSERVAÇÕES", string.IsNullOrWhiteSpace(Observacao) ? "" : Observacao, "")); + tupleList.Tuples = obj; + list.Add(tupleList); + return list; + } +} |