on 09-20-2010 6:17 PM
Que tal,
Estoy creando un proceso de autorizacion para evitar crear nuevas facturas a clientes que tengan facturas vencidad abiertas a menos que sean autorizadas por la direccion. Ya cree el proceso y lo malo es que ya me pide autorizacion para todas las facturas asi que creo que mi error esta en el query. El query es el siguiente:
SELECT DISTINCT 'TRUE' FROM [dbo].[OCRD] T0 LEFT OUTER JOIN [dbo].[OINV] T1 ON T1.[CardCode] = T0.[CardCode] AND T1.[CardCode] = T0.[CardCode] WHERE T1.[DocStatus] Like N'%O%' AND T1.[DocDueDate] <= GETDATE()
Espero me puedan ayudar.
Gracias
Tengo una autorizacion por el mismo caso que necesitas, pero yo los bloqueo desde la Orden de Venta.
Te puede servir como ejemplo:
SELECT CASE
WHEN (SELECT COUNT(*) FROM OINV
WHERE CardCode = $[ORDR.CardCode] AND DATEDIFF(DAY, DocDueDate, GETDATE()) > 15
AND DocStatus = 'O') > 0 THEN 'true'
ELSE 'false'
END
Me arroja un número mayor a 0 si existen alguna factura con vencimiento mayor a 15 días y se activa la alerta.
Si deseas bloquearlo en la factura,
cambia $[ORDR.CardCode] por $[OINV.CardCode]
Saludos,
Edited by: Enrique Hurtado on Sep 23, 2010 12:26 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
mira primero yo genere un sp para enviar la información y generar la autorización. obviamente yo la puse antes de la factura para que asi no se me generara un cuello de botella.
AS
DECLARE @VARIABLE INT
DECLARE @SnCondPago nvarchar(60)
DECLARE @cont nvarchar(60)
DECLARE @limitcredit numeric(19,6)
DECLARE @saldocuenta numeric(19,6)
SET @VARIABLE = (select count(t0.docentry)
from OINV t0
where (t0.canceled='n') and t0.docstatus='o' and (t0.paidtodate<t0.doctotal)
and (datediff(day,t0.docduedate,getdate()) >= 1)
and t0.cardcode=@cliente)
SET @SnCondPago = (select OCRD.groupnum
from OCRD
where OCRD.cardtype = 'C'
and OCRD.cardcode = @Cliente)
SET @saldocuenta= (select OCRD.balance
from OCRD
where OCRD.cardtype = 'C'
and OCRD.cardcode = @Cliente)+@doctotal
SET @limitcredit= (select ocrd.creditline
from OCRD
WHERE OCRD.CARDTYPE='C'
and OCRD.CARDCODE= @cliente)
IF( (@saldocuenta>=@limitcredit)or (@variable>=1))
BEGIN
SELECT 'TRUE'
END
variable me trae si existen facturas de ese cliente sin pagar, oks. saludos
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
99 | |
11 | |
11 | |
6 | |
6 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.