Aftersales_Rechnungen_neu.iqd 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. COGNOS QUERY
  2. STRUCTURE,1,1
  3. DATABASE,Locosoft_GC
  4. DATASOURCENAME,C:\GlobalCube\System\LOCOSOFT\IQD\serv_teile\Aftersales_Rechnungen_neu.imr
  5. TITLE,Aftersales_Rechnungen_neu.imr
  6. BEGIN SQL
  7. select c253 as c1,
  8. c252 as c2,
  9. c251 as c3,
  10. c250 as c4,
  11. c249 as c5,
  12. c248 as c6,
  13. c247 as c7,
  14. c246 as c8,
  15. c245 as c9,
  16. c244 as c10,
  17. c243 as c11,
  18. c242 as c12,
  19. c241 as c13,
  20. c240 as c14,
  21. c239 as c15,
  22. c238 as c16,
  23. c237 as c17,
  24. c236 as c18,
  25. c235 as c19,
  26. c234 as c20,
  27. c233 as c21,
  28. c232 as c22,
  29. c231 as c23,
  30. c230 as c24,
  31. c229 as c25,
  32. c228 as c26,
  33. c227 as c27,
  34. c226 as c28,
  35. c225 as c29,
  36. c224 as c30,
  37. c223 as c31,
  38. c222 as c32,
  39. c221 as c33,
  40. c220 as c34,
  41. c219 as c35,
  42. c218 as c36,
  43. c217 as c37,
  44. c216 as c38,
  45. c172 as c39,
  46. c215 as c40,
  47. c214 as c41,
  48. c213 as c42,
  49. c212 as c43,
  50. c211 as c44,
  51. c210 as c45,
  52. c209 as c46,
  53. c208 as c47,
  54. c207 as c48,
  55. c206 as c49,
  56. c205 as c50,
  57. c204 as c51,
  58. c203 as c52,
  59. c202 as c53,
  60. c201 as c54,
  61. c200 as c55,
  62. c199 as c56,
  63. c198 as c57,
  64. c197 as c58,
  65. c196 as c59,
  66. c195 as c60,
  67. c194 as c61,
  68. c193 as c62,
  69. c192 as c63,
  70. c191 as c64,
  71. c190 as c65,
  72. c189 as c66,
  73. c188 as c67,
  74. c187 as c68,
  75. c186 as c69,
  76. c185 as c70,
  77. c184 as c71,
  78. c183 as c72,
  79. c182 as c73,
  80. c181 as c74,
  81. c180 as c75,
  82. c158 as c76,
  83. c179 as c77,
  84. c178 as c78,
  85. c177 as c79,
  86. c176 as c80,
  87. c175 as c81,
  88. c174 as c82,
  89. '1' 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(c253 for c141) as c124,
  131. 1 / (XCOUNT(c253 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. '0' || (cast_numberToString(cast_integer(T3."branch_number"))) as c173,
  178. 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 c174,
  179. T4."zip_code" as c175,
  180. T3."previously_used_account_no" as c176,
  181. T3."skr51_cost_unit" as c177,
  182. T3."skr51_sales_channel" as c178,
  183. T3."skr51_cost_center" as c179,
  184. T3."skr51_branch" as c180,
  185. T3."day_of_actual_accounting" as c181,
  186. T3."days_for_cash_discount" as c182,
  187. T3."vat_key" as c183,
  188. T3."account_statement_page" as c184,
  189. T3."account_statement_number" as c185,
  190. T3."vat_id_number" as c186,
  191. T3."vehicle_reference" as c187,
  192. T3."posting_text" as c188,
  193. T3."term_of_payment" as c189,
  194. T3."cash_discount" as c190,
  195. T3."journal_line" as c191,
  196. T3."journal_page" as c192,
  197. T3."last_dunning_date" as c193,
  198. T3."dunning_level" as c194,
  199. T3."invoice_number" as c195,
  200. T3."invoice_date" as c196,
  201. T3."employee_number" as c197,
  202. T3."serial_number_each_month" as c198,
  203. T3."account_form_page_line" as c199,
  204. T3."account_form_page_number" as c200,
  205. 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 c201,
  206. T3."nominal_contra_account" as c202,
  207. T3."customer_contra_account" as c203,
  208. T3."branch_number" as c204,
  209. T3."posted_count" as c205,
  210. T3."debit_or_credit" as c206,
  211. (cast_float(T3."posted_value")) as c207,
  212. T3."document_date" as c208,
  213. T3."clearing_number" as c209,
  214. T3."is_balanced" as c210,
  215. T3."nominal_account_number" as c211,
  216. T3."customer_number" as c212,
  217. T3."position_in_document" as c213,
  218. T3."document_number" as c214,
  219. T3."document_type" as c215,
  220. (od_left((cast_numberToString(cast_integer(T1."invoice_type"))),1)) || (od_left((cast_numberToString(cast_integer(T1."invoice_number"))),9)) as c216,
  221. T1."total_net" as c217,
  222. T1."total_gross" as c218,
  223. T1."part_disposal" as c219,
  224. T1."part_rebate" as c220,
  225. T1."part_amount_gross" as c221,
  226. T1."part_amount_net" as c222,
  227. T1."job_rebate" as c223,
  228. T1."job_amount_gross" as c224,
  229. T1."job_amount_net" as c225,
  230. T1."used_part_vat_value" as c226,
  231. T1."reduced_vat_value" as c227,
  232. T1."reduced_vat_percentage" as c228,
  233. T1."reduced_vat_basevalue" as c229,
  234. T1."full_vat_value" as c230,
  235. T1."full_vat_percentage" as c231,
  236. T1."full_vat_basevalue" as c232,
  237. T1."vehicle_number" as c233,
  238. T1."internal_cost_account" as c234,
  239. T1."creating_employee" as c235,
  240. T1."odometer_reading" as c236,
  241. T1."credit_invoice_number" as c237,
  242. T1."credit_invoice_type" as c238,
  243. T1."is_credit" as c239,
  244. T1."is_own_vehicle" as c240,
  245. T1."cancelation_employee" as c241,
  246. T1."cancelation_date" as c242,
  247. T1."cancelation_number" as c243,
  248. T1."is_canceled" as c244,
  249. T1."service_date" as c245,
  250. T1."invoice_date" as c246,
  251. T1."order_customer" as c247,
  252. T1."paying_customer" as c248,
  253. T1."subsidiary" as c249,
  254. T1."invoice_number" as c250,
  255. T2."description" as c251,
  256. T2."type" as c252,
  257. T1."invoice_type" as c253
  258. 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")
  259. 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))
  260. order by c141 asc,c214 asc,c213 asc,c216 asc
  261. ) D1
  262. END SQL
  263. COLUMN,0,Invoice Type
  264. COLUMN,1,Type_Invoice_Types
  265. COLUMN,2,Description_Invoice_Types
  266. COLUMN,3,Invoice Number
  267. COLUMN,4,Subsidiary
  268. COLUMN,5,Paying Customer
  269. COLUMN,6,Order Customer
  270. COLUMN,7,Invoice Date
  271. COLUMN,8,Service Date
  272. COLUMN,9,Is Canceled
  273. COLUMN,10,Cancelation Number
  274. COLUMN,11,Cancelation Date
  275. COLUMN,12,Cancelation Employee
  276. COLUMN,13,Is Own Vehicle
  277. COLUMN,14,Is Credit
  278. COLUMN,15,Credit Invoice Type
  279. COLUMN,16,Credit Invoice Number
  280. COLUMN,17,Odometer Reading
  281. COLUMN,18,Creating Employee
  282. COLUMN,19,Internal Cost Account
  283. COLUMN,20,Vehicle Number
  284. COLUMN,21,Full Vat Basevalue
  285. COLUMN,22,Full Vat Percentage
  286. COLUMN,23,Full Vat Value
  287. COLUMN,24,Reduced Vat Basevalue
  288. COLUMN,25,Reduced Vat Percentage
  289. COLUMN,26,Reduced Vat Value
  290. COLUMN,27,Used Part Vat Value
  291. COLUMN,28,Job Amount Net
  292. COLUMN,29,Job Amount Gross
  293. COLUMN,30,Job Rebate
  294. COLUMN,31,Part Amount Net
  295. COLUMN,32,Part Amount Gross
  296. COLUMN,33,Part Rebate
  297. COLUMN,34,Part Disposal
  298. COLUMN,35,Total Gross
  299. COLUMN,36,Total Net
  300. COLUMN,37,Inv_Type_Invoice_Number
  301. COLUMN,38,Accounting Date
  302. COLUMN,39,Document Type
  303. COLUMN,40,Document Number
  304. COLUMN,41,Position In Document
  305. COLUMN,42,Customer Number
  306. COLUMN,43,Nominal Account Number
  307. COLUMN,44,Is Balanced
  308. COLUMN,45,Clearing Number
  309. COLUMN,46,Document Date
  310. COLUMN,47,Posted Value
  311. COLUMN,48,Debit Or Credit
  312. COLUMN,49,Posted Count
  313. COLUMN,50,Branch Number
  314. COLUMN,51,Customer Contra Account
  315. COLUMN,52,Nominal Contra Account
  316. COLUMN,53,Contra Account Text
  317. COLUMN,54,Account Form Page Number
  318. COLUMN,55,Account Form Page Line
  319. COLUMN,56,Serial Number Each Month
  320. COLUMN,57,Employee Number
  321. COLUMN,58,Invoice Date_falsch
  322. COLUMN,59,Invoice Number
  323. COLUMN,60,Dunning Level
  324. COLUMN,61,Last Dunning Date
  325. COLUMN,62,Journal Page
  326. COLUMN,63,Journal Line
  327. COLUMN,64,Cash Discount
  328. COLUMN,65,Term Of Payment
  329. COLUMN,66,Posting Text
  330. COLUMN,67,Vehicle Reference
  331. COLUMN,68,Vat Id Number
  332. COLUMN,69,Account Statement Number
  333. COLUMN,70,Account Statement Page
  334. COLUMN,71,Vat Key
  335. COLUMN,72,Days For Cash Discount
  336. COLUMN,73,Day Of Actual Accounting
  337. COLUMN,74,Skr51 Branch
  338. COLUMN,75,Skr51 Make
  339. COLUMN,76,Skr51 Cost Center
  340. COLUMN,77,Skr51 Sales Channel
  341. COLUMN,78,Skr51 Cost Unit
  342. COLUMN,79,Previously Used Account No
  343. COLUMN,80,Free Form Accounting Text
  344. COLUMN,81,Free Form Document Text
  345. COLUMN,82,Hauptbetrieb
  346. COLUMN,83,Standort
  347. COLUMN,84,Invoice Date_accounting
  348. COLUMN,85,Employee Number_Employees
  349. COLUMN,86,Name_Employees
  350. COLUMN,87,Mechanic Number_Employees
  351. COLUMN,88,Salesman Number_Employees
  352. COLUMN,89,Is Business Executive_Employees
  353. COLUMN,90,Is Master Craftsman_Employees
  354. COLUMN,91,Serviceberater_Rg_Steller
  355. COLUMN,92,Customer Number_Customers_Suppliers
  356. COLUMN,93,First Name_Customers_Suppliers
  357. COLUMN,94,Family Name_Customers_Suppliers
  358. COLUMN,95,Kunde
  359. COLUMN,96,Betrag
  360. COLUMN,97,Kostenstelle
  361. COLUMN,98,Marke
  362. COLUMN,99,Kundenart
  363. COLUMN,100,KST_1_Stelle
  364. COLUMN,101,Umsatzart
  365. COLUMN,102,Auftragsart
  366. COLUMN,103,Geschäftsart
  367. COLUMN,104,Make Number
  368. COLUMN,105,Free Form Make Text
  369. COLUMN,106,Model Code
  370. COLUMN,107,Free Form Model Text
  371. COLUMN,108,Description_Makes
  372. COLUMN,109,Description_Models
  373. COLUMN,110,Fabrikat
  374. COLUMN,111,Model_Detail
  375. COLUMN,112,Model
  376. COLUMN,113,Umsatz Lohn
  377. COLUMN,114,Umsatz FL
  378. COLUMN,115,Einsatz FL
  379. COLUMN,116,Umsatz Teile
  380. COLUMN,117,Einsatz Teile
  381. COLUMN,118,Umsatz MW
  382. COLUMN,119,Einsatz MW
  383. COLUMN,120,Umsatz Sonst.
  384. COLUMN,121,Einsatz Sonst.
  385. COLUMN,122,DG_1
  386. COLUMN,123,DG_2
  387. COLUMN,124,DG
  388. COLUMN,125,Fahrzeug
  389. COLUMN,126,Order Number
  390. COLUMN,127,Invoice_Date_Uhrzeit
  391. COLUMN,128,Order Number_Rg_Ausg
  392. COLUMN,129,Konto Nr
  393. COLUMN,130,Konto Bezeichnung
  394. COLUMN,131,Ebene1
  395. COLUMN,132,Ebene2
  396. COLUMN,133,Ebene3
  397. COLUMN,134,Ebene4
  398. COLUMN,135,Serviceberater_order_pos
  399. COLUMN,136,Serviceberater