public LiberateCreditViewModel Liberate(LiberateCreditBindingModel bindingmodel) { LiberateCreditViewModel result = null; var model = new LiberateCreditModel(bindingmodel); bool statusCredit = false; _notificationHandler.Notifications = new List <string>(); if (!model.ValidateLimitValueCredit()) { _notificationHandler.Notifications.Add("Limite máximo excedido"); return(default);
public void ShouldSucessLiberateCredit() { LiberateCreditBindingModel liberateCreditBindingModel = new LiberateCreditBindingModel(); liberateCreditBindingModel.ClientType = ClientTypeEnum.PF; liberateCreditBindingModel.CreditType = CreditTypeEnum.CONSIGNED_CREDIT; liberateCreditBindingModel.CreditValue = 10000; liberateCreditBindingModel.DateFirstDueDate = DateTime.Now.AddDays(15); liberateCreditBindingModel.QuantityParcel = 10; LiberateCreditViewModel liberateCreditViewModel = new LiberateCreditViewModel(); liberateCreditViewModel.InterestValue = 1000; liberateCreditViewModel.TotalValue = 11000; liberateCreditViewModel.StatusType = StatusTypeEnum.Approved; var result = _liberateCreditService.Liberate(liberateCreditBindingModel); result.InterestValue.Should().Be(liberateCreditViewModel.InterestValue); result.TotalValue.Should().Be(liberateCreditViewModel.TotalValue); result.StatusType.Should().Be(liberateCreditViewModel.StatusType); }
public LiberateCreditViewModel LiberateCreditViewModel(bool statusCredit) { LiberateCreditViewModel returnLiberateCredit = new LiberateCreditViewModel(); if (statusCredit) { returnLiberateCredit.InterestValue = 0; returnLiberateCredit.TotalValue = 0; returnLiberateCredit.StatusType = StatusTypeEnum.Recused; } else { int value = Convert.ToInt32(CreditType); double percent = (Convert.ToDouble(value) / 100.00); returnLiberateCredit.InterestValue = Convert.ToDecimal((QuantityParcel * percent) * Convert.ToDouble(CreditValue)); returnLiberateCredit.TotalValue = Convert.ToDecimal((QuantityParcel * percent) * Convert.ToDouble(CreditValue) + Convert.ToDouble(CreditValue));; returnLiberateCredit.StatusType = StatusTypeEnum.Approved; } return(returnLiberateCredit); }