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

namespace Gestor.Model.Domain.Ferramentas;

public class Imposto : DomainBase, IDomain
{
	public Seguradora Seguradora { get; set; }

	public Ramo Ramo { get; set; }

	public decimal Ir { get; set; }

	public decimal Iss { get; set; }

	public decimal Outros { get; set; }

	public decimal Desconto { get; set; }

	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();
		if (Ir > 1m)
		{
			list.AddValue("Ir|PORCENTAGEM IR", "O VALOR DE IR NÃO PODE SER MAIOR QUE 100%.");
		}
		if (Iss > 1m)
		{
			list.AddValue("Iss|PORCENTAGEM ISS", "O VALOR DE ISS NÃO PODE SER MAIOR QUE 100%.");
		}
		if (Outros > 1m)
		{
			list.AddValue("Outros|PORCENTAGEM OUTROS", "O VALOR DOS OUTROS DESCONTOS NÃO PODE SER MAIOR QUE 100%.");
		}
		if (Desconto > 1m)
		{
			list.AddValue("Desconto|PORCENTAGEM DESCONTO", "O VALOR DE DESCONTO NÃO PODE SER MAIOR QUE 100%.");
		}
		if (Ir < 0m)
		{
			list.AddValue("Ir|PORCENTAGEM IR", "O VALOR DE IR NÃO PODE SER MENOR QUE 0%.");
		}
		if (Iss < 0m)
		{
			list.AddValue("Iss|PORCENTAGEM ISS", "O VALOR DE ISS NÃO PODE SER MENOR QUE 0%.");
		}
		if (Outros < 0m)
		{
			list.AddValue("Outros|PORCENTAGEM OUTROS", "O VALOR DOS OUTROS DESCONTOS NÃO PODE SER MENOR QUE 0%.");
		}
		if (Desconto < 0m)
		{
			list.AddValue("Desconto|PORCENTAGEM DESCONTO", "O VALOR DE DESCONTO NÃO PODE SER MENOR QUE 0%.");
		}
		if (Ir + Iss + Outros + Desconto > 1m)
		{
			list.AddValue("Ir|PORCENTAGEM TOTAL", "NÃO É POSSÍVEL DEDUZIR MAIS QUE 100% DO TOTAL RECEBIDO.");
		}
		if (Ir + Iss + Outros + Desconto == 0m)
		{
			list.AddValue("Ir|PORCENTAGEM TOTAL", "A SOMA DOS IMPOSTOS DEVEM SER MAIOR QUE 0 (ZERO).");
		}
		return list;
	}

	public List<TupleList> Log()
	{
		return new List<TupleList>
		{
			new TupleList
			{
				Tuples = new ObservableCollection<Tuple<string, string, string>>
				{
					new Tuple<string, string, string>("RAMO", Ramo?.Nome ?? "", ""),
					new Tuple<string, string, string>("SEGURADORA", Seguradora?.NomeSocial ?? Seguradora?.Nome ?? "", ""),
					new Tuple<string, string, string>("IR", Ir.ToString("p"), ""),
					new Tuple<string, string, string>("ISS", Iss.ToString("p"), ""),
					new Tuple<string, string, string>("OUTROS", Outros.ToString("p"), ""),
					new Tuple<string, string, string>("DESCONTO", Desconto.ToString("p"), ""),
					new Tuple<string, string, string>("ATIVO", Ativo ? "SIM" : "NÃO", "")
				}
			}
		};
	}
}