Código de Access - Impresora Fiscal en Access

2019
estrellaestrellaestrellaestrellaestrella(1)

Publicado el 28 de Mayo del 2020gráfica de visualizaciones de la versión: 2019
1.868 visualizaciones desde el 28 de Mayo del 2020
estrellaestrellaestrellaestrellaestrella
estrellaestrellaestrellaestrella
estrellaestrellaestrella
estrellaestrella
estrella

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
Function ImprimirFactura(IdFactura As Double)
    DoCmd.Hourglass True
 
    Dim Sql As String
    Dim Rs As ADODB.Recordset
    Set Rs = New ADODB.Recordset
 
    Sql = "SELECT FacturaEncabezado.IdFactura, FacturaEncabezado.NoEnviar, FacturaDetalle.IdFacDet AS IdFacturaDetalle, FacturaEncabezado.NumeroFac, 1 AS TipoDocumento, Clientes.Rif, Clientes.NomCliente, Clientes.Direccion, IIf(IsNull([Telefono]),IIf(IsNull([Celular]),[TeleOficina],[Celular]),[Telefono]) AS Telfs, Productos.idProducto AS CodPropio, Len(IIf(IsNull([FacturaDetalle].[Descripcion]),[Productos].[DescProducto],[FacturaDetalle].[Descripcion])) AS Expr3, IIf(IsNull([FacturaDetalle].[Descripcion]),Mid([Productos].[DescProducto],1,45),Mid([FacturaDetalle].[Descripcion],1,45)) AS Expr1, IIf(IsNull([FacturaDetalle].[Descripcion]),Mid([Productos].[DescProducto],46,126),Mid([FacturaDetalle].[Descripcion],46,126)) AS Expr2,"
    Sql = Sql & " FacturaDetalle.Cantidad, Round([SubTotal]/[FacturaDetalle].[cantidad],2) AS PrecioUnitQ, Format(Int([PrecioUnit]),'00000000') AS PrecioInt, left(Format((Round([PrecioUnit],2)-Int([PrecioUnit]))*100,'00'),2) AS PrecioDec, Format(Int([FacturaDetalle].[Cantidad]),'00000') AS CantidadInt"
    Sql = Sql & " , Format(([FacturaDetalle].[Cantidad]-Int([FacturaDetalle].[Cantidad]))*1000,'000') AS CantidadDec, Chr([CodigoFiscalFac]) AS Comando, Format(Int([PrecioUnit]),'00000000') & Format(([PrecioUnit]-Int([PrecioUnit]))*100,'00') AS PrecioCre, Format(Int([FacturaDetalle].[Cantidad]),'00000') & Format(([FacturaDetalle].[Cantidad]-Int([FacturaDetalle].[Cantidad]))*1000,'000') AS CantidadCre, IIf([IVAPorcenFac]=0,False,True) AS Retensiones"
    Sql = Sql & " , Format(Int([CxcEfectivo]),'00000000000') & Format(([CxcEfectivo]-Int([CxcEfectivo]))*100,'00') AS Efectivo, Format(Int([CxcCheques]),'00000000000') & Format(([CxcCheques]-Int([CxcCheques]))*100,'00') AS Cheque, Format(Int([TarjetasDebito]),'00000000000') & Format(([TarjetasDebito]-Int([TarjetasDebito]))*100,'00') AS Debito, Format(Int([TarjetasCredito]),'00000000000') & Format(([TarjetasCredito]-Int([TarjetasCredito]))*100,'00') AS Credito, Format(Int([CxcTransferencias]),'00000000000') & Format(([CxcTransferencias]-Int([CxcTransferencias]))*100,'00') AS Transferencia"
    Sql = Sql & " , Format(Int([CxcNC]),'00000000000') & Format(([CxcNC]-Int([CxcNC]))*100,'00') AS NC, Format(Int([Porcendescuento]),'00') & Format(([Porcendescuento]-Int([Porcendescuento]))*100,'00') AS Descuento, Format(Int([CxcDeposito]),'00000000000') & Format(([CxcDeposito]-Int([CxcDeposito]))*100,'00') AS Deposito, FacturaEncabezado.Status, Productos.IdProducto, TipoPago.DescTipPago, Format(Int([CxcAporte]),'00000000000') & Format(([CxcAporte]-Int([CxcAporte]))*100,'00') AS Aporte, FacturaEncabezado.Usuario, FormaPago.PagoForma, FacturaEncabezado.IdPedido, FacturaEncabezado.Recolector, FacturaEncabezado.Concepto, 'Nro Compras ' & UCase(Format([FacturaEncabezado].[Fecha],'mmm')) & ':' & [Compras] AS CompraMes"
    Sql = Sql & " FROM (((((((FacturaEncabezado INNER JOIN FacturaDetalle ON FacturaEncabezado.IdFactura = FacturaDetalle.IdFactura) LEFT JOIN Productos ON FacturaDetalle.IdRepuesto = Productos.IdProducto) INNER JOIN Clientes ON FacturaEncabezado.IdCliente = Clientes.IdCliente) LEFT JOIN FacturasPagosEnca ON (FacturaEncabezado.IdCxcEncabezado = FacturasPagosEnca.IdCxcEncabezado) AND (FacturaEncabezado.IdFactura = FacturasPagosEnca.IdFactura)) INNER JOIN Impuestos ON FacturaDetalle.IVAPorcenFac = Impuestos.Valor) INNER JOIN TipoPago ON FacturaEncabezado.IdTipoPago = TipoPago.IdTipoPago) INNER JOIN FormaPago ON FacturaEncabezado.IdFormaPago = FormaPago.IdFormaPago) LEFT JOIN ComprasFactura ON Clientes.IdCliente = ComprasFactura.IdCliente"
    Sql = Sql & " WHERE (((FacturaEncabezado.IdFactura) = " & IdFactura & ")) ORDER BY FacturaDetalle.IdFacDet"
 
    Efectivo = ""
    Cheque = ""
    Debito = ""
    Credito = ""
    CestaTicket = ""
    Transferencia = ""
    Seguro = ""
    Aporte = ""
    Deposito = ""
    Descuent = ""
    FacAfec = ""
    Nc = ""
    DescDetalle1 = ""
    DescDetalle2 = ""
    vPasoImp = 0
 
Rs.Open Sql, CodeProject.Connection, adOpenDynamic, adLockOptimistic
If Not Rs.EOF Then
   Seguir = 1
   Rs.MoveFirst
   Dim cmd As New ADODB.Command
   Encabezado = "iR*" & Nz(Left(Rs!RIF, 12))
   Hacer = SendCmd(Status, Error, Encabezado)
 
   Encabezado = "iS*" & Nz(Left(LimpiarNombre(Trim(Rs!NomCliente)), 55))
   Hacer = SendCmd(Status, Error, Encabezado)
 
   If Len(Trim(Rs!NomCliente)) > 55 Then
      Encabezado = "i01" & Nz(Mid(LimpiarNombre(Trim(Rs!NomCliente)), 56, 126))
      Hacer = SendCmd(Status, Error, Encabezado)
   End If
 
   Encabezado = "i02Dir. " & Nz(Left(LimpiarDesc(Trim(Rs!Direccion)), 52))
   Hacer = SendCmd(Status, Error, Encabezado)
 
   If Len(Trim(Rs!Direccion)) > 52 Then
      Encabezado = "i03" & Nz(Mid(LimpiarDesc(Trim(Rs!Direccion)), 53, 126))
      Hacer = SendCmd(Status, Error, Encabezado)
   End If
 
   Encabezado = "i04Telf." & Nz(Left(Trim(Rs!Telfs), 40)) & IIf(Nz(Rs!NoEnviar, 0) = 0, "", " NO ENVIAR FACTURA")
   Hacer = SendCmd(Status, Error, Encabezado)
 
   Encabezado = "i05Nro.Documento." & Trim(Rs!NumeroFac) & IIf(Nz(Rs!NoEnviar, 0) = 0, "", " NO ENVIAR FACTURA")
   Hacer = SendCmd(Status, Error, Encabezado)
 
   Encabezado = "i06Recolector :" & Nz(Trim(Rs!Recolector)) & IIf(Nz(Rs!NoEnviar, 0) = 0, "", " NO ENVIAR FACTURA")
   Hacer = SendCmd(Status, Error, Encabezado)
 
   Encabezado = "i07Cesta :" & Nz(Left(Rs!Concepto, 55))
   Hacer = SendCmd(Status, Error, Encabezado)
 
   If Nz(Rs!NoEnviar, 0) = 0 Then
      Encabezado = "i08Pedido Nro." & Nz(Trim(DLookup("IdPedidoMySql", "PedidoEncabezado", "IdPedido = " & Rs!IdPedido))) & " " & Trim(Rs!CompraMes)
      Hacer = SendCmd(Status, Error, Encabezado)
   Else
      Encabezado = "i08Pedido Nro." & Nz(Trim(DLookup("IdPedidoMySql", "PedidoEncabezado", "IdPedido = " & Rs!IdPedido))) & "   NO ENVIAR FACTURA"
      Hacer = SendCmd(Status, Error, Encabezado)
   End If
 
   Transferencia = Nz(Rs!Transferencia)
   Credito = Nz(Rs!Credito)
   Debito = Nz(Rs!Debito)
   Efectivo = Nz(Rs!Efectivo)
   Cheque = Nz(Rs!Cheque)
   Deposito = Nz(Rs!Deposito)
   Aporte = Nz(Rs!Aporte)
   Nc = Nz(Rs!Nc)
   Descuent = Nz(Rs!Descuento)
   vChequeo = ReadFpStatus(Status, Error)
 
   If Error <> 0 Then
      Rs.Close
      Set Rs = Nothing
      Me.MostrarZ = UCase(ErrorFiscal(Error))
      Beep
      Beep
      Beep
      Beep
      Beep
   Else
      Rs.MoveFirst
      Do While Not Rs.EOF
         DescDetalle1 = LimpiarDesc(Rs!Expr1)
         Encabezado = Rs!comando & Trim(Rs!precioint) & Trim(Rs!preciodec) & Trim(Rs!Cantidadint) & Trim(Rs!CantidadDec) & Nz(DescDetalle1)
         Hacer = SendCmd(Status, Error, Encabezado)
         If Rs!Expr3 > 45 Then
            DescDetalle2 = LimpiarDesc(Rs!Expr2)
            Encabezado = "@" & DescDetalle2
            Hacer = SendCmd(Status, Error, Encabezado)
         End If
         vChequeo = ReadFpStatus(Status, Error)
         If Error <> 0 Then
            Seguir = 0
            Exit Do
         End If
         Rs.MoveNext
       Loop
       ''''''''''''''''''''''''''''''''''''''''''''
       ' Imprime el Subtotal
       If Seguir = 0 Then
          Rs.Close
          Set Rs = Nothing
          Me.MostrarZ = UCase(ErrorFiscal(Error))
          Beep
          Beep
          Beep
          Beep
          Beep
       Else
          Encabezado = "3"
          Hacer = SendCmd(Status, Error, Encabezado)
          vChequeo = ReadFpStatus(Status, Error)
          If Error <> 0 Then
             Rs.Close
             Set Rs = Nothing
             Me.MostrarZ = UCase(ErrorFiscal(Error))
             Beep
             Beep
             Beep
             Beep
             Beep
          Else
              ' Descuentos por Porcentaje
              If Val(Descuent) > 0 Then
                 Encabezado = "p" & "-" & Descuent
                 Hacer = SendCmd(Status, Error, Encabezado)
              End If
              'End If
              '''''''''''''''''''''''''''''''''''''''''''''''''''
              ' Cierre de Factura y asignacion del modo de pago
              '''''''''''''''''''''''''''''''''''''''''''''''''''
              '''''''''''''''''''''
              vPasoPago = False
              If Val(Transferencia) > 0 Then
                 Encabezado = "101" & "Transferencia"
                 Hacer = SendCmd(Status, Error, Encabezado)
                 vPasoPago = True
              End If
              If Val(Credito) > 0 Then
                 Encabezado = "102" & "Tarjeta Credito"
                 Hacer = SendCmd(Status, Error, Encabezado)
                 vPasoPago = True
              End If
              If Val(Debito) > 0 Then
                 Encabezado = "103" & "Tarjeta Debito"
                 Hacer = SendCmd(Status, Error, Encabezado)
                 vPasoPago = True
              End If
              If Val(Efectivo) > 0 Then
                 Encabezado = "104" & "Efectivo"
                 Hacer = SendCmd(Status, Error, Encabezado)
                 vPasoPago = True
              End If
              If Val(Cheque) > 0 Then
                 Encabezado = "105" & "Cheque"
                 Hacer = SendCmd(Status, Error, Encabezado)
                 vPasoPago = True
              End If
              If Val(Deposito) > 0 Then
                 Encabezado = "106" & "Deposito"
                 Hacer = SendCmd(Status, Error, Encabezado)
                 vPasoPago = True
              End If
              If Val(Aporte) > 0 Then
                 Encabezado = "107" & "Aporte"
                 Hacer = SendCmd(Status, Error, Encabezado)
                 vPasoPago = True
              End If
              If Val(Nc) > 0 Then
                 Encabezado = "108" & "Nota de Credito"
                 Hacer = SendCmd(Status, Error, Encabezado)
                 vPasoPago = True
              End If
              If vPasoPago = False Then
                 Encabezado = "101" & "Transferencia"
                 Hacer = SendCmd(Status, Error, Encabezado)
              End If
 
              ' Obtener el Numero de Factura Fiscal y Numero de Maquina Fiscal
              Set cmd.ActiveConnection = CodeProject.Connection
              cmd.CommandText = "Update FacturaEncabezado Set Fecha = '" & Date & "', FechaVen = '" & Date & "', Impresa = -1 Where IdFactura = " & Nz(IdFactura, 0)
              cmd.Execute
 
              Encabezado = "S1"
              Hacer = UploadStatusCmd(Status, Error, Encabezado, strCarpetaPrograma & "cadenafarmacia.txt")
 
              Open strCarpetaPrograma & "cadenafarmacia.txt" For Input As 1
              Line Input #1, strLinea
              strCaracter = Mid(strLinea, 22, 8)
              Me.NumeroFiscalFac = strCaracter
 
              strCaracter = Mid(strLinea, 93, 10)
              Me.MaquinaFiscalFac = strCaracter
              Close #1
              ''''''''''''''''''''''''
              Rs.Close
              Set Rs = Nothing
 
              cmd.CommandText = "Update FacturaEncabezado Set ODS = '" & vPasoImp & "', NumeroFiscalFac = '" & Nz(Me.NumeroFiscalFac) & "', MaquinaFiscalFac = '" & Nz(Me.MaquinaFiscalFac) & "' Where IdFactura = " & Nz(IdFactura, 0)
              cmd.Execute
              Me.Mostrar = "Se Imprimió la Factura : " & Me.NumeroFiscalFac & " a las " & Time()
          End If
       End If
    End If
 Else
   Rs.Close
   Set Rs = Nothing
 End If
 DoCmd.Hourglass False
 
End Function



Comentarios sobre la versión: 2019 (1)

14 de Diciembre del 2020
estrellaestrellaestrellaestrellaestrella
No ha dejado ningún comentario
Responder

Comentar la versión: 2019

Nombre
Correo (no se visualiza en la web)
Valoración
Comentarios...
CerrarCerrar
CerrarCerrar
Cerrar

Tienes que ser un usuario registrado para poder insertar imágenes, archivos y/o videos.

Puedes registrarte o validarte desde aquí.

Codigo
Negrita
Subrayado
Tachado
Cursiva
Insertar enlace
Imagen externa
Emoticon
Tabular
Centrar
Titulo
Linea
Disminuir
Aumentar
Vista preliminar
sonreir
dientes
lengua
guiño
enfadado
confundido
llorar
avergonzado
sorprendido
triste
sol
estrella
jarra
camara
taza de cafe
email
beso
bombilla
amor
mal
bien
Es necesario revisar y aceptar las políticas de privacidad

http://lwp-l.com/s6239