Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Local TIPO_FACTURA
- Local TIPO_IVA
- Local TIPO_DOCU
- Local Se
- Local fd, nIva
- Local intentos
- Local todo_ok As Boolean
- Local lin
- Local Total As Decimal
- Local descuento As Decimal
- Local ndocu As String
- Local salctacte As Decimal
- Local dias As Integer
- Local cDirCom As String
- Local cDirRes As String
- Local sNombre As String
- Local cTalk As String
- Local nFlete As Decimal
- Local nDRet As Decimal
- this.TodoOK = .F.
- cTalk = Set("Talk")
- Set Talk Off
- thisform.EjecutaSQL(goApp.nCon, "select * from tiporesp where idTipoResp=?clientes.tiporesp", "tiporesp")
- If tiporesp.discrimina
- this.Clase = "A"
- Else
- this.Clase = "B"
- Endif
- sCliente = Thisformset.frmCliente.cliente1.validacod.value
- m.dias = 0&&This.dias()
- m.descuento = 0.00&&Thisform.txtdescuento.Value &&el descuento general de la factura
- nTOTAL = thisform.Totales.txtTotal.value
- sNombre = Strtran(Thisformset.frmCliente.cliente1.lbltexto.Caption,"Ñ","N") &&saco las Ñ que no imprime el controlador fiscal
- If This.contado = "N"
- m.salctacte = This.SaldoCliente(sCliente, 0) &&Obtengo el saldo en cuenta corriente del cliente
- Else
- m.salctacte = 0
- Endif
- lImpreFiscal = trae_dirimprefiscal() &&devuelve el path donde estan las carpetas para el impresor fiscal
- nIva = ASIVA21()
- m.salctacte = Iif(Isnull(m.salctacte),0.00, m.salctacte)
- nDRet = 0.00
- Select("det")
- If -1 = SQLExec(goApp.nCon, "select * from localidades where idLocalidad=?clientes.idLocalidad","loc")
- goApp.Error()
- Endif
- &&si el total supera los 5000 no se hace ticket, se obliga a que se haga una factura
- *!* Do While Empty(This.ticket)
- *!* This.ticket = This.DefineComp()
- *!* Enddo
- This.Ticket = 'S'
- Se = Chr(28) &&separador de comandos
- &&this.condicion indica si es nota de credito o factura o nota de debito
- If This.condicion <> "C"
- If This.condicion = "D" &¬a de debito
- If This.clase = "B"
- TIPO_FACTURA = "E"
- Else
- TIPO_FACTURA = "D"
- Endif
- Else
- && si no es nota de debito ni credito es factura
- If This.clase = "B" Or this.clase = "C"
- TIPO_FACTURA = "B"
- Else
- TIPO_FACTURA = "A"
- Endif
- Endif
- Else
- If This.clase = "B"
- TIPO_FACTURA = "S"
- Else
- TIPO_FACTURA = "R"
- Endif
- Endif
- &&traigo la tabla de parametros
- *!* If SQLExec(Thisform.con, "select * from parametr","parametr") = -1
- *!* Messagebox("Se ha producido un error al recuperar el tipo de Documento" + Chr(10)+Chr(13)+Message(),0+48,"ERROR")
- *!* Return -1
- *!* Endif
- &&indica si el cliente tiene que poseer cuit
- If tiporesp.obligacuit
- If Empty( Val( Strtran( clientes.cuit, "-" ) ) )
- Messagebox ("ATENCION: Falta Registrar CUIT de Cliente", 0+48, "CUIT")
- Do While Val(ndocu) < 2
- ndocu = Inputbox("Ingrese CUIT")
- Enddo
- ndocu = Alltrim( Strtran( ndocu, "-" ) )
- Else
- TIPO_DOCU = 'C' &&tiporesp.tipo_iva &&"C"
- ndocu = Alltrim( Strtran( clientes.cuit, "-" ) )
- Endif
- Else
- If SQLExec(goApp.nCon, "select * from tipodoc where codigo=?clientes.tipodocu","tipodoc") = -1
- goApp.Error()
- Return -1
- Endif
- If Reccount("tipodoc") > 0
- TIPO_DOCU = tipodoc.tipo
- Else
- TIPO_DOCU = '2'
- Endif
- ndocu = Alltrim(Str(clientes.dni))
- If Val(ndocu) < 2
- ndocu = '11111111'
- Endif
- Endif
- TIPO_IVA = tiporesp.TIPOIVA
- Select("comando")
- &&me fijo si es ticket factura o factura
- If This.Ticket = "S"
- lin = "5"
- Else
- lin = "3"
- Endif
- If This.Ticket = "N"
- &&en caso de ser factura imprimo todo el encabezado que va en la factura
- Select("comando")
- Insert Into comando;
- VALUES( "]" + Se + "1" + Se + Chr(127) )
- Insert Into comando;
- VALUES( "]" + Se + "2" + Se + Chr(127) )
- Insert Into comando;
- values( "]" + Se + "2" + Se + "Ing.Brut. 914-532186-1" )
- If This.contado = "N"
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "Vendedor: "+Alltrim(vendedor.nom_ven)+;
- SPACE(10)+"Vencimiento de este Comp.: "+;
- DTOC(This.FechaVen(Thisform.txtFecha.Value))+;
- " Saldo Actual de CTA_CTE(S.E.U.O.): $"+;
- ALLTRIM(Str((m.salctacte),12,2)))
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + "Vendedor: "+;
- ALLTRIM(vendedor.nom_ven)+;
- SPACE(10)+"Vencimiento de este Comp.: "+;
- DTOC(This.FechaVen(Thisform.txtFecha.Value)))
- Endif
- lin = Str(Val(lin)+1,1,0)
- Do Case
- Case Used("obsfac")
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + "OBS.: "+Alltrim(obsfac.obs1)+Alltrim(obsfac.obs2))
- Case This.pagoanticipado &&det.pagoanticipado
- If det.reparto
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + "PAGO ANTICIPADO - REPARTO")
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + "PAGO ANTICIPADO - RETIRA")
- Endif
- Case This.lReparto
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + "MERCADERIA DE REPARTO")
- Case !This.lReparto
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + "MERCADERIA PARA RETIRAR")
- Otherwise
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + "DEVOLUCIONES DENTRO DE LAS 48 HRS.")
- Endcase
- lin = Str(Val(lin)+1,1,0)
- This.letras.dicenum(m.nTOTAL)
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se + ;
- "SON:" + This.letras.retorno)
- lin = "11"
- &&especifico las formas de cancelacion que posee la factura
- If pagos.adic1 > 0 .Or. pagos.plazo1 > 0
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se + ;
- "OPCION DE PAGO: Hasta el "+;
- Dtoc(Thisform.txtFecha.Value+This.dias())+ " "+;
- STR(pagos.adic1)+" % Desc. $ "+;
- STR(m.nTOTAL*pagos.adic1/100,08,2)+;
- " Paga $ "+Str((m.nTOTAL-(m.nTOTAL*pagos.adic1)/100),10,2))
- Else
- If Inlist(pagos.pago,'00','01','02')
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se + ;
- "OPCION DE PAGO: Contado Efectivo"+;
- " 3% Desc. "+;
- " Paga $ "+ Str(m.nTOTAL,10,2))
- Else
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se + Chr(127))
- Endif
- Endif
- lin = Str(Val(lin)+1,2,0)
- If pagos.adic2 > 0 .Or. pagos.plazo2 > 0
- If Isnull(pagos.dia) Or Empty(pagos.dia)
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se +;
- "OPCION DE PAGO: Hasta el "+ ;
- DTOC(This.FechaVen(Thisform.txtFecha.Value))+" "+;
- STR(pagos.adic2)+" % Desc. $ ";
- +Str(m.nTOTAL*pagos.adic2/100,08,2)+;
- " Paga $ "+Str((m.nTOTAL-(m.nTOTAL*pagos.adic2)/100),10,2))
- Else
- If pagos.pago = '51'
- *!* Pongo esto para que en esta condicion no me sume los dias de ADIC2
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "OPCION DE PAGO: Hasta el "+ ;
- DTOC(pagos.dia)+" "+;
- STR(pagos.adic2)+" % Desc. $ "+;
- STR(m.nTOTAL*pagos.adic2/100,08,2)+;
- " Paga $ "+Str((m.nTOTAL-(m.nTOTAL*pagos.adic2)/100),10,2))
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "OPCION DE PAGO: Hasta el "+ ;
- DTOC(This.FechaVen(Thisform.txtFecha.Value))+" "+;
- STR(pagos.adic2)+" % Desc. $ "+;
- STR(m.nTOTAL*pagos.adic2/100,08,2)+;
- " Paga $ "+Str((m.nTOTAL-(m.nTOTAL*pagos.adic2)/100),10,2))
- Endif
- Endif
- Else
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se + Chr(127) )
- Endif
- lin = Str(Val(lin)+1,2,0)
- If pagos.adic3 > 0 .Or. pagos.plazo3 >0
- If Isnull(pagos.dia) Or Empty(pagos.dia)
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "OPCION DE PAGO: Hasta el "+ ;
- DTOC(Thisform.txtFecha.Value+Cast(pagos.dias1 As Integer))+" "+;
- STR(pagos.adic3)+" % Desc. $ "+;
- STR(m.nTOTAL*pagos.adic3/100,08,2)+;
- " Paga $ "+Str((m.nTOTAL-(m.nTOTAL*pagos.adic3/100)),10,2))
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "OPCION DE PAGO: Hasta el "+ ;
- DTOC(pagos.dia+Cast(pagos.dias1 As Integer))+" "+;
- STR(pagos.adic3)+" % Desc. $ "+;
- STR(m.nTOTAL*pagos.adic3/100,08,2)+;
- " Paga $ "+Str((m.nTOTAL-(m.nTOTAL*pagos.adic3/100)),10,2))
- Endif
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + Chr(127))
- Endif
- lin = Str(Val(lin)+1,2,0)
- *!* Insert Into comando;
- *!* VALUES ("]" + Se + lin + Se + Chr(127))
- If m.nFlete > 0 Or m.nDRet > 0
- If m.nFlete > 0
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "Prec. de Merc. Incl. Flete "+ ;
- Transform(m.nFlete, "@$ 99,999,999.99"))
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "Merc. Incl. Desc p/RETIRA "+ ;
- Transform(m.nDRet, "@$ 99,999,999.99"))
- Endif
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + Chr(127))
- Endif
- &&si se factura sobre remitos se imprimen los remitos afectados
- If Thisform.viene = "X" &&hay q revisar esto para ver q cuando se factura de remitos se imprima
- Insert Into comando;
- VALUES ( Chr(147) + Se + "1" + Se + Substr(This.remitosafacturar,1,17))
- If !Empty(Substr(This.remitosafacturar,19,20))
- Insert Into comando;
- VALUES (Chr(147) + Se + "2" + Se + Substr(This.remitosafacturar,19,20))
- Endif
- Endif
- Else
- If This.contado = 'N'
- Insert Into comando;
- values("]" + Se + lin + Se+;
- " Saldo de CTA_CTE: $"+;
- ALLTRIM(Str((m.salctacte),12,2)))
- lin = '6'
- Else
- Insert Into comando;
- values("]" + Se + lin + Se + Chr(127))
- lin = '6'
- Endif
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se + "Vendedor: "+Alltrim(goApp.User) )
- lin = '7'
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + Chr(127))
- lin = '8'
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + Chr(127))
- lin = '11'
- *!* Insert Into comando;
- *!* VALUES ("]" + Se + lin + Se + Chr(127))
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + Chr(127))
- Endif
- If This.Ticket="S"
- Insert Into comando;
- VALUES ( "]" + Se + "9" + Se +Chr(127))
- Insert Into comando;
- VALUES ("]" + Se + "10" + Se +Chr(127))
- If This.condicion = 'C' And Val(sCliente) = 1
- Insert Into comando;
- VALUES ("b" + Se + Substr(sNombre,1,30) + Se + ;
- ndocu + Se + TIPO_IVA + Se + TIPO_DOCU + Se +;
- " S/NOMBRE")
- Else
- Insert Into comando;
- VALUES ("b" + Se + Substr(sNombre,1,30) + Se + ;
- ndocu + Se + TIPO_IVA + Se + TIPO_DOCU + Se +;
- SUBSTR(Alltrim(thisformset.frmCliente.txtDomicilio.Value)+" "+Alltrim(loc.nombre)+;
- " "+Alltrim(loc.provincia),1,40))
- Endif
- Else
- &&"["+sCliente+"] "+
- Insert Into comando;
- VALUES ( "b" + Se + "[" + sCliente + "] " + Substr(sNombre,1,40) + Se +;
- ndocu + Se + TIPO_IVA + Se + TIPO_DOCU + Se + ;
- ALLTRIM(Thisform.txtDom.Value)+" ("+Alltrim(clientes.codpos)+") "+;
- Alltrim(loc.nombre)+" "+Alltrim(loc.provincia))
- Endif
- If This.condicion <> "C"
- Insert Into comando;
- VALUES (Chr(64)+Se+TIPO_FACTURA+Se+"T")
- Else
- &&Definir tipo y num de factura afectado por nota de credito
- Insert Into comando;
- VALUES (Chr(147) + Se + "1" + Se + cre.tipoaf + " " + cre.numeroaf)
- Insert Into comando;
- VALUES (Chr(128)+Se+TIPO_FACTURA+Se+"T")
- Endif
- &&el cursor "DET" posee los items a facturar
- Select("det")
- Go Top
- Do While ! Eof()
- *!* Create Cursor det;
- *!* (cantidad n(12,4), unidad c(8), detalle c(40), total n(12,2), idArticulo int,;
- *!* unitario n(12,2), costo n(12,2), montoiva n(12,2), montodgr n(12,2), montomuni N(12,2),;
- *!* poriva n(12,2), tipoiva c(2))
- If det.unitario != 0
- If This.clase = "A"
- If This.Ticket = "S"
- Insert Into comando;
- VALUES ("A" + Se + det.unidad +" "+Substr(det.detalle,1,19)+ Se + "0")
- Insert Into comando;
- VALUES ("B" + Se + Padr(Alltrim(Substr(det.detalle,20,20)),20,".") + Se +;
- ALLTRIM(Str(det.cantidad,6,2)+"0")+ Se +;
- ALLTRIM(Str(det.unitario,9,2)) + Se + ;
- ALLTRIM(Str(det.poriva,5,2)) + Se +;
- "M" + Se + "0.00" + Se + "0" + Se + "T")
- Else
- Insert Into comando;
- VALUES ("B" + Se + det.unidad +" "+det.detalle+ Se + ;
- ALLTRIM(Str(det.cantidad,11,2))+ Se + ;
- Alltrim(Str(det.unitario,13,2)) + ;
- Se +Alltrim(Str(det.poriva,5,2)) + Se + ;
- "M" + Se + "0" + Se + "" + Se + "T")
- Endif
- Else
- If This.Ticket = "S"
- Insert Into comando;
- VALUES ( "A" + Se + det.unidad +" "+Substr(det.detalle,1,19)+ Se + "0")
- Insert Into comando;
- VALUES ("B" + Se + Padr(Alltrim(Substr(det.detalle,20,20)),20,".") + ;
- Se +Alltrim(Str(det.cantidad,6,2)+"0")+ Se + ;
- ALLTRIM(Str(det.unitario,9,2)) + Se + ;
- ALLTRIM(Str(det.poriva,5,2)) + Se + ;
- "M" + Se + "0.00" + Se + "0" + Se + "T")
- Else
- Insert Into comando;
- VALUES ("B" + Se + det.unidad+" "+det.detalle+ Se +;
- ALLTRIM(Str(det.cantidad,11,2))+ Se + ;
- ALLTRIM(Str(det.unitario,13,2)) + Se +;
- ALLTRIM(Str(det.poriva,5,2)) + Se + ;
- "M" + Se + "0" + Se + "" + Se + "T")
- Endif
- Endif
- Endif
- Select("det")
- Skip
- Enddo
- If This.condicion <> "C"
- If This.Ticket = "S"
- If This.contado = "S"
- Insert Into comando;
- VALUES (Chr(68)+ Se + Substr(formapago.detalle,1,30)+ Se + ;
- ALLTRIM(Str(ThisForm.Saldacontado.txtPago.Value,10,2))+ Se +"T"+ Se+"0")
- Else
- Insert Into comando;
- VALUES ( Chr(68)+ Se + Substr(formapago.detalle,1,30)+ ;
- Se + Alltrim(Str(ThisForm.Saldacontado.txtPago.Value,10,2))+ Se +"T"+ Se+"0")
- Endif
- Else
- If This.contado = "S"
- Insert Into comando;
- VALUES (Chr(68)+ Se + Alltrim(formapago.detalle)+ Se + ;
- ALLTRIM(Str(ThisForm.Saldacontado.txtPago.Value,12,2))+ Se +"T"+ Se+"0")
- Else
- Insert Into comando;
- VALUES(Chr(68)+ Se + Alltrim(formapago.detalle)+ Se + ;
- ALLTRIM(Str(ThisForm.Saldacontado.txtPago.Value,12,2))+ Se +"T"+ Se+"0")
- Endif
- Endif
- Endif
- If This.condicion <> "C"
- Insert Into comando;
- VALUES (Chr(69))
- Else
- Insert Into comando;
- VALUES ( Chr(129) )
- Endif
- &&en esta parte copio el archivo con los comandos a la carpeta desde el cual
- &&el spooler de impresion lee el archivo
- If This.Ticket ="S"
- && si es ticket me fijo a cual impresora debo enviar
- If lImpreFiscal
- mtXt = Alltrim(impfis.dircoticket) + Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(impfis.dirreticket) + Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Else
- mtXt = Alltrim(parametr.dirco)+"715\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(parametr.dirre)+"715\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Endif
- *!* cDirCom = "fpserver715" + "\impred.exe"
- *!* cDirCom = Fullpath(cDirCom)
- *!* && Mato el proceso del spooler y lo vuelvo a cargar
- *!* This.killprocessbyname("impred.exe")
- *!* This.killprocessbyname("wspooler.exe")
- *!* oShell = Createobject("Shell.Application")
- *!* oShell.ShellExecute (cDirCom)
- Else
- &&aca envio a la 320
- If lImpreFiscal
- mtXt = Alltrim(impfis.dircofactura) + Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(impfis.dirrefactura) + Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Else
- mtXt = Alltrim(parametr.dirco)+"320\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(parametr.dirre)+"320\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Endif
- Endif
- Select("comando")
- Goto Top
- &&en caso de que tenga un archivo en la cola de impresion de la impresora
- &&no se deja imprimir
- *Browse
- If File(mtXt)
- Messagebox("ATENCION: Ud. ya tiene un Documento en Cola de Impresión"+Chr(10)+Chr(13)+;
- " AGUARDE a que el mismo sea impreso o elimínelo luego vuelva a intentar")
- Return This.TodoOK
- Else
- Copy To &mtXt Sdf
- If File(maNs)
- Erase &maNs
- Endif
- If File(Alltrim(paramfac.dirpa)+"SPOOLER.LOG")
- Erase (Alltrim(paramfac.dirpa)+"SPOOLER.LOG")
- Endif
- Wait Windows 'Esperando Respuesta del Controlador Fiscal...' Nowait
- fd = -1
- intentos =1
- Do While fd < 0 .And. Lastkey() != 27
- fd = Fopen(maNs, 0)
- This.LeerSpooler("T")
- If intentos = 30
- Messagebox("ATENCION: Verifique que el Controlador Esté Conectado y Encendido. " + Chr(10) + Chr(13)+ ;
- "Verifique además que el Programa Spooler se esté ejecutando " + Chr(10) + Chr(13)+ ;
- "en el equipo al cual se encuentra conectado el Controlador Fiscal")
- This.LeerSpooler("T")
- Endif
- If intentos = 70
- Messagebox("ATENCION: Tiempo de Espera Agotado !!! Presione ESC. para cancelar este Comprobante")
- This.LeerSpooler("T")
- Endif
- intentos = intentos + 1
- *For i=1 To 100
- *Next
- Inkey(1)
- If Lastkey() = 27
- If Substr(comando.comando,17,16) = "Impresor Ocupado"
- Messagebox("ATENCION: No se aconseja cancelar este documento por programa, "+;
- CHR(10)+Chr(13)+"La impresora ya lo ha procesado y saldrá impreso"+;
- CHR(10)+Chr(13)+ "una vez que esta se ponga en linea")
- Endif
- If Messagebox("ATENCION: Realmente desea Cancelar la Emisión de este Documento??",4+256) = 6
- Messagebox(" Se proceder a Cancelar el Documento por Sistema"+;
- CHR(10)+Chr(13)+" Verifique que la impresora también lo haya Cancelado.")
- Keyboard '{ESC}'
- Else
- Keyboard ""
- Endif
- Endif
- Enddo
- If Lastkey() = 27.Or. fd < 0
- If File(mtXt)
- Erase &mtXt
- Endif
- fd = Fopen((Alltrim(paramfac.dirpa)+"SPOOLER.LOG"), 0)
- If fd < 0
- Messagebox("Operación Cancelada: ERROR de comunicaciones con el Controlador.; Probablemente no se este ejecutando Spooler. ")
- Else
- fd =Fclose(fd)
- This.LeerSpooler("T")
- Endif
- Else
- fd = Fclose(fd)
- Select("comando")
- Zap
- Append From &maNs Sdf
- Goto Bottom
- This.numero = Val(Substr(comando.comando,35,8))
- If This.numero <> 0
- SQLExec(goApp.nCon, "select * from puntero where sucursal=?param.sucursal","puntero")
- If This.Ticket = "S"
- If This.MasDeMil
- This.numero = Val('0009'+strzero(This.numero,8))
- Else
- If lImpreFiscal
- This.numero = Val(impfis.PtoVtaTicket+strzero(This.numero,8))
- Else
- If Param.sucursal=0
- If File("c:\0009.txt")
- This.numero = Val(strzero(9,4)+strzero(This.numero,8))
- Else
- This.numero = Val(strzero(puntero.pvta_tic,4)+strzero(This.numero,8))
- Endif
- Else
- If Param.sucursal = 1
- This.numero = Val(strzero(8,4)+strzero(This.numero,8))
- Endif
- Endif
- Endif
- Endif
- Else
- If lImpreFiscal
- This.numero = Val(impfis.PtoVtaFac+strzero(This.numero,8))
- Else
- This.numero = Val(strzero(puntero.pvta_fac,4)+strzero(This.numero,8))
- Endif
- Endif
- This.TodoOK = .T.
- Endif
- Endif
- If File((Alltrim(paramfac.dirpa)+"SPOOLER.LOG"))
- Erase Alltrim(paramfac.dirpa)+"SPOOLER.LOG"
- Endif
- Endif
- *This.killprocessbyname("impred.exe")
- *This.killprocessbyname("wspooler.exe")
- Set Talk &cTalk
- Return This.Todo
- *!* Do While Empty(This.ticket)
- *!* This.ticket = This.DefineComp()
- *!* Enddo
- This.Ticket = 'S'
- Se = Chr(28) &&separador de comandos
- &&this.condicion indica si es nota de credito o factura o nota de debito
- If This.condicion <> "C"
- If This.condicion = "D" &¬a de debito
- If This.clase = "B"
- TIPO_FACTURA = "E"
- Else
- TIPO_FACTURA = "D"
- Endif
- Else
- && si no es nota de debito ni credito es factura
- If This.clase = "B" Or this.clase = "C"
- TIPO_FACTURA = "B"
- Else
- TIPO_FACTURA = "A"
- Endif
- Endif
- Else
- If This.clase = "B"
- TIPO_FACTURA = "S"
- Else
- TIPO_FACTURA = "R"
- Endif
- Endif
- &&traigo la tabla de parametros
- *!* If SQLExec(Thisform.con, "select * from parametr","parametr") = -1
- *!* Messagebox("Se ha producido un error al recuperar el tipo de Documento" + Chr(10)+Chr(13)+Message(),0+48,"ERROR")
- *!* Return -1
- *!* Endif
- &&indica si el cliente tiene que poseer cuit
- If tiporesp.obligacuit
- If Empty( Val( Strtran( clientes.cuit, "-" ) ) )
- Messagebox ("ATENCION: Falta Registrar CUIT de Cliente", 0+48, "CUIT")
- Do While Val(ndocu) < 2
- ndocu = Inputbox("Ingrese CUIT")
- Enddo
- ndocu = Alltrim( Strtran( ndocu, "-" ) )
- Else
- TIPO_DOCU = 'C' &&tiporesp.tipo_iva &&"C"
- ndocu = Alltrim( Strtran( clientes.cuit, "-" ) )
- Endif
- Else
- If SQLExec(goApp.nCon, "select * from tipodoc where codigo=?clientes.tipodocu","tipodoc") = -1
- goApp.Error()
- Return -1
- Endif
- If Reccount("tipodoc") > 0
- TIPO_DOCU = tipodoc.tipo
- Else
- TIPO_DOCU = '2'
- Endif
- ndocu = Alltrim(Str(clientes.dni))
- If Val(ndocu) < 2
- ndocu = '11111111'
- Endif
- Endif
- TIPO_IVA = tiporesp.TIPOIVA
- Select("comando")
- &&me fijo si es ticket factura o factura
- If This.Ticket = "S"
- lin = "5"
- Else
- lin = "3"
- Endif
- If This.Ticket = "N"
- &&en caso de ser factura imprimo todo el encabezado que va en la factura
- Select("comando")
- Insert Into comando;
- VALUES( "]" + Se + "1" + Se + Chr(127) )
- Insert Into comando;
- VALUES( "]" + Se + "2" + Se + Chr(127) )
- Insert Into comando;
- values( "]" + Se + "2" + Se + "Ing.Brut. 914-532186-1" )
- If This.contado = "N"
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "Vendedor: "+Alltrim(vendedor.nom_ven)+;
- SPACE(10)+"Vencimiento de este Comp.: "+;
- DTOC(This.FechaVen(Thisform.txtFecha.Value))+;
- " Saldo Actual de CTA_CTE(S.E.U.O.): $"+;
- ALLTRIM(Str((m.salctacte),12,2)))
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + "Vendedor: "+;
- ALLTRIM(vendedor.nom_ven)+;
- SPACE(10)+"Vencimiento de este Comp.: "+;
- DTOC(This.FechaVen(Thisform.txtFecha.Value)))
- Endif
- lin = Str(Val(lin)+1,1,0)
- Do Case
- Case Used("obsfac")
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + "OBS.: "+Alltrim(obsfac.obs1)+Alltrim(obsfac.obs2))
- Case This.pagoanticipado &&det.pagoanticipado
- If det.reparto
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + "PAGO ANTICIPADO - REPARTO")
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + "PAGO ANTICIPADO - RETIRA")
- Endif
- Case This.lReparto
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + "MERCADERIA DE REPARTO")
- Case !This.lReparto
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + "MERCADERIA PARA RETIRAR")
- Otherwise
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + "DEVOLUCIONES DENTRO DE LAS 48 HRS.")
- Endcase
- lin = Str(Val(lin)+1,1,0)
- This.letras.dicenum(m.nTOTAL)
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se + ;
- "SON:" + This.letras.retorno)
- lin = "11"
- &&especifico las formas de cancelacion que posee la factura
- If pagos.adic1 > 0 .Or. pagos.plazo1 > 0
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se + ;
- "OPCION DE PAGO: Hasta el "+;
- Dtoc(Thisform.txtFecha.Value+This.dias())+ " "+;
- STR(pagos.adic1)+" % Desc. $ "+;
- STR(m.nTOTAL*pagos.adic1/100,08,2)+;
- " Paga $ "+Str((m.nTOTAL-(m.nTOTAL*pagos.adic1)/100),10,2))
- Else
- If Inlist(pagos.pago,'00','01','02')
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se + ;
- "OPCION DE PAGO: Contado Efectivo"+;
- " 3% Desc. "+;
- " Paga $ "+ Str(m.nTOTAL,10,2))
- Else
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se + Chr(127))
- Endif
- Endif
- lin = Str(Val(lin)+1,2,0)
- If pagos.adic2 > 0 .Or. pagos.plazo2 > 0
- If Isnull(pagos.dia) Or Empty(pagos.dia)
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se +;
- "OPCION DE PAGO: Hasta el "+ ;
- DTOC(This.FechaVen(Thisform.txtFecha.Value))+" "+;
- STR(pagos.adic2)+" % Desc. $ ";
- +Str(m.nTOTAL*pagos.adic2/100,08,2)+;
- " Paga $ "+Str((m.nTOTAL-(m.nTOTAL*pagos.adic2)/100),10,2))
- Else
- If pagos.pago = '51'
- *!* Pongo esto para que en esta condicion no me sume los dias de ADIC2
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "OPCION DE PAGO: Hasta el "+ ;
- DTOC(pagos.dia)+" "+;
- STR(pagos.adic2)+" % Desc. $ "+;
- STR(m.nTOTAL*pagos.adic2/100,08,2)+;
- " Paga $ "+Str((m.nTOTAL-(m.nTOTAL*pagos.adic2)/100),10,2))
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "OPCION DE PAGO: Hasta el "+ ;
- DTOC(This.FechaVen(Thisform.txtFecha.Value))+" "+;
- STR(pagos.adic2)+" % Desc. $ "+;
- STR(m.nTOTAL*pagos.adic2/100,08,2)+;
- " Paga $ "+Str((m.nTOTAL-(m.nTOTAL*pagos.adic2)/100),10,2))
- Endif
- Endif
- Else
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se + Chr(127) )
- Endif
- lin = Str(Val(lin)+1,2,0)
- If pagos.adic3 > 0 .Or. pagos.plazo3 >0
- If Isnull(pagos.dia) Or Empty(pagos.dia)
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "OPCION DE PAGO: Hasta el "+ ;
- DTOC(Thisform.txtFecha.Value+Cast(pagos.dias1 As Integer))+" "+;
- STR(pagos.adic3)+" % Desc. $ "+;
- STR(m.nTOTAL*pagos.adic3/100,08,2)+;
- " Paga $ "+Str((m.nTOTAL-(m.nTOTAL*pagos.adic3/100)),10,2))
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "OPCION DE PAGO: Hasta el "+ ;
- DTOC(pagos.dia+Cast(pagos.dias1 As Integer))+" "+;
- STR(pagos.adic3)+" % Desc. $ "+;
- STR(m.nTOTAL*pagos.adic3/100,08,2)+;
- " Paga $ "+Str((m.nTOTAL-(m.nTOTAL*pagos.adic3/100)),10,2))
- Endif
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + Chr(127))
- Endif
- lin = Str(Val(lin)+1,2,0)
- *!* Insert Into comando;
- *!* VALUES ("]" + Se + lin + Se + Chr(127))
- If m.nFlete > 0 Or m.nDRet > 0
- If m.nFlete > 0
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "Prec. de Merc. Incl. Flete "+ ;
- Transform(m.nFlete, "@$ 99,999,999.99"))
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "Merc. Incl. Desc p/RETIRA "+ ;
- Transform(m.nDRet, "@$ 99,999,999.99"))
- Endif
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + Chr(127))
- Endif
- &&si se factura sobre remitos se imprimen los remitos afectados
- If Thisform.viene = "X" &&hay q revisar esto para ver q cuando se factura de remitos se imprima
- Insert Into comando;
- VALUES ( Chr(147) + Se + "1" + Se + Substr(This.remitosafacturar,1,17))
- If !Empty(Substr(This.remitosafacturar,19,20))
- Insert Into comando;
- VALUES (Chr(147) + Se + "2" + Se + Substr(This.remitosafacturar,19,20))
- Endif
- Endif
- Else
- If This.contado = 'N'
- Insert Into comando;
- values("]" + Se + lin + Se+;
- " Saldo de CTA_CTE: $"+;
- ALLTRIM(Str((m.salctacte),12,2)))
- lin = '6'
- Else
- Insert Into comando;
- values("]" + Se + lin + Se + Chr(127))
- lin = '6'
- Endif
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se + "Vendedor: "+Alltrim(goApp.User) )
- lin = '7'
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + Chr(127))
- lin = '8'
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + Chr(127))
- lin = '11'
- *!* Insert Into comando;
- *!* VALUES ("]" + Se + lin + Se + Chr(127))
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + Chr(127))
- Endif
- If This.Ticket="S"
- Insert Into comando;
- VALUES ( "]" + Se + "9" + Se +Chr(127))
- Insert Into comando;
- VALUES ("]" + Se + "10" + Se +Chr(127))
- If This.condicion = 'C' And Val(sCliente) = 1
- Insert Into comando;
- VALUES ("b" + Se + Substr(sNombre,1,30) + Se + ;
- ndocu + Se + TIPO_IVA + Se + TIPO_DOCU + Se +;
- " S/NOMBRE")
- Else
- Insert Into comando;
- VALUES ("b" + Se + Substr(sNombre,1,30) + Se + ;
- ndocu + Se + TIPO_IVA + Se + TIPO_DOCU + Se +;
- SUBSTR(Alltrim(thisformset.frmCliente.txtDomicilio.Value)+" "+Alltrim(loc.nombre)+;
- " "+Alltrim(loc.provincia),1,40))
- Endif
- Else
- &&"["+sCliente+"] "+
- Insert Into comando;
- VALUES ( "b" + Se + "[" + sCliente + "] " + Substr(sNombre,1,40) + Se +;
- ndocu + Se + TIPO_IVA + Se + TIPO_DOCU + Se + ;
- ALLTRIM(Thisform.txtDom.Value)+" ("+Alltrim(clientes.codpos)+") "+;
- Alltrim(loc.nombre)+" "+Alltrim(loc.provincia))
- Endif
- If This.condicion <> "C"
- Insert Into comando;
- VALUES (Chr(64)+Se+TIPO_FACTURA+Se+"T")
- Else
- &&Definir tipo y num de factura afectado por nota de credito
- Insert Into comando;
- VALUES (Chr(147) + Se + "1" + Se + cre.tipoaf + " " + cre.numeroaf)
- Insert Into comando;
- VALUES (Chr(128)+Se+TIPO_FACTURA+Se+"T")
- Endif
- &&el cursor "DET" posee los items a facturar
- Select("det")
- Go Top
- Do While ! Eof()
- *!* Create Cursor det;
- *!* (cantidad n(12,4), unidad c(8), detalle c(40), total n(12,2), idArticulo int,;
- *!* unitario n(12,2), costo n(12,2), montoiva n(12,2), montodgr n(12,2), montomuni N(12,2),;
- *!* poriva n(12,2), tipoiva c(2))
- If det.unitario != 0
- If This.clase = "A"
- If This.Ticket = "S"
- Insert Into comando;
- VALUES ("A" + Se + det.unidad +" "+Substr(det.detalle,1,19)+ Se + "0")
- Insert Into comando;
- VALUES ("B" + Se + Padr(Alltrim(Substr(det.detalle,20,20)),20,".") + Se +;
- ALLTRIM(Str(det.cantidad,6,2)+"0")+ Se +;
- ALLTRIM(Str(det.unitario,9,2)) + Se + ;
- ALLTRIM(Str(det.poriva,5,2)) + Se +;
- "M" + Se + "0.00" + Se + "0" + Se + "T")
- Else
- Insert Into comando;
- VALUES ("B" + Se + det.unidad +" "+det.detalle+ Se + ;
- ALLTRIM(Str(det.cantidad,11,2))+ Se + ;
- Alltrim(Str(det.unitario,13,2)) + ;
- Se +Alltrim(Str(det.poriva,5,2)) + Se + ;
- "M" + Se + "0" + Se + "" + Se + "T")
- Endif
- Else
- If This.Ticket = "S"
- Insert Into comando;
- VALUES ( "A" + Se + det.unidad +" "+Substr(det.detalle,1,19)+ Se + "0")
- Insert Into comando;
- VALUES ("B" + Se + Padr(Alltrim(Substr(det.detalle,20,20)),20,".") + ;
- Se +Alltrim(Str(det.cantidad,6,2)+"0")+ Se + ;
- ALLTRIM(Str(det.unitario,9,2)) + Se + ;
- ALLTRIM(Str(det.poriva,5,2)) + Se + ;
- "M" + Se + "0.00" + Se + "0" + Se + "T")
- Else
- Insert Into comando;
- VALUES ("B" + Se + det.unidad+" "+det.detalle+ Se +;
- ALLTRIM(Str(det.cantidad,11,2))+ Se + ;
- ALLTRIM(Str(det.unitario,13,2)) + Se +;
- ALLTRIM(Str(det.poriva,5,2)) + Se + ;
- "M" + Se + "0" + Se + "" + Se + "T")
- Endif
- Endif
- Endif
- Select("det")
- Skip
- Enddo
- If This.condicion <> "C"
- If This.Ticket = "S"
- If This.contado = "S"
- Insert Into comando;
- VALUES (Chr(68)+ Se + Substr(formapago.detalle,1,30)+ Se + ;
- ALLTRIM(Str(ThisForm.Saldacontado.txtPago.Value,10,2))+ Se +"T"+ Se+"0")
- Else
- Insert Into comando;
- VALUES ( Chr(68)+ Se + Substr(formapago.detalle,1,30)+ ;
- Se + Alltrim(Str(ThisForm.Saldacontado.txtPago.Value,10,2))+ Se +"T"+ Se+"0")
- Endif
- Else
- If This.contado = "S"
- Insert Into comando;
- VALUES (Chr(68)+ Se + Alltrim(formapago.detalle)+ Se + ;
- ALLTRIM(Str(ThisForm.Saldacontado.txtPago.Value,12,2))+ Se +"T"+ Se+"0")
- Else
- Insert Into comando;
- VALUES(Chr(68)+ Se + Alltrim(formapago.detalle)+ Se + ;
- ALLTRIM(Str(ThisForm.Saldacontado.txtPago.Value,12,2))+ Se +"T"+ Se+"0")
- Endif
- Endif
- Endif
- If This.condicion <> "C"
- Insert Into comando;
- VALUES (Chr(69))
- Else
- Insert Into comando;
- VALUES ( Chr(129) )
- Endif
- &&en esta parte copio el archivo con los comandos a la carpeta desde el cual
- &&el spooler de impresion lee el archivo
- If This.Ticket ="S"
- && si es ticket me fijo a cual impresora debo enviar
- If lImpreFiscal
- mtXt = Alltrim(impfis.dircoticket) + Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(impfis.dirreticket) + Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Else
- mtXt = Alltrim(parametr.dirco)+"715\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(parametr.dirre)+"715\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Endif
- *!* cDirCom = "fpserver715" + "\impred.exe"
- *!* cDirCom = Fullpath(cDirCom)
- *!* && Mato el proceso del spooler y lo vuelvo a cargar
- *!* This.killprocessbyname("impred.exe")
- *!* This.killprocessbyname("wspooler.exe")
- *!* oShell = Createobject("Shell.Application")
- *!* oShell.ShellExecute (cDirCom)
- Else
- &&aca envio a la 320
- If lImpreFiscal
- mtXt = Alltrim(impfis.dircofactura) + Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(impfis.dirrefactura) + Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Else
- mtXt = Alltrim(parametr.dirco)+"320\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(parametr.dirre)+"320\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Endif
- Endif
- Select("comando")
- Goto Top
- &&en caso de que tenga un archivo en la cola de impresion de la impresora
- &&no se deja imprimir
- *Browse
- If File(mtXt)
- Messagebox("ATENCION: Ud. ya tiene un Documento en Cola de Impresión"+Chr(10)+Chr(13)+;
- " AGUARDE a que el mismo sea impreso o elimínelo luego vuelva a intentar")
- Return This.TodoOK
- Else
- Copy To &mtXt Sdf
- If File(maNs)
- Erase &maNs
- Endif
- If File(Alltrim(paramfac.dirpa)+"SPOOLER.LOG")
- Erase (Alltrim(paramfac.dirpa)+"SPOOLER.LOG")
- Endif
- Wait Windows 'Esperando Respuesta del Controlador Fiscal...' Nowait
- fd = -1
- intentos =1
- Do While fd < 0 .And. Lastkey() != 27
- fd = Fopen(maNs, 0)
- This.LeerSpooler("T")
- If intentos = 30
- Messagebox("ATENCION: Verifique que el Controlador Esté Conectado y Encendido. " + Chr(10) + Chr(13)+ ;
- "Verifique además que el Programa Spooler se esté ejecutando " + Chr(10) + Chr(13)+ ;
- "en el equipo al cual se encuentra conectado el Controlador Fiscal")
- This.LeerSpooler("T")
- Endif
- If intentos = 70
- Messagebox("ATENCION: Tiempo de Espera Agotado !!! Presione ESC. para cancelar este Comprobante")
- This.LeerSpooler("T")
- Endif
- intentos = intentos + 1
- *For i=1 To 100
- *Next
- Inkey(1)
- If Lastkey() = 27
- If Substr(comando.comando,17,16) = "Impresor Ocupado"
- Messagebox("ATENCION: No se aconseja cancelar este documento por programa, "+;
- CHR(10)+Chr(13)+"La impresora ya lo ha procesado y saldrá impreso"+;
- CHR(10)+Chr(13)+ "una vez que esta se ponga en linea")
- Endif
- If Messagebox("ATENCION: Realmente desea Cancelar la Emisión de este Documento??",4+256) = 6
- Messagebox(" Se proceder a Cancelar el Documento por Sistema"+;
- CHR(10)+Chr(13)+" Verifique que la impresora también lo haya Cancelado.")
- Keyboard '{ESC}'
- Else
- Keyboard ""
- Endif
- Endif
- Enddo
- If Lastkey() = 27.Or. fd < 0
- If File(mtXt)
- Erase &mtXt
- Endif
- fd = Fopen((Alltrim(paramfac.dirpa)+"SPOOLER.LOG"), 0)
- If fd < 0
- Messagebox("Operación Cancelada: ERROR de comunicaciones con el Controlador.; Probablemente no se este ejecutando Spooler. ")
- Else
- fd =Fclose(fd)
- This.LeerSpooler("T")
- Endif
- Else
- fd = Fclose(fd)
- Select("comando")
- Zap
- Append From &maNs Sdf
- Goto Bottom
- This.numero = Val(Substr(comando.comando,35,8))
- If This.numero <> 0
- SQLExec(goApp.nCon, "select * from puntero where sucursal=?param.sucursal","puntero")
- If This.Ticket = "S"
- If This.MasDeMil
- This.numero = Val('0009'+strzero(This.numero,8))
- Else
- If lImpreFiscal
- This.numero = Val(impfis.PtoVtaTicket+strzero(This.numero,8))
- Else
- If Param.sucursal=0
- If File("c:\0009.txt")
- This.numero = Val(strzero(9,4)+strzero(This.numero,8))
- Else
- This.numero = Val(strzero(puntero.pvta_tic,4)+strzero(This.numero,8))
- Endif
- Else
- If Param.sucursal = 1
- This.numero = Val(strzero(8,4)+strzero(This.numero,8))
- Endif
- Endif
- Endif
- Endif
- Else
- If lImpreFiscal
- This.numero = Val(impfis.PtoVtaFac+strzero(This.numero,8))
- Else
- This.numero = Val(strzero(puntero.pvta_fac,4)+strzero(This.numero,8))
- Endif
- Endif
- This.TodoOK = .T.
- Endif
- Endif
- If File((Alltrim(paramfac.dirpa)+"SPOOLER.LOG"))
- Erase Alltrim(paramfac.dirpa)+"SPOOLER.LOG"
- Endif
- Endif
- *This.killprocessbyname("impred.exe")
- *This.killprocessbyname("wspooler.exe")
- Set Talk &cTalk
- Return This.Todo
- *!* This.ticket = This.DefineComp()
- *!* Enddo
- This.Ticket = 'S'
- Se = Chr(28) &&separador de comandos
- &&this.condicion indica si es nota de credito o factura o nota de debito
- If This.condicion <> "C"
- If This.condicion = "D" &¬a de debito
- If This.clase = "B"
- TIPO_FACTURA = "E"
- Else
- TIPO_FACTURA = "D"
- Endif
- Else
- && si no es nota de debito ni credito es factura
- If This.clase = "B" Or this.clase = "C"
- TIPO_FACTURA = "B"
- Else
- TIPO_FACTURA = "A"
- Endif
- Endif
- Else
- If This.clase = "B"
- TIPO_FACTURA = "S"
- Else
- TIPO_FACTURA = "R"
- Endif
- Endif
- &&traigo la tabla de parametros
- *!* If SQLExec(Thisform.con, "select * from parametr","parametr") = -1
- *!* Messagebox("Se ha producido un error al recuperar el tipo de Documento" + Chr(10)+Chr(13)+Message(),0+48,"ERROR")
- *!* Return -1
- *!* Endif
- &&indica si el cliente tiene que poseer cuit
- If tiporesp.obligacuit
- If Empty( Val( Strtran( clientes.cuit, "-" ) ) )
- Messagebox ("ATENCION: Falta Registrar CUIT de Cliente", 0+48, "CUIT")
- Do While Val(ndocu) < 2
- ndocu = Inputbox("Ingrese CUIT")
- Enddo
- ndocu = Alltrim( Strtran( ndocu, "-" ) )
- Else
- TIPO_DOCU = 'C' &&tiporesp.tipo_iva &&"C"
- ndocu = Alltrim( Strtran( clientes.cuit, "-" ) )
- Endif
- Else
- If SQLExec(goApp.nCon, "select * from tipodoc where codigo=?clientes.tipodocu","tipodoc") = -1
- goApp.Error()
- Return -1
- Endif
- If Reccount("tipodoc") > 0
- TIPO_DOCU = tipodoc.tipo
- Else
- TIPO_DOCU = '2'
- Endif
- ndocu = Alltrim(Str(clientes.dni))
- If Val(ndocu) < 2
- ndocu = '11111111'
- Endif
- Endif
- TIPO_IVA = tiporesp.TIPOIVA
- Select("comando")
- &&me fijo si es ticket factura o factura
- If This.Ticket = "S"
- lin = "5"
- Else
- lin = "3"
- Endif
- If This.Ticket = "N"
- &&en caso de ser factura imprimo todo el encabezado que va en la factura
- Select("comando")
- Insert Into comando;
- VALUES( "]" + Se + "1" + Se + Chr(127) )
- Insert Into comando;
- VALUES( "]" + Se + "2" + Se + Chr(127) )
- Insert Into comando;
- values( "]" + Se + "2" + Se + "Ing.Brut. 914-532186-1" )
- If This.contado = "N"
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "Vendedor: "+Alltrim(vendedor.nom_ven)+;
- SPACE(10)+"Vencimiento de este Comp.: "+;
- DTOC(This.FechaVen(Thisform.txtFecha.Value))+;
- " Saldo Actual de CTA_CTE(S.E.U.O.): $"+;
- ALLTRIM(Str((m.salctacte),12,2)))
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + "Vendedor: "+;
- ALLTRIM(vendedor.nom_ven)+;
- SPACE(10)+"Vencimiento de este Comp.: "+;
- DTOC(This.FechaVen(Thisform.txtFecha.Value)))
- Endif
- lin = Str(Val(lin)+1,1,0)
- Do Case
- Case Used("obsfac")
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + "OBS.: "+Alltrim(obsfac.obs1)+Alltrim(obsfac.obs2))
- Case This.pagoanticipado &&det.pagoanticipado
- If det.reparto
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + "PAGO ANTICIPADO - REPARTO")
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + "PAGO ANTICIPADO - RETIRA")
- Endif
- Case This.lReparto
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + "MERCADERIA DE REPARTO")
- Case !This.lReparto
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + "MERCADERIA PARA RETIRAR")
- Otherwise
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + "DEVOLUCIONES DENTRO DE LAS 48 HRS.")
- Endcase
- lin = Str(Val(lin)+1,1,0)
- This.letras.dicenum(m.nTOTAL)
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se + ;
- "SON:" + This.letras.retorno)
- lin = "11"
- &&especifico las formas de cancelacion que posee la factura
- If pagos.adic1 > 0 .Or. pagos.plazo1 > 0
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se + ;
- "OPCION DE PAGO: Hasta el "+;
- Dtoc(Thisform.txtFecha.Value+This.dias())+ " "+;
- STR(pagos.adic1)+" % Desc. $ "+;
- STR(m.nTOTAL*pagos.adic1/100,08,2)+;
- " Paga $ "+Str((m.nTOTAL-(m.nTOTAL*pagos.adic1)/100),10,2))
- Else
- If Inlist(pagos.pago,'00','01','02')
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se + ;
- "OPCION DE PAGO: Contado Efectivo"+;
- " 3% Desc. "+;
- " Paga $ "+ Str(m.nTOTAL,10,2))
- Else
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se + Chr(127))
- Endif
- Endif
- lin = Str(Val(lin)+1,2,0)
- If pagos.adic2 > 0 .Or. pagos.plazo2 > 0
- If Isnull(pagos.dia) Or Empty(pagos.dia)
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se +;
- "OPCION DE PAGO: Hasta el "+ ;
- DTOC(This.FechaVen(Thisform.txtFecha.Value))+" "+;
- STR(pagos.adic2)+" % Desc. $ ";
- +Str(m.nTOTAL*pagos.adic2/100,08,2)+;
- " Paga $ "+Str((m.nTOTAL-(m.nTOTAL*pagos.adic2)/100),10,2))
- Else
- If pagos.pago = '51'
- *!* Pongo esto para que en esta condicion no me sume los dias de ADIC2
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "OPCION DE PAGO: Hasta el "+ ;
- DTOC(pagos.dia)+" "+;
- STR(pagos.adic2)+" % Desc. $ "+;
- STR(m.nTOTAL*pagos.adic2/100,08,2)+;
- " Paga $ "+Str((m.nTOTAL-(m.nTOTAL*pagos.adic2)/100),10,2))
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "OPCION DE PAGO: Hasta el "+ ;
- DTOC(This.FechaVen(Thisform.txtFecha.Value))+" "+;
- STR(pagos.adic2)+" % Desc. $ "+;
- STR(m.nTOTAL*pagos.adic2/100,08,2)+;
- " Paga $ "+Str((m.nTOTAL-(m.nTOTAL*pagos.adic2)/100),10,2))
- Endif
- Endif
- Else
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se + Chr(127) )
- Endif
- lin = Str(Val(lin)+1,2,0)
- If pagos.adic3 > 0 .Or. pagos.plazo3 >0
- If Isnull(pagos.dia) Or Empty(pagos.dia)
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "OPCION DE PAGO: Hasta el "+ ;
- DTOC(Thisform.txtFecha.Value+Cast(pagos.dias1 As Integer))+" "+;
- STR(pagos.adic3)+" % Desc. $ "+;
- STR(m.nTOTAL*pagos.adic3/100,08,2)+;
- " Paga $ "+Str((m.nTOTAL-(m.nTOTAL*pagos.adic3/100)),10,2))
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "OPCION DE PAGO: Hasta el "+ ;
- DTOC(pagos.dia+Cast(pagos.dias1 As Integer))+" "+;
- STR(pagos.adic3)+" % Desc. $ "+;
- STR(m.nTOTAL*pagos.adic3/100,08,2)+;
- " Paga $ "+Str((m.nTOTAL-(m.nTOTAL*pagos.adic3/100)),10,2))
- Endif
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + Chr(127))
- Endif
- lin = Str(Val(lin)+1,2,0)
- *!* Insert Into comando;
- *!* VALUES ("]" + Se + lin + Se + Chr(127))
- If m.nFlete > 0 Or m.nDRet > 0
- If m.nFlete > 0
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "Prec. de Merc. Incl. Flete "+ ;
- Transform(m.nFlete, "@$ 99,999,999.99"))
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "Merc. Incl. Desc p/RETIRA "+ ;
- Transform(m.nDRet, "@$ 99,999,999.99"))
- Endif
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + Chr(127))
- Endif
- &&si se factura sobre remitos se imprimen los remitos afectados
- If Thisform.viene = "X" &&hay q revisar esto para ver q cuando se factura de remitos se imprima
- Insert Into comando;
- VALUES ( Chr(147) + Se + "1" + Se + Substr(This.remitosafacturar,1,17))
- If !Empty(Substr(This.remitosafacturar,19,20))
- Insert Into comando;
- VALUES (Chr(147) + Se + "2" + Se + Substr(This.remitosafacturar,19,20))
- Endif
- Endif
- Else
- If This.contado = 'N'
- Insert Into comando;
- values("]" + Se + lin + Se+;
- " Saldo de CTA_CTE: $"+;
- ALLTRIM(Str((m.salctacte),12,2)))
- lin = '6'
- Else
- Insert Into comando;
- values("]" + Se + lin + Se + Chr(127))
- lin = '6'
- Endif
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se + "Vendedor: "+Alltrim(goApp.User) )
- lin = '7'
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + Chr(127))
- lin = '8'
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + Chr(127))
- lin = '11'
- *!* Insert Into comando;
- *!* VALUES ("]" + Se + lin + Se + Chr(127))
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + Chr(127))
- Endif
- If This.Ticket="S"
- Insert Into comando;
- VALUES ( "]" + Se + "9" + Se +Chr(127))
- Insert Into comando;
- VALUES ("]" + Se + "10" + Se +Chr(127))
- If This.condicion = 'C' And Val(sCliente) = 1
- Insert Into comando;
- VALUES ("b" + Se + Substr(sNombre,1,30) + Se + ;
- ndocu + Se + TIPO_IVA + Se + TIPO_DOCU + Se +;
- " S/NOMBRE")
- Else
- Insert Into comando;
- VALUES ("b" + Se + Substr(sNombre,1,30) + Se + ;
- ndocu + Se + TIPO_IVA + Se + TIPO_DOCU + Se +;
- SUBSTR(Alltrim(thisformset.frmCliente.txtDomicilio.Value)+" "+Alltrim(loc.nombre)+;
- " "+Alltrim(loc.provincia),1,40))
- Endif
- Else
- &&"["+sCliente+"] "+
- Insert Into comando;
- VALUES ( "b" + Se + "[" + sCliente + "] " + Substr(sNombre,1,40) + Se +;
- ndocu + Se + TIPO_IVA + Se + TIPO_DOCU + Se + ;
- ALLTRIM(Thisform.txtDom.Value)+" ("+Alltrim(clientes.codpos)+") "+;
- Alltrim(loc.nombre)+" "+Alltrim(loc.provincia))
- Endif
- If This.condicion <> "C"
- Insert Into comando;
- VALUES (Chr(64)+Se+TIPO_FACTURA+Se+"T")
- Else
- &&Definir tipo y num de factura afectado por nota de credito
- Insert Into comando;
- VALUES (Chr(147) + Se + "1" + Se + cre.tipoaf + " " + cre.numeroaf)
- Insert Into comando;
- VALUES (Chr(128)+Se+TIPO_FACTURA+Se+"T")
- Endif
- &&el cursor "DET" posee los items a facturar
- Select("det")
- Go Top
- Do While ! Eof()
- *!* Create Cursor det;
- *!* (cantidad n(12,4), unidad c(8), detalle c(40), total n(12,2), idArticulo int,;
- *!* unitario n(12,2), costo n(12,2), montoiva n(12,2), montodgr n(12,2), montomuni N(12,2),;
- *!* poriva n(12,2), tipoiva c(2))
- If det.unitario != 0
- If This.clase = "A"
- If This.Ticket = "S"
- Insert Into comando;
- VALUES ("A" + Se + det.unidad +" "+Substr(det.detalle,1,19)+ Se + "0")
- Insert Into comando;
- VALUES ("B" + Se + Padr(Alltrim(Substr(det.detalle,20,20)),20,".") + Se +;
- ALLTRIM(Str(det.cantidad,6,2)+"0")+ Se +;
- ALLTRIM(Str(det.unitario,9,2)) + Se + ;
- ALLTRIM(Str(det.poriva,5,2)) + Se +;
- "M" + Se + "0.00" + Se + "0" + Se + "T")
- Else
- Insert Into comando;
- VALUES ("B" + Se + det.unidad +" "+det.detalle+ Se + ;
- ALLTRIM(Str(det.cantidad,11,2))+ Se + ;
- Alltrim(Str(det.unitario,13,2)) + ;
- Se +Alltrim(Str(det.poriva,5,2)) + Se + ;
- "M" + Se + "0" + Se + "" + Se + "T")
- Endif
- Else
- If This.Ticket = "S"
- Insert Into comando;
- VALUES ( "A" + Se + det.unidad +" "+Substr(det.detalle,1,19)+ Se + "0")
- Insert Into comando;
- VALUES ("B" + Se + Padr(Alltrim(Substr(det.detalle,20,20)),20,".") + ;
- Se +Alltrim(Str(det.cantidad,6,2)+"0")+ Se + ;
- ALLTRIM(Str(det.unitario,9,2)) + Se + ;
- ALLTRIM(Str(det.poriva,5,2)) + Se + ;
- "M" + Se + "0.00" + Se + "0" + Se + "T")
- Else
- Insert Into comando;
- VALUES ("B" + Se + det.unidad+" "+det.detalle+ Se +;
- ALLTRIM(Str(det.cantidad,11,2))+ Se + ;
- ALLTRIM(Str(det.unitario,13,2)) + Se +;
- ALLTRIM(Str(det.poriva,5,2)) + Se + ;
- "M" + Se + "0" + Se + "" + Se + "T")
- Endif
- Endif
- Endif
- Select("det")
- Skip
- Enddo
- If This.condicion <> "C"
- If This.Ticket = "S"
- If This.contado = "S"
- Insert Into comando;
- VALUES (Chr(68)+ Se + Substr(formapago.detalle,1,30)+ Se + ;
- ALLTRIM(Str(ThisForm.Saldacontado.txtPago.Value,10,2))+ Se +"T"+ Se+"0")
- Else
- Insert Into comando;
- VALUES ( Chr(68)+ Se + Substr(formapago.detalle,1,30)+ ;
- Se + Alltrim(Str(ThisForm.Saldacontado.txtPago.Value,10,2))+ Se +"T"+ Se+"0")
- Endif
- Else
- If This.contado = "S"
- Insert Into comando;
- VALUES (Chr(68)+ Se + Alltrim(formapago.detalle)+ Se + ;
- ALLTRIM(Str(ThisForm.Saldacontado.txtPago.Value,12,2))+ Se +"T"+ Se+"0")
- Else
- Insert Into comando;
- VALUES(Chr(68)+ Se + Alltrim(formapago.detalle)+ Se + ;
- ALLTRIM(Str(ThisForm.Saldacontado.txtPago.Value,12,2))+ Se +"T"+ Se+"0")
- Endif
- Endif
- Endif
- If This.condicion <> "C"
- Insert Into comando;
- VALUES (Chr(69))
- Else
- Insert Into comando;
- VALUES ( Chr(129) )
- Endif
- &&en esta parte copio el archivo con los comandos a la carpeta desde el cual
- &&el spooler de impresion lee el archivo
- If This.Ticket ="S"
- && si es ticket me fijo a cual impresora debo enviar
- If lImpreFiscal
- mtXt = Alltrim(impfis.dircoticket) + Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(impfis.dirreticket) + Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Else
- mtXt = Alltrim(parametr.dirco)+"715\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(parametr.dirre)+"715\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Endif
- *!* cDirCom = "fpserver715" + "\impred.exe"
- *!* cDirCom = Fullpath(cDirCom)
- *!* && Mato el proceso del spooler y lo vuelvo a cargar
- *!* This.killprocessbyname("impred.exe")
- *!* This.killprocessbyname("wspooler.exe")
- *!* oShell = Createobject("Shell.Application")
- *!* oShell.ShellExecute (cDirCom)
- Else
- &&aca envio a la 320
- If lImpreFiscal
- mtXt = Alltrim(impfis.dircofactura) + Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(impfis.dirrefactura) + Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Else
- mtXt = Alltrim(parametr.dirco)+"320\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(parametr.dirre)+"320\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Endif
- Endif
- Select("comando")
- Goto Top
- &&en caso de que tenga un archivo en la cola de impresion de la impresora
- &&no se deja imprimir
- *Browse
- If File(mtXt)
- Messagebox("ATENCION: Ud. ya tiene un Documento en Cola de Impresión"+Chr(10)+Chr(13)+;
- " AGUARDE a que el mismo sea impreso o elimínelo luego vuelva a intentar")
- Return This.TodoOK
- Else
- Copy To &mtXt Sdf
- If File(maNs)
- Erase &maNs
- Endif
- If File(Alltrim(paramfac.dirpa)+"SPOOLER.LOG")
- Erase (Alltrim(paramfac.dirpa)+"SPOOLER.LOG")
- Endif
- Wait Windows 'Esperando Respuesta del Controlador Fiscal...' Nowait
- fd = -1
- intentos =1
- Do While fd < 0 .And. Lastkey() != 27
- fd = Fopen(maNs, 0)
- This.LeerSpooler("T")
- If intentos = 30
- Messagebox("ATENCION: Verifique que el Controlador Esté Conectado y Encendido. " + Chr(10) + Chr(13)+ ;
- "Verifique además que el Programa Spooler se esté ejecutando " + Chr(10) + Chr(13)+ ;
- "en el equipo al cual se encuentra conectado el Controlador Fiscal")
- This.LeerSpooler("T")
- Endif
- If intentos = 70
- Messagebox("ATENCION: Tiempo de Espera Agotado !!! Presione ESC. para cancelar este Comprobante")
- This.LeerSpooler("T")
- Endif
- intentos = intentos + 1
- *For i=1 To 100
- *Next
- Inkey(1)
- If Lastkey() = 27
- If Substr(comando.comando,17,16) = "Impresor Ocupado"
- Messagebox("ATENCION: No se aconseja cancelar este documento por programa, "+;
- CHR(10)+Chr(13)+"La impresora ya lo ha procesado y saldrá impreso"+;
- CHR(10)+Chr(13)+ "una vez que esta se ponga en linea")
- Endif
- If Messagebox("ATENCION: Realmente desea Cancelar la Emisión de este Documento??",4+256) = 6
- Messagebox(" Se proceder a Cancelar el Documento por Sistema"+;
- CHR(10)+Chr(13)+" Verifique que la impresora también lo haya Cancelado.")
- Keyboard '{ESC}'
- Else
- Keyboard ""
- Endif
- Endif
- Enddo
- If Lastkey() = 27.Or. fd < 0
- If File(mtXt)
- Erase &mtXt
- Endif
- fd = Fopen((Alltrim(paramfac.dirpa)+"SPOOLER.LOG"), 0)
- If fd < 0
- Messagebox("Operación Cancelada: ERROR de comunicaciones con el Controlador.; Probablemente no se este ejecutando Spooler. ")
- Else
- fd =Fclose(fd)
- This.LeerSpooler("T")
- Endif
- Else
- fd = Fclose(fd)
- Select("comando")
- Zap
- Append From &maNs Sdf
- Goto Bottom
- This.numero = Val(Substr(comando.comando,35,8))
- If This.numero <> 0
- SQLExec(goApp.nCon, "select * from puntero where sucursal=?param.sucursal","puntero")
- If This.Ticket = "S"
- If This.MasDeMil
- This.numero = Val('0009'+strzero(This.numero,8))
- Else
- If lImpreFiscal
- This.numero = Val(impfis.PtoVtaTicket+strzero(This.numero,8))
- Else
- If Param.sucursal=0
- If File("c:\0009.txt")
- This.numero = Val(strzero(9,4)+strzero(This.numero,8))
- Else
- This.numero = Val(strzero(puntero.pvta_tic,4)+strzero(This.numero,8))
- Endif
- Else
- If Param.sucursal = 1
- This.numero = Val(strzero(8,4)+strzero(This.numero,8))
- Endif
- Endif
- Endif
- Endif
- Else
- If lImpreFiscal
- This.numero = Val(impfis.PtoVtaFac+strzero(This.numero,8))
- Else
- This.numero = Val(strzero(puntero.pvta_fac,4)+strzero(This.numero,8))
- Endif
- Endif
- This.TodoOK = .T.
- Endif
- Endif
- If File((Alltrim(paramfac.dirpa)+"SPOOLER.LOG"))
- Erase Alltrim(paramfac.dirpa)+"SPOOLER.LOG"
- Endif
- Endif
- *This.killprocessbyname("impred.exe")
- *This.killprocessbyname("wspooler.exe")
- Set Talk &cTalk
- Return This.Todo
- *!* Enddo
- This.Ticket = 'S'
- Se = Chr(28) &&separador de comandos
- &&this.condicion indica si es nota de credito o factura o nota de debito
- If This.condicion <> "C"
- If This.condicion = "D" &¬a de debito
- If This.clase = "B"
- TIPO_FACTURA = "E"
- Else
- TIPO_FACTURA = "D"
- Endif
- Else
- && si no es nota de debito ni credito es factura
- If This.clase = "B" Or this.clase = "C"
- TIPO_FACTURA = "B"
- Else
- TIPO_FACTURA = "A"
- Endif
- Endif
- Else
- If This.clase = "B"
- TIPO_FACTURA = "S"
- Else
- TIPO_FACTURA = "R"
- Endif
- Endif
- &&traigo la tabla de parametros
- *!* If SQLExec(Thisform.con, "select * from parametr","parametr") = -1
- *!* Messagebox("Se ha producido un error al recuperar el tipo de Documento" + Chr(10)+Chr(13)+Message(),0+48,"ERROR")
- *!* Return -1
- *!* Endif
- &&indica si el cliente tiene que poseer cuit
- If tiporesp.obligacuit
- If Empty( Val( Strtran( clientes.cuit, "-" ) ) )
- Messagebox ("ATENCION: Falta Registrar CUIT de Cliente", 0+48, "CUIT")
- Do While Val(ndocu) < 2
- ndocu = Inputbox("Ingrese CUIT")
- Enddo
- ndocu = Alltrim( Strtran( ndocu, "-" ) )
- Else
- TIPO_DOCU = 'C' &&tiporesp.tipo_iva &&"C"
- ndocu = Alltrim( Strtran( clientes.cuit, "-" ) )
- Endif
- Else
- If SQLExec(goApp.nCon, "select * from tipodoc where codigo=?clientes.tipodocu","tipodoc") = -1
- goApp.Error()
- Return -1
- Endif
- If Reccount("tipodoc") > 0
- TIPO_DOCU = tipodoc.tipo
- Else
- TIPO_DOCU = '2'
- Endif
- ndocu = Alltrim(Str(clientes.dni))
- If Val(ndocu) < 2
- ndocu = '11111111'
- Endif
- Endif
- TIPO_IVA = tiporesp.TIPOIVA
- Select("comando")
- &&me fijo si es ticket factura o factura
- If This.Ticket = "S"
- lin = "5"
- Else
- lin = "3"
- Endif
- If This.Ticket = "N"
- &&en caso de ser factura imprimo todo el encabezado que va en la factura
- Select("comando")
- Insert Into comando;
- VALUES( "]" + Se + "1" + Se + Chr(127) )
- Insert Into comando;
- VALUES( "]" + Se + "2" + Se + Chr(127) )
- Insert Into comando;
- values( "]" + Se + "2" + Se + "Ing.Brut. 914-532186-1" )
- If This.contado = "N"
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "Vendedor: "+Alltrim(vendedor.nom_ven)+;
- SPACE(10)+"Vencimiento de este Comp.: "+;
- DTOC(This.FechaVen(Thisform.txtFecha.Value))+;
- " Saldo Actual de CTA_CTE(S.E.U.O.): $"+;
- ALLTRIM(Str((m.salctacte),12,2)))
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + "Vendedor: "+;
- ALLTRIM(vendedor.nom_ven)+;
- SPACE(10)+"Vencimiento de este Comp.: "+;
- DTOC(This.FechaVen(Thisform.txtFecha.Value)))
- Endif
- lin = Str(Val(lin)+1,1,0)
- Do Case
- Case Used("obsfac")
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + "OBS.: "+Alltrim(obsfac.obs1)+Alltrim(obsfac.obs2))
- Case This.pagoanticipado &&det.pagoanticipado
- If det.reparto
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + "PAGO ANTICIPADO - REPARTO")
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + "PAGO ANTICIPADO - RETIRA")
- Endif
- Case This.lReparto
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + "MERCADERIA DE REPARTO")
- Case !This.lReparto
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + "MERCADERIA PARA RETIRAR")
- Otherwise
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + "DEVOLUCIONES DENTRO DE LAS 48 HRS.")
- Endcase
- lin = Str(Val(lin)+1,1,0)
- This.letras.dicenum(m.nTOTAL)
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se + ;
- "SON:" + This.letras.retorno)
- lin = "11"
- &&especifico las formas de cancelacion que posee la factura
- If pagos.adic1 > 0 .Or. pagos.plazo1 > 0
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se + ;
- "OPCION DE PAGO: Hasta el "+;
- Dtoc(Thisform.txtFecha.Value+This.dias())+ " "+;
- STR(pagos.adic1)+" % Desc. $ "+;
- STR(m.nTOTAL*pagos.adic1/100,08,2)+;
- " Paga $ "+Str((m.nTOTAL-(m.nTOTAL*pagos.adic1)/100),10,2))
- Else
- If Inlist(pagos.pago,'00','01','02')
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se + ;
- "OPCION DE PAGO: Contado Efectivo"+;
- " 3% Desc. "+;
- " Paga $ "+ Str(m.nTOTAL,10,2))
- Else
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se + Chr(127))
- Endif
- Endif
- lin = Str(Val(lin)+1,2,0)
- If pagos.adic2 > 0 .Or. pagos.plazo2 > 0
- If Isnull(pagos.dia) Or Empty(pagos.dia)
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se +;
- "OPCION DE PAGO: Hasta el "+ ;
- DTOC(This.FechaVen(Thisform.txtFecha.Value))+" "+;
- STR(pagos.adic2)+" % Desc. $ ";
- +Str(m.nTOTAL*pagos.adic2/100,08,2)+;
- " Paga $ "+Str((m.nTOTAL-(m.nTOTAL*pagos.adic2)/100),10,2))
- Else
- If pagos.pago = '51'
- *!* Pongo esto para que en esta condicion no me sume los dias de ADIC2
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "OPCION DE PAGO: Hasta el "+ ;
- DTOC(pagos.dia)+" "+;
- STR(pagos.adic2)+" % Desc. $ "+;
- STR(m.nTOTAL*pagos.adic2/100,08,2)+;
- " Paga $ "+Str((m.nTOTAL-(m.nTOTAL*pagos.adic2)/100),10,2))
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "OPCION DE PAGO: Hasta el "+ ;
- DTOC(This.FechaVen(Thisform.txtFecha.Value))+" "+;
- STR(pagos.adic2)+" % Desc. $ "+;
- STR(m.nTOTAL*pagos.adic2/100,08,2)+;
- " Paga $ "+Str((m.nTOTAL-(m.nTOTAL*pagos.adic2)/100),10,2))
- Endif
- Endif
- Else
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se + Chr(127) )
- Endif
- lin = Str(Val(lin)+1,2,0)
- If pagos.adic3 > 0 .Or. pagos.plazo3 >0
- If Isnull(pagos.dia) Or Empty(pagos.dia)
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "OPCION DE PAGO: Hasta el "+ ;
- DTOC(Thisform.txtFecha.Value+Cast(pagos.dias1 As Integer))+" "+;
- STR(pagos.adic3)+" % Desc. $ "+;
- STR(m.nTOTAL*pagos.adic3/100,08,2)+;
- " Paga $ "+Str((m.nTOTAL-(m.nTOTAL*pagos.adic3/100)),10,2))
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "OPCION DE PAGO: Hasta el "+ ;
- DTOC(pagos.dia+Cast(pagos.dias1 As Integer))+" "+;
- STR(pagos.adic3)+" % Desc. $ "+;
- STR(m.nTOTAL*pagos.adic3/100,08,2)+;
- " Paga $ "+Str((m.nTOTAL-(m.nTOTAL*pagos.adic3/100)),10,2))
- Endif
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + Chr(127))
- Endif
- lin = Str(Val(lin)+1,2,0)
- *!* Insert Into comando;
- *!* VALUES ("]" + Se + lin + Se + Chr(127))
- If m.nFlete > 0 Or m.nDRet > 0
- If m.nFlete > 0
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "Prec. de Merc. Incl. Flete "+ ;
- Transform(m.nFlete, "@$ 99,999,999.99"))
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "Merc. Incl. Desc p/RETIRA "+ ;
- Transform(m.nDRet, "@$ 99,999,999.99"))
- Endif
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + Chr(127))
- Endif
- &&si se factura sobre remitos se imprimen los remitos afectados
- If Thisform.viene = "X" &&hay q revisar esto para ver q cuando se factura de remitos se imprima
- Insert Into comando;
- VALUES ( Chr(147) + Se + "1" + Se + Substr(This.remitosafacturar,1,17))
- If !Empty(Substr(This.remitosafacturar,19,20))
- Insert Into comando;
- VALUES (Chr(147) + Se + "2" + Se + Substr(This.remitosafacturar,19,20))
- Endif
- Endif
- Else
- If This.contado = 'N'
- Insert Into comando;
- values("]" + Se + lin + Se+;
- " Saldo de CTA_CTE: $"+;
- ALLTRIM(Str((m.salctacte),12,2)))
- lin = '6'
- Else
- Insert Into comando;
- values("]" + Se + lin + Se + Chr(127))
- lin = '6'
- Endif
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se + "Vendedor: "+Alltrim(goApp.User) )
- lin = '7'
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + Chr(127))
- lin = '8'
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + Chr(127))
- lin = '11'
- *!* Insert Into comando;
- *!* VALUES ("]" + Se + lin + Se + Chr(127))
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + Chr(127))
- Endif
- If This.Ticket="S"
- Insert Into comando;
- VALUES ( "]" + Se + "9" + Se +Chr(127))
- Insert Into comando;
- VALUES ("]" + Se + "10" + Se +Chr(127))
- If This.condicion = 'C' And Val(sCliente) = 1
- Insert Into comando;
- VALUES ("b" + Se + Substr(sNombre,1,30) + Se + ;
- ndocu + Se + TIPO_IVA + Se + TIPO_DOCU + Se +;
- " S/NOMBRE")
- Else
- Insert Into comando;
- VALUES ("b" + Se + Substr(sNombre,1,30) + Se + ;
- ndocu + Se + TIPO_IVA + Se + TIPO_DOCU + Se +;
- SUBSTR(Alltrim(thisformset.frmCliente.txtDomicilio.Value)+" "+Alltrim(loc.nombre)+;
- " "+Alltrim(loc.provincia),1,40))
- Endif
- Else
- &&"["+sCliente+"] "+
- Insert Into comando;
- VALUES ( "b" + Se + "[" + sCliente + "] " + Substr(sNombre,1,40) + Se +;
- ndocu + Se + TIPO_IVA + Se + TIPO_DOCU + Se + ;
- ALLTRIM(Thisform.txtDom.Value)+" ("+Alltrim(clientes.codpos)+") "+;
- Alltrim(loc.nombre)+" "+Alltrim(loc.provincia))
- Endif
- If This.condicion <> "C"
- Insert Into comando;
- VALUES (Chr(64)+Se+TIPO_FACTURA+Se+"T")
- Else
- &&Definir tipo y num de factura afectado por nota de credito
- Insert Into comando;
- VALUES (Chr(147) + Se + "1" + Se + cre.tipoaf + " " + cre.numeroaf)
- Insert Into comando;
- VALUES (Chr(128)+Se+TIPO_FACTURA+Se+"T")
- Endif
- &&el cursor "DET" posee los items a facturar
- Select("det")
- Go Top
- Do While ! Eof()
- *!* Create Cursor det;
- *!* (cantidad n(12,4), unidad c(8), detalle c(40), total n(12,2), idArticulo int,;
- *!* unitario n(12,2), costo n(12,2), montoiva n(12,2), montodgr n(12,2), montomuni N(12,2),;
- *!* poriva n(12,2), tipoiva c(2))
- If det.unitario != 0
- If This.clase = "A"
- If This.Ticket = "S"
- Insert Into comando;
- VALUES ("A" + Se + det.unidad +" "+Substr(det.detalle,1,19)+ Se + "0")
- Insert Into comando;
- VALUES ("B" + Se + Padr(Alltrim(Substr(det.detalle,20,20)),20,".") + Se +;
- ALLTRIM(Str(det.cantidad,6,2)+"0")+ Se +;
- ALLTRIM(Str(det.unitario,9,2)) + Se + ;
- ALLTRIM(Str(det.poriva,5,2)) + Se +;
- "M" + Se + "0.00" + Se + "0" + Se + "T")
- Else
- Insert Into comando;
- VALUES ("B" + Se + det.unidad +" "+det.detalle+ Se + ;
- ALLTRIM(Str(det.cantidad,11,2))+ Se + ;
- Alltrim(Str(det.unitario,13,2)) + ;
- Se +Alltrim(Str(det.poriva,5,2)) + Se + ;
- "M" + Se + "0" + Se + "" + Se + "T")
- Endif
- Else
- If This.Ticket = "S"
- Insert Into comando;
- VALUES ( "A" + Se + det.unidad +" "+Substr(det.detalle,1,19)+ Se + "0")
- Insert Into comando;
- VALUES ("B" + Se + Padr(Alltrim(Substr(det.detalle,20,20)),20,".") + ;
- Se +Alltrim(Str(det.cantidad,6,2)+"0")+ Se + ;
- ALLTRIM(Str(det.unitario,9,2)) + Se + ;
- ALLTRIM(Str(det.poriva,5,2)) + Se + ;
- "M" + Se + "0.00" + Se + "0" + Se + "T")
- Else
- Insert Into comando;
- VALUES ("B" + Se + det.unidad+" "+det.detalle+ Se +;
- ALLTRIM(Str(det.cantidad,11,2))+ Se + ;
- ALLTRIM(Str(det.unitario,13,2)) + Se +;
- ALLTRIM(Str(det.poriva,5,2)) + Se + ;
- "M" + Se + "0" + Se + "" + Se + "T")
- Endif
- Endif
- Endif
- Select("det")
- Skip
- Enddo
- If This.condicion <> "C"
- If This.Ticket = "S"
- If This.contado = "S"
- Insert Into comando;
- VALUES (Chr(68)+ Se + Substr(formapago.detalle,1,30)+ Se + ;
- ALLTRIM(Str(ThisForm.Saldacontado.txtPago.Value,10,2))+ Se +"T"+ Se+"0")
- Else
- Insert Into comando;
- VALUES ( Chr(68)+ Se + Substr(formapago.detalle,1,30)+ ;
- Se + Alltrim(Str(ThisForm.Saldacontado.txtPago.Value,10,2))+ Se +"T"+ Se+"0")
- Endif
- Else
- If This.contado = "S"
- Insert Into comando;
- VALUES (Chr(68)+ Se + Alltrim(formapago.detalle)+ Se + ;
- ALLTRIM(Str(ThisForm.Saldacontado.txtPago.Value,12,2))+ Se +"T"+ Se+"0")
- Else
- Insert Into comando;
- VALUES(Chr(68)+ Se + Alltrim(formapago.detalle)+ Se + ;
- ALLTRIM(Str(ThisForm.Saldacontado.txtPago.Value,12,2))+ Se +"T"+ Se+"0")
- Endif
- Endif
- Endif
- If This.condicion <> "C"
- Insert Into comando;
- VALUES (Chr(69))
- Else
- Insert Into comando;
- VALUES ( Chr(129) )
- Endif
- &&en esta parte copio el archivo con los comandos a la carpeta desde el cual
- &&el spooler de impresion lee el archivo
- If This.Ticket ="S"
- && si es ticket me fijo a cual impresora debo enviar
- If lImpreFiscal
- mtXt = Alltrim(impfis.dircoticket) + Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(impfis.dirreticket) + Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Else
- mtXt = Alltrim(parametr.dirco)+"715\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(parametr.dirre)+"715\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Endif
- *!* cDirCom = "fpserver715" + "\impred.exe"
- *!* cDirCom = Fullpath(cDirCom)
- *!* && Mato el proceso del spooler y lo vuelvo a cargar
- *!* This.killprocessbyname("impred.exe")
- *!* This.killprocessbyname("wspooler.exe")
- *!* oShell = Createobject("Shell.Application")
- *!* oShell.ShellExecute (cDirCom)
- Else
- &&aca envio a la 320
- If lImpreFiscal
- mtXt = Alltrim(impfis.dircofactura) + Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(impfis.dirrefactura) + Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Else
- mtXt = Alltrim(parametr.dirco)+"320\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(parametr.dirre)+"320\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Endif
- Endif
- Select("comando")
- Goto Top
- &&en caso de que tenga un archivo en la cola de impresion de la impresora
- &&no se deja imprimir
- *Browse
- If File(mtXt)
- Messagebox("ATENCION: Ud. ya tiene un Documento en Cola de Impresión"+Chr(10)+Chr(13)+;
- " AGUARDE a que el mismo sea impreso o elimínelo luego vuelva a intentar")
- Return This.TodoOK
- Else
- Copy To &mtXt Sdf
- If File(maNs)
- Erase &maNs
- Endif
- If File(Alltrim(paramfac.dirpa)+"SPOOLER.LOG")
- Erase (Alltrim(paramfac.dirpa)+"SPOOLER.LOG")
- Endif
- Wait Windows 'Esperando Respuesta del Controlador Fiscal...' Nowait
- fd = -1
- intentos =1
- Do While fd < 0 .And. Lastkey() != 27
- fd = Fopen(maNs, 0)
- This.LeerSpooler("T")
- If intentos = 30
- Messagebox("ATENCION: Verifique que el Controlador Esté Conectado y Encendido. " + Chr(10) + Chr(13)+ ;
- "Verifique además que el Programa Spooler se esté ejecutando " + Chr(10) + Chr(13)+ ;
- "en el equipo al cual se encuentra conectado el Controlador Fiscal")
- This.LeerSpooler("T")
- Endif
- If intentos = 70
- Messagebox("ATENCION: Tiempo de Espera Agotado !!! Presione ESC. para cancelar este Comprobante")
- This.LeerSpooler("T")
- Endif
- intentos = intentos + 1
- *For i=1 To 100
- *Next
- Inkey(1)
- If Lastkey() = 27
- If Substr(comando.comando,17,16) = "Impresor Ocupado"
- Messagebox("ATENCION: No se aconseja cancelar este documento por programa, "+;
- CHR(10)+Chr(13)+"La impresora ya lo ha procesado y saldrá impreso"+;
- CHR(10)+Chr(13)+ "una vez que esta se ponga en linea")
- Endif
- If Messagebox("ATENCION: Realmente desea Cancelar la Emisión de este Documento??",4+256) = 6
- Messagebox(" Se proceder a Cancelar el Documento por Sistema"+;
- CHR(10)+Chr(13)+" Verifique que la impresora también lo haya Cancelado.")
- Keyboard '{ESC}'
- Else
- Keyboard ""
- Endif
- Endif
- Enddo
- If Lastkey() = 27.Or. fd < 0
- If File(mtXt)
- Erase &mtXt
- Endif
- fd = Fopen((Alltrim(paramfac.dirpa)+"SPOOLER.LOG"), 0)
- If fd < 0
- Messagebox("Operación Cancelada: ERROR de comunicaciones con el Controlador.; Probablemente no se este ejecutando Spooler. ")
- Else
- fd =Fclose(fd)
- This.LeerSpooler("T")
- Endif
- Else
- fd = Fclose(fd)
- Select("comando")
- Zap
- Append From &maNs Sdf
- Goto Bottom
- This.numero = Val(Substr(comando.comando,35,8))
- If This.numero <> 0
- SQLExec(goApp.nCon, "select * from puntero where sucursal=?param.sucursal","puntero")
- If This.Ticket = "S"
- If This.MasDeMil
- This.numero = Val('0009'+strzero(This.numero,8))
- Else
- If lImpreFiscal
- This.numero = Val(impfis.PtoVtaTicket+strzero(This.numero,8))
- Else
- If Param.sucursal=0
- If File("c:\0009.txt")
- This.numero = Val(strzero(9,4)+strzero(This.numero,8))
- Else
- This.numero = Val(strzero(puntero.pvta_tic,4)+strzero(This.numero,8))
- Endif
- Else
- If Param.sucursal = 1
- This.numero = Val(strzero(8,4)+strzero(This.numero,8))
- Endif
- Endif
- Endif
- Endif
- Else
- If lImpreFiscal
- This.numero = Val(impfis.PtoVtaFac+strzero(This.numero,8))
- Else
- This.numero = Val(strzero(puntero.pvta_fac,4)+strzero(This.numero,8))
- Endif
- Endif
- This.TodoOK = .T.
- Endif
- Endif
- If File((Alltrim(paramfac.dirpa)+"SPOOLER.LOG"))
- Erase Alltrim(paramfac.dirpa)+"SPOOLER.LOG"
- Endif
- Endif
- *This.killprocessbyname("impred.exe")
- *This.killprocessbyname("wspooler.exe")
- Set Talk &cTalk
- Return This.Todo
- *!* If SQLExec(Thisform.con, "select * from parametr","parametr") = -1
- *!* Messagebox("Se ha producido un error al recuperar el tipo de Documento" + Chr(10)+Chr(13)+Message(),0+48,"ERROR")
- *!* Return -1
- *!* Endif
- &&indica si el cliente tiene que poseer cuit
- If tiporesp.obligacuit
- If Empty( Val( Strtran( clientes.cuit, "-" ) ) )
- Messagebox ("ATENCION: Falta Registrar CUIT de Cliente", 0+48, "CUIT")
- Do While Val(ndocu) < 2
- ndocu = Inputbox("Ingrese CUIT")
- Enddo
- ndocu = Alltrim( Strtran( ndocu, "-" ) )
- Else
- TIPO_DOCU = 'C' &&tiporesp.tipo_iva &&"C"
- ndocu = Alltrim( Strtran( clientes.cuit, "-" ) )
- Endif
- Else
- If SQLExec(goApp.nCon, "select * from tipodoc where codigo=?clientes.tipodocu","tipodoc") = -1
- goApp.Error()
- Return -1
- Endif
- If Reccount("tipodoc") > 0
- TIPO_DOCU = tipodoc.tipo
- Else
- TIPO_DOCU = '2'
- Endif
- ndocu = Alltrim(Str(clientes.dni))
- If Val(ndocu) < 2
- ndocu = '11111111'
- Endif
- Endif
- TIPO_IVA = tiporesp.TIPOIVA
- Select("comando")
- &&me fijo si es ticket factura o factura
- If This.Ticket = "S"
- lin = "5"
- Else
- lin = "3"
- Endif
- If This.Ticket = "N"
- &&en caso de ser factura imprimo todo el encabezado que va en la factura
- Select("comando")
- Insert Into comando;
- VALUES( "]" + Se + "1" + Se + Chr(127) )
- Insert Into comando;
- VALUES( "]" + Se + "2" + Se + Chr(127) )
- Insert Into comando;
- values( "]" + Se + "2" + Se + "Ing.Brut. 914-532186-1" )
- If This.contado = "N"
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "Vendedor: "+Alltrim(vendedor.nom_ven)+;
- SPACE(10)+"Vencimiento de este Comp.: "+;
- DTOC(This.FechaVen(Thisform.txtFecha.Value))+;
- " Saldo Actual de CTA_CTE(S.E.U.O.): $"+;
- ALLTRIM(Str((m.salctacte),12,2)))
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + "Vendedor: "+;
- ALLTRIM(vendedor.nom_ven)+;
- SPACE(10)+"Vencimiento de este Comp.: "+;
- DTOC(This.FechaVen(Thisform.txtFecha.Value)))
- Endif
- lin = Str(Val(lin)+1,1,0)
- Do Case
- Case Used("obsfac")
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + "OBS.: "+Alltrim(obsfac.obs1)+Alltrim(obsfac.obs2))
- Case This.pagoanticipado &&det.pagoanticipado
- If det.reparto
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + "PAGO ANTICIPADO - REPARTO")
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + "PAGO ANTICIPADO - RETIRA")
- Endif
- Case This.lReparto
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + "MERCADERIA DE REPARTO")
- Case !This.lReparto
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + "MERCADERIA PARA RETIRAR")
- Otherwise
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + "DEVOLUCIONES DENTRO DE LAS 48 HRS.")
- Endcase
- lin = Str(Val(lin)+1,1,0)
- This.letras.dicenum(m.nTOTAL)
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se + ;
- "SON:" + This.letras.retorno)
- lin = "11"
- &&especifico las formas de cancelacion que posee la factura
- If pagos.adic1 > 0 .Or. pagos.plazo1 > 0
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se + ;
- "OPCION DE PAGO: Hasta el "+;
- Dtoc(Thisform.txtFecha.Value+This.dias())+ " "+;
- STR(pagos.adic1)+" % Desc. $ "+;
- STR(m.nTOTAL*pagos.adic1/100,08,2)+;
- " Paga $ "+Str((m.nTOTAL-(m.nTOTAL*pagos.adic1)/100),10,2))
- Else
- If Inlist(pagos.pago,'00','01','02')
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se + ;
- "OPCION DE PAGO: Contado Efectivo"+;
- " 3% Desc. "+;
- " Paga $ "+ Str(m.nTOTAL,10,2))
- Else
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se + Chr(127))
- Endif
- Endif
- lin = Str(Val(lin)+1,2,0)
- If pagos.adic2 > 0 .Or. pagos.plazo2 > 0
- If Isnull(pagos.dia) Or Empty(pagos.dia)
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se +;
- "OPCION DE PAGO: Hasta el "+ ;
- DTOC(This.FechaVen(Thisform.txtFecha.Value))+" "+;
- STR(pagos.adic2)+" % Desc. $ ";
- +Str(m.nTOTAL*pagos.adic2/100,08,2)+;
- " Paga $ "+Str((m.nTOTAL-(m.nTOTAL*pagos.adic2)/100),10,2))
- Else
- If pagos.pago = '51'
- *!* Pongo esto para que en esta condicion no me sume los dias de ADIC2
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "OPCION DE PAGO: Hasta el "+ ;
- DTOC(pagos.dia)+" "+;
- STR(pagos.adic2)+" % Desc. $ "+;
- STR(m.nTOTAL*pagos.adic2/100,08,2)+;
- " Paga $ "+Str((m.nTOTAL-(m.nTOTAL*pagos.adic2)/100),10,2))
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "OPCION DE PAGO: Hasta el "+ ;
- DTOC(This.FechaVen(Thisform.txtFecha.Value))+" "+;
- STR(pagos.adic2)+" % Desc. $ "+;
- STR(m.nTOTAL*pagos.adic2/100,08,2)+;
- " Paga $ "+Str((m.nTOTAL-(m.nTOTAL*pagos.adic2)/100),10,2))
- Endif
- Endif
- Else
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se + Chr(127) )
- Endif
- lin = Str(Val(lin)+1,2,0)
- If pagos.adic3 > 0 .Or. pagos.plazo3 >0
- If Isnull(pagos.dia) Or Empty(pagos.dia)
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "OPCION DE PAGO: Hasta el "+ ;
- DTOC(Thisform.txtFecha.Value+Cast(pagos.dias1 As Integer))+" "+;
- STR(pagos.adic3)+" % Desc. $ "+;
- STR(m.nTOTAL*pagos.adic3/100,08,2)+;
- " Paga $ "+Str((m.nTOTAL-(m.nTOTAL*pagos.adic3/100)),10,2))
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "OPCION DE PAGO: Hasta el "+ ;
- DTOC(pagos.dia+Cast(pagos.dias1 As Integer))+" "+;
- STR(pagos.adic3)+" % Desc. $ "+;
- STR(m.nTOTAL*pagos.adic3/100,08,2)+;
- " Paga $ "+Str((m.nTOTAL-(m.nTOTAL*pagos.adic3/100)),10,2))
- Endif
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + Chr(127))
- Endif
- lin = Str(Val(lin)+1,2,0)
- *!* Insert Into comando;
- *!* VALUES ("]" + Se + lin + Se + Chr(127))
- If m.nFlete > 0 Or m.nDRet > 0
- If m.nFlete > 0
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "Prec. de Merc. Incl. Flete "+ ;
- Transform(m.nFlete, "@$ 99,999,999.99"))
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "Merc. Incl. Desc p/RETIRA "+ ;
- Transform(m.nDRet, "@$ 99,999,999.99"))
- Endif
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + Chr(127))
- Endif
- &&si se factura sobre remitos se imprimen los remitos afectados
- If Thisform.viene = "X" &&hay q revisar esto para ver q cuando se factura de remitos se imprima
- Insert Into comando;
- VALUES ( Chr(147) + Se + "1" + Se + Substr(This.remitosafacturar,1,17))
- If !Empty(Substr(This.remitosafacturar,19,20))
- Insert Into comando;
- VALUES (Chr(147) + Se + "2" + Se + Substr(This.remitosafacturar,19,20))
- Endif
- Endif
- Else
- If This.contado = 'N'
- Insert Into comando;
- values("]" + Se + lin + Se+;
- " Saldo de CTA_CTE: $"+;
- ALLTRIM(Str((m.salctacte),12,2)))
- lin = '6'
- Else
- Insert Into comando;
- values("]" + Se + lin + Se + Chr(127))
- lin = '6'
- Endif
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se + "Vendedor: "+Alltrim(goApp.User) )
- lin = '7'
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + Chr(127))
- lin = '8'
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + Chr(127))
- lin = '11'
- *!* Insert Into comando;
- *!* VALUES ("]" + Se + lin + Se + Chr(127))
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + Chr(127))
- Endif
- If This.Ticket="S"
- Insert Into comando;
- VALUES ( "]" + Se + "9" + Se +Chr(127))
- Insert Into comando;
- VALUES ("]" + Se + "10" + Se +Chr(127))
- If This.condicion = 'C' And Val(sCliente) = 1
- Insert Into comando;
- VALUES ("b" + Se + Substr(sNombre,1,30) + Se + ;
- ndocu + Se + TIPO_IVA + Se + TIPO_DOCU + Se +;
- " S/NOMBRE")
- Else
- Insert Into comando;
- VALUES ("b" + Se + Substr(sNombre,1,30) + Se + ;
- ndocu + Se + TIPO_IVA + Se + TIPO_DOCU + Se +;
- SUBSTR(Alltrim(thisformset.frmCliente.txtDomicilio.Value)+" "+Alltrim(loc.nombre)+;
- " "+Alltrim(loc.provincia),1,40))
- Endif
- Else
- &&"["+sCliente+"] "+
- Insert Into comando;
- VALUES ( "b" + Se + "[" + sCliente + "] " + Substr(sNombre,1,40) + Se +;
- ndocu + Se + TIPO_IVA + Se + TIPO_DOCU + Se + ;
- ALLTRIM(Thisform.txtDom.Value)+" ("+Alltrim(clientes.codpos)+") "+;
- Alltrim(loc.nombre)+" "+Alltrim(loc.provincia))
- Endif
- If This.condicion <> "C"
- Insert Into comando;
- VALUES (Chr(64)+Se+TIPO_FACTURA+Se+"T")
- Else
- &&Definir tipo y num de factura afectado por nota de credito
- Insert Into comando;
- VALUES (Chr(147) + Se + "1" + Se + cre.tipoaf + " " + cre.numeroaf)
- Insert Into comando;
- VALUES (Chr(128)+Se+TIPO_FACTURA+Se+"T")
- Endif
- &&el cursor "DET" posee los items a facturar
- Select("det")
- Go Top
- Do While ! Eof()
- *!* Create Cursor det;
- *!* (cantidad n(12,4), unidad c(8), detalle c(40), total n(12,2), idArticulo int,;
- *!* unitario n(12,2), costo n(12,2), montoiva n(12,2), montodgr n(12,2), montomuni N(12,2),;
- *!* poriva n(12,2), tipoiva c(2))
- If det.unitario != 0
- If This.clase = "A"
- If This.Ticket = "S"
- Insert Into comando;
- VALUES ("A" + Se + det.unidad +" "+Substr(det.detalle,1,19)+ Se + "0")
- Insert Into comando;
- VALUES ("B" + Se + Padr(Alltrim(Substr(det.detalle,20,20)),20,".") + Se +;
- ALLTRIM(Str(det.cantidad,6,2)+"0")+ Se +;
- ALLTRIM(Str(det.unitario,9,2)) + Se + ;
- ALLTRIM(Str(det.poriva,5,2)) + Se +;
- "M" + Se + "0.00" + Se + "0" + Se + "T")
- Else
- Insert Into comando;
- VALUES ("B" + Se + det.unidad +" "+det.detalle+ Se + ;
- ALLTRIM(Str(det.cantidad,11,2))+ Se + ;
- Alltrim(Str(det.unitario,13,2)) + ;
- Se +Alltrim(Str(det.poriva,5,2)) + Se + ;
- "M" + Se + "0" + Se + "" + Se + "T")
- Endif
- Else
- If This.Ticket = "S"
- Insert Into comando;
- VALUES ( "A" + Se + det.unidad +" "+Substr(det.detalle,1,19)+ Se + "0")
- Insert Into comando;
- VALUES ("B" + Se + Padr(Alltrim(Substr(det.detalle,20,20)),20,".") + ;
- Se +Alltrim(Str(det.cantidad,6,2)+"0")+ Se + ;
- ALLTRIM(Str(det.unitario,9,2)) + Se + ;
- ALLTRIM(Str(det.poriva,5,2)) + Se + ;
- "M" + Se + "0.00" + Se + "0" + Se + "T")
- Else
- Insert Into comando;
- VALUES ("B" + Se + det.unidad+" "+det.detalle+ Se +;
- ALLTRIM(Str(det.cantidad,11,2))+ Se + ;
- ALLTRIM(Str(det.unitario,13,2)) + Se +;
- ALLTRIM(Str(det.poriva,5,2)) + Se + ;
- "M" + Se + "0" + Se + "" + Se + "T")
- Endif
- Endif
- Endif
- Select("det")
- Skip
- Enddo
- If This.condicion <> "C"
- If This.Ticket = "S"
- If This.contado = "S"
- Insert Into comando;
- VALUES (Chr(68)+ Se + Substr(formapago.detalle,1,30)+ Se + ;
- ALLTRIM(Str(ThisForm.Saldacontado.txtPago.Value,10,2))+ Se +"T"+ Se+"0")
- Else
- Insert Into comando;
- VALUES ( Chr(68)+ Se + Substr(formapago.detalle,1,30)+ ;
- Se + Alltrim(Str(ThisForm.Saldacontado.txtPago.Value,10,2))+ Se +"T"+ Se+"0")
- Endif
- Else
- If This.contado = "S"
- Insert Into comando;
- VALUES (Chr(68)+ Se + Alltrim(formapago.detalle)+ Se + ;
- ALLTRIM(Str(ThisForm.Saldacontado.txtPago.Value,12,2))+ Se +"T"+ Se+"0")
- Else
- Insert Into comando;
- VALUES(Chr(68)+ Se + Alltrim(formapago.detalle)+ Se + ;
- ALLTRIM(Str(ThisForm.Saldacontado.txtPago.Value,12,2))+ Se +"T"+ Se+"0")
- Endif
- Endif
- Endif
- If This.condicion <> "C"
- Insert Into comando;
- VALUES (Chr(69))
- Else
- Insert Into comando;
- VALUES ( Chr(129) )
- Endif
- &&en esta parte copio el archivo con los comandos a la carpeta desde el cual
- &&el spooler de impresion lee el archivo
- If This.Ticket ="S"
- && si es ticket me fijo a cual impresora debo enviar
- If lImpreFiscal
- mtXt = Alltrim(impfis.dircoticket) + Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(impfis.dirreticket) + Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Else
- mtXt = Alltrim(parametr.dirco)+"715\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(parametr.dirre)+"715\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Endif
- *!* cDirCom = "fpserver715" + "\impred.exe"
- *!* cDirCom = Fullpath(cDirCom)
- *!* && Mato el proceso del spooler y lo vuelvo a cargar
- *!* This.killprocessbyname("impred.exe")
- *!* This.killprocessbyname("wspooler.exe")
- *!* oShell = Createobject("Shell.Application")
- *!* oShell.ShellExecute (cDirCom)
- Else
- &&aca envio a la 320
- If lImpreFiscal
- mtXt = Alltrim(impfis.dircofactura) + Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(impfis.dirrefactura) + Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Else
- mtXt = Alltrim(parametr.dirco)+"320\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(parametr.dirre)+"320\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Endif
- Endif
- Select("comando")
- Goto Top
- &&en caso de que tenga un archivo en la cola de impresion de la impresora
- &&no se deja imprimir
- *Browse
- If File(mtXt)
- Messagebox("ATENCION: Ud. ya tiene un Documento en Cola de Impresión"+Chr(10)+Chr(13)+;
- " AGUARDE a que el mismo sea impreso o elimínelo luego vuelva a intentar")
- Return This.TodoOK
- Else
- Copy To &mtXt Sdf
- If File(maNs)
- Erase &maNs
- Endif
- If File(Alltrim(paramfac.dirpa)+"SPOOLER.LOG")
- Erase (Alltrim(paramfac.dirpa)+"SPOOLER.LOG")
- Endif
- Wait Windows 'Esperando Respuesta del Controlador Fiscal...' Nowait
- fd = -1
- intentos =1
- Do While fd < 0 .And. Lastkey() != 27
- fd = Fopen(maNs, 0)
- This.LeerSpooler("T")
- If intentos = 30
- Messagebox("ATENCION: Verifique que el Controlador Esté Conectado y Encendido. " + Chr(10) + Chr(13)+ ;
- "Verifique además que el Programa Spooler se esté ejecutando " + Chr(10) + Chr(13)+ ;
- "en el equipo al cual se encuentra conectado el Controlador Fiscal")
- This.LeerSpooler("T")
- Endif
- If intentos = 70
- Messagebox("ATENCION: Tiempo de Espera Agotado !!! Presione ESC. para cancelar este Comprobante")
- This.LeerSpooler("T")
- Endif
- intentos = intentos + 1
- *For i=1 To 100
- *Next
- Inkey(1)
- If Lastkey() = 27
- If Substr(comando.comando,17,16) = "Impresor Ocupado"
- Messagebox("ATENCION: No se aconseja cancelar este documento por programa, "+;
- CHR(10)+Chr(13)+"La impresora ya lo ha procesado y saldrá impreso"+;
- CHR(10)+Chr(13)+ "una vez que esta se ponga en linea")
- Endif
- If Messagebox("ATENCION: Realmente desea Cancelar la Emisión de este Documento??",4+256) = 6
- Messagebox(" Se proceder a Cancelar el Documento por Sistema"+;
- CHR(10)+Chr(13)+" Verifique que la impresora también lo haya Cancelado.")
- Keyboard '{ESC}'
- Else
- Keyboard ""
- Endif
- Endif
- Enddo
- If Lastkey() = 27.Or. fd < 0
- If File(mtXt)
- Erase &mtXt
- Endif
- fd = Fopen((Alltrim(paramfac.dirpa)+"SPOOLER.LOG"), 0)
- If fd < 0
- Messagebox("Operación Cancelada: ERROR de comunicaciones con el Controlador.; Probablemente no se este ejecutando Spooler. ")
- Else
- fd =Fclose(fd)
- This.LeerSpooler("T")
- Endif
- Else
- fd = Fclose(fd)
- Select("comando")
- Zap
- Append From &maNs Sdf
- Goto Bottom
- This.numero = Val(Substr(comando.comando,35,8))
- If This.numero <> 0
- SQLExec(goApp.nCon, "select * from puntero where sucursal=?param.sucursal","puntero")
- If This.Ticket = "S"
- If This.MasDeMil
- This.numero = Val('0009'+strzero(This.numero,8))
- Else
- If lImpreFiscal
- This.numero = Val(impfis.PtoVtaTicket+strzero(This.numero,8))
- Else
- If Param.sucursal=0
- If File("c:\0009.txt")
- This.numero = Val(strzero(9,4)+strzero(This.numero,8))
- Else
- This.numero = Val(strzero(puntero.pvta_tic,4)+strzero(This.numero,8))
- Endif
- Else
- If Param.sucursal = 1
- This.numero = Val(strzero(8,4)+strzero(This.numero,8))
- Endif
- Endif
- Endif
- Endif
- Else
- If lImpreFiscal
- This.numero = Val(impfis.PtoVtaFac+strzero(This.numero,8))
- Else
- This.numero = Val(strzero(puntero.pvta_fac,4)+strzero(This.numero,8))
- Endif
- Endif
- This.TodoOK = .T.
- Endif
- Endif
- If File((Alltrim(paramfac.dirpa)+"SPOOLER.LOG"))
- Erase Alltrim(paramfac.dirpa)+"SPOOLER.LOG"
- Endif
- Endif
- *This.killprocessbyname("impred.exe")
- *This.killprocessbyname("wspooler.exe")
- Set Talk &cTalk
- Return This.Todo
- *!* Messagebox("Se ha producido un error al recuperar el tipo de Documento" + Chr(10)+Chr(13)+Message(),0+48,"ERROR")
- *!* Return -1
- *!* Endif
- &&indica si el cliente tiene que poseer cuit
- If tiporesp.obligacuit
- If Empty( Val( Strtran( clientes.cuit, "-" ) ) )
- Messagebox ("ATENCION: Falta Registrar CUIT de Cliente", 0+48, "CUIT")
- Do While Val(ndocu) < 2
- ndocu = Inputbox("Ingrese CUIT")
- Enddo
- ndocu = Alltrim( Strtran( ndocu, "-" ) )
- Else
- TIPO_DOCU = 'C' &&tiporesp.tipo_iva &&"C"
- ndocu = Alltrim( Strtran( clientes.cuit, "-" ) )
- Endif
- Else
- If SQLExec(goApp.nCon, "select * from tipodoc where codigo=?clientes.tipodocu","tipodoc") = -1
- goApp.Error()
- Return -1
- Endif
- If Reccount("tipodoc") > 0
- TIPO_DOCU = tipodoc.tipo
- Else
- TIPO_DOCU = '2'
- Endif
- ndocu = Alltrim(Str(clientes.dni))
- If Val(ndocu) < 2
- ndocu = '11111111'
- Endif
- Endif
- TIPO_IVA = tiporesp.TIPOIVA
- Select("comando")
- &&me fijo si es ticket factura o factura
- If This.Ticket = "S"
- lin = "5"
- Else
- lin = "3"
- Endif
- If This.Ticket = "N"
- &&en caso de ser factura imprimo todo el encabezado que va en la factura
- Select("comando")
- Insert Into comando;
- VALUES( "]" + Se + "1" + Se + Chr(127) )
- Insert Into comando;
- VALUES( "]" + Se + "2" + Se + Chr(127) )
- Insert Into comando;
- values( "]" + Se + "2" + Se + "Ing.Brut. 914-532186-1" )
- If This.contado = "N"
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "Vendedor: "+Alltrim(vendedor.nom_ven)+;
- SPACE(10)+"Vencimiento de este Comp.: "+;
- DTOC(This.FechaVen(Thisform.txtFecha.Value))+;
- " Saldo Actual de CTA_CTE(S.E.U.O.): $"+;
- ALLTRIM(Str((m.salctacte),12,2)))
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + "Vendedor: "+;
- ALLTRIM(vendedor.nom_ven)+;
- SPACE(10)+"Vencimiento de este Comp.: "+;
- DTOC(This.FechaVen(Thisform.txtFecha.Value)))
- Endif
- lin = Str(Val(lin)+1,1,0)
- Do Case
- Case Used("obsfac")
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + "OBS.: "+Alltrim(obsfac.obs1)+Alltrim(obsfac.obs2))
- Case This.pagoanticipado &&det.pagoanticipado
- If det.reparto
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + "PAGO ANTICIPADO - REPARTO")
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + "PAGO ANTICIPADO - RETIRA")
- Endif
- Case This.lReparto
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + "MERCADERIA DE REPARTO")
- Case !This.lReparto
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + "MERCADERIA PARA RETIRAR")
- Otherwise
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + "DEVOLUCIONES DENTRO DE LAS 48 HRS.")
- Endcase
- lin = Str(Val(lin)+1,1,0)
- This.letras.dicenum(m.nTOTAL)
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se + ;
- "SON:" + This.letras.retorno)
- lin = "11"
- &&especifico las formas de cancelacion que posee la factura
- If pagos.adic1 > 0 .Or. pagos.plazo1 > 0
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se + ;
- "OPCION DE PAGO: Hasta el "+;
- Dtoc(Thisform.txtFecha.Value+This.dias())+ " "+;
- STR(pagos.adic1)+" % Desc. $ "+;
- STR(m.nTOTAL*pagos.adic1/100,08,2)+;
- " Paga $ "+Str((m.nTOTAL-(m.nTOTAL*pagos.adic1)/100),10,2))
- Else
- If Inlist(pagos.pago,'00','01','02')
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se + ;
- "OPCION DE PAGO: Contado Efectivo"+;
- " 3% Desc. "+;
- " Paga $ "+ Str(m.nTOTAL,10,2))
- Else
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se + Chr(127))
- Endif
- Endif
- lin = Str(Val(lin)+1,2,0)
- If pagos.adic2 > 0 .Or. pagos.plazo2 > 0
- If Isnull(pagos.dia) Or Empty(pagos.dia)
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se +;
- "OPCION DE PAGO: Hasta el "+ ;
- DTOC(This.FechaVen(Thisform.txtFecha.Value))+" "+;
- STR(pagos.adic2)+" % Desc. $ ";
- +Str(m.nTOTAL*pagos.adic2/100,08,2)+;
- " Paga $ "+Str((m.nTOTAL-(m.nTOTAL*pagos.adic2)/100),10,2))
- Else
- If pagos.pago = '51'
- *!* Pongo esto para que en esta condicion no me sume los dias de ADIC2
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "OPCION DE PAGO: Hasta el "+ ;
- DTOC(pagos.dia)+" "+;
- STR(pagos.adic2)+" % Desc. $ "+;
- STR(m.nTOTAL*pagos.adic2/100,08,2)+;
- " Paga $ "+Str((m.nTOTAL-(m.nTOTAL*pagos.adic2)/100),10,2))
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "OPCION DE PAGO: Hasta el "+ ;
- DTOC(This.FechaVen(Thisform.txtFecha.Value))+" "+;
- STR(pagos.adic2)+" % Desc. $ "+;
- STR(m.nTOTAL*pagos.adic2/100,08,2)+;
- " Paga $ "+Str((m.nTOTAL-(m.nTOTAL*pagos.adic2)/100),10,2))
- Endif
- Endif
- Else
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se + Chr(127) )
- Endif
- lin = Str(Val(lin)+1,2,0)
- If pagos.adic3 > 0 .Or. pagos.plazo3 >0
- If Isnull(pagos.dia) Or Empty(pagos.dia)
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "OPCION DE PAGO: Hasta el "+ ;
- DTOC(Thisform.txtFecha.Value+Cast(pagos.dias1 As Integer))+" "+;
- STR(pagos.adic3)+" % Desc. $ "+;
- STR(m.nTOTAL*pagos.adic3/100,08,2)+;
- " Paga $ "+Str((m.nTOTAL-(m.nTOTAL*pagos.adic3/100)),10,2))
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "OPCION DE PAGO: Hasta el "+ ;
- DTOC(pagos.dia+Cast(pagos.dias1 As Integer))+" "+;
- STR(pagos.adic3)+" % Desc. $ "+;
- STR(m.nTOTAL*pagos.adic3/100,08,2)+;
- " Paga $ "+Str((m.nTOTAL-(m.nTOTAL*pagos.adic3/100)),10,2))
- Endif
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + Chr(127))
- Endif
- lin = Str(Val(lin)+1,2,0)
- *!* Insert Into comando;
- *!* VALUES ("]" + Se + lin + Se + Chr(127))
- If m.nFlete > 0 Or m.nDRet > 0
- If m.nFlete > 0
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "Prec. de Merc. Incl. Flete "+ ;
- Transform(m.nFlete, "@$ 99,999,999.99"))
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "Merc. Incl. Desc p/RETIRA "+ ;
- Transform(m.nDRet, "@$ 99,999,999.99"))
- Endif
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + Chr(127))
- Endif
- &&si se factura sobre remitos se imprimen los remitos afectados
- If Thisform.viene = "X" &&hay q revisar esto para ver q cuando se factura de remitos se imprima
- Insert Into comando;
- VALUES ( Chr(147) + Se + "1" + Se + Substr(This.remitosafacturar,1,17))
- If !Empty(Substr(This.remitosafacturar,19,20))
- Insert Into comando;
- VALUES (Chr(147) + Se + "2" + Se + Substr(This.remitosafacturar,19,20))
- Endif
- Endif
- Else
- If This.contado = 'N'
- Insert Into comando;
- values("]" + Se + lin + Se+;
- " Saldo de CTA_CTE: $"+;
- ALLTRIM(Str((m.salctacte),12,2)))
- lin = '6'
- Else
- Insert Into comando;
- values("]" + Se + lin + Se + Chr(127))
- lin = '6'
- Endif
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se + "Vendedor: "+Alltrim(goApp.User) )
- lin = '7'
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + Chr(127))
- lin = '8'
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + Chr(127))
- lin = '11'
- *!* Insert Into comando;
- *!* VALUES ("]" + Se + lin + Se + Chr(127))
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + Chr(127))
- Endif
- If This.Ticket="S"
- Insert Into comando;
- VALUES ( "]" + Se + "9" + Se +Chr(127))
- Insert Into comando;
- VALUES ("]" + Se + "10" + Se +Chr(127))
- If This.condicion = 'C' And Val(sCliente) = 1
- Insert Into comando;
- VALUES ("b" + Se + Substr(sNombre,1,30) + Se + ;
- ndocu + Se + TIPO_IVA + Se + TIPO_DOCU + Se +;
- " S/NOMBRE")
- Else
- Insert Into comando;
- VALUES ("b" + Se + Substr(sNombre,1,30) + Se + ;
- ndocu + Se + TIPO_IVA + Se + TIPO_DOCU + Se +;
- SUBSTR(Alltrim(thisformset.frmCliente.txtDomicilio.Value)+" "+Alltrim(loc.nombre)+;
- " "+Alltrim(loc.provincia),1,40))
- Endif
- Else
- &&"["+sCliente+"] "+
- Insert Into comando;
- VALUES ( "b" + Se + "[" + sCliente + "] " + Substr(sNombre,1,40) + Se +;
- ndocu + Se + TIPO_IVA + Se + TIPO_DOCU + Se + ;
- ALLTRIM(Thisform.txtDom.Value)+" ("+Alltrim(clientes.codpos)+") "+;
- Alltrim(loc.nombre)+" "+Alltrim(loc.provincia))
- Endif
- If This.condicion <> "C"
- Insert Into comando;
- VALUES (Chr(64)+Se+TIPO_FACTURA+Se+"T")
- Else
- &&Definir tipo y num de factura afectado por nota de credito
- Insert Into comando;
- VALUES (Chr(147) + Se + "1" + Se + cre.tipoaf + " " + cre.numeroaf)
- Insert Into comando;
- VALUES (Chr(128)+Se+TIPO_FACTURA+Se+"T")
- Endif
- &&el cursor "DET" posee los items a facturar
- Select("det")
- Go Top
- Do While ! Eof()
- *!* Create Cursor det;
- *!* (cantidad n(12,4), unidad c(8), detalle c(40), total n(12,2), idArticulo int,;
- *!* unitario n(12,2), costo n(12,2), montoiva n(12,2), montodgr n(12,2), montomuni N(12,2),;
- *!* poriva n(12,2), tipoiva c(2))
- If det.unitario != 0
- If This.clase = "A"
- If This.Ticket = "S"
- Insert Into comando;
- VALUES ("A" + Se + det.unidad +" "+Substr(det.detalle,1,19)+ Se + "0")
- Insert Into comando;
- VALUES ("B" + Se + Padr(Alltrim(Substr(det.detalle,20,20)),20,".") + Se +;
- ALLTRIM(Str(det.cantidad,6,2)+"0")+ Se +;
- ALLTRIM(Str(det.unitario,9,2)) + Se + ;
- ALLTRIM(Str(det.poriva,5,2)) + Se +;
- "M" + Se + "0.00" + Se + "0" + Se + "T")
- Else
- Insert Into comando;
- VALUES ("B" + Se + det.unidad +" "+det.detalle+ Se + ;
- ALLTRIM(Str(det.cantidad,11,2))+ Se + ;
- Alltrim(Str(det.unitario,13,2)) + ;
- Se +Alltrim(Str(det.poriva,5,2)) + Se + ;
- "M" + Se + "0" + Se + "" + Se + "T")
- Endif
- Else
- If This.Ticket = "S"
- Insert Into comando;
- VALUES ( "A" + Se + det.unidad +" "+Substr(det.detalle,1,19)+ Se + "0")
- Insert Into comando;
- VALUES ("B" + Se + Padr(Alltrim(Substr(det.detalle,20,20)),20,".") + ;
- Se +Alltrim(Str(det.cantidad,6,2)+"0")+ Se + ;
- ALLTRIM(Str(det.unitario,9,2)) + Se + ;
- ALLTRIM(Str(det.poriva,5,2)) + Se + ;
- "M" + Se + "0.00" + Se + "0" + Se + "T")
- Else
- Insert Into comando;
- VALUES ("B" + Se + det.unidad+" "+det.detalle+ Se +;
- ALLTRIM(Str(det.cantidad,11,2))+ Se + ;
- ALLTRIM(Str(det.unitario,13,2)) + Se +;
- ALLTRIM(Str(det.poriva,5,2)) + Se + ;
- "M" + Se + "0" + Se + "" + Se + "T")
- Endif
- Endif
- Endif
- Select("det")
- Skip
- Enddo
- If This.condicion <> "C"
- If This.Ticket = "S"
- If This.contado = "S"
- Insert Into comando;
- VALUES (Chr(68)+ Se + Substr(formapago.detalle,1,30)+ Se + ;
- ALLTRIM(Str(ThisForm.Saldacontado.txtPago.Value,10,2))+ Se +"T"+ Se+"0")
- Else
- Insert Into comando;
- VALUES ( Chr(68)+ Se + Substr(formapago.detalle,1,30)+ ;
- Se + Alltrim(Str(ThisForm.Saldacontado.txtPago.Value,10,2))+ Se +"T"+ Se+"0")
- Endif
- Else
- If This.contado = "S"
- Insert Into comando;
- VALUES (Chr(68)+ Se + Alltrim(formapago.detalle)+ Se + ;
- ALLTRIM(Str(ThisForm.Saldacontado.txtPago.Value,12,2))+ Se +"T"+ Se+"0")
- Else
- Insert Into comando;
- VALUES(Chr(68)+ Se + Alltrim(formapago.detalle)+ Se + ;
- ALLTRIM(Str(ThisForm.Saldacontado.txtPago.Value,12,2))+ Se +"T"+ Se+"0")
- Endif
- Endif
- Endif
- If This.condicion <> "C"
- Insert Into comando;
- VALUES (Chr(69))
- Else
- Insert Into comando;
- VALUES ( Chr(129) )
- Endif
- &&en esta parte copio el archivo con los comandos a la carpeta desde el cual
- &&el spooler de impresion lee el archivo
- If This.Ticket ="S"
- && si es ticket me fijo a cual impresora debo enviar
- If lImpreFiscal
- mtXt = Alltrim(impfis.dircoticket) + Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(impfis.dirreticket) + Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Else
- mtXt = Alltrim(parametr.dirco)+"715\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(parametr.dirre)+"715\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Endif
- *!* cDirCom = "fpserver715" + "\impred.exe"
- *!* cDirCom = Fullpath(cDirCom)
- *!* && Mato el proceso del spooler y lo vuelvo a cargar
- *!* This.killprocessbyname("impred.exe")
- *!* This.killprocessbyname("wspooler.exe")
- *!* oShell = Createobject("Shell.Application")
- *!* oShell.ShellExecute (cDirCom)
- Else
- &&aca envio a la 320
- If lImpreFiscal
- mtXt = Alltrim(impfis.dircofactura) + Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(impfis.dirrefactura) + Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Else
- mtXt = Alltrim(parametr.dirco)+"320\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(parametr.dirre)+"320\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Endif
- Endif
- Select("comando")
- Goto Top
- &&en caso de que tenga un archivo en la cola de impresion de la impresora
- &&no se deja imprimir
- *Browse
- If File(mtXt)
- Messagebox("ATENCION: Ud. ya tiene un Documento en Cola de Impresión"+Chr(10)+Chr(13)+;
- " AGUARDE a que el mismo sea impreso o elimínelo luego vuelva a intentar")
- Return This.TodoOK
- Else
- Copy To &mtXt Sdf
- If File(maNs)
- Erase &maNs
- Endif
- If File(Alltrim(paramfac.dirpa)+"SPOOLER.LOG")
- Erase (Alltrim(paramfac.dirpa)+"SPOOLER.LOG")
- Endif
- Wait Windows 'Esperando Respuesta del Controlador Fiscal...' Nowait
- fd = -1
- intentos =1
- Do While fd < 0 .And. Lastkey() != 27
- fd = Fopen(maNs, 0)
- This.LeerSpooler("T")
- If intentos = 30
- Messagebox("ATENCION: Verifique que el Controlador Esté Conectado y Encendido. " + Chr(10) + Chr(13)+ ;
- "Verifique además que el Programa Spooler se esté ejecutando " + Chr(10) + Chr(13)+ ;
- "en el equipo al cual se encuentra conectado el Controlador Fiscal")
- This.LeerSpooler("T")
- Endif
- If intentos = 70
- Messagebox("ATENCION: Tiempo de Espera Agotado !!! Presione ESC. para cancelar este Comprobante")
- This.LeerSpooler("T")
- Endif
- intentos = intentos + 1
- *For i=1 To 100
- *Next
- Inkey(1)
- If Lastkey() = 27
- If Substr(comando.comando,17,16) = "Impresor Ocupado"
- Messagebox("ATENCION: No se aconseja cancelar este documento por programa, "+;
- CHR(10)+Chr(13)+"La impresora ya lo ha procesado y saldrá impreso"+;
- CHR(10)+Chr(13)+ "una vez que esta se ponga en linea")
- Endif
- If Messagebox("ATENCION: Realmente desea Cancelar la Emisión de este Documento??",4+256) = 6
- Messagebox(" Se proceder a Cancelar el Documento por Sistema"+;
- CHR(10)+Chr(13)+" Verifique que la impresora también lo haya Cancelado.")
- Keyboard '{ESC}'
- Else
- Keyboard ""
- Endif
- Endif
- Enddo
- If Lastkey() = 27.Or. fd < 0
- If File(mtXt)
- Erase &mtXt
- Endif
- fd = Fopen((Alltrim(paramfac.dirpa)+"SPOOLER.LOG"), 0)
- If fd < 0
- Messagebox("Operación Cancelada: ERROR de comunicaciones con el Controlador.; Probablemente no se este ejecutando Spooler. ")
- Else
- fd =Fclose(fd)
- This.LeerSpooler("T")
- Endif
- Else
- fd = Fclose(fd)
- Select("comando")
- Zap
- Append From &maNs Sdf
- Goto Bottom
- This.numero = Val(Substr(comando.comando,35,8))
- If This.numero <> 0
- SQLExec(goApp.nCon, "select * from puntero where sucursal=?param.sucursal","puntero")
- If This.Ticket = "S"
- If This.MasDeMil
- This.numero = Val('0009'+strzero(This.numero,8))
- Else
- If lImpreFiscal
- This.numero = Val(impfis.PtoVtaTicket+strzero(This.numero,8))
- Else
- If Param.sucursal=0
- If File("c:\0009.txt")
- This.numero = Val(strzero(9,4)+strzero(This.numero,8))
- Else
- This.numero = Val(strzero(puntero.pvta_tic,4)+strzero(This.numero,8))
- Endif
- Else
- If Param.sucursal = 1
- This.numero = Val(strzero(8,4)+strzero(This.numero,8))
- Endif
- Endif
- Endif
- Endif
- Else
- If lImpreFiscal
- This.numero = Val(impfis.PtoVtaFac+strzero(This.numero,8))
- Else
- This.numero = Val(strzero(puntero.pvta_fac,4)+strzero(This.numero,8))
- Endif
- Endif
- This.TodoOK = .T.
- Endif
- Endif
- If File((Alltrim(paramfac.dirpa)+"SPOOLER.LOG"))
- Erase Alltrim(paramfac.dirpa)+"SPOOLER.LOG"
- Endif
- Endif
- *This.killprocessbyname("impred.exe")
- *This.killprocessbyname("wspooler.exe")
- Set Talk &cTalk
- Return This.Todo
- *!* Return -1
- *!* Endif
- &&indica si el cliente tiene que poseer cuit
- If tiporesp.obligacuit
- If Empty( Val( Strtran( clientes.cuit, "-" ) ) )
- Messagebox ("ATENCION: Falta Registrar CUIT de Cliente", 0+48, "CUIT")
- Do While Val(ndocu) < 2
- ndocu = Inputbox("Ingrese CUIT")
- Enddo
- ndocu = Alltrim( Strtran( ndocu, "-" ) )
- Else
- TIPO_DOCU = 'C' &&tiporesp.tipo_iva &&"C"
- ndocu = Alltrim( Strtran( clientes.cuit, "-" ) )
- Endif
- Else
- If SQLExec(goApp.nCon, "select * from tipodoc where codigo=?clientes.tipodocu","tipodoc") = -1
- goApp.Error()
- Return -1
- Endif
- If Reccount("tipodoc") > 0
- TIPO_DOCU = tipodoc.tipo
- Else
- TIPO_DOCU = '2'
- Endif
- ndocu = Alltrim(Str(clientes.dni))
- If Val(ndocu) < 2
- ndocu = '11111111'
- Endif
- Endif
- TIPO_IVA = tiporesp.TIPOIVA
- Select("comando")
- &&me fijo si es ticket factura o factura
- If This.Ticket = "S"
- lin = "5"
- Else
- lin = "3"
- Endif
- If This.Ticket = "N"
- &&en caso de ser factura imprimo todo el encabezado que va en la factura
- Select("comando")
- Insert Into comando;
- VALUES( "]" + Se + "1" + Se + Chr(127) )
- Insert Into comando;
- VALUES( "]" + Se + "2" + Se + Chr(127) )
- Insert Into comando;
- values( "]" + Se + "2" + Se + "Ing.Brut. 914-532186-1" )
- If This.contado = "N"
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "Vendedor: "+Alltrim(vendedor.nom_ven)+;
- SPACE(10)+"Vencimiento de este Comp.: "+;
- DTOC(This.FechaVen(Thisform.txtFecha.Value))+;
- " Saldo Actual de CTA_CTE(S.E.U.O.): $"+;
- ALLTRIM(Str((m.salctacte),12,2)))
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + "Vendedor: "+;
- ALLTRIM(vendedor.nom_ven)+;
- SPACE(10)+"Vencimiento de este Comp.: "+;
- DTOC(This.FechaVen(Thisform.txtFecha.Value)))
- Endif
- lin = Str(Val(lin)+1,1,0)
- Do Case
- Case Used("obsfac")
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + "OBS.: "+Alltrim(obsfac.obs1)+Alltrim(obsfac.obs2))
- Case This.pagoanticipado &&det.pagoanticipado
- If det.reparto
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + "PAGO ANTICIPADO - REPARTO")
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + "PAGO ANTICIPADO - RETIRA")
- Endif
- Case This.lReparto
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + "MERCADERIA DE REPARTO")
- Case !This.lReparto
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + "MERCADERIA PARA RETIRAR")
- Otherwise
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + "DEVOLUCIONES DENTRO DE LAS 48 HRS.")
- Endcase
- lin = Str(Val(lin)+1,1,0)
- This.letras.dicenum(m.nTOTAL)
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se + ;
- "SON:" + This.letras.retorno)
- lin = "11"
- &&especifico las formas de cancelacion que posee la factura
- If pagos.adic1 > 0 .Or. pagos.plazo1 > 0
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se + ;
- "OPCION DE PAGO: Hasta el "+;
- Dtoc(Thisform.txtFecha.Value+This.dias())+ " "+;
- STR(pagos.adic1)+" % Desc. $ "+;
- STR(m.nTOTAL*pagos.adic1/100,08,2)+;
- " Paga $ "+Str((m.nTOTAL-(m.nTOTAL*pagos.adic1)/100),10,2))
- Else
- If Inlist(pagos.pago,'00','01','02')
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se + ;
- "OPCION DE PAGO: Contado Efectivo"+;
- " 3% Desc. "+;
- " Paga $ "+ Str(m.nTOTAL,10,2))
- Else
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se + Chr(127))
- Endif
- Endif
- lin = Str(Val(lin)+1,2,0)
- If pagos.adic2 > 0 .Or. pagos.plazo2 > 0
- If Isnull(pagos.dia) Or Empty(pagos.dia)
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se +;
- "OPCION DE PAGO: Hasta el "+ ;
- DTOC(This.FechaVen(Thisform.txtFecha.Value))+" "+;
- STR(pagos.adic2)+" % Desc. $ ";
- +Str(m.nTOTAL*pagos.adic2/100,08,2)+;
- " Paga $ "+Str((m.nTOTAL-(m.nTOTAL*pagos.adic2)/100),10,2))
- Else
- If pagos.pago = '51'
- *!* Pongo esto para que en esta condicion no me sume los dias de ADIC2
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "OPCION DE PAGO: Hasta el "+ ;
- DTOC(pagos.dia)+" "+;
- STR(pagos.adic2)+" % Desc. $ "+;
- STR(m.nTOTAL*pagos.adic2/100,08,2)+;
- " Paga $ "+Str((m.nTOTAL-(m.nTOTAL*pagos.adic2)/100),10,2))
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "OPCION DE PAGO: Hasta el "+ ;
- DTOC(This.FechaVen(Thisform.txtFecha.Value))+" "+;
- STR(pagos.adic2)+" % Desc. $ "+;
- STR(m.nTOTAL*pagos.adic2/100,08,2)+;
- " Paga $ "+Str((m.nTOTAL-(m.nTOTAL*pagos.adic2)/100),10,2))
- Endif
- Endif
- Else
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se + Chr(127) )
- Endif
- lin = Str(Val(lin)+1,2,0)
- If pagos.adic3 > 0 .Or. pagos.plazo3 >0
- If Isnull(pagos.dia) Or Empty(pagos.dia)
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "OPCION DE PAGO: Hasta el "+ ;
- DTOC(Thisform.txtFecha.Value+Cast(pagos.dias1 As Integer))+" "+;
- STR(pagos.adic3)+" % Desc. $ "+;
- STR(m.nTOTAL*pagos.adic3/100,08,2)+;
- " Paga $ "+Str((m.nTOTAL-(m.nTOTAL*pagos.adic3/100)),10,2))
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "OPCION DE PAGO: Hasta el "+ ;
- DTOC(pagos.dia+Cast(pagos.dias1 As Integer))+" "+;
- STR(pagos.adic3)+" % Desc. $ "+;
- STR(m.nTOTAL*pagos.adic3/100,08,2)+;
- " Paga $ "+Str((m.nTOTAL-(m.nTOTAL*pagos.adic3/100)),10,2))
- Endif
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + Chr(127))
- Endif
- lin = Str(Val(lin)+1,2,0)
- *!* Insert Into comando;
- *!* VALUES ("]" + Se + lin + Se + Chr(127))
- If m.nFlete > 0 Or m.nDRet > 0
- If m.nFlete > 0
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "Prec. de Merc. Incl. Flete "+ ;
- Transform(m.nFlete, "@$ 99,999,999.99"))
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "Merc. Incl. Desc p/RETIRA "+ ;
- Transform(m.nDRet, "@$ 99,999,999.99"))
- Endif
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + Chr(127))
- Endif
- &&si se factura sobre remitos se imprimen los remitos afectados
- If Thisform.viene = "X" &&hay q revisar esto para ver q cuando se factura de remitos se imprima
- Insert Into comando;
- VALUES ( Chr(147) + Se + "1" + Se + Substr(This.remitosafacturar,1,17))
- If !Empty(Substr(This.remitosafacturar,19,20))
- Insert Into comando;
- VALUES (Chr(147) + Se + "2" + Se + Substr(This.remitosafacturar,19,20))
- Endif
- Endif
- Else
- If This.contado = 'N'
- Insert Into comando;
- values("]" + Se + lin + Se+;
- " Saldo de CTA_CTE: $"+;
- ALLTRIM(Str((m.salctacte),12,2)))
- lin = '6'
- Else
- Insert Into comando;
- values("]" + Se + lin + Se + Chr(127))
- lin = '6'
- Endif
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se + "Vendedor: "+Alltrim(goApp.User) )
- lin = '7'
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + Chr(127))
- lin = '8'
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + Chr(127))
- lin = '11'
- *!* Insert Into comando;
- *!* VALUES ("]" + Se + lin + Se + Chr(127))
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + Chr(127))
- Endif
- If This.Ticket="S"
- Insert Into comando;
- VALUES ( "]" + Se + "9" + Se +Chr(127))
- Insert Into comando;
- VALUES ("]" + Se + "10" + Se +Chr(127))
- If This.condicion = 'C' And Val(sCliente) = 1
- Insert Into comando;
- VALUES ("b" + Se + Substr(sNombre,1,30) + Se + ;
- ndocu + Se + TIPO_IVA + Se + TIPO_DOCU + Se +;
- " S/NOMBRE")
- Else
- Insert Into comando;
- VALUES ("b" + Se + Substr(sNombre,1,30) + Se + ;
- ndocu + Se + TIPO_IVA + Se + TIPO_DOCU + Se +;
- SUBSTR(Alltrim(thisformset.frmCliente.txtDomicilio.Value)+" "+Alltrim(loc.nombre)+;
- " "+Alltrim(loc.provincia),1,40))
- Endif
- Else
- &&"["+sCliente+"] "+
- Insert Into comando;
- VALUES ( "b" + Se + "[" + sCliente + "] " + Substr(sNombre,1,40) + Se +;
- ndocu + Se + TIPO_IVA + Se + TIPO_DOCU + Se + ;
- ALLTRIM(Thisform.txtDom.Value)+" ("+Alltrim(clientes.codpos)+") "+;
- Alltrim(loc.nombre)+" "+Alltrim(loc.provincia))
- Endif
- If This.condicion <> "C"
- Insert Into comando;
- VALUES (Chr(64)+Se+TIPO_FACTURA+Se+"T")
- Else
- &&Definir tipo y num de factura afectado por nota de credito
- Insert Into comando;
- VALUES (Chr(147) + Se + "1" + Se + cre.tipoaf + " " + cre.numeroaf)
- Insert Into comando;
- VALUES (Chr(128)+Se+TIPO_FACTURA+Se+"T")
- Endif
- &&el cursor "DET" posee los items a facturar
- Select("det")
- Go Top
- Do While ! Eof()
- *!* Create Cursor det;
- *!* (cantidad n(12,4), unidad c(8), detalle c(40), total n(12,2), idArticulo int,;
- *!* unitario n(12,2), costo n(12,2), montoiva n(12,2), montodgr n(12,2), montomuni N(12,2),;
- *!* poriva n(12,2), tipoiva c(2))
- If det.unitario != 0
- If This.clase = "A"
- If This.Ticket = "S"
- Insert Into comando;
- VALUES ("A" + Se + det.unidad +" "+Substr(det.detalle,1,19)+ Se + "0")
- Insert Into comando;
- VALUES ("B" + Se + Padr(Alltrim(Substr(det.detalle,20,20)),20,".") + Se +;
- ALLTRIM(Str(det.cantidad,6,2)+"0")+ Se +;
- ALLTRIM(Str(det.unitario,9,2)) + Se + ;
- ALLTRIM(Str(det.poriva,5,2)) + Se +;
- "M" + Se + "0.00" + Se + "0" + Se + "T")
- Else
- Insert Into comando;
- VALUES ("B" + Se + det.unidad +" "+det.detalle+ Se + ;
- ALLTRIM(Str(det.cantidad,11,2))+ Se + ;
- Alltrim(Str(det.unitario,13,2)) + ;
- Se +Alltrim(Str(det.poriva,5,2)) + Se + ;
- "M" + Se + "0" + Se + "" + Se + "T")
- Endif
- Else
- If This.Ticket = "S"
- Insert Into comando;
- VALUES ( "A" + Se + det.unidad +" "+Substr(det.detalle,1,19)+ Se + "0")
- Insert Into comando;
- VALUES ("B" + Se + Padr(Alltrim(Substr(det.detalle,20,20)),20,".") + ;
- Se +Alltrim(Str(det.cantidad,6,2)+"0")+ Se + ;
- ALLTRIM(Str(det.unitario,9,2)) + Se + ;
- ALLTRIM(Str(det.poriva,5,2)) + Se + ;
- "M" + Se + "0.00" + Se + "0" + Se + "T")
- Else
- Insert Into comando;
- VALUES ("B" + Se + det.unidad+" "+det.detalle+ Se +;
- ALLTRIM(Str(det.cantidad,11,2))+ Se + ;
- ALLTRIM(Str(det.unitario,13,2)) + Se +;
- ALLTRIM(Str(det.poriva,5,2)) + Se + ;
- "M" + Se + "0" + Se + "" + Se + "T")
- Endif
- Endif
- Endif
- Select("det")
- Skip
- Enddo
- If This.condicion <> "C"
- If This.Ticket = "S"
- If This.contado = "S"
- Insert Into comando;
- VALUES (Chr(68)+ Se + Substr(formapago.detalle,1,30)+ Se + ;
- ALLTRIM(Str(ThisForm.Saldacontado.txtPago.Value,10,2))+ Se +"T"+ Se+"0")
- Else
- Insert Into comando;
- VALUES ( Chr(68)+ Se + Substr(formapago.detalle,1,30)+ ;
- Se + Alltrim(Str(ThisForm.Saldacontado.txtPago.Value,10,2))+ Se +"T"+ Se+"0")
- Endif
- Else
- If This.contado = "S"
- Insert Into comando;
- VALUES (Chr(68)+ Se + Alltrim(formapago.detalle)+ Se + ;
- ALLTRIM(Str(ThisForm.Saldacontado.txtPago.Value,12,2))+ Se +"T"+ Se+"0")
- Else
- Insert Into comando;
- VALUES(Chr(68)+ Se + Alltrim(formapago.detalle)+ Se + ;
- ALLTRIM(Str(ThisForm.Saldacontado.txtPago.Value,12,2))+ Se +"T"+ Se+"0")
- Endif
- Endif
- Endif
- If This.condicion <> "C"
- Insert Into comando;
- VALUES (Chr(69))
- Else
- Insert Into comando;
- VALUES ( Chr(129) )
- Endif
- &&en esta parte copio el archivo con los comandos a la carpeta desde el cual
- &&el spooler de impresion lee el archivo
- If This.Ticket ="S"
- && si es ticket me fijo a cual impresora debo enviar
- If lImpreFiscal
- mtXt = Alltrim(impfis.dircoticket) + Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(impfis.dirreticket) + Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Else
- mtXt = Alltrim(parametr.dirco)+"715\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(parametr.dirre)+"715\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Endif
- *!* cDirCom = "fpserver715" + "\impred.exe"
- *!* cDirCom = Fullpath(cDirCom)
- *!* && Mato el proceso del spooler y lo vuelvo a cargar
- *!* This.killprocessbyname("impred.exe")
- *!* This.killprocessbyname("wspooler.exe")
- *!* oShell = Createobject("Shell.Application")
- *!* oShell.ShellExecute (cDirCom)
- Else
- &&aca envio a la 320
- If lImpreFiscal
- mtXt = Alltrim(impfis.dircofactura) + Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(impfis.dirrefactura) + Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Else
- mtXt = Alltrim(parametr.dirco)+"320\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(parametr.dirre)+"320\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Endif
- Endif
- Select("comando")
- Goto Top
- &&en caso de que tenga un archivo en la cola de impresion de la impresora
- &&no se deja imprimir
- *Browse
- If File(mtXt)
- Messagebox("ATENCION: Ud. ya tiene un Documento en Cola de Impresión"+Chr(10)+Chr(13)+;
- " AGUARDE a que el mismo sea impreso o elimínelo luego vuelva a intentar")
- Return This.TodoOK
- Else
- Copy To &mtXt Sdf
- If File(maNs)
- Erase &maNs
- Endif
- If File(Alltrim(paramfac.dirpa)+"SPOOLER.LOG")
- Erase (Alltrim(paramfac.dirpa)+"SPOOLER.LOG")
- Endif
- Wait Windows 'Esperando Respuesta del Controlador Fiscal...' Nowait
- fd = -1
- intentos =1
- Do While fd < 0 .And. Lastkey() != 27
- fd = Fopen(maNs, 0)
- This.LeerSpooler("T")
- If intentos = 30
- Messagebox("ATENCION: Verifique que el Controlador Esté Conectado y Encendido. " + Chr(10) + Chr(13)+ ;
- "Verifique además que el Programa Spooler se esté ejecutando " + Chr(10) + Chr(13)+ ;
- "en el equipo al cual se encuentra conectado el Controlador Fiscal")
- This.LeerSpooler("T")
- Endif
- If intentos = 70
- Messagebox("ATENCION: Tiempo de Espera Agotado !!! Presione ESC. para cancelar este Comprobante")
- This.LeerSpooler("T")
- Endif
- intentos = intentos + 1
- *For i=1 To 100
- *Next
- Inkey(1)
- If Lastkey() = 27
- If Substr(comando.comando,17,16) = "Impresor Ocupado"
- Messagebox("ATENCION: No se aconseja cancelar este documento por programa, "+;
- CHR(10)+Chr(13)+"La impresora ya lo ha procesado y saldrá impreso"+;
- CHR(10)+Chr(13)+ "una vez que esta se ponga en linea")
- Endif
- If Messagebox("ATENCION: Realmente desea Cancelar la Emisión de este Documento??",4+256) = 6
- Messagebox(" Se proceder a Cancelar el Documento por Sistema"+;
- CHR(10)+Chr(13)+" Verifique que la impresora también lo haya Cancelado.")
- Keyboard '{ESC}'
- Else
- Keyboard ""
- Endif
- Endif
- Enddo
- If Lastkey() = 27.Or. fd < 0
- If File(mtXt)
- Erase &mtXt
- Endif
- fd = Fopen((Alltrim(paramfac.dirpa)+"SPOOLER.LOG"), 0)
- If fd < 0
- Messagebox("Operación Cancelada: ERROR de comunicaciones con el Controlador.; Probablemente no se este ejecutando Spooler. ")
- Else
- fd =Fclose(fd)
- This.LeerSpooler("T")
- Endif
- Else
- fd = Fclose(fd)
- Select("comando")
- Zap
- Append From &maNs Sdf
- Goto Bottom
- This.numero = Val(Substr(comando.comando,35,8))
- If This.numero <> 0
- SQLExec(goApp.nCon, "select * from puntero where sucursal=?param.sucursal","puntero")
- If This.Ticket = "S"
- If This.MasDeMil
- This.numero = Val('0009'+strzero(This.numero,8))
- Else
- If lImpreFiscal
- This.numero = Val(impfis.PtoVtaTicket+strzero(This.numero,8))
- Else
- If Param.sucursal=0
- If File("c:\0009.txt")
- This.numero = Val(strzero(9,4)+strzero(This.numero,8))
- Else
- This.numero = Val(strzero(puntero.pvta_tic,4)+strzero(This.numero,8))
- Endif
- Else
- If Param.sucursal = 1
- This.numero = Val(strzero(8,4)+strzero(This.numero,8))
- Endif
- Endif
- Endif
- Endif
- Else
- If lImpreFiscal
- This.numero = Val(impfis.PtoVtaFac+strzero(This.numero,8))
- Else
- This.numero = Val(strzero(puntero.pvta_fac,4)+strzero(This.numero,8))
- Endif
- Endif
- This.TodoOK = .T.
- Endif
- Endif
- If File((Alltrim(paramfac.dirpa)+"SPOOLER.LOG"))
- Erase Alltrim(paramfac.dirpa)+"SPOOLER.LOG"
- Endif
- Endif
- *This.killprocessbyname("impred.exe")
- *This.killprocessbyname("wspooler.exe")
- Set Talk &cTalk
- Return This.Todo
- *!* Endif
- &&indica si el cliente tiene que poseer cuit
- If tiporesp.obligacuit
- If Empty( Val( Strtran( clientes.cuit, "-" ) ) )
- Messagebox ("ATENCION: Falta Registrar CUIT de Cliente", 0+48, "CUIT")
- Do While Val(ndocu) < 2
- ndocu = Inputbox("Ingrese CUIT")
- Enddo
- ndocu = Alltrim( Strtran( ndocu, "-" ) )
- Else
- TIPO_DOCU = 'C' &&tiporesp.tipo_iva &&"C"
- ndocu = Alltrim( Strtran( clientes.cuit, "-" ) )
- Endif
- Else
- If SQLExec(goApp.nCon, "select * from tipodoc where codigo=?clientes.tipodocu","tipodoc") = -1
- goApp.Error()
- Return -1
- Endif
- If Reccount("tipodoc") > 0
- TIPO_DOCU = tipodoc.tipo
- Else
- TIPO_DOCU = '2'
- Endif
- ndocu = Alltrim(Str(clientes.dni))
- If Val(ndocu) < 2
- ndocu = '11111111'
- Endif
- Endif
- TIPO_IVA = tiporesp.TIPOIVA
- Select("comando")
- &&me fijo si es ticket factura o factura
- If This.Ticket = "S"
- lin = "5"
- Else
- lin = "3"
- Endif
- If This.Ticket = "N"
- &&en caso de ser factura imprimo todo el encabezado que va en la factura
- Select("comando")
- Insert Into comando;
- VALUES( "]" + Se + "1" + Se + Chr(127) )
- Insert Into comando;
- VALUES( "]" + Se + "2" + Se + Chr(127) )
- Insert Into comando;
- values( "]" + Se + "2" + Se + "Ing.Brut. 914-532186-1" )
- If This.contado = "N"
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "Vendedor: "+Alltrim(vendedor.nom_ven)+;
- SPACE(10)+"Vencimiento de este Comp.: "+;
- DTOC(This.FechaVen(Thisform.txtFecha.Value))+;
- " Saldo Actual de CTA_CTE(S.E.U.O.): $"+;
- ALLTRIM(Str((m.salctacte),12,2)))
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + "Vendedor: "+;
- ALLTRIM(vendedor.nom_ven)+;
- SPACE(10)+"Vencimiento de este Comp.: "+;
- DTOC(This.FechaVen(Thisform.txtFecha.Value)))
- Endif
- lin = Str(Val(lin)+1,1,0)
- Do Case
- Case Used("obsfac")
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + "OBS.: "+Alltrim(obsfac.obs1)+Alltrim(obsfac.obs2))
- Case This.pagoanticipado &&det.pagoanticipado
- If det.reparto
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + "PAGO ANTICIPADO - REPARTO")
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + "PAGO ANTICIPADO - RETIRA")
- Endif
- Case This.lReparto
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + "MERCADERIA DE REPARTO")
- Case !This.lReparto
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + "MERCADERIA PARA RETIRAR")
- Otherwise
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + "DEVOLUCIONES DENTRO DE LAS 48 HRS.")
- Endcase
- lin = Str(Val(lin)+1,1,0)
- This.letras.dicenum(m.nTOTAL)
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se + ;
- "SON:" + This.letras.retorno)
- lin = "11"
- &&especifico las formas de cancelacion que posee la factura
- If pagos.adic1 > 0 .Or. pagos.plazo1 > 0
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se + ;
- "OPCION DE PAGO: Hasta el "+;
- Dtoc(Thisform.txtFecha.Value+This.dias())+ " "+;
- STR(pagos.adic1)+" % Desc. $ "+;
- STR(m.nTOTAL*pagos.adic1/100,08,2)+;
- " Paga $ "+Str((m.nTOTAL-(m.nTOTAL*pagos.adic1)/100),10,2))
- Else
- If Inlist(pagos.pago,'00','01','02')
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se + ;
- "OPCION DE PAGO: Contado Efectivo"+;
- " 3% Desc. "+;
- " Paga $ "+ Str(m.nTOTAL,10,2))
- Else
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se + Chr(127))
- Endif
- Endif
- lin = Str(Val(lin)+1,2,0)
- If pagos.adic2 > 0 .Or. pagos.plazo2 > 0
- If Isnull(pagos.dia) Or Empty(pagos.dia)
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se +;
- "OPCION DE PAGO: Hasta el "+ ;
- DTOC(This.FechaVen(Thisform.txtFecha.Value))+" "+;
- STR(pagos.adic2)+" % Desc. $ ";
- +Str(m.nTOTAL*pagos.adic2/100,08,2)+;
- " Paga $ "+Str((m.nTOTAL-(m.nTOTAL*pagos.adic2)/100),10,2))
- Else
- If pagos.pago = '51'
- *!* Pongo esto para que en esta condicion no me sume los dias de ADIC2
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "OPCION DE PAGO: Hasta el "+ ;
- DTOC(pagos.dia)+" "+;
- STR(pagos.adic2)+" % Desc. $ "+;
- STR(m.nTOTAL*pagos.adic2/100,08,2)+;
- " Paga $ "+Str((m.nTOTAL-(m.nTOTAL*pagos.adic2)/100),10,2))
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "OPCION DE PAGO: Hasta el "+ ;
- DTOC(This.FechaVen(Thisform.txtFecha.Value))+" "+;
- STR(pagos.adic2)+" % Desc. $ "+;
- STR(m.nTOTAL*pagos.adic2/100,08,2)+;
- " Paga $ "+Str((m.nTOTAL-(m.nTOTAL*pagos.adic2)/100),10,2))
- Endif
- Endif
- Else
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se + Chr(127) )
- Endif
- lin = Str(Val(lin)+1,2,0)
- If pagos.adic3 > 0 .Or. pagos.plazo3 >0
- If Isnull(pagos.dia) Or Empty(pagos.dia)
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "OPCION DE PAGO: Hasta el "+ ;
- DTOC(Thisform.txtFecha.Value+Cast(pagos.dias1 As Integer))+" "+;
- STR(pagos.adic3)+" % Desc. $ "+;
- STR(m.nTOTAL*pagos.adic3/100,08,2)+;
- " Paga $ "+Str((m.nTOTAL-(m.nTOTAL*pagos.adic3/100)),10,2))
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "OPCION DE PAGO: Hasta el "+ ;
- DTOC(pagos.dia+Cast(pagos.dias1 As Integer))+" "+;
- STR(pagos.adic3)+" % Desc. $ "+;
- STR(m.nTOTAL*pagos.adic3/100,08,2)+;
- " Paga $ "+Str((m.nTOTAL-(m.nTOTAL*pagos.adic3/100)),10,2))
- Endif
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + Chr(127))
- Endif
- lin = Str(Val(lin)+1,2,0)
- *!* Insert Into comando;
- *!* VALUES ("]" + Se + lin + Se + Chr(127))
- If m.nFlete > 0 Or m.nDRet > 0
- If m.nFlete > 0
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "Prec. de Merc. Incl. Flete "+ ;
- Transform(m.nFlete, "@$ 99,999,999.99"))
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "Merc. Incl. Desc p/RETIRA "+ ;
- Transform(m.nDRet, "@$ 99,999,999.99"))
- Endif
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + Chr(127))
- Endif
- &&si se factura sobre remitos se imprimen los remitos afectados
- If Thisform.viene = "X" &&hay q revisar esto para ver q cuando se factura de remitos se imprima
- Insert Into comando;
- VALUES ( Chr(147) + Se + "1" + Se + Substr(This.remitosafacturar,1,17))
- If !Empty(Substr(This.remitosafacturar,19,20))
- Insert Into comando;
- VALUES (Chr(147) + Se + "2" + Se + Substr(This.remitosafacturar,19,20))
- Endif
- Endif
- Else
- If This.contado = 'N'
- Insert Into comando;
- values("]" + Se + lin + Se+;
- " Saldo de CTA_CTE: $"+;
- ALLTRIM(Str((m.salctacte),12,2)))
- lin = '6'
- Else
- Insert Into comando;
- values("]" + Se + lin + Se + Chr(127))
- lin = '6'
- Endif
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se + "Vendedor: "+Alltrim(goApp.User) )
- lin = '7'
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + Chr(127))
- lin = '8'
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + Chr(127))
- lin = '11'
- *!* Insert Into comando;
- *!* VALUES ("]" + Se + lin + Se + Chr(127))
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + Chr(127))
- Endif
- If This.Ticket="S"
- Insert Into comando;
- VALUES ( "]" + Se + "9" + Se +Chr(127))
- Insert Into comando;
- VALUES ("]" + Se + "10" + Se +Chr(127))
- If This.condicion = 'C' And Val(sCliente) = 1
- Insert Into comando;
- VALUES ("b" + Se + Substr(sNombre,1,30) + Se + ;
- ndocu + Se + TIPO_IVA + Se + TIPO_DOCU + Se +;
- " S/NOMBRE")
- Else
- Insert Into comando;
- VALUES ("b" + Se + Substr(sNombre,1,30) + Se + ;
- ndocu + Se + TIPO_IVA + Se + TIPO_DOCU + Se +;
- SUBSTR(Alltrim(thisformset.frmCliente.txtDomicilio.Value)+" "+Alltrim(loc.nombre)+;
- " "+Alltrim(loc.provincia),1,40))
- Endif
- Else
- &&"["+sCliente+"] "+
- Insert Into comando;
- VALUES ( "b" + Se + "[" + sCliente + "] " + Substr(sNombre,1,40) + Se +;
- ndocu + Se + TIPO_IVA + Se + TIPO_DOCU + Se + ;
- ALLTRIM(Thisform.txtDom.Value)+" ("+Alltrim(clientes.codpos)+") "+;
- Alltrim(loc.nombre)+" "+Alltrim(loc.provincia))
- Endif
- If This.condicion <> "C"
- Insert Into comando;
- VALUES (Chr(64)+Se+TIPO_FACTURA+Se+"T")
- Else
- &&Definir tipo y num de factura afectado por nota de credito
- Insert Into comando;
- VALUES (Chr(147) + Se + "1" + Se + cre.tipoaf + " " + cre.numeroaf)
- Insert Into comando;
- VALUES (Chr(128)+Se+TIPO_FACTURA+Se+"T")
- Endif
- &&el cursor "DET" posee los items a facturar
- Select("det")
- Go Top
- Do While ! Eof()
- *!* Create Cursor det;
- *!* (cantidad n(12,4), unidad c(8), detalle c(40), total n(12,2), idArticulo int,;
- *!* unitario n(12,2), costo n(12,2), montoiva n(12,2), montodgr n(12,2), montomuni N(12,2),;
- *!* poriva n(12,2), tipoiva c(2))
- If det.unitario != 0
- If This.clase = "A"
- If This.Ticket = "S"
- Insert Into comando;
- VALUES ("A" + Se + det.unidad +" "+Substr(det.detalle,1,19)+ Se + "0")
- Insert Into comando;
- VALUES ("B" + Se + Padr(Alltrim(Substr(det.detalle,20,20)),20,".") + Se +;
- ALLTRIM(Str(det.cantidad,6,2)+"0")+ Se +;
- ALLTRIM(Str(det.unitario,9,2)) + Se + ;
- ALLTRIM(Str(det.poriva,5,2)) + Se +;
- "M" + Se + "0.00" + Se + "0" + Se + "T")
- Else
- Insert Into comando;
- VALUES ("B" + Se + det.unidad +" "+det.detalle+ Se + ;
- ALLTRIM(Str(det.cantidad,11,2))+ Se + ;
- Alltrim(Str(det.unitario,13,2)) + ;
- Se +Alltrim(Str(det.poriva,5,2)) + Se + ;
- "M" + Se + "0" + Se + "" + Se + "T")
- Endif
- Else
- If This.Ticket = "S"
- Insert Into comando;
- VALUES ( "A" + Se + det.unidad +" "+Substr(det.detalle,1,19)+ Se + "0")
- Insert Into comando;
- VALUES ("B" + Se + Padr(Alltrim(Substr(det.detalle,20,20)),20,".") + ;
- Se +Alltrim(Str(det.cantidad,6,2)+"0")+ Se + ;
- ALLTRIM(Str(det.unitario,9,2)) + Se + ;
- ALLTRIM(Str(det.poriva,5,2)) + Se + ;
- "M" + Se + "0.00" + Se + "0" + Se + "T")
- Else
- Insert Into comando;
- VALUES ("B" + Se + det.unidad+" "+det.detalle+ Se +;
- ALLTRIM(Str(det.cantidad,11,2))+ Se + ;
- ALLTRIM(Str(det.unitario,13,2)) + Se +;
- ALLTRIM(Str(det.poriva,5,2)) + Se + ;
- "M" + Se + "0" + Se + "" + Se + "T")
- Endif
- Endif
- Endif
- Select("det")
- Skip
- Enddo
- If This.condicion <> "C"
- If This.Ticket = "S"
- If This.contado = "S"
- Insert Into comando;
- VALUES (Chr(68)+ Se + Substr(formapago.detalle,1,30)+ Se + ;
- ALLTRIM(Str(ThisForm.Saldacontado.txtPago.Value,10,2))+ Se +"T"+ Se+"0")
- Else
- Insert Into comando;
- VALUES ( Chr(68)+ Se + Substr(formapago.detalle,1,30)+ ;
- Se + Alltrim(Str(ThisForm.Saldacontado.txtPago.Value,10,2))+ Se +"T"+ Se+"0")
- Endif
- Else
- If This.contado = "S"
- Insert Into comando;
- VALUES (Chr(68)+ Se + Alltrim(formapago.detalle)+ Se + ;
- ALLTRIM(Str(ThisForm.Saldacontado.txtPago.Value,12,2))+ Se +"T"+ Se+"0")
- Else
- Insert Into comando;
- VALUES(Chr(68)+ Se + Alltrim(formapago.detalle)+ Se + ;
- ALLTRIM(Str(ThisForm.Saldacontado.txtPago.Value,12,2))+ Se +"T"+ Se+"0")
- Endif
- Endif
- Endif
- If This.condicion <> "C"
- Insert Into comando;
- VALUES (Chr(69))
- Else
- Insert Into comando;
- VALUES ( Chr(129) )
- Endif
- &&en esta parte copio el archivo con los comandos a la carpeta desde el cual
- &&el spooler de impresion lee el archivo
- If This.Ticket ="S"
- && si es ticket me fijo a cual impresora debo enviar
- If lImpreFiscal
- mtXt = Alltrim(impfis.dircoticket) + Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(impfis.dirreticket) + Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Else
- mtXt = Alltrim(parametr.dirco)+"715\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(parametr.dirre)+"715\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Endif
- *!* cDirCom = "fpserver715" + "\impred.exe"
- *!* cDirCom = Fullpath(cDirCom)
- *!* && Mato el proceso del spooler y lo vuelvo a cargar
- *!* This.killprocessbyname("impred.exe")
- *!* This.killprocessbyname("wspooler.exe")
- *!* oShell = Createobject("Shell.Application")
- *!* oShell.ShellExecute (cDirCom)
- Else
- &&aca envio a la 320
- If lImpreFiscal
- mtXt = Alltrim(impfis.dircofactura) + Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(impfis.dirrefactura) + Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Else
- mtXt = Alltrim(parametr.dirco)+"320\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(parametr.dirre)+"320\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Endif
- Endif
- Select("comando")
- Goto Top
- &&en caso de que tenga un archivo en la cola de impresion de la impresora
- &&no se deja imprimir
- *Browse
- If File(mtXt)
- Messagebox("ATENCION: Ud. ya tiene un Documento en Cola de Impresión"+Chr(10)+Chr(13)+;
- " AGUARDE a que el mismo sea impreso o elimínelo luego vuelva a intentar")
- Return This.TodoOK
- Else
- Copy To &mtXt Sdf
- If File(maNs)
- Erase &maNs
- Endif
- If File(Alltrim(paramfac.dirpa)+"SPOOLER.LOG")
- Erase (Alltrim(paramfac.dirpa)+"SPOOLER.LOG")
- Endif
- Wait Windows 'Esperando Respuesta del Controlador Fiscal...' Nowait
- fd = -1
- intentos =1
- Do While fd < 0 .And. Lastkey() != 27
- fd = Fopen(maNs, 0)
- This.LeerSpooler("T")
- If intentos = 30
- Messagebox("ATENCION: Verifique que el Controlador Esté Conectado y Encendido. " + Chr(10) + Chr(13)+ ;
- "Verifique además que el Programa Spooler se esté ejecutando " + Chr(10) + Chr(13)+ ;
- "en el equipo al cual se encuentra conectado el Controlador Fiscal")
- This.LeerSpooler("T")
- Endif
- If intentos = 70
- Messagebox("ATENCION: Tiempo de Espera Agotado !!! Presione ESC. para cancelar este Comprobante")
- This.LeerSpooler("T")
- Endif
- intentos = intentos + 1
- *For i=1 To 100
- *Next
- Inkey(1)
- If Lastkey() = 27
- If Substr(comando.comando,17,16) = "Impresor Ocupado"
- Messagebox("ATENCION: No se aconseja cancelar este documento por programa, "+;
- CHR(10)+Chr(13)+"La impresora ya lo ha procesado y saldrá impreso"+;
- CHR(10)+Chr(13)+ "una vez que esta se ponga en linea")
- Endif
- If Messagebox("ATENCION: Realmente desea Cancelar la Emisión de este Documento??",4+256) = 6
- Messagebox(" Se proceder a Cancelar el Documento por Sistema"+;
- CHR(10)+Chr(13)+" Verifique que la impresora también lo haya Cancelado.")
- Keyboard '{ESC}'
- Else
- Keyboard ""
- Endif
- Endif
- Enddo
- If Lastkey() = 27.Or. fd < 0
- If File(mtXt)
- Erase &mtXt
- Endif
- fd = Fopen((Alltrim(paramfac.dirpa)+"SPOOLER.LOG"), 0)
- If fd < 0
- Messagebox("Operación Cancelada: ERROR de comunicaciones con el Controlador.; Probablemente no se este ejecutando Spooler. ")
- Else
- fd =Fclose(fd)
- This.LeerSpooler("T")
- Endif
- Else
- fd = Fclose(fd)
- Select("comando")
- Zap
- Append From &maNs Sdf
- Goto Bottom
- This.numero = Val(Substr(comando.comando,35,8))
- If This.numero <> 0
- SQLExec(goApp.nCon, "select * from puntero where sucursal=?param.sucursal","puntero")
- If This.Ticket = "S"
- If This.MasDeMil
- This.numero = Val('0009'+strzero(This.numero,8))
- Else
- If lImpreFiscal
- This.numero = Val(impfis.PtoVtaTicket+strzero(This.numero,8))
- Else
- If Param.sucursal=0
- If File("c:\0009.txt")
- This.numero = Val(strzero(9,4)+strzero(This.numero,8))
- Else
- This.numero = Val(strzero(puntero.pvta_tic,4)+strzero(This.numero,8))
- Endif
- Else
- If Param.sucursal = 1
- This.numero = Val(strzero(8,4)+strzero(This.numero,8))
- Endif
- Endif
- Endif
- Endif
- Else
- If lImpreFiscal
- This.numero = Val(impfis.PtoVtaFac+strzero(This.numero,8))
- Else
- This.numero = Val(strzero(puntero.pvta_fac,4)+strzero(This.numero,8))
- Endif
- Endif
- This.TodoOK = .T.
- Endif
- Endif
- If File((Alltrim(paramfac.dirpa)+"SPOOLER.LOG"))
- Erase Alltrim(paramfac.dirpa)+"SPOOLER.LOG"
- Endif
- Endif
- *This.killprocessbyname("impred.exe")
- *This.killprocessbyname("wspooler.exe")
- Set Talk &cTalk
- Return This.Todo
- *!* Pongo esto para que en esta condicion no me sume los dias de ADIC2
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "OPCION DE PAGO: Hasta el "+ ;
- DTOC(pagos.dia)+" "+;
- STR(pagos.adic2)+" % Desc. $ "+;
- STR(m.nTOTAL*pagos.adic2/100,08,2)+;
- " Paga $ "+Str((m.nTOTAL-(m.nTOTAL*pagos.adic2)/100),10,2))
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "OPCION DE PAGO: Hasta el "+ ;
- DTOC(This.FechaVen(Thisform.txtFecha.Value))+" "+;
- STR(pagos.adic2)+" % Desc. $ "+;
- STR(m.nTOTAL*pagos.adic2/100,08,2)+;
- " Paga $ "+Str((m.nTOTAL-(m.nTOTAL*pagos.adic2)/100),10,2))
- Endif
- Endif
- Else
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se + Chr(127) )
- Endif
- lin = Str(Val(lin)+1,2,0)
- If pagos.adic3 > 0 .Or. pagos.plazo3 >0
- If Isnull(pagos.dia) Or Empty(pagos.dia)
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "OPCION DE PAGO: Hasta el "+ ;
- DTOC(Thisform.txtFecha.Value+Cast(pagos.dias1 As Integer))+" "+;
- STR(pagos.adic3)+" % Desc. $ "+;
- STR(m.nTOTAL*pagos.adic3/100,08,2)+;
- " Paga $ "+Str((m.nTOTAL-(m.nTOTAL*pagos.adic3/100)),10,2))
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "OPCION DE PAGO: Hasta el "+ ;
- DTOC(pagos.dia+Cast(pagos.dias1 As Integer))+" "+;
- STR(pagos.adic3)+" % Desc. $ "+;
- STR(m.nTOTAL*pagos.adic3/100,08,2)+;
- " Paga $ "+Str((m.nTOTAL-(m.nTOTAL*pagos.adic3/100)),10,2))
- Endif
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + Chr(127))
- Endif
- lin = Str(Val(lin)+1,2,0)
- *!* Insert Into comando;
- *!* VALUES ("]" + Se + lin + Se + Chr(127))
- If m.nFlete > 0 Or m.nDRet > 0
- If m.nFlete > 0
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "Prec. de Merc. Incl. Flete "+ ;
- Transform(m.nFlete, "@$ 99,999,999.99"))
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "Merc. Incl. Desc p/RETIRA "+ ;
- Transform(m.nDRet, "@$ 99,999,999.99"))
- Endif
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + Chr(127))
- Endif
- &&si se factura sobre remitos se imprimen los remitos afectados
- If Thisform.viene = "X" &&hay q revisar esto para ver q cuando se factura de remitos se imprima
- Insert Into comando;
- VALUES ( Chr(147) + Se + "1" + Se + Substr(This.remitosafacturar,1,17))
- If !Empty(Substr(This.remitosafacturar,19,20))
- Insert Into comando;
- VALUES (Chr(147) + Se + "2" + Se + Substr(This.remitosafacturar,19,20))
- Endif
- Endif
- Else
- If This.contado = 'N'
- Insert Into comando;
- values("]" + Se + lin + Se+;
- " Saldo de CTA_CTE: $"+;
- ALLTRIM(Str((m.salctacte),12,2)))
- lin = '6'
- Else
- Insert Into comando;
- values("]" + Se + lin + Se + Chr(127))
- lin = '6'
- Endif
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se + "Vendedor: "+Alltrim(goApp.User) )
- lin = '7'
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + Chr(127))
- lin = '8'
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + Chr(127))
- lin = '11'
- *!* Insert Into comando;
- *!* VALUES ("]" + Se + lin + Se + Chr(127))
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + Chr(127))
- Endif
- If This.Ticket="S"
- Insert Into comando;
- VALUES ( "]" + Se + "9" + Se +Chr(127))
- Insert Into comando;
- VALUES ("]" + Se + "10" + Se +Chr(127))
- If This.condicion = 'C' And Val(sCliente) = 1
- Insert Into comando;
- VALUES ("b" + Se + Substr(sNombre,1,30) + Se + ;
- ndocu + Se + TIPO_IVA + Se + TIPO_DOCU + Se +;
- " S/NOMBRE")
- Else
- Insert Into comando;
- VALUES ("b" + Se + Substr(sNombre,1,30) + Se + ;
- ndocu + Se + TIPO_IVA + Se + TIPO_DOCU + Se +;
- SUBSTR(Alltrim(thisformset.frmCliente.txtDomicilio.Value)+" "+Alltrim(loc.nombre)+;
- " "+Alltrim(loc.provincia),1,40))
- Endif
- Else
- &&"["+sCliente+"] "+
- Insert Into comando;
- VALUES ( "b" + Se + "[" + sCliente + "] " + Substr(sNombre,1,40) + Se +;
- ndocu + Se + TIPO_IVA + Se + TIPO_DOCU + Se + ;
- ALLTRIM(Thisform.txtDom.Value)+" ("+Alltrim(clientes.codpos)+") "+;
- Alltrim(loc.nombre)+" "+Alltrim(loc.provincia))
- Endif
- If This.condicion <> "C"
- Insert Into comando;
- VALUES (Chr(64)+Se+TIPO_FACTURA+Se+"T")
- Else
- &&Definir tipo y num de factura afectado por nota de credito
- Insert Into comando;
- VALUES (Chr(147) + Se + "1" + Se + cre.tipoaf + " " + cre.numeroaf)
- Insert Into comando;
- VALUES (Chr(128)+Se+TIPO_FACTURA+Se+"T")
- Endif
- &&el cursor "DET" posee los items a facturar
- Select("det")
- Go Top
- Do While ! Eof()
- *!* Create Cursor det;
- *!* (cantidad n(12,4), unidad c(8), detalle c(40), total n(12,2), idArticulo int,;
- *!* unitario n(12,2), costo n(12,2), montoiva n(12,2), montodgr n(12,2), montomuni N(12,2),;
- *!* poriva n(12,2), tipoiva c(2))
- If det.unitario != 0
- If This.clase = "A"
- If This.Ticket = "S"
- Insert Into comando;
- VALUES ("A" + Se + det.unidad +" "+Substr(det.detalle,1,19)+ Se + "0")
- Insert Into comando;
- VALUES ("B" + Se + Padr(Alltrim(Substr(det.detalle,20,20)),20,".") + Se +;
- ALLTRIM(Str(det.cantidad,6,2)+"0")+ Se +;
- ALLTRIM(Str(det.unitario,9,2)) + Se + ;
- ALLTRIM(Str(det.poriva,5,2)) + Se +;
- "M" + Se + "0.00" + Se + "0" + Se + "T")
- Else
- Insert Into comando;
- VALUES ("B" + Se + det.unidad +" "+det.detalle+ Se + ;
- ALLTRIM(Str(det.cantidad,11,2))+ Se + ;
- Alltrim(Str(det.unitario,13,2)) + ;
- Se +Alltrim(Str(det.poriva,5,2)) + Se + ;
- "M" + Se + "0" + Se + "" + Se + "T")
- Endif
- Else
- If This.Ticket = "S"
- Insert Into comando;
- VALUES ( "A" + Se + det.unidad +" "+Substr(det.detalle,1,19)+ Se + "0")
- Insert Into comando;
- VALUES ("B" + Se + Padr(Alltrim(Substr(det.detalle,20,20)),20,".") + ;
- Se +Alltrim(Str(det.cantidad,6,2)+"0")+ Se + ;
- ALLTRIM(Str(det.unitario,9,2)) + Se + ;
- ALLTRIM(Str(det.poriva,5,2)) + Se + ;
- "M" + Se + "0.00" + Se + "0" + Se + "T")
- Else
- Insert Into comando;
- VALUES ("B" + Se + det.unidad+" "+det.detalle+ Se +;
- ALLTRIM(Str(det.cantidad,11,2))+ Se + ;
- ALLTRIM(Str(det.unitario,13,2)) + Se +;
- ALLTRIM(Str(det.poriva,5,2)) + Se + ;
- "M" + Se + "0" + Se + "" + Se + "T")
- Endif
- Endif
- Endif
- Select("det")
- Skip
- Enddo
- If This.condicion <> "C"
- If This.Ticket = "S"
- If This.contado = "S"
- Insert Into comando;
- VALUES (Chr(68)+ Se + Substr(formapago.detalle,1,30)+ Se + ;
- ALLTRIM(Str(ThisForm.Saldacontado.txtPago.Value,10,2))+ Se +"T"+ Se+"0")
- Else
- Insert Into comando;
- VALUES ( Chr(68)+ Se + Substr(formapago.detalle,1,30)+ ;
- Se + Alltrim(Str(ThisForm.Saldacontado.txtPago.Value,10,2))+ Se +"T"+ Se+"0")
- Endif
- Else
- If This.contado = "S"
- Insert Into comando;
- VALUES (Chr(68)+ Se + Alltrim(formapago.detalle)+ Se + ;
- ALLTRIM(Str(ThisForm.Saldacontado.txtPago.Value,12,2))+ Se +"T"+ Se+"0")
- Else
- Insert Into comando;
- VALUES(Chr(68)+ Se + Alltrim(formapago.detalle)+ Se + ;
- ALLTRIM(Str(ThisForm.Saldacontado.txtPago.Value,12,2))+ Se +"T"+ Se+"0")
- Endif
- Endif
- Endif
- If This.condicion <> "C"
- Insert Into comando;
- VALUES (Chr(69))
- Else
- Insert Into comando;
- VALUES ( Chr(129) )
- Endif
- &&en esta parte copio el archivo con los comandos a la carpeta desde el cual
- &&el spooler de impresion lee el archivo
- If This.Ticket ="S"
- && si es ticket me fijo a cual impresora debo enviar
- If lImpreFiscal
- mtXt = Alltrim(impfis.dircoticket) + Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(impfis.dirreticket) + Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Else
- mtXt = Alltrim(parametr.dirco)+"715\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(parametr.dirre)+"715\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Endif
- *!* cDirCom = "fpserver715" + "\impred.exe"
- *!* cDirCom = Fullpath(cDirCom)
- *!* && Mato el proceso del spooler y lo vuelvo a cargar
- *!* This.killprocessbyname("impred.exe")
- *!* This.killprocessbyname("wspooler.exe")
- *!* oShell = Createobject("Shell.Application")
- *!* oShell.ShellExecute (cDirCom)
- Else
- &&aca envio a la 320
- If lImpreFiscal
- mtXt = Alltrim(impfis.dircofactura) + Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(impfis.dirrefactura) + Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Else
- mtXt = Alltrim(parametr.dirco)+"320\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(parametr.dirre)+"320\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Endif
- Endif
- Select("comando")
- Goto Top
- &&en caso de que tenga un archivo en la cola de impresion de la impresora
- &&no se deja imprimir
- *Browse
- If File(mtXt)
- Messagebox("ATENCION: Ud. ya tiene un Documento en Cola de Impresión"+Chr(10)+Chr(13)+;
- " AGUARDE a que el mismo sea impreso o elimínelo luego vuelva a intentar")
- Return This.TodoOK
- Else
- Copy To &mtXt Sdf
- If File(maNs)
- Erase &maNs
- Endif
- If File(Alltrim(paramfac.dirpa)+"SPOOLER.LOG")
- Erase (Alltrim(paramfac.dirpa)+"SPOOLER.LOG")
- Endif
- Wait Windows 'Esperando Respuesta del Controlador Fiscal...' Nowait
- fd = -1
- intentos =1
- Do While fd < 0 .And. Lastkey() != 27
- fd = Fopen(maNs, 0)
- This.LeerSpooler("T")
- If intentos = 30
- Messagebox("ATENCION: Verifique que el Controlador Esté Conectado y Encendido. " + Chr(10) + Chr(13)+ ;
- "Verifique además que el Programa Spooler se esté ejecutando " + Chr(10) + Chr(13)+ ;
- "en el equipo al cual se encuentra conectado el Controlador Fiscal")
- This.LeerSpooler("T")
- Endif
- If intentos = 70
- Messagebox("ATENCION: Tiempo de Espera Agotado !!! Presione ESC. para cancelar este Comprobante")
- This.LeerSpooler("T")
- Endif
- intentos = intentos + 1
- *For i=1 To 100
- *Next
- Inkey(1)
- If Lastkey() = 27
- If Substr(comando.comando,17,16) = "Impresor Ocupado"
- Messagebox("ATENCION: No se aconseja cancelar este documento por programa, "+;
- CHR(10)+Chr(13)+"La impresora ya lo ha procesado y saldrá impreso"+;
- CHR(10)+Chr(13)+ "una vez que esta se ponga en linea")
- Endif
- If Messagebox("ATENCION: Realmente desea Cancelar la Emisión de este Documento??",4+256) = 6
- Messagebox(" Se proceder a Cancelar el Documento por Sistema"+;
- CHR(10)+Chr(13)+" Verifique que la impresora también lo haya Cancelado.")
- Keyboard '{ESC}'
- Else
- Keyboard ""
- Endif
- Endif
- Enddo
- If Lastkey() = 27.Or. fd < 0
- If File(mtXt)
- Erase &mtXt
- Endif
- fd = Fopen((Alltrim(paramfac.dirpa)+"SPOOLER.LOG"), 0)
- If fd < 0
- Messagebox("Operación Cancelada: ERROR de comunicaciones con el Controlador.; Probablemente no se este ejecutando Spooler. ")
- Else
- fd =Fclose(fd)
- This.LeerSpooler("T")
- Endif
- Else
- fd = Fclose(fd)
- Select("comando")
- Zap
- Append From &maNs Sdf
- Goto Bottom
- This.numero = Val(Substr(comando.comando,35,8))
- If This.numero <> 0
- SQLExec(goApp.nCon, "select * from puntero where sucursal=?param.sucursal","puntero")
- If This.Ticket = "S"
- If This.MasDeMil
- This.numero = Val('0009'+strzero(This.numero,8))
- Else
- If lImpreFiscal
- This.numero = Val(impfis.PtoVtaTicket+strzero(This.numero,8))
- Else
- If Param.sucursal=0
- If File("c:\0009.txt")
- This.numero = Val(strzero(9,4)+strzero(This.numero,8))
- Else
- This.numero = Val(strzero(puntero.pvta_tic,4)+strzero(This.numero,8))
- Endif
- Else
- If Param.sucursal = 1
- This.numero = Val(strzero(8,4)+strzero(This.numero,8))
- Endif
- Endif
- Endif
- Endif
- Else
- If lImpreFiscal
- This.numero = Val(impfis.PtoVtaFac+strzero(This.numero,8))
- Else
- This.numero = Val(strzero(puntero.pvta_fac,4)+strzero(This.numero,8))
- Endif
- Endif
- This.TodoOK = .T.
- Endif
- Endif
- If File((Alltrim(paramfac.dirpa)+"SPOOLER.LOG"))
- Erase Alltrim(paramfac.dirpa)+"SPOOLER.LOG"
- Endif
- Endif
- *This.killprocessbyname("impred.exe")
- *This.killprocessbyname("wspooler.exe")
- Set Talk &cTalk
- Return This.Todo
- *!* Insert Into comando;
- *!* VALUES ("]" + Se + lin + Se + Chr(127))
- If m.nFlete > 0 Or m.nDRet > 0
- If m.nFlete > 0
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "Prec. de Merc. Incl. Flete "+ ;
- Transform(m.nFlete, "@$ 99,999,999.99"))
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "Merc. Incl. Desc p/RETIRA "+ ;
- Transform(m.nDRet, "@$ 99,999,999.99"))
- Endif
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + Chr(127))
- Endif
- &&si se factura sobre remitos se imprimen los remitos afectados
- If Thisform.viene = "X" &&hay q revisar esto para ver q cuando se factura de remitos se imprima
- Insert Into comando;
- VALUES ( Chr(147) + Se + "1" + Se + Substr(This.remitosafacturar,1,17))
- If !Empty(Substr(This.remitosafacturar,19,20))
- Insert Into comando;
- VALUES (Chr(147) + Se + "2" + Se + Substr(This.remitosafacturar,19,20))
- Endif
- Endif
- Else
- If This.contado = 'N'
- Insert Into comando;
- values("]" + Se + lin + Se+;
- " Saldo de CTA_CTE: $"+;
- ALLTRIM(Str((m.salctacte),12,2)))
- lin = '6'
- Else
- Insert Into comando;
- values("]" + Se + lin + Se + Chr(127))
- lin = '6'
- Endif
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se + "Vendedor: "+Alltrim(goApp.User) )
- lin = '7'
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + Chr(127))
- lin = '8'
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + Chr(127))
- lin = '11'
- *!* Insert Into comando;
- *!* VALUES ("]" + Se + lin + Se + Chr(127))
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + Chr(127))
- Endif
- If This.Ticket="S"
- Insert Into comando;
- VALUES ( "]" + Se + "9" + Se +Chr(127))
- Insert Into comando;
- VALUES ("]" + Se + "10" + Se +Chr(127))
- If This.condicion = 'C' And Val(sCliente) = 1
- Insert Into comando;
- VALUES ("b" + Se + Substr(sNombre,1,30) + Se + ;
- ndocu + Se + TIPO_IVA + Se + TIPO_DOCU + Se +;
- " S/NOMBRE")
- Else
- Insert Into comando;
- VALUES ("b" + Se + Substr(sNombre,1,30) + Se + ;
- ndocu + Se + TIPO_IVA + Se + TIPO_DOCU + Se +;
- SUBSTR(Alltrim(thisformset.frmCliente.txtDomicilio.Value)+" "+Alltrim(loc.nombre)+;
- " "+Alltrim(loc.provincia),1,40))
- Endif
- Else
- &&"["+sCliente+"] "+
- Insert Into comando;
- VALUES ( "b" + Se + "[" + sCliente + "] " + Substr(sNombre,1,40) + Se +;
- ndocu + Se + TIPO_IVA + Se + TIPO_DOCU + Se + ;
- ALLTRIM(Thisform.txtDom.Value)+" ("+Alltrim(clientes.codpos)+") "+;
- Alltrim(loc.nombre)+" "+Alltrim(loc.provincia))
- Endif
- If This.condicion <> "C"
- Insert Into comando;
- VALUES (Chr(64)+Se+TIPO_FACTURA+Se+"T")
- Else
- &&Definir tipo y num de factura afectado por nota de credito
- Insert Into comando;
- VALUES (Chr(147) + Se + "1" + Se + cre.tipoaf + " " + cre.numeroaf)
- Insert Into comando;
- VALUES (Chr(128)+Se+TIPO_FACTURA+Se+"T")
- Endif
- &&el cursor "DET" posee los items a facturar
- Select("det")
- Go Top
- Do While ! Eof()
- *!* Create Cursor det;
- *!* (cantidad n(12,4), unidad c(8), detalle c(40), total n(12,2), idArticulo int,;
- *!* unitario n(12,2), costo n(12,2), montoiva n(12,2), montodgr n(12,2), montomuni N(12,2),;
- *!* poriva n(12,2), tipoiva c(2))
- If det.unitario != 0
- If This.clase = "A"
- If This.Ticket = "S"
- Insert Into comando;
- VALUES ("A" + Se + det.unidad +" "+Substr(det.detalle,1,19)+ Se + "0")
- Insert Into comando;
- VALUES ("B" + Se + Padr(Alltrim(Substr(det.detalle,20,20)),20,".") + Se +;
- ALLTRIM(Str(det.cantidad,6,2)+"0")+ Se +;
- ALLTRIM(Str(det.unitario,9,2)) + Se + ;
- ALLTRIM(Str(det.poriva,5,2)) + Se +;
- "M" + Se + "0.00" + Se + "0" + Se + "T")
- Else
- Insert Into comando;
- VALUES ("B" + Se + det.unidad +" "+det.detalle+ Se + ;
- ALLTRIM(Str(det.cantidad,11,2))+ Se + ;
- Alltrim(Str(det.unitario,13,2)) + ;
- Se +Alltrim(Str(det.poriva,5,2)) + Se + ;
- "M" + Se + "0" + Se + "" + Se + "T")
- Endif
- Else
- If This.Ticket = "S"
- Insert Into comando;
- VALUES ( "A" + Se + det.unidad +" "+Substr(det.detalle,1,19)+ Se + "0")
- Insert Into comando;
- VALUES ("B" + Se + Padr(Alltrim(Substr(det.detalle,20,20)),20,".") + ;
- Se +Alltrim(Str(det.cantidad,6,2)+"0")+ Se + ;
- ALLTRIM(Str(det.unitario,9,2)) + Se + ;
- ALLTRIM(Str(det.poriva,5,2)) + Se + ;
- "M" + Se + "0.00" + Se + "0" + Se + "T")
- Else
- Insert Into comando;
- VALUES ("B" + Se + det.unidad+" "+det.detalle+ Se +;
- ALLTRIM(Str(det.cantidad,11,2))+ Se + ;
- ALLTRIM(Str(det.unitario,13,2)) + Se +;
- ALLTRIM(Str(det.poriva,5,2)) + Se + ;
- "M" + Se + "0" + Se + "" + Se + "T")
- Endif
- Endif
- Endif
- Select("det")
- Skip
- Enddo
- If This.condicion <> "C"
- If This.Ticket = "S"
- If This.contado = "S"
- Insert Into comando;
- VALUES (Chr(68)+ Se + Substr(formapago.detalle,1,30)+ Se + ;
- ALLTRIM(Str(ThisForm.Saldacontado.txtPago.Value,10,2))+ Se +"T"+ Se+"0")
- Else
- Insert Into comando;
- VALUES ( Chr(68)+ Se + Substr(formapago.detalle,1,30)+ ;
- Se + Alltrim(Str(ThisForm.Saldacontado.txtPago.Value,10,2))+ Se +"T"+ Se+"0")
- Endif
- Else
- If This.contado = "S"
- Insert Into comando;
- VALUES (Chr(68)+ Se + Alltrim(formapago.detalle)+ Se + ;
- ALLTRIM(Str(ThisForm.Saldacontado.txtPago.Value,12,2))+ Se +"T"+ Se+"0")
- Else
- Insert Into comando;
- VALUES(Chr(68)+ Se + Alltrim(formapago.detalle)+ Se + ;
- ALLTRIM(Str(ThisForm.Saldacontado.txtPago.Value,12,2))+ Se +"T"+ Se+"0")
- Endif
- Endif
- Endif
- If This.condicion <> "C"
- Insert Into comando;
- VALUES (Chr(69))
- Else
- Insert Into comando;
- VALUES ( Chr(129) )
- Endif
- &&en esta parte copio el archivo con los comandos a la carpeta desde el cual
- &&el spooler de impresion lee el archivo
- If This.Ticket ="S"
- && si es ticket me fijo a cual impresora debo enviar
- If lImpreFiscal
- mtXt = Alltrim(impfis.dircoticket) + Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(impfis.dirreticket) + Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Else
- mtXt = Alltrim(parametr.dirco)+"715\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(parametr.dirre)+"715\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Endif
- *!* cDirCom = "fpserver715" + "\impred.exe"
- *!* cDirCom = Fullpath(cDirCom)
- *!* && Mato el proceso del spooler y lo vuelvo a cargar
- *!* This.killprocessbyname("impred.exe")
- *!* This.killprocessbyname("wspooler.exe")
- *!* oShell = Createobject("Shell.Application")
- *!* oShell.ShellExecute (cDirCom)
- Else
- &&aca envio a la 320
- If lImpreFiscal
- mtXt = Alltrim(impfis.dircofactura) + Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(impfis.dirrefactura) + Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Else
- mtXt = Alltrim(parametr.dirco)+"320\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(parametr.dirre)+"320\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Endif
- Endif
- Select("comando")
- Goto Top
- &&en caso de que tenga un archivo en la cola de impresion de la impresora
- &&no se deja imprimir
- *Browse
- If File(mtXt)
- Messagebox("ATENCION: Ud. ya tiene un Documento en Cola de Impresión"+Chr(10)+Chr(13)+;
- " AGUARDE a que el mismo sea impreso o elimínelo luego vuelva a intentar")
- Return This.TodoOK
- Else
- Copy To &mtXt Sdf
- If File(maNs)
- Erase &maNs
- Endif
- If File(Alltrim(paramfac.dirpa)+"SPOOLER.LOG")
- Erase (Alltrim(paramfac.dirpa)+"SPOOLER.LOG")
- Endif
- Wait Windows 'Esperando Respuesta del Controlador Fiscal...' Nowait
- fd = -1
- intentos =1
- Do While fd < 0 .And. Lastkey() != 27
- fd = Fopen(maNs, 0)
- This.LeerSpooler("T")
- If intentos = 30
- Messagebox("ATENCION: Verifique que el Controlador Esté Conectado y Encendido. " + Chr(10) + Chr(13)+ ;
- "Verifique además que el Programa Spooler se esté ejecutando " + Chr(10) + Chr(13)+ ;
- "en el equipo al cual se encuentra conectado el Controlador Fiscal")
- This.LeerSpooler("T")
- Endif
- If intentos = 70
- Messagebox("ATENCION: Tiempo de Espera Agotado !!! Presione ESC. para cancelar este Comprobante")
- This.LeerSpooler("T")
- Endif
- intentos = intentos + 1
- *For i=1 To 100
- *Next
- Inkey(1)
- If Lastkey() = 27
- If Substr(comando.comando,17,16) = "Impresor Ocupado"
- Messagebox("ATENCION: No se aconseja cancelar este documento por programa, "+;
- CHR(10)+Chr(13)+"La impresora ya lo ha procesado y saldrá impreso"+;
- CHR(10)+Chr(13)+ "una vez que esta se ponga en linea")
- Endif
- If Messagebox("ATENCION: Realmente desea Cancelar la Emisión de este Documento??",4+256) = 6
- Messagebox(" Se proceder a Cancelar el Documento por Sistema"+;
- CHR(10)+Chr(13)+" Verifique que la impresora también lo haya Cancelado.")
- Keyboard '{ESC}'
- Else
- Keyboard ""
- Endif
- Endif
- Enddo
- If Lastkey() = 27.Or. fd < 0
- If File(mtXt)
- Erase &mtXt
- Endif
- fd = Fopen((Alltrim(paramfac.dirpa)+"SPOOLER.LOG"), 0)
- If fd < 0
- Messagebox("Operación Cancelada: ERROR de comunicaciones con el Controlador.; Probablemente no se este ejecutando Spooler. ")
- Else
- fd =Fclose(fd)
- This.LeerSpooler("T")
- Endif
- Else
- fd = Fclose(fd)
- Select("comando")
- Zap
- Append From &maNs Sdf
- Goto Bottom
- This.numero = Val(Substr(comando.comando,35,8))
- If This.numero <> 0
- SQLExec(goApp.nCon, "select * from puntero where sucursal=?param.sucursal","puntero")
- If This.Ticket = "S"
- If This.MasDeMil
- This.numero = Val('0009'+strzero(This.numero,8))
- Else
- If lImpreFiscal
- This.numero = Val(impfis.PtoVtaTicket+strzero(This.numero,8))
- Else
- If Param.sucursal=0
- If File("c:\0009.txt")
- This.numero = Val(strzero(9,4)+strzero(This.numero,8))
- Else
- This.numero = Val(strzero(puntero.pvta_tic,4)+strzero(This.numero,8))
- Endif
- Else
- If Param.sucursal = 1
- This.numero = Val(strzero(8,4)+strzero(This.numero,8))
- Endif
- Endif
- Endif
- Endif
- Else
- If lImpreFiscal
- This.numero = Val(impfis.PtoVtaFac+strzero(This.numero,8))
- Else
- This.numero = Val(strzero(puntero.pvta_fac,4)+strzero(This.numero,8))
- Endif
- Endif
- This.TodoOK = .T.
- Endif
- Endif
- If File((Alltrim(paramfac.dirpa)+"SPOOLER.LOG"))
- Erase Alltrim(paramfac.dirpa)+"SPOOLER.LOG"
- Endif
- Endif
- *This.killprocessbyname("impred.exe")
- *This.killprocessbyname("wspooler.exe")
- Set Talk &cTalk
- Return This.Todo
- *!* VALUES ("]" + Se + lin + Se + Chr(127))
- If m.nFlete > 0 Or m.nDRet > 0
- If m.nFlete > 0
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "Prec. de Merc. Incl. Flete "+ ;
- Transform(m.nFlete, "@$ 99,999,999.99"))
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + ;
- "Merc. Incl. Desc p/RETIRA "+ ;
- Transform(m.nDRet, "@$ 99,999,999.99"))
- Endif
- Else
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + Chr(127))
- Endif
- &&si se factura sobre remitos se imprimen los remitos afectados
- If Thisform.viene = "X" &&hay q revisar esto para ver q cuando se factura de remitos se imprima
- Insert Into comando;
- VALUES ( Chr(147) + Se + "1" + Se + Substr(This.remitosafacturar,1,17))
- If !Empty(Substr(This.remitosafacturar,19,20))
- Insert Into comando;
- VALUES (Chr(147) + Se + "2" + Se + Substr(This.remitosafacturar,19,20))
- Endif
- Endif
- Else
- If This.contado = 'N'
- Insert Into comando;
- values("]" + Se + lin + Se+;
- " Saldo de CTA_CTE: $"+;
- ALLTRIM(Str((m.salctacte),12,2)))
- lin = '6'
- Else
- Insert Into comando;
- values("]" + Se + lin + Se + Chr(127))
- lin = '6'
- Endif
- Insert Into comando;
- VALUES ( "]" + Se + lin + Se + "Vendedor: "+Alltrim(goApp.User) )
- lin = '7'
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + Chr(127))
- lin = '8'
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + Chr(127))
- lin = '11'
- *!* Insert Into comando;
- *!* VALUES ("]" + Se + lin + Se + Chr(127))
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + Chr(127))
- Endif
- If This.Ticket="S"
- Insert Into comando;
- VALUES ( "]" + Se + "9" + Se +Chr(127))
- Insert Into comando;
- VALUES ("]" + Se + "10" + Se +Chr(127))
- If This.condicion = 'C' And Val(sCliente) = 1
- Insert Into comando;
- VALUES ("b" + Se + Substr(sNombre,1,30) + Se + ;
- ndocu + Se + TIPO_IVA + Se + TIPO_DOCU + Se +;
- " S/NOMBRE")
- Else
- Insert Into comando;
- VALUES ("b" + Se + Substr(sNombre,1,30) + Se + ;
- ndocu + Se + TIPO_IVA + Se + TIPO_DOCU + Se +;
- SUBSTR(Alltrim(thisformset.frmCliente.txtDomicilio.Value)+" "+Alltrim(loc.nombre)+;
- " "+Alltrim(loc.provincia),1,40))
- Endif
- Else
- &&"["+sCliente+"] "+
- Insert Into comando;
- VALUES ( "b" + Se + "[" + sCliente + "] " + Substr(sNombre,1,40) + Se +;
- ndocu + Se + TIPO_IVA + Se + TIPO_DOCU + Se + ;
- ALLTRIM(Thisform.txtDom.Value)+" ("+Alltrim(clientes.codpos)+") "+;
- Alltrim(loc.nombre)+" "+Alltrim(loc.provincia))
- Endif
- If This.condicion <> "C"
- Insert Into comando;
- VALUES (Chr(64)+Se+TIPO_FACTURA+Se+"T")
- Else
- &&Definir tipo y num de factura afectado por nota de credito
- Insert Into comando;
- VALUES (Chr(147) + Se + "1" + Se + cre.tipoaf + " " + cre.numeroaf)
- Insert Into comando;
- VALUES (Chr(128)+Se+TIPO_FACTURA+Se+"T")
- Endif
- &&el cursor "DET" posee los items a facturar
- Select("det")
- Go Top
- Do While ! Eof()
- *!* Create Cursor det;
- *!* (cantidad n(12,4), unidad c(8), detalle c(40), total n(12,2), idArticulo int,;
- *!* unitario n(12,2), costo n(12,2), montoiva n(12,2), montodgr n(12,2), montomuni N(12,2),;
- *!* poriva n(12,2), tipoiva c(2))
- If det.unitario != 0
- If This.clase = "A"
- If This.Ticket = "S"
- Insert Into comando;
- VALUES ("A" + Se + det.unidad +" "+Substr(det.detalle,1,19)+ Se + "0")
- Insert Into comando;
- VALUES ("B" + Se + Padr(Alltrim(Substr(det.detalle,20,20)),20,".") + Se +;
- ALLTRIM(Str(det.cantidad,6,2)+"0")+ Se +;
- ALLTRIM(Str(det.unitario,9,2)) + Se + ;
- ALLTRIM(Str(det.poriva,5,2)) + Se +;
- "M" + Se + "0.00" + Se + "0" + Se + "T")
- Else
- Insert Into comando;
- VALUES ("B" + Se + det.unidad +" "+det.detalle+ Se + ;
- ALLTRIM(Str(det.cantidad,11,2))+ Se + ;
- Alltrim(Str(det.unitario,13,2)) + ;
- Se +Alltrim(Str(det.poriva,5,2)) + Se + ;
- "M" + Se + "0" + Se + "" + Se + "T")
- Endif
- Else
- If This.Ticket = "S"
- Insert Into comando;
- VALUES ( "A" + Se + det.unidad +" "+Substr(det.detalle,1,19)+ Se + "0")
- Insert Into comando;
- VALUES ("B" + Se + Padr(Alltrim(Substr(det.detalle,20,20)),20,".") + ;
- Se +Alltrim(Str(det.cantidad,6,2)+"0")+ Se + ;
- ALLTRIM(Str(det.unitario,9,2)) + Se + ;
- ALLTRIM(Str(det.poriva,5,2)) + Se + ;
- "M" + Se + "0.00" + Se + "0" + Se + "T")
- Else
- Insert Into comando;
- VALUES ("B" + Se + det.unidad+" "+det.detalle+ Se +;
- ALLTRIM(Str(det.cantidad,11,2))+ Se + ;
- ALLTRIM(Str(det.unitario,13,2)) + Se +;
- ALLTRIM(Str(det.poriva,5,2)) + Se + ;
- "M" + Se + "0" + Se + "" + Se + "T")
- Endif
- Endif
- Endif
- Select("det")
- Skip
- Enddo
- If This.condicion <> "C"
- If This.Ticket = "S"
- If This.contado = "S"
- Insert Into comando;
- VALUES (Chr(68)+ Se + Substr(formapago.detalle,1,30)+ Se + ;
- ALLTRIM(Str(ThisForm.Saldacontado.txtPago.Value,10,2))+ Se +"T"+ Se+"0")
- Else
- Insert Into comando;
- VALUES ( Chr(68)+ Se + Substr(formapago.detalle,1,30)+ ;
- Se + Alltrim(Str(ThisForm.Saldacontado.txtPago.Value,10,2))+ Se +"T"+ Se+"0")
- Endif
- Else
- If This.contado = "S"
- Insert Into comando;
- VALUES (Chr(68)+ Se + Alltrim(formapago.detalle)+ Se + ;
- ALLTRIM(Str(ThisForm.Saldacontado.txtPago.Value,12,2))+ Se +"T"+ Se+"0")
- Else
- Insert Into comando;
- VALUES(Chr(68)+ Se + Alltrim(formapago.detalle)+ Se + ;
- ALLTRIM(Str(ThisForm.Saldacontado.txtPago.Value,12,2))+ Se +"T"+ Se+"0")
- Endif
- Endif
- Endif
- If This.condicion <> "C"
- Insert Into comando;
- VALUES (Chr(69))
- Else
- Insert Into comando;
- VALUES ( Chr(129) )
- Endif
- &&en esta parte copio el archivo con los comandos a la carpeta desde el cual
- &&el spooler de impresion lee el archivo
- If This.Ticket ="S"
- && si es ticket me fijo a cual impresora debo enviar
- If lImpreFiscal
- mtXt = Alltrim(impfis.dircoticket) + Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(impfis.dirreticket) + Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Else
- mtXt = Alltrim(parametr.dirco)+"715\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(parametr.dirre)+"715\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Endif
- *!* cDirCom = "fpserver715" + "\impred.exe"
- *!* cDirCom = Fullpath(cDirCom)
- *!* && Mato el proceso del spooler y lo vuelvo a cargar
- *!* This.killprocessbyname("impred.exe")
- *!* This.killprocessbyname("wspooler.exe")
- *!* oShell = Createobject("Shell.Application")
- *!* oShell.ShellExecute (cDirCom)
- Else
- &&aca envio a la 320
- If lImpreFiscal
- mtXt = Alltrim(impfis.dircofactura) + Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(impfis.dirrefactura) + Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Else
- mtXt = Alltrim(parametr.dirco)+"320\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(parametr.dirre)+"320\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Endif
- Endif
- Select("comando")
- Goto Top
- &&en caso de que tenga un archivo en la cola de impresion de la impresora
- &&no se deja imprimir
- *Browse
- If File(mtXt)
- Messagebox("ATENCION: Ud. ya tiene un Documento en Cola de Impresión"+Chr(10)+Chr(13)+;
- " AGUARDE a que el mismo sea impreso o elimínelo luego vuelva a intentar")
- Return This.TodoOK
- Else
- Copy To &mtXt Sdf
- If File(maNs)
- Erase &maNs
- Endif
- If File(Alltrim(paramfac.dirpa)+"SPOOLER.LOG")
- Erase (Alltrim(paramfac.dirpa)+"SPOOLER.LOG")
- Endif
- Wait Windows 'Esperando Respuesta del Controlador Fiscal...' Nowait
- fd = -1
- intentos =1
- Do While fd < 0 .And. Lastkey() != 27
- fd = Fopen(maNs, 0)
- This.LeerSpooler("T")
- If intentos = 30
- Messagebox("ATENCION: Verifique que el Controlador Esté Conectado y Encendido. " + Chr(10) + Chr(13)+ ;
- "Verifique además que el Programa Spooler se esté ejecutando " + Chr(10) + Chr(13)+ ;
- "en el equipo al cual se encuentra conectado el Controlador Fiscal")
- This.LeerSpooler("T")
- Endif
- If intentos = 70
- Messagebox("ATENCION: Tiempo de Espera Agotado !!! Presione ESC. para cancelar este Comprobante")
- This.LeerSpooler("T")
- Endif
- intentos = intentos + 1
- *For i=1 To 100
- *Next
- Inkey(1)
- If Lastkey() = 27
- If Substr(comando.comando,17,16) = "Impresor Ocupado"
- Messagebox("ATENCION: No se aconseja cancelar este documento por programa, "+;
- CHR(10)+Chr(13)+"La impresora ya lo ha procesado y saldrá impreso"+;
- CHR(10)+Chr(13)+ "una vez que esta se ponga en linea")
- Endif
- If Messagebox("ATENCION: Realmente desea Cancelar la Emisión de este Documento??",4+256) = 6
- Messagebox(" Se proceder a Cancelar el Documento por Sistema"+;
- CHR(10)+Chr(13)+" Verifique que la impresora también lo haya Cancelado.")
- Keyboard '{ESC}'
- Else
- Keyboard ""
- Endif
- Endif
- Enddo
- If Lastkey() = 27.Or. fd < 0
- If File(mtXt)
- Erase &mtXt
- Endif
- fd = Fopen((Alltrim(paramfac.dirpa)+"SPOOLER.LOG"), 0)
- If fd < 0
- Messagebox("Operación Cancelada: ERROR de comunicaciones con el Controlador.; Probablemente no se este ejecutando Spooler. ")
- Else
- fd =Fclose(fd)
- This.LeerSpooler("T")
- Endif
- Else
- fd = Fclose(fd)
- Select("comando")
- Zap
- Append From &maNs Sdf
- Goto Bottom
- This.numero = Val(Substr(comando.comando,35,8))
- If This.numero <> 0
- SQLExec(goApp.nCon, "select * from puntero where sucursal=?param.sucursal","puntero")
- If This.Ticket = "S"
- If This.MasDeMil
- This.numero = Val('0009'+strzero(This.numero,8))
- Else
- If lImpreFiscal
- This.numero = Val(impfis.PtoVtaTicket+strzero(This.numero,8))
- Else
- If Param.sucursal=0
- If File("c:\0009.txt")
- This.numero = Val(strzero(9,4)+strzero(This.numero,8))
- Else
- This.numero = Val(strzero(puntero.pvta_tic,4)+strzero(This.numero,8))
- Endif
- Else
- If Param.sucursal = 1
- This.numero = Val(strzero(8,4)+strzero(This.numero,8))
- Endif
- Endif
- Endif
- Endif
- Else
- If lImpreFiscal
- This.numero = Val(impfis.PtoVtaFac+strzero(This.numero,8))
- Else
- This.numero = Val(strzero(puntero.pvta_fac,4)+strzero(This.numero,8))
- Endif
- Endif
- This.TodoOK = .T.
- Endif
- Endif
- If File((Alltrim(paramfac.dirpa)+"SPOOLER.LOG"))
- Erase Alltrim(paramfac.dirpa)+"SPOOLER.LOG"
- Endif
- Endif
- *This.killprocessbyname("impred.exe")
- *This.killprocessbyname("wspooler.exe")
- Set Talk &cTalk
- Return This.Todo
- *!* Insert Into comando;
- *!* VALUES ("]" + Se + lin + Se + Chr(127))
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + Chr(127))
- Endif
- If This.Ticket="S"
- Insert Into comando;
- VALUES ( "]" + Se + "9" + Se +Chr(127))
- Insert Into comando;
- VALUES ("]" + Se + "10" + Se +Chr(127))
- If This.condicion = 'C' And Val(sCliente) = 1
- Insert Into comando;
- VALUES ("b" + Se + Substr(sNombre,1,30) + Se + ;
- ndocu + Se + TIPO_IVA + Se + TIPO_DOCU + Se +;
- " S/NOMBRE")
- Else
- Insert Into comando;
- VALUES ("b" + Se + Substr(sNombre,1,30) + Se + ;
- ndocu + Se + TIPO_IVA + Se + TIPO_DOCU + Se +;
- SUBSTR(Alltrim(thisformset.frmCliente.txtDomicilio.Value)+" "+Alltrim(loc.nombre)+;
- " "+Alltrim(loc.provincia),1,40))
- Endif
- Else
- &&"["+sCliente+"] "+
- Insert Into comando;
- VALUES ( "b" + Se + "[" + sCliente + "] " + Substr(sNombre,1,40) + Se +;
- ndocu + Se + TIPO_IVA + Se + TIPO_DOCU + Se + ;
- ALLTRIM(Thisform.txtDom.Value)+" ("+Alltrim(clientes.codpos)+") "+;
- Alltrim(loc.nombre)+" "+Alltrim(loc.provincia))
- Endif
- If This.condicion <> "C"
- Insert Into comando;
- VALUES (Chr(64)+Se+TIPO_FACTURA+Se+"T")
- Else
- &&Definir tipo y num de factura afectado por nota de credito
- Insert Into comando;
- VALUES (Chr(147) + Se + "1" + Se + cre.tipoaf + " " + cre.numeroaf)
- Insert Into comando;
- VALUES (Chr(128)+Se+TIPO_FACTURA+Se+"T")
- Endif
- &&el cursor "DET" posee los items a facturar
- Select("det")
- Go Top
- Do While ! Eof()
- *!* Create Cursor det;
- *!* (cantidad n(12,4), unidad c(8), detalle c(40), total n(12,2), idArticulo int,;
- *!* unitario n(12,2), costo n(12,2), montoiva n(12,2), montodgr n(12,2), montomuni N(12,2),;
- *!* poriva n(12,2), tipoiva c(2))
- If det.unitario != 0
- If This.clase = "A"
- If This.Ticket = "S"
- Insert Into comando;
- VALUES ("A" + Se + det.unidad +" "+Substr(det.detalle,1,19)+ Se + "0")
- Insert Into comando;
- VALUES ("B" + Se + Padr(Alltrim(Substr(det.detalle,20,20)),20,".") + Se +;
- ALLTRIM(Str(det.cantidad,6,2)+"0")+ Se +;
- ALLTRIM(Str(det.unitario,9,2)) + Se + ;
- ALLTRIM(Str(det.poriva,5,2)) + Se +;
- "M" + Se + "0.00" + Se + "0" + Se + "T")
- Else
- Insert Into comando;
- VALUES ("B" + Se + det.unidad +" "+det.detalle+ Se + ;
- ALLTRIM(Str(det.cantidad,11,2))+ Se + ;
- Alltrim(Str(det.unitario,13,2)) + ;
- Se +Alltrim(Str(det.poriva,5,2)) + Se + ;
- "M" + Se + "0" + Se + "" + Se + "T")
- Endif
- Else
- If This.Ticket = "S"
- Insert Into comando;
- VALUES ( "A" + Se + det.unidad +" "+Substr(det.detalle,1,19)+ Se + "0")
- Insert Into comando;
- VALUES ("B" + Se + Padr(Alltrim(Substr(det.detalle,20,20)),20,".") + ;
- Se +Alltrim(Str(det.cantidad,6,2)+"0")+ Se + ;
- ALLTRIM(Str(det.unitario,9,2)) + Se + ;
- ALLTRIM(Str(det.poriva,5,2)) + Se + ;
- "M" + Se + "0.00" + Se + "0" + Se + "T")
- Else
- Insert Into comando;
- VALUES ("B" + Se + det.unidad+" "+det.detalle+ Se +;
- ALLTRIM(Str(det.cantidad,11,2))+ Se + ;
- ALLTRIM(Str(det.unitario,13,2)) + Se +;
- ALLTRIM(Str(det.poriva,5,2)) + Se + ;
- "M" + Se + "0" + Se + "" + Se + "T")
- Endif
- Endif
- Endif
- Select("det")
- Skip
- Enddo
- If This.condicion <> "C"
- If This.Ticket = "S"
- If This.contado = "S"
- Insert Into comando;
- VALUES (Chr(68)+ Se + Substr(formapago.detalle,1,30)+ Se + ;
- ALLTRIM(Str(ThisForm.Saldacontado.txtPago.Value,10,2))+ Se +"T"+ Se+"0")
- Else
- Insert Into comando;
- VALUES ( Chr(68)+ Se + Substr(formapago.detalle,1,30)+ ;
- Se + Alltrim(Str(ThisForm.Saldacontado.txtPago.Value,10,2))+ Se +"T"+ Se+"0")
- Endif
- Else
- If This.contado = "S"
- Insert Into comando;
- VALUES (Chr(68)+ Se + Alltrim(formapago.detalle)+ Se + ;
- ALLTRIM(Str(ThisForm.Saldacontado.txtPago.Value,12,2))+ Se +"T"+ Se+"0")
- Else
- Insert Into comando;
- VALUES(Chr(68)+ Se + Alltrim(formapago.detalle)+ Se + ;
- ALLTRIM(Str(ThisForm.Saldacontado.txtPago.Value,12,2))+ Se +"T"+ Se+"0")
- Endif
- Endif
- Endif
- If This.condicion <> "C"
- Insert Into comando;
- VALUES (Chr(69))
- Else
- Insert Into comando;
- VALUES ( Chr(129) )
- Endif
- &&en esta parte copio el archivo con los comandos a la carpeta desde el cual
- &&el spooler de impresion lee el archivo
- If This.Ticket ="S"
- && si es ticket me fijo a cual impresora debo enviar
- If lImpreFiscal
- mtXt = Alltrim(impfis.dircoticket) + Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(impfis.dirreticket) + Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Else
- mtXt = Alltrim(parametr.dirco)+"715\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(parametr.dirre)+"715\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Endif
- *!* cDirCom = "fpserver715" + "\impred.exe"
- *!* cDirCom = Fullpath(cDirCom)
- *!* && Mato el proceso del spooler y lo vuelvo a cargar
- *!* This.killprocessbyname("impred.exe")
- *!* This.killprocessbyname("wspooler.exe")
- *!* oShell = Createobject("Shell.Application")
- *!* oShell.ShellExecute (cDirCom)
- Else
- &&aca envio a la 320
- If lImpreFiscal
- mtXt = Alltrim(impfis.dircofactura) + Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(impfis.dirrefactura) + Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Else
- mtXt = Alltrim(parametr.dirco)+"320\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(parametr.dirre)+"320\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Endif
- Endif
- Select("comando")
- Goto Top
- &&en caso de que tenga un archivo en la cola de impresion de la impresora
- &&no se deja imprimir
- *Browse
- If File(mtXt)
- Messagebox("ATENCION: Ud. ya tiene un Documento en Cola de Impresión"+Chr(10)+Chr(13)+;
- " AGUARDE a que el mismo sea impreso o elimínelo luego vuelva a intentar")
- Return This.TodoOK
- Else
- Copy To &mtXt Sdf
- If File(maNs)
- Erase &maNs
- Endif
- If File(Alltrim(paramfac.dirpa)+"SPOOLER.LOG")
- Erase (Alltrim(paramfac.dirpa)+"SPOOLER.LOG")
- Endif
- Wait Windows 'Esperando Respuesta del Controlador Fiscal...' Nowait
- fd = -1
- intentos =1
- Do While fd < 0 .And. Lastkey() != 27
- fd = Fopen(maNs, 0)
- This.LeerSpooler("T")
- If intentos = 30
- Messagebox("ATENCION: Verifique que el Controlador Esté Conectado y Encendido. " + Chr(10) + Chr(13)+ ;
- "Verifique además que el Programa Spooler se esté ejecutando " + Chr(10) + Chr(13)+ ;
- "en el equipo al cual se encuentra conectado el Controlador Fiscal")
- This.LeerSpooler("T")
- Endif
- If intentos = 70
- Messagebox("ATENCION: Tiempo de Espera Agotado !!! Presione ESC. para cancelar este Comprobante")
- This.LeerSpooler("T")
- Endif
- intentos = intentos + 1
- *For i=1 To 100
- *Next
- Inkey(1)
- If Lastkey() = 27
- If Substr(comando.comando,17,16) = "Impresor Ocupado"
- Messagebox("ATENCION: No se aconseja cancelar este documento por programa, "+;
- CHR(10)+Chr(13)+"La impresora ya lo ha procesado y saldrá impreso"+;
- CHR(10)+Chr(13)+ "una vez que esta se ponga en linea")
- Endif
- If Messagebox("ATENCION: Realmente desea Cancelar la Emisión de este Documento??",4+256) = 6
- Messagebox(" Se proceder a Cancelar el Documento por Sistema"+;
- CHR(10)+Chr(13)+" Verifique que la impresora también lo haya Cancelado.")
- Keyboard '{ESC}'
- Else
- Keyboard ""
- Endif
- Endif
- Enddo
- If Lastkey() = 27.Or. fd < 0
- If File(mtXt)
- Erase &mtXt
- Endif
- fd = Fopen((Alltrim(paramfac.dirpa)+"SPOOLER.LOG"), 0)
- If fd < 0
- Messagebox("Operación Cancelada: ERROR de comunicaciones con el Controlador.; Probablemente no se este ejecutando Spooler. ")
- Else
- fd =Fclose(fd)
- This.LeerSpooler("T")
- Endif
- Else
- fd = Fclose(fd)
- Select("comando")
- Zap
- Append From &maNs Sdf
- Goto Bottom
- This.numero = Val(Substr(comando.comando,35,8))
- If This.numero <> 0
- SQLExec(goApp.nCon, "select * from puntero where sucursal=?param.sucursal","puntero")
- If This.Ticket = "S"
- If This.MasDeMil
- This.numero = Val('0009'+strzero(This.numero,8))
- Else
- If lImpreFiscal
- This.numero = Val(impfis.PtoVtaTicket+strzero(This.numero,8))
- Else
- If Param.sucursal=0
- If File("c:\0009.txt")
- This.numero = Val(strzero(9,4)+strzero(This.numero,8))
- Else
- This.numero = Val(strzero(puntero.pvta_tic,4)+strzero(This.numero,8))
- Endif
- Else
- If Param.sucursal = 1
- This.numero = Val(strzero(8,4)+strzero(This.numero,8))
- Endif
- Endif
- Endif
- Endif
- Else
- If lImpreFiscal
- This.numero = Val(impfis.PtoVtaFac+strzero(This.numero,8))
- Else
- This.numero = Val(strzero(puntero.pvta_fac,4)+strzero(This.numero,8))
- Endif
- Endif
- This.TodoOK = .T.
- Endif
- Endif
- If File((Alltrim(paramfac.dirpa)+"SPOOLER.LOG"))
- Erase Alltrim(paramfac.dirpa)+"SPOOLER.LOG"
- Endif
- Endif
- *This.killprocessbyname("impred.exe")
- *This.killprocessbyname("wspooler.exe")
- Set Talk &cTalk
- Return This.Todo
- *!* VALUES ("]" + Se + lin + Se + Chr(127))
- Insert Into comando;
- VALUES ("]" + Se + lin + Se + Chr(127))
- Endif
- If This.Ticket="S"
- Insert Into comando;
- VALUES ( "]" + Se + "9" + Se +Chr(127))
- Insert Into comando;
- VALUES ("]" + Se + "10" + Se +Chr(127))
- If This.condicion = 'C' And Val(sCliente) = 1
- Insert Into comando;
- VALUES ("b" + Se + Substr(sNombre,1,30) + Se + ;
- ndocu + Se + TIPO_IVA + Se + TIPO_DOCU + Se +;
- " S/NOMBRE")
- Else
- Insert Into comando;
- VALUES ("b" + Se + Substr(sNombre,1,30) + Se + ;
- ndocu + Se + TIPO_IVA + Se + TIPO_DOCU + Se +;
- SUBSTR(Alltrim(thisformset.frmCliente.txtDomicilio.Value)+" "+Alltrim(loc.nombre)+;
- " "+Alltrim(loc.provincia),1,40))
- Endif
- Else
- &&"["+sCliente+"] "+
- Insert Into comando;
- VALUES ( "b" + Se + "[" + sCliente + "] " + Substr(sNombre,1,40) + Se +;
- ndocu + Se + TIPO_IVA + Se + TIPO_DOCU + Se + ;
- ALLTRIM(Thisform.txtDom.Value)+" ("+Alltrim(clientes.codpos)+") "+;
- Alltrim(loc.nombre)+" "+Alltrim(loc.provincia))
- Endif
- If This.condicion <> "C"
- Insert Into comando;
- VALUES (Chr(64)+Se+TIPO_FACTURA+Se+"T")
- Else
- &&Definir tipo y num de factura afectado por nota de credito
- Insert Into comando;
- VALUES (Chr(147) + Se + "1" + Se + cre.tipoaf + " " + cre.numeroaf)
- Insert Into comando;
- VALUES (Chr(128)+Se+TIPO_FACTURA+Se+"T")
- Endif
- &&el cursor "DET" posee los items a facturar
- Select("det")
- Go Top
- Do While ! Eof()
- *!* Create Cursor det;
- *!* (cantidad n(12,4), unidad c(8), detalle c(40), total n(12,2), idArticulo int,;
- *!* unitario n(12,2), costo n(12,2), montoiva n(12,2), montodgr n(12,2), montomuni N(12,2),;
- *!* poriva n(12,2), tipoiva c(2))
- If det.unitario != 0
- If This.clase = "A"
- If This.Ticket = "S"
- Insert Into comando;
- VALUES ("A" + Se + det.unidad +" "+Substr(det.detalle,1,19)+ Se + "0")
- Insert Into comando;
- VALUES ("B" + Se + Padr(Alltrim(Substr(det.detalle,20,20)),20,".") + Se +;
- ALLTRIM(Str(det.cantidad,6,2)+"0")+ Se +;
- ALLTRIM(Str(det.unitario,9,2)) + Se + ;
- ALLTRIM(Str(det.poriva,5,2)) + Se +;
- "M" + Se + "0.00" + Se + "0" + Se + "T")
- Else
- Insert Into comando;
- VALUES ("B" + Se + det.unidad +" "+det.detalle+ Se + ;
- ALLTRIM(Str(det.cantidad,11,2))+ Se + ;
- Alltrim(Str(det.unitario,13,2)) + ;
- Se +Alltrim(Str(det.poriva,5,2)) + Se + ;
- "M" + Se + "0" + Se + "" + Se + "T")
- Endif
- Else
- If This.Ticket = "S"
- Insert Into comando;
- VALUES ( "A" + Se + det.unidad +" "+Substr(det.detalle,1,19)+ Se + "0")
- Insert Into comando;
- VALUES ("B" + Se + Padr(Alltrim(Substr(det.detalle,20,20)),20,".") + ;
- Se +Alltrim(Str(det.cantidad,6,2)+"0")+ Se + ;
- ALLTRIM(Str(det.unitario,9,2)) + Se + ;
- ALLTRIM(Str(det.poriva,5,2)) + Se + ;
- "M" + Se + "0.00" + Se + "0" + Se + "T")
- Else
- Insert Into comando;
- VALUES ("B" + Se + det.unidad+" "+det.detalle+ Se +;
- ALLTRIM(Str(det.cantidad,11,2))+ Se + ;
- ALLTRIM(Str(det.unitario,13,2)) + Se +;
- ALLTRIM(Str(det.poriva,5,2)) + Se + ;
- "M" + Se + "0" + Se + "" + Se + "T")
- Endif
- Endif
- Endif
- Select("det")
- Skip
- Enddo
- If This.condicion <> "C"
- If This.Ticket = "S"
- If This.contado = "S"
- Insert Into comando;
- VALUES (Chr(68)+ Se + Substr(formapago.detalle,1,30)+ Se + ;
- ALLTRIM(Str(ThisForm.Saldacontado.txtPago.Value,10,2))+ Se +"T"+ Se+"0")
- Else
- Insert Into comando;
- VALUES ( Chr(68)+ Se + Substr(formapago.detalle,1,30)+ ;
- Se + Alltrim(Str(ThisForm.Saldacontado.txtPago.Value,10,2))+ Se +"T"+ Se+"0")
- Endif
- Else
- If This.contado = "S"
- Insert Into comando;
- VALUES (Chr(68)+ Se + Alltrim(formapago.detalle)+ Se + ;
- ALLTRIM(Str(ThisForm.Saldacontado.txtPago.Value,12,2))+ Se +"T"+ Se+"0")
- Else
- Insert Into comando;
- VALUES(Chr(68)+ Se + Alltrim(formapago.detalle)+ Se + ;
- ALLTRIM(Str(ThisForm.Saldacontado.txtPago.Value,12,2))+ Se +"T"+ Se+"0")
- Endif
- Endif
- Endif
- If This.condicion <> "C"
- Insert Into comando;
- VALUES (Chr(69))
- Else
- Insert Into comando;
- VALUES ( Chr(129) )
- Endif
- &&en esta parte copio el archivo con los comandos a la carpeta desde el cual
- &&el spooler de impresion lee el archivo
- If This.Ticket ="S"
- && si es ticket me fijo a cual impresora debo enviar
- If lImpreFiscal
- mtXt = Alltrim(impfis.dircoticket) + Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(impfis.dirreticket) + Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Else
- mtXt = Alltrim(parametr.dirco)+"715\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(parametr.dirre)+"715\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Endif
- *!* cDirCom = "fpserver715" + "\impred.exe"
- *!* cDirCom = Fullpath(cDirCom)
- *!* && Mato el proceso del spooler y lo vuelvo a cargar
- *!* This.killprocessbyname("impred.exe")
- *!* This.killprocessbyname("wspooler.exe")
- *!* oShell = Createobject("Shell.Application")
- *!* oShell.ShellExecute (cDirCom)
- Else
- &&aca envio a la 320
- If lImpreFiscal
- mtXt = Alltrim(impfis.dircofactura) + Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(impfis.dirrefactura) + Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Else
- mtXt = Alltrim(parametr.dirco)+"320\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(parametr.dirre)+"320\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Endif
- Endif
- Select("comando")
- Goto Top
- &&en caso de que tenga un archivo en la cola de impresion de la impresora
- &&no se deja imprimir
- *Browse
- If File(mtXt)
- Messagebox("ATENCION: Ud. ya tiene un Documento en Cola de Impresión"+Chr(10)+Chr(13)+;
- " AGUARDE a que el mismo sea impreso o elimínelo luego vuelva a intentar")
- Return This.TodoOK
- Else
- Copy To &mtXt Sdf
- If File(maNs)
- Erase &maNs
- Endif
- If File(Alltrim(paramfac.dirpa)+"SPOOLER.LOG")
- Erase (Alltrim(paramfac.dirpa)+"SPOOLER.LOG")
- Endif
- Wait Windows 'Esperando Respuesta del Controlador Fiscal...' Nowait
- fd = -1
- intentos =1
- Do While fd < 0 .And. Lastkey() != 27
- fd = Fopen(maNs, 0)
- This.LeerSpooler("T")
- If intentos = 30
- Messagebox("ATENCION: Verifique que el Controlador Esté Conectado y Encendido. " + Chr(10) + Chr(13)+ ;
- "Verifique además que el Programa Spooler se esté ejecutando " + Chr(10) + Chr(13)+ ;
- "en el equipo al cual se encuentra conectado el Controlador Fiscal")
- This.LeerSpooler("T")
- Endif
- If intentos = 70
- Messagebox("ATENCION: Tiempo de Espera Agotado !!! Presione ESC. para cancelar este Comprobante")
- This.LeerSpooler("T")
- Endif
- intentos = intentos + 1
- *For i=1 To 100
- *Next
- Inkey(1)
- If Lastkey() = 27
- If Substr(comando.comando,17,16) = "Impresor Ocupado"
- Messagebox("ATENCION: No se aconseja cancelar este documento por programa, "+;
- CHR(10)+Chr(13)+"La impresora ya lo ha procesado y saldrá impreso"+;
- CHR(10)+Chr(13)+ "una vez que esta se ponga en linea")
- Endif
- If Messagebox("ATENCION: Realmente desea Cancelar la Emisión de este Documento??",4+256) = 6
- Messagebox(" Se proceder a Cancelar el Documento por Sistema"+;
- CHR(10)+Chr(13)+" Verifique que la impresora también lo haya Cancelado.")
- Keyboard '{ESC}'
- Else
- Keyboard ""
- Endif
- Endif
- Enddo
- If Lastkey() = 27.Or. fd < 0
- If File(mtXt)
- Erase &mtXt
- Endif
- fd = Fopen((Alltrim(paramfac.dirpa)+"SPOOLER.LOG"), 0)
- If fd < 0
- Messagebox("Operación Cancelada: ERROR de comunicaciones con el Controlador.; Probablemente no se este ejecutando Spooler. ")
- Else
- fd =Fclose(fd)
- This.LeerSpooler("T")
- Endif
- Else
- fd = Fclose(fd)
- Select("comando")
- Zap
- Append From &maNs Sdf
- Goto Bottom
- This.numero = Val(Substr(comando.comando,35,8))
- If This.numero <> 0
- SQLExec(goApp.nCon, "select * from puntero where sucursal=?param.sucursal","puntero")
- If This.Ticket = "S"
- If This.MasDeMil
- This.numero = Val('0009'+strzero(This.numero,8))
- Else
- If lImpreFiscal
- This.numero = Val(impfis.PtoVtaTicket+strzero(This.numero,8))
- Else
- If Param.sucursal=0
- If File("c:\0009.txt")
- This.numero = Val(strzero(9,4)+strzero(This.numero,8))
- Else
- This.numero = Val(strzero(puntero.pvta_tic,4)+strzero(This.numero,8))
- Endif
- Else
- If Param.sucursal = 1
- This.numero = Val(strzero(8,4)+strzero(This.numero,8))
- Endif
- Endif
- Endif
- Endif
- Else
- If lImpreFiscal
- This.numero = Val(impfis.PtoVtaFac+strzero(This.numero,8))
- Else
- This.numero = Val(strzero(puntero.pvta_fac,4)+strzero(This.numero,8))
- Endif
- Endif
- This.TodoOK = .T.
- Endif
- Endif
- If File((Alltrim(paramfac.dirpa)+"SPOOLER.LOG"))
- Erase Alltrim(paramfac.dirpa)+"SPOOLER.LOG"
- Endif
- Endif
- *This.killprocessbyname("impred.exe")
- *This.killprocessbyname("wspooler.exe")
- Set Talk &cTalk
- Return This.Todo
- *!* Create Cursor det;
- *!* (cantidad n(12,4), unidad c(8), detalle c(40), total n(12,2), idArticulo int,;
- *!* unitario n(12,2), costo n(12,2), montoiva n(12,2), montodgr n(12,2), montomuni N(12,2),;
- *!* poriva n(12,2), tipoiva c(2))
- If det.unitario != 0
- If This.clase = "A"
- If This.Ticket = "S"
- Insert Into comando;
- VALUES ("A" + Se + det.unidad +" "+Substr(det.detalle,1,19)+ Se + "0")
- Insert Into comando;
- VALUES ("B" + Se + Padr(Alltrim(Substr(det.detalle,20,20)),20,".") + Se +;
- ALLTRIM(Str(det.cantidad,6,2)+"0")+ Se +;
- ALLTRIM(Str(det.unitario,9,2)) + Se + ;
- ALLTRIM(Str(det.poriva,5,2)) + Se +;
- "M" + Se + "0.00" + Se + "0" + Se + "T")
- Else
- Insert Into comando;
- VALUES ("B" + Se + det.unidad +" "+det.detalle+ Se + ;
- ALLTRIM(Str(det.cantidad,11,2))+ Se + ;
- Alltrim(Str(det.unitario,13,2)) + ;
- Se +Alltrim(Str(det.poriva,5,2)) + Se + ;
- "M" + Se + "0" + Se + "" + Se + "T")
- Endif
- Else
- If This.Ticket = "S"
- Insert Into comando;
- VALUES ( "A" + Se + det.unidad +" "+Substr(det.detalle,1,19)+ Se + "0")
- Insert Into comando;
- VALUES ("B" + Se + Padr(Alltrim(Substr(det.detalle,20,20)),20,".") + ;
- Se +Alltrim(Str(det.cantidad,6,2)+"0")+ Se + ;
- ALLTRIM(Str(det.unitario,9,2)) + Se + ;
- ALLTRIM(Str(det.poriva,5,2)) + Se + ;
- "M" + Se + "0.00" + Se + "0" + Se + "T")
- Else
- Insert Into comando;
- VALUES ("B" + Se + det.unidad+" "+det.detalle+ Se +;
- ALLTRIM(Str(det.cantidad,11,2))+ Se + ;
- ALLTRIM(Str(det.unitario,13,2)) + Se +;
- ALLTRIM(Str(det.poriva,5,2)) + Se + ;
- "M" + Se + "0" + Se + "" + Se + "T")
- Endif
- Endif
- Endif
- Select("det")
- Skip
- Enddo
- If This.condicion <> "C"
- If This.Ticket = "S"
- If This.contado = "S"
- Insert Into comando;
- VALUES (Chr(68)+ Se + Substr(formapago.detalle,1,30)+ Se + ;
- ALLTRIM(Str(ThisForm.Saldacontado.txtPago.Value,10,2))+ Se +"T"+ Se+"0")
- Else
- Insert Into comando;
- VALUES ( Chr(68)+ Se + Substr(formapago.detalle,1,30)+ ;
- Se + Alltrim(Str(ThisForm.Saldacontado.txtPago.Value,10,2))+ Se +"T"+ Se+"0")
- Endif
- Else
- If This.contado = "S"
- Insert Into comando;
- VALUES (Chr(68)+ Se + Alltrim(formapago.detalle)+ Se + ;
- ALLTRIM(Str(ThisForm.Saldacontado.txtPago.Value,12,2))+ Se +"T"+ Se+"0")
- Else
- Insert Into comando;
- VALUES(Chr(68)+ Se + Alltrim(formapago.detalle)+ Se + ;
- ALLTRIM(Str(ThisForm.Saldacontado.txtPago.Value,12,2))+ Se +"T"+ Se+"0")
- Endif
- Endif
- Endif
- If This.condicion <> "C"
- Insert Into comando;
- VALUES (Chr(69))
- Else
- Insert Into comando;
- VALUES ( Chr(129) )
- Endif
- &&en esta parte copio el archivo con los comandos a la carpeta desde el cual
- &&el spooler de impresion lee el archivo
- If This.Ticket ="S"
- && si es ticket me fijo a cual impresora debo enviar
- If lImpreFiscal
- mtXt = Alltrim(impfis.dircoticket) + Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(impfis.dirreticket) + Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Else
- mtXt = Alltrim(parametr.dirco)+"715\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(parametr.dirre)+"715\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Endif
- *!* cDirCom = "fpserver715" + "\impred.exe"
- *!* cDirCom = Fullpath(cDirCom)
- *!* && Mato el proceso del spooler y lo vuelvo a cargar
- *!* This.killprocessbyname("impred.exe")
- *!* This.killprocessbyname("wspooler.exe")
- *!* oShell = Createobject("Shell.Application")
- *!* oShell.ShellExecute (cDirCom)
- Else
- &&aca envio a la 320
- If lImpreFiscal
- mtXt = Alltrim(impfis.dircofactura) + Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(impfis.dirrefactura) + Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Else
- mtXt = Alltrim(parametr.dirco)+"320\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(parametr.dirre)+"320\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Endif
- Endif
- Select("comando")
- Goto Top
- &&en caso de que tenga un archivo en la cola de impresion de la impresora
- &&no se deja imprimir
- *Browse
- If File(mtXt)
- Messagebox("ATENCION: Ud. ya tiene un Documento en Cola de Impresión"+Chr(10)+Chr(13)+;
- " AGUARDE a que el mismo sea impreso o elimínelo luego vuelva a intentar")
- Return This.TodoOK
- Else
- Copy To &mtXt Sdf
- If File(maNs)
- Erase &maNs
- Endif
- If File(Alltrim(paramfac.dirpa)+"SPOOLER.LOG")
- Erase (Alltrim(paramfac.dirpa)+"SPOOLER.LOG")
- Endif
- Wait Windows 'Esperando Respuesta del Controlador Fiscal...' Nowait
- fd = -1
- intentos =1
- Do While fd < 0 .And. Lastkey() != 27
- fd = Fopen(maNs, 0)
- This.LeerSpooler("T")
- If intentos = 30
- Messagebox("ATENCION: Verifique que el Controlador Esté Conectado y Encendido. " + Chr(10) + Chr(13)+ ;
- "Verifique además que el Programa Spooler se esté ejecutando " + Chr(10) + Chr(13)+ ;
- "en el equipo al cual se encuentra conectado el Controlador Fiscal")
- This.LeerSpooler("T")
- Endif
- If intentos = 70
- Messagebox("ATENCION: Tiempo de Espera Agotado !!! Presione ESC. para cancelar este Comprobante")
- This.LeerSpooler("T")
- Endif
- intentos = intentos + 1
- *For i=1 To 100
- *Next
- Inkey(1)
- If Lastkey() = 27
- If Substr(comando.comando,17,16) = "Impresor Ocupado"
- Messagebox("ATENCION: No se aconseja cancelar este documento por programa, "+;
- CHR(10)+Chr(13)+"La impresora ya lo ha procesado y saldrá impreso"+;
- CHR(10)+Chr(13)+ "una vez que esta se ponga en linea")
- Endif
- If Messagebox("ATENCION: Realmente desea Cancelar la Emisión de este Documento??",4+256) = 6
- Messagebox(" Se proceder a Cancelar el Documento por Sistema"+;
- CHR(10)+Chr(13)+" Verifique que la impresora también lo haya Cancelado.")
- Keyboard '{ESC}'
- Else
- Keyboard ""
- Endif
- Endif
- Enddo
- If Lastkey() = 27.Or. fd < 0
- If File(mtXt)
- Erase &mtXt
- Endif
- fd = Fopen((Alltrim(paramfac.dirpa)+"SPOOLER.LOG"), 0)
- If fd < 0
- Messagebox("Operación Cancelada: ERROR de comunicaciones con el Controlador.; Probablemente no se este ejecutando Spooler. ")
- Else
- fd =Fclose(fd)
- This.LeerSpooler("T")
- Endif
- Else
- fd = Fclose(fd)
- Select("comando")
- Zap
- Append From &maNs Sdf
- Goto Bottom
- This.numero = Val(Substr(comando.comando,35,8))
- If This.numero <> 0
- SQLExec(goApp.nCon, "select * from puntero where sucursal=?param.sucursal","puntero")
- If This.Ticket = "S"
- If This.MasDeMil
- This.numero = Val('0009'+strzero(This.numero,8))
- Else
- If lImpreFiscal
- This.numero = Val(impfis.PtoVtaTicket+strzero(This.numero,8))
- Else
- If Param.sucursal=0
- If File("c:\0009.txt")
- This.numero = Val(strzero(9,4)+strzero(This.numero,8))
- Else
- This.numero = Val(strzero(puntero.pvta_tic,4)+strzero(This.numero,8))
- Endif
- Else
- If Param.sucursal = 1
- This.numero = Val(strzero(8,4)+strzero(This.numero,8))
- Endif
- Endif
- Endif
- Endif
- Else
- If lImpreFiscal
- This.numero = Val(impfis.PtoVtaFac+strzero(This.numero,8))
- Else
- This.numero = Val(strzero(puntero.pvta_fac,4)+strzero(This.numero,8))
- Endif
- Endif
- This.TodoOK = .T.
- Endif
- Endif
- If File((Alltrim(paramfac.dirpa)+"SPOOLER.LOG"))
- Erase Alltrim(paramfac.dirpa)+"SPOOLER.LOG"
- Endif
- Endif
- *This.killprocessbyname("impred.exe")
- *This.killprocessbyname("wspooler.exe")
- Set Talk &cTalk
- Return This.Todo
- *!* (cantidad n(12,4), unidad c(8), detalle c(40), total n(12,2), idArticulo int,;
- *!* unitario n(12,2), costo n(12,2), montoiva n(12,2), montodgr n(12,2), montomuni N(12,2),;
- *!* poriva n(12,2), tipoiva c(2))
- If det.unitario != 0
- If This.clase = "A"
- If This.Ticket = "S"
- Insert Into comando;
- VALUES ("A" + Se + det.unidad +" "+Substr(det.detalle,1,19)+ Se + "0")
- Insert Into comando;
- VALUES ("B" + Se + Padr(Alltrim(Substr(det.detalle,20,20)),20,".") + Se +;
- ALLTRIM(Str(det.cantidad,6,2)+"0")+ Se +;
- ALLTRIM(Str(det.unitario,9,2)) + Se + ;
- ALLTRIM(Str(det.poriva,5,2)) + Se +;
- "M" + Se + "0.00" + Se + "0" + Se + "T")
- Else
- Insert Into comando;
- VALUES ("B" + Se + det.unidad +" "+det.detalle+ Se + ;
- ALLTRIM(Str(det.cantidad,11,2))+ Se + ;
- Alltrim(Str(det.unitario,13,2)) + ;
- Se +Alltrim(Str(det.poriva,5,2)) + Se + ;
- "M" + Se + "0" + Se + "" + Se + "T")
- Endif
- Else
- If This.Ticket = "S"
- Insert Into comando;
- VALUES ( "A" + Se + det.unidad +" "+Substr(det.detalle,1,19)+ Se + "0")
- Insert Into comando;
- VALUES ("B" + Se + Padr(Alltrim(Substr(det.detalle,20,20)),20,".") + ;
- Se +Alltrim(Str(det.cantidad,6,2)+"0")+ Se + ;
- ALLTRIM(Str(det.unitario,9,2)) + Se + ;
- ALLTRIM(Str(det.poriva,5,2)) + Se + ;
- "M" + Se + "0.00" + Se + "0" + Se + "T")
- Else
- Insert Into comando;
- VALUES ("B" + Se + det.unidad+" "+det.detalle+ Se +;
- ALLTRIM(Str(det.cantidad,11,2))+ Se + ;
- ALLTRIM(Str(det.unitario,13,2)) + Se +;
- ALLTRIM(Str(det.poriva,5,2)) + Se + ;
- "M" + Se + "0" + Se + "" + Se + "T")
- Endif
- Endif
- Endif
- Select("det")
- Skip
- Enddo
- If This.condicion <> "C"
- If This.Ticket = "S"
- If This.contado = "S"
- Insert Into comando;
- VALUES (Chr(68)+ Se + Substr(formapago.detalle,1,30)+ Se + ;
- ALLTRIM(Str(ThisForm.Saldacontado.txtPago.Value,10,2))+ Se +"T"+ Se+"0")
- Else
- Insert Into comando;
- VALUES ( Chr(68)+ Se + Substr(formapago.detalle,1,30)+ ;
- Se + Alltrim(Str(ThisForm.Saldacontado.txtPago.Value,10,2))+ Se +"T"+ Se+"0")
- Endif
- Else
- If This.contado = "S"
- Insert Into comando;
- VALUES (Chr(68)+ Se + Alltrim(formapago.detalle)+ Se + ;
- ALLTRIM(Str(ThisForm.Saldacontado.txtPago.Value,12,2))+ Se +"T"+ Se+"0")
- Else
- Insert Into comando;
- VALUES(Chr(68)+ Se + Alltrim(formapago.detalle)+ Se + ;
- ALLTRIM(Str(ThisForm.Saldacontado.txtPago.Value,12,2))+ Se +"T"+ Se+"0")
- Endif
- Endif
- Endif
- If This.condicion <> "C"
- Insert Into comando;
- VALUES (Chr(69))
- Else
- Insert Into comando;
- VALUES ( Chr(129) )
- Endif
- &&en esta parte copio el archivo con los comandos a la carpeta desde el cual
- &&el spooler de impresion lee el archivo
- If This.Ticket ="S"
- && si es ticket me fijo a cual impresora debo enviar
- If lImpreFiscal
- mtXt = Alltrim(impfis.dircoticket) + Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(impfis.dirreticket) + Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Else
- mtXt = Alltrim(parametr.dirco)+"715\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(parametr.dirre)+"715\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Endif
- *!* cDirCom = "fpserver715" + "\impred.exe"
- *!* cDirCom = Fullpath(cDirCom)
- *!* && Mato el proceso del spooler y lo vuelvo a cargar
- *!* This.killprocessbyname("impred.exe")
- *!* This.killprocessbyname("wspooler.exe")
- *!* oShell = Createobject("Shell.Application")
- *!* oShell.ShellExecute (cDirCom)
- Else
- &&aca envio a la 320
- If lImpreFiscal
- mtXt = Alltrim(impfis.dircofactura) + Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(impfis.dirrefactura) + Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Else
- mtXt = Alltrim(parametr.dirco)+"320\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(parametr.dirre)+"320\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Endif
- Endif
- Select("comando")
- Goto Top
- &&en caso de que tenga un archivo en la cola de impresion de la impresora
- &&no se deja imprimir
- *Browse
- If File(mtXt)
- Messagebox("ATENCION: Ud. ya tiene un Documento en Cola de Impresión"+Chr(10)+Chr(13)+;
- " AGUARDE a que el mismo sea impreso o elimínelo luego vuelva a intentar")
- Return This.TodoOK
- Else
- Copy To &mtXt Sdf
- If File(maNs)
- Erase &maNs
- Endif
- If File(Alltrim(paramfac.dirpa)+"SPOOLER.LOG")
- Erase (Alltrim(paramfac.dirpa)+"SPOOLER.LOG")
- Endif
- Wait Windows 'Esperando Respuesta del Controlador Fiscal...' Nowait
- fd = -1
- intentos =1
- Do While fd < 0 .And. Lastkey() != 27
- fd = Fopen(maNs, 0)
- This.LeerSpooler("T")
- If intentos = 30
- Messagebox("ATENCION: Verifique que el Controlador Esté Conectado y Encendido. " + Chr(10) + Chr(13)+ ;
- "Verifique además que el Programa Spooler se esté ejecutando " + Chr(10) + Chr(13)+ ;
- "en el equipo al cual se encuentra conectado el Controlador Fiscal")
- This.LeerSpooler("T")
- Endif
- If intentos = 70
- Messagebox("ATENCION: Tiempo de Espera Agotado !!! Presione ESC. para cancelar este Comprobante")
- This.LeerSpooler("T")
- Endif
- intentos = intentos + 1
- *For i=1 To 100
- *Next
- Inkey(1)
- If Lastkey() = 27
- If Substr(comando.comando,17,16) = "Impresor Ocupado"
- Messagebox("ATENCION: No se aconseja cancelar este documento por programa, "+;
- CHR(10)+Chr(13)+"La impresora ya lo ha procesado y saldrá impreso"+;
- CHR(10)+Chr(13)+ "una vez que esta se ponga en linea")
- Endif
- If Messagebox("ATENCION: Realmente desea Cancelar la Emisión de este Documento??",4+256) = 6
- Messagebox(" Se proceder a Cancelar el Documento por Sistema"+;
- CHR(10)+Chr(13)+" Verifique que la impresora también lo haya Cancelado.")
- Keyboard '{ESC}'
- Else
- Keyboard ""
- Endif
- Endif
- Enddo
- If Lastkey() = 27.Or. fd < 0
- If File(mtXt)
- Erase &mtXt
- Endif
- fd = Fopen((Alltrim(paramfac.dirpa)+"SPOOLER.LOG"), 0)
- If fd < 0
- Messagebox("Operación Cancelada: ERROR de comunicaciones con el Controlador.; Probablemente no se este ejecutando Spooler. ")
- Else
- fd =Fclose(fd)
- This.LeerSpooler("T")
- Endif
- Else
- fd = Fclose(fd)
- Select("comando")
- Zap
- Append From &maNs Sdf
- Goto Bottom
- This.numero = Val(Substr(comando.comando,35,8))
- If This.numero <> 0
- SQLExec(goApp.nCon, "select * from puntero where sucursal=?param.sucursal","puntero")
- If This.Ticket = "S"
- If This.MasDeMil
- This.numero = Val('0009'+strzero(This.numero,8))
- Else
- If lImpreFiscal
- This.numero = Val(impfis.PtoVtaTicket+strzero(This.numero,8))
- Else
- If Param.sucursal=0
- If File("c:\0009.txt")
- This.numero = Val(strzero(9,4)+strzero(This.numero,8))
- Else
- This.numero = Val(strzero(puntero.pvta_tic,4)+strzero(This.numero,8))
- Endif
- Else
- If Param.sucursal = 1
- This.numero = Val(strzero(8,4)+strzero(This.numero,8))
- Endif
- Endif
- Endif
- Endif
- Else
- If lImpreFiscal
- This.numero = Val(impfis.PtoVtaFac+strzero(This.numero,8))
- Else
- This.numero = Val(strzero(puntero.pvta_fac,4)+strzero(This.numero,8))
- Endif
- Endif
- This.TodoOK = .T.
- Endif
- Endif
- If File((Alltrim(paramfac.dirpa)+"SPOOLER.LOG"))
- Erase Alltrim(paramfac.dirpa)+"SPOOLER.LOG"
- Endif
- Endif
- *This.killprocessbyname("impred.exe")
- *This.killprocessbyname("wspooler.exe")
- Set Talk &cTalk
- Return This.Todo
- *!* unitario n(12,2), costo n(12,2), montoiva n(12,2), montodgr n(12,2), montomuni N(12,2),;
- *!* poriva n(12,2), tipoiva c(2))
- If det.unitario != 0
- If This.clase = "A"
- If This.Ticket = "S"
- Insert Into comando;
- VALUES ("A" + Se + det.unidad +" "+Substr(det.detalle,1,19)+ Se + "0")
- Insert Into comando;
- VALUES ("B" + Se + Padr(Alltrim(Substr(det.detalle,20,20)),20,".") + Se +;
- ALLTRIM(Str(det.cantidad,6,2)+"0")+ Se +;
- ALLTRIM(Str(det.unitario,9,2)) + Se + ;
- ALLTRIM(Str(det.poriva,5,2)) + Se +;
- "M" + Se + "0.00" + Se + "0" + Se + "T")
- Else
- Insert Into comando;
- VALUES ("B" + Se + det.unidad +" "+det.detalle+ Se + ;
- ALLTRIM(Str(det.cantidad,11,2))+ Se + ;
- Alltrim(Str(det.unitario,13,2)) + ;
- Se +Alltrim(Str(det.poriva,5,2)) + Se + ;
- "M" + Se + "0" + Se + "" + Se + "T")
- Endif
- Else
- If This.Ticket = "S"
- Insert Into comando;
- VALUES ( "A" + Se + det.unidad +" "+Substr(det.detalle,1,19)+ Se + "0")
- Insert Into comando;
- VALUES ("B" + Se + Padr(Alltrim(Substr(det.detalle,20,20)),20,".") + ;
- Se +Alltrim(Str(det.cantidad,6,2)+"0")+ Se + ;
- ALLTRIM(Str(det.unitario,9,2)) + Se + ;
- ALLTRIM(Str(det.poriva,5,2)) + Se + ;
- "M" + Se + "0.00" + Se + "0" + Se + "T")
- Else
- Insert Into comando;
- VALUES ("B" + Se + det.unidad+" "+det.detalle+ Se +;
- ALLTRIM(Str(det.cantidad,11,2))+ Se + ;
- ALLTRIM(Str(det.unitario,13,2)) + Se +;
- ALLTRIM(Str(det.poriva,5,2)) + Se + ;
- "M" + Se + "0" + Se + "" + Se + "T")
- Endif
- Endif
- Endif
- Select("det")
- Skip
- Enddo
- If This.condicion <> "C"
- If This.Ticket = "S"
- If This.contado = "S"
- Insert Into comando;
- VALUES (Chr(68)+ Se + Substr(formapago.detalle,1,30)+ Se + ;
- ALLTRIM(Str(ThisForm.Saldacontado.txtPago.Value,10,2))+ Se +"T"+ Se+"0")
- Else
- Insert Into comando;
- VALUES ( Chr(68)+ Se + Substr(formapago.detalle,1,30)+ ;
- Se + Alltrim(Str(ThisForm.Saldacontado.txtPago.Value,10,2))+ Se +"T"+ Se+"0")
- Endif
- Else
- If This.contado = "S"
- Insert Into comando;
- VALUES (Chr(68)+ Se + Alltrim(formapago.detalle)+ Se + ;
- ALLTRIM(Str(ThisForm.Saldacontado.txtPago.Value,12,2))+ Se +"T"+ Se+"0")
- Else
- Insert Into comando;
- VALUES(Chr(68)+ Se + Alltrim(formapago.detalle)+ Se + ;
- ALLTRIM(Str(ThisForm.Saldacontado.txtPago.Value,12,2))+ Se +"T"+ Se+"0")
- Endif
- Endif
- Endif
- If This.condicion <> "C"
- Insert Into comando;
- VALUES (Chr(69))
- Else
- Insert Into comando;
- VALUES ( Chr(129) )
- Endif
- &&en esta parte copio el archivo con los comandos a la carpeta desde el cual
- &&el spooler de impresion lee el archivo
- If This.Ticket ="S"
- && si es ticket me fijo a cual impresora debo enviar
- If lImpreFiscal
- mtXt = Alltrim(impfis.dircoticket) + Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(impfis.dirreticket) + Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Else
- mtXt = Alltrim(parametr.dirco)+"715\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(parametr.dirre)+"715\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Endif
- *!* cDirCom = "fpserver715" + "\impred.exe"
- *!* cDirCom = Fullpath(cDirCom)
- *!* && Mato el proceso del spooler y lo vuelvo a cargar
- *!* This.killprocessbyname("impred.exe")
- *!* This.killprocessbyname("wspooler.exe")
- *!* oShell = Createobject("Shell.Application")
- *!* oShell.ShellExecute (cDirCom)
- Else
- &&aca envio a la 320
- If lImpreFiscal
- mtXt = Alltrim(impfis.dircofactura) + Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(impfis.dirrefactura) + Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Else
- mtXt = Alltrim(parametr.dirco)+"320\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(parametr.dirre)+"320\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Endif
- Endif
- Select("comando")
- Goto Top
- &&en caso de que tenga un archivo en la cola de impresion de la impresora
- &&no se deja imprimir
- *Browse
- If File(mtXt)
- Messagebox("ATENCION: Ud. ya tiene un Documento en Cola de Impresión"+Chr(10)+Chr(13)+;
- " AGUARDE a que el mismo sea impreso o elimínelo luego vuelva a intentar")
- Return This.TodoOK
- Else
- Copy To &mtXt Sdf
- If File(maNs)
- Erase &maNs
- Endif
- If File(Alltrim(paramfac.dirpa)+"SPOOLER.LOG")
- Erase (Alltrim(paramfac.dirpa)+"SPOOLER.LOG")
- Endif
- Wait Windows 'Esperando Respuesta del Controlador Fiscal...' Nowait
- fd = -1
- intentos =1
- Do While fd < 0 .And. Lastkey() != 27
- fd = Fopen(maNs, 0)
- This.LeerSpooler("T")
- If intentos = 30
- Messagebox("ATENCION: Verifique que el Controlador Esté Conectado y Encendido. " + Chr(10) + Chr(13)+ ;
- "Verifique además que el Programa Spooler se esté ejecutando " + Chr(10) + Chr(13)+ ;
- "en el equipo al cual se encuentra conectado el Controlador Fiscal")
- This.LeerSpooler("T")
- Endif
- If intentos = 70
- Messagebox("ATENCION: Tiempo de Espera Agotado !!! Presione ESC. para cancelar este Comprobante")
- This.LeerSpooler("T")
- Endif
- intentos = intentos + 1
- *For i=1 To 100
- *Next
- Inkey(1)
- If Lastkey() = 27
- If Substr(comando.comando,17,16) = "Impresor Ocupado"
- Messagebox("ATENCION: No se aconseja cancelar este documento por programa, "+;
- CHR(10)+Chr(13)+"La impresora ya lo ha procesado y saldrá impreso"+;
- CHR(10)+Chr(13)+ "una vez que esta se ponga en linea")
- Endif
- If Messagebox("ATENCION: Realmente desea Cancelar la Emisión de este Documento??",4+256) = 6
- Messagebox(" Se proceder a Cancelar el Documento por Sistema"+;
- CHR(10)+Chr(13)+" Verifique que la impresora también lo haya Cancelado.")
- Keyboard '{ESC}'
- Else
- Keyboard ""
- Endif
- Endif
- Enddo
- If Lastkey() = 27.Or. fd < 0
- If File(mtXt)
- Erase &mtXt
- Endif
- fd = Fopen((Alltrim(paramfac.dirpa)+"SPOOLER.LOG"), 0)
- If fd < 0
- Messagebox("Operación Cancelada: ERROR de comunicaciones con el Controlador.; Probablemente no se este ejecutando Spooler. ")
- Else
- fd =Fclose(fd)
- This.LeerSpooler("T")
- Endif
- Else
- fd = Fclose(fd)
- Select("comando")
- Zap
- Append From &maNs Sdf
- Goto Bottom
- This.numero = Val(Substr(comando.comando,35,8))
- If This.numero <> 0
- SQLExec(goApp.nCon, "select * from puntero where sucursal=?param.sucursal","puntero")
- If This.Ticket = "S"
- If This.MasDeMil
- This.numero = Val('0009'+strzero(This.numero,8))
- Else
- If lImpreFiscal
- This.numero = Val(impfis.PtoVtaTicket+strzero(This.numero,8))
- Else
- If Param.sucursal=0
- If File("c:\0009.txt")
- This.numero = Val(strzero(9,4)+strzero(This.numero,8))
- Else
- This.numero = Val(strzero(puntero.pvta_tic,4)+strzero(This.numero,8))
- Endif
- Else
- If Param.sucursal = 1
- This.numero = Val(strzero(8,4)+strzero(This.numero,8))
- Endif
- Endif
- Endif
- Endif
- Else
- If lImpreFiscal
- This.numero = Val(impfis.PtoVtaFac+strzero(This.numero,8))
- Else
- This.numero = Val(strzero(puntero.pvta_fac,4)+strzero(This.numero,8))
- Endif
- Endif
- This.TodoOK = .T.
- Endif
- Endif
- If File((Alltrim(paramfac.dirpa)+"SPOOLER.LOG"))
- Erase Alltrim(paramfac.dirpa)+"SPOOLER.LOG"
- Endif
- Endif
- *This.killprocessbyname("impred.exe")
- *This.killprocessbyname("wspooler.exe")
- Set Talk &cTalk
- Return This.Todo
- *!* poriva n(12,2), tipoiva c(2))
- If det.unitario != 0
- If This.clase = "A"
- If This.Ticket = "S"
- Insert Into comando;
- VALUES ("A" + Se + det.unidad +" "+Substr(det.detalle,1,19)+ Se + "0")
- Insert Into comando;
- VALUES ("B" + Se + Padr(Alltrim(Substr(det.detalle,20,20)),20,".") + Se +;
- ALLTRIM(Str(det.cantidad,6,2)+"0")+ Se +;
- ALLTRIM(Str(det.unitario,9,2)) + Se + ;
- ALLTRIM(Str(det.poriva,5,2)) + Se +;
- "M" + Se + "0.00" + Se + "0" + Se + "T")
- Else
- Insert Into comando;
- VALUES ("B" + Se + det.unidad +" "+det.detalle+ Se + ;
- ALLTRIM(Str(det.cantidad,11,2))+ Se + ;
- Alltrim(Str(det.unitario,13,2)) + ;
- Se +Alltrim(Str(det.poriva,5,2)) + Se + ;
- "M" + Se + "0" + Se + "" + Se + "T")
- Endif
- Else
- If This.Ticket = "S"
- Insert Into comando;
- VALUES ( "A" + Se + det.unidad +" "+Substr(det.detalle,1,19)+ Se + "0")
- Insert Into comando;
- VALUES ("B" + Se + Padr(Alltrim(Substr(det.detalle,20,20)),20,".") + ;
- Se +Alltrim(Str(det.cantidad,6,2)+"0")+ Se + ;
- ALLTRIM(Str(det.unitario,9,2)) + Se + ;
- ALLTRIM(Str(det.poriva,5,2)) + Se + ;
- "M" + Se + "0.00" + Se + "0" + Se + "T")
- Else
- Insert Into comando;
- VALUES ("B" + Se + det.unidad+" "+det.detalle+ Se +;
- ALLTRIM(Str(det.cantidad,11,2))+ Se + ;
- ALLTRIM(Str(det.unitario,13,2)) + Se +;
- ALLTRIM(Str(det.poriva,5,2)) + Se + ;
- "M" + Se + "0" + Se + "" + Se + "T")
- Endif
- Endif
- Endif
- Select("det")
- Skip
- Enddo
- If This.condicion <> "C"
- If This.Ticket = "S"
- If This.contado = "S"
- Insert Into comando;
- VALUES (Chr(68)+ Se + Substr(formapago.detalle,1,30)+ Se + ;
- ALLTRIM(Str(ThisForm.Saldacontado.txtPago.Value,10,2))+ Se +"T"+ Se+"0")
- Else
- Insert Into comando;
- VALUES ( Chr(68)+ Se + Substr(formapago.detalle,1,30)+ ;
- Se + Alltrim(Str(ThisForm.Saldacontado.txtPago.Value,10,2))+ Se +"T"+ Se+"0")
- Endif
- Else
- If This.contado = "S"
- Insert Into comando;
- VALUES (Chr(68)+ Se + Alltrim(formapago.detalle)+ Se + ;
- ALLTRIM(Str(ThisForm.Saldacontado.txtPago.Value,12,2))+ Se +"T"+ Se+"0")
- Else
- Insert Into comando;
- VALUES(Chr(68)+ Se + Alltrim(formapago.detalle)+ Se + ;
- ALLTRIM(Str(ThisForm.Saldacontado.txtPago.Value,12,2))+ Se +"T"+ Se+"0")
- Endif
- Endif
- Endif
- If This.condicion <> "C"
- Insert Into comando;
- VALUES (Chr(69))
- Else
- Insert Into comando;
- VALUES ( Chr(129) )
- Endif
- &&en esta parte copio el archivo con los comandos a la carpeta desde el cual
- &&el spooler de impresion lee el archivo
- If This.Ticket ="S"
- && si es ticket me fijo a cual impresora debo enviar
- If lImpreFiscal
- mtXt = Alltrim(impfis.dircoticket) + Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(impfis.dirreticket) + Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Else
- mtXt = Alltrim(parametr.dirco)+"715\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(parametr.dirre)+"715\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Endif
- *!* cDirCom = "fpserver715" + "\impred.exe"
- *!* cDirCom = Fullpath(cDirCom)
- *!* && Mato el proceso del spooler y lo vuelvo a cargar
- *!* This.killprocessbyname("impred.exe")
- *!* This.killprocessbyname("wspooler.exe")
- *!* oShell = Createobject("Shell.Application")
- *!* oShell.ShellExecute (cDirCom)
- Else
- &&aca envio a la 320
- If lImpreFiscal
- mtXt = Alltrim(impfis.dircofactura) + Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(impfis.dirrefactura) + Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Else
- mtXt = Alltrim(parametr.dirco)+"320\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".txt"
- maNs = Alltrim(parametr.dirre)+"320\"+Substr(Sys(0),1,At("#",Sys(0))-2)+".ans"
- Endif
- Endif
- Select("comando")
- Goto Top
- &&en caso de que tenga un archivo en la cola de impresion de la impresora
- &&no se deja imprimir
- *Browse
- If File(mtXt)
- Messagebox("ATENCION: Ud. ya tiene un Documento en Cola de Impresión"+Chr(10)+Chr(13)+;
- " AGUARDE a que el mismo sea impreso o elimínelo luego vuelva a intentar")
- Return This.TodoOK
- Else
- Copy To &mtXt Sdf
- If File(maNs)
- Erase &maNs
- Endif
- If File(Alltrim(paramfac.dirpa)+"SPOOLER.LOG")
- Erase (Alltrim(paramfac.dirpa)+"SPOOLER.LOG")
- Endif
- Wait Windows 'Esperando Respuesta del Controlador Fiscal...' Nowait
- fd = -1
- intentos =1
- Do While fd < 0 .And. Lastkey() != 27
- fd = Fopen(maNs, 0)
- This.LeerSpooler("T")
- If intentos = 30
- Messagebox("ATENCION: Verifique que el Controlador Esté Conectado y Encendido. " + Chr(10) + Chr(13)+ ;
- "Verifique además que el Programa Spooler se esté ejecutando " + Chr(10) + Chr(13)+ ;
- "en el equipo al cual se encuentra conectado el Controlador Fiscal")
- This.LeerSpooler("T")
- Endif
- If intentos = 70
- Messagebox("ATENCION: Tiempo de Espera Agotado !!! Presione ESC. para cancelar este Comprobante")
- This.LeerSpooler("T")
- Endif
- intentos = intentos + 1
- *For i=1 To 100
- *Next
- Inkey(1)
- If Lastkey() = 27
- If Substr(comando.comando,17,16) = "Impresor Ocupado"
- Messagebox("ATENCION: No se aconseja cancelar este documento por programa, "+;
- CHR(10)+Chr(13)+"La impresora ya lo ha procesado y saldrá impreso"+;
- CHR(10)+Chr(13)+ "una vez que esta se ponga en linea")
- Endif
- If Messagebox("ATENCION: Realmente desea Cancelar la Emisión de este Documento??",4+256) = 6
- Messagebox(" Se proceder a Cancelar el Documento por Sistema"+;
- CHR(10)+Chr(13)+" Verifique que la impresora también lo haya Cancelado.")
- Keyboard '{ESC}'
- Else
- Keyboard ""
- Endif
- Endif
- Enddo
- If Lastkey() = 27.Or. fd < 0
- If File(mtXt)
- Erase &mtXt
- Endif
- fd = Fopen((Alltrim(paramfac.dirpa)+"SPOOLER.LOG"), 0)
- If fd < 0
- Messagebox("Operación Cancelada: ERROR de comunicaciones con el Controlador.; Probablemente no se este ejecutando Spooler. ")
- Else
- fd =Fclose(fd)
- This.LeerSpooler("T")
- Endif
- Else
- fd = Fclose(fd)
- Select("comando")
- Zap
- Append From &maNs Sdf
- Goto Bottom
- This.numero = Val(Substr(comando.comando,35,8))
- If This.numero <> 0
- SQLExec(goApp.nCon, "select * from puntero where sucursal=?param.sucursal","puntero")
- If This.Ticket = "S"
- If This.MasDeMil
- This.numero = Val('0009'+strzero(This.numero,8))
- Else
- If lImpreFiscal
- This.numero = Val(impfis.PtoVtaTicket+strzero(This.numero,8))
- Else
- If Param.sucursal=0
- If File("c:\0009.txt")
- This.numero = Val(strzero(9,4)+strzero(This.numero,8))
- Else
- This.numero = Val(strzero(puntero.pvta_tic,4)+strzero(This.numero,8))
- Endif
- Else
- If Param.sucursal = 1
- This.numero = Val(strzero(8,4)+strzero(This.numero,8))
- Endif
- Endif
- Endif
- Endif
- Else
- If lImpreFiscal
- This.numero = Val(impfis.PtoVtaFac+strzero(This.numero,8))
- Else
- This.numero = Val(strzero(puntero.pvta_fac,4)+strzero(This.numero,8))
- Endif
- Endif
- This.TodoOK = .T.
- Endif
- Endif
- If File((Alltrim(paramfac.dirpa)+"SPOOLER.LOG"))
- Erase Alltrim(paramfac.dirpa)+"SPOOLER.LOG"
- Endif
- Endif
- *This.killprocessbyname("impred.exe")
- *This.killprocessbyname("wspooler.exe")
- Set Talk &cTalk
- Return This.TodoOK
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement