on 12-18-2008 9:41 PM
que tal compañeros, estoy haciendo un query para poder sacar comiisones dependiendo del articulo y fecha de pago.
Es decir que dependiendo cuanto se tardo en pagar la factura el cliente es la comision que se le dara al vendedor, tengo esto:
CASE T3.[DocCur] WHEN 'USD' THEN T3.[DocTotalFC] else T3.[DocTotal] END AS 'Tot Factura',( T3.DocTotal - T3.VatSum) As 'Factura S/IVA', T6.[CommisPcnt] as '% Comision',
'Com. Normal' = case when ( DATEDIFF(day, T3.docdate, T0.docdate) <=45) then (T4.[LineTotal]*( T6.CommisPcnt/100)) end,
'16-30 Retraso' = case when (DATEDIFF(day, T3.docdate, T0.docdate) >=46 and DATEDIFF(day, T3.docdate, T0.docdate) <=60) then (T4.[LineTotal]*( T6.CommisPcnt/100)*(70/100)) end,
'31-45 Retraso' = case when (DATEDIFF(day, T3.docdate, T0.docdate) >=61 and DATEDIFF(day, T3.docdate, T0.docdate) <=90) then (T4.[LineTotal]*( T6.CommisPcnt/100)*(50/100)) end,
'46-90 Retraso' = case when (DATEDIFF(day, T3.docdate, T0.docdate) >=91 and DATEDIFF(day, T3.docdate, T0.docdate) <=180) then (T4.[LineTotal]*( T6.CommisPcnt/100)*(10/100)) end
FROM ORCT T0 INNER JOIN RCT2 T2 ON T0.DocEntry = T2.DocNum INNER JOIN OINV T3 ON T2.DocEntry = T3.DocEntry INNER JOIN INV1 T4 ON T3.DocEntry = T4.DocEntry INNER JOIN OSLP T5 ON T3.SlpCode = T5.SlpCode INNER JOIN OITM T6 ON T4.ItemCode = T6.ItemCode WHERE T0.[DocDate] >='[%0]' AND T0.[DocDate] <='[%1]' AND T5.[SlpName] =[%2] AND T0.[JrnlMemo] <> 'Cancelado'
Los ultimos tres campos que son los que calcula comision checando los dias no me da resultado, solo el campo de "com. Normal" me da......... alguien puede darme un norte de que estoy haciendo mal?
Saludos.
Iba a borrar el post pero bueno, lo deja para quien le sirva, el error esta en poner 70/100, 50/100 y asi por el estilo, hay que pone solo 0.7 y 0.5
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 |
---|---|
108 | |
12 | |
11 | |
6 | |
5 | |
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.