public ActionResult Monobank(InstallmentModel installmentModel) { installmentModel.SumPerMonth = Math.Round((installmentModel.Sum / installmentModel.Duration) + (installmentModel.Sum * (installmentModel.Percent / 100)), 2); installmentModel.FinalSum = installmentModel.SumPerMonth * installmentModel.Duration; installmentModel.OverPayment = installmentModel.FinalSum - installmentModel.Sum; return(View(installmentModel)); }
public ActionResult <InstallmentInfo> Get([FromBody] ApiRequest request) { if (request.PurchasePrice <= 0) { return(BadRequest("price can not be negative or 0")); } return(Ok(InstallmentModel.GetInstallment(request.PurchasePrice, Convert.ToDateTime(request.PurchaseDate)))); }
public async Task CreateAsync(InstallmentModel installment) { using (var context = _msSqlContextFactory.CreateDataContext()) { await context.Installments.AddAsync(_mapper.Map <InstallmentEntity>(installment)); await context.SaveChangesAsync(); } }
private void SetInitialValues() { Installment = new InstallmentModel(); InstallmentProducts = new List <InstallmentProductModel>(); ChoosenProductList_InstallmentOrderUC.ItemsSource = null; ChoosenProductList_InstallmentOrderUC.ItemsSource = InstallmentProducts; Update_CustomerNamesVariablesAndEvents(); UpdateTheCategoriesFromThePublicVariables(); CategoryValue_InstallmentOrderUC.ItemsSource = Categories; CategoryValue_InstallmentOrderUC.DisplayMemberPath = "Name"; CategoryValue_InstallmentOrderUC.SelectedItem = null; UpdateTheBrandsFromThePublicVariables(); BrandValue_InstallmentOrderUC.ItemsSource = Brands; BrandValue_InstallmentOrderUC.DisplayMemberPath = "Name"; BrandValue_InstallmentOrderUC.SelectedItem = null; GetStocksFormThePublicVariables(); ProductValue_InstallmentOrderUC.ItemsSource = null; ProductValue_InstallmentOrderUC.ItemsSource = Stocks; ProductValue_InstallmentOrderUC.DisplayMemberPath = "Product.Name"; ProductValue_InstallmentOrderUC.SelectedItem = null; ClearStockInfo(); // Set the default installment valus PaymentsStartDate_InstallmentOrderUC.DisplayDateStart = DateTime.Now; Installment.Date = DateTime.Now; Installment.PaymentsStartDate = DateTime.Now; Installment.NumberOfMonths = 1; NumberOfMonthsValue_InstallmentOrderUC.Text = Installment.NumberOfMonths.ToString(); Installment.Deposit = 0; DipositValue_InstallmentOrderUC.Text = Installment.Deposit.ToString(); Installment.RateOfInterest = 1.1; RateOfInterestValue_InstallmentOrderUC.Text = Installment.RateOfInterest.ToString(); UpdateInstallmentValues(); }
public static void EditMemberPaymentInstallment(int id, InstallmentModel model) { using (var ctx = new DFAppEntities()) { var installment = ctx.MemberPaymentInstallments.FirstOrDefault(x => x.ID == id); if (installment != null) { if (model.IsPaid.HasValue) { installment.IsPaid = (bool)model.IsPaid; if (installment.IsPaid && !model.PaymentDate.HasValue) { installment.PaymentDate = DateTime.Now; } if (!installment.IsPaid) { installment.PaymentDate = null; } } if (model.PaymentDate.HasValue && installment.IsPaid) { installment.PaymentDate = model.PaymentDate; } if (model.IsCanceled.HasValue) { installment.IsCanceled = (bool)model.IsCanceled; } if (!string.IsNullOrEmpty(model.Note)) { installment.Note = model.Note; } ctx.SaveChanges(); } } }
public ActionResult getInstallmentsData(InstallmentModel data) { var context = new RRRoadwaysDBContext(); int vehicleNumber = Convert.ToInt32(data.VehicleNumber); List <InstallmentReport> griddata = new List <InstallmentReport>(); var installments = context.Installment .Join(context.Vehicle, vc => vc.VehicleId, v => v.Id, (vc, v) => new { Date = vc.InstallmentDate, Vechicle = vc.VehicleId, VechicleNumber = v.VehicleNumber, Month = vc.InstallmentsMonth, Details = vc.InstallmentDetail, Amount = vc.Amount }).Where(c => c.Date.Value.Date >= data.StartDate.Date) .Where(c => c.Date.Value.Date <= data.EndDate.Date) .Where(c => data.VehicleNumber != "-1" ? c.Vechicle == vehicleNumber : 1 == 1).ToList(); if (installments.Count > 0) { foreach (var item in installments) { InstallmentReport obj = new InstallmentReport() { SerialNo = griddata.Count + 1, Date = item.Date.Value.Date, VehicleNumber = item.VechicleNumber, InstallmentMonth = System.Globalization.CultureInfo.InvariantCulture.DateTimeFormat.GetMonthName(Convert.ToInt32(item.Month)), InstallmentDetails = item.Details, Amount = item.Amount, }; griddata.Add(obj); } } return(Json(new { data = griddata }, new Newtonsoft.Json.JsonSerializerSettings())); }
public async Task <(bool IsSuccessful, string Message)> ProcessPaymentAsync(InstallmentModel installment) { decimal previousCompletionAmount; decimal netPrice; var previousInstallment = await _propertyInstallmentPaymentRepository .GetLastInstallmentAsync(installment.ReferralLeadId); // Then purchase already exists this will return the campaign id without creating a new one var referralResult = await _referralClient.ReferralLeadApi.AddRealEstatePurchase(new RealEstatePurchaseRequest { ReferralId = installment.ReferralLeadId, Timestamp = installment.Timestamp }); if (referralResult.ErrorCode != RealEstatePurchaseErrorCode.None) { var message = $"The Referral Real estate creation failed with error code '{referralResult.ErrorCode}'"; _log.Error(message: message, context: installment); return(false, message); } if (previousInstallment == null) { var downPayment = await _downPaymentRepository.GetByReferralLeadIdAsync(installment.ReferralLeadId); if (downPayment == null) { return(false, $"No down-payment for referral '{installment.ReferralLeadId}' was found"); } previousCompletionAmount = 0M; netPrice = downPayment.NetPropertyPrice; } else { previousCompletionAmount = previousInstallment.CompletionAmount; netPrice = previousInstallment.NetPropertyPrice; } installment.PaidAmount = installment.CompletionAmount - previousCompletionAmount; if (installment.PaidAmount <= 0) { const string errorMessage = "Received payment does not increase total paid amount."; _log.Warning(errorMessage, null, new { installment, previousInstallment }); return(true, errorMessage); } await _propertyInstallmentPaymentRepository.CreateAsync(installment); if (!string.IsNullOrEmpty(installment.ReferralLeadId)) { netPrice = installment.NetPropertyPrice != 0 ? installment.NetPropertyPrice : netPrice; var purchaseCompletionPercentage = netPrice != 0 ? (installment.CompletionAmount / netPrice) * 100M : 0; await _referralPaymentEventPublisher.PublishAsync(new ReferralRealEstatePurchasePaymentEvent { CustomerId = installment.ReferrerId, ReferralId = installment.ReferralLeadId, InstallmentAmount = installment.PaidAmount, CurrencyCode = installment.CurrencyCode, NetPropertyAmount = installment.NetPropertyPrice, PurchaseCompletionAmount = installment.CompletionAmount, PurchaseCompletionPercentage = purchaseCompletionPercentage, IsDownPayment = false, CampaignId = referralResult.CampaignId, UnitLocationCode = installment.UnitLocationCode }); } return(true, string.Empty); }
public static void AddMemberPayment(int memberID, MemberPaymentModel model) { // get payment info var paymentInfo = DB.Payments.GetPayment(model.ID); // check discount if (model.DiscountPercentage.HasValue) { model.DiscountAmount = paymentInfo.Amount * (1 - ((decimal)model.DiscountPercentage / 100)); } // generate installments model.Installments = new List <InstallmentModel>(); if (paymentInfo.Type.ToUpper() == "ONE-TIME" || paymentInfo.Type.ToUpper() == "MONTHLY") { if (paymentInfo.NumberOfInstallments == 1) { /* * FULL ONE-TIME PAYMENT - treated as one-time payment with only one installment * * MONTHLY PAYMENTS - treated one-time payments but with installment date changed accordingly * Recurring can go indefinitely if there is no stop date * Service agent is in charge of creating new monthly payments at the beginning of each month * */ decimal installmentAmount = model.DiscountAmount.HasValue ? (decimal)model.DiscountAmount : (decimal)paymentInfo.Amount; if (model.Companions != null && model.Companions.Count() > 0) { foreach (var c in model.Companions) { installmentAmount += (decimal)paymentInfo.AmountForCompanion; } } DateTime?installmentDate = null; if (paymentInfo.Type.ToUpper() == "MONTHLY") { int paymentDay = ((DateTime)paymentInfo.DueDate).Day; installmentDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, paymentDay); } if (paymentInfo.Type.ToUpper() == "ONE-TIME") { installmentDate = (DateTime)paymentInfo.DueDate; } var oneTimePayment = new InstallmentModel() { InstallmentDate = installmentDate, Amount = installmentAmount, IsPaid = false }; model.Installments.Add(oneTimePayment); } if (paymentInfo.NumberOfInstallments > 1) { /* * ONE-TIME PAYMENT WITH INSTALLMENTS */ List <decimal> installmentAmounts = new List <decimal>(); if (!string.IsNullOrEmpty(paymentInfo.InstallmentAmounts)) { if (paymentInfo.InstallmentAmounts.EndsWith(";")) { paymentInfo.InstallmentAmounts = paymentInfo.InstallmentAmounts.Substring(0, paymentInfo.InstallmentAmounts.Length - 1); } installmentAmounts = paymentInfo.InstallmentAmounts.Split(';').Select(x => decimal.Parse(x)).ToList(); } else { for (int xx = 1; xx <= paymentInfo.NumberOfInstallments; xx++) { installmentAmounts.Add((decimal)paymentInfo.Amount / (int)paymentInfo.NumberOfInstallments); } } List <decimal> installmentAmountsForCompanion = new List <decimal>(); if (model.Companions != null && model.Companions.Count() > 0) { if (!string.IsNullOrEmpty(paymentInfo.InstallmentAmountsForCompanion)) { if (paymentInfo.InstallmentAmountsForCompanion.EndsWith(";")) { paymentInfo.InstallmentAmountsForCompanion = paymentInfo.InstallmentAmountsForCompanion.Substring(0, paymentInfo.InstallmentAmountsForCompanion.Length - 1); } installmentAmountsForCompanion = paymentInfo.InstallmentAmountsForCompanion.Split(';').Select(x => decimal.Parse(x)).ToList(); } else { for (int xx = 1; xx <= paymentInfo.NumberOfInstallments; xx++) { installmentAmountsForCompanion.Add((decimal)paymentInfo.AmountForCompanion / (int)paymentInfo.NumberOfInstallments); } } } decimal totalAmount = (decimal)paymentInfo.Amount; if (model.DiscountPercentage.HasValue) { totalAmount = totalAmount * (1 - ((decimal)model.DiscountPercentage / 100)); installmentAmounts = installmentAmounts.Select(x => x * (1 - ((decimal)model.DiscountPercentage / 100))).ToList(); } for (int i = 0; i < paymentInfo.NumberOfInstallments; i++) { // DateTime paymentDate = new DateTime(DateTime.Now.Year, ((DateTime)paymentInfo.DueDate).Month, ((DateTime)paymentInfo.DueDate).Day); DateTime paymentDate = (DateTime)paymentInfo.DueDate; DateTime installmentDate = (i == 0) ? paymentDate : paymentDate.AddMonths(i); decimal installmentAmount = installmentAmounts.ElementAt(i); if (model.Companions != null && model.Companions.Count() > 0) { foreach (var c in model.Companions) { installmentAmount += installmentAmountsForCompanion.ElementAt(i); } } var installment = new InstallmentModel() { InstallmentDate = installmentDate, Amount = installmentAmount, IsPaid = false }; model.Installments.Add(installment); } } } DB.Members.AddMemberPayment(memberID, model); }
public void EditMemberPaymentInstallment(int installmentID, InstallmentModel model) { DB.Members.EditMemberPaymentInstallment(installmentID, model); }
public async Task <IActionResult> Installment(InstallmentModel model) { var installments = await _dataServices.GetPosInstallments(model.BinNumber); return(new JsonResult(installments)); }