diff options
Diffstat (limited to 'Gestor.Model/Gestor.Model.Domain.Financeiro/Lancamento.cs')
| -rw-r--r-- | Gestor.Model/Gestor.Model.Domain.Financeiro/Lancamento.cs | 195 |
1 files changed, 195 insertions, 0 deletions
diff --git a/Gestor.Model/Gestor.Model.Domain.Financeiro/Lancamento.cs b/Gestor.Model/Gestor.Model.Domain.Financeiro/Lancamento.cs new file mode 100644 index 0000000..7608cb9 --- /dev/null +++ b/Gestor.Model/Gestor.Model.Domain.Financeiro/Lancamento.cs @@ -0,0 +1,195 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using Gestor.Model.Attributes; +using Gestor.Model.Common; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Helper; +using Gestor.Model.Resources; +using Newtonsoft.Json; + +namespace Gestor.Model.Domain.Financeiro; + +public class Lancamento : DomainBase, IDomain +{ + private decimal? _valorPago; + + private string _historico; + + private string _documento; + + private string _complemento; + + private string _competencia; + + public bool Selecionado { get; set; } + + public ControleFinanceiro Controle { get; set; } + + [Log(true)] + public BancosContas Conta { get; set; } + + [Log(true)] + [Description("TIPO PAGAMENTO")] + public TipoPagamento TipoPagamento { get; set; } + + [Log(true)] + [Description("HISTÓRICO")] + public string Historico + { + get + { + return _historico?.ToUpper(); + } + set + { + _historico = value; + } + } + + [Log(true)] + public string Documento + { + get + { + return _documento?.ToUpper(); + } + set + { + _documento = value; + } + } + + [Log(true)] + public string Complemento + { + get + { + return _complemento?.ToUpper(); + } + set + { + _complemento = value; + } + } + + [Log(true)] + [Description("COMPETÊNCIA")] + public string Competencia + { + get + { + return _competencia?.ToUpper(); + } + set + { + _competencia = value; + } + } + + [Log(true)] + public int Parcela { get; set; } + + [Log(true)] + public DateTime Vencimento { get; set; } + + [Log(true)] + public decimal Valor { get; set; } + + [Log(true)] + [Description("DATA DA BAIXA")] + public DateTime? Baixa { get; set; } + + [Log(true)] + [Description("VALOR PAGO")] + public decimal? ValorPago + { + get + { + return _valorPago.GetValueOrDefault(); + } + set + { + _valorPago = value; + } + } + + [Log(true)] + public DateTime? Pagamento { get; set; } + + [Log(true)] + public Sinal Sinal { get; set; } + + [Log(true)] + [Description("OBSERVAÇÃO")] + public string Observacao { get; set; } + + public bool Baixado { get; set; } + + [Log(true)] + [Description("CÓDIGO BANCO")] + public string CodigoBanco { get; set; } + + [Log(true)] + [Description("DATA LANÇAMENTO")] + public DateTime? DataLancamento { get; set; } + + [JsonIgnore] + public Func<List<KeyValuePair<string, string>>> ValidationEvent => Validate; + + public List<KeyValuePair<string, string>> Validate() + { + List<KeyValuePair<string, string>> list = ValidationHelper.AddValue(); + list.AddRange(Controle.Validate()); + if (string.IsNullOrWhiteSpace(Historico)) + { + list.AddValue("Historico", Messages.Obrigatorio); + } + else if (Historico.Length > 100) + { + list.AddValue("Historico", string.Format(Messages.MaiorQueLimite, 100)); + } + if (Valor <= 0m) + { + list.AddValue("Valor", Messages.Obrigatorio); + } + decimal? valorPago = ValorPago; + if ((valorPago.GetValueOrDefault() < default(decimal)) & valorPago.HasValue) + { + list.AddValue("ValorPago", Messages.Obrigatorio); + } + if (Conta == null) + { + list.AddValue("Conta|CONTA CORRENTE", Messages.Obrigatorio + "\nSE NÃO HOUVER NENHUMA CONTA CORRENTE CADASTRADA\nACESSE A TELA BANCOS E CONTAS PARA INCLUIR"); + } + if (!string.IsNullOrWhiteSpace(Documento) && Documento.Length > 50) + { + list.AddValue("Documento", string.Format(Messages.MaiorQueLimite, 50)); + } + if (!string.IsNullOrWhiteSpace(Competencia) && Competencia.Length > 8) + { + list.AddValue("Competencia|COMPETÊNCIA", string.Format(Messages.MaiorQueLimite, 8)); + } + if (!string.IsNullOrWhiteSpace(Complemento) && Complemento.Length > 50) + { + list.AddValue("Complemento", string.Format(Messages.MaiorQueLimite, 50)); + } + if (Baixa.HasValue && (DateTime.Compare(Baixa.Value, new DateTime(1753, 1, 1)) < 0 || DateTime.Compare(Baixa.Value, new DateTime(9999, 12, 31)) > 0)) + { + list.AddValue("Baixa", string.Format(Messages.DataInvalida)); + } + if (DateTime.Compare(Vencimento, new DateTime(1753, 1, 1)) < 0 || DateTime.Compare(Vencimento, new DateTime(9999, 12, 31)) > 0) + { + list.AddValue("Vencimento", string.Format(Messages.DataInvalida)); + } + if (Pagamento.HasValue && (DateTime.Compare(Pagamento.Value, new DateTime(1753, 1, 1)) < 0 || DateTime.Compare(Pagamento.Value, new DateTime(9999, 12, 31)) > 0)) + { + list.AddValue("Pagamento", string.Format(Messages.DataInvalida)); + } + if (!Baixa.HasValue && Baixado) + { + list.AddValue("Baixa", "NÃO É POSSÍVEL SALVAR UM DOCUMENTO SEM DATA DE BAIXA QUANDO O LANÇAMENTO POSSUÍ BAIXA"); + } + return list; + } +} |