1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036 |
- 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",
- "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",
- "Rechtseinheit" AS "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 T5."customer_number" AS "Customer Number_suctomer_supplier",
- ((((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 (T7."invoice_type" IN (2, 4, 6, 3))
- THEN ('3')
- WHEN (T7."invoice_type" IN (5))
- THEN ('6')
- WHEN (T7."invoice_type" IN (7))
- THEN ('1')
- WHEN (T7."invoice_type" IN (8))
- THEN ('2')
- WHEN (T6."document_type_in_journal" = 'R')
- THEN ('7')
- ELSE NULL
- END
- ) = '1'
- )
- THEN ('Neuwagen')
- WHEN (
- (
- CASE
- WHEN (T7."invoice_type" IN (2, 4, 6, 3))
- THEN ('3')
- WHEN (T7."invoice_type" IN (5))
- THEN ('6')
- WHEN (T7."invoice_type" IN (7))
- THEN ('1')
- WHEN (T7."invoice_type" IN (8))
- THEN ('2')
- WHEN (T6."document_type_in_journal" = 'R')
- THEN ('7')
- ELSE NULL
- END
- ) = '2'
- )
- THEN ('Gebrauchtwagen')
- WHEN (
- (
- CASE
- WHEN (T7."invoice_type" IN (2, 4, 6, 3))
- THEN ('3')
- WHEN (T7."invoice_type" IN (5))
- THEN ('6')
- WHEN (T7."invoice_type" IN (7))
- THEN ('1')
- WHEN (T7."invoice_type" IN (8))
- THEN ('2')
- WHEN (T6."document_type_in_journal" = 'R')
- THEN ('7')
- ELSE NULL
- END
- ) = '3'
- )
- THEN ('Service')
- WHEN (
- (
- CASE
- WHEN (T7."invoice_type" IN (2, 4, 6, 3))
- THEN ('3')
- WHEN (T7."invoice_type" IN (5))
- THEN ('6')
- WHEN (T7."invoice_type" IN (7))
- THEN ('1')
- WHEN (T7."invoice_type" IN (8))
- THEN ('2')
- WHEN (T6."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",
- T4."name" AS "Name_Employees_journal_accountings",
- T4."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 (T5."first_name" IS NOT NULL)
- THEN ((left((((T5."customer_number"))), 7)) + ' - ' + T5."first_name" + ' ' + T5."family_name")
- ELSE ((left((((T5."customer_number"))), 7)) + ' - ' + T5."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 (T7."invoice_type" IN (2, 4, 6, 3))
- THEN ('3')
- WHEN (T7."invoice_type" IN (5))
- THEN ('6')
- WHEN (T7."invoice_type" IN (7))
- THEN ('1')
- WHEN (T7."invoice_type" IN (8))
- THEN ('2')
- WHEN (T6."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",
- CASE
- WHEN (T2."salesman_number" IS NOT NULL)
- THEN ((left((((T3."employee_number"))), 4)) + ' - ' + T3."name")
- ELSE ((left((((T4."employee_number"))), 4)) + ' - ' + T4."name")
- END AS "Sel Name",
- CASE
- WHEN (T7."subsidiary" IS NOT NULL)
- THEN ((left((((T7."subsidiary"))), 1)))
- ELSE ('nicht zuzuordnen')
- END AS "Standort_ori",
- T1."subsidiary_to_company_ref" AS "Rechtseinheit",
- T7."invoice_date" AS "Invoice Date_Invoices",
- T7."subsidiary" AS "Subsidiary_Invoices",
- T7."invoice_number" AS "Invoice Number_Invoices",
- T7."invoice_type" AS "Invoice Type_Invoices",
- T6."document_type_description" AS "Document Type Description",
- T6."document_type_in_journal" AS "Document Type In Journal",
- T5."family_name" AS "Family Name",
- T5."first_name" AS "First Name",
- T5."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
- ) + ' - ' + (
- CASE
- WHEN (T2."salesman_number" IS NOT NULL)
- THEN ((left((((T3."employee_number"))))) + ' - ' + T3."name")
- ELSE ((left((((T4."employee_number"))), 4)) + ' - ' + T4."name")
- END
- ) + ' - ' + (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
- ) + ' - ' + (
- CASE
- WHEN (T2."salesman_number" IS NOT NULL)
- THEN ((left((((T3."employee_number"))))) + ' - ' + T3."name")
- ELSE ((left((((T4."employee_number"))), 4)) + ' - ' + T4."name")
- END
- ) + ' - ' + (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
- ) + ' - ' + (
- CASE
- WHEN (T2."salesman_number" IS NOT NULL)
- THEN ((left((((T3."employee_number"))))) + ' - ' + T3."name")
- ELSE ((left((((T4."employee_number"))), 4)) + ' - ' + T4."name")
- END
- ) + ' - ' + (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
- ) + ' - ' + (
- CASE
- WHEN (T2."salesman_number" IS NOT NULL)
- THEN ((left((((T3."employee_number"))))) + ' - ' + T3."name")
- ELSE ((left((((T4."employee_number"))), 4)) + ' - ' + T4."name")
- END
- ) + ' - ' + (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
- ) + ' - ' + (
- CASE
- WHEN (T2."salesman_number" IS NOT NULL)
- THEN ((left((((T3."employee_number"))))) + ' - ' + T3."name")
- ELSE ((left((((T4."employee_number"))), 4)) + ' - ' + T4."name")
- END
- ) + ' - ' + (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
- ) + ' - ' + (
- CASE
- WHEN (T2."salesman_number" IS NOT NULL)
- THEN ((left((((T3."employee_number"))))) + ' - ' + T3."name")
- ELSE ((left((((T4."employee_number"))), 4)) + ' - ' + T4."name")
- END
- ) + ' - ' + (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
- ) + ' - ' + (
- CASE
- WHEN (T2."salesman_number" IS NOT NULL)
- THEN ((left((((T3."employee_number"))))) + ' - ' + T3."name")
- ELSE ((left((((T4."employee_number"))), 4)) + ' - ' + T4."name")
- END
- ) + ' - ' + (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
- ) + ' - ' + (
- CASE
- WHEN (T2."salesman_number" IS NOT NULL)
- THEN ((left((((T3."employee_number"))))) + ' - ' + T3."name")
- ELSE ((left((((T4."employee_number"))), 4)) + ' - ' + T4."name")
- END
- ) + ' - ' + (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
- ) + ' - ' + (
- CASE
- WHEN (T2."salesman_number" IS NOT NULL)
- THEN ((left((((T3."employee_number"))))) + ' - ' + T3."name")
- ELSE ((left((((T4."employee_number"))), 4)) + ' - ' + T4."name")
- END
- ) + ' - ' + (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
- ) + ' - ' + (
- CASE
- WHEN (T2."salesman_number" IS NOT NULL)
- THEN ((left((((T3."employee_number"))))) + ' - ' + T3."name")
- ELSE ((left((((T4."employee_number"))), 4)) + ' - ' + T4."name")
- END
- ) + ' - ' + (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
- ) + ' - ' + (
- CASE
- WHEN (T2."salesman_number" IS NOT NULL)
- THEN ((left((((T3."employee_number"))))) + ' - ' + T3."name")
- ELSE ((left((((T4."employee_number"))), 4)) + ' - ' + T4."name")
- END
- ) + ' - ' + (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
- ) + ' - ' + (
- CASE
- WHEN (T2."salesman_number" IS NOT NULL)
- THEN ((left((((T3."employee_number"))))) + ' - ' + T3."name")
- ELSE ((left((((T4."employee_number"))), 4)) + ' - ' + T4."name")
- END
- ) + ' - ' + (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 "vehicles" T2 ON (right(T1."vehicle_reference", 17)) = T2."vin"
- ) LEFT JOIN "employees" T3 ON (T2."salesman_number" <> 0)
- AND (T2."salesman_number" = T3."salesman_number")
- ) LEFT JOIN "LOCOSOFT"."dbo"."employees" T4 ON T1."employee_number" = T4."employee_number"
- ) LEFT JOIN "LOCOSOFT"."dbo"."customers_suppliers" T5 ON T5."customer_number" = T1."customer_number"
- ) LEFT JOIN "document_types" T6 ON T6."document_type_in_journal" = T1."document_type"
- ) LEFT JOIN "invoices" T7 ON T7."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 T6."document_type_in_journal" IN ('A', 'E', 'U', 'V'))
- )
- AND (T5."customer_number" IS NOT NULL)
- )
- ) D2
- ) D1
- WHERE (c80 <> 0)
- -- order by "Customer Number" asc,"Document Type In Journal" asc,"Nominal Account Number" asc
|