hace 6 años
Tengo Tango Astor version 9.91
Quiero eliminar una orden de pago completamente y volverla a ingresar con el mismo nro.
la OP tiene cheques de terceros.
Elimino la FACTURA y anulo la OP.
En Tesoreria, elimino los asientos de la OP y del REV,
Elimino la OP con el siguiente script:DECLARE @OP VARCHAR(13)SET @OP = ' 000000003746' --Exactamente 13 caracteres, hay un espacio en blanco-- primero chequea que el comprobante este revertidoIF EXISTS (select top 1 1 from SBA27 WHERE T_COMP_ORI = 'O/P' AND N_COMP_ORI = @OP) BEGIN
DELETE from SBA04 WHERE (COD_COMP = 'O/P' AND N_COMP = @OP) OR (COD_COMP = 'REV' AND N_COMP = (select N_COMP_REV from SBA27 WHERE T_COMP_ORI = 'O/P' AND N_COMP_ORI = @OP)) DELETE from SBA05 WHERE (COD_COMP = 'O/P' AND N_COMP = @OP) OR (COD_COMP = 'REV' AND N_COMP = (select N_COMP_REV from SBA27 WHERE T_COMP_ORI = 'O/P' AND N_COMP_ORI = @OP)) DELETE from SBA15 WHERE T_COMP_EMI = 'O/P' AND N_COMP_EMI = @OP
DELETE from SBA27 WHERE T_COMP_ORI = 'O/P' AND N_COMP_ORI = @OP
END
Me sale el mensaje de error:
Msg 547, Level 16, State 0, Line 12
The DELETE statement conflicted with the REFERENCE constraint "FK_MOVIMIENTO_CHEQUE_TERCERO_SBA05". The conflict occurred in database "COOP", table "dbo.MOVIMIENTO_CHEQUE_TERCERO", column 'ID_SBA05'.
Entonces le agrego la siguiente linea, no se si es correctoDELETE from MOVIMIENTO_CHEQUE_TERCERO WHERE (ID_SBA05 = (select ID_SBA05 from SBA05 WHERE (COD_COMP = 'O/P' AND N_COMP = @OP AND COD_CTA = 11103)))La cuenta 11103 es Valores a Depositar
La OP no se elimina totalmente, no la puedo volver a cargar con el mismo numero.
Sigue quedando en el listado de OP anuladas
¿Realmente quieres cerrar esta reparación?
Sí
No
¿Realmente quieres reabrir esta reparación?
Sí
No
¿Realmente quieres borrar este post?
Sí
No