1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253
| SELECT "DATA"."Exercice","DATA"."Type de doc", "DATA"."DocNum","DATA"."DocDate", "DATA"."CardCode", "DATA"."CardName", "DATA"."SlpName","DATA"."ItemCode","DATA"."ItmsGrpCod", "DATA"."ItmsGrpNam","DATA"."LineNum",SUM("DATA"."CA HT Récurrent"),SUM("DATA"."CA HT Prestation"),SUM("DATA"."CA HT One Shot")
FROM(
SELECT 'N-1' "Exercice",'Facture' "Type de doc",T0."DocNum",T0."DocDate", T0."CardCode", T0."CardName", T2."SlpName",T6."ItemCode",T6."ItmsGrpCod", T8."ItmsGrpNam",T4."LineNum",CASE
WHEN coalesce(T0."DiscPrcnt",0) = 0 then T4."LineTotal"
ELSE T4."LineTotal" - (T4."LineTotal" * T0."DiscPrcnt"/100)
END "CA HT Récurrent",0 "CA HT Prestation",0 "CA HT One Shot"
FROM OINV T0
LEFT JOIN OSLP T2 ON T2."SlpCode" = T0."SlpCode"
LEFT JOIN INV1 T4 ON T4."DocEntry"=T0."DocEntry"
LEFT JOIN OITM T6 ON T6."ItemCode"=T4."ItemCode"
LEFT JOIN OITB T8 ON T8."ItmsGrpCod"=T6."ItmsGrpCod"
WHERE T0."CANCELED" = 'N' and T4."LineTotal"<>0 and T8."ItmsGrpNam" IS NOT NULL AND T8."U_OSTYPECOMM" = 'Rec'AND CASE WHEN EXTRACT(MONTH FROM T0."DocDate") BETWEEN 01 and 09
AND EXTRACT(YEAR FROM T0."DocDate") = EXTRACT(YEAR FROM CURRENT_DATE) - 1
THEN 1
WHEN EXTRACT(MONTH FROM T0."DocDate") BETWEEN 10 AND 12
AND EXTRACT(YEAR FROM T0."DocDate") = EXTRACT(YEAR FROM CURRENT_DATE) - 2
THEN 1
ELSE 0
END = 1
UNION
SELECT 'N-1' "Exercice",'Avoir' "Type de doc", T1."DocNum", T1."DocDate", T1."CardCode", T1."CardName",T3."SlpName",T7."ItemCode",T7."ItmsGrpCod",T9."ItmsGrpNam",T5."LineNum",CASE
WHEN coalesce(T1."DiscPrcnt",0) = 0 then -T5."LineTotal"
ELSE -(T5."LineTotal" - (T5."LineTotal" * T1."DiscPrcnt" /100))
END "CA HT Récurrent",0 "CA HT Prestation",0 "CA HT One Shot"
FROM ORIN T1
LEFT JOIN OSLP T3 ON T3."SlpCode"=T1."SlpCode"
LEFT JOIN RIN1 T5 ON T5."DocEntry"=T1."DocEntry"
LEFT JOIN OITM T7 ON T7."ItemCode"=T5."ItemCode"
LEFT JOIN OITB T9 ON T9."ItmsGrpCod"=T7."ItmsGrpCod"
WHERE T1."CANCELED" ='N' and T5."LineTotal"<>0 and T9."ItmsGrpNam" IS NOT NULL AND T9."U_OSTYPECOMM" = 'Rec' AND CASE WHEN EXTRACT(MONTH FROM T1."DocDate") BETWEEN 01 and 09
AND EXTRACT(YEAR FROM T1."DocDate") = EXTRACT(YEAR FROM CURRENT_DATE) - 1
THEN 1
WHEN EXTRACT(MONTH FROM T1."DocDate") BETWEEN 10 AND 12
AND EXTRACT(YEAR FROM T1."DocDate") = EXTRACT(YEAR FROM CURRENT_DATE) - 2
THEN 1
ELSE 0
END = 1
UNION
SELECT 'N-1' "Exercice",'Facture' "Type de doc",T0."DocNum",T0."DocDate", T0."CardCode", T0."CardName", T2."SlpName",T6."ItemCode",T6."ItmsGrpCod", T8."ItmsGrpNam",T4."LineNum",0 "CA HT Récurrent",CASE
WHEN coalesce(T0."DiscPrcnt",0) = 0 then T4."LineTotal"
ELSE T4."LineTotal" - (T4."LineTotal" * T0."DiscPrcnt"/100)
END "CA HT Prestation",0 "CA HT One Shot"
FROM OINV T0
LEFT JOIN OSLP T2 ON T2."SlpCode" = T0."SlpCode"
LEFT JOIN INV1 T4 ON T4."DocEntry"=T0."DocEntry"
LEFT JOIN OITM T6 ON T6."ItemCode"=T4."ItemCode"
LEFT JOIN OITB T8 ON T8."ItmsGrpCod"=T6."ItmsGrpCod"
WHERE T0."CANCELED" = 'N' and T4."LineTotal"<>0 and T8."ItmsGrpNam" IS NOT NULL AND T8."U_OSTYPECOMM" = 'Pre' AND CASE WHEN EXTRACT(MONTH FROM T0."DocDate") BETWEEN 01 and 09
AND EXTRACT(YEAR FROM T0."DocDate") = EXTRACT(YEAR FROM CURRENT_DATE) - 1
THEN 1
WHEN EXTRACT(MONTH FROM T0."DocDate") BETWEEN 10 AND 12
AND EXTRACT(YEAR FROM T0."DocDate") = EXTRACT(YEAR FROM CURRENT_DATE) - 2
THEN 1
ELSE 0
END = 1
UNION
SELECT 'N-1' "Exercice",'Avoir' "Type de doc", T1."DocNum", T1."DocDate", T1."CardCode", T1."CardName",T3."SlpName",T7."ItemCode",T7."ItmsGrpCod",T9."ItmsGrpNam",T5."LineNum",0 "CA HT Récurrent",CASE
WHEN coalesce(T1."DiscPrcnt",0) = 0 then -T5."LineTotal"
ELSE -(T5."LineTotal" - (T5."LineTotal" * T1."DiscPrcnt" /100))
END "CA HT Prestation",0 "CA HT One Shot"
FROM ORIN T1
LEFT JOIN OSLP T3 ON T3."SlpCode"=T1."SlpCode"
LEFT JOIN RIN1 T5 ON T5."DocEntry"=T1."DocEntry"
LEFT JOIN OITM T7 ON T7."ItemCode"=T5."ItemCode"
LEFT JOIN OITB T9 ON T9."ItmsGrpCod"=T7."ItmsGrpCod"
WHERE T1."CANCELED" ='N' and T5."LineTotal"<>0 and T9."ItmsGrpNam" IS NOT NULL AND T9."U_OSTYPECOMM" = 'Pre' AND CASE WHEN EXTRACT(MONTH FROM T1."DocDate") BETWEEN 01 and 09
AND EXTRACT(YEAR FROM T1."DocDate") = EXTRACT(YEAR FROM CURRENT_DATE) - 1
THEN 1
WHEN EXTRACT(MONTH FROM T1."DocDate") BETWEEN 10 AND 12
AND EXTRACT(YEAR FROM T1."DocDate") = EXTRACT(YEAR FROM CURRENT_DATE) - 2
THEN 1
ELSE 0
END = 1
UNION
SELECT 'N-1' "Exercice",'Facture' "Type de doc",T0."DocNum",T0."DocDate", T0."CardCode", T0."CardName", T2."SlpName",T6."ItemCode",T6."ItmsGrpCod", T8."ItmsGrpNam",T4."LineNum",0 "CA HT Récurrent",0 "CA HT Prestation",CASE
WHEN coalesce(T0."DiscPrcnt",0) = 0 then T4."LineTotal"
ELSE T4."LineTotal" - (T4."LineTotal" * T0."DiscPrcnt"/100)
END "CA HT One Shot"
FROM OINV T0
LEFT JOIN OSLP T2 ON T2."SlpCode" = T0."SlpCode"
LEFT JOIN INV1 T4 ON T4."DocEntry"=T0."DocEntry"
LEFT JOIN OITM T6 ON T6."ItemCode"=T4."ItemCode"
LEFT JOIN OITB T8 ON T8."ItmsGrpCod"=T6."ItmsGrpCod"
WHERE T0."CANCELED" = 'N'and T4."LineTotal"<>0 and T8."ItmsGrpNam" IS NOT NULL AND T8."U_OSTYPECOMM" = 'Neg' AND CASE WHEN EXTRACT(MONTH FROM T0."DocDate") BETWEEN 01 and 09
AND EXTRACT(YEAR FROM T0."DocDate") = EXTRACT(YEAR FROM CURRENT_DATE) - 1
THEN 1
WHEN EXTRACT(MONTH FROM T0."DocDate") BETWEEN 10 AND 12
AND EXTRACT(YEAR FROM T0."DocDate") = EXTRACT(YEAR FROM CURRENT_DATE) - 2
THEN 1
ELSE 0
END = 1
UNION
SELECT 'N-1' "Exercice",'Avoir' "Type de doc", T1."DocNum", T1."DocDate", T1."CardCode", T1."CardName",T3."SlpName",T7."ItemCode",T7."ItmsGrpCod",T9."ItmsGrpNam",T5."LineNum",0 "CA HT Récurrent",0 "CA HT Prestation",CASE
WHEN coalesce(T1."DiscPrcnt",0) = 0 then -T5."LineTotal"
ELSE -(T5."LineTotal" - (T5."LineTotal" * T1."DiscPrcnt" /100))
END "CA HT One Shot"
FROM ORIN T1
LEFT JOIN OSLP T3 ON T3."SlpCode"=T1."SlpCode"
LEFT JOIN RIN1 T5 ON T5."DocEntry"=T1."DocEntry"
LEFT JOIN OITM T7 ON T7."ItemCode"=T5."ItemCode"
LEFT JOIN OITB T9 ON T9."ItmsGrpCod"=T7."ItmsGrpCod"
WHERE T1."CANCELED" ='N' and T5."LineTotal"<>0 and T9."ItmsGrpNam" IS NOT NULL AND T9."U_OSTYPECOMM" = 'Neg' AND CASE WHEN EXTRACT(MONTH FROM T1."DocDate") BETWEEN 01 and 09
AND EXTRACT(YEAR FROM T1."DocDate") = EXTRACT(YEAR FROM CURRENT_DATE) - 1
THEN 1
WHEN EXTRACT(MONTH FROM T1."DocDate") BETWEEN 10 AND 12
AND EXTRACT(YEAR FROM T1."DocDate") = EXTRACT(YEAR FROM CURRENT_DATE) - 2
THEN 1
ELSE 0
END = 1
UNION
SELECT 'N' "Exercice",'Facture' "Type de doc",T0."DocNum",T0."DocDate", T0."CardCode", T0."CardName", T2."SlpName",T6."ItemCode",T6."ItmsGrpCod", T8."ItmsGrpNam",T4."LineNum",CASE
WHEN coalesce(T0."DiscPrcnt",0) = 0 then T4."LineTotal"
ELSE T4."LineTotal" - (T4."LineTotal" * T0."DiscPrcnt"/100)
END "CA HT Récurrent",0 "CA HT Prestation",0 "CA HT One Shot"
FROM OINV T0
LEFT JOIN OSLP T2 ON T2."SlpCode" = T0."SlpCode"
LEFT JOIN INV1 T4 ON T4."DocEntry"=T0."DocEntry"
LEFT JOIN OITM T6 ON T6."ItemCode"=T4."ItemCode"
LEFT JOIN OITB T8 ON T8."ItmsGrpCod"=T6."ItmsGrpCod"
WHERE T0."CANCELED" = 'N' and T4."LineTotal"<>0 and T8."ItmsGrpNam" IS NOT NULL AND T8."U_OSTYPECOMM" = 'Rec'AND CASE WHEN EXTRACT(MONTH FROM T0."DocDate") BETWEEN 01 and 09
AND EXTRACT(YEAR FROM T0."DocDate") = EXTRACT(YEAR FROM CURRENT_DATE)
THEN 1
WHEN EXTRACT(MONTH FROM T0."DocDate") BETWEEN 10 AND 12
AND EXTRACT(YEAR FROM T0."DocDate") = EXTRACT(YEAR FROM CURRENT_DATE) - 1
THEN 1
ELSE 0
END = 1
UNION
SELECT 'N' "Exercice",'Avoir' "Type de doc", T1."DocNum", T1."DocDate", T1."CardCode", T1."CardName",T3."SlpName",T7."ItemCode",T7."ItmsGrpCod",T9."ItmsGrpNam",T5."LineNum",CASE
WHEN coalesce(T1."DiscPrcnt",0) = 0 then -T5."LineTotal"
ELSE -(T5."LineTotal" - (T5."LineTotal" * T1."DiscPrcnt" /100))
END "CA HT Récurrent",0 "CA HT Prestation",0 "CA HT One Shot"
FROM ORIN T1
LEFT JOIN OSLP T3 ON T3."SlpCode"=T1."SlpCode"
LEFT JOIN RIN1 T5 ON T5."DocEntry"=T1."DocEntry"
LEFT JOIN OITM T7 ON T7."ItemCode"=T5."ItemCode"
LEFT JOIN OITB T9 ON T9."ItmsGrpCod"=T7."ItmsGrpCod"
WHERE T1."CANCELED" ='N' and T5."LineTotal"<>0 and T9."ItmsGrpNam" IS NOT NULL AND T9."U_OSTYPECOMM" = 'Rec' AND CASE WHEN EXTRACT(MONTH FROM T1."DocDate") BETWEEN 01 and 09
AND EXTRACT(YEAR FROM T1."DocDate") = EXTRACT(YEAR FROM CURRENT_DATE)
THEN 1
WHEN EXTRACT(MONTH FROM T1."DocDate") BETWEEN 10 AND 12
AND EXTRACT(YEAR FROM T1."DocDate") = EXTRACT(YEAR FROM CURRENT_DATE) - 1
THEN 1
ELSE 0
END = 1
UNION
SELECT 'N' "Exercice",'Facture' "Type de doc",T0."DocNum",T0."DocDate", T0."CardCode", T0."CardName", T2."SlpName",T6."ItemCode",T6."ItmsGrpCod", T8."ItmsGrpNam",T4."LineNum",0 "CA HT Récurrent",CASE
WHEN coalesce(T0."DiscPrcnt",0) = 0 then T4."LineTotal"
ELSE T4."LineTotal" - (T4."LineTotal" * T0."DiscPrcnt"/100)
END "CA HT Prestation",0 "CA HT One Shot"
FROM OINV T0
LEFT JOIN OSLP T2 ON T2."SlpCode" = T0."SlpCode"
LEFT JOIN INV1 T4 ON T4."DocEntry"=T0."DocEntry"
LEFT JOIN OITM T6 ON T6."ItemCode"=T4."ItemCode"
LEFT JOIN OITB T8 ON T8."ItmsGrpCod"=T6."ItmsGrpCod"
WHERE T0."CANCELED" = 'N' and T4."LineTotal"<>0 and T8."ItmsGrpNam" IS NOT NULL AND T8."U_OSTYPECOMM" = 'Pre'AND CASE WHEN EXTRACT(MONTH FROM T0."DocDate") BETWEEN 01 and 09
AND EXTRACT(YEAR FROM T0."DocDate") = EXTRACT(YEAR FROM CURRENT_DATE)
THEN 1
WHEN EXTRACT(MONTH FROM T0."DocDate") BETWEEN 10 AND 12
AND EXTRACT(YEAR FROM T0."DocDate") = EXTRACT(YEAR FROM CURRENT_DATE) - 1
THEN 1
ELSE 0
END = 1
UNION
SELECT 'N' "Exercice",'Avoir' "Type de doc", T1."DocNum", T1."DocDate", T1."CardCode", T1."CardName",T3."SlpName",T7."ItemCode",T7."ItmsGrpCod",T9."ItmsGrpNam",T5."LineNum",0 "CA HT Récurrent",CASE
WHEN coalesce(T1."DiscPrcnt",0) = 0 then -T5."LineTotal"
ELSE -(T5."LineTotal" - (T5."LineTotal" * T1."DiscPrcnt" /100))
END "CA HT Prestation",0 "CA HT One Shot"
FROM ORIN T1
LEFT JOIN OSLP T3 ON T3."SlpCode"=T1."SlpCode"
LEFT JOIN RIN1 T5 ON T5."DocEntry"=T1."DocEntry"
LEFT JOIN OITM T7 ON T7."ItemCode"=T5."ItemCode"
LEFT JOIN OITB T9 ON T9."ItmsGrpCod"=T7."ItmsGrpCod"
WHERE T1."CANCELED" ='N' and T5."LineTotal"<>0 and T9."ItmsGrpNam" IS NOT NULL AND T9."U_OSTYPECOMM" = 'Pre'AND CASE WHEN EXTRACT(MONTH FROM T1."DocDate") BETWEEN 01 and 09
AND EXTRACT(YEAR FROM T1."DocDate") = EXTRACT(YEAR FROM CURRENT_DATE)
THEN 1
WHEN EXTRACT(MONTH FROM T1."DocDate") BETWEEN 10 AND 12
AND EXTRACT(YEAR FROM T1."DocDate") = EXTRACT(YEAR FROM CURRENT_DATE) - 1
THEN 1
ELSE 0
END = 1
UNION
SELECT 'N' "Exercice",'Facture' "Type de doc",T0."DocNum",T0."DocDate", T0."CardCode", T0."CardName", T2."SlpName",T6."ItemCode",T6."ItmsGrpCod", T8."ItmsGrpNam",T4."LineNum",0 "CA HT Récurrent",0 "CA HT Prestation",CASE
WHEN coalesce(T0."DiscPrcnt",0) = 0 then T4."LineTotal"
ELSE T4."LineTotal" - (T4."LineTotal" * T0."DiscPrcnt"/100)
END "CA HT One Shot"
FROM OINV T0
LEFT JOIN OSLP T2 ON T2."SlpCode" = T0."SlpCode"
LEFT JOIN INV1 T4 ON T4."DocEntry"=T0."DocEntry"
LEFT JOIN OITM T6 ON T6."ItemCode"=T4."ItemCode"
LEFT JOIN OITB T8 ON T8."ItmsGrpCod"=T6."ItmsGrpCod"
WHERE T0."CANCELED" = 'N'and T4."LineTotal"<>0 and T8."ItmsGrpNam" IS NOT NULL AND T8."U_OSTYPECOMM" = 'Neg' AND CASE WHEN EXTRACT(MONTH FROM T0."DocDate") BETWEEN 01 and 09
AND EXTRACT(YEAR FROM T0."DocDate") = EXTRACT(YEAR FROM CURRENT_DATE)
THEN 1
WHEN EXTRACT(MONTH FROM T0."DocDate") BETWEEN 10 AND 12
AND EXTRACT(YEAR FROM T0."DocDate") = EXTRACT(YEAR FROM CURRENT_DATE) - 1
THEN 1
ELSE 0
END = 1
UNION
SELECT 'N' "Exercice",'Avoir' "Type de doc", T1."DocNum", T1."DocDate", T1."CardCode", T1."CardName",T3."SlpName",T7."ItemCode",T7."ItmsGrpCod",T9."ItmsGrpNam",T5."LineNum",0 "CA HT Récurrent",0 "CA HT Prestation",CASE
WHEN coalesce(T1."DiscPrcnt",0) = 0 then -T5."LineTotal"
ELSE -(T5."LineTotal" - (T5."LineTotal" * T1."DiscPrcnt" /100))
END "CA HT One Shot"
FROM ORIN T1
LEFT JOIN OSLP T3 ON T3."SlpCode"=T1."SlpCode"
LEFT JOIN RIN1 T5 ON T5."DocEntry"=T1."DocEntry"
LEFT JOIN OITM T7 ON T7."ItemCode"=T5."ItemCode"
LEFT JOIN OITB T9 ON T9."ItmsGrpCod"=T7."ItmsGrpCod"
WHERE T1."CANCELED" ='N' and T5."LineTotal"<>0 and T9."ItmsGrpNam" IS NOT NULL AND T9."U_OSTYPECOMM" = 'Neg' AND CASE WHEN EXTRACT(MONTH FROM T1."DocDate") BETWEEN 01 and 09
AND EXTRACT(YEAR FROM T1."DocDate") = EXTRACT(YEAR FROM CURRENT_DATE)
THEN 1
WHEN EXTRACT(MONTH FROM T1."DocDate") BETWEEN 10 AND 12
AND EXTRACT(YEAR FROM T1."DocDate") = EXTRACT(YEAR FROM CURRENT_DATE) - 1
THEN 1
ELSE 0
END = 1
) "DATA"
GROUP BY "DATA"."Exercice","DATA"."Type de doc","DATA"."DocNum","DATA"."DocDate", "DATA"."CardCode", "DATA"."CardName", "DATA"."SlpName","DATA"."ItemCode","DATA"."ItmsGrpCod", "DATA"."ItmsGrpNam","DATA"."LineNum"
ORDER BY "DATA"."DocDate" |
Partager