diff options
Diffstat (limited to 'Codemerx/Gestor.Model/Model.Domain.Seguros/VinculoRepasse.cs')
| -rw-r--r-- | Codemerx/Gestor.Model/Model.Domain.Seguros/VinculoRepasse.cs | 159 |
1 files changed, 159 insertions, 0 deletions
diff --git a/Codemerx/Gestor.Model/Model.Domain.Seguros/VinculoRepasse.cs b/Codemerx/Gestor.Model/Model.Domain.Seguros/VinculoRepasse.cs new file mode 100644 index 0000000..002f83e --- /dev/null +++ b/Codemerx/Gestor.Model/Model.Domain.Seguros/VinculoRepasse.cs @@ -0,0 +1,159 @@ +using Gestor.Model.Common;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Helper;
+using Gestor.Model.Resources;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.CompilerServices;
+
+namespace Gestor.Model.Domain.Seguros
+{
+ public class VinculoRepasse : DomainBase
+ {
+ public long IdRepasse
+ {
+ get;
+ set;
+ }
+
+ public Repasse RepasseVinculo
+ {
+ get;
+ set;
+ }
+
+ public Gestor.Model.Domain.Seguros.TipoVendedor TipoVendedor
+ {
+ get;
+ set;
+ }
+
+ public Gestor.Model.Domain.Seguros.TipoVendedor TipoVendedorVinculo
+ {
+ get;
+ set;
+ }
+
+ public VinculoRepasse()
+ {
+ }
+
+ public List<KeyValuePair<string, string>> Validate(List<VinculoRepasse> vinculos, Repasse repasse)
+ {
+ decimal zero;
+ decimal num;
+ decimal zero1;
+ decimal num1;
+ List<KeyValuePair<string, string>> keyValuePairs = ValidationHelper.AddValue();
+ if (this.TipoVendedor == null)
+ {
+ keyValuePairs.AddValue<string, string>("TipoVendedor|TIPO VENDEDOR DO REPASSE", Messages.Obrigatorio, true);
+ }
+ if (this.IdRepasse == 0)
+ {
+ keyValuePairs.AddValue<string, string>("IdRepasse|REPASSE", Messages.Obrigatorio, true);
+ }
+ if (this.TipoVendedorVinculo == null)
+ {
+ keyValuePairs.AddValue<string, string>("TipoVendedorVinculo|TIPO VENDEDOR DO VÍNCULO", Messages.Obrigatorio, true);
+ }
+ if (this.RepasseVinculo == null)
+ {
+ keyValuePairs.AddValue<string, string>("RepasseVinculo|REPASSE DO VÍNCULO", Messages.Obrigatorio, true);
+ }
+ if (this.TipoVendedor != null && this.TipoVendedorVinculo != null && this.TipoVendedor.Id == this.TipoVendedorVinculo.Id)
+ {
+ keyValuePairs.AddValue<string, string>("TipoVendedor", "TIPO VENDEDOR SELECIONADO NÃO PODE SER O MESMO TIPO VENDEDOR DO VINCULO", true);
+ }
+ if (this.IdRepasse > (long)0 && this.RepasseVinculo != null && this.IdRepasse == this.RepasseVinculo.Id)
+ {
+ keyValuePairs.AddValue<string, string>("RepasseVinculo|REPASSE DO VÍNCULO", "NÃO É POSSÍVEL VINCULAR O MESMO REPASSE", true);
+ }
+ if (this.RepasseVinculo == null)
+ {
+ zero = decimal.Zero;
+ }
+ else
+ {
+ zero = (this.RepasseVinculo.Tipo.GetValueOrDefault() != TipoRepasse.Percentual || this.RepasseVinculo.Incidencia.GetValueOrDefault() != TipoIncidencia.SobreComissao ? decimal.Zero : this.RepasseVinculo.ValorNovo);
+ }
+ decimal num2 = zero;
+ decimal num3 = (repasse.Tipo.GetValueOrDefault() != TipoRepasse.Percentual || repasse.Incidencia.GetValueOrDefault() != TipoIncidencia.SobreComissao ? decimal.Zero : repasse.ValorNovo) + num2;
+ decimal num4 = num3;
+ if (this.TipoVendedor == null)
+ {
+ num = decimal.Zero;
+ }
+ else
+ {
+ num = (vinculos != null ? vinculos.Where<VinculoRepasse>((VinculoRepasse x) => {
+ if (this.TipoVendedor.Id != x.TipoVendedor.Id || x.RepasseVinculo.Tipo.GetValueOrDefault() != TipoRepasse.Percentual)
+ {
+ return false;
+ }
+ return x.RepasseVinculo.Incidencia.GetValueOrDefault() == TipoIncidencia.SobreComissao;
+ }).Sum<VinculoRepasse>((VinculoRepasse x) => x.RepasseVinculo.ValorNovo) : decimal.Zero);
+ }
+ num3 = num4 + num;
+ if (this.RepasseVinculo == null)
+ {
+ zero1 = decimal.Zero;
+ }
+ else
+ {
+ zero1 = (this.RepasseVinculo.Tipo.GetValueOrDefault() != TipoRepasse.Percentual || this.RepasseVinculo.Incidencia.GetValueOrDefault() != TipoIncidencia.SobreComissao ? decimal.Zero : this.RepasseVinculo.ValorRenovacao);
+ }
+ decimal num5 = zero1;
+ decimal num6 = (repasse.Tipo.GetValueOrDefault() != TipoRepasse.Percentual || repasse.Incidencia.GetValueOrDefault() != TipoIncidencia.SobreComissao ? decimal.Zero : repasse.ValorRenovacao) + num5;
+ if (this.TipoVendedor == null)
+ {
+ num1 = decimal.Zero;
+ }
+ else
+ {
+ num1 = (vinculos != null ? vinculos.Where<VinculoRepasse>((VinculoRepasse x) => {
+ if (this.TipoVendedor.Id != x.TipoVendedor.Id || x.RepasseVinculo.Tipo.GetValueOrDefault() != TipoRepasse.Percentual)
+ {
+ return false;
+ }
+ return x.RepasseVinculo.Incidencia.GetValueOrDefault() == TipoIncidencia.SobreComissao;
+ }).Sum<VinculoRepasse>((VinculoRepasse x) => x.RepasseVinculo.ValorRenovacao) : decimal.Zero);
+ }
+ decimal num7 = num6 + num1;
+ if (num3 > new decimal(100))
+ {
+ keyValuePairs.AddValue<string, string>("RepasseVinculo|VALOR NOVO", "O VALOR DE REPASSE PARA SEGUROS NOVOS ULTRAPASSARÁ 100% DA COMISSÃO RECEBIDA", true);
+ }
+ if (num7 > new decimal(100))
+ {
+ keyValuePairs.AddValue<string, string>("RepasseVinculo|VALOR RENOVAÇÃO", "O VALOR DE REPASSE PARA RENOVAÇÕES ULTRAPASSARÁ 100% DA COMISSÃO RECEBIDA", true);
+ }
+ if (vinculos == null || vinculos.Count <= 0)
+ {
+ return keyValuePairs;
+ }
+ if (this.TipoVendedor != null && this.TipoVendedorVinculo != null && vinculos.Any<VinculoRepasse>((VinculoRepasse x) => {
+ if (x.TipoVendedor.Id != this.TipoVendedor.Id)
+ {
+ return false;
+ }
+ return x.TipoVendedorVinculo.Id == this.TipoVendedorVinculo.Id;
+ }))
+ {
+ keyValuePairs.AddValue<string, string>("TipoVendedorVinculo|TIPO VENDEDOR DO VÍNCULO", string.Concat("JÁ EXISTE UM VINCULO DE REPASSE PARA ", this.TipoVendedorVinculo.Descricao), true);
+ }
+ if (this.TipoVendedor != null && this.RepasseVinculo != null && vinculos.Any<VinculoRepasse>((VinculoRepasse x) => {
+ if (x.TipoVendedor.Id != this.TipoVendedor.Id)
+ {
+ return false;
+ }
+ return x.RepasseVinculo.Vendedor.Id == this.RepasseVinculo.Vendedor.Id;
+ }))
+ {
+ keyValuePairs.AddValue<string, string>("TipoVendedorVinculo|VENDEDOR DO VÍNCULO", string.Concat("JÁ EXISTE UM VINCULO DE REPASSE PARA PARA ", this.RepasseVinculo.Vendedor.Nome), true);
+ }
+ return keyValuePairs;
+ }
+ }
+}
\ No newline at end of file |