public JsonResult FindTransactionsPendingDiet(SearchViewModel model) { var result = new List <ApprovalPendingDietModel>(); var allowReversar = PermissionService.IsFunctionalityAllowed("GestionarAprobaciones.Reversar"); var allowAprobar = PermissionService.IsFunctionalityAllowed("GestionarAprobaciones.Aprobar"); var allowRechazar = PermissionService.IsFunctionalityAllowed("GestionarAprobaciones.Rechazar"); var allowCancelar = PermissionService.IsFunctionalityAllowed("GestionarAprobaciones.Cancelar"); var allowEditar = PermissionService.IsFunctionalityAllowed("GestionarAprobaciones.Editar"); int?conceptId = ConceptService.GetConceptByCode(((int)PaymentConceptEnum.Dieta).ToString()).ConceptId; var payments = PaymentService.FindPaymentsToApprove(model.EBTNumber, model.CaseNumber, model.EntityName, model.SocialSecurityNumber, model.BirthDate, model.FilingDate, model.RegionId, model.DispensaryId, model.From, model.To, model.StatusId, conceptId).ToList(); foreach (var payment in payments) { if (payment.CaseId == null) { continue; } if (payment.CaseDetailId != null) { result.Add(new ApprovalPendingDietModel { CaseId = payment.CaseId.Value, CaseDetailId = payment.CaseDetailId.Value, CaseNumber = payment.CaseNumber, Lesionado = payment.CaseDetail.Entity.FullName, Ssn = payment.CaseDetail.Entity.SSN, FechaNacimiento = payment.CaseDetail.Entity.BirthDate.ToShortDateString(), FechaDecision = payment.IssueDate.ToShortDateString(), Desde = payment.FromDate.ToShortDateString(), Hasta = payment.ToDate.ToShortDateString(), NroDias = payment.PaymentDay.HasValue ? payment.PaymentDay.ToString() : string.Empty, Jornal = payment.Case.DailyWage.ToCurrency(), CompSemanal = payment.Case.WeeklyComp.ToCurrency(), Dieta = payment.Amount.ToCurrency(), Estado = payment.Status.Status1, RazonRechazo = payment.Transaction.IsNull() ? string.Empty : payment.Transaction.RejectedReason, TransactionId = payment.TransactionId, PaymentId = payment.PaymentId, DiasSemana = payment.Case.DaysWeek ?? 0, StatusId = payment.StatusId.Value, AllowAprobar = allowAprobar, AllowCancelar = allowCancelar, AllowEditar = allowEditar && !payment.CaseDetail.CaseFolderId.HasValue, AllowRechazar = allowRechazar, AllowReversar = allowReversar, }); } } return(JsonDataTable(result)); }
public JsonResult FindTransactionsDeath(SearchViewModel model) { var result = new List <ApprovalDeathModel>(); int?conceptId = ConceptService.GetConceptByCode(((int)PaymentConceptEnum.Muerte).ToString()).ConceptId; var allowReversar = this.PermissionService.IsFunctionalityAllowed("GestionarAprobaciones.Reversar"); var allowAprobar = this.PermissionService.IsFunctionalityAllowed("GestionarAprobaciones.Aprobar"); var allowRechazar = this.PermissionService.IsFunctionalityAllowed("GestionarAprobaciones.Rechazar"); var allowCancelar = this.PermissionService.IsFunctionalityAllowed("GestionarAprobaciones.Cancelar"); var allowEditar = this.PermissionService.IsFunctionalityAllowed("GestionarAprobaciones.Editar"); var payments = PaymentService.FindPaymentsToApprove(model.EBTNumber, model.CaseNumber, model.EntityName, model.SocialSecurityNumber, model.BirthDate, model.FilingDate, model.RegionId, model.DispensaryId, model.From, model.To, model.StatusId, conceptId).Where(p => p.Transaction.IsNull()); var groupsCaseIds = payments.DistinctBy(p => p.CaseId); foreach (var parent in groupsCaseIds) { if (parent.CaseId == null) { continue; } var casedetail = CaseService.FindCaseDetailByIdAndKey(parent.CaseId.Value, parent.CaseKey); var lesionado = EntityService.GetById(casedetail.EntityId.Value); var groupPayments = payments.Where(x => x.CaseId != null && x.CaseId.Value == casedetail.CaseId); var transaction = TransactionService.FindTransactionById(parent.TransactionId.Value); if (casedetail.CaseId == null) { continue; } var approvalDeath = new ApprovalDeathModel { CaseId = casedetail.CaseId.Value, CaseDetailId = casedetail.CaseDetailId, CaseNumber = casedetail.CaseNumber, Lesionado = lesionado != null ? lesionado.FullName : string.Empty, Ssn = lesionado != null ? lesionado.SSN : string.Empty, FechaDecision = transaction != null && transaction.DecisionDate != null? transaction.DecisionDate.ToShortDateString() : string.Empty, FechaDefuncion = lesionado != null && lesionado.DeceaseDate != null? lesionado.DeceaseDate.ToShortDateString() : string.Empty, AllowAprobar = true, AllowCancelar = true, AllowEditar = true, AllowRechazar = true, AllowReversar = true }; foreach (var child in groupPayments) { if (child.CaseId == null) { continue; } if (child.CaseDetailId == null) { continue; } if (child.StatusId == null) { continue; } if (child.Amount != null) { var payment = PaymentService.FindPaymentById(child.PaymentId); var entidad = EntityService.GetById(payment.CaseDetail.EntityId.Value); var rel = RelationshipTypeService.GetRelationshipTypes(). Where(m => m.RelationshipCategoryId == child.CaseDetail.RelationshipTypeId).FirstOrDefault(); approvalDeath.Beneficiarios.Add(new ApprovalDeathBeneficiariesModel { CaseId = child.CaseId.Value, CaseDetailId = child.CaseDetailId.Value, CaseNumber = string.Format("{0} {1}", child.CaseNumber, child.CaseDetail != null ? child.CaseDetail.CaseKey : string.Empty), TransactionId = child.TransactionId != null ? child.TransactionId.Value : 0, Beneficiario = entidad.FullName, Ssn = entidad.SSN, FechaNacimiento = entidad.BirthDate.ToShortDateString(), Relacion = rel.RelationshipType1, Estudiante = entidad.IsStudying != null && entidad.IsStudying.Value ? "Si" : "No", Tutor = string.Empty, PagoInicial = child.Amount.Value.ToCurrency(), Reserva = child.CaseDetail.Reserve.ToCurrency(), Mensualidad = child.CaseDetail.MonthlyInstallment.ToCurrency(), MensualidadesVencidas = (child.Amount / child.CaseDetail.MonthlyInstallment).ToString(), TotalAPagar = child.Amount.ToCurrency(), Estatus = child.Status.Status1, EstatusId = child.StatusId.Value }); } } result.Add(approvalDeath); } return(JsonDataTable(result)); }
public JsonResult FindTransactionsIpp(SearchViewModel model) { var result = new List <ApprovalIppModel>(); int?conceptId = ConceptService.GetConceptByCode(((int)PaymentConceptEnum.IPP).ToString()).ConceptId; var transactions = TransactionService.FindTransactionsToApprove(model.EBTNumber, model.CaseNumber, model.EntityName, model.SocialSecurityNumber, model.BirthDate, model.FilingDate, model.RegionId, model.DispensaryId, model.From, model.To, model.DocumentType, model.StatusId, conceptId).ToList(); var allowReversar = PermissionService.IsFunctionalityAllowed("GestionarAprobaciones.Reversar"); var allowAprobar = true; PermissionService.IsFunctionalityAllowed("GestionarAprobaciones.Aprobar"); var allowRechazar = PermissionService.IsFunctionalityAllowed("GestionarAprobaciones.Rechazar"); var allowCancelar = PermissionService.IsFunctionalityAllowed("GestionarAprobaciones.Cancelar"); var allowEditar = PermissionService.IsFunctionalityAllowed("GestionarAprobaciones.Editar"); foreach (var transaction in transactions) { if (transaction.CaseDetail.CaseId == null) { continue; } if (transaction.CaseDetailId == null) { continue; } if (transaction.TransactionDate == null) { continue; } var approvalIppModel = new ApprovalIppModel { TransactionId = transaction.TransactionId, CaseId = transaction.CaseDetail.CaseId.Value, CaseNumber = transaction.CaseDetail.CaseNumber, CaseDetailId = transaction.CaseDetailId.Value, Lesionado = transaction.CaseDetail.Entity.FullName, Ssn = transaction.CaseDetail.Entity.SSN, FechaAdjudicacion = transaction.DecisionDate.HasValue ? transaction.TransactionDate.Value.ToShortDateString() : string.Empty, TipoAdjudicacion = transaction.TransactionTypeId.HasValue ? transaction.TransactionType.TransactionType1 : string.Empty, CantidadAdjudicada = transaction.TransactionAmount.ToCurrency(), PagoInicial = 1500m.ToCurrency(), Mensualidad = transaction.MonthlyInstallment.GetValueOrDefault(decimal.Zero).ToCurrency(), Semanas = transaction.NumberOfWeeks, MensualidadesVencidas = decimal.Zero, AllowAprobar = allowAprobar, AllowCancelar = allowCancelar, AllowEditar = allowEditar && !transaction.CaseDetail.CaseFolderId.HasValue, AllowRechazar = allowRechazar, AllowReversar = allowReversar, RazonRechazo = "" }; if (transaction.Payments.Any()) { approvalIppModel.TotalPagar = transaction.Payments.Sum(p => p.Amount).GetValueOrDefault(decimal.Zero).ToCurrency(); var firstPayment = transaction.Payments.FirstOrDefault(); if (firstPayment != null) { approvalIppModel.Estado = firstPayment.Status.Status1; approvalIppModel.PaymentId = firstPayment.PaymentId; if (firstPayment.StatusId != null) { approvalIppModel.StatusId = firstPayment.StatusId.Value; } } } else { approvalIppModel.TotalPagar = decimal.Zero.ToCurrency(); approvalIppModel.Estado = string.Empty; } result.Add(approvalIppModel); } return(JsonDataTable(result)); }