Lentitud al arrancar y al cerra pantalla
aca va el init
LPARAMETERS idComprobante, nIdOrdenTrabajo, dFechaRemito, idCliente, nMontoPagado
IF .NOT. DODEFAULT()
RETURN .F.
ENDIF
m.nidordentrabajo = IIF(EMPTY(m.nidordentrabajo), .NULL., m.nidordentrabajo)
thisform.idordentrabajo = m.nidordentrabajo
thisform.grillaprod.recordsource = .NULL.
thisform.grillafp.recordsource = .NULL.
nFP = thisform.idformapago.Value
thisform.idformapago.crearcursor("curFPMoneda")
thisform.idformapago.Value = nFP
ad("exec VerConfiguraciones @Descrip = NULL, @Grupo = 'Facturacion'", "curConfig")
LOCATE FOR LOWER(ALLTRIM(confdescrip))="precioventa"
thisform.TipoVenta.value = INT(VAL(curconfig.confvalor))
IF !EMPTY(m.idcomprobante)
LOCAL bPermiso
thisform.idcomprobante = m.idcomprobante
thisform.menu.imprimir.visible = .T.
thisform.menu.eliminar.visible = .T.
ad("exec GetComprobante "+tostr(m.idcomprobante), "curGetComprobante")
SELECT cdprocodigo AS procodigo, cdprodescrip AS prodescrip, cdcantidad, cdpreciounit, cdiva1, ROUND((cdcantidad * cdpreciounit * ( 1 + (cdIVA1 / 100))) - cdpreciounit, 2) as TotalIVA, ;
cddescuento, ROUND((cdcantidad * cdpreciounit * (1 + (cdIva1 / 100))) * ((100 - cddescuento) / 100), 2) as Total, idproducto, ;
ididentificable, idcomdetalle, cdiva2, idformapago ;
FROM curGetComprobante1 ;
INTO CURSOR curDetalleProd READWRITE
SELECT * ;
FROM curGetComprobante2 ;
INTO CURSOR curDetalleFP READWRITE
bPermiso = thisform.acceder(_SCREEN.idusuario, "Permite ver comprobantes de Otras Sucursales", thisform.idmodulo, .NULL., .NULL., .NULL., .NULL., .NULL.)
IF (curgetcomprobante.idsucursal = _SCREEN.idsucursal OR bPermiso = .T.) AND (curgetcomprobante.tcFactura = .T. OR curgetcomprobante.tcTicketFactura = .T. OR tcNotaCredito = .T.)
thisform.idtipocomprobante.value = curgetcomprobante.idtipocomprobante
thisform.identidad.value = curgetcomprobante.identidad
thisform.comfecha.value = curgetcomprobante.comfecha
thisform.comobservac.value = curgetcomprobante.comobservac
thisform.comnumero.value = TRANSFORM(curgetcomprobante.comnumero)
thisform.comanulado.visible = curgetcomprobante.comanulado
thisform.cerrado.visible = .NOT. ISNULL(curgetcomprobante.idcierrecaja)
thisform.relacionados1.visible = .T.
thisform.relacionados1.idcomprobante = m.idcomprobante
thisform.iddeposito.value = curgetcomprobante.iddeposito
thisform.habilitar(.F.)
thisform.sumarizar()
thisform.agregarctacte.value = IIF(thisform.totaltotalfp.value<>thisform.totaltotal.value, .T., .F.)
thisform.idtipocomprobante.tccantcopias = IIF(EMPTY(thisform.idtipocomprobante.tccantcopias), 1, thisform.idtipocomprobante.tccantcopias)
thisform.grillaprod.recordsource = "curDetalleProd"
thisform.grillafp.recordsource = "curDetalleFP"
thisform.grillafp.click()
thisform.tipoventa.enabled = .F.
thisform.grillafp.column6.enabled = .F.
thisform.grillaprod.enabled = .F.
thisform.agregarctacte.enabled = .F.
thisform.titulo23.enabled = .F.
thisform.titulo24.enabled = .F.
thisform.idproducto.enabled = .F.
thisform.cdcantidad.enabled = .F.
thisform.cdpreciounit.enabled = .F.
thisform.cddescuento.enabled = .F.
thisform.agregarprod.enabled = .F.
thisform.idformapago.enabled = .F.
thisform.agregarfp.enabled = .F.
thisform.fpdmonto.enabled = .F.
thisform.menu.guardar.visible = .F.
thisform.menu.cancelar.visible = .F.
thisform.titulo36.Visible = .T.
thisform.comCAE.Visible = .T.
thisform.titulo20.Visible = .F.
thisform.TipoVenta.Visible = .F.
thisform.titulo37.Visible = .T.
thisform.comFechaVtoCAE.Visible = .T.
thisform.comCAE.Value = curgetcomprobante.comCAE
thisform.comFechaVtoCAE.Value = curgetcomprobante.comFechaVtoCAE
thisform.comCodigoBarrasFAE.Value = curgetcomprobante.comCodigoBarrasFAE
cfechas = ""
SELECT curgetcomprobante3
SCAN
cmonto = TRANSFORM(IIF(EMPTY(ctadebe), ctahaber, ctadebe))
cfechas = cfechas+"$"+cmonto+" - "+DTOC(fecha)+CHR(13)
ENDSCAN
thisform.fpdfinanciacion.value = cfechas
ELSE
msgbox("El comprobante no es de esta Sucursal, o no es un comprobante de facturación", 64, "Comprobante")
RETURN .F.
ENDIF
ELSE
thisform.crearclave()
CREATE CURSOR curDetalleProd (procodigo C (25), prodescrip C (70), cdcantidad N (9, 2), cdpreciounit N (9, 2), cdiva1 N (9, 2), totaliva N (9, 2), ;
cddescuento N (9, 2), total N (9, 2), idproducto I, ididentificable I NULL, cdiva2 N (9, 2), idformapago I NULL)
CREATE CURSOR curDetalleFP (fpdescrip C (50), fpdcupon C (15) NULL, fpdnumcheque C (50) NULL, fpdbco C (50) NULL, fpdfechacobrocheque D NULL, fpdmonto N (9, 2), ;
fpdvalormoneda N (9, 2), total N (9, 2), idformapago I, idrecibi I NULL, idcuentabancaria I NULL, entdescrip C (50) NULL, tcbdescrip C (50) NULL, ;
ctacbu C (50) NULL, ctanrocuenta C (50) NULL, ctasucursal C (50) NULL, fpdnrotransferencia C (50) NULL, idformapagocaja I NULL)
IF .NOT. EMPTY(m.nidordentrabajo) .AND. .NOT. ISNULL(m.nidordentrabajo)
ad("exec GetOrdenTrabajo "+tostr(m.nidordentrabajo), "curOrdTrab")
SELECT curordtrab1
SUM monto TO totmonto
IF .NOT. EMPTY(m.totmonto)
INSERT INTO curDetalleFP (fpdescrip, fpdmonto, fpdvalormoneda, total, idformapago, idrecibi) VALUES ("Pagos en Cuenta Corriente", totmonto, 1.0000 , totmonto, 0, 0)
ENDIF
SELECT curordtrab2
SCAN
a = ad("exec InsertComDetalle " + tostr(curordtrab2.idproducto, .T.) + tostr(.NULL., .T.) + tostr(curordtrab2.pocantidad, .T.) + ;
tostr(curordtrab2.podescuento, .T.) + tostr(thisform.cdclave, .T.) + tostr(curordtrab2.poprecio))
nTotal = ROUND((curordtrab2.pocantidad * curordtrab2.poprecio * (1 + (curordtrab2.poiva1 / 100))) * ((100 - curordtrab2.podescuento) / 100), 2)
INSERT INTO curDetalleProd ;
(procodigo, prodescrip, cdcantidad, cdpreciounit, cddescuento, total, idproducto, ididentificable, procodigo, cdiva1, cdiva2, idformapago) ;
VALUES ;
(curordtrab2.pocodigo, curordtrab2.podescrip, curordtrab2.pocantidad, curordtrab2.poprecio, curordtrab2.podescuento, nTotal, ;
curordtrab2.idproducto, .NULL., curordtrab2.procodigo, curordtrab2.poiva1, curordtrab2.poiva2, curordtrab2.idformapago)
ENDSCAN
thisform.sumarizar()
thisform.identidad.value = curordtrab.idcliente
thisform.fpdmonto.value = EVL(m.nMontoPagado, curordtrab.otmonto - m.totmonto)
thisform.comobservac.value = "Facturación de productos - " + ALLTRIM(curordtrab.otdescrip)
thisform.guardarycerrar = .T.
thisform.agregarprod.enabled = .F.
thisform.identidad.enabled = .F.
thisform.idproducto.enabled = .F.
thisform.cdcantidad.enabled = .F.
thisform.cddescuento.enabled = .F.
ENDIF
IF .NOT. EMPTY(m.dfecharemito)
ad("exec GetFacturacionRemitos "+tostr(m.dfecharemito, .T.)+tostr(m.idcliente), "curFacturacionRemito")
SELECT curfacturacionremito
IF RECCOUNT()=0
msgbox("No hay remitos sin facturar, por favor asegúrese de haber seleccionado correctamente el cliente", 64, "Sin Remitos")
RETURN .F.
ELSE
SELECT DISTINCT .T. AS seleccionar, comnumero, idcomprobante FROM curFacturacionRemito INTO CURSOR curFacturacionRemito1 READWRITE
IF RECCOUNT()>1
DO FORM SeleccionarRemito
SELECT c.* ;
FROM curFacturacionRemito c ;
INNER JOIN curFacturacionRemito1 r ON c.comnumero=r.comnumero ;
WHERE seleccionar=.T. ;
INTO CURSOR curFacturacionRemito READWRITE
ENDIF
IF RECCOUNT()=0
RETURN .F.
ENDIF
ENDIF
SELECT curfacturacionremito
SCAN
a = ad("exec InsertComDetalle " + tostr(curfacturacionremito.idproducto, .T.) + tostr(curfacturacionremito.ididentificable, .T.) + ;
tostr(curfacturacionremito.cdcantidad, .T.) + tostr(curfacturacionremito.cddescuento, .T.) + tostr(thisform.cdclave, .T.) + ;
tostr(curfacturacionremito.cdpreciounit))
INSERT INTO curDetalleProd ;
(procodigo, prodescrip, cdcantidad, cdpreciounit, cddescuento, total, idproducto, ididentificable, procodigo, cdiva1, cdiva2, idformapago) ;
VALUES ;
(curfacturacionremito.procodigo, curfacturacionremito.cdprodescrip, curfacturacionremito.cdcantidad, curfacturacionremito.cdpreciounit, ;
curfacturacionremito.cddescuento, curfacturacionremito.total, curfacturacionremito.idproducto, curfacturacionremito.ididentificable, ;
curfacturacionremito.procodigo, curfacturacionremito.cdiva1, curfacturacionremito.cdiva2, curfacturacionremito.idformapago)
ENDSCAN
thisform.sumarizar()
thisform.fecharemito = m.dfecharemito
thisform.identidad.value = m.idcliente
thisform.guardarycerrar = .T.
thisform.identidad.enabled = .F.
thisform.facturar.enabled = .F.
thisform.tipoventa.enabled = .F.
thisform.habilitar(.F., "Producto")
ENDIF
thisform.grillafp.recordsource = "curDetalleFP"
thisform.grillaprod.recordsource = "curDetalleProd"
thisform.cdpreciounit.enabled = .F.
thisform.tipoventa.setfocus()
ENDIF
thisform.identidad.setfocus()
thisform.Titulo40.Visible = .T.
thisform.Titulo40.FontBold = .T.
thisform.Titulo40.ForeColor = RGB(100, 100, 100)
thisform.Titulo40.FontName = "Arial"
thisform.idTipoComprobante.Visible = .F.