Belege_Autoline_History.sql 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. select T1."AccountCode" as "Accountcode",
  2. T1."CostCentre" as "Costcentre",
  3. T1."ExpenseCode" as "Expensecode",
  4. T1."NLPeriod" as "Nlperiod",
  5. T1."NLYear" as "Nlyear",
  6. T1."CurrencyType" as "Currencytype",
  7. T1."BroughtForward" as "Broughtforward",
  8. T1."CurrentPostings" as "Currentpostings",
  9. T1."FuturePostings" as "Futurepostings",
  10. T1."AdjustmentFlag" as "Adjustmentflag",
  11. T1."Adjustment" as "Adjustment",
  12. T1."GroupDrBroughtFwd" as "Groupdrbroughtfwd",
  13. T1."GroupCrBroughtFwd" as "Groupcrbroughtfwd",
  14. T1."GroupDrCurrent" as "Groupdrcurrent",
  15. T1."GroupCrCurrent" as "Groupcrcurrent",
  16. T1."GroupDrFuture" as "Groupdrfuture",
  17. T1."GroupCrFuture" as "Groupcrfuture",
  18. T1."GroupDrAdjustments" as "Groupdradjustments",
  19. T1."GroupCrAdjustments" as "Groupcradjustments",
  20. T1."Client_DB" as "Client Db",
  21. ((cinteger(nconvert(((rtrim((((T1."NLYear"))))) + (convert(varchar(50), round(T1."NLPeriod",0,0),2)) + '28')),0))) as "Bookkeep Date",
  22. T1."Client_DB" as "Rechtseinheit_ID",
  23. T2."Description002" as "Description002_Expense_Code_Kto_Bez",
  24. T2."AccountType" as "Accounttype_Expense_Code",
  25. T3."CostCentre" as "Costcentre_Department",
  26. T3."ShortName" as "Shortname_Department",
  27. T3."Description001" as "Description001_Department",
  28. T3."Description002" as "Description002_Department",
  29. T3."Description003" as "Description003_Department",
  30. T3."Description004" as "Description004_Department",
  31. T3."CostCentreGroup" as "Costcentregroup_Department",
  32. T4."CostCentreGroup" as "Costcentregroup_Costcentergr",
  33. T4."Description001" as "Description001_Costcentergr",
  34. T4."Description002" as "Description002_Costcentergr",
  35. T4."Description003" as "Description003_Costcentergr",
  36. T4."Description004" as "Description004_Costcentergr",
  37. T5."LocationCode" as "Locationcode_GB_company",
  38. T5."Description" as "Description_GB_company",
  39. T5."LocationName" as "Locationname_GB_company",
  40. '' as "Rechtseinheit_Name",
  41. T5."LocationCode" as "Standort_ID",
  42. T5."LocationCode" + ' - ' + T5."Description" as "Standort_Name",
  43. T1."ExpenseCode" as "Acct Nr",
  44. '' as "Text",
  45. T4."CostCentreGroup" + ' - ' + T4."Description002" as "Kostenstelle",
  46. (rtrim((((T3."CostCentre"))))) + ' - ' + T3."Description002" as "KST_Detail",
  47. (rtrim((((T1."NLYear"))))) + (convert(varchar(50), round(T1."NLPeriod",0,0),2)) + '28' as "Datum_Zeichen_alt",
  48. T1."CurrentPostings" as "Basevalue",
  49. (cinteger(nconvert(((rtrim((((T1."NLYear"))))) + (convert(varchar(50), round(T1."NLPeriod",0,0),2)) + '28')),0)) as "Datum_Zahl"
  50. from (((("AUTOLINE"."import"."NL_NominalAccountHistoryFile" T1 left outer join "AUTOLINE"."import"."NL_NominalExpenseCodes" T2 on (T1."ExpenseCode" = T2."ExpenseCode") and (T1."Client_DB" = T2."Client_DB")) left outer join "AUTOLINE"."import"."NL_NominalDepartmentCodes" T3 on (T1."CostCentre" = T3."CostCentre") and (T1."Client_DB" = T3."Client_DB")) left outer join "AUTOLINE"."import"."NL_DepartmentCodeGroups" T4 on (T3."CostCentreGroup" = T4."CostCentreGroup") and (T3."Client_DB" = T4."Client_DB")) left outer join "AUTOLINE"."import"."GB_CompanyLocations" T5 on (left((((T1."CostCentre"))),2)) = T5."LocationCode")
  51. where (((T2."AccountType" = 'P') and (not T3."CostCentreGroup" LIKE '9%')) and (T1."NLYear" > 2018))