summaryrefslogtreecommitdiff
path: root/Gestor.Model/Gestor.Model.Domain.Seguros/Repasse.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Gestor.Model/Gestor.Model.Domain.Seguros/Repasse.cs')
-rw-r--r--Gestor.Model/Gestor.Model.Domain.Seguros/Repasse.cs112
1 files changed, 112 insertions, 0 deletions
diff --git a/Gestor.Model/Gestor.Model.Domain.Seguros/Repasse.cs b/Gestor.Model/Gestor.Model.Domain.Seguros/Repasse.cs
new file mode 100644
index 0000000..4beadaf
--- /dev/null
+++ b/Gestor.Model/Gestor.Model.Domain.Seguros/Repasse.cs
@@ -0,0 +1,112 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Helper;
+using Gestor.Model.Resources;
+using Gestor.Model.Validation;
+using Newtonsoft.Json;
+
+namespace Gestor.Model.Domain.Seguros;
+
+public class Repasse : DomainBase, IDomain
+{
+ private string _incidenciaVendedor = "";
+
+ private string _pgtoVendedor = "";
+
+ public Vendedor Vendedor { get; set; }
+
+ public long? Seguradora { get; set; }
+
+ public Ramo Ramo { get; set; }
+
+ public decimal ValorNovo { get; set; }
+
+ public decimal ValorRenovacao { get; set; }
+
+ public TipoRepasse? Tipo { get; set; }
+
+ public TipoIncidencia? Incidencia { get; set; }
+
+ public FormaRepasse? Forma { get; set; }
+
+ public BaseRepasse? Base { get; set; }
+
+ public bool Ativo { get; set; }
+
+ public List<VinculoRepasse> Vinculo { get; set; }
+
+ public string IncidenciaVendedor => _incidenciaVendedor = Incidencia.GetDescription();
+
+ public string PagtoVendedor => _pgtoVendedor = Forma.GetDescription();
+
+ [JsonIgnore]
+ public Func<List<KeyValuePair<string, string>>> ValidationEvent => Validate;
+
+ public List<KeyValuePair<string, string>> Validate()
+ {
+ List<KeyValuePair<string, string>> list = ValidationHelper.AddValue();
+ if (Vendedor == null)
+ {
+ list.AddValue("Vendedor", Messages.Obrigatorio);
+ }
+ if (TipoRepasse.CoCorretagem != Tipo.GetValueOrDefault() && ValorNovo == 0m)
+ {
+ list.AddValue("ValorNovo", Messages.Obrigatorio);
+ }
+ if (TipoRepasse.CoCorretagem != Tipo.GetValueOrDefault() && ValorRenovacao == 0m)
+ {
+ list.AddValue("ValorRenovacao", Messages.Obrigatorio);
+ }
+ if (!Tipo.HasValue)
+ {
+ list.AddValue("Tipo", Messages.Obrigatorio);
+ }
+ if (!Incidencia.HasValue && Forma.HasValue && Forma.GetValueOrDefault() == FormaRepasse.Recebimento)
+ {
+ list.AddValue("Incidencia", Messages.Obrigatorio);
+ }
+ if (!Forma.HasValue)
+ {
+ list.AddValue("Forma", Messages.Obrigatorio);
+ }
+ if (Forma.HasValue && Forma.GetValueOrDefault() != FormaRepasse.Recebimento)
+ {
+ if (!Base.HasValue)
+ {
+ list.AddValue("Base", Messages.Obrigatorio);
+ }
+ if (Forma.GetValueOrDefault() == FormaRepasse.Prazo && Base.GetValueOrDefault() != BaseRepasse.Vencimento)
+ {
+ list.AddValue("Base", Messages.Invalido);
+ }
+ }
+ if (Forma.HasValue && Forma.GetValueOrDefault() == FormaRepasse.Recebimento && Base.HasValue)
+ {
+ list.AddValue("Base", Messages.Invalido);
+ }
+ return list;
+ }
+
+ public List<TupleList> Log()
+ {
+ return new List<TupleList>
+ {
+ new TupleList
+ {
+ Tuples = new ObservableCollection<Tuple<string, string, string>>
+ {
+ new Tuple<string, string, string>("TIPO", Tipo.GetDescription(), ""),
+ new Tuple<string, string, string>("VALOR NOVO", $"{ValorNovo:##.00}", ""),
+ new Tuple<string, string, string>("VALOR RENOVAÇÃO", $"{ValorRenovacao:##.00}", ""),
+ new Tuple<string, string, string>("INCIDÊNCIA", Incidencia.GetDescription(), ""),
+ new Tuple<string, string, string>("FORMA PAGAMENTO", Forma.GetDescription(), ""),
+ new Tuple<string, string, string>("BASE PAGAMENTO", Base.GetDescription(), ""),
+ new Tuple<string, string, string>("ATIVO", Ativo ? "SIM" : "NÃO", "")
+ }
+ }
+ };
+ }
+}