public IActionResult GetById(int id) { var paymentType = _repo.GetById(id); if (paymentType == null) { return(NotFound("No payment type")); } return(Ok(paymentType)); }
private void CreateTransactionTypeRows() { var paymentTypeId = paymentTypeRepository.Add(PAYMENTTYPE_TOADD); var fundTypeId = fundTypeRepository.Add(FUNDTYPE_TOADD); var budgetTypeId = budgetTypeRepository.Add(BUDGETTYPE_TOADD); PAYMENTTYPE = paymentTypeRepository.GetById(paymentTypeId); BUDGETTYPE = budgetTypeRepository.GetById(budgetTypeId); FUNDTYPE = fundTypeRepository.GetById(fundTypeId); }
public AccountStatus CreateAccountStatus(AccountStatusRequest AccountStatus) { var entityToInsert = new AccountStatus() { }; MergeAccountStatus(entityToInsert, AccountStatus); if (entityToInsert.IsPayment()) { var unit = UnitRepository.GetById(AccountStatus.UnitId); var consortium = ConsortiumRepository.GetAll().Where(x => x.Ownership.Id == unit.Ownership.Id).FirstOrDefault(); var dateDay = AccountStatus.StatusDate.Day; var limitDateConfiguration = ConsortiumConfigurationRepository .GetAll().Where(x => x.Consortium.Id == consortium.Id && x.Type.Description == "Día límite pago adelantado") .OrderByDescending(x => x.ConfigurationDate) .FirstOrDefault(); var limitDayValue = limitDateConfiguration != null?Convert.ToInt32(limitDateConfiguration.Value) : 0; if (dateDay <= limitDayValue) { var advancedPaymentConfiguration = ConsortiumConfigurationRepository .GetAll().Where(x => x.Consortium.Id == consortium.Id && x.Type.Description == "Descuento por pago adelantado") .OrderByDescending(x => x.ConfigurationDate) .FirstOrDefault(); var advandedPaymentValue = advancedPaymentConfiguration != null ? advancedPaymentConfiguration.Value : 0; this.RecalculateAmount(entityToInsert, advandedPaymentValue); } } AccountStatusRepository.Insert(entityToInsert); if (entityToInsert.IsPayment()) { var payment = new Payment() { AccountStatus = entityToInsert, PaymentType = PaymentTypeRepository.GetById(AccountStatus.PaymentTypeId.Value) }; PaymentRepository.Insert(payment); var unit = UnitRepository.GetById(AccountStatus.UnitId); var consortium = ConsortiumRepository.GetAll().Where(x => x.Ownership.Id == unit.Ownership.Id).FirstOrDefault(); var actualPatrimonyStatus = this.PatrimonyStatusRepository.GetByConsortiumId(consortium.Id) .OrderByDescending(x => x.StatusDate).FirstOrDefault(); var patrimonyStatus = new PatrimonyStatus() { Activo = actualPatrimonyStatus != null ? actualPatrimonyStatus.Activo + entityToInsert.Haber : entityToInsert.Haber, Debe = 0, Pasivo = actualPatrimonyStatus != null ? actualPatrimonyStatus.Pasivo - entityToInsert.Haber : -entityToInsert.Haber, Haber = entityToInsert.Haber, Consortium = consortium, StatusDate = DateTime.Now }; this.PatrimonyStatusRepository.Insert(patrimonyStatus); //modificar el ultimo estado de cuenta var unitAccount = this.AccountStatusRepository.GetByUnitId(unit.Id).ToList(); var lastSummarizedStatus = unitAccount.Where(x => !x.IsPayment() && !x.Interest).OrderByDescending(x => x.StatusDate).FirstOrDefault(); lastSummarizedStatus.Haber += entityToInsert.Haber; lastSummarizedStatus.Debe -= entityToInsert.Haber; this.AccountStatusRepository.Update(lastSummarizedStatus); } return(entityToInsert); }