public List <LineaDetalle> ParsearLineas(List <LineaDetalleSistema> lineasSistema) { var felLineas = new List <LineaDetalle>(); var cont = 0; LineaDetalle lnFel; foreach (var linea in lineasSistema) { lnFel = new LineaDetalle { Cantidad = linea.Cantidad, Codigo = new CodigoType[] { new CodigoType { Codigo = linea.Codigo, Tipo = ModFunciones.ObtenerValorEnumerador(linea.TipoCodigo, CodigoType.TipoType.Item99) } }, Detalle = linea.Detalle, NumeroLinea = (cont + 1).ToString(), UnidadMedida = ModFunciones.ObtenerValorEnumerador(linea.UnidadMedida, LineaDetalle.UnidadMedidaType.Unid), MontoDescuento = linea.MontoDescuento, MontoDescuentoSpecified = linea.MontoDescuento > 0, NaturalezaDescuento = linea.NaturalezaDescuento, NaturalezaDescuentoSpecified = !string.IsNullOrEmpty(linea.NaturalezaDescuento), MontoTotal = linea.MontoTotal, MontoTotalLinea = linea.MontoTotalLinea, PrecioUnitario = linea.PrecioUnitario, SubTotal = linea.SubTotal }; ParsearImpuesto(lnFel, linea); felLineas.Add(lnFel); cont++; } return(felLineas); }
protected void ASPxGridView1_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e) { try { using (var conexion = new DataModelFE()) { DetalleServicio detalleServicio = (DetalleServicio)Session["detalleServicio"]; var id = e.Values["codigo.codigo"].ToString(); LineaDetalle dato = detalleServicio.lineaDetalle.Where(x => x.codigo.codigo == id).FirstOrDefault(); detalleServicio.lineaDetalle.Remove(dato); //esto es para el manero del devexpress e.Cancel = true; this.ASPxGridView1.CancelEdit(); } } catch (Exception ex) { throw new Exception(Utilidades.validarExepcionSQL(ex), ex.InnerException); } finally { //refescar los datos this.refreshData(); } }
public HttpResponseMessage Put(FormDataCollection form) { Models.Factura factura = new Factura(); Models.DetalleServicio detalleservicio = new DetalleServicio(); factura.CodigoActividad1 = form.Get("CodActividad"); factura.Clave1 = form.Get("Clave"); factura.NumeroConsecutivo1 = form.Get("NumConsecutivo"); factura.FechaEmision1 = Convert.ToDateTime(form.Get("FechaEmision")); Identificacion idemisor = new Identificacion(); idemisor.Numero1 = form.Get("Emisor"); Persona emisor = new Persona(); emisor.IdentificacionNumero1 = idemisor; factura.EmisorPersona1 = emisor; Identificacion idreceptor = new Identificacion(); idreceptor.Numero1 = form.Get("Receptor"); Persona receptor = new Persona(); receptor.IdentificacionNumero1 = idreceptor; factura.ReceptorPersona1 = receptor; factura.CondicionVenta1 = form.Get("CondVenta"); factura.PlazoCredito1 = form.Get("PlazoCredito"); factura.MedioPago1 = form.Get("MedioPago"); var msgadevolver = factura.Insert_Factura(); DetalleServicio detalleservicio1 = new DetalleServicio(); detalleservicio1.Clave1 = factura; JArray jObject = JArray.Parse(form.Get("LineaDetalleFactura")); JToken jUser3 = jObject; var lista = jUser3.ToObject <List <lineadetalle_local> >(); List <LineaDetalle> listalineadetalleobj = new List <LineaDetalle>(); foreach (lineadetalle_local item in lista) { LineaDetalle lineadetalle = new LineaDetalle(); lineadetalle.Consecutivo1 = Convert.ToInt32(item.Consecutivo1); listalineadetalleobj.Add(lineadetalle); } detalleservicio1.LineaDetalleFactura1 = listalineadetalleobj; detalleservicio1.Insert_DetalleServicio(); string[] respuesta = new string[2]; respuesta[0] = msgadevolver; respuesta[1] = form.Get("Clave"); HttpResponseMessage response = Request.CreateResponse <string[]>(HttpStatusCode.Created, respuesta); return(response); }
public void InsertarLineaDetalle(LineaDetalle lD_linea) { using (ModeloDB db = new ModeloDB()) { db.LineaDetalle.Add(lD_linea); db.SaveChanges(); } }
public HttpResponseMessage Get() { LineaDetalle lineadetalle = new LineaDetalle(); HttpResponseMessage response = Request.CreateResponse <List <Models.LineaDetalle> >(HttpStatusCode.Created, lineadetalle.Select_Todo_LineaDetalle()); return(response); }
public HttpResponseMessage Get([FromUri] int id) { LineaDetalle lineadetalle = new LineaDetalle(); lineadetalle.Consecutivo1 = id; HttpResponseMessage response = Request.CreateResponse <Models.LineaDetalle>(HttpStatusCode.Created, lineadetalle.Select_LineaDetalle()); return(response); }
public static Resultado InsertarLinea(LineaDetalle lineaDetalle) { try { return(ProductosDAL.InsertarLinea(lineaDetalle)); } catch (Exception) { throw; } }
public HttpResponseMessage Delete(FormDataCollection form) { LineaDetalle lineadetalle = new LineaDetalle(); lineadetalle.Consecutivo1 = Convert.ToInt32(form.Get("Consecutivo")); string[] respuesta = new string[2]; respuesta[0] = lineadetalle.Delete_LineaDetalle(); respuesta[1] = form.Get("Consecutivo"); HttpResponseMessage response = Request.CreateResponse <string[]>(HttpStatusCode.Created, respuesta); return(response); }
public void addList(String strNumeroFactura, String strNumeroLinea, String strCodigo, String strPrecio, String strCantidad) { LineaDetalle linea = new LineaDetalle { IdFactura = Int64.Parse(strNumeroFactura), IdLineaDetalle = Int64.Parse(strNumeroLinea), Codigo = Int64.Parse(strCodigo), Precio = Decimal.Parse(strPrecio), Cantidad = Int32.Parse(strCantidad) }; listaDetalle.Add(linea); }
private void newLinea() { LineaDetalle lineaActual = new LineaDetalle(); ListaDeProductos productos = new ListaDeProductos(); resetConsole(); int cont; do { Console.Write("Código producto: "); int codigo = Convert.ToInt32(Console.ReadLine()); cont = 1; do { if (cont <= productos.Count && productos.Get(cont).Codigo != codigo) { cont++; } }while (cont <= productos.Count && productos.Get(cont).Codigo != codigo); if (cont == productos.Count + 1) { Console.WriteLine("Invalid product try again"); } else { lineaActual.ProductoActual = productos.Get(cont); } } while (lineaActual.ProductoActual == null); Console.Write("Cantidad: "); try { lineaActual.Cantidad = Convert.ToInt32(Console.ReadLine()); } catch (Exception) { Console.WriteLine("Invalid option set 1"); lineaActual.Cantidad = 1; } Facturas.Get(Index).Lineas.Add(lineaActual); }
private void ParsearImpuesto(LineaDetalle lnFel, LineaDetalleSistema linea) { if (!Validador.HayImpuestosDeSistema(linea.Impuesto)) { return; } var imp = new List <Impuesto>(); linea.Impuesto.ForEach(i => { imp.Add(new Impuesto { Monto = i.Monto, Tarifa = i.Tarifa, Codigo = ModFunciones.ObtenerValorEnumerador(i.Codigo, Impuesto.ImpuestoCodigo.Item99), Exoneracion = ParsearExoneracion(i.Exoneracion) }); }); lnFel.Impuesto = imp.ToArray(); }
private void ParsearImpuesto(LineaDetalle lnFel, LineaDetalleSistema linea) { var imp = new List <Impuesto>(); linea.Impuesto.ForEach(i => { imp.Add(new Impuesto { Codigo = ModFunciones.ObtenerValorEnumerador(i.Codigo, Impuesto.ImpuestoCodigo.Item99), CodigoTarifa = ModFunciones.ObtenerValorEnumerador(i.CodigoTarifa, Impuesto.ImpuestoTypeCodigoTarifa.Item01), Tarifa = i.Tarifa, FactorIVASpecified = i.FactorIVA > 0, FactorIVA = i.FactorIVA, Monto = i.Monto, Exoneracion = ParsearExoneracion(i.Exoneracion) }); }); lnFel.Impuesto = imp.ToArray(); }
public void EliminarCliente(String cedula) { using (ModeloDB db = new ModeloDB()) { /* Selecciona al cliente */ var cliente = from c in db.Cliente where c.Cedula == cedula select c; /* Si existe algun cliente con esa cedula*/ if (cliente.Any <Cliente>()) { //selecciona un unico cliente var clienteAux = cliente.Single <Cliente>(); int tamañoListaC = clienteAux.Factura.Count(); for (int i = tamañoListaC - 1; i >= 0; i--) { Factura facturaActual = clienteAux.Factura.ElementAt <Factura>(i); int tamañoListaF = facturaActual.LineaDetalle.Count(); for (int j = tamañoListaF - 1; j >= 0; j--) { LineaDetalle detalle = facturaActual.LineaDetalle.ElementAt <LineaDetalle>(j); db.LineaDetalle.Remove(detalle); } db.Factura.Remove(facturaActual); } db.Cliente.Remove(clienteAux); db.SaveChanges(); } } }
public async Task <IActionResult> EnviarFacturaElectronicaAsync(int transID) { var dbContext = this._context.TransaccionHeaders.Include(d => d.TransDetails).Where(t => t.TransID == transID); if (dbContext == null) { return(NotFound()); } var transaccion = dbContext.ToList().FirstOrDefault(); if (transaccion == null) { return(NotFound()); } if (transaccion != null && !transaccion.EnviadaHacienda) { Datos datos = new Datos(); string consecutivo = datos.CreaNumeroSecuencia("1", "1", "01", "00000019"); //string consecutivo = datos.CreaNumeroSecuencia("1", "1", "01", transaccion.TransIdStr); DateTime date = DateTime.Now; //string codigoSeguridad = datos.CreaCodigoSeguridad("01", "1", "1", date, transaccion.TransIdStr); string codigoSeguridad = datos.CreaCodigoSeguridad("01", "1", "1", date, "00000019"); string clave = datos.CreaClave("506", date.Day.ToString(), date.Month.ToString(), date.Year.ToString(), "207030159", consecutivo, "1", codigoSeguridad); Cliente client = this._context.Clientes.FirstOrDefault(cliente => cliente.ID == transaccion.ClienteID); EmisorModel.Emisor emi = this._context.Emisor.FirstOrDefault(emisor => emisor.ID > 0); if (client != null && emi != null) { //string rutaCertificado = "C:\\ATV Alexis\\Llave Criptografica (firma) stag\\020703015917.p12"; string rutaCertificado = emi.RutaArchivoCertificado; //string rutaOutput = "C:\\OutputFiles\\"; string rutaOutput = emi.OutputFolder; Receptor receptor = new Receptor(client.NombreCompleto, "01", client.CedulaSinGuiones, "506", client.Telefono.Replace("-", string.Empty), client.Email); Emisor emisor = new Emisor(emi.NombreCompleto, emi.TipoIdentificacion, emi.NumeroIdentificacion, emi.Provincia, emi.Canton, emi.Distrito, emi.Barrio, emi.OtrasSenas, emi.CodigoPaisTelefono, emi.NumeroTelefono, emi.CorreoElectronico, rutaCertificado, emi.PinCertificado, emi.UsuarioApi.Trim(), emi.ClaveApi.Trim(), emi.OutputFolder); int numeroLinea = 0; List <LineaDetalle> listaDetalles = new List <LineaDetalle>(); foreach (TransaccionDetail det in transaccion.TransDetails) { LineaDetalle detalle = new LineaDetalle(); detalle.NumeroLinea = ++numeroLinea; detalle.ArticuloTipo = "03"; detalle.ArticuloCodigo = det.VINVehiculo; detalle.Cantidad = 1; detalle.UnidadMedida = "Sp"; detalle.DetalleArticulo = "venta de vehiculo " + det.VINVehiculo; detalle.PrecioUnitario = Convert.ToDouble(det.PrecioAcordado); detalle.MontoDescuento = 0; detalle.NaturalezaDescuento = "0"; detalle.ImpuestoCodigo = "07"; detalle.ImpuestoTarifa = 0; detalle.isGravado = false; detalle.isServicio = true; listaDetalles.Add(detalle); } CustomFacturaElectronicaCR fact = new CustomFacturaElectronicaCR(consecutivo, clave, emisor, receptor, "01", string.Empty, "01", listaDetalles, "CRC", 1); XmlDocument xmlSinFirmar = fact.CreaXMLFacturaElectronica(); emisor.OutputFolder = rutaOutput; try { await fact.ProcesaAsync(xmlSinFirmar.OuterXml, emisor.OutputFolder, consecutivo); } catch (Exception) { transaccion.EnviadaHacienda = false; ///throw; this.TempData["ErrorMessage"] = "Error al enviar a Hacienda. Intente de nuevo más tarde."; } transaccion.ClaveHacienda = clave; transaccion.EnviadaHacienda = true; transaccion.ConsecutivoHacienda = consecutivo; this._context.TransaccionHeaders.Update(transaccion); await _context.SaveChangesAsync(); } } return(this.RedirectToAction(nameof(Edit), new { id = transID })); }
private void button1_Click(object sender, EventArgs e) { if (txtNombre.Text == "" || txtCedula.Text == "" || txtVenta.Text == "" || txtDescuento.Text == "" || txtSubTotal.Text == "" || txtIVA.Text == "" || txtTotalVenta.Text == "" || tablaLinea.RowCount <= 0) { MessageBox.Show("No puedes dejar campos en blanco"); } else { Factura historial = new Factura { Identificacion = txtCedula.Text, Fecha = DateTime.Now.ToString("yyyy-MM-dd"), Hora = DateTime.Now.ToString("HH:mm:ss"), TotalVenta = Convert.ToDouble(txtTotalVenta.Text), Descuento = Convert.ToDouble(txtDescuento.Text), SubTotal = Convert.ToDouble(txtSubTotal.Text), IVA = Convert.ToDouble(txtIVA.Text), PorcentajeIVA = cmbIVA.SelectedValue.ToString() + "%" }; //Se inserta la factura Resultado r = HistorialBLL.InsertarHistorial(historial); if (r.Codigo == 1) { // insetar linea factura for (int i = 0; i < tablaLinea.RowCount; i++) { LineaDetalle l = new LineaDetalle { NumeroFactura = Convert.ToInt32(lblNumFactura.Text), IdLinea = i + 1, IdProducto = Convert.ToInt32(tablaLinea.Rows[i].Cells["Codigo"].Value), Cantidad = Convert.ToInt32(tablaLinea.Rows[i].Cells["Cantidad"].Value), PrecioProducto = Convert.ToDouble(tablaLinea.Rows[i].Cells["PrecioUnit"].Value) }; ProductoBLL.InsertarLinea(l); } ObtenerNumeroFactura(); //llenar objetos para crear el ticket Persona persona = PersonasBLL.BuscarUnaPersona(txtCedula.Text); Factura factura = HistorialBLL.ultimoRegistro(); List <ProductosLineaDetalle> ListadoProductosLineaDetalle = ProductoBLL.ListadoProductosLineaDetalle(factura.NumeroFactura); control.CrearTickete(persona, ListadoProductosLineaDetalle, factura); MessageBox.Show("Tomar el tiquete", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); limpiarTxt(); this.Visible = false; control.AbrirFormPrincipal(); } else { MessageBox.Show(r.Mensaje, "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public HttpResponseMessage Put(FormDataCollection form) { LineaDetalle lineadetalle = new LineaDetalle(); lineadetalle.NumeroLinea1 = Convert.ToInt32(form.Get("NumeroLinea")); lineadetalle.PartidaArancelaria1 = form.Get("PartidaArancelaria"); lineadetalle.Codigo1 = form.Get("Codigo"); lineadetalle.Cantidad1 = Convert.ToDecimal(form.Get("Cantidad").Replace('.', ',')); lineadetalle.UnidadMedida1 = form.Get("UnidadMedida"); lineadetalle.UnidadMedidaComercial1 = form.Get("UnidadMedidaComercial"); lineadetalle.Detalle1 = form.Get("Detalle"); lineadetalle.PrecioUnitario1 = Convert.ToDecimal(form.Get("PrecioUnitario").Replace('.', ',')); lineadetalle.MontoTotal1 = Convert.ToDecimal(form.Get("MontoTotal").Replace('.', ',')); lineadetalle.Subtotal1 = Convert.ToDecimal(form.Get("Subtotal").Replace('.', ',')); lineadetalle.BaseImponible1 = Convert.ToDecimal(form.Get("BaseImponible").Replace('.', ',')); lineadetalle.ImpuestoNeto1 = Convert.ToDecimal(form.Get("ImpuestoNeto").Replace('.', ',')); lineadetalle.MontoTotalLinea1 = Convert.ToDecimal(form.Get("MontoTotalLinea").Replace('.', ',')); lineadetalle.Consecutivo1 = Convert.ToInt32(form.Get("Consecutivo")); Descuento monto = new Descuento(); monto.MontoDescuento1 = Convert.ToDecimal(form.Get("MontoDescuento")); lineadetalle.MontoDescuento1 = monto; Descuento naturaleza = new Descuento(); naturaleza.NaturalezaDescuento = form.Get("NaturalezaDescuento"); lineadetalle.NaturalezaDescuento = naturaleza; CodigoComercial tipo = new CodigoComercial(); tipo.Tipo1 = form.Get("CodigoComercialTipo"); lineadetalle.CodigoComercialTipo1 = tipo; CodigoComercial codigo = new CodigoComercial(); codigo.Codigo1 = form.Get("CodigoComercialCodigo"); lineadetalle.CodigoComercialCodigo1 = codigo; JArray jObject = JArray.Parse(form.Get("ListaActualDeLineaDetalle_Impuesto_Exoneracion")); JToken jUser = jObject; var lista = jUser.ToObject <List <LineaDetalle_Impuesto_Exoneracion_Local> >(); List <Models.LineaDetalle_Impuesto_Exoneracion> lineadetalle_impuesto_s = new List <LineaDetalle_Impuesto_Exoneracion>(); foreach (var item in lista) { Impuesto impuesto = new Impuesto(); impuesto.Codigo1 = item.ImpuestoCodigo; Exoneracion exoneracion = new Exoneracion(); exoneracion.TipoDocumento1 = item.TipoDocumento; exoneracion.NumeroDocumento1 = item.NumeroDocumento; LineaDetalle_Impuesto_Exoneracion lineadetalle_impuesto_exoneracion = new LineaDetalle_Impuesto_Exoneracion(); lineadetalle_impuesto_exoneracion.NumeroDocumento1 = exoneracion; lineadetalle_impuesto_exoneracion.TipoDocumento1 = exoneracion; lineadetalle_impuesto_exoneracion.ImpuestoCodigo1 = impuesto; lineadetalle_impuesto_s.Add(lineadetalle_impuesto_exoneracion); } lineadetalle.ListaLineaDetalleImpuestoExoneracion1 = lineadetalle_impuesto_s; string[] respuesta = new string[2]; respuesta[0] = lineadetalle.Insert_LineaDetalle(); respuesta[1] = form.Get("Consecutivo"); HttpResponseMessage response = Request.CreateResponse <string[]>(HttpStatusCode.Created, respuesta); return(response); }
protected void ASPxGridView1_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e) { try { using (var conexion = new DataModelFE()) { DetalleServicio detalleServicio = (DetalleServicio)Session["detalleServicio"]; string codProducto = e.NewValues["codigo.codigo"] != null ? e.NewValues["codigo.codigo"].ToString().ToUpper() : null; LineaDetalle dato = detalleServicio.lineaDetalle.Where(x => x.codigo.codigo == codProducto).FirstOrDefault(); //llena el objeto con los valores de la pantalla Producto producto = conexion.Producto.Where(x => x.codigo == codProducto).FirstOrDefault(); decimal tontoTotalLinea = dato.montoTotalLinea; //dato.numeroLinea = detalleServicio.lineaDetalle.Count; dato.cantidad = e.NewValues["cantidad"] != null?decimal.Parse(e.NewValues["cantidad"].ToString()) : 0; //dato.codigo.tipo = producto.tipo; //dato.codigo.codigo = producto.codigo; //dato.detalle = producto.descripcion; //dato.unidadMedida = producto.unidadMedida; dato.unidadMedidaComercial = ""; decimal precio = "0".Equals(e.NewValues["precioUnitario"].ToString()) ? producto.precioVenta1 : decimal.Parse(e.NewValues["precioUnitario"].ToString()); dato.producto = producto.codigo;/*solo para uso del grid*/ dato.precioUnitario = precio; dato.montoDescuento = e.NewValues["montoDescuento"] != null?decimal.Parse(e.NewValues["montoDescuento"].ToString()) : 0; dato.montoTotal = dato.subTotal - dato.montoDescuento; dato.calcularMontos(); dato.naturalezaDescuento = e.NewValues["naturalezaDescuento"] != null ? e.NewValues["naturalezaDescuento"].ToString().ToUpper() : null; dato.naturalezaDescuento = dato.naturalezaDescuento; if (TipoDocumento.NOTA_CREDITO.Equals(Session["tipoNota"].ToString())) { if (tontoTotalLinea < dato.montoTotalLinea) { throw new Exception(string.Format("El monto de la línea de la nota de crédito no puede ser mayor al original {0}", tontoTotalLinea)); } } //agrega el objeto Session["detalleServicio"] = detalleServicio; } //esto es para el manero del devexpress e.Cancel = true; this.ASPxGridView1.CancelEdit(); } catch (Exception ex) { throw new Exception(Utilidades.validarExepcionSQL(ex), ex.InnerException); } finally { //refescar los datos this.refreshData(); } }
private decimal _CalcNicotina(LineaDetalle row) { return(Math.Round((2 * row.Valor2 - row.Valor1) * Form_ProduccionNicotinaEditor.constanteNicotina1 * Form_ProduccionNicotinaEditor.constanteNicotina2 * row.FactorN * _CalcFH(row.PorcentajeH), 2, MidpointRounding.AwayFromZero)); }