public function guardarFacturaVenta($Venta, $Detalle)
 {
     $IdUltimaVenta;
     $Credito = new Credito();
     try {
         $Venta->save();
         $IdUltimaVenta = $this->obtenerUltimoIdVenta();
         if (strcmp($Venta->TipoVenta, "cr") == 0) {
             $Credito->IdVenta = $IdUltimaVenta;
             $Credito->MontoTotal = $Venta->TotalVenta;
             $Credito->Saldo = $Venta->TotalVenta;
             $Credito->IdCliente = $Venta->IdCliente;
             $Credito->FechaRegistro = $Venta->Fecha;
             $Credito->Estado = "A";
             $Credito->save();
         }
         foreach ($Detalle as $Linea) {
             $DetalleVenta = new DetalleVenta();
             $Producto = Producto::findOrFail($Linea->IdProducto);
             $Producto->Stock = $Producto->Stock - $Linea->Cantidad;
             $DetalleVenta->IdVenta = $IdUltimaVenta;
             $DetalleVenta->IdProducto = $Linea->IdProducto;
             $DetalleVenta->PrecioVentaUnitario = $Linea->PrecioVentaUnitario;
             $DetalleVenta->Cantidad = $Linea->Cantidad;
             $DetalleVenta->PrecioCostoUnitario = $Linea->PrecioCosto;
             $DetalleVenta->EsExcento = $Linea->EsExcento;
             $DetalleVenta->PorcentajeIV = $Linea->PorcentajeIV;
             $DetalleVenta->PorcentajeDescuento = $Linea->PorcentajeDescuento;
             $DetalleVenta->PorcentajeUtilidad = $Linea->PorcentajeUtilidad;
             $DetalleVenta->DescuentoUnitario = $Linea->DescuentoUnitario;
             $DetalleVenta->UtilidadUnitario = $Linea->UtilidadUnitario;
             $DetalleVenta->TotalIV = $Linea->TotalIV;
             $DetalleVenta->TotalDescuento = $Linea->TotalDescuento;
             $DetalleVenta->TotalUtilidad = $Linea->TotalUtilidad;
             $DetalleVenta->TotalLinea = $Linea->TotalLinea;
             $DetalleVenta->save();
             $Producto->save();
         }
         return true;
     } catch (Exception $e) {
         return false;
     }
 }