Create(CreditDataDto credit) { InfoClientDto infoClientDto = null; (bool valid, HttpStatusCode creditStatus, string creditMsg) = CreateCreditValidations(credit, ref infoClientDto); if (!valid) { return(creditStatus, creditMsg, false); } CreditEntity creditEntity = _mapper.Map <CreditEntity>(credit); ClientEntity clientEntity = _mapper.Map <ClientEntity>(infoClientDto); List <QuotaEntity> quotaEntities = _mapper.Map <List <QuotaEntity> >(credit.Quotas); clientEntity.CupoDisponible = clientEntity.CupoDisponible - credit.CapitalValue; creditEntity.FechaCreacion = ColombianHour.GetDate(); _ = _creditRepository.Create(creditEntity, clientEntity, quotaEntities); return(HttpStatusCode.OK, SuccessMsg, true); }
private List <QuotaDataDto> CalculateQuotas(SimulateQuotasRequest simulateQuotasRequest) { List <QuotaDataDto> reponse = new List <QuotaDataDto>(); int quotaQuantity = simulateQuotasRequest.TermMonths * ((simulateQuotasRequest.Frequency == 15) ? 2 : 1); decimal monthRate = decimal.Parse(_config.GetSection("CommonValues:MonthlyRate").Value); decimal totalQuotaValue = (((simulateQuotasRequest.CapitalValue * monthRate) * simulateQuotasRequest.TermMonths) + simulateQuotasRequest.CapitalValue) / quotaQuantity; decimal quotaCapitalValue = simulateQuotasRequest.CapitalValue / quotaQuantity; for (int i = 1; i <= quotaQuantity; i++) { reponse.Add(new QuotaDataDto { IdQuota = i, CapitalValue = quotaCapitalValue, TotalValue = totalQuotaValue, PaymentDate = ColombianHour.GetDate(). AddDays(((simulateQuotasRequest.Frequency == 15) ? 15 : 30) * i) }); } return(reponse); }