summaryrefslogtreecommitdiff
path: root/Gestor.Model/Model.Domain.Ferramentas/Imposto.cs
blob: 7a65e49cb3ecfa56c17b630f7f2af5e951697751 (plain)
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
using Gestor.Model.Domain.Generic;
using Gestor.Model.Domain.Seguros;
using Gestor.Model.Helper;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Runtime.CompilerServices;

namespace Gestor.Model.Domain.Ferramentas
{
	public class Imposto : DomainBase, IDomain
	{
		public bool Ativo
		{
			get;
			set;
		}

		public decimal Desconto
		{
			get;
			set;
		}

		public decimal Ir
		{
			get;
			set;
		}

		public decimal Iss
		{
			get;
			set;
		}

		public decimal Outros
		{
			get;
			set;
		}

		public Gestor.Model.Domain.Seguros.Ramo Ramo
		{
			get;
			set;
		}

		public Gestor.Model.Domain.Seguros.Seguradora Seguradora
		{
			get;
			set;
		}

		[JsonIgnore]
		public Func<List<KeyValuePair<string, string>>> ValidationEvent
		{
			get
			{
				Imposto imposto = this;
				return new Func<List<KeyValuePair<string, string>>>(imposto.Validate);
			}
		}

		public Imposto()
		{
		}

		public List<TupleList> Log()
		{
			object nome;
			object nomeSocial;
			List<TupleList> tupleLists = new List<TupleList>();
			TupleList tupleList = new TupleList();
			ObservableCollection<Tuple<string, string, string>> observableCollection = new ObservableCollection<Tuple<string, string, string>>();
			Gestor.Model.Domain.Seguros.Ramo ramo = this.Ramo;
			if (ramo != null)
			{
				nome = ramo.Nome;
			}
			else
			{
				nome = null;
			}
			if (nome == null)
			{
				nome = "";
			}
			observableCollection.Add(new Tuple<string, string, string>("RAMO", nome, ""));
			Gestor.Model.Domain.Seguros.Seguradora seguradora = this.Seguradora;
			if (seguradora != null)
			{
				nomeSocial = seguradora.NomeSocial;
			}
			else
			{
				nomeSocial = null;
			}
			if (nomeSocial == null)
			{
				Gestor.Model.Domain.Seguros.Seguradora seguradora1 = this.Seguradora;
				if (seguradora1 != null)
				{
					nomeSocial = seguradora1.Nome;
				}
				else
				{
					nomeSocial = null;
				}
				if (nomeSocial == null)
				{
					nomeSocial = "";
				}
			}
			observableCollection.Add(new Tuple<string, string, string>("SEGURADORA", nomeSocial, ""));
			decimal ir = this.Ir;
			observableCollection.Add(new Tuple<string, string, string>("IR", ir.ToString("p"), ""));
			ir = this.Iss;
			observableCollection.Add(new Tuple<string, string, string>("ISS", ir.ToString("p"), ""));
			ir = this.Outros;
			observableCollection.Add(new Tuple<string, string, string>("OUTROS", ir.ToString("p"), ""));
			ir = this.Desconto;
			observableCollection.Add(new Tuple<string, string, string>("DESCONTO", ir.ToString("p"), ""));
			observableCollection.Add(new Tuple<string, string, string>("ATIVO", (this.Ativo ? "SIM" : "NÃO"), ""));
			tupleList.Tuples = observableCollection;
			tupleLists.Add(tupleList);
			return tupleLists;
		}

		public List<KeyValuePair<string, string>> Validate()
		{
			List<KeyValuePair<string, string>> keyValuePairs = ValidationHelper.AddValue();
			if (this.Ir > decimal.One)
			{
				keyValuePairs.AddValue<string, string>("Ir|PORCENTAGEM IR", "O VALOR DE IR NÃO PODE SER MAIOR QUE 100%.", true);
			}
			if (this.Iss > decimal.One)
			{
				keyValuePairs.AddValue<string, string>("Iss|PORCENTAGEM ISS", "O VALOR DE ISS NÃO PODE SER MAIOR QUE 100%.", true);
			}
			if (this.Outros > decimal.One)
			{
				keyValuePairs.AddValue<string, string>("Outros|PORCENTAGEM OUTROS", "O VALOR DOS OUTROS DESCONTOS NÃO PODE SER MAIOR QUE 100%.", true);
			}
			if (this.Desconto > decimal.One)
			{
				keyValuePairs.AddValue<string, string>("Desconto|PORCENTAGEM DESCONTO", "O VALOR DE DESCONTO NÃO PODE SER MAIOR QUE 100%.", true);
			}
			if (this.Ir < decimal.Zero)
			{
				keyValuePairs.AddValue<string, string>("Ir|PORCENTAGEM IR", "O VALOR DE IR NÃO PODE SER MENOR QUE 0%.", true);
			}
			if (this.Iss < decimal.Zero)
			{
				keyValuePairs.AddValue<string, string>("Iss|PORCENTAGEM ISS", "O VALOR DE ISS NÃO PODE SER MENOR QUE 0%.", true);
			}
			if (this.Outros < decimal.Zero)
			{
				keyValuePairs.AddValue<string, string>("Outros|PORCENTAGEM OUTROS", "O VALOR DOS OUTROS DESCONTOS NÃO PODE SER MENOR QUE 0%.", true);
			}
			if (this.Desconto < decimal.Zero)
			{
				keyValuePairs.AddValue<string, string>("Desconto|PORCENTAGEM DESCONTO", "O VALOR DE DESCONTO NÃO PODE SER MENOR QUE 0%.", true);
			}
			if ((((this.Ir + this.Iss) + this.Outros) + this.Desconto) > decimal.One)
			{
				keyValuePairs.AddValue<string, string>("Ir|PORCENTAGEM TOTAL", "NÃO É POSSÍVEL DEDUZIR MAIS QUE 100% DO TOTAL RECEBIDO.", true);
			}
			if ((((this.Ir + this.Iss) + this.Outros) + this.Desconto) == decimal.Zero)
			{
				keyValuePairs.AddValue<string, string>("Ir|PORCENTAGEM TOTAL", "A SOMA DOS IMPOSTOS DEVEM SER MAIOR QUE 0 (ZERO).", true);
			}
			return keyValuePairs;
		}
	}
}