public ActionResult VencimientosLinAddNew([ModelBinder(typeof(DevExpressEditorsBinder))] FacturasComprasVencimientosModel item, string id)
        {
            var model = Session[sessionvencimientos] as List <FacturasComprasVencimientosModel>;

            try
            {
                if (ModelState.IsValid)
                {
                    var max = model.Any() ? model.Max(f => f.Id) : 0;
                    item.Id = max + 1;
                    item.Diasvencimiento    = item.Diasvencimiento;
                    item.Fechavencimiento   = item.Fechavencimiento;
                    item.Importevencimiento = item.Importevencimiento;
                    using (var facturasService = new FacturasComprasService(ContextService))
                        facturasService.GetVencimiento(Session[sessioncabecera] as FacturasComprasModel, model, item);
                    model.Add(item);
                    Session[sessionvencimientos] = model;
                }
            }
            catch (ValidationException)
            {
                model.Remove(item);
                throw;
            }
            return(PartialView("_vencimientoslin", model));
        }
        public ActionResult VencimientosLinUpdate([ModelBinder(typeof(DevExpressEditorsBinder))] FacturasComprasVencimientosModel item, string id)
        {
            var model = Session[sessionvencimientos] as List <FacturasComprasVencimientosModel>;

            try
            {
                if (ModelState.IsValid)
                {
                    var editItem = model.Single(f => f.Id == item.Id);
                    editItem.Diasvencimiento    = item.Diasvencimiento;
                    editItem.Fechavencimiento   = item.Fechavencimiento;
                    editItem.Importevencimiento = item.Importevencimiento;
                    using (var facturasService = new FacturasComprasService(ContextService))
                        facturasService.GetVencimiento(Session[sessioncabecera] as FacturasComprasModel, model, editItem);
                    Session[sessionvencimientos] = model;
                }
            }
            catch (ValidationException)
            {
                throw;
            }

            return(PartialView("_vencimientoslin", model));
        }
        public void GetVencimiento(FacturasComprasModel cabecera, List <FacturasComprasVencimientosModel> lineas, FacturasComprasVencimientosModel item)
        {
            var formapagoService   = FService.Instance.GetService(typeof(FormasPagoModel), _context) as FormasPagoService;
            var formapagoObj       = formapagoService.get(cabecera.Fkformaspago.ToString()) as FormasPagoModel;
            var proveedoresService = FService.Instance.GetService(typeof(ProveedoresModel), _context) as ProveedoresService;
            var clienteObj         = proveedoresService.get(cabecera.Fkproveedores) as ProveedoresModel;
            var monedasService     = FService.Instance.GetService(typeof(MonedasModel), _context) as MonedasService;
            var monedasObj         = monedasService.get(cabecera.Fkmonedas.ToString()) as MonedasModel;

            var diafijo1     = clienteObj.Diafijopago1;
            var diafijo2     = clienteObj.Diafijopago2;
            var fechaFactura = cabecera.Fechadocumento;
            var decimales    = monedasObj.Decimales;

            item.Fechavencimiento = GetFechavencimiento(fechaFactura.Value, item.Diasvencimiento.Value, diafijo1,
                                                        diafijo2, formapagoObj.ExcluirFestivos);
            item.Importevencimiento = Math.Round(item.Importevencimiento.Value, decimales);
            item.Decimalesmonedas   = monedasObj.Decimales;
        }