Publicado el Dejar un comentario

Imprime el ticket via Windows

' Mybusiness POS v. 2011
Sub Main()

imprime Ambiente.rstEstacion.fields("ImpRem")
'imprime "\\SERVER2\HP LaserJet 3300 Series PCL 6"

End Sub

Function imprime( cImpresora )
' Formato de remisiones
' Por() Daniel

Dim rstEncabezado 'El recordSet de los datos generales
Dim rstPartidas 'Las partidas de la factura
Dim rstCliente 'El cliente de la venta
Dim rstLotes 'Lista de lotes
Dim rstSeries 'Lista de números de serie
Dim nRenglon 'El número de renglón sobre el que se va a trabajar
Dim strSql 'Una cadena con el query que se va a ejecutar
Dim Estado 'El estado de la venta cancelado o facturado
Dim ImportePartida 'El importe de cada partida
Dim ImporteTotal 'El importe total de la factura
Dim Impuesto 'El impuesto de la factura
Dim rstMoneda 'La moneda de la venta
Dim nLineas 'Un contador para los campos de tipo memo
Dim nSalto

nSalto = 0.7

'Esto abre el cajon de dinero
if Ambiente.rstEstacion("Cajon") <> 0 Then
if Not clEmpty(Ambiente.rstEstacion("pticket")) Then
Out Trim(Ambiente.rstEstacion("pticket")), Chr(27) & Chr(112) & Chr(48) & Chr(20) & Chr(20)
end if
end if

' Creamos el recordSet del encabezado de la venta
Set rstEncabezado = Rst("SELECT * FROM ventas WHERE venta = " & prn.Documento, Ambiente.Connection )

' Verificamos que la venta que se desea imprimir exista
if rstEncabezado.EOF Then
MsgBox "No existe la venta seleccionada",vbInformation
Exit Function
end if

' Creamos el recordSet de las partidas que componen la venta
Set rstPartidas = Rst("SELECT * FROM partvta WHERE venta =" & rstEncabezado.fields("Venta"), Ambiente.Connection )

' Traemos todos los datos del cliente
Set rstCliente = Rst("SELECT * FROM clients WHERE cliente = '" & rstEncabezado.fields("Cliente") & "'", Ambiente.Connection )

'Indicamos cual es la impresora que deseamos utilizar
EstableceImpresora (cImpresora)

' Iniciamos la Impresión del encabezado de la forma
IniciaDocumento

EstableceFuente "Courier New", 9
FontBold True

' Imprimimos el logo del programa
'Picture Ambiente.path & "\Images\Business.jpg", Col(28), Row(1), Col(7),Row(4)

' Imprimimos el Nombre de la empres
'FilledBox 1.5,0.2,5,0.33, RGB( 200, 200, 200 )

nRenglon = 0
nRenglon = nRenglon + nSalto

FontBold True
Say Row(nRenglon),Col(28), Ambiente.Empresa
FontBold False

nRenglon = nRenglon + nSalto
nRenglon = nRenglon + nSalto
Say Prn.Row(nRenglon), Col(28), Ambiente.Direccion1
nRenglon = nRenglon + nSalto
Say Prn.Row(nRenglon), Col(28), Ambiente.Direccion2
nRenglon = nRenglon + nSalto
Say Prn.Row(nRenglon), Col(28), "Ticket: " & rstEncabezado.Fields("No_referen") & " Caja: " & Ambiente.Estacion
nRenglon = nRenglon + nSalto
Say Prn.Row(nRenglon), Col(28), rstEncabezado.Fields("Usuario") & " " & Formato( rstEncabezado.Fields("UsuFecha"), "dd/MM/yyyy") & " " & rstEncabezado.Fields("UsuHora")

if rstEncabezado.Fields("Estado") = "CA" Then
Estado = "CANCELADO"
end if

if rstEncabezado.Fields("Estado") = "CO" Then
Estado = "REMISIONADO"
end if

FontBold False

nRenglon = nRenglon + nSalto

While Not rstPartidas.EOF

' No congelamos el sistema
Ev = DoEvents

'Say Row(nRenglon), Col(36), Trim(rstPartidas.Fields("Articulo"))
Say Row(nRenglon), Col(43), Padl(Formato(rstPartidas.Fields("Precio") * (1 + ( rstPartidas.Fields("Impuesto") / 100)), "###,###,###.00"), 6)
Say Row(nRenglon), Col(40), rstPartidas.Fields("Cantidad")
'Say Row(nRenglon), Col(59), rstPartidas.Fields("Descuento")

' Calculamos el importe
ImportePartida = rstPartidas.Fields("Precio") * rstPartidas.Fields("Cantidad")
ImportePartida = ImportePartida - ( ImportePartida * ( rstPartidas.Fields("Descuento") / 100 ) )

Say Row(nRenglon), Col(47.5), PadL(Formato(ImportePartida * (1 + ( rstPartidas.Fields("Impuesto") / 100)),"###,###,###.00"),6)

' Contamos las lineas que tiene el campo memo
' Imprimimos las lineas al final para poder incrementar los renglones
' sin afectar a las partidas
nLineas = CuantasLineas( rstPartidas.Fields("Observ") )

' Imprimimos cada una de ellas
For n = 1 to nLineas
Say Row(nRenglon), Col(28), Mid( strLinea( Trim(rstPartidas.Fields("Observ")), n), 1, 18 )
nRenglon = nRenglon + nSalto
Next

' Si no existen comentarios no disminuimos en un renglon.
if nLineas > 0 Then
nRenglon = nRenglon - nSalto
end if

rstPartidas.MoveNext
nRenglon = nRenglon + nSalto

If nRenglon >= 60 Then
nRenglon = 1
PaginaNueva
End If

Wend

' Imprimimos las observaciones de la operacion
nLineas = CuantasLineas( rstEncabezado.Fields("Observ") )

' Imprimimos cada una de ellas
For n = 1 to nLineas
nRenglon = nRenglon + 1
Say Row(nRenglon), Col(30), strLinea( rstEncabezado.Fields("Observ"), n)
Next

' Imprimimos la leyenda en letra y los totales
ImporteTotal = rstEncabezado.fields("Importe")
Impuesto = rstEncabezado.fields("Impuesto")

Set rstMoneda = rst("SELECT * FROM monedas WHERE moneda = '" & rstEncabezado.fields("Moneda") & "'", Ambiente.Connection )

nRenglon = nRenglon + nSalto
Say Row(nRenglon), Col(28), "Importe : " & PadL(Formato(ImporteTotal,"###,###,###.00"),12)
nRenglon = nRenglon + nSalto
Say Row(nRenglon), Col(28), "Impuesto: " & PadL(Formato(Impuesto,"###,###,###.00"),12)
nRenglon = nRenglon + nSalto
Say Row(nRenglon), Col(28), "Total : " & PadL(Formato(ImporteTotal + Impuesto,"###,###,###.00"),12)
nRenglon = nRenglon + nSalto
nCobro = rstEncabezado.fields("Pago1") + rstEncabezado.fields("Pago2") + rstEncabezado.fields("Pago3")
Say Row(nRenglon), Col(28), "Su pago : " & PadL( Formato( nCobro, Ambiente.Fdinero ), 12 )
nRenglon = nRenglon + nSalto
nCambio = ImporteTotal + Impuesto - (rstEncabezado.fields("Pago1") + rstEncabezado.fields("Pago2") + rstEncabezado.fields("Pago3"))
Say Row(nRenglon), Col(28), "Cambio : " & PadL( Formato( Abs(nCambio), Ambiente.FDinero ), 12 )
nRenglon = nRenglon + nSalto
nRenglon = nRenglon + nSalto
Say Row(nRenglon), Col(28),Trim( Letra(ImporteTotal + Impuesto, rstMoneda.fields("Descrip"), True, rstMoneda.fields("Nombre") ) )

nRenglon = nRenglon + nSalto
Say Row(nRenglon), Col(28), "Gracias por su preferencia"

' Se da por terminado el documento
FinDocumento

End Function

Deja un comentario