Belege_Autoline.sql 4.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. select T1."CostCentre" as "Costcentre",
  2. T1."ExpenseCode" as "Expensecode",
  3. T1."Suffix" as "Suffix",
  4. T1."AccountsModule" as "Accountsmodule",
  5. T1."DaybookNumber" as "Daybooknumber",
  6. T1."ItemNumber" as "Itemnumber",
  7. T1."PostingDate" as "Postingdate",
  8. T1."AccountsCompany" as "Accountscompany",
  9. T1."SLPLAccountCode" as "Slplaccountcode",
  10. T1."Period" as "Period",
  11. T1."JournalReference" as "Journalreference",
  12. T1."Narrative" as "Narrative",
  13. T1."Year" as "Year",
  14. T1."BaseValue" as "Basevalue",
  15. T1."CurrencyValue" as "Currencyvalue",
  16. T1."SequenceNumber" as "Sequencenumber",
  17. T1."Reconciled" as "Reconciled",
  18. T1."JournalType" as "Journaltype",
  19. T1."TransferBatch" as "Transferbatch",
  20. T1."GroupDrValue" as "Groupdrvalue",
  21. T1."GroupCrValue" as "Groupcrvalue",
  22. T1."CurrencyLogSerial" as "Currencylogserial",
  23. T1."SourceCompany" as "Sourcecompany",
  24. T1."StatementDate" as "Statementdate",
  25. T1."SourceModule" as "Sourcemodule",
  26. T1."VATCode" as "Vatcode",
  27. T1."LegalAnalytic" as "Legalanalytic",
  28. T1."LatinSequence" as "Latinsequence",
  29. T1."LatinSequenceLine" as "Latinsequenceline",
  30. T1."ReconciledDate" as "Reconcileddate",
  31. T1."ReconciledTime" as "Reconciledtime",
  32. T1."ReconciledUser" as "Reconcileduser",
  33. T1."ChequeValueDate" as "Chequevaluedate",
  34. T1."DocumentNumber" as "Documentnumber",
  35. T1."JournalClass" as "Journalclass",
  36. T1."JournalSeqType" as "Journalseqtype",
  37. T1."VATGroup" as "Vatgroup",
  38. T1."CustomerReference" as "Customerreference",
  39. T1."ReconciledReference" as "Reconciledreference",
  40. T1."CashFlowGroup" as "Cashflowgroup",
  41. T1."CashFlowCode" as "Cashflowcode",
  42. T1."ConsSourceCompany" as "Conssourcecompany",
  43. T1."ConsSourceDaybook" as "Conssourcedaybook",
  44. T1."BranchCode" as "Branchcode",
  45. T1."DocumentDate" as "Documentdate",
  46. T1."Client_DB" as "Client Db",
  47. T1."AccountCode" as "Accountcode",
  48. T1."PostingDate" as "Bookkeep Date",
  49. T1."Client_DB" as "Rechtseinheit_ID",
  50. T2."Description002" as "Description002_Expense_Code_Kto_Bez",
  51. T2."AccountType" as "Accounttype_Expense_Code",
  52. T3."CostCentre" as "Costcentre_Department",
  53. T3."ShortName" as "Shortname_Department",
  54. T3."Description001" as "Description001_Department",
  55. T3."Description002" as "Description002_Department",
  56. T3."Description003" as "Description003_Department",
  57. T3."Description004" as "Description004_Department",
  58. T3."CostCentreGroup" as "Costcentregroup_Department",
  59. T4."CostCentreGroup" as "Costcentregroup_Costcentergr",
  60. T4."Description001" as "Description001_Costcentergr",
  61. T4."Description002" as "Description002_Costcentergr",
  62. T4."Description003" as "Description003_Costcentergr",
  63. T4."Description004" as "Description004_Costcentergr",
  64. T5."LocationCode" as "Locationcode_GB_company",
  65. T5."Description" as "Description_GB_company",
  66. T5."LocationName" as "Locationname_GB_company",
  67. '' as "Rechtseinheit_Name",
  68. T5."LocationCode" as "Standort_ID",
  69. T5."LocationCode" + ' - ' + T5."Description" as "Standort_Name",
  70. T1."ExpenseCode" as "Acct Nr",
  71. CASE WHEN ((-1 * datediff(day, (getdate()), T1."PostingDate")) <= 180) THEN ((rtrim((((T1."DocumentNumber"))))) + ' - ' + T1."JournalClass" + ' - ' + T1."CustomerReference") ELSE ('Belege älter 180 Tage') END as "Text",
  72. T4."CostCentreGroup" + ' - ' + T4."Description002" as "Kostenstelle",
  73. (rtrim((((T3."CostCentre"))))) + ' - ' + T3."Description002" as "KST_Detail"
  74. from (((("AUTOLINE"."import"."NL_NominalTransactionFile" T1 left outer join "AUTOLINE"."import"."NL_NominalExpenseCodes" T2 on (T2."ExpenseCode" = T1."ExpenseCode") and (T2."Client_DB" = T1."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")
  75. where ((T2."AccountType" = 'P') and (not T3."CostCentreGroup" LIKE '9%'))
  76. -- order by "Suffix" asc