summaryrefslogtreecommitdiff
path: root/Gestor.Model/Gestor.Model.Domain.Seguros/Parcela.cs
diff options
context:
space:
mode:
authorLucas Faria Mendes <lucas.fariamo08@gmail.com>2026-03-30 17:17:46 +0000
committerLucas Faria Mendes <lucas.fariamo08@gmail.com>2026-03-30 17:17:46 +0000
commit0440c722a221b8068bbf388c1c0c51f0faff0451 (patch)
tree169cbf90c50ff7961db82ecb606c50c2a45a1688 /Gestor.Model/Gestor.Model.Domain.Seguros/Parcela.cs
parent225aa1499e37faf9d38257caabbadc68d78b427e (diff)
downloadgestor-master.tar.gz
gestor-master.zip
some dllsHEADmaster
Diffstat (limited to 'Gestor.Model/Gestor.Model.Domain.Seguros/Parcela.cs')
-rw-r--r--Gestor.Model/Gestor.Model.Domain.Seguros/Parcela.cs389
1 files changed, 389 insertions, 0 deletions
diff --git a/Gestor.Model/Gestor.Model.Domain.Seguros/Parcela.cs b/Gestor.Model/Gestor.Model.Domain.Seguros/Parcela.cs
new file mode 100644
index 0000000..00fbedf
--- /dev/null
+++ b/Gestor.Model/Gestor.Model.Domain.Seguros/Parcela.cs
@@ -0,0 +1,389 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Linq;
+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.Seguros;
+
+public class Parcela : DomainBase, IDomain
+{
+ private string _extrato;
+
+ private string _fatura;
+
+ [Log(true)]
+ [ForceLog(true)]
+ [Description("STATUS PAGAMENTO")]
+ private StatusPagamento? _statusPagamento;
+
+ private bool _percentualmaiorque100;
+
+ private bool _alteracao;
+
+ private bool _permitirVencimentoMenor;
+
+ private bool _permitirVencimentoMaior;
+
+ public bool Baixando { get; set; }
+
+ public long IdEmpresa { get; set; }
+
+ [Log(false)]
+ [ForceLog(true)]
+ public Documento Documento { get; set; }
+
+ [Log(true)]
+ [ForceLog(true)]
+ [Description("PARCELA")]
+ public int NumeroParcela { get; set; }
+
+ [Log(true)]
+ [ForceLog(true)]
+ [Description("VENCIMENTO")]
+ public DateTime Vencimento { get; set; }
+
+ [Log(true)]
+ [ForceLog(true)]
+ [Description("RECEBIMENTO")]
+ public DateTime? DataRecebimento { get; set; }
+
+ [Log(true)]
+ [ForceLog(true)]
+ [Description("QUITAÇÃO")]
+ public DateTime? DataQuitacao { get; set; }
+
+ [Log(true)]
+ [ForceLog(true)]
+ [Description("CONTROLE")]
+ public DateTime? DataControle { get; set; }
+
+ [Log(true)]
+ [ForceLog(true)]
+ [Description("CRÉDITO")]
+ public DateTime? DataCredito { get; set; }
+
+ [Log(true)]
+ [ForceLog(true)]
+ [Description("VALOR")]
+ public decimal Valor { get; set; }
+
+ public decimal ValorPago { get; set; }
+
+ [Log(true)]
+ [ForceLog(true)]
+ [Description("VALOR PARCELA EXTRATO")]
+ public decimal ValorRealizado { get; set; }
+
+ [Log(true)]
+ [ForceLog(true)]
+ [Description("COMISSÃO")]
+ public decimal Comissao { get; set; }
+
+ [Log(true)]
+ [ForceLog(true)]
+ [Description("VALOR DE COMISSÃO")]
+ public decimal ValorComissao { get; set; }
+
+ public string Observacao { get; set; }
+
+ [Log(true)]
+ [ForceLog(true)]
+ [Description("EXTRATO")]
+ public string Extrato
+ {
+ get
+ {
+ return _extrato?.ToUpper();
+ }
+ set
+ {
+ _extrato = value;
+ }
+ }
+
+ [Log(true)]
+ [ForceLog(true)]
+ [Description("IR")]
+ public decimal Irr { get; set; }
+
+ [Log(true)]
+ [ForceLog(true)]
+ [Description("ISS")]
+ public decimal Iss { get; set; }
+
+ [Log(true)]
+ [ForceLog(true)]
+ [Description("OUTROS")]
+ public decimal Outros { get; set; }
+
+ [Log(true)]
+ [ForceLog(true)]
+ [Description("DESCONTO")]
+ public decimal Desconto { get; set; }
+
+ public decimal ValorExtrato { get; set; }
+
+ [Log(true)]
+ [ForceLog(true)]
+ [Description("COMISSÃO LÍQUIDA")]
+ public decimal ValorComDesconto { get; set; }
+
+ [Log(true)]
+ [ForceLog(true)]
+ [Description("TIPO DA PARCELA")]
+ public SubTipo SubTipo { get; set; }
+
+ public TipoPagamento TipoPagamento { get; set; }
+
+ [Log(true)]
+ [ForceLog(true)]
+ [Description("VALOR LÍQUIDO FATURA")]
+ public decimal ValorLiquidoFatura { get; set; }
+
+ [Log(true)]
+ [ForceLog(true)]
+ [Description("FATURA")]
+ public string Fatura
+ {
+ get
+ {
+ return _fatura?.ToUpper().Trim();
+ }
+ set
+ {
+ _fatura = value;
+ }
+ }
+
+ [Log(true)]
+ [ForceLog(true)]
+ [Description("INÍCIO FATURA")]
+ public DateTime? VigenciaIncial { get; set; }
+
+ [Log(true)]
+ [ForceLog(true)]
+ [Description("FIM FATURA")]
+ public DateTime? VigenciaFinal { get; set; }
+
+ [Log(true)]
+ [ForceLog(true)]
+ [Description("EMISSÃO FATURA")]
+ public DateTime? Emissao { get; set; }
+
+ [Log(false)]
+ public DateTime? DataCriacao { get; set; }
+
+ [Log(false)]
+ public long UsuarioCriacao { get; set; }
+
+ [Log(false)]
+ public StatusPagamento? StatusPagamento
+ {
+ get
+ {
+ return _statusPagamento;
+ }
+ set
+ {
+ _statusPagamento = value.GetValueOrDefault();
+ }
+ }
+
+ [Log(false)]
+ public long IdParcelaPendente { get; set; }
+
+ [Log(false)]
+ public ObservableCollection<VendedorParcela> Vendedores { get; set; }
+
+ [JsonIgnore]
+ public Func<List<KeyValuePair<string, string>>> ValidationEvent => Validate;
+
+ public List<KeyValuePair<string, string>> Validate(bool permitirVencimentoMenor, bool permitirVencimentoMaior, bool alteracao = false, bool percentualmaiorque100 = false)
+ {
+ _permitirVencimentoMenor = permitirVencimentoMenor;
+ _permitirVencimentoMaior = permitirVencimentoMaior;
+ _alteracao = alteracao;
+ _percentualmaiorque100 = percentualmaiorque100;
+ return Validate();
+ }
+
+ public List<KeyValuePair<string, string>> Validate()
+ {
+ List<KeyValuePair<string, string>> list = ValidationHelper.AddValue();
+ if (Emissao.HasValue && (DateTime.Compare(Emissao.Value, new DateTime(1753, 1, 1)) < 0 || DateTime.Compare(Emissao.Value, new DateTime(9999, 12, 31)) > 0))
+ {
+ list.AddValue("Emissao|EMISSÃO", string.Format(Messages.DataInvalida));
+ }
+ if (VigenciaFinal.HasValue && (DateTime.Compare(VigenciaFinal.Value, new DateTime(1753, 1, 1)) < 0 || DateTime.Compare(VigenciaFinal.Value, new DateTime(9999, 12, 31)) > 0))
+ {
+ list.AddValue("VigenciaFinal|VIGÊNCIA FINAL", string.Format(Messages.DataInvalida));
+ }
+ if (VigenciaIncial.HasValue && (DateTime.Compare(VigenciaIncial.Value, new DateTime(1753, 1, 1)) < 0 || DateTime.Compare(VigenciaIncial.Value, new DateTime(9999, 12, 31)) > 0))
+ {
+ list.AddValue("VigenciaIncial|VIGÊNCIA INICIAL", string.Format(Messages.DataInvalida));
+ }
+ if (DataCredito.HasValue && (DateTime.Compare(DataCredito.Value, new DateTime(1753, 1, 1)) < 0 || DateTime.Compare(DataCredito.Value, new DateTime(9999, 12, 31)) > 0))
+ {
+ list.AddValue("DataCredito|DATA DE CRÉDITO", string.Format(Messages.DataInvalida));
+ }
+ if (DataRecebimento.HasValue && (DateTime.Compare(DataRecebimento.Value, new DateTime(1753, 1, 1)) < 0 || DateTime.Compare(DataRecebimento.Value, new DateTime(9999, 12, 31)) > 0))
+ {
+ list.AddValue("DataRecebimento|DATA RECEBIMENTO", 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 (NumeroParcela == 0)
+ {
+ list.AddValue("NumeroParcela|NÚMERO DA PARCELA", Messages.Obrigatorio);
+ }
+ if (Valor == 0m)
+ {
+ list.AddValue("Valor", Messages.Obrigatorio);
+ }
+ if (Comissao == 0m && Documento.TipoRecebimento.GetValueOrDefault() != TipoRecebimento.Fatura)
+ {
+ list.AddValue("Comissao|COMISSÃO", Messages.Obrigatorio);
+ }
+ if (Comissao > 100m && (Documento.TipoRecebimento.GetValueOrDefault() != TipoRecebimento.Fatura || !_percentualmaiorque100))
+ {
+ list.AddValue("Comissao|% COMISSÃO", "MAIOR QUE 100%");
+ }
+ if (DataRecebimento.HasValue && !DataCredito.HasValue)
+ {
+ list.AddValue("DataCredito|DATA DE CRÉDITO", Messages.Obrigatorio);
+ }
+ if (DataCredito.HasValue && !DataRecebimento.HasValue)
+ {
+ list.AddValue("DataRecebimento|DATA RECEBIMENTO", Messages.Obrigatorio);
+ }
+ if (Baixando)
+ {
+ if (!DataRecebimento.HasValue)
+ {
+ list.AddValue("DataRecebimento|DATA DE RECEBIMENTO", Messages.Obrigatorio);
+ }
+ if (!DataCredito.HasValue)
+ {
+ list.AddValue("DataCredito|DATA DE CRÉDITO", Messages.Obrigatorio);
+ }
+ }
+ if (!_alteracao && (DataCredito.HasValue || DataRecebimento.HasValue) && ValorRealizado == 0m)
+ {
+ list.AddValue("ValorRealizado|VALOR REALIZADO", Messages.Obrigatorio);
+ }
+ if (Documento.TipoRecebimento.GetValueOrDefault() != TipoRecebimento.Fatura && SubTipo == SubTipo.ParcelaNormal)
+ {
+ if (Documento.NumeroParcelas == 1m)
+ {
+ decimal num = Math.Abs(Valor);
+ decimal value = Math.Abs(Documento.PremioTotal);
+ decimal? obj = Documento.Controle?.Seguradora?.Tolerancia;
+ decimal? num2 = (decimal?)value + obj;
+ if ((num > num2.GetValueOrDefault()) & num2.HasValue)
+ {
+ list.AddValue("Valor", Messages.ValorParcelaInvalido);
+ }
+ }
+ else
+ {
+ decimal num3 = Math.Abs(Valor);
+ decimal value2 = Math.Abs(Documento.PremioTotal);
+ decimal? obj2 = Documento.Controle?.Seguradora?.Tolerancia;
+ decimal? num2 = (decimal?)value2 + obj2 - (decimal?)Documento.NumeroParcelas;
+ if ((num3 > num2.GetValueOrDefault()) & num2.HasValue)
+ {
+ decimal valor = Valor;
+ num2 = Documento.Controle?.Seguradora?.Tolerancia;
+ if ((valor > num2.GetValueOrDefault()) & num2.HasValue)
+ {
+ list.AddValue("Valor", Messages.ValorParcelaInvalido);
+ }
+ }
+ }
+ }
+ if (Documento.TipoRecebimento.GetValueOrDefault() != TipoRecebimento.Fatura && SubTipo == SubTipo.ParcelaNormal && Documento.Parcelas != null && Documento.NumeroParcelas == (decimal)Documento.Parcelas.Count && Math.Abs(Documento.Parcelas.Where((Parcela x) => x.SubTipo == SubTipo.ParcelaNormal).Sum((Parcela x) => x.Valor)) > Math.Abs(Documento.PremioTotal) + (Documento.Controle?.Seguradora?.Tolerancia).GetValueOrDefault() && (decimal)NumeroParcela == Documento.NumeroParcelas)
+ {
+ list.AddValue("Valor", Messages.ValorParcelaInvalido);
+ }
+ if (!_permitirVencimentoMaior && Documento.Vigencia2.HasValue)
+ {
+ DateTime vencimento = Vencimento;
+ DateTime? vigencia = Documento.Vigencia2;
+ if (vigencia.HasValue && vencimento > vigencia.GetValueOrDefault() && Documento.Controle.Ramo.Id != 23)
+ {
+ list.AddValue("Vencimento", Messages.VencimentoMaior);
+ }
+ }
+ if (!_permitirVencimentoMenor && ((Documento.Vigencia1 > DateTime.MinValue && NumeroParcela == 1 && Vencimento < Documento.Vigencia1.AddDays(-30.0)) || (NumeroParcela != 1 && Vencimento < Documento.Vigencia1)))
+ {
+ list.AddValue("Vencimento", Messages.VencimentoMenor);
+ }
+ if (Documento == null || Documento.TipoRecebimento.GetValueOrDefault() != TipoRecebimento.Fatura)
+ {
+ return list;
+ }
+ if (string.IsNullOrWhiteSpace(Fatura))
+ {
+ list.AddValue("Fatura", Messages.Obrigatorio);
+ }
+ else if (Fatura.Length > 50)
+ {
+ list.AddValue("Fatura", string.Format(Messages.MaiorQueLimite, 255));
+ }
+ if (ValorLiquidoFatura == 0m)
+ {
+ list.AddValue("ValorLiquidoFatura|VALOR LÍQUIDO DA FATURA", Messages.Obrigatorio);
+ }
+ if (!VigenciaIncial.HasValue)
+ {
+ list.AddValue("VigenciaIncial|VIGÊNCIA INICIAL", Messages.Obrigatorio);
+ }
+ if (!VigenciaFinal.HasValue)
+ {
+ list.AddValue("VigenciaFinal|VIGÊNCIA FINAL", Messages.Obrigatorio);
+ }
+ if (!Emissao.HasValue)
+ {
+ list.AddValue("Emissao|EMISSÃO", Messages.Obrigatorio);
+ }
+ if (!string.IsNullOrWhiteSpace(Extrato) && Extrato.Length > 50)
+ {
+ list.AddValue("Extrato", string.Format(Messages.MaiorQueLimite, 50));
+ }
+ if (VigenciaFinal.HasValue && Documento.Vigencia2.HasValue)
+ {
+ DateTime? vigencia = VigenciaFinal;
+ DateTime? vigencia2 = Documento.Vigencia2;
+ if ((vigencia.HasValue & vigencia2.HasValue) && vigencia.GetValueOrDefault() > vigencia2.GetValueOrDefault() && !_permitirVencimentoMaior)
+ {
+ list.AddValue("VigenciaFinal|VIGÊNCIA FINAL", Messages.VencimentoMaior);
+ }
+ }
+ if (!DataRecebimento.HasValue && ValorComissao != 0m && Documento.TipoRecebimento.GetValueOrDefault() == TipoRecebimento.Fatura)
+ {
+ list.AddValue("DataRecebimento|DATA RECEBIMENTO", Messages.Obrigatorio);
+ }
+ if (Documento.TipoRecebimento.GetValueOrDefault() != TipoRecebimento.Fatura && Documento.Parcelas != null && Documento.Parcelas.Any((Parcela x) => x.NumeroParcela < NumeroParcela && !x.DataRecebimento.HasValue))
+ {
+ list.AddValue("DataRecebimento|DATA RECEBIMENTO", Messages.BaixaInvalida);
+ }
+ if (DataRecebimento.HasValue && ValorComissao != 0m && Documento.TipoRecebimento.GetValueOrDefault() == TipoRecebimento.Fatura)
+ {
+ decimal num4 = ((ValorExtrato == 0m) ? ValorLiquidoFatura : ValorExtrato);
+ if (((num4 > 0m) ? num4.CompareTo(ValorComissao) : ValorComissao.CompareTo(num4)) < 0)
+ {
+ list.AddValue("ValorComissao|RECEBIDO", "VALOR RECEBIDO MAIOR QUE VALOR PARCELA");
+ }
+ }
+ return list;
+ }
+}