1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
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;
}
}
|