123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959 |
- SELECT "Accounting Date" AS "Accounting Date",
- "Document Type" AS "Document Type",
- "Document Number" AS "Document Number",
- "Position In Document" AS "Position In Document",
- "Nominal Account Number" AS "Nominal Account Number",
- "Customer Number" AS "Customer Number",
- "Is Balanced" AS "Is Balanced",
- "Clearing Number" AS "Clearing Number",
- "Document Date" AS "Document Date",
- "Posted Value" AS "Posted Value",
- "Debit Or Credit" AS "Debit Or Credit",
- "Posted Count" AS "Posted Count",
- "Branch Number" AS "Branch Number",
- "Customer Contra Account" AS "Customer Contra Account",
- "Nominal Contra Account" AS "Nominal Contra Account",
- "Contra Account Text" AS "Contra Account Text",
- "Account Form Page Number" AS "Account Form Page Number",
- "Account Form Page Line" AS "Account Form Page Line",
- "Serial Number Each Month" AS "Serial Number Each Month",
- "Employee Number" AS "Employee Number",
- "Invoice Date" AS "Invoice Date",
- "Invoice Number" AS "Invoice Number",
- "Dunning Level" AS "Dunning Level",
- "Last Dunning Date" AS "Last Dunning Date",
- "Journal Page" AS "Journal Page",
- "Journal Line" AS "Journal Line",
- "Cash Discount" AS "Cash Discount",
- "Term Of Payment" AS "Term Of Payment",
- "Posting Text" AS "Posting Text",
- "Vehicle Reference" AS "Vehicle Reference",
- "Vat Id Number" AS "Vat Id Number",
- "Account Statement Number" AS "Account Statement Number",
- "Account Statement Page" AS "Account Statement Page",
- "Vat Key" AS "Vat Key",
- "Days For Cash Discount" AS "Days For Cash Discount",
- "Day Of Actual Accounting" AS "Day Of Actual Accounting",
- "Skr51 Branch" AS "Skr51 Branch",
- "Skr51 Make" AS "Skr51 Make",
- "Skr51 Cost Center" AS "Skr51 Cost Center",
- "Skr51 Sales Channel" AS "Skr51 Sales Channel",
- "Skr51 Cost Unit" AS "Skr51 Cost Unit",
- "Previously Used Account No" AS "Previously Used Account No",
- "Free Form Accounting Text" AS "Free Form Accounting Text",
- "Free Form Document Text" AS "Free Form Document Text",
- "Rechtseinheit" AS "Rechtseinheit",
- "Betrieb" AS "Betrieb",
- "Bookkeep Date" AS "Bookkeep Date",
- "Text" AS "Text",
- "Mandant" AS "Mandant",
- "Betrag" AS "Betrag",
- "Menge" AS "Menge",
- "Acct Nr" AS "Acct Nr",
- "Customer Number_suctomer_supplier" AS "Customer Number_suctomer_supplier",
- "Is Supplier" AS "Is Supplier",
- "First Name" AS "First Name",
- "Family Name" AS "Family Name",
- "Document Type In Journal" AS "Document Type In Journal",
- "Document Type Description" AS "Document Type Description",
- SUM("Betrag") OVER (PARTITION BY "Customer Number_suctomer_supplier") AS "Debitorsaldo",
- "Invoice Type_Invoices" AS "Invoice Type_Invoices",
- "Invoice Number_Invoices" AS "Invoice Number_Invoices",
- "Subsidiary_Invoices" AS "Subsidiary_Invoices",
- "Invoice Date_Invoices" AS "Invoice Date_Invoices",
- "Hauptbetrieb" AS "Hauptbetrieb",
- "Standort_ori" AS "Standort_ori",
- "Sel Name" AS "Sel Name",
- "OP-Saldo_" AS "OP-Saldo_",
- "Kostenstelle" AS "Kostenstelle",
- "Tage" AS "Tage",
- "Staffel" AS "Staffel",
- "Kunde" AS "Kunde",
- "Beleg" AS "Beleg",
- "Employee Number_Employees_journal_accountings" AS "Employee Number_Employees_journal_accountings",
- "Name_Employees_journal_accountings" AS "Name_Employees_journal_accountings",
- "Anzahl_Stellen_Invoice_Number" AS "Anzahl_Stellen_Invoice_Number",
- "Forderungsart_aus_erste_Stelle_Inv_Number" AS "Forderungsart_aus_erste_Stelle_Inv_Number",
- "Forderungsart" AS "Forderungsart",
- "Standort_aus_2_Stelle_Invoice_Number" AS "Standort_aus_2_Stelle_Invoice_Number",
- "Standort" AS "Standort"
- FROM (
- SELECT "Accounting Date",
- "Document Type",
- "Document Number",
- "Position In Document",
- "Nominal Account Number",
- "Customer Number",
- "Is Balanced",
- "Clearing Number",
- "Document Date",
- "Posted Value",
- "Debit Or Credit",
- "Posted Count",
- "Branch Number",
- "Customer Contra Account",
- "Nominal Contra Account",
- "Contra Account Text",
- "Account Form Page Number",
- "Account Form Page Line",
- "Serial Number Each Month",
- "Employee Number",
- "Invoice Date",
- "Invoice Number",
- "Dunning Level",
- "Last Dunning Date",
- "Journal Page",
- "Journal Line",
- "Cash Discount",
- "Term Of Payment",
- "Posting Text",
- "Vehicle Reference",
- "Vat Id Number",
- "Account Statement Number",
- "Account Statement Page",
- "Vat Key",
- "Days For Cash Discount",
- "Day Of Actual Accounting",
- "Skr51 Branch",
- "Skr51 Make",
- "Skr51 Cost Center",
- "Skr51 Sales Channel",
- "Skr51 Cost Unit",
- "Previously Used Account No",
- "Free Form Accounting Text",
- "Free Form Document Text",
- '1' AS "Rechtseinheit",
- "Betrieb",
- "Accounting Date" AS "Bookkeep Date",
- "Text",
- '1' AS "Mandant",
- "Betrag",
- "Menge",
- "Nominal Account Number" AS "Acct Nr",
- "Customer Number_suctomer_supplier",
- "Is Supplier",
- "First Name",
- "Family Name",
- "Document Type In Journal",
- "Document Type Description",
- "Invoice Type_Invoices",
- "Invoice Number_Invoices",
- "Subsidiary_Invoices",
- "Invoice Date_Invoices",
- "Hauptbetrieb",
- "Standort_ori",
- "Sel Name",
- "Betrag" AS "OP-Saldo_",
- "Kostenstelle",
- "Tage",
- "Staffel",
- "Kunde",
- "Beleg",
- "Employee Number_Employees_journal_accountings",
- "Name_Employees_journal_accountings",
- "Anzahl_Stellen_Invoice_Number",
- "Forderungsart_aus_erste_Stelle_Inv_Number",
- "Forderungsart",
- "Standort_aus_2_Stelle_Invoice_Number",
- "Betrieb" AS "Standort",
- SUM("Betrag") OVER (PARTITION BY "Customer Number_suctomer_supplier") AS c80
- FROM (
- SELECT T3."customer_number" AS "Customer Number_suctomer_supplier",
- ('0' + (((T1."branch_number")))) AS "Betrieb",
- CASE
- WHEN (
- (
- (
- (
- len((
- CASE
- WHEN (
- (T1."invoice_number" IS NULL)
- OR (T1."invoice_number" = ' ')
- )
- THEN (' - ')
- ELSE (T1."invoice_number")
- END
- ))
- )
- ) = 7
- )
- AND (
- (
- substring((
- CASE
- WHEN (
- (T1."invoice_number" IS NULL)
- OR (T1."invoice_number" = ' ')
- )
- THEN (' - ')
- ELSE (T1."invoice_number")
- END
- ), 2, 1)
- ) BETWEEN '1' AND '4'
- )
- )
- THEN (
- '0' + (
- substring((
- CASE
- WHEN (
- (T1."invoice_number" IS NULL)
- OR (T1."invoice_number" = ' ')
- )
- THEN (' - ')
- ELSE (T1."invoice_number")
- END
- ), 2, 1)
- )
- )
- ELSE NULL
- END AS "Standort_aus_2_Stelle_Invoice_Number",
- CASE
- WHEN (
- (
- CASE
- WHEN (T5."invoice_type" IN (2, 4, 6, 3))
- THEN ('3')
- WHEN (T5."invoice_type" IN (5))
- THEN ('6')
- WHEN (T5."invoice_type" IN (7))
- THEN ('1')
- WHEN (T5."invoice_type" IN (8))
- THEN ('2')
- WHEN (T4."document_type_in_journal" = 'R')
- THEN ('7')
- ELSE NULL
- END
- ) = '1'
- )
- THEN ('Neuwagen')
- WHEN (
- (
- CASE
- WHEN (T5."invoice_type" IN (2, 4, 6, 3))
- THEN ('3')
- WHEN (T5."invoice_type" IN (5))
- THEN ('6')
- WHEN (T5."invoice_type" IN (7))
- THEN ('1')
- WHEN (T5."invoice_type" IN (8))
- THEN ('2')
- WHEN (T4."document_type_in_journal" = 'R')
- THEN ('7')
- ELSE NULL
- END
- ) = '2'
- )
- THEN ('Gebrauchtwagen')
- WHEN (
- (
- CASE
- WHEN (T5."invoice_type" IN (2, 4, 6, 3))
- THEN ('3')
- WHEN (T5."invoice_type" IN (5))
- THEN ('6')
- WHEN (T5."invoice_type" IN (7))
- THEN ('1')
- WHEN (T5."invoice_type" IN (8))
- THEN ('2')
- WHEN (T4."document_type_in_journal" = 'R')
- THEN ('7')
- ELSE NULL
- END
- ) = '3'
- )
- THEN ('Service')
- WHEN (
- (
- CASE
- WHEN (T5."invoice_type" IN (2, 4, 6, 3))
- THEN ('3')
- WHEN (T5."invoice_type" IN (5))
- THEN ('6')
- WHEN (T5."invoice_type" IN (7))
- THEN ('1')
- WHEN (T5."invoice_type" IN (8))
- THEN ('2')
- WHEN (T4."document_type_in_journal" = 'R')
- THEN ('7')
- ELSE NULL
- END
- ) = '6'
- )
- THEN ('Teile')
- ELSE ('nicht zuzuordnen')
- END AS "Forderungsart",
- CASE
- WHEN (
- (
- (
- (
- len((
- CASE
- WHEN (
- (T1."invoice_number" IS NULL)
- OR (T1."invoice_number" = ' ')
- )
- THEN (' - ')
- ELSE (T1."invoice_number")
- END
- ))
- )
- ) = 7
- )
- AND (
- (
- substring((
- CASE
- WHEN (
- (T1."invoice_number" IS NULL)
- OR (T1."invoice_number" = ' ')
- )
- THEN (' - ')
- ELSE (T1."invoice_number")
- END
- ), 1, 1)
- ) IN ('2', '3', '4')
- )
- )
- THEN ('Service')
- WHEN (
- (
- (
- (
- len((
- CASE
- WHEN (
- (T1."invoice_number" IS NULL)
- OR (T1."invoice_number" = ' ')
- )
- THEN (' - ')
- ELSE (T1."invoice_number")
- END
- ))
- )
- ) = 7
- )
- AND (
- (
- substring((
- CASE
- WHEN (
- (T1."invoice_number" IS NULL)
- OR (T1."invoice_number" = ' ')
- )
- THEN (' - ')
- ELSE (T1."invoice_number")
- END
- ), 1, 1)
- ) IN ('5')
- )
- )
- THEN ('Teile')
- WHEN (
- (
- (
- (
- len((
- CASE
- WHEN (
- (T1."invoice_number" IS NULL)
- OR (T1."invoice_number" = ' ')
- )
- THEN (' - ')
- ELSE (T1."invoice_number")
- END
- ))
- )
- ) = 7
- )
- AND (
- (
- substring((
- CASE
- WHEN (
- (T1."invoice_number" IS NULL)
- OR (T1."invoice_number" = ' ')
- )
- THEN (' - ')
- ELSE (T1."invoice_number")
- END
- ), 1, 1)
- ) IN ('6')
- )
- )
- THEN ('Garantie')
- WHEN (
- (
- (
- (
- len((
- CASE
- WHEN (
- (T1."invoice_number" IS NULL)
- OR (T1."invoice_number" = ' ')
- )
- THEN (' - ')
- ELSE (T1."invoice_number")
- END
- ))
- )
- ) = 7
- )
- AND (
- (
- substring((
- CASE
- WHEN (
- (T1."invoice_number" IS NULL)
- OR (T1."invoice_number" = ' ')
- )
- THEN (' - ')
- ELSE (T1."invoice_number")
- END
- ), 1, 1)
- ) IN ('7')
- )
- )
- THEN ('Neuwagen')
- WHEN (
- (
- (
- (
- len((
- CASE
- WHEN (
- (T1."invoice_number" IS NULL)
- OR (T1."invoice_number" = ' ')
- )
- THEN (' - ')
- ELSE (T1."invoice_number")
- END
- ))
- )
- ) = 7
- )
- AND (
- (
- substring((
- CASE
- WHEN (
- (T1."invoice_number" IS NULL)
- OR (T1."invoice_number" = ' ')
- )
- THEN (' - ')
- ELSE (T1."invoice_number")
- END
- ), 1, 1)
- ) IN ('8')
- )
- )
- THEN ('Gebrauchtwagen')
- WHEN (T1."document_type" = 'R')
- THEN ('Rent')
- ELSE ('nicht zuzuordnen')
- END AS "Forderungsart_aus_erste_Stelle_Inv_Number",
- (
- len((
- CASE
- WHEN (
- (T1."invoice_number" IS NULL)
- OR (T1."invoice_number" = ' ')
- )
- THEN (' - ')
- ELSE (T1."invoice_number")
- END
- ))
- ) AS "Anzahl_Stellen_Invoice_Number",
- T2."name" AS "Name_Employees_journal_accountings",
- T2."employee_number" AS "Employee Number_Employees_journal_accountings",
- (
- (
- CASE
- WHEN (
- (T1."posting_text" IS NULL)
- OR (T1."posting_text" = ' ')
- )
- THEN (' - ')
- ELSE (T1."posting_text")
- END
- ) + '/' + (
- CASE
- WHEN (
- (T1."vehicle_reference" IS NULL)
- OR (T1."vehicle_reference" = ' ')
- )
- THEN (' - ')
- ELSE (T1."vehicle_reference")
- END
- )
- ) AS "Beleg",
- CASE
- WHEN (T3."first_name" IS NOT NULL)
- THEN ((left((((T3."customer_number"))), 7)) + ' - ' + T3."first_name" + ' ' + T3."family_name")
- ELSE ((left((((T3."customer_number"))), 7)) + ' ' + T3."family_name")
- END AS "Kunde",
- CASE
- WHEN (((- 1 * datediff(day, (getdate()), (convert(DATETIME, T1."accounting_date"))))) BETWEEN 0 AND 14)
- THEN ('< 2 Wochen')
- WHEN (((- 1 * datediff(day, (getdate()), (convert(DATETIME, T1."accounting_date"))))) BETWEEN 15 AND 28)
- THEN ('2 - 4 Wochen')
- WHEN (((- 1 * datediff(day, (getdate()), (convert(DATETIME, T1."accounting_date"))))) BETWEEN 29 AND 42)
- THEN ('4 - 6 Wochen')
- WHEN (((- 1 * datediff(day, (getdate()), (convert(DATETIME, T1."accounting_date"))))) BETWEEN 43 AND 84)
- THEN ('6 - 12 Wochen')
- WHEN (((- 1 * datediff(day, (getdate()), (convert(DATETIME, T1."accounting_date"))))) > 84)
- THEN ('> 12 Wochen')
- ELSE NULL
- END AS "Staffel",
- (- 1 * datediff(day, (getdate()), (convert(DATETIME, T1."accounting_date")))) AS "Tage",
- CASE
- WHEN (T5."invoice_type" IN (2, 4, 6, 3))
- THEN ('3')
- WHEN (T5."invoice_type" IN (5))
- THEN ('6')
- WHEN (T5."invoice_type" IN (7))
- THEN ('1')
- WHEN (T5."invoice_type" IN (8))
- THEN ('2')
- WHEN (T4."document_type_in_journal" = 'R')
- THEN ('7')
- ELSE NULL
- END AS "Kostenstelle",
- (
- CASE
- WHEN (T1."debit_or_credit" = 'H')
- THEN (T1."posted_value" / 100 * - 1)
- ELSE (T1."posted_value" / 100)
- END
- ) AS "Betrag",
- (left((((T2."employee_number"))), 4)) + ' - ' + T2."name" AS "Sel Name",
- CASE
- WHEN (T5."subsidiary" IS NOT NULL)
- THEN ('0' + (left((((T5."subsidiary"))), 1)))
- ELSE ('nicht zuzuordnen')
- END AS "Standort_ori",
- CASE
- WHEN ((('0' + (((T1."branch_number"))))) IN ('015 '))
- THEN ('15')
- ELSE ('1')
- END AS "Hauptbetrieb",
- T5."invoice_date" AS "Invoice Date_Invoices",
- T5."subsidiary" AS "Subsidiary_Invoices",
- T5."invoice_number" AS "Invoice Number_Invoices",
- T5."invoice_type" AS "Invoice Type_Invoices",
- T4."document_type_description" AS "Document Type Description",
- T4."document_type_in_journal" AS "Document Type In Journal",
- T3."family_name" AS "Family Name",
- T3."first_name" AS "First Name",
- T3."is_supplier" AS "Is Supplier",
- T1."nominal_account_number" AS "Nominal Account Number",
- CASE
- WHEN (T1."debit_or_credit" = 'H')
- THEN (T1."posted_count" / 100 * - 1)
- ELSE (T1."posted_count" / 100)
- END AS "Menge",
- CASE
- WHEN (
- (
- CASE
- WHEN (
- (T1."posting_text" IS NULL)
- OR (T1."posting_text" = ' ')
- )
- THEN (' - ')
- ELSE (T1."posting_text")
- END
- ) IS NOT NULL
- )
- THEN (
- (rtrim((convert(VARCHAR(50), ((T1."document_number")))))) + ' - ' + (
- CASE
- WHEN (
- (T1."posting_text" IS NULL)
- OR (T1."posting_text" = ' ')
- )
- THEN (' - ')
- ELSE (T1."posting_text")
- END
- ) + '/' + (
- CASE
- WHEN (
- (T1."vehicle_reference" IS NULL)
- OR (T1."vehicle_reference" = ' ')
- )
- THEN (' - ')
- ELSE (T1."vehicle_reference")
- END
- ) + ' - ' + ((left((((T2."employee_number"))))) + ' - ' + T2."name") + ' - ' + (convert(VARCHAR(50), year(T1."document_date")) + '-' + convert(VARCHAR(50), month(T1."document_date")) + '-' + convert(VARCHAR(50), day(T1."document_date")))
- )
- ELSE (
- (rtrim((convert(VARCHAR(50), ((T1."document_number")))))) + ' - ' + (
- CASE
- WHEN (
- (T1."vehicle_reference" IS NULL)
- OR (T1."vehicle_reference" = ' ')
- )
- THEN (' - ')
- ELSE (T1."vehicle_reference")
- END
- ) + ' - ' + ((left((((T2."employee_number"))))) + ' - ' + T2."name") + ' - ' + (convert(VARCHAR(50), year(T1."document_date")) + '-' + convert(VARCHAR(50), month(T1."document_date")) + '-' + convert(VARCHAR(50), day(T1."document_date")))
- )
- END AS "Text",
- T1."accounting_date" AS "Accounting Date",
- CASE
- WHEN (
- (
- (
- (
- (
- (
- CASE
- WHEN (
- (
- CASE
- WHEN (
- (T1."posting_text" IS NULL)
- OR (T1."posting_text" = ' ')
- )
- THEN (' - ')
- ELSE (T1."posting_text")
- END
- ) IS NOT NULL
- )
- THEN (
- (rtrim((convert(VARCHAR(50), ((T1."document_number")))))) + ' - ' + (
- CASE
- WHEN (
- (T1."posting_text" IS NULL)
- OR (T1."posting_text" = ' ')
- )
- THEN (' - ')
- ELSE (T1."posting_text")
- END
- ) + '/' + (
- CASE
- WHEN (
- (T1."vehicle_reference" IS NULL)
- OR (T1."vehicle_reference" = ' ')
- )
- THEN (' - ')
- ELSE (T1."vehicle_reference")
- END
- ) + ' - ' + ((left((((T2."employee_number"))))) + ' - ' + T2."name") + ' - ' + (convert(VARCHAR(50), year(T1."document_date")) + '-' + convert(VARCHAR(50), month(T1."document_date")) + '-' + convert(VARCHAR(50), day(T1."document_date")))
- )
- ELSE (
- (rtrim((convert(VARCHAR(50), ((T1."document_number")))))) + ' - ' + (
- CASE
- WHEN (
- (T1."vehicle_reference" IS NULL)
- OR (T1."vehicle_reference" = ' ')
- )
- THEN (' - ')
- ELSE (T1."vehicle_reference")
- END
- ) + ' - ' + ((left((((T2."employee_number"))))) + ' - ' + T2."name") + ' - ' + (convert(VARCHAR(50), year(T1."document_date")) + '-' + convert(VARCHAR(50), month(T1."document_date")) + '-' + convert(VARCHAR(50), day(T1."document_date")))
- )
- END
- ) LIKE '%RG-BONUS%'
- )
- OR (
- (
- CASE
- WHEN (
- (
- CASE
- WHEN (
- (T1."posting_text" IS NULL)
- OR (T1."posting_text" = ' ')
- )
- THEN (' - ')
- ELSE (T1."posting_text")
- END
- ) IS NOT NULL
- )
- THEN (
- (rtrim((convert(VARCHAR(50), ((T1."document_number")))))) + ' - ' + (
- CASE
- WHEN (
- (T1."posting_text" IS NULL)
- OR (T1."posting_text" = ' ')
- )
- THEN (' - ')
- ELSE (T1."posting_text")
- END
- ) + '/' + (
- CASE
- WHEN (
- (T1."vehicle_reference" IS NULL)
- OR (T1."vehicle_reference" = ' ')
- )
- THEN (' - ')
- ELSE (T1."vehicle_reference")
- END
- ) + ' - ' + ((left((((T2."employee_number"))))) + ' - ' + T2."name") + ' - ' + (convert(VARCHAR(50), year(T1."document_date")) + '-' + convert(VARCHAR(50), month(T1."document_date")) + '-' + convert(VARCHAR(50), day(T1."document_date")))
- )
- ELSE (
- (rtrim((convert(VARCHAR(50), ((T1."document_number")))))) + ' - ' + (
- CASE
- WHEN (
- (T1."vehicle_reference" IS NULL)
- OR (T1."vehicle_reference" = ' ')
- )
- THEN (' - ')
- ELSE (T1."vehicle_reference")
- END
- ) + ' - ' + ((left((((T2."employee_number"))))) + ' - ' + T2."name") + ' - ' + (convert(VARCHAR(50), year(T1."document_date")) + '-' + convert(VARCHAR(50), month(T1."document_date")) + '-' + convert(VARCHAR(50), day(T1."document_date")))
- )
- END
- ) LIKE '%GEBURTSTAGS%'
- )
- )
- OR (
- (
- CASE
- WHEN (
- (
- CASE
- WHEN (
- (T1."posting_text" IS NULL)
- OR (T1."posting_text" = ' ')
- )
- THEN (' - ')
- ELSE (T1."posting_text")
- END
- ) IS NOT NULL
- )
- THEN (
- (rtrim((convert(VARCHAR(50), ((T1."document_number")))))) + ' - ' + (
- CASE
- WHEN (
- (T1."posting_text" IS NULL)
- OR (T1."posting_text" = ' ')
- )
- THEN (' - ')
- ELSE (T1."posting_text")
- END
- ) + '/' + (
- CASE
- WHEN (
- (T1."vehicle_reference" IS NULL)
- OR (T1."vehicle_reference" = ' ')
- )
- THEN (' - ')
- ELSE (T1."vehicle_reference")
- END
- ) + ' - ' + ((left((((T2."employee_number"))))) + ' - ' + T2."name") + ' - ' + (convert(VARCHAR(50), year(T1."document_date")) + '-' + convert(VARCHAR(50), month(T1."document_date")) + '-' + convert(VARCHAR(50), day(T1."document_date")))
- )
- ELSE (
- (rtrim((convert(VARCHAR(50), ((T1."document_number")))))) + ' - ' + (
- CASE
- WHEN (
- (T1."vehicle_reference" IS NULL)
- OR (T1."vehicle_reference" = ' ')
- )
- THEN (' - ')
- ELSE (T1."vehicle_reference")
- END
- ) + ' - ' + ((left((((T2."employee_number"))))) + ' - ' + T2."name") + ' - ' + (convert(VARCHAR(50), year(T1."document_date")) + '-' + convert(VARCHAR(50), month(T1."document_date")) + '-' + convert(VARCHAR(50), day(T1."document_date")))
- )
- END
- ) LIKE '%STARTGUTHABEN%'
- )
- )
- OR (
- (
- CASE
- WHEN (
- (
- CASE
- WHEN (
- (T1."posting_text" IS NULL)
- OR (T1."posting_text" = ' ')
- )
- THEN (' - ')
- ELSE (T1."posting_text")
- END
- ) IS NOT NULL
- )
- THEN (
- (rtrim((convert(VARCHAR(50), ((T1."document_number")))))) + ' - ' + (
- CASE
- WHEN (
- (T1."posting_text" IS NULL)
- OR (T1."posting_text" = ' ')
- )
- THEN (' - ')
- ELSE (T1."posting_text")
- END
- ) + '/' + (
- CASE
- WHEN (
- (T1."vehicle_reference" IS NULL)
- OR (T1."vehicle_reference" = ' ')
- )
- THEN (' - ')
- ELSE (T1."vehicle_reference")
- END
- ) + ' - ' + ((left((((T2."employee_number"))))) + ' - ' + T2."name") + ' - ' + (convert(VARCHAR(50), year(T1."document_date")) + '-' + convert(VARCHAR(50), month(T1."document_date")) + '-' + convert(VARCHAR(50), day(T1."document_date")))
- )
- ELSE (
- (rtrim((convert(VARCHAR(50), ((T1."document_number")))))) + ' - ' + (
- CASE
- WHEN (
- (T1."vehicle_reference" IS NULL)
- OR (T1."vehicle_reference" = ' ')
- )
- THEN (' - ')
- ELSE (T1."vehicle_reference")
- END
- ) + ' - ' + ((left((((T2."employee_number"))))) + ' - ' + T2."name") + ' - ' + (convert(VARCHAR(50), year(T1."document_date")) + '-' + convert(VARCHAR(50), month(T1."document_date")) + '-' + convert(VARCHAR(50), day(T1."document_date")))
- )
- END
- ) LIKE '%BONUS F%'
- )
- )
- OR (
- (
- CASE
- WHEN (
- (
- CASE
- WHEN (
- (T1."posting_text" IS NULL)
- OR (T1."posting_text" = ' ')
- )
- THEN (' - ')
- ELSE (T1."posting_text")
- END
- ) IS NOT NULL
- )
- THEN (
- (rtrim((convert(VARCHAR(50), ((T1."document_number")))))) + ' - ' + (
- CASE
- WHEN (
- (T1."posting_text" IS NULL)
- OR (T1."posting_text" = ' ')
- )
- THEN (' - ')
- ELSE (T1."posting_text")
- END
- ) + '/' + (
- CASE
- WHEN (
- (T1."vehicle_reference" IS NULL)
- OR (T1."vehicle_reference" = ' ')
- )
- THEN (' - ')
- ELSE (T1."vehicle_reference")
- END
- ) + ' - ' + ((left((((T2."employee_number"))))) + ' - ' + T2."name") + ' - ' + (convert(VARCHAR(50), year(T1."document_date")) + '-' + convert(VARCHAR(50), month(T1."document_date")) + '-' + convert(VARCHAR(50), day(T1."document_date")))
- )
- ELSE (
- (rtrim((convert(VARCHAR(50), ((T1."document_number")))))) + ' - ' + (
- CASE
- WHEN (
- (T1."vehicle_reference" IS NULL)
- OR (T1."vehicle_reference" = ' ')
- )
- THEN (' - ')
- ELSE (T1."vehicle_reference")
- END
- ) + ' - ' + ((left((((T2."employee_number"))))) + ' - ' + T2."name") + ' - ' + (convert(VARCHAR(50), year(T1."document_date")) + '-' + convert(VARCHAR(50), month(T1."document_date")) + '-' + convert(VARCHAR(50), day(T1."document_date")))
- )
- END
- ) LIKE '%RG-ABZUG%'
- )
- )
- THEN ('Bonus/Startguthaben')
- ELSE ('ohne Bonus/Startguthaben')
- END AS "Free Form Document Text",
- T1."free_form_accounting_text" AS "Free Form Accounting Text",
- T1."previously_used_account_no" AS "Previously Used Account No",
- T1."skr51_cost_unit" AS "Skr51 Cost Unit",
- T1."skr51_sales_channel" AS "Skr51 Sales Channel",
- T1."skr51_cost_center" AS "Skr51 Cost Center",
- T1."skr51_make" AS "Skr51 Make",
- T1."skr51_branch" AS "Skr51 Branch",
- T1."day_of_actual_accounting" AS "Day Of Actual Accounting",
- (convert(VARCHAR(50), year(T1."accounting_date")) + '-' + convert(VARCHAR(50), month(T1."accounting_date")) + '-' + convert(VARCHAR(50), day(T1."accounting_date"))) AS "Days For Cash Discount",
- T1."vat_key" AS "Vat Key",
- T1."account_statement_page" AS "Account Statement Page",
- T1."account_statement_number" AS "Account Statement Number",
- T1."vat_id_number" AS "Vat Id Number",
- CASE
- WHEN (
- (T1."vehicle_reference" IS NULL)
- OR (T1."vehicle_reference" = ' ')
- )
- THEN (' - ')
- ELSE (T1."vehicle_reference")
- END AS "Vehicle Reference",
- CASE
- WHEN (
- (T1."posting_text" IS NULL)
- OR (T1."posting_text" = ' ')
- )
- THEN (' - ')
- ELSE (T1."posting_text")
- END AS "Posting Text",
- T1."term_of_payment" AS "Term Of Payment",
- T1."cash_discount" AS "Cash Discount",
- T1."journal_line" AS "Journal Line",
- T1."journal_page" AS "Journal Page",
- T1."last_dunning_date" AS "Last Dunning Date",
- T1."dunning_level" AS "Dunning Level",
- CASE
- WHEN (
- (T1."invoice_number" IS NULL)
- OR (T1."invoice_number" = ' ')
- )
- THEN (' - ')
- ELSE (T1."invoice_number")
- END AS "Invoice Number",
- T1."invoice_date" AS "Invoice Date",
- T1."employee_number" AS "Employee Number",
- T1."serial_number_each_month" AS "Serial Number Each Month",
- T1."account_form_page_line" AS "Account Form Page Line",
- T1."account_form_page_number" AS "Account Form Page Number",
- T1."contra_account_text" AS "Contra Account Text",
- T1."nominal_contra_account" AS "Nominal Contra Account",
- T1."customer_contra_account" AS "Customer Contra Account",
- T1."branch_number" AS "Branch Number",
- T1."posted_count" AS "Posted Count",
- T1."debit_or_credit" AS "Debit Or Credit",
- T1."posted_value" AS "Posted Value",
- T1."document_date" AS "Document Date",
- T1."clearing_number" AS "Clearing Number",
- T1."is_balanced" AS "Is Balanced",
- T1."customer_number" AS "Customer Number",
- T1."position_in_document" AS "Position In Document",
- (T1."document_number") AS "Document Number",
- T1."document_type" AS "Document Type"
- FROM (
- (
- (
- (
- "journal_accountings" T1 LEFT JOIN "LOCOSOFT"."dbo"."employees" T2 ON T1."employee_number" = T2."employee_number"
- ) LEFT JOIN "LOCOSOFT"."dbo"."customers_suppliers" T3 ON T3."customer_number" = T1."customer_number"
- ) LEFT JOIN "document_types" T4 ON T4."document_type_in_journal" = T1."document_type"
- ) LEFT JOIN "invoices" T5 ON T5."invtype_invnr" = T1."invoice_number"
- )
- WHERE (
- (
- (
- (
- (T1."nominal_account_number" IN (1400, 1409, 1451, 1408, 1525))
- AND (T1."clearing_number" = 0)
- )
- AND (T1."customer_number" IS NOT NULL)
- )
- AND (NOT T4."document_type_in_journal" IN ('A', 'E', 'U', 'V'))
- )
- AND (T3."customer_number" IS NOT NULL)
- )
- ) D2
- ) D1
- WHERE (c80 <> 0)
- -- order by "Customer Number" asc,"Document Type In Journal" asc,"Nominal Account Number" asc
|