private void UpdatePagos() { if (this.CanAccept()) { //var part = this.Pagar.Value / this.SelectedPlazo.Value; //this.Primero = Math.Ceiling(part); //var res = this.Primero.Value * (this.SelectedPlazo.Value - 1); //this.Ultimo = this.Pagar.Value - res; //this.PlanPago.Clear(); //var fec = this.Promocion.Fechas.Where(i => i >= this.SelectedPromocion.Value).ToArray(); //for (int i = 0; i < this.SelectedPlazo.Value; i++) //{ // var pp = new Models.PlanPagoItem { // Number = i + 1, // Date = fec[i] // }; // if (i == 0) // { // pp.Amount = this.Primero.Value + this.Promocion.Blindaje; // } // else if ((i + 1) == this.SelectedPlazo.Value) // { // pp.Amount = this.Ultimo.Value; // } // else // { // pp.Amount = this.Primero.Value; // } // this.PlanPago.Add(pp); //} this.PlanPago.Clear(); this.Primero = null; this.Ultimo = null; var request = new Common.Entities.Pago { FormaPago = FormaPago.VA, Importe = this.Pagar.Value, //Vale = i.Vale, Plazos = this.SelectedPlazo, FechaAplicar = this.SelectedPromocion, //ContraVale = i.ContraVale, //Limite = i.Limite, //Negocio = i.Negocio, //NoCuenta = i.NoCuenta }; if (this.Vale.Distribuidor.Electronica) { request.ProductosPlazos = this.Productos .Where(i => i.Item.FormasPago.Where(k => k.FormaPago == this.FormaPago).Any()) .Select(i => new ProductoPlazo { Plazos = i.SelectedPlazo, //Importe = i.Item.Precio Importe = i.Item.FormasPago.Where(k => k.FormaPago == this.FormaPago) .Single().Importe }); } this.IsBusy = true; var detalle = _proxy.GenerarPlanPagosFechas(this.Vale.Distribuidor.Id, request); var count = 0; foreach (var item in detalle) { this.PlanPago.Add(new Models.PlanPagoItem { Number = ++count, Date = item.Key, Amount = item.Value }); } this.IsBusy = false; } else { this.PlanPago.Clear(); this.Primero = null; this.Ultimo = null; } this.ProductosView.Refresh(); }