Aftersales_Rechnungen_neu.iqd 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. COGNOS QUERY
  2. STRUCTURE,1,1
  3. DATABASE,GC_LOCOSOFT
  4. DATASOURCENAME,C:\GlobalCube\System\LOCOSOFT\IQD\serv_teile\Aftersales_Rechnungen_neu.imr
  5. TITLE,Aftersales_Rechnungen_neu.imr
  6. BEGIN SQL
  7. select c254 as c1,
  8. c253 as c2,
  9. c252 as c3,
  10. c251 as c4,
  11. c250 as c5,
  12. c249 as c6,
  13. c248 as c7,
  14. c247 as c8,
  15. c246 as c9,
  16. c245 as c10,
  17. c244 as c11,
  18. c243 as c12,
  19. c242 as c13,
  20. c241 as c14,
  21. c240 as c15,
  22. c239 as c16,
  23. c238 as c17,
  24. c237 as c18,
  25. c236 as c19,
  26. c235 as c20,
  27. c234 as c21,
  28. c233 as c22,
  29. c232 as c23,
  30. c231 as c24,
  31. c230 as c25,
  32. c229 as c26,
  33. c228 as c27,
  34. c227 as c28,
  35. c226 as c29,
  36. c225 as c30,
  37. c224 as c31,
  38. c223 as c32,
  39. c222 as c33,
  40. c221 as c34,
  41. c220 as c35,
  42. c219 as c36,
  43. c218 as c37,
  44. c217 as c38,
  45. c172 as c39,
  46. c216 as c40,
  47. c215 as c41,
  48. c214 as c42,
  49. c213 as c43,
  50. c212 as c44,
  51. c211 as c45,
  52. c210 as c46,
  53. c209 as c47,
  54. c208 as c48,
  55. c207 as c49,
  56. c206 as c50,
  57. c205 as c51,
  58. c204 as c52,
  59. c203 as c53,
  60. c202 as c54,
  61. c201 as c55,
  62. c200 as c56,
  63. c199 as c57,
  64. c198 as c58,
  65. c197 as c59,
  66. c196 as c60,
  67. c195 as c61,
  68. c194 as c62,
  69. c193 as c63,
  70. c192 as c64,
  71. c191 as c65,
  72. c190 as c66,
  73. c189 as c67,
  74. c188 as c68,
  75. c187 as c69,
  76. c186 as c70,
  77. c185 as c71,
  78. c184 as c72,
  79. c183 as c73,
  80. c182 as c74,
  81. c181 as c75,
  82. c158 as c76,
  83. c180 as c77,
  84. c179 as c78,
  85. c178 as c79,
  86. c177 as c80,
  87. c176 as c81,
  88. c175 as c82,
  89. c174 as c83,
  90. c173 as c84,
  91. c172 as c85,
  92. c171 as c86,
  93. c170 as c87,
  94. c169 as c88,
  95. c168 as c89,
  96. c167 as c90,
  97. c166 as c91,
  98. c165 as c92,
  99. c164 as c93,
  100. c163 as c94,
  101. c162 as c95,
  102. c161 as c96,
  103. c160 as c97,
  104. c159 as c98,
  105. c158 as c99,
  106. c157 as c100,
  107. c156 as c101,
  108. c155 as c102,
  109. c154 as c103,
  110. '' as c104,
  111. c153 as c105,
  112. c152 as c106,
  113. c151 as c107,
  114. c150 as c108,
  115. c149 as c109,
  116. c148 as c110,
  117. c149 as c111,
  118. c148 as c112,
  119. c147 as c113,
  120. (0) as c114,
  121. (0) as c115,
  122. (0) as c116,
  123. (0) as c117,
  124. (0) as c118,
  125. (0) as c119,
  126. (0) as c120,
  127. (0) as c121,
  128. (0) as c122,
  129. 1 as c123,
  130. XCOUNT(c254 for c141) as c124,
  131. 1 / (XCOUNT(c254 for c141)) as c125,
  132. c146 as c126,
  133. c141 as c127,
  134. c145 as c128,
  135. c144 as c129,
  136. '' as c130,
  137. '' as c131,
  138. '' as c132,
  139. '' as c133,
  140. '' as c134,
  141. '' as c135,
  142. c143 as c136,
  143. c142 as c137
  144. from
  145. (select (CASE WHEN ((CASE WHEN (T1."invoice_type" = 5) THEN (((od_left((cast_numberToString(cast_integer(T5."employee_number"))),4)) || ' - ' || T5."name")) ELSE (T10."Serviceberater") END) IS NOT NULL) THEN (((od_left((cast_numberToString(cast_integer(T1."invoice_type"))),1)) || (od_left((cast_numberToString(cast_integer(T1."invoice_number"))),9))) || ' - ' || (CASE WHEN (T1."invoice_type" = 5) THEN (((od_left((cast_numberToString(cast_integer(T5."employee_number"))),4)) || ' - ' || T5."name")) ELSE (T10."Serviceberater") END) || ' - ' || (CASE WHEN (T4."first_name" IS NULL) THEN ((od_left((cast_numberToString(cast_integer(T4."customer_number"))),7)) || ' - ' || T4."family_name") ELSE ((od_left((cast_numberToString(cast_integer(T4."customer_number"))),7)) || ' - ' || T4."first_name" || ' ' || T4."family_name") END)) ELSE (((od_left((cast_numberToString(cast_integer(T1."invoice_type"))),1)) || (od_left((cast_numberToString(cast_integer(T1."invoice_number"))),9))) || ' - ' || (CASE WHEN (T4."first_name" IS NULL) THEN ((od_left((cast_numberToString(cast_integer(T4."customer_number"))),7)) || ' - ' || T4."family_name") ELSE ((od_left((cast_numberToString(cast_integer(T4."customer_number"))),7)) || ' - ' || T4."first_name" || ' ' || T4."family_name") END)) END) as c141,
  146. CASE WHEN (T1."invoice_type" = 5) THEN (((od_left((cast_numberToString(cast_integer(T5."employee_number"))),4)) || ' - ' || T5."name")) ELSE (T10."Serviceberater") END as c142,
  147. T10."Serviceberater" as c143,
  148. CASE WHEN ((extract(DAY FROM (now()) - ((cdatetime(T1."invoice_date"))))) <= 4) THEN ((CASE WHEN ((CASE WHEN (T1."invoice_type" = 5) THEN (((od_left((cast_numberToString(cast_integer(T5."employee_number"))),4)) || ' - ' || T5."name")) ELSE (T10."Serviceberater") END) IS NOT NULL) THEN (((od_left((cast_numberToString(cast_integer(T1."invoice_type"))),1)) || (od_left((cast_numberToString(cast_integer(T1."invoice_number"))),9))) || ' - ' || (CASE WHEN (T1."invoice_type" = 5) THEN (((od_left((cast_numberToString(cast_integer(T5."employee_number"))),4)) || ' - ' || T5."name")) ELSE (T10."Serviceberater") END) || ' - ' || (CASE WHEN (T4."first_name" IS NULL) THEN ((od_left((cast_numberToString(cast_integer(T4."customer_number"))),7)) || ' - ' || T4."family_name") ELSE ((od_left((cast_numberToString(cast_integer(T4."customer_number"))),7)) || ' - ' || T4."first_name" || ' ' || T4."family_name") END)) ELSE (((od_left((cast_numberToString(cast_integer(T1."invoice_type"))),1)) || (od_left((cast_numberToString(cast_integer(T1."invoice_number"))),9))) || ' - ' || (CASE WHEN (T4."first_name" IS NULL) THEN ((od_left((cast_numberToString(cast_integer(T4."customer_number"))),7)) || ' - ' || T4."family_name") ELSE ((od_left((cast_numberToString(cast_integer(T4."customer_number"))),7)) || ' - ' || T4."first_name" || ' ' || T4."family_name") END)) END)) ELSE null END as c144,
  149. (cdatetime(T1."invoice_date")) as c145,
  150. (od_left((od_left((cast_numberToString(cast_integer(T1."vehicle_number"))),5)) || ' - ' || T9."description",100)) as c146,
  151. (od_left((ucase(T9."description")),3)) as c147,
  152. T9."description" as c148,
  153. T8."description" as c149,
  154. T7."free_form_model_text" as c150,
  155. T7."model_code" as c151,
  156. T7."free_form_make_text" as c152,
  157. T7."make_number" as c153,
  158. CASE WHEN (T1."invoice_type" = 5) THEN ('Teile') ELSE ('Service') END as c154,
  159. CASE WHEN (T1."invoice_type" = 6) THEN ('GWL') WHEN ((T1."invoice_type" = 4) or (T4."customer_number" IN (1000000,1000001,1000002,1000003,1000010))) THEN ('intern') ELSE ('extern') END as c155,
  160. (od_left(((rtrim((cast_numberToString(cast_integer(T3."skr51_cost_center"))))) || ' - ' || T6."skr51_cost_center_name"),1)) as c156,
  161. (rtrim((cast_numberToString(cast_integer(T3."skr51_sales_channel"))))) || ' - ' || T6."skr51_sales_channel_name" as c157,
  162. T3."skr51_make" as c158,
  163. (rtrim((cast_numberToString(cast_integer(T3."skr51_cost_center"))))) || ' - ' || T6."skr51_cost_center_name" as c159,
  164. CASE WHEN (T3."debit_or_credit" = 'H') THEN (((cast_float(T3."posted_value"))) / 100 * -1) ELSE (((cast_float(T3."posted_value"))) / 100) END as c160,
  165. CASE WHEN (T4."first_name" IS NULL) THEN ((od_left((cast_numberToString(cast_integer(T4."customer_number"))),7)) || ' - ' || T4."family_name") ELSE ((od_left((cast_numberToString(cast_integer(T4."customer_number"))),7)) || ' - ' || T4."first_name" || ' ' || T4."family_name") END as c161,
  166. T4."family_name" as c162,
  167. T4."first_name" as c163,
  168. T4."customer_number" as c164,
  169. (od_left((cast_numberToString(cast_integer(T5."employee_number"))),4)) || ' - ' || T5."name" as c165,
  170. T5."is_master_craftsman" as c166,
  171. T5."is_business_executive" as c167,
  172. T5."salesman_number" as c168,
  173. T5."mechanic_number" as c169,
  174. T5."name" as c170,
  175. T5."employee_number" as c171,
  176. T3."accounting_date" as c172,
  177. (cast_numberToString(cast_integer(T3."branch_number"))) as c173,
  178. T3."subsidiary_to_company_ref" as c174,
  179. CASE WHEN (T3."skr51_cost_unit" BETWEEN 1 AND 49) THEN ('Neuwagen') WHEN (T3."skr51_cost_unit" BETWEEN 50 AND 59) THEN ('Gebrauchtwagen') WHEN (T3."skr51_cost_unit" BETWEEN 60 AND 69) THEN ('Teile & Zubehör') WHEN (T3."skr51_cost_unit" BETWEEN 70 AND 79) THEN ('Service') WHEN (T3."skr51_cost_unit" = 0) THEN ('Ohne Kostenträger') ELSE null END as c175,
  180. T4."zip_code" as c176,
  181. T3."previously_used_account_no" as c177,
  182. T3."skr51_cost_unit" as c178,
  183. T3."skr51_sales_channel" as c179,
  184. T3."skr51_cost_center" as c180,
  185. T3."skr51_branch" as c181,
  186. T3."day_of_actual_accounting" as c182,
  187. T3."days_for_cash_discount" as c183,
  188. T3."vat_key" as c184,
  189. T3."account_statement_page" as c185,
  190. T3."account_statement_number" as c186,
  191. T3."vat_id_number" as c187,
  192. T3."vehicle_reference" as c188,
  193. T3."posting_text" as c189,
  194. T3."term_of_payment" as c190,
  195. T3."cash_discount" as c191,
  196. T3."journal_line" as c192,
  197. T3."journal_page" as c193,
  198. T3."last_dunning_date" as c194,
  199. T3."dunning_level" as c195,
  200. T3."invoice_number" as c196,
  201. T3."invoice_date" as c197,
  202. T3."employee_number" as c198,
  203. T3."serial_number_each_month" as c199,
  204. T3."account_form_page_line" as c200,
  205. T3."account_form_page_number" as c201,
  206. CASE WHEN (T3."nominal_account_number" = 5701) THEN ((rtrim((cast_numberToString(cast_integer(T3."nominal_account_number"))))) || '_' || (rtrim((cast_numberToString(cast_integer(T3."skr51_cost_center")))))) ELSE ((rtrim((cast_numberToString(cast_integer(T3."nominal_account_number")))))) END as c202,
  207. T3."nominal_contra_account" as c203,
  208. T3."customer_contra_account" as c204,
  209. T3."branch_number" as c205,
  210. T3."posted_count" as c206,
  211. T3."debit_or_credit" as c207,
  212. (cast_float(T3."posted_value")) as c208,
  213. T3."document_date" as c209,
  214. T3."clearing_number" as c210,
  215. T3."is_balanced" as c211,
  216. T3."nominal_account_number" as c212,
  217. T3."customer_number" as c213,
  218. T3."position_in_document" as c214,
  219. T3."document_number" as c215,
  220. T3."document_type" as c216,
  221. (od_left((cast_numberToString(cast_integer(T1."invoice_type"))),1)) || (od_left((cast_numberToString(cast_integer(T1."invoice_number"))),9)) as c217,
  222. T1."total_net" as c218,
  223. T1."total_gross" as c219,
  224. T1."part_disposal" as c220,
  225. T1."part_rebate" as c221,
  226. T1."part_amount_gross" as c222,
  227. T1."part_amount_net" as c223,
  228. T1."job_rebate" as c224,
  229. T1."job_amount_gross" as c225,
  230. T1."job_amount_net" as c226,
  231. T1."used_part_vat_value" as c227,
  232. T1."reduced_vat_value" as c228,
  233. T1."reduced_vat_percentage" as c229,
  234. T1."reduced_vat_basevalue" as c230,
  235. T1."full_vat_value" as c231,
  236. T1."full_vat_percentage" as c232,
  237. T1."full_vat_basevalue" as c233,
  238. T1."vehicle_number" as c234,
  239. T1."internal_cost_account" as c235,
  240. T1."creating_employee" as c236,
  241. T1."odometer_reading" as c237,
  242. T1."credit_invoice_number" as c238,
  243. T1."credit_invoice_type" as c239,
  244. T1."is_credit" as c240,
  245. T1."is_own_vehicle" as c241,
  246. T1."cancelation_employee" as c242,
  247. T1."cancelation_date" as c243,
  248. T1."cancelation_number" as c244,
  249. T1."is_canceled" as c245,
  250. T1."service_date" as c246,
  251. T1."invoice_date" as c247,
  252. T1."order_customer" as c248,
  253. T1."paying_customer" as c249,
  254. T1."subsidiary" as c250,
  255. T1."invoice_number" as c251,
  256. T2."description" as c252,
  257. T2."type" as c253,
  258. T1."invoice_type" as c254
  259. from ((((((((("dbo"."invoices" T1 left outer join "dbo"."invoice_types" T2 on T2."type" = T1."invoice_type") left outer join "dbo"."journal_accountings" T3 on T3."invoice_number" = T1."invtype_invnr") left outer join "dbo"."customers_suppliers" T4 on T4."customer_number" = T1."paying_customer") left outer join "dbo"."employees" T5 on T1."creating_employee" = T5."employee_number") left outer join "dbo"."accounts_characteristics" T6 on (((((T6."skr51_branch" = T3."skr51_branch") and (T6."skr51_make" = T3."skr51_make")) and (T6."skr51_cost_center" = T3."skr51_cost_center")) and (T6."skr51_sales_channel" = T3."skr51_sales_channel")) and (T6."skr51_cost_unit" = T3."skr51_cost_unit")) and (T6."subsidiary_to_company_ref" = T3."subsidiary_to_company_ref")) left outer join "dbo"."vehicles" T7 on T1."vehicle_number" = T7."internal_number") left outer join "dbo"."makes" T8 on T7."make_number" = T8."make_number") left outer join "dbo"."models" T9 on (T7."make_number" = T9."make_number") and (T7."model_code" = T9."model_code")) left outer join QSS."C:\GlobalCube\System\LOCOSOFT\Catalogs\..\IQD\Serv_Teile\Serviceberater_Rechnung.ims" T10 on T1."invtype_invnr" = T10."invtype_invnr")
  260. where (((((T1."invoice_type" BETWEEN 2 AND 6) and ((od_left((cast_numberToString(cast_integer(T3."nominal_account_number"))),1)) IN ('4','5','7','8'))) and (T1."invoice_date" >= DATE '2019-01-01')) and (T1."is_canceled" <> 1)) and (((length((rtrim((cast_numberToString(cast_integer(T3."nominal_account_number"))))) || 'Z') - 1)) = 4))
  261. order by c141 asc,c215 asc,c214 asc,c217 asc
  262. ) D1
  263. END SQL
  264. COLUMN,0,Invoice Type
  265. COLUMN,1,Type_Invoice_Types
  266. COLUMN,2,Description_Invoice_Types
  267. COLUMN,3,Invoice Number
  268. COLUMN,4,Subsidiary
  269. COLUMN,5,Paying Customer
  270. COLUMN,6,Order Customer
  271. COLUMN,7,Invoice Date
  272. COLUMN,8,Service Date
  273. COLUMN,9,Is Canceled
  274. COLUMN,10,Cancelation Number
  275. COLUMN,11,Cancelation Date
  276. COLUMN,12,Cancelation Employee
  277. COLUMN,13,Is Own Vehicle
  278. COLUMN,14,Is Credit
  279. COLUMN,15,Credit Invoice Type
  280. COLUMN,16,Credit Invoice Number
  281. COLUMN,17,Odometer Reading
  282. COLUMN,18,Creating Employee
  283. COLUMN,19,Internal Cost Account
  284. COLUMN,20,Vehicle Number
  285. COLUMN,21,Full Vat Basevalue
  286. COLUMN,22,Full Vat Percentage
  287. COLUMN,23,Full Vat Value
  288. COLUMN,24,Reduced Vat Basevalue
  289. COLUMN,25,Reduced Vat Percentage
  290. COLUMN,26,Reduced Vat Value
  291. COLUMN,27,Used Part Vat Value
  292. COLUMN,28,Job Amount Net
  293. COLUMN,29,Job Amount Gross
  294. COLUMN,30,Job Rebate
  295. COLUMN,31,Part Amount Net
  296. COLUMN,32,Part Amount Gross
  297. COLUMN,33,Part Rebate
  298. COLUMN,34,Part Disposal
  299. COLUMN,35,Total Gross
  300. COLUMN,36,Total Net
  301. COLUMN,37,Inv_Type_Invoice_Number
  302. COLUMN,38,Accounting Date
  303. COLUMN,39,Document Type
  304. COLUMN,40,Document Number
  305. COLUMN,41,Position In Document
  306. COLUMN,42,Customer Number
  307. COLUMN,43,Nominal Account Number
  308. COLUMN,44,Is Balanced
  309. COLUMN,45,Clearing Number
  310. COLUMN,46,Document Date
  311. COLUMN,47,Posted Value
  312. COLUMN,48,Debit Or Credit
  313. COLUMN,49,Posted Count
  314. COLUMN,50,Branch Number
  315. COLUMN,51,Customer Contra Account
  316. COLUMN,52,Nominal Contra Account
  317. COLUMN,53,Contra Account Text
  318. COLUMN,54,Account Form Page Number
  319. COLUMN,55,Account Form Page Line
  320. COLUMN,56,Serial Number Each Month
  321. COLUMN,57,Employee Number
  322. COLUMN,58,Invoice Date_falsch
  323. COLUMN,59,Invoice Number
  324. COLUMN,60,Dunning Level
  325. COLUMN,61,Last Dunning Date
  326. COLUMN,62,Journal Page
  327. COLUMN,63,Journal Line
  328. COLUMN,64,Cash Discount
  329. COLUMN,65,Term Of Payment
  330. COLUMN,66,Posting Text
  331. COLUMN,67,Vehicle Reference
  332. COLUMN,68,Vat Id Number
  333. COLUMN,69,Account Statement Number
  334. COLUMN,70,Account Statement Page
  335. COLUMN,71,Vat Key
  336. COLUMN,72,Days For Cash Discount
  337. COLUMN,73,Day Of Actual Accounting
  338. COLUMN,74,Skr51 Branch
  339. COLUMN,75,Skr51 Make
  340. COLUMN,76,Skr51 Cost Center
  341. COLUMN,77,Skr51 Sales Channel
  342. COLUMN,78,Skr51 Cost Unit
  343. COLUMN,79,Previously Used Account No
  344. COLUMN,80,Free Form Accounting Text
  345. COLUMN,81,Free Form Document Text
  346. COLUMN,82,Hauptbetrieb
  347. COLUMN,83,Standort
  348. COLUMN,84,Invoice Date_accounting
  349. COLUMN,85,Employee Number_Employees
  350. COLUMN,86,Name_Employees
  351. COLUMN,87,Mechanic Number_Employees
  352. COLUMN,88,Salesman Number_Employees
  353. COLUMN,89,Is Business Executive_Employees
  354. COLUMN,90,Is Master Craftsman_Employees
  355. COLUMN,91,Serviceberater_Rg_Steller
  356. COLUMN,92,Customer Number_Customers_Suppliers
  357. COLUMN,93,First Name_Customers_Suppliers
  358. COLUMN,94,Family Name_Customers_Suppliers
  359. COLUMN,95,Kunde
  360. COLUMN,96,Betrag
  361. COLUMN,97,Kostenstelle
  362. COLUMN,98,Marke
  363. COLUMN,99,Kundenart
  364. COLUMN,100,KST_1_Stelle
  365. COLUMN,101,Umsatzart
  366. COLUMN,102,Auftragsart
  367. COLUMN,103,Geschäftsart
  368. COLUMN,104,Make Number
  369. COLUMN,105,Free Form Make Text
  370. COLUMN,106,Model Code
  371. COLUMN,107,Free Form Model Text
  372. COLUMN,108,Description_Makes
  373. COLUMN,109,Description_Models
  374. COLUMN,110,Fabrikat
  375. COLUMN,111,Model_Detail
  376. COLUMN,112,Model
  377. COLUMN,113,Umsatz Lohn
  378. COLUMN,114,Umsatz FL
  379. COLUMN,115,Einsatz FL
  380. COLUMN,116,Umsatz Teile
  381. COLUMN,117,Einsatz Teile
  382. COLUMN,118,Umsatz MW
  383. COLUMN,119,Einsatz MW
  384. COLUMN,120,Umsatz Sonst.
  385. COLUMN,121,Einsatz Sonst.
  386. COLUMN,122,DG_1
  387. COLUMN,123,DG_2
  388. COLUMN,124,DG
  389. COLUMN,125,Fahrzeug
  390. COLUMN,126,Order Number
  391. COLUMN,127,Invoice_Date_Uhrzeit
  392. COLUMN,128,Order Number_Rg_Ausg
  393. COLUMN,129,Konto Nr
  394. COLUMN,130,Konto Bezeichnung
  395. COLUMN,131,Ebene1
  396. COLUMN,132,Ebene2
  397. COLUMN,133,Ebene3
  398. COLUMN,134,Ebene4
  399. COLUMN,135,Serviceberater_order_pos
  400. COLUMN,136,Serviceberater