--
-- PostgreSQL database dump
--

-- Dumped from database version 14.5 (Debian 14.5-1.pgdg110+1)
-- Dumped by pg_dump version 15.2

SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;

--
-- Name: public; Type: SCHEMA; Schema: -; Owner: postgres
--

CREATE SCHEMA public;


ALTER SCHEMA public OWNER TO postgres;

--
-- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres
--

COMMENT ON SCHEMA public IS 'standard public schema';


SET default_tablespace = '';

SET default_table_access_method = heap;

--
-- Name: absence_calendar; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.absence_calendar (
    employee_number integer NOT NULL,
    date date NOT NULL,
    unique_dummy integer NOT NULL,
    type character varying(1),
    is_payed boolean,
    day_contingent numeric(4,2),
    reason character varying(3),
    booking_flag character varying(1),
    CONSTRAINT absence_calendar_booking_flag_check CHECK ((((booking_flag)::text = 'A'::text) OR ((booking_flag)::text = 'J'::text)))
);


ALTER TABLE public.absence_calendar OWNER TO postgres;

--
-- Name: TABLE absence_calendar; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.absence_calendar IS 'Abwesenheiten, wie z.B. Urlaub oder Krankheit';


--
-- Name: COLUMN absence_calendar.employee_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.absence_calendar.employee_number IS 'Mitarbeiter, zu dem diese Abwesenheit gehört';


--
-- Name: COLUMN absence_calendar.date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.absence_calendar.date IS 'Datum dieser Abwesenheit';


--
-- Name: COLUMN absence_calendar.unique_dummy; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.absence_calendar.unique_dummy IS 'Zähler je Mitarbeiter und Tag (ohne Bedeutung für die Abwesenheit, nicht unbedingt sequenziell)';


--
-- Name: COLUMN absence_calendar.type; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.absence_calendar.type IS 'Abwesenheits-Typ (z.B. geplant oder real)';


--
-- Name: COLUMN absence_calendar.is_payed; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.absence_calendar.is_payed IS 'Diese Abwesenheit wird bezahlt (true) oder nicht (false)';


--
-- Name: COLUMN absence_calendar.day_contingent; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.absence_calendar.day_contingent IS 'Tagesanteil dieser Abwesenheit, z.B. 0,25 entspricht 2 Stunden bei acht Stunden Arbeitszeit pro Tag';


--
-- Name: COLUMN absence_calendar.reason; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.absence_calendar.reason IS 'Abwesenheits-Grund (z.B. Urlaub oder Krankheit)';


--
-- Name: COLUMN absence_calendar.booking_flag; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.absence_calendar.booking_flag IS 'A = Arbeitszeitkonto oder J = Jahresurlaub';


--
-- Name: absence_reasons; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.absence_reasons (
    id character varying(3) NOT NULL,
    description character varying(15),
    is_annual_vacation boolean,
    CONSTRAINT absence_reasons_id_check CHECK (((id)::text > ''::text))
);


ALTER TABLE public.absence_reasons OWNER TO postgres;

--
-- Name: TABLE absence_reasons; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.absence_reasons IS 'Abwesenheitsgründe für Tabelle absence_calendar';


--
-- Name: COLUMN absence_reasons.id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.absence_reasons.id IS 'Interne Codierung der Abwesenheit';


--
-- Name: COLUMN absence_reasons.description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.absence_reasons.description IS 'Beschreibung des Abwesenheitsgrund';


--
-- Name: COLUMN absence_reasons.is_annual_vacation; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.absence_reasons.is_annual_vacation IS 'Dieser Abwesenheitsgrund bezieht sich auf den Jahresurlaub';


--
-- Name: absence_types; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.absence_types (
    type character varying(1) NOT NULL,
    description character varying(20),
    CONSTRAINT absence_types_type_check CHECK (((type)::text > ''::text))
);


ALTER TABLE public.absence_types OWNER TO postgres;

--
-- Name: TABLE absence_types; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.absence_types IS 'Abwesenheits-Typen, z.B. reale Abwesenheit oder geplante Abwesenheit';


--
-- Name: COLUMN absence_types.type; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.absence_types.type IS 'Interne Codierung des Typs';


--
-- Name: COLUMN absence_types.description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.absence_types.description IS 'Beschreibung des Abwesenheits-Typ';


--
-- Name: accounts_characteristics; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.accounts_characteristics (
    subsidiary_to_company_ref bigint NOT NULL,
    skr51_branch bigint NOT NULL,
    skr51_make bigint NOT NULL,
    skr51_cost_center bigint NOT NULL,
    skr51_sales_channel bigint NOT NULL,
    skr51_cost_unit bigint NOT NULL,
    skr51_brach_name text,
    skr51_make_description text,
    skr51_cost_center_name text,
    skr51_sales_channel_name text,
    skr51_cost_unit_name text
);


ALTER TABLE public.accounts_characteristics OWNER TO postgres;

--
-- Name: TABLE accounts_characteristics; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.accounts_characteristics IS 'KR-Merkmale, auf die Buchungen verzeichnet sind';


--
-- Name: COLUMN accounts_characteristics.subsidiary_to_company_ref; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.accounts_characteristics.subsidiary_to_company_ref IS 'BetriebsGruppe:Zuordnung zu der "Betriebsgruppe" bei Buchhaltungssplitt - ansonsten immer 1';


--
-- Name: COLUMN accounts_characteristics.skr51_branch; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.accounts_characteristics.skr51_branch IS 'SKR51-Betrieb:A:Falls SKR51 im Einsatz: Betriebs-Nr.';


--
-- Name: COLUMN accounts_characteristics.skr51_make; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.accounts_characteristics.skr51_make IS 'SKR51-Marke:B:Falls SKR51 im Einsatz: Nummer der Marke/des Fabrikats';


--
-- Name: COLUMN accounts_characteristics.skr51_cost_center; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.accounts_characteristics.skr51_cost_center IS 'SKR51-KostenStelle:C:Falls SKR51 im Einsatz: Kostenstellen Nr.';


--
-- Name: COLUMN accounts_characteristics.skr51_sales_channel; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.accounts_characteristics.skr51_sales_channel IS 'SKR51-AbsatzKanal:D:Falls SKR51 im Einsatz: Absatz Kanal Nr.';


--
-- Name: COLUMN accounts_characteristics.skr51_cost_unit; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.accounts_characteristics.skr51_cost_unit IS 'SKR51-KostenTraeger:E:Falls SKR51 im Einsatz: Kosten Träger Nr.';


--
-- Name: COLUMN accounts_characteristics.skr51_brach_name; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.accounts_characteristics.skr51_brach_name IS 'SKR51-BetriebBez:F:Falls SKR51 im Einsatz: Betriebs-Bezeichnung';


--
-- Name: COLUMN accounts_characteristics.skr51_make_description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.accounts_characteristics.skr51_make_description IS 'SKR51-Marke-Bez:G:Falls SKR51 im Einsatz: Bezeichnung der Marke/des Fabrikats';


--
-- Name: COLUMN accounts_characteristics.skr51_cost_center_name; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.accounts_characteristics.skr51_cost_center_name IS 'SKR51-KostenStelleBez:H:Falls SKR51 im Einsatz: Kostenstellen Bezeichnung';


--
-- Name: COLUMN accounts_characteristics.skr51_sales_channel_name; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.accounts_characteristics.skr51_sales_channel_name IS 'SKR51-AbsatzKanalBez:I:Falls SKR51 im Einsatz: Absatz Kanal Bezeichnung';


--
-- Name: COLUMN accounts_characteristics.skr51_cost_unit_name; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.accounts_characteristics.skr51_cost_unit_name IS 'SKR51-KostenTraegerBez:J:Falls SKR51 im Einsatz: Kosten Träger Bezeichnung';


--
-- Name: appointments; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.appointments (
    id integer NOT NULL,
    subsidiary integer,
    appointment_type integer,
    customer_number integer,
    vehicle_number integer,
    comment character varying(80),
    created_by_employee integer,
    created_timestamp timestamp without time zone,
    locked_by_employee integer,
    blocked_timestamp timestamp without time zone,
    bring_timestamp timestamp without time zone,
    return_timestamp timestamp without time zone,
    pseudo_customer_name character varying(45),
    pseudo_customer_country character varying(3),
    pseudo_customer_zip_code character varying(20),
    pseudo_customer_home_city character varying(25),
    pseudo_customer_home_street character varying(27),
    pseudo_vehicle_make_number integer,
    pseudo_vehicle_make_text character varying(10),
    pseudo_model_code character varying(16),
    pseudo_model_text character varying(18),
    pseudo_license_plate character varying(12),
    pseudo_vin character varying(17),
    order_number integer,
    is_customer_reminder_allowed boolean,
    customer_reminder_type character varying(30),
    customer_reminder_timestamp timestamp without time zone,
    bring_duration integer,
    bring_employee_no integer,
    return_duration integer,
    return_employee_no integer,
    customer_pickup_bring integer,
    is_general_inspection_service boolean,
    urgency integer,
    vehicle_status integer,
    progress_status integer,
    lock_by_workstation integer,
    lock_time timestamp without time zone,
    lock_trace character varying(100),
    lock_trigger character varying(100),
    lock_by_employee integer,
    lock_sourcecode character varying(100)
);


ALTER TABLE public.appointments OWNER TO postgres;

--
-- Name: TABLE appointments; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.appointments IS 'Werkstatt-Termine';


--
-- Name: COLUMN appointments.id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.appointments.id IS 'Interne Vorgangsnummer für Mietwagen-Termine. Hinweis: Vorgangsnummern von Werkstatt-Terminen sind unabhnägig von Mietwagen-Terminen und können sich überschneiden.';


--
-- Name: COLUMN appointments.subsidiary; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.appointments.subsidiary IS 'Dieser Vorgang ist dem angegebenen Betrieb zugeordnet';


--
-- Name: COLUMN appointments.appointment_type; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.appointments.appointment_type IS 'Klassifizierung der Terminart. 0 = feste, 76 = lose, 82 = real, 85 = unbekannt (Hinweis: ASCII-Code, 0 wird in Loco-Soft als "F" angezeigt.';


--
-- Name: COLUMN appointments.customer_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.appointments.customer_number IS 'Zugeordneter Kunde zu diesem Vorgang';


--
-- Name: COLUMN appointments.vehicle_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.appointments.vehicle_number IS 'Zugeordnetes Fahrzeug zu diesem Vorgang';


--
-- Name: COLUMN appointments.comment; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.appointments.comment IS 'Zusätzlicher Kommentar zu dem Vorgang';


--
-- Name: COLUMN appointments.created_by_employee; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.appointments.created_by_employee IS 'Erstellt von Mitarbeiter Nr.';


--
-- Name: COLUMN appointments.created_timestamp; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.appointments.created_timestamp IS 'Zeitpunkt der Neuanlage';


--
-- Name: COLUMN appointments.locked_by_employee; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.appointments.locked_by_employee IS 'Sperrender Mitarbeiter';


--
-- Name: COLUMN appointments.blocked_timestamp; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.appointments.blocked_timestamp IS 'Sperrzeit';


--
-- Name: COLUMN appointments.bring_timestamp; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.appointments.bring_timestamp IS 'Kunde bringt Fahrzeug';


--
-- Name: COLUMN appointments.return_timestamp; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.appointments.return_timestamp IS 'Kunde holt Fahrzeug';


--
-- Name: COLUMN appointments.pseudo_customer_name; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.appointments.pseudo_customer_name IS 'Falls der Kunde noch nicht im Stamm erfasst worden sein sollte, steht hier der Kundenname';


--
-- Name: COLUMN appointments.pseudo_customer_country; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.appointments.pseudo_customer_country IS 'Falls der Kunde noch nicht im Stamm erfasst worden sein sollte, steht hier das Landeskennzeichen (oder NULL bei inländischen Adressen)';


--
-- Name: COLUMN appointments.pseudo_customer_zip_code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.appointments.pseudo_customer_zip_code IS 'Falls der Kunde noch nicht im Stamm erfasst worden sein sollte, steht hier die Postleitzahl';


--
-- Name: COLUMN appointments.pseudo_customer_home_city; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.appointments.pseudo_customer_home_city IS 'Falls der Kunde noch nicht im Stamm erfasst worden sein sollte, steht hier der Wohnort / Standort';


--
-- Name: COLUMN appointments.pseudo_customer_home_street; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.appointments.pseudo_customer_home_street IS 'Falls der Kunde noch nicht im Stamm erfasst worden sein sollte, steht hier die Straße des Kunden. Bei ausländischen Adressen ist auch der ZIP-Code enthalten.';


--
-- Name: COLUMN appointments.pseudo_vehicle_make_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.appointments.pseudo_vehicle_make_number IS 'Bei Fahrzeugen, die noch nicht im Fahrzeugstamm erfasst wurden, steht hier die Fabrikats-Nummer.';


--
-- Name: COLUMN appointments.pseudo_vehicle_make_text; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.appointments.pseudo_vehicle_make_text IS 'Bei Fahrzeugen, die noch nicht im Fahrzeugstamm erfasst wurden, steht hier die Fabrikats-Bezeichnung.';


--
-- Name: COLUMN appointments.pseudo_model_code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.appointments.pseudo_model_code IS 'Bei Fahrzeugen, die noch nicht im Fahrzeugstamm erfasst wurden, steht hier der Modellcode. make_number und model_code verweise auf Tabelle models(make_number, model_code)';


--
-- Name: COLUMN appointments.pseudo_model_text; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.appointments.pseudo_model_text IS 'Bei Fahrzeugen, die noch nicht im Fahrzeugstamm erfasst wurden, steht hier die Modellbezeichnung.';


--
-- Name: COLUMN appointments.order_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.appointments.order_number IS 'Auftragsnummer zu diesem Vorgang, falls vorhanden';


--
-- Name: COLUMN appointments.is_customer_reminder_allowed; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.appointments.is_customer_reminder_allowed IS 'Darf der Kunde automatisch an den Termin erinnert werden? NULL falls unbekannt.';


--
-- Name: COLUMN appointments.customer_reminder_type; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.appointments.customer_reminder_type IS 'Kunde wurde über den angegebenen Kanal an den Termin erinnert oder NULL';


--
-- Name: COLUMN appointments.customer_reminder_timestamp; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.appointments.customer_reminder_timestamp IS 'Zeitpunkt der Erinnerung oder NULL';


--
-- Name: COLUMN appointments.bring_duration; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.appointments.bring_duration IS 'Dauer für Fahrzeug-Übergabe in Minuten';


--
-- Name: COLUMN appointments.bring_employee_no; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.appointments.bring_employee_no IS 'Mitarbeiter-Nr. für die Fahrzeug-Annahme des Kunden-Fahrzeugs';


--
-- Name: COLUMN appointments.return_duration; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.appointments.return_duration IS 'Dauer für Fahrzeug-Rückabe in Minuten';


--
-- Name: COLUMN appointments.return_employee_no; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.appointments.return_employee_no IS 'Mitarbeiter-Nr. für die Fahrzeug-Rückgabe an den Kunden';


--
-- Name: COLUMN appointments.customer_pickup_bring; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.appointments.customer_pickup_bring IS 'Kunde kommt persönlich oder Hol-/Bring-Service. Werte siehe Tabelle wtp_pickup_bring_type';


--
-- Name: COLUMN appointments.is_general_inspection_service; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.appointments.is_general_inspection_service IS 'Der Termin bezieht sich auf die Hauptuntersuchung (true) oder nicht (false)';


--
-- Name: COLUMN appointments.urgency; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.appointments.urgency IS 'Dringlichkeit als Code, z.B. für eilt oder fertig. Siehe wtp_urgency';


--
-- Name: COLUMN appointments.vehicle_status; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.appointments.vehicle_status IS 'Fahrzeugstatus, z.B. für in Bearbeitung oder fertig. Siehe wtp_vehicle_status';


--
-- Name: COLUMN appointments.progress_status; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.appointments.progress_status IS 'Stempelstatus, z.B. läuft oder pausiert. siehe wtp_progress_status.';


--
-- Name: COLUMN appointments.lock_by_workstation; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.appointments.lock_by_workstation IS 'Protokollierung von Datensatz-Sperren: Arbeitsplatznummer, der die Sperre erzeugt hat oder NULL.';


--
-- Name: COLUMN appointments.lock_time; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.appointments.lock_time IS 'Protokollierung von Datensatz-Sperren: Zeitstempel, an dem der Datensatz mit Sperre zuletzt geändert wurde oder NULL.';


--
-- Name: COLUMN appointments.lock_trace; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.appointments.lock_trace IS 'Protokollierung von Datensatz-Sperren: Reihenfolge der aufgerufenen Programme bei letztem Update des Datesatzes oder NULL.';


--
-- Name: COLUMN appointments.lock_trigger; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.appointments.lock_trigger IS 'Protokollierung von Datensatz-Sperren: Dienstname oder UI-Information oder NULL.';


--
-- Name: COLUMN appointments.lock_by_employee; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.appointments.lock_by_employee IS 'Protokollierung von Datensatz-Sperren: Interne Mitarbeiter-Nr. oder NULL.';


--
-- Name: COLUMN appointments.lock_sourcecode; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.appointments.lock_sourcecode IS 'Protokollierung von Datensatz-Sperren: Programmstelle oder NULL.';


--
-- Name: appointments_text; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.appointments_text (
    appointment_id integer NOT NULL,
    description character varying(376),
    lock_by_workstation integer,
    lock_time timestamp without time zone,
    lock_trace character varying(100),
    lock_trigger character varying(100),
    lock_by_employee integer,
    lock_sourcecode character varying(100)
);


ALTER TABLE public.appointments_text OWNER TO postgres;

--
-- Name: TABLE appointments_text; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.appointments_text IS 'Kommentare für Werkstatt-Termine';


--
-- Name: COLUMN appointments_text.appointment_id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.appointments_text.appointment_id IS 'Interne Vorgangsnummer für Werkstatt-Termine.';


--
-- Name: COLUMN appointments_text.description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.appointments_text.description IS 'Vom Anwender erfasste Beschreibung zu dem Termin.';


--
-- Name: COLUMN appointments_text.lock_by_workstation; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.appointments_text.lock_by_workstation IS 'Protokollierung von Datensatz-Sperren: Arbeitsplatznummer, der die Sperre erzeugt hat oder NULL.';


--
-- Name: COLUMN appointments_text.lock_time; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.appointments_text.lock_time IS 'Protokollierung von Datensatz-Sperren: Zeitstempel, an dem der Datensatz mit Sperre zuletzt geändert wurde oder NULL.';


--
-- Name: COLUMN appointments_text.lock_trace; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.appointments_text.lock_trace IS 'Protokollierung von Datensatz-Sperren: Reihenfolge der aufgerufenen Programme bei letztem Update des Datesatzes oder NULL.';


--
-- Name: COLUMN appointments_text.lock_trigger; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.appointments_text.lock_trigger IS 'Protokollierung von Datensatz-Sperren: Dienstname oder UI-Information oder NULL.';


--
-- Name: COLUMN appointments_text.lock_by_employee; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.appointments_text.lock_by_employee IS 'Protokollierung von Datensatz-Sperren: Interne Mitarbeiter-Nr. oder NULL.';


--
-- Name: COLUMN appointments_text.lock_sourcecode; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.appointments_text.lock_sourcecode IS 'Protokollierung von Datensatz-Sperren: Programmstelle oder NULL.';


--
-- Name: charge_type_descriptions; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.charge_type_descriptions (
    type integer NOT NULL,
    description character varying(40)
);


ALTER TABLE public.charge_type_descriptions OWNER TO postgres;

--
-- Name: TABLE charge_type_descriptions; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.charge_type_descriptions IS 'Textbezeichnungen der einzelnen Berechnungsarten aus charge_types';


--
-- Name: COLUMN charge_type_descriptions.type; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.charge_type_descriptions.type IS 'Berechnungsart (derzeit zwischen 0 und 99)';


--
-- Name: COLUMN charge_type_descriptions.description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.charge_type_descriptions.description IS 'Bezeichnung der Berechnungsart';


--
-- Name: charge_types; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.charge_types (
    type integer NOT NULL,
    subsidiary integer NOT NULL,
    timeunit_rate numeric(9,3),
    department integer,
    CONSTRAINT charge_types_department_check CHECK (((department = 0) OR ((department >= 1) AND (department <= 6)) OR (department = 9)))
);


ALTER TABLE public.charge_types OWNER TO postgres;

--
-- Name: TABLE charge_types; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.charge_types IS 'Eine Berechnungsart gibt den Verrechnungssatz je AW an. Zusätzlich wird je Berechnungsart zwischen Karosserie, Lackierung, intern, Garantie und Fremdleistung unterschieden.';


--
-- Name: COLUMN charge_types.type; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.charge_types.type IS 'Berechnungsart (derzeit zwischen 0 und 99). (1. Keyanteil).';


--
-- Name: COLUMN charge_types.subsidiary; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.charge_types.subsidiary IS 'Betriebsstätte (2. Keyanteil).';


--
-- Name: COLUMN charge_types.timeunit_rate; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.charge_types.timeunit_rate IS 'Verrechnungssatz pro AW.';


--
-- Name: COLUMN charge_types.department; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.charge_types.department IS 'Kennzeichen: 0 = keine Berechnung (nur Text), 1 = Werkstatt, 2 = Karosserie, 3 = Lackierung, 4 = intern, 6 = Garantie, 9 = Fremdleistung';


--
-- Name: clearing_delay_types; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.clearing_delay_types (
    type character varying(1) NOT NULL,
    description character varying(42)
);


ALTER TABLE public.clearing_delay_types OWNER TO postgres;

--
-- Name: TABLE clearing_delay_types; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.clearing_delay_types IS 'Abrechnungs-Verzögerungs-Grund. Eine Begründung, warum der Auftrag noch nicht, bzw. nicht frühzeitig abgerechnet werden konnte.';


--
-- Name: COLUMN clearing_delay_types.type; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.clearing_delay_types.type IS 'Kennzeichen für Abrechnungs-Verzögerungs-Gründe';


--
-- Name: COLUMN clearing_delay_types.description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.clearing_delay_types.description IS 'Bezeichnung für Abrechnungs-Verzögerungs-Gründe';


--
-- Name: codes_customer_def; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.codes_customer_def (
    code character varying(5) NOT NULL,
    is_defined_by_dms boolean,
    format character varying(1),
    length integer,
    "decimal" integer,
    description character varying(44)
);


ALTER TABLE public.codes_customer_def OWNER TO postgres;

--
-- Name: TABLE codes_customer_def; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.codes_customer_def IS 'Definition der Kunden-Zusatzcodes';


--
-- Name: COLUMN codes_customer_def.code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.codes_customer_def.code IS 'Code für Zusatz-Code';


--
-- Name: COLUMN codes_customer_def.is_defined_by_dms; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.codes_customer_def.is_defined_by_dms IS 'true = dieser Code wird von Loco-Soft ausgeliefert und kann nicht manuell geändert werden';


--
-- Name: COLUMN codes_customer_def.format; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.codes_customer_def.format IS 'Aussehen des Feldes: (G)roßbuchstaben, B = Groß- und Kleinbuchstaben, Z = Zahl, D = Datum';


--
-- Name: COLUMN codes_customer_def.length; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.codes_customer_def.length IS 'Länge des Felders. Bei G/B: Gesamtlänge; bei Z: Anzahl der Vorkommastellen';


--
-- Name: COLUMN codes_customer_def."decimal"; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.codes_customer_def."decimal" IS 'Nachkommastellen. Bei G/B: immer 0; bei Z: Anzahl der Nachkommastellen';


--
-- Name: COLUMN codes_customer_def.description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.codes_customer_def.description IS 'Beschreibung';


--
-- Name: codes_customer_list; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.codes_customer_list (
    customer_number integer NOT NULL,
    code character varying(5) NOT NULL,
    value_format character varying(1),
    value_text character varying(40),
    value_numeric numeric(18,9),
    value_date date
);


ALTER TABLE public.codes_customer_list OWNER TO postgres;

--
-- Name: TABLE codes_customer_list; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.codes_customer_list IS 'Kunden-Zusatzcodes';


--
-- Name: COLUMN codes_customer_list.customer_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.codes_customer_list.customer_number IS 'Kundennummer, für die dieser Zusatzcode gilt';


--
-- Name: COLUMN codes_customer_list.code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.codes_customer_list.code IS 'Kunden-Zusatzcode';


--
-- Name: COLUMN codes_customer_list.value_format; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.codes_customer_list.value_format IS 'Formatierungs-Kennzeichen wie in codes_customer_def.format';


--
-- Name: COLUMN codes_customer_list.value_text; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.codes_customer_list.value_text IS 'Textwert (falls value_format G oder B ist)';


--
-- Name: COLUMN codes_customer_list.value_numeric; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.codes_customer_list.value_numeric IS 'Zahlenwert (falls value_format Z ist)';


--
-- Name: COLUMN codes_customer_list.value_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.codes_customer_list.value_date IS 'Datumswert (falls value_format D ist)';


--
-- Name: codes_vehicle_date; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.codes_vehicle_date (
    vehicle_number integer NOT NULL,
    code character varying(5) NOT NULL,
    date date
);


ALTER TABLE public.codes_vehicle_date OWNER TO postgres;

--
-- Name: TABLE codes_vehicle_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.codes_vehicle_date IS 'Fahrzeug-Zusatz-Termine';


--
-- Name: COLUMN codes_vehicle_date.vehicle_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.codes_vehicle_date.vehicle_number IS 'Interne Fahrzeugnummer';


--
-- Name: COLUMN codes_vehicle_date.code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.codes_vehicle_date.code IS 'Fahrzeug-Zusatz-Termin-Code';


--
-- Name: COLUMN codes_vehicle_date.date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.codes_vehicle_date.date IS 'Datum/Termin';


--
-- Name: codes_vehicle_date_def; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.codes_vehicle_date_def (
    code character varying(5) NOT NULL,
    is_defined_by_dms boolean,
    month_increase_factor integer,
    show_in_211_from_or_to character varying(1),
    is_backdate_on_exceeding boolean,
    description character varying(44)
);


ALTER TABLE public.codes_vehicle_date_def OWNER TO postgres;

--
-- Name: TABLE codes_vehicle_date_def; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.codes_vehicle_date_def IS 'Fahrzeug-Zusatz-Termin-Code (Code-Definitionen)';


--
-- Name: COLUMN codes_vehicle_date_def.code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.codes_vehicle_date_def.code IS 'Code für Fahrzeug-Zusatz-Termin';


--
-- Name: COLUMN codes_vehicle_date_def.is_defined_by_dms; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.codes_vehicle_date_def.is_defined_by_dms IS 'true = dieser Code wird von Loco-Soft ausgeliefert und kann nicht manuell geändert werden';


--
-- Name: COLUMN codes_vehicle_date_def.month_increase_factor; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.codes_vehicle_date_def.month_increase_factor IS 'Monatsfaktor zur Terminweiterdatierung';


--
-- Name: COLUMN codes_vehicle_date_def.show_in_211_from_or_to; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.codes_vehicle_date_def.show_in_211_from_or_to IS 'Anzeige in Prg.211 ab oder bis Datum, A = ab, B = bis';


--
-- Name: COLUMN codes_vehicle_date_def.is_backdate_on_exceeding; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.codes_vehicle_date_def.is_backdate_on_exceeding IS 'Rückdatierung bei Terminüberschreitung';


--
-- Name: COLUMN codes_vehicle_date_def.description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.codes_vehicle_date_def.description IS 'Beschreibung';


--
-- Name: codes_vehicle_def; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.codes_vehicle_def (
    code character varying(5) NOT NULL,
    is_defined_by_dms boolean,
    format character varying(1),
    length integer,
    "decimal" integer,
    description character varying(44)
);


ALTER TABLE public.codes_vehicle_def OWNER TO postgres;

--
-- Name: TABLE codes_vehicle_def; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.codes_vehicle_def IS 'Zusatzcodes für Fahrzeuge (Code-Definitionen)';


--
-- Name: COLUMN codes_vehicle_def.code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.codes_vehicle_def.code IS 'Code für Zusatz-Code';


--
-- Name: COLUMN codes_vehicle_def.is_defined_by_dms; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.codes_vehicle_def.is_defined_by_dms IS 'true = dieser Code wird von Loco-Soft ausgeliefert und kann nicht manuell geändert werden';


--
-- Name: COLUMN codes_vehicle_def.format; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.codes_vehicle_def.format IS 'Aussehen des Feldes: (G)roßbuchstaben, B = Groß- und Kleinbuchstaben, Z = Zahl, D = Datum';


--
-- Name: COLUMN codes_vehicle_def.length; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.codes_vehicle_def.length IS 'Länge des Felders. Bei G/B: Gesamtlänge; bei Z: Anzahl der Vorkommastellen';


--
-- Name: COLUMN codes_vehicle_def."decimal"; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.codes_vehicle_def."decimal" IS 'Nachkommastellen. Bei G/B: immer 0; bei Z: Anzahl der Nachkommastellen';


--
-- Name: COLUMN codes_vehicle_def.description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.codes_vehicle_def.description IS 'Beschreibung';


--
-- Name: codes_vehicle_list; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.codes_vehicle_list (
    vehicle_number integer NOT NULL,
    code character varying(5) NOT NULL,
    value_format character varying(1),
    value_text character varying(40),
    value_numeric numeric(18,9),
    value_date date
);


ALTER TABLE public.codes_vehicle_list OWNER TO postgres;

--
-- Name: TABLE codes_vehicle_list; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.codes_vehicle_list IS 'Fahrzeug-Zusatzcodes';


--
-- Name: COLUMN codes_vehicle_list.vehicle_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.codes_vehicle_list.vehicle_number IS 'Interne Fahrzeugnummer';


--
-- Name: COLUMN codes_vehicle_list.code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.codes_vehicle_list.code IS 'Fahrzeug-Zusatzcode';


--
-- Name: COLUMN codes_vehicle_list.value_format; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.codes_vehicle_list.value_format IS 'Formatierungs-Kennzeichen wie in codes_vehicle_def.format';


--
-- Name: COLUMN codes_vehicle_list.value_text; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.codes_vehicle_list.value_text IS 'Textwert (falls value_format G oder B ist)';


--
-- Name: COLUMN codes_vehicle_list.value_numeric; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.codes_vehicle_list.value_numeric IS 'Zahlenwert (falls value_format Z ist)';


--
-- Name: COLUMN codes_vehicle_list.value_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.codes_vehicle_list.value_date IS 'Datumswert (falls value_format D ist)';


--
-- Name: codes_vehicle_mileage; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.codes_vehicle_mileage (
    vehicle_number integer NOT NULL,
    code character varying(5) NOT NULL,
    kilometer integer
);


ALTER TABLE public.codes_vehicle_mileage OWNER TO postgres;

--
-- Name: TABLE codes_vehicle_mileage; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.codes_vehicle_mileage IS 'Fahrzeug-Zusatz-Km';


--
-- Name: COLUMN codes_vehicle_mileage.vehicle_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.codes_vehicle_mileage.vehicle_number IS 'Interne Fahrzeugnummer';


--
-- Name: COLUMN codes_vehicle_mileage.code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.codes_vehicle_mileage.code IS 'Fahrzeug-Zusatz-Km-code';


--
-- Name: COLUMN codes_vehicle_mileage.kilometer; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.codes_vehicle_mileage.kilometer IS 'Kilometer';


--
-- Name: codes_vehicle_mileage_def; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.codes_vehicle_mileage_def (
    code character varying(5) NOT NULL,
    is_defined_by_dms boolean,
    mileage_increase_factor integer,
    show_in_211_from_or_to character varying(1),
    description character varying(44)
);


ALTER TABLE public.codes_vehicle_mileage_def OWNER TO postgres;

--
-- Name: TABLE codes_vehicle_mileage_def; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.codes_vehicle_mileage_def IS 'Fahrzeug-Zusatz-km/Ablesestand Einstellungen (Code-Definitionen)';


--
-- Name: COLUMN codes_vehicle_mileage_def.code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.codes_vehicle_mileage_def.code IS 'Code für Fahrzeug-Zusatz-Km-Stand';


--
-- Name: COLUMN codes_vehicle_mileage_def.is_defined_by_dms; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.codes_vehicle_mileage_def.is_defined_by_dms IS 'true = dieser Code wird von Loco-Soft ausgeliefert und kann nicht manuell geändert werden';


--
-- Name: COLUMN codes_vehicle_mileage_def.mileage_increase_factor; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.codes_vehicle_mileage_def.mileage_increase_factor IS 'km-Faktor * 100 zur Weiterschreibung';


--
-- Name: COLUMN codes_vehicle_mileage_def.show_in_211_from_or_to; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.codes_vehicle_mileage_def.show_in_211_from_or_to IS 'Anzeige in Prg.211 ab oder bis km-Stand, A = ab, B = bis';


--
-- Name: COLUMN codes_vehicle_mileage_def.description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.codes_vehicle_mileage_def.description IS 'Beschreibung';


--
-- Name: com_number_types; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.com_number_types (
    typ character varying(1) NOT NULL,
    description character varying(50),
    is_office_number boolean,
    CONSTRAINT com_number_types_typ_check CHECK (((typ)::text > ''::text))
);


ALTER TABLE public.com_number_types OWNER TO postgres;

--
-- Name: TABLE com_number_types; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.com_number_types IS 'Kommunikations-Nummern-Typen (z.B. Telefon geschäftlich)';


--
-- Name: COLUMN com_number_types.typ; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.com_number_types.typ IS 'Interne Codierung des Kommunikationstyp';


--
-- Name: COLUMN com_number_types.description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.com_number_types.description IS 'Beschreibung des Kommunikationstyp';


--
-- Name: COLUMN com_number_types.is_office_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.com_number_types.is_office_number IS 'Privat (home) = false, Büro (office) = true';


--
-- Name: configuration; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.configuration (
    type character varying(40) NOT NULL,
    value_numeric bigint NOT NULL,
    value_text character varying(50) NOT NULL,
    description text,
    CONSTRAINT configuration_type_check CHECK (((type)::text > ''::text))
);


ALTER TABLE public.configuration OWNER TO postgres;

--
-- Name: TABLE configuration; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.configuration IS 'Status- und Versionsinformationen zu: Datenstruktur, Dateninhalt, Programmversion, Aktualisierung und Einstellungen';


--
-- Name: COLUMN configuration.type; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.configuration.type IS 'Interne Codierung der Status- oder Versionsangabe. Z.B. version_new_structures, created_start, created_end, ...';


--
-- Name: COLUMN configuration.value_numeric; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.configuration.value_numeric IS 'Wert als Zahl. Inhalte siehe description. Boolische Werte werden als 1 und 0 angegeben';


--
-- Name: COLUMN configuration.value_text; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.configuration.value_text IS 'Wert als Text, Inhalte siehe description. Boolische Werte werden als "true" und "false" angegeben';


--
-- Name: COLUMN configuration.description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.configuration.description IS 'Beschreibung der Versionsinformation oder Einstellung';


--
-- Name: configuration_numeric; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.configuration_numeric (
    parameter_number integer NOT NULL,
    subsidiary integer NOT NULL,
    text_value character varying(18),
    description character varying(49)
);


ALTER TABLE public.configuration_numeric OWNER TO postgres;

--
-- Name: TABLE configuration_numeric; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.configuration_numeric IS 'Numerische Einstellungen (Programm Nr. 912 "Händlerdaten variable")';


--
-- Name: COLUMN configuration_numeric.parameter_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.configuration_numeric.parameter_number IS 'Einstellungs-Nummer';


--
-- Name: COLUMN configuration_numeric.subsidiary; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.configuration_numeric.subsidiary IS 'Einstellungen, die nicht abweichend je Betrieb hinterlegt werden können, haben hier den Wert 0 (zero). Ansonsten wird hier die Betriebsstätte angegeben, für die diese Einstellung gilt.';


--
-- Name: COLUMN configuration_numeric.text_value; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.configuration_numeric.text_value IS 'Wert der Einstellung als Text';


--
-- Name: COLUMN configuration_numeric.description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.configuration_numeric.description IS 'Beschreibung';


--
-- Name: countries; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.countries (
    code character varying(3) NOT NULL,
    description character varying(40),
    iso3166_alpha2 character varying(2)
);


ALTER TABLE public.countries OWNER TO postgres;

--
-- Name: TABLE countries; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.countries IS 'Liste der Länderkennzeichen (Zuweisung zu ISO-Code Bezeichnung)';


--
-- Name: COLUMN countries.code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.countries.code IS 'Länderkennzeichen';


--
-- Name: COLUMN countries.description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.countries.description IS 'Name des Landes';


--
-- Name: COLUMN countries.iso3166_alpha2; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.countries.iso3166_alpha2 IS 'ISO-Code zu dem Länderkennzeichen';


--
-- Name: customer_codes; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.customer_codes (
    code integer NOT NULL,
    description character varying(42)
);


ALTER TABLE public.customer_codes OWNER TO postgres;

--
-- Name: TABLE customer_codes; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.customer_codes IS 'Liste der möglichen Kundencodes';


--
-- Name: COLUMN customer_codes.code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customer_codes.code IS 'Kunden-Code';


--
-- Name: COLUMN customer_codes.description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customer_codes.description IS 'Bezeichnung des Kundencodes';


--
-- Name: customer_com_numbers; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.customer_com_numbers (
    customer_number integer NOT NULL,
    counter bigint NOT NULL,
    com_type character varying(1),
    is_reference boolean,
    only_on_1st_tab boolean,
    address character varying(300),
    has_contact_person_fields boolean,
    contact_salutation character varying(20),
    contact_firstname character varying(80),
    contact_lastname character varying(80),
    contact_description character varying(80),
    note character varying(80)
);


ALTER TABLE public.customer_com_numbers OWNER TO postgres;

--
-- Name: TABLE customer_com_numbers; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.customer_com_numbers IS 'Kommunikationsnummern je Kunde (Telefon, E-Mail etc.)';


--
-- Name: COLUMN customer_com_numbers.customer_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customer_com_numbers.customer_number IS 'Kundennummer';


--
-- Name: COLUMN customer_com_numbers.counter; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customer_com_numbers.counter IS 'Automatischer Zähler, um mehrere Nummern gleichen des gleichen Typ speichern zu können';


--
-- Name: COLUMN customer_com_numbers.com_type; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customer_com_numbers.com_type IS 'Kommunikationstyp';


--
-- Name: COLUMN customer_com_numbers.is_reference; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customer_com_numbers.is_reference IS 'Diese Nummer ist die Referenznummer (trie)';


--
-- Name: COLUMN customer_com_numbers.only_on_1st_tab; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customer_com_numbers.only_on_1st_tab IS 'In Loco-Soft können drei Nummern im ersten Tab des Kunden angegeben werden. Diese Nummern/Adressen sind mit only_on_1st_tab = true gekennzeichnet. Die Nummern aus dem ersten Tab können keine Referenz,';


--
-- Name: COLUMN customer_com_numbers.address; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customer_com_numbers.address IS 'Adresse, bzw. Nummern (also z.B. die E-Mail Adresse oder die Telefonnummer)';


--
-- Name: COLUMN customer_com_numbers.has_contact_person_fields; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customer_com_numbers.has_contact_person_fields IS 'In Loco-Soft kann bei jeder Adresse, bzw. Nummer, ein Ansprechpartner mit Anrede, Vorname und Nachname angegeben werden, oder eine allgemeine Beschreibung ohne das genannte Schema. Steht dieses Feld a';


--
-- Name: COLUMN customer_com_numbers.contact_salutation; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customer_com_numbers.contact_salutation IS 'Anrede des eventuell abweichenden Ansprechpartners';


--
-- Name: COLUMN customer_com_numbers.contact_firstname; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customer_com_numbers.contact_firstname IS 'Vorname des eventuell abweichenden Ansprechpartners';


--
-- Name: COLUMN customer_com_numbers.contact_lastname; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customer_com_numbers.contact_lastname IS 'Vorname des eventuell abweichenden Ansprechpartners';


--
-- Name: COLUMN customer_com_numbers.contact_description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customer_com_numbers.contact_description IS 'Allgemeine Beschreibung des eventuell abweichenden Ansprechpartners';


--
-- Name: COLUMN customer_com_numbers.note; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customer_com_numbers.note IS 'Ggf. frei eingebbare Notiz zu dieser Nummer/Adresse';


--
-- Name: customer_profession_codes; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.customer_profession_codes (
    code integer NOT NULL,
    description character varying(42)
);


ALTER TABLE public.customer_profession_codes OWNER TO postgres;

--
-- Name: TABLE customer_profession_codes; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.customer_profession_codes IS 'Berufsschlüssel';


--
-- Name: COLUMN customer_profession_codes.code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customer_profession_codes.code IS 'Berufsschlüssel';


--
-- Name: COLUMN customer_profession_codes.description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customer_profession_codes.description IS 'Bezeichnung des Berufschlüssels';


--
-- Name: customer_supplier_bank_information; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.customer_supplier_bank_information (
    customer_number integer NOT NULL,
    iban character varying(35),
    swift character varying(15),
    sepa_mandate_start_date date,
    note character varying(40)
);


ALTER TABLE public.customer_supplier_bank_information OWNER TO postgres;

--
-- Name: TABLE customer_supplier_bank_information; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.customer_supplier_bank_information IS 'Bankdaten inklusive SEPA-Mandat';


--
-- Name: COLUMN customer_supplier_bank_information.customer_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customer_supplier_bank_information.customer_number IS 'Kundennummer';


--
-- Name: COLUMN customer_supplier_bank_information.iban; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customer_supplier_bank_information.iban IS 'IBAN';


--
-- Name: COLUMN customer_supplier_bank_information.swift; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customer_supplier_bank_information.swift IS 'SWIFT';


--
-- Name: COLUMN customer_supplier_bank_information.sepa_mandate_start_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customer_supplier_bank_information.sepa_mandate_start_date IS 'SEPA-Mandat erteilt am';


--
-- Name: COLUMN customer_supplier_bank_information.note; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customer_supplier_bank_information.note IS 'Frei erfassbarer Informationstext';


--
-- Name: customer_to_customercodes; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.customer_to_customercodes (
    customer_number integer NOT NULL,
    customer_code integer NOT NULL
);


ALTER TABLE public.customer_to_customercodes OWNER TO postgres;

--
-- Name: TABLE customer_to_customercodes; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.customer_to_customercodes IS 'Zuordnung von Kunden/Lieferanten zu Kundencodes';


--
-- Name: COLUMN customer_to_customercodes.customer_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customer_to_customercodes.customer_number IS 'Kundennummer';


--
-- Name: COLUMN customer_to_customercodes.customer_code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customer_to_customercodes.customer_code IS 'Kundencode';


--
-- Name: customer_to_professioncodes; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.customer_to_professioncodes (
    customer_number integer NOT NULL,
    profession_code integer NOT NULL
);


ALTER TABLE public.customer_to_professioncodes OWNER TO postgres;

--
-- Name: TABLE customer_to_professioncodes; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.customer_to_professioncodes IS 'Zuordnung von Kunden/Lieferanten zu Berufsschlüssel';


--
-- Name: COLUMN customer_to_professioncodes.customer_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customer_to_professioncodes.customer_number IS 'Kundennummer';


--
-- Name: COLUMN customer_to_professioncodes.profession_code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customer_to_professioncodes.profession_code IS 'Berufsschlüssel';


--
-- Name: customers_suppliers; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.customers_suppliers (
    customer_number integer NOT NULL,
    subsidiary integer,
    is_supplier boolean,
    is_natural_person boolean,
    is_dummy_customer boolean,
    salutation_code character varying(2),
    name_prefix character varying(40) COLLATE pg_catalog."de-x-icu",
    first_name character varying(40) COLLATE pg_catalog."de-x-icu",
    family_name character varying(40) COLLATE pg_catalog."de-x-icu",
    name_postfix character varying(40) COLLATE pg_catalog."de-x-icu",
    country_code character varying(3),
    zip_code character varying(20),
    home_city character varying(40) COLLATE pg_catalog."de-x-icu",
    home_street character varying(40) COLLATE pg_catalog."de-x-icu",
    contact_salutation_code character varying(2),
    contact_family_name character varying(30) COLLATE pg_catalog."de-x-icu",
    contact_first_name character varying(30) COLLATE pg_catalog."de-x-icu",
    contact_note character varying(30) COLLATE pg_catalog."de-x-icu",
    contact_personal_known boolean,
    parts_rebate_group_buy integer,
    parts_rebate_group_sell integer,
    rebate_labour_percent numeric(9,5),
    rebate_material_percent numeric(9,5),
    rebate_new_vehicles_percent numeric(9,5),
    cash_discount_percent numeric(9,5),
    vat_id_number character varying(20),
    vat_id_number_checked_date date,
    vat_id_free_code_1 integer,
    vat_id_free_code_2 integer,
    birthday date,
    last_contact date,
    preferred_com_number_type character varying(1),
    created_date date,
    created_employee_no integer,
    updated_date date,
    updated_employee_no integer,
    name_updated_date date,
    name_updated_employee_no integer,
    sales_assistant_employee_no integer,
    service_assistant_employee_no integer,
    parts_assistant_employee_no integer,
    lock_by_workstation integer,
    lock_time timestamp without time zone,
    lock_trace character varying(100),
    lock_trigger character varying(100),
    lock_by_employee integer,
    lock_sourcecode character varying(100),
    fullname_vector tsvector GENERATED ALWAYS AS (to_tsvector('simple'::regconfig, (((((((name_prefix)::text || ' '::text) || (first_name)::text) || ' '::text) || (family_name)::text) || ' '::text) || (name_postfix)::text))) STORED
);


ALTER TABLE public.customers_suppliers OWNER TO postgres;

--
-- Name: TABLE customers_suppliers; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.customers_suppliers IS 'Kunden und Lieferaten';


--
-- Name: COLUMN customers_suppliers.customer_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customers_suppliers.customer_number IS 'Kundennummer oder Lieferantennummer';


--
-- Name: COLUMN customers_suppliers.subsidiary; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customers_suppliers.subsidiary IS 'Zuordnung zu der betreuenden Betriebsstätte';


--
-- Name: COLUMN customers_suppliers.is_supplier; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customers_suppliers.is_supplier IS 'Ist Lieferant: True bedeutet, dass es ein Lieferant ist';


--
-- Name: COLUMN customers_suppliers.is_natural_person; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customers_suppliers.is_natural_person IS 'Ist natürliche Person: True bedeutet, dass der Kunde oder Lieferant ein Mensch ist, also keine Firma oder juristischen Personen. Bei dem Dummy-Kunden ist dieser Wert NULL.';


--
-- Name: COLUMN customers_suppliers.is_dummy_customer; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customers_suppliers.is_dummy_customer IS 'In Loco-Soft kann eine Kundennummer als "DIVERSER KUNDE" angegeben werden (true). Dieser Kunde kann stellvertretend in Aufträgen für alle nicht erfassten Kunden verwendet werden.';


--
-- Name: COLUMN customers_suppliers.salutation_code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customers_suppliers.salutation_code IS 'Anredecode aus Tabelle salutations. Werte 0, 1, 2, 3, 4, 5 oder weitere frei definierbare Werte sind möglich. Der Wert NULL ist auch möglich.';


--
-- Name: COLUMN customers_suppliers.name_prefix; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customers_suppliers.name_prefix IS 'Namensvorsatz, z.B. "Rechtsanwalt"';


--
-- Name: COLUMN customers_suppliers.first_name; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customers_suppliers.first_name IS 'Vorname';


--
-- Name: COLUMN customers_suppliers.family_name; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customers_suppliers.family_name IS 'Nachname oder Firmenname';


--
-- Name: COLUMN customers_suppliers.name_postfix; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customers_suppliers.name_postfix IS 'Namensnachsatz. Hier können u.a. Firmenbezeichnungen wie z.B. "Kfz-Meisterbetrieb" vorkommen';


--
-- Name: COLUMN customers_suppliers.country_code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customers_suppliers.country_code IS 'Ländercode (verweist auf Tabelle countries). Bei inländischen Adressen ist NULL üblich aber nicht obligatorisch. Ländercodes sind benutzerdefiniert.';


--
-- Name: COLUMN customers_suppliers.zip_code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customers_suppliers.zip_code IS 'Postleitzahl als Text';


--
-- Name: COLUMN customers_suppliers.home_city; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customers_suppliers.home_city IS 'Wohnort / Standort';


--
-- Name: COLUMN customers_suppliers.home_street; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customers_suppliers.home_street IS 'Adresse / Straße';


--
-- Name: COLUMN customers_suppliers.contact_salutation_code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customers_suppliers.contact_salutation_code IS 'Ansprechpartner: Anredecode';


--
-- Name: COLUMN customers_suppliers.contact_family_name; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customers_suppliers.contact_family_name IS 'Ansprechpartner: Nachname';


--
-- Name: COLUMN customers_suppliers.contact_first_name; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customers_suppliers.contact_first_name IS 'Ansprechpartner: Vorname';


--
-- Name: COLUMN customers_suppliers.contact_note; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customers_suppliers.contact_note IS 'Ansprechpartner: Hinweis/interne Notiz';


--
-- Name: COLUMN customers_suppliers.contact_personal_known; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customers_suppliers.contact_personal_known IS 'Ansprechpartner: Persönlich bekannt (true/false)';


--
-- Name: COLUMN customers_suppliers.parts_rebate_group_buy; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customers_suppliers.parts_rebate_group_buy IS 'Standard-Teile-Rabattgruppe für den Lieferanten';


--
-- Name: COLUMN customers_suppliers.parts_rebate_group_sell; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customers_suppliers.parts_rebate_group_sell IS 'Teile-Rabattgruppe zur Vorbelegung in Aufträgen';


--
-- Name: COLUMN customers_suppliers.rebate_labour_percent; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customers_suppliers.rebate_labour_percent IS 'Nachlass auf Arbeiten zur Vorbelegung in Aufträgen';


--
-- Name: COLUMN customers_suppliers.rebate_material_percent; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customers_suppliers.rebate_material_percent IS 'Nachlass auf Teile zur Vorbelegung in Aufträgen';


--
-- Name: COLUMN customers_suppliers.rebate_new_vehicles_percent; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customers_suppliers.rebate_new_vehicles_percent IS 'Nachlass auf Neufahrzeuge zur Vorbelegung in Aufträgen';


--
-- Name: COLUMN customers_suppliers.cash_discount_percent; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customers_suppliers.cash_discount_percent IS 'Skonto-Prozentsatz zur Vorbelegung in Aufträgen';


--
-- Name: COLUMN customers_suppliers.vat_id_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customers_suppliers.vat_id_number IS 'USt.ID-Nr. des Kunden/Lieferanten';


--
-- Name: COLUMN customers_suppliers.vat_id_number_checked_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customers_suppliers.vat_id_number_checked_date IS 'Datum der Online-Prüfung der Ust.ID-Nr.';


--
-- Name: COLUMN customers_suppliers.vat_id_free_code_1; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customers_suppliers.vat_id_free_code_1 IS 'Umsatzsteuer-Frei-Kennzeichen (erster Anteil, z.B. 1 für 1-11)';


--
-- Name: COLUMN customers_suppliers.vat_id_free_code_2; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customers_suppliers.vat_id_free_code_2 IS 'Umsatzsteuer-Frei-Kennzeichen (zweiter Anteil, z.B. 11 für 1-11)';


--
-- Name: COLUMN customers_suppliers.birthday; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customers_suppliers.birthday IS 'Geburtsdatum.';


--
-- Name: COLUMN customers_suppliers.last_contact; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customers_suppliers.last_contact IS 'Datum des letzten Kundenkontakts';


--
-- Name: COLUMN customers_suppliers.preferred_com_number_type; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customers_suppliers.preferred_com_number_type IS 'Bevorzugter Kommunikationsweg oder NULL';


--
-- Name: COLUMN customers_suppliers.created_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customers_suppliers.created_date IS 'Datum, an dem dieser Datensatz zuerst erstellt wurde';


--
-- Name: COLUMN customers_suppliers.created_employee_no; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customers_suppliers.created_employee_no IS 'Nummer des Mitarbeiters, der diesen Datensatz zuerst erstellt hat';


--
-- Name: COLUMN customers_suppliers.updated_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customers_suppliers.updated_date IS 'Datum, an dem dieser Datensatz zuletzt geändert wurde';


--
-- Name: COLUMN customers_suppliers.updated_employee_no; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customers_suppliers.updated_employee_no IS 'Nummer des Mitarbeiters, der diesen Datensatz zuletzt geändert hat';


--
-- Name: COLUMN customers_suppliers.name_updated_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customers_suppliers.name_updated_date IS 'Datum, an dem der Name zuletzt geändert wurde';


--
-- Name: COLUMN customers_suppliers.name_updated_employee_no; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customers_suppliers.name_updated_employee_no IS 'Nummer des Mitarbeiters, der den Namen zuletzt geändert hat';


--
-- Name: COLUMN customers_suppliers.sales_assistant_employee_no; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customers_suppliers.sales_assistant_employee_no IS 'Nummer des Mitarbeiters, der als Verkaufsberater zugewiesen wurde';


--
-- Name: COLUMN customers_suppliers.service_assistant_employee_no; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customers_suppliers.service_assistant_employee_no IS 'Nummer des Mitarbeiters, der als Serviceberater zugewiesen wurde';


--
-- Name: COLUMN customers_suppliers.parts_assistant_employee_no; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customers_suppliers.parts_assistant_employee_no IS 'Nummer des Mitarbeiters, der als Berater für Teile und Zubehör zugewiesen wurde';


--
-- Name: COLUMN customers_suppliers.lock_by_workstation; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customers_suppliers.lock_by_workstation IS 'Protokollierung von Datensatz-Sperren: Arbeitsplatznummer, der die Sperre erzeugt hat oder NULL.';


--
-- Name: COLUMN customers_suppliers.lock_time; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customers_suppliers.lock_time IS 'Protokollierung von Datensatz-Sperren: Zeitstempel, an dem der Datensatz mit Sperre zuletzt geändert wurde oder NULL.';


--
-- Name: COLUMN customers_suppliers.lock_trace; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customers_suppliers.lock_trace IS 'Protokollierung von Datensatz-Sperren: Reihenfolge der aufgerufenen Programme bei letztem Update des Datesatzes oder NULL.';


--
-- Name: COLUMN customers_suppliers.lock_trigger; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customers_suppliers.lock_trigger IS 'Protokollierung von Datensatz-Sperren: Dienstname oder UI-Information oder NULL.';


--
-- Name: COLUMN customers_suppliers.lock_by_employee; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customers_suppliers.lock_by_employee IS 'Protokollierung von Datensatz-Sperren: Interne Mitarbeiter-Nr. oder NULL.';


--
-- Name: COLUMN customers_suppliers.lock_sourcecode; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.customers_suppliers.lock_sourcecode IS 'Protokollierung von Datensatz-Sperren: Programmstelle oder NULL.';


--
-- Name: dealer_vehicles; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.dealer_vehicles (
    dealer_vehicle_type character varying(1) NOT NULL,
    dealer_vehicle_number integer NOT NULL,
    vehicle_number integer,
    location character varying(10),
    buyer_customer_no integer,
    deregistration_date date,
    refinancing_start_date date,
    refinancing_end_date date,
    refinancing_value numeric(9,2),
    refinancing_refundment numeric(9,2),
    refinancing_bank_customer_no integer,
    refinanc_interest_free_date date,
    in_subsidiary integer,
    in_buy_salesman_number integer,
    in_buy_order_no character varying(15),
    in_buy_order_no_date date,
    in_buy_invoice_no character varying(12),
    in_buy_invoice_no_date date,
    in_buy_edp_order_no character varying(15),
    in_buy_edp_order_no_date date,
    in_is_trade_in_ken character varying(1),
    in_is_trade_in_kom integer,
    in_used_vehicle_buy_type character varying(2),
    in_buy_list_price numeric(9,2),
    in_arrival_date date,
    in_expected_arrival_date date,
    in_accounting_document_type character varying(1),
    in_accounting_document_number bigint,
    in_accounting_document_date date,
    in_acntg_exceptional_group character varying(4),
    in_acntg_cost_unit_new_vehicle numeric(2,0),
    in_accounting_make numeric(2,0),
    in_registration_reference character varying(10),
    in_expected_repair_cost numeric(9,2),
    in_order_status character varying(2),
    out_subsidiary integer,
    out_is_ready_for_sale boolean,
    out_ready_for_sale_date date,
    out_sale_type character varying(1),
    out_sales_contract_number character varying(12),
    out_sales_contract_date date,
    out_is_sales_contract_confrmed boolean,
    out_salesman_number_1 integer,
    out_salesman_number_2 integer,
    out_desired_shipment_date date,
    out_is_registration_included boolean,
    out_recommended_retail_price numeric(9,2),
    out_extra_expenses numeric(9,2),
    out_sale_price numeric(9,2),
    out_sale_price_dealer numeric(9,2),
    out_sale_price_minimum numeric(9,2),
    out_sale_price_internet numeric(9,2),
    out_estimated_invoice_value numeric(9,2),
    out_discount_percent_vehicle numeric(9,5),
    out_discount_percent_accessory numeric(9,5),
    out_order_number integer,
    out_invoice_type integer,
    out_invoice_number integer,
    out_invoice_date date,
    out_deposit_invoice_type integer,
    out_deposit_invoice_number integer,
    out_deposit_value numeric(9,2),
    out_license_plate character varying(12),
    out_make_number integer,
    out_model_code character varying(25),
    out_license_plate_country character varying(3),
    out_license_plate_season character varying(6),
    calc_basic_charge numeric(9,2),
    calc_accessory numeric(9,2),
    calc_extra_expenses numeric(9,2),
    calc_usage_value_encr_external numeric(9,2),
    calc_usage_value_encr_internal numeric(9,2),
    calc_usage_value_encr_other numeric(9,2),
    calc_total_writedown numeric(9,2),
    calc_cost_percent_stockingdays numeric(3,0),
    calc_interest_percent_stkdays numeric(6,3),
    calc_actual_payed_interest numeric(9,2),
    calc_commission_for_arranging numeric(9,2),
    calc_commission_for_salesman numeric(9,2),
    calc_cost_internal_invoices numeric(9,2),
    calc_cost_other numeric(9,2),
    calc_sales_aid numeric(9,2),
    calc_sales_aid_finish numeric(9,2),
    calc_sales_aid_bonus numeric(9,2),
    calc_returns_workshop numeric(9,2),
    exclusive_reserved_employee_no integer,
    exclusive_reserved_until date,
    pre_owned_car_code character varying(1),
    is_sale_internet boolean,
    is_sale_prohibit boolean,
    is_agency_business boolean,
    is_rental_or_school_vehicle boolean,
    previous_owner_number integer,
    mileage_km integer,
    memo character varying(80),
    keys_box_number integer,
    last_change_date date,
    last_change_employee_no integer,
    created_date date,
    created_employee_no integer,
    has_financing_example boolean,
    has_leasing_example_ref boolean,
    deactivated_by_employee_no integer,
    deactivated_date date,
    access_limit integer,
    lock_by_workstation integer,
    lock_time timestamp without time zone,
    lock_trace character varying(100),
    lock_trigger character varying(100),
    lock_by_employee integer,
    lock_sourcecode character varying(100)
);


ALTER TABLE public.dealer_vehicles OWNER TO postgres;

--
-- Name: TABLE dealer_vehicles; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.dealer_vehicles IS 'Händlerfahrzeug-Daten';


--
-- Name: COLUMN dealer_vehicles.dealer_vehicle_type; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.dealer_vehicle_type IS 'Fahrzeugart (erster Teil der Kommissionsnummer)';


--
-- Name: COLUMN dealer_vehicles.dealer_vehicle_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.dealer_vehicle_number IS 'Kommissionsnummer';


--
-- Name: COLUMN dealer_vehicles.vehicle_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.vehicle_number IS 'Interne Fahrzeugnummer';


--
-- Name: COLUMN dealer_vehicles.location; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.location IS 'Standort';


--
-- Name: COLUMN dealer_vehicles.buyer_customer_no; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.buyer_customer_no IS 'Kundennummer des eingetragenen Käufers';


--
-- Name: COLUMN dealer_vehicles.deregistration_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.deregistration_date IS 'Zulassung abgemeldet zum ...';


--
-- Name: COLUMN dealer_vehicles.refinancing_start_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.refinancing_start_date IS 'Refinanzierung seit dem ...';


--
-- Name: COLUMN dealer_vehicles.refinancing_end_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.refinancing_end_date IS 'Refinanzierung bis zum ...';


--
-- Name: COLUMN dealer_vehicles.refinancing_value; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.refinancing_value IS 'Refinanzierter Betrag';


--
-- Name: COLUMN dealer_vehicles.refinancing_refundment; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.refinancing_refundment IS 'Von dem refinanzierten Betrag zurückgezahlter Betrag';


--
-- Name: COLUMN dealer_vehicles.refinancing_bank_customer_no; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.refinancing_bank_customer_no IS 'Kundennummer der Refinanzierungs-Bank';


--
-- Name: COLUMN dealer_vehicles.refinanc_interest_free_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.refinanc_interest_free_date IS 'Fahrzeug zinsfrei bis ...';


--
-- Name: COLUMN dealer_vehicles.in_subsidiary; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.in_subsidiary IS 'Ankaufende Betriebsstätte';


--
-- Name: COLUMN dealer_vehicles.in_buy_salesman_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.in_buy_salesman_number IS 'Ankaufender Verkaufsberater';


--
-- Name: COLUMN dealer_vehicles.in_buy_order_no; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.in_buy_order_no IS 'Auftragsnummer / VA-Nummer';


--
-- Name: COLUMN dealer_vehicles.in_buy_order_no_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.in_buy_order_no_date IS 'Datum zu in_buy_order_no';


--
-- Name: COLUMN dealer_vehicles.in_buy_invoice_no; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.in_buy_invoice_no IS 'Eingangs-Bestellreferenz. Z.B. Eingangs-Rg-Nr., Lieferschein-Nr. oder Vertragsnummer';


--
-- Name: COLUMN dealer_vehicles.in_buy_invoice_no_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.in_buy_invoice_no_date IS 'Datum zu in_buy_invoice_no';


--
-- Name: COLUMN dealer_vehicles.in_buy_edp_order_no; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.in_buy_edp_order_no IS 'EDV-Bestellnummer';


--
-- Name: COLUMN dealer_vehicles.in_buy_edp_order_no_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.in_buy_edp_order_no_date IS 'Datum zu in_buy_edp_order_no';


--
-- Name: COLUMN dealer_vehicles.in_is_trade_in_ken; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.in_is_trade_in_ken IS 'Wenn dieses Fahrzeug ein Ankaufsfahrzeug war, dann wird hier die Fahrzeugart der Kommissions-Nr. des an den Kunden verkauften Fahrzeugs angegeben';


--
-- Name: COLUMN dealer_vehicles.in_is_trade_in_kom; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.in_is_trade_in_kom IS 'Kommissionsnummer zu buy_is_trade_in_ken';


--
-- Name: COLUMN dealer_vehicles.in_used_vehicle_buy_type; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.in_used_vehicle_buy_type IS 'Ankaufs-/Zugangstyp bei gebrauchten Fahrzeugen';


--
-- Name: COLUMN dealer_vehicles.in_buy_list_price; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.in_buy_list_price IS 'Einkaufspreis laut Liste';


--
-- Name: COLUMN dealer_vehicles.in_arrival_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.in_arrival_date IS 'Datum des echten Farzeugeingangs';


--
-- Name: COLUMN dealer_vehicles.in_expected_arrival_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.in_expected_arrival_date IS 'Datum des geplanten/erwarteten Fahrzeugeingangs';


--
-- Name: COLUMN dealer_vehicles.in_accounting_document_type; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.in_accounting_document_type IS 'Ankauf / Belegart zu Beleg-Nr. in der Finanzbuchhaltung';


--
-- Name: COLUMN dealer_vehicles.in_accounting_document_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.in_accounting_document_number IS 'Ankauf / Beleg-Nr. in der Finanzbuchhaltung';


--
-- Name: COLUMN dealer_vehicles.in_accounting_document_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.in_accounting_document_date IS 'Belegdatum des Ankaufs';


--
-- Name: COLUMN dealer_vehicles.in_acntg_exceptional_group; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.in_acntg_exceptional_group IS 'Ankauf / Sonderkonten-Gruppe (SOKO)';


--
-- Name: COLUMN dealer_vehicles.in_acntg_cost_unit_new_vehicle; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.in_acntg_cost_unit_new_vehicle IS 'Bei Verwendung des SKR51 Kostenträgermerkmal bei Neufahrzeugen (kann nach Änderung der Fahrzeugart auch bei gebrauchten Fahrzeugen belegt sein)';


--
-- Name: COLUMN dealer_vehicles.in_accounting_make; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.in_accounting_make IS 'Bei Verwendung des SKR51 Markenbezug bei Fahrzeugen, die nicht als Neufahrzeug gelten';


--
-- Name: COLUMN dealer_vehicles.in_registration_reference; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.in_registration_reference IS 'Fahrzeug Zulassungsreferenz (z.B. bei Opel OPA-Nr.)';


--
-- Name: COLUMN dealer_vehicles.in_expected_repair_cost; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.in_expected_repair_cost IS 'Erwartete Reparaturkosten';


--
-- Name: COLUMN dealer_vehicles.in_order_status; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.in_order_status IS 'Frei vergebbarer Fahrzeug-Bestellstatus';


--
-- Name: COLUMN dealer_vehicles.out_subsidiary; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.out_subsidiary IS 'Verkaufende Betriebsstätte';


--
-- Name: COLUMN dealer_vehicles.out_is_ready_for_sale; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.out_is_ready_for_sale IS 'Das Fahrzeug ist verkaufsfertig';


--
-- Name: COLUMN dealer_vehicles.out_ready_for_sale_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.out_ready_for_sale_date IS 'Verkaufsfertig seit';


--
-- Name: COLUMN dealer_vehicles.out_sale_type; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.out_sale_type IS 'Verkaufsart';


--
-- Name: COLUMN dealer_vehicles.out_sales_contract_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.out_sales_contract_number IS 'Kaufvertrag-Nr.';


--
-- Name: COLUMN dealer_vehicles.out_sales_contract_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.out_sales_contract_date IS 'Kaufvertrag vom ...';


--
-- Name: COLUMN dealer_vehicles.out_is_sales_contract_confrmed; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.out_is_sales_contract_confrmed IS 'Kaufvertrag ist bestätigt';


--
-- Name: COLUMN dealer_vehicles.out_salesman_number_1; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.out_salesman_number_1 IS 'Verkaufender Verkaufsberater Nr. 1';


--
-- Name: COLUMN dealer_vehicles.out_salesman_number_2; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.out_salesman_number_2 IS 'Verkaufender Verkaufsberater Nr. 2';


--
-- Name: COLUMN dealer_vehicles.out_desired_shipment_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.out_desired_shipment_date IS 'Gewünschte Auslieferung an Kunden';


--
-- Name: COLUMN dealer_vehicles.out_is_registration_included; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.out_is_registration_included IS 'Zulassung inklusive (z.B. über die Nebenkosten)';


--
-- Name: COLUMN dealer_vehicles.out_recommended_retail_price; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.out_recommended_retail_price IS 'Bei Neufahrzeugen der empfohlene Verkaufspreis, bei Gebrauchtfahrzeugen der ermittelte Marktpreis';


--
-- Name: COLUMN dealer_vehicles.out_extra_expenses; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.out_extra_expenses IS 'Überführung und Nebenkosten';


--
-- Name: COLUMN dealer_vehicles.out_sale_price; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.out_sale_price IS 'Hauspreis';


--
-- Name: COLUMN dealer_vehicles.out_sale_price_dealer; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.out_sale_price_dealer IS 'Abgabepreis an Händler';


--
-- Name: COLUMN dealer_vehicles.out_sale_price_minimum; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.out_sale_price_minimum IS 'Mindestverkaufspreis an Endkunden';


--
-- Name: COLUMN dealer_vehicles.out_sale_price_internet; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.out_sale_price_internet IS 'Internetpreis';


--
-- Name: COLUMN dealer_vehicles.out_estimated_invoice_value; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.out_estimated_invoice_value IS 'Veraussichtliche Rechnungssumme';


--
-- Name: COLUMN dealer_vehicles.out_discount_percent_vehicle; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.out_discount_percent_vehicle IS 'Offener Nachlass auf das Fahrzeug in Prozent';


--
-- Name: COLUMN dealer_vehicles.out_discount_percent_accessory; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.out_discount_percent_accessory IS 'Offener Nachlass auf Zubehör in Prozent';


--
-- Name: COLUMN dealer_vehicles.out_order_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.out_order_number IS 'Auftragsnummer für den Fahrzeug-Verkauf';


--
-- Name: COLUMN dealer_vehicles.out_invoice_type; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.out_invoice_type IS 'Rechnungsart der Ausgangs-Hauptrechnung';


--
-- Name: COLUMN dealer_vehicles.out_invoice_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.out_invoice_number IS 'Rechnungsnummer der Ausgangs-Hauptrechnung';


--
-- Name: COLUMN dealer_vehicles.out_invoice_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.out_invoice_date IS 'Datum der Ausgangs-Hauptrechnung';


--
-- Name: COLUMN dealer_vehicles.out_deposit_invoice_type; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.out_deposit_invoice_type IS 'Rechnungsart der Ausgangs-Anzahlungsrechnung';


--
-- Name: COLUMN dealer_vehicles.out_deposit_invoice_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.out_deposit_invoice_number IS 'Rechnungsnummer der Ausgangs-Anzahlungsrechnung';


--
-- Name: COLUMN dealer_vehicles.out_deposit_value; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.out_deposit_value IS 'Angezahlter Betrag';


--
-- Name: COLUMN dealer_vehicles.out_license_plate; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.out_license_plate IS 'Polizeiliches Kennzeichen zum Zeitpunkt der Fakturierung';


--
-- Name: COLUMN dealer_vehicles.out_make_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.out_make_number IS 'Interne Fabrikatsnummer zum Zeitpunkt der Fakturierung';


--
-- Name: COLUMN dealer_vehicles.out_model_code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.out_model_code IS 'Modellcode zum Zeitpunkt der Fakturierung. Kann null sein oder die Kombination aus make_number und model_code verweist auf Tabelle models(make_number, model_code)';


--
-- Name: COLUMN dealer_vehicles.out_license_plate_country; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.out_license_plate_country IS 'Ländercode des Polizeiliche Kennzeichens zum Zeitpunkt der Fakturierung';


--
-- Name: COLUMN dealer_vehicles.out_license_plate_season; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.out_license_plate_season IS 'Saisonanteil für das Polizeiliche Kennzeichen zum Zeitpunkt der Fakturierung';


--
-- Name: COLUMN dealer_vehicles.calc_basic_charge; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.calc_basic_charge IS 'Fahrzeuggrundpreis - entspricht dem Anschaffungspreis oder dem Ankaufspreis lt. Ankaufsbeleg (Differenzbest.)';


--
-- Name: COLUMN dealer_vehicles.calc_accessory; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.calc_accessory IS 'Zubehör bei Anlieferung';


--
-- Name: COLUMN dealer_vehicles.calc_extra_expenses; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.calc_extra_expenses IS 'Fracht / Brief / Nebenkosten';


--
-- Name: COLUMN dealer_vehicles.calc_usage_value_encr_external; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.calc_usage_value_encr_external IS 'Einsatzwerterterhöhung durch externe Rechnungen';


--
-- Name: COLUMN dealer_vehicles.calc_usage_value_encr_internal; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.calc_usage_value_encr_internal IS 'Einsatzwerterterhöhung durch externe Rechnungen';


--
-- Name: COLUMN dealer_vehicles.calc_usage_value_encr_other; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.calc_usage_value_encr_other IS 'Sonstige Einsatzwerterhöhung';


--
-- Name: COLUMN dealer_vehicles.calc_total_writedown; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.calc_total_writedown IS 'Kumulierte Abschreibungssumme';


--
-- Name: COLUMN dealer_vehicles.calc_cost_percent_stockingdays; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.calc_cost_percent_stockingdays IS 'Prozentsatz für kalkulative Standkosten für Standtage';


--
-- Name: COLUMN dealer_vehicles.calc_interest_percent_stkdays; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.calc_interest_percent_stkdays IS 'Kalkulative Zinsen für Standtage in Prozent';


--
-- Name: COLUMN dealer_vehicles.calc_actual_payed_interest; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.calc_actual_payed_interest IS 'Tatsächlich gezahlte Zinsaufwendungen';


--
-- Name: COLUMN dealer_vehicles.calc_commission_for_arranging; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.calc_commission_for_arranging IS 'Gezahlte Provision für Vermittlung';


--
-- Name: COLUMN dealer_vehicles.calc_commission_for_salesman; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.calc_commission_for_salesman IS 'Gezahlte Provision für Verkäufer';


--
-- Name: COLUMN dealer_vehicles.calc_cost_internal_invoices; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.calc_cost_internal_invoices IS 'Kosten interne Rechnungen';


--
-- Name: COLUMN dealer_vehicles.calc_cost_other; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.calc_cost_other IS 'Sonstige Kosten';


--
-- Name: COLUMN dealer_vehicles.calc_sales_aid; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.calc_sales_aid IS 'Verkaufshilfen (durch Hersteller)';


--
-- Name: COLUMN dealer_vehicles.calc_sales_aid_finish; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.calc_sales_aid_finish IS 'Finish-Vergütungen';


--
-- Name: COLUMN dealer_vehicles.calc_sales_aid_bonus; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.calc_sales_aid_bonus IS 'Bonus durch Hersteller';


--
-- Name: COLUMN dealer_vehicles.calc_returns_workshop; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.calc_returns_workshop IS 'Erlöse aus Werkstattrechnungen';


--
-- Name: COLUMN dealer_vehicles.exclusive_reserved_employee_no; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.exclusive_reserved_employee_no IS 'Fahrzeug reserviert durch Mitarbeiter Nr.';


--
-- Name: COLUMN dealer_vehicles.exclusive_reserved_until; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.exclusive_reserved_until IS 'Fahrzeug reserviert bis';


--
-- Name: COLUMN dealer_vehicles.pre_owned_car_code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.pre_owned_car_code IS 'Jahreswagen-Kennzeichen';


--
-- Name: COLUMN dealer_vehicles.is_sale_internet; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.is_sale_internet IS 'Das Fahrzeug ist zum Verkauf in Internetbörsen freigegeben';


--
-- Name: COLUMN dealer_vehicles.is_sale_prohibit; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.is_sale_prohibit IS 'Das Fahrzeug darf nicht im "Normalgeschäft" verkauft werden (falls true)';


--
-- Name: COLUMN dealer_vehicles.is_agency_business; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.is_agency_business IS 'Verkauf als Agenturgeschäft';


--
-- Name: COLUMN dealer_vehicles.is_rental_or_school_vehicle; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.is_rental_or_school_vehicle IS 'Das Fahrzeug war ein Miet- oder Fahrschul-Fahrzeug';


--
-- Name: COLUMN dealer_vehicles.previous_owner_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.previous_owner_number IS 'Vorbesitzer-Kundennummer des Fahrzeugs';


--
-- Name: COLUMN dealer_vehicles.mileage_km; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.mileage_km IS 'Laufleistung in Kilometern';


--
-- Name: COLUMN dealer_vehicles.memo; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.memo IS 'Memo';


--
-- Name: COLUMN dealer_vehicles.keys_box_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.keys_box_number IS 'Schlüsselkasten-Nummer';


--
-- Name: COLUMN dealer_vehicles.last_change_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.last_change_date IS 'Datum, an dem dieser Datensatz zuletzt geändert wurde';


--
-- Name: COLUMN dealer_vehicles.last_change_employee_no; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.last_change_employee_no IS 'Nummer des Mitarbeiters, der diesen Datensatz zuletzt geändert hat';


--
-- Name: COLUMN dealer_vehicles.created_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.created_date IS 'Datum, an dem dieser Datensatz zuerst erstellt wurde';


--
-- Name: COLUMN dealer_vehicles.created_employee_no; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.created_employee_no IS 'Nummer des Mitarbeiters, der diesen Datensatz zuerst erstellt hat';


--
-- Name: COLUMN dealer_vehicles.has_financing_example; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.has_financing_example IS 'True = es existiert ein Finanzierungsbeispiel zu dem Fahrzeug in Tabelle financing_examples';


--
-- Name: COLUMN dealer_vehicles.has_leasing_example_ref; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.has_leasing_example_ref IS 'True = es existiert ein Leasingbeispiel zu dem Fahrzeug in Tabelle leasing_examples';


--
-- Name: COLUMN dealer_vehicles.deactivated_by_employee_no; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.deactivated_by_employee_no IS 'Fahrzeug wurde durch Mitarbeiter deaktiviert oder NULL';


--
-- Name: COLUMN dealer_vehicles.deactivated_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.deactivated_date IS 'Fahrzeug wurde an diesem Datum deaktiviert oder NULL';


--
-- Name: COLUMN dealer_vehicles.access_limit; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.access_limit IS 'Mitarbeiter-Zugriffsschlüssel, ab dem dieses Fahrzeug angezeigt werden darf (0 = keine Sperre)';


--
-- Name: COLUMN dealer_vehicles.lock_by_workstation; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.lock_by_workstation IS 'Protokollierung von Datensatz-Sperren: Arbeitsplatznummer, der die Sperre erzeugt hat oder NULL.';


--
-- Name: COLUMN dealer_vehicles.lock_time; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.lock_time IS 'Protokollierung von Datensatz-Sperren: Zeitstempel, an dem der Datensatz mit Sperre zuletzt geändert wurde oder NULL.';


--
-- Name: COLUMN dealer_vehicles.lock_trace; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.lock_trace IS 'Protokollierung von Datensatz-Sperren: Reihenfolge der aufgerufenen Programme bei letztem Update des Datesatzes oder NULL.';


--
-- Name: COLUMN dealer_vehicles.lock_trigger; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.lock_trigger IS 'Protokollierung von Datensatz-Sperren: Dienstname oder UI-Information oder NULL.';


--
-- Name: COLUMN dealer_vehicles.lock_by_employee; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.lock_by_employee IS 'Protokollierung von Datensatz-Sperren: Interne Mitarbeiter-Nr. oder NULL.';


--
-- Name: COLUMN dealer_vehicles.lock_sourcecode; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.dealer_vehicles.lock_sourcecode IS 'Protokollierung von Datensatz-Sperren: Programmstelle oder NULL.';


--
-- Name: document_types; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.document_types (
    document_type_in_journal text NOT NULL,
    document_type_description text
);


ALTER TABLE public.document_types OWNER TO postgres;

--
-- Name: TABLE document_types; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.document_types IS 'Kennzeichen zur Gruppierung von Belegen';


--
-- Name: COLUMN document_types.document_type_in_journal; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.document_types.document_type_in_journal IS 'BelegArtInJournal:Belegarten aus Tabelle Journalbuchungen';


--
-- Name: COLUMN document_types.document_type_description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.document_types.document_type_description IS 'BelegArtBezeichnung:';


--
-- Name: employees_history; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.employees_history (
    is_latest_record boolean,
    employee_number integer NOT NULL,
    validity_date date NOT NULL,
    subsidiary integer,
    has_constant_salary boolean,
    name character varying(25),
    initials character varying(3),
    customer_number integer,
    mechanic_number integer,
    salesman_number integer,
    is_business_executive boolean,
    is_master_craftsman boolean,
    employment_date date,
    termination_date date,
    leave_date date,
    is_flextime boolean,
    break_time_registration character varying(10),
    productivity_factor numeric(2,1),
    CONSTRAINT employees_history_employee_number_check CHECK ((employee_number > 0))
);


ALTER TABLE public.employees_history OWNER TO postgres;

--
-- Name: TABLE employees_history; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.employees_history IS 'Mitarbeiter Historie';


--
-- Name: COLUMN employees_history.is_latest_record; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.employees_history.is_latest_record IS 'Zu einem Mitarbeiter kann es mehrere Datensätze geben. Der aktuelle Datensatz des Mitarbeiters ist durch is_lastest_record = true gekennzeichnet.';


--
-- Name: COLUMN employees_history.employee_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.employees_history.employee_number IS 'Mitarbeiter-Nummer';


--
-- Name: COLUMN employees_history.validity_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.employees_history.validity_date IS 'Gültigkeitsdatum, ab wann dieser Datensatz gültig ist (mit jeder Änderung an den Mitarbeiterdaten entsteht ein neuer Datensatz)';


--
-- Name: COLUMN employees_history.subsidiary; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.employees_history.subsidiary IS 'Betriebsstätte';


--
-- Name: COLUMN employees_history.has_constant_salary; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.employees_history.has_constant_salary IS 'Der Mitarbeiter bekommt ein festes Gehalt (true) oder einen Stundenlohn (false)';


--
-- Name: COLUMN employees_history.name; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.employees_history.name IS 'Name des Mitarbeiters';


--
-- Name: COLUMN employees_history.initials; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.employees_history.initials IS 'Initialen des Mitarbeiters';


--
-- Name: COLUMN employees_history.customer_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.employees_history.customer_number IS 'Optional kann ein Mitarbeiter mit einem Datensatz in customers_suppliers verbunden werden';


--
-- Name: COLUMN employees_history.mechanic_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.employees_history.mechanic_number IS 'Wenn der Mitarbeiter ein Monteur ist, hat er eine Monteur-Nummer';


--
-- Name: COLUMN employees_history.salesman_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.employees_history.salesman_number IS 'Wenn der Mitarbeiter ein Verkäufer ist, hat er eine Verkäufer-Nummer';


--
-- Name: COLUMN employees_history.is_business_executive; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.employees_history.is_business_executive IS 'Der Mitarbeiter ist Geschäftsführer (true)';


--
-- Name: COLUMN employees_history.is_master_craftsman; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.employees_history.is_master_craftsman IS 'Der Mitarbeiter ist Meister in dem Werkstattbetrieb (true)';


--
-- Name: COLUMN employees_history.employment_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.employees_history.employment_date IS 'Eintrittsdatum, ab dem die Einstellung gilt';


--
-- Name: COLUMN employees_history.termination_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.employees_history.termination_date IS 'Datum, ab dem das Anstellungsverhältnis laut Kündigung endet';


--
-- Name: COLUMN employees_history.leave_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.employees_history.leave_date IS 'Datum, ab dem der Mitarbeiter den Betrieb verlassen hat. Das Datum kann auf Grund von Urlaub von dem Kündigungsdatum abweichen.';


--
-- Name: COLUMN employees_history.is_flextime; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.employees_history.is_flextime IS 'Wenn der Mitarbeiter feste Arbeitszeiten hat, steht das Feld auf false. Wenn er Gleitzeit hat, steht es auf true.';


--
-- Name: COLUMN employees_history.break_time_registration; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.employees_history.break_time_registration IS 'Mitarbeiter stempelt wie folgt: self: Pausen stempelt er selber, automatic: Pausen müssen von Zeiten abgezogen werden, order: Pausen müssen nicht von Auftragstempelung abgezogen werden';


--
-- Name: COLUMN employees_history.productivity_factor; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.employees_history.productivity_factor IS 'wird in der Gegenüberstellung der Stempelzeitenverteilung benutzt, um die Stempel-AW der Leistung des Mitarbeiters anzupassen';


--
-- Name: employees; Type: VIEW; Schema: public; Owner: postgres
--

CREATE VIEW public.employees AS
 SELECT employees_history.is_latest_record,
    employees_history.employee_number,
    employees_history.validity_date,
    employees_history.subsidiary,
    employees_history.has_constant_salary,
    employees_history.name,
    employees_history.initials,
    employees_history.customer_number,
    employees_history.mechanic_number,
    employees_history.salesman_number,
    employees_history.is_business_executive,
    employees_history.is_master_craftsman,
    employees_history.employment_date,
    employees_history.termination_date,
    employees_history.leave_date,
    employees_history.is_flextime,
    employees_history.break_time_registration,
    employees_history.productivity_factor
   FROM public.employees_history
  WHERE (employees_history.is_latest_record = true);


ALTER TABLE public.employees OWNER TO postgres;

--
-- Name: employees_breaktimes; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.employees_breaktimes (
    is_latest_record boolean,
    employee_number integer NOT NULL,
    validity_date date NOT NULL,
    dayofweek integer NOT NULL,
    break_start numeric(5,3) NOT NULL,
    break_end numeric(5,3),
    CONSTRAINT employees_breaktimes_employee_number_check CHECK ((employee_number > 0))
);


ALTER TABLE public.employees_breaktimes OWNER TO postgres;

--
-- Name: TABLE employees_breaktimes; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.employees_breaktimes IS 'Mitarbeiter Pausenzeiten';


--
-- Name: COLUMN employees_breaktimes.is_latest_record; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.employees_breaktimes.is_latest_record IS 'Zu einem Mitarbeiter kann es mehrere Datensätze geben. Der aktuelle Datensatz des Mitarbeiters ist durch is_lastest_record = true gekennzeichnet.';


--
-- Name: COLUMN employees_breaktimes.employee_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.employees_breaktimes.employee_number IS 'Mitarbeiter-Nummer';


--
-- Name: COLUMN employees_breaktimes.validity_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.employees_breaktimes.validity_date IS 'Gültigkeitsdatum, ab wann dieser Datensatz gültig ist (mit jeder Änderung an den Mitarbeiterdaten entsteht ein neuer Datensatz)';


--
-- Name: COLUMN employees_breaktimes.dayofweek; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.employees_breaktimes.dayofweek IS 'Wochentag. Montag=1, Dienstag=2, etc.';


--
-- Name: COLUMN employees_breaktimes.break_start; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.employees_breaktimes.break_start IS 'Pausenzeit (Anfang) in Dezimalstunden. Z.B. 8,5 entpricht 08:30 Uhr.';


--
-- Name: COLUMN employees_breaktimes.break_end; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.employees_breaktimes.break_end IS 'Pausenzeit (Ende) in Dezimalstunden. Z.B. 8,5 entpricht 08:30 Uhr.';


--
-- Name: employees_worktimes; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.employees_worktimes (
    is_latest_record boolean,
    employee_number integer NOT NULL,
    validity_date date NOT NULL,
    dayofweek integer NOT NULL,
    work_duration numeric(5,3),
    worktime_start numeric(5,3),
    worktime_end numeric(5,3),
    CONSTRAINT employees_worktimes_employee_number_check CHECK ((employee_number > 0))
);


ALTER TABLE public.employees_worktimes OWNER TO postgres;

--
-- Name: TABLE employees_worktimes; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.employees_worktimes IS 'Mitarbeiter Arbeitszeiten';


--
-- Name: COLUMN employees_worktimes.is_latest_record; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.employees_worktimes.is_latest_record IS 'Zu einem Mitarbeiter kann es mehrere Datensätze geben. Der aktuelle Datensatz des Mitarbeiters ist durch is_lastest_record = true gekennzeichnet.';


--
-- Name: COLUMN employees_worktimes.employee_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.employees_worktimes.employee_number IS 'Mitarbeiter-Nummer';


--
-- Name: COLUMN employees_worktimes.validity_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.employees_worktimes.validity_date IS 'Gültigkeitsdatum, ab wann dieser Datensatz gültig ist (mit jeder Änderung an den Mitarbeiterdaten entsteht ein neuer Datensatz)';


--
-- Name: COLUMN employees_worktimes.dayofweek; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.employees_worktimes.dayofweek IS 'Wochentag. Montag=1, Dienstag=2, etc.';


--
-- Name: COLUMN employees_worktimes.work_duration; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.employees_worktimes.work_duration IS 'Arbeitszeit (Dauer) in Dezimalstunden. Z.B. 8,5 entpricht 08:30 Uhr. Die Pausenzeiten sind bereits abgezogen.';


--
-- Name: COLUMN employees_worktimes.worktime_start; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.employees_worktimes.worktime_start IS 'Arbeitszeit (Anfang) in Dezimalstunden. Z.B. 8,5 entpricht 08:30 Uhr. Bei Gleitzeit steht das Feld auf NULL.';


--
-- Name: COLUMN employees_worktimes.worktime_end; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.employees_worktimes.worktime_end IS 'Arbeitszeit (Ende) in Dezimalstunden. Z.B. 8,5 entpricht 08:30 Uhr. Bei Gleitzeit steht das Feld auf NULL.';


--
-- Name: external_customer_references; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.external_customer_references (
    api_type character varying(4) NOT NULL,
    api_id character varying(10) NOT NULL,
    customer_number integer NOT NULL,
    subsidiary integer NOT NULL,
    reference character varying(100),
    last_received_time timestamp without time zone,
    version character varying(30)
);


ALTER TABLE public.external_customer_references OWNER TO postgres;

--
-- Name: TABLE external_customer_references; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.external_customer_references IS 'Fremdreferenzen zu Kunden von Drittanbietersystemen / Verkäuferarbeitsplätzen';


--
-- Name: COLUMN external_customer_references.api_type; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.external_customer_references.api_type IS 'Kategorie der Schnittstelle aus Tabelle external_reference_parties';


--
-- Name: COLUMN external_customer_references.api_id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.external_customer_references.api_id IS 'Internes Kennzeichen der Schnittstelle aus Tabelle external_reference_parties';


--
-- Name: COLUMN external_customer_references.customer_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.external_customer_references.customer_number IS 'Kundennummer in Tabelle customers_suppliers, auf den sich diese Referenz bezieht.';


--
-- Name: COLUMN external_customer_references.subsidiary; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.external_customer_references.subsidiary IS 'Bei manchen Systemen kann die Referenz in Betriebsstätten abweichend sein. Hier sind Werte ab 0 aufsteigend möglich.';


--
-- Name: COLUMN external_customer_references.reference; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.external_customer_references.reference IS 'Code, unter dem der Kunde bei dem Anbieter des Verkäuferarbeitsplatzes / der Schnittstelle gefunden werden kann.';


--
-- Name: COLUMN external_customer_references.last_received_time; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.external_customer_references.last_received_time IS 'Zeitpunkt, an dem diese Referenz zuletzt empfangen wurde';


--
-- Name: COLUMN external_customer_references.version; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.external_customer_references.version IS '?';


--
-- Name: external_reference_parties; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.external_reference_parties (
    api_type character varying(4) NOT NULL,
    api_id character varying(10) NOT NULL,
    make character varying(4),
    description character varying(50)
);


ALTER TABLE public.external_reference_parties OWNER TO postgres;

--
-- Name: TABLE external_reference_parties; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.external_reference_parties IS 'Drittanbietersysteme von Verkäuferarbeitsplätzen etc.';


--
-- Name: COLUMN external_reference_parties.api_type; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.external_reference_parties.api_type IS 'Kategorie der Schnittstelle. VAP = Verkäufer-Arbeitsplätze und ähnliches aus Programm 749';


--
-- Name: COLUMN external_reference_parties.api_id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.external_reference_parties.api_id IS 'Internes Kennzeichen der Schnittstelle in Loco-Soft';


--
-- Name: COLUMN external_reference_parties.make; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.external_reference_parties.make IS 'Zuordnung zu Fabrikat oder Konzern auf 4 Zeichen gekürzt und in Großbuchstaben (z.B. SUZU = Suzuki)';


--
-- Name: COLUMN external_reference_parties.description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.external_reference_parties.description IS 'Name der Schnittstelle, bzw. des Verkäuferarbeitsplatzes in Loco-Soft';


--
-- Name: financing_examples; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.financing_examples (
    id integer NOT NULL,
    initial_payment numeric(9,2),
    loan_amount numeric(9,2),
    number_rates integer,
    annual_percentage_rate numeric(4,2),
    debit_interest numeric(4,2),
    debit_interest_type character varying(20),
    monthly_rate numeric(9,2),
    differing_first_rate numeric(9,2),
    last_rate numeric(9,2),
    rate_insurance numeric(9,2),
    acquisition_fee numeric(9,2),
    total numeric(9,2),
    interest_free_credit_until date,
    interest_free_credit_amount numeric(9,2),
    due_date integer,
    due_date_last_rate integer,
    bank_customer_no integer,
    source character varying(15),
    referenced_dealer_vehicle_type character varying(1),
    referenced_dealer_vehicle_no integer
);


ALTER TABLE public.financing_examples OWNER TO postgres;

--
-- Name: TABLE financing_examples; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.financing_examples IS 'Beispielfinanzierungen';


--
-- Name: COLUMN financing_examples.id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.financing_examples.id IS 'Laufende Nummer als Primärschlüssel ohne weitere Bedeutung. Der Wert kann sich zwischen den Exporten ändern';


--
-- Name: COLUMN financing_examples.initial_payment; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.financing_examples.initial_payment IS 'Anzahlung';


--
-- Name: COLUMN financing_examples.loan_amount; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.financing_examples.loan_amount IS 'Darlehensbetrag';


--
-- Name: COLUMN financing_examples.number_rates; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.financing_examples.number_rates IS 'Laufzeit in Monaten (Anzahl der Monatsraten)';


--
-- Name: COLUMN financing_examples.annual_percentage_rate; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.financing_examples.annual_percentage_rate IS 'Effektiver Jahreszins';


--
-- Name: COLUMN financing_examples.debit_interest; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.financing_examples.debit_interest IS 'Sollzins';


--
-- Name: COLUMN financing_examples.debit_interest_type; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.financing_examples.debit_interest_type IS 'Sollzins-Art (fixed=gebunden,variable=veränderlich,combined=kombiniert)';


--
-- Name: COLUMN financing_examples.monthly_rate; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.financing_examples.monthly_rate IS 'Sollzins';


--
-- Name: COLUMN financing_examples.differing_first_rate; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.financing_examples.differing_first_rate IS 'Abweichende erste Rate (oder NULL)';


--
-- Name: COLUMN financing_examples.last_rate; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.financing_examples.last_rate IS 'Schlußrate die nach Beendigung der Laufzeit fällig wird (oder NULL)';


--
-- Name: COLUMN financing_examples.rate_insurance; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.financing_examples.rate_insurance IS 'Ratenabsicherung';


--
-- Name: COLUMN financing_examples.acquisition_fee; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.financing_examples.acquisition_fee IS 'Abschlussgebühr';


--
-- Name: COLUMN financing_examples.total; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.financing_examples.total IS 'Gesamtbetrag';


--
-- Name: COLUMN financing_examples.interest_free_credit_until; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.financing_examples.interest_free_credit_until IS 'Zinsloser Kredit bei Händler bis zum ...';


--
-- Name: COLUMN financing_examples.interest_free_credit_amount; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.financing_examples.interest_free_credit_amount IS 'Zinsloser Kredit bei Händler in Höhe von ...';


--
-- Name: COLUMN financing_examples.due_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.financing_examples.due_date IS 'Die Abtragung wird jeweils am x. jeden Monat fällig';


--
-- Name: COLUMN financing_examples.due_date_last_rate; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.financing_examples.due_date_last_rate IS 'Am x. des Folgemanats nach Beendigung der Laufzeit wird die Schlußrate fällig';


--
-- Name: COLUMN financing_examples.bank_customer_no; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.financing_examples.bank_customer_no IS 'Kundennummer der Finanzierungsbank';


--
-- Name: COLUMN financing_examples.source; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.financing_examples.source IS 'Dieses Beispiel gehört zu: order=Kaufvertrag,offer=Angebot,dealer_vehicle=Händlerfahrzeug';


--
-- Name: COLUMN financing_examples.referenced_dealer_vehicle_type; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.financing_examples.referenced_dealer_vehicle_type IS 'Falls die Finanzierung zu einem Händlerfahrzeug gehört, steht hier die Fahrzeugart (D/G/L/N/V)';


--
-- Name: COLUMN financing_examples.referenced_dealer_vehicle_no; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.financing_examples.referenced_dealer_vehicle_no IS 'Falls die Finanzierung zu einem Händlerfahrzeug gehört, steht hier die Kommissionsnummer';


--
-- Name: financing_examples_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.financing_examples_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.financing_examples_id_seq OWNER TO postgres;

--
-- Name: financing_examples_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.financing_examples_id_seq OWNED BY public.financing_examples.id;


--
-- Name: fuels; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.fuels (
    code character varying(1) NOT NULL,
    description character varying(200),
    CONSTRAINT fuels_code_check CHECK (((code)::text > ''::text))
);


ALTER TABLE public.fuels OWNER TO postgres;

--
-- Name: TABLE fuels; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.fuels IS 'Kraftstoffe';


--
-- Name: COLUMN fuels.code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.fuels.code IS 'Interne Codierung für Kraftstoff (z.B. für Diesel)';


--
-- Name: COLUMN fuels.description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.fuels.description IS 'Beschreibung des Kraftstoffs';


--
-- Name: invoice_types; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.invoice_types (
    type integer NOT NULL,
    description character varying(200),
    CONSTRAINT invoice_types_type_check CHECK ((type > 0))
);


ALTER TABLE public.invoice_types OWNER TO postgres;

--
-- Name: TABLE invoice_types; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.invoice_types IS 'Rechnungsarten';


--
-- Name: COLUMN invoice_types.type; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.invoice_types.type IS 'Rechnungsart, z.B. 2 für Werkstattrechnung';


--
-- Name: COLUMN invoice_types.description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.invoice_types.description IS 'Bezeichnung der Rechnungsart';


--
-- Name: invoices; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.invoices (
    invoice_type integer NOT NULL,
    invoice_number integer NOT NULL,
    subsidiary integer,
    order_number integer,
    paying_customer integer,
    invoice_date date,
    service_date date,
    is_canceled boolean,
    cancelation_number integer,
    cancelation_date date,
    cancelation_employee integer,
    is_own_vehicle boolean,
    is_credit boolean,
    credit_invoice_type integer,
    credit_invoice_number integer,
    odometer_reading integer,
    creating_employee integer,
    internal_cost_account integer,
    vehicle_number integer,
    full_vat_basevalue numeric(9,2),
    full_vat_percentage numeric(4,2),
    full_vat_value numeric(18,2),
    reduced_vat_basevalue numeric(9,2),
    reduced_vat_percentage numeric(4,2),
    reduced_vat_value numeric(18,2),
    used_part_vat_value numeric(9,2),
    job_amount_net numeric(18,2),
    job_amount_gross numeric(18,2),
    job_rebate numeric(9,2),
    part_amount_net numeric(18,2),
    part_amount_gross numeric(18,2),
    part_rebate numeric(9,2),
    part_disposal numeric(9,2),
    total_gross numeric(18,2),
    total_net numeric(18,2),
    parts_rebate_group_sell integer,
    CONSTRAINT invoices_invoice_number_check CHECK ((invoice_number > 0))
);


ALTER TABLE public.invoices OWNER TO postgres;

--
-- Name: TABLE invoices; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.invoices IS 'Rechnungsgrunddaten. Die Positionen samt Kostenstelle und zugehörigen Zeilen können über die Tabellen labours und parts ermittelt werden.';


--
-- Name: COLUMN invoices.invoice_type; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.invoices.invoice_type IS 'Rechnungsart (1. Keyanteil)';


--
-- Name: COLUMN invoices.invoice_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.invoices.invoice_number IS 'Rechnungsnummer (2. Keyanteil)';


--
-- Name: COLUMN invoices.subsidiary; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.invoices.subsidiary IS 'Fakturierende Betriebsstätte';


--
-- Name: COLUMN invoices.order_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.invoices.order_number IS 'Auftragsnummer zu dieser Rechnung';


--
-- Name: COLUMN invoices.paying_customer; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.invoices.paying_customer IS 'Kundennummer des Zahlers';


--
-- Name: COLUMN invoices.invoice_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.invoices.invoice_date IS 'Rechnungsdatum, das in der Rechnung ausgewiesen ist.';


--
-- Name: COLUMN invoices.service_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.invoices.service_date IS 'Leistungsdatum';


--
-- Name: COLUMN invoices.is_canceled; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.invoices.is_canceled IS 'Die Rechnung wurde storniert (true)';


--
-- Name: COLUMN invoices.cancelation_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.invoices.cancelation_number IS 'Storno-Nummer';


--
-- Name: COLUMN invoices.cancelation_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.invoices.cancelation_date IS 'Stornierungsdatum';


--
-- Name: COLUMN invoices.cancelation_employee; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.invoices.cancelation_employee IS 'Stornierender Mitarbeiter';


--
-- Name: COLUMN invoices.is_own_vehicle; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.invoices.is_own_vehicle IS 'Das Fahrzeug ist ein Händlerfahrzeug (true) oder ein Kundenfahrzeug (false)';


--
-- Name: COLUMN invoices.is_credit; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.invoices.is_credit IS 'Die Rechnung ist eine Gutschrift (true)';


--
-- Name: COLUMN invoices.credit_invoice_type; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.invoices.credit_invoice_type IS 'Bei Gutschriften steht hier die Rechnung, auf die sich die Gutschrift bezieht.';


--
-- Name: COLUMN invoices.credit_invoice_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.invoices.credit_invoice_number IS 'Bei Gutschriften steht hier die Rechnung, auf die sich die Gutschrift bezieht.';


--
-- Name: COLUMN invoices.odometer_reading; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.invoices.odometer_reading IS 'Leistungs-Kilometerstand bei Rechnungsstellung (idR. nur bei Werkstattrechnungen belegt)';


--
-- Name: COLUMN invoices.creating_employee; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.invoices.creating_employee IS 'Fakturierender Mitarbeiter';


--
-- Name: COLUMN invoices.internal_cost_account; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.invoices.internal_cost_account IS 'Internes Kosten-Konto';


--
-- Name: COLUMN invoices.vehicle_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.invoices.vehicle_number IS 'Interne Fahrzeugnummer des Fahrzeugs zu der Rechnung';


--
-- Name: COLUMN invoices.full_vat_basevalue; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.invoices.full_vat_basevalue IS 'Basiswert des normal zu besteuernden Rechnungsanteils';


--
-- Name: COLUMN invoices.full_vat_percentage; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.invoices.full_vat_percentage IS 'Prozentsatz (für den normal zu besteuernden Rechnungsanteil)';


--
-- Name: COLUMN invoices.full_vat_value; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.invoices.full_vat_value IS 'Umsatzsteuerbetrag (normal besteuert)';


--
-- Name: COLUMN invoices.reduced_vat_basevalue; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.invoices.reduced_vat_basevalue IS 'Basiswert des Rechnungsanteils, der mit dem reduzierten Steuersatz besteuert wird (z.B. Bücher)';


--
-- Name: COLUMN invoices.reduced_vat_percentage; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.invoices.reduced_vat_percentage IS 'Prozentsatz (reduzierter Prozentsatz, z.B. für Bücher)';


--
-- Name: COLUMN invoices.reduced_vat_value; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.invoices.reduced_vat_value IS 'Umsatzsteuerbetrag (reduziert besteuert)';


--
-- Name: COLUMN invoices.used_part_vat_value; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.invoices.used_part_vat_value IS 'Umsatzsteuerwert für Altteile (in  EUR)';


--
-- Name: COLUMN invoices.job_amount_net; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.invoices.job_amount_net IS 'Netto-Summe aller Arbeiten in der Rechnung';


--
-- Name: COLUMN invoices.job_amount_gross; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.invoices.job_amount_gross IS 'Brutto-Summe aller Arbeiten in der Rechnung';


--
-- Name: COLUMN invoices.job_rebate; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.invoices.job_rebate IS 'Netto-Summe aller Nachlässe auf Arbeiten in der Rechnung';


--
-- Name: COLUMN invoices.part_amount_net; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.invoices.part_amount_net IS 'Netto-Summe aller Ersatzteile in der Rechnung';


--
-- Name: COLUMN invoices.part_amount_gross; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.invoices.part_amount_gross IS 'Brutto-Summe aller Ersatzteile in der Rechnung';


--
-- Name: COLUMN invoices.part_rebate; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.invoices.part_rebate IS 'Netto-Summe aller Nachlässe auf Ersatzteile in der Rechnung';


--
-- Name: COLUMN invoices.part_disposal; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.invoices.part_disposal IS 'Entsorgungskosten für Teile';


--
-- Name: COLUMN invoices.total_gross; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.invoices.total_gross IS 'Gesamtbetrag brutto';


--
-- Name: COLUMN invoices.total_net; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.invoices.total_net IS 'Gesamtbetrag netto';


--
-- Name: COLUMN invoices.parts_rebate_group_sell; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.invoices.parts_rebate_group_sell IS 'Teile-Rabatt-Gruppe zum Zeitpunkt der Fakturierung oder NULL';


--
-- Name: journal_accountings; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.journal_accountings (
    subsidiary_to_company_ref bigint NOT NULL,
    accounting_date date NOT NULL,
    document_type text NOT NULL,
    document_number bigint NOT NULL,
    position_in_document bigint NOT NULL,
    customer_number bigint,
    nominal_account_number bigint,
    is_balanced text,
    clearing_number bigint,
    document_date date,
    posted_value bigint,
    debit_or_credit text,
    posted_count bigint,
    branch_number bigint,
    customer_contra_account bigint,
    nominal_contra_account bigint,
    contra_account_text text,
    account_form_page_number bigint,
    account_form_page_line bigint,
    serial_number_each_month text,
    employee_number bigint,
    invoice_date date,
    invoice_number text,
    dunning_level text,
    last_dunning_date date,
    journal_page bigint,
    journal_line bigint,
    cash_discount bigint,
    term_of_payment bigint,
    posting_text text,
    vehicle_reference text,
    vat_id_number text,
    account_statement_number bigint,
    account_statement_page bigint,
    vat_key text,
    days_for_cash_discount bigint,
    day_of_actual_accounting date,
    skr51_branch bigint,
    skr51_make bigint,
    skr51_cost_center bigint,
    skr51_sales_channel bigint,
    skr51_cost_unit bigint,
    previously_used_account_no text,
    free_form_accounting_text text,
    free_form_document_text text
);


ALTER TABLE public.journal_accountings OWNER TO postgres;

--
-- Name: TABLE journal_accountings; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.journal_accountings IS 'Buchungen zu Personen- und Sachkonten im Journal';


--
-- Name: COLUMN journal_accountings.subsidiary_to_company_ref; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.journal_accountings.subsidiary_to_company_ref IS 'BetriebsGruppe:Zuordnung zu der "Betriebsgruppe" bei Buchhaltungssplitt - ansonsten immer 1';


--
-- Name: COLUMN journal_accountings.accounting_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.journal_accountings.accounting_date IS 'BuchungPerDatum:H:Dies ist das unveränderliche Datum, mit dem der Beleg in der FiBu verbucht/dokumentiert wurde';


--
-- Name: COLUMN journal_accountings.document_type; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.journal_accountings.document_type IS 'BelegArt:A:Definiert per Kürzel welche Belegart vorliegt, z.B. B für Bank';


--
-- Name: COLUMN journal_accountings.document_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.journal_accountings.document_number IS 'BelegNr:B:Mit dieser Nummer ist der Beleg in der Ablage zu finden, z.B. laufende Nr. der Eingangs-Rechnungen';


--
-- Name: COLUMN journal_accountings.position_in_document; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.journal_accountings.position_in_document IS 'BuchNr:C:Pos. innerh. einer Buchung, Wert 1 bis max. 2000, P-Konto belegt 2 Positionen';


--
-- Name: COLUMN journal_accountings.customer_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.journal_accountings.customer_number IS 'KundenNr:D:Personenkonto-Nummer';


--
-- Name: COLUMN journal_accountings.nominal_account_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.journal_accountings.nominal_account_number IS 'SachKontoNr:E:Sachkonto-Nummer oder Sachkto. zum Personenkonto';


--
-- Name: COLUMN journal_accountings.is_balanced; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.journal_accountings.is_balanced IS 'Ausgeglichen:F:Dieses Flag (meist bei P-Konten) an, ob die Buchung ausgeziffert ist J für Ja oder N für Nein';


--
-- Name: COLUMN journal_accountings.clearing_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.journal_accountings.clearing_number IS 'AuszifferungsNr:G:Zeigt an wann JJMMnnnnn die Buchung ausgeziffert wurde. nnnnn ist ein Zähler im Monat.';


--
-- Name: COLUMN journal_accountings.document_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.journal_accountings.document_date IS 'Belegdatum:I:Dieses (evtl. unzulässige) Datum wollte der Anwender belegen, was aber z.B. bei einem abgeschl. Vorjahr unmöglich war';


--
-- Name: COLUMN journal_accountings.posted_value; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.journal_accountings.posted_value IS 'Buchungsbetrag:J:Buchungsbetrag in Cent, ggf. auch negativ möglich';


--
-- Name: COLUMN journal_accountings.debit_or_credit; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.journal_accountings.debit_or_credit IS 'SollHabenBuchung:K:S = Soll-seitige Buchung, H = Haben-seitige Buchung';


--
-- Name: COLUMN journal_accountings.posted_count; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.journal_accountings.posted_count IS 'Buchungsmenge:L:Mengenzähler bei Fzgn und ETs, Nettobetrag falls USt.-Buchungen vorliegen';


--
-- Name: COLUMN journal_accountings.branch_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.journal_accountings.branch_number IS 'Filiale:M:Betriebs-Nummer, in der die Buchung erzeugt wurde';


--
-- Name: COLUMN journal_accountings.customer_contra_account; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.journal_accountings.customer_contra_account IS 'GegenkontoPersonen:N:Sofern in einer Splittbuchung ein eindeutiges Personen-Gegenkonto zu dieser Zeile existiert';


--
-- Name: COLUMN journal_accountings.nominal_contra_account; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.journal_accountings.nominal_contra_account IS 'GegenkontoSach:O:Sofern in einer Splittbuchung ein eindeutiges Sach-Gegenkonto zu dieserZeile existiert';


--
-- Name: COLUMN journal_accountings.contra_account_text; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.journal_accountings.contra_account_text IS 'GegenkontoText:';


--
-- Name: COLUMN journal_accountings.account_form_page_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.journal_accountings.account_form_page_number IS 'KontenblattSeite:Q:Druckseite, auf der die Buchung auf dem Kontenblattdruck zu finden ist';


--
-- Name: COLUMN journal_accountings.account_form_page_line; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.journal_accountings.account_form_page_line IS 'KontenblattZeile:R:Laufende Zeilennummer innerhalb der Kontenblattdrucke, je Konto 1 bis n';


--
-- Name: COLUMN journal_accountings.serial_number_each_month; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.journal_accountings.serial_number_each_month IS 'LfdNrBuchungImMonat:S:Pro Buchung wird im Monat ein Zähler zu Prüfzwecken lückenlos hochgezählt';


--
-- Name: COLUMN journal_accountings.employee_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.journal_accountings.employee_number IS 'MitarbeiterNr:T:Mitarbeiter Nummer des fakturierenden oder manuell buchenden Mitarbeiters';


--
-- Name: COLUMN journal_accountings.invoice_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.journal_accountings.invoice_date IS 'Rechnungsdatum:U:Datum, das vom Anwender als Rechnungdatum erfasst wurde';


--
-- Name: COLUMN journal_accountings.invoice_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.journal_accountings.invoice_number IS 'Rechnungsnummer:V:Alphanum. Belegnr. des Org.-Belegs, evtl. abweichend von der Belegnummerinnerhalb der FiBu';


--
-- Name: COLUMN journal_accountings.dunning_level; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.journal_accountings.dunning_level IS 'Mahnstufe:W:Werte 0 bis 9 für 1.-9. Mahnung wurde erstellt, Gesperrt = Mahnsperre dieser Position';


--
-- Name: COLUMN journal_accountings.last_dunning_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.journal_accountings.last_dunning_date IS 'MahndatumLetzte:X:Datum der letzten an diesen Kunden erstellten Mahnung';


--
-- Name: COLUMN journal_accountings.journal_page; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.journal_accountings.journal_page IS 'JournalSeite:Y:Druckseite im Journals, wo die Buchzeile belegt wurde';


--
-- Name: COLUMN journal_accountings.journal_line; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.journal_accountings.journal_line IS 'ZeilenNr:Z:Zeile innerhalb des Journals, beginnend mit 1 am Anfang des Geschäftsjahres';


--
-- Name: COLUMN journal_accountings.cash_discount; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.journal_accountings.cash_discount IS 'RechnungsSkonto:AA:Laut Rechnung oder Buchung möglicher Skontowert in Prozent';


--
-- Name: COLUMN journal_accountings.term_of_payment; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.journal_accountings.term_of_payment IS 'RechnungZiel:AB:Ziel der Rechnung bei Faktura oder Erfassung (in Tagen)';


--
-- Name: COLUMN journal_accountings.posting_text; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.journal_accountings.posting_text IS 'Buchungstext:AC:Text zur Buchungszeile, vom Anwender oder systemseitig erstellt';


--
-- Name: COLUMN journal_accountings.vehicle_reference; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.journal_accountings.vehicle_reference IS 'Fahrzeugverweis:AD:Seit Buchung 12/2011: Verweis auf Kom.-Nr.+Fg.-Endnr., falls Bezug auf ein Hdl.-Fzg. besteht.';


--
-- Name: COLUMN journal_accountings.vat_id_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.journal_accountings.vat_id_number IS 'USt-ID-Nr:AE:Seit Buchung 12/2011: USt-ID-Nr. zum Zeitpunkt der Erfassung bzw. Rechnungserstellung.';


--
-- Name: COLUMN journal_accountings.account_statement_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.journal_accountings.account_statement_number IS 'PKtnDruckLaufNr:AF:P-Kto.-Blätter können zu beliebigen Terminen gedruckt werden. Eine Lauf-Nr. markiert die Aufbereitungsläufe hierfür';


--
-- Name: COLUMN journal_accountings.account_statement_page; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.journal_accountings.account_statement_page IS 'PKtnDruckLaufSeite:AG:Druckseite innerhalb vorgenannter Läufe, beginnend ab Seite 1 je Pers.-Konten Aufbereitungs-Lauf.';


--
-- Name: COLUMN journal_accountings.vat_key; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.journal_accountings.vat_key IS 'UStSchluessel:AH:USt-Schlüssel dieser Buchzeile,siehe Tabelle d391us';


--
-- Name: COLUMN journal_accountings.days_for_cash_discount; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.journal_accountings.days_for_cash_discount IS 'Skontotage:AI:Skonto gemäß Rechnung oder Buchung in Tagen';


--
-- Name: COLUMN journal_accountings.day_of_actual_accounting; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.journal_accountings.day_of_actual_accounting IS 'DatumEchtverbuchung:AJ:Seit 12/2012: Datum, am dem die Buchung unv. an die FiBu übertragen wurde oder eine Kontenplanumstellung erfolgte. Aufbau JJMMT';


--
-- Name: COLUMN journal_accountings.skr51_branch; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.journal_accountings.skr51_branch IS 'SKR51-Betrieb:AK:Falls SKR51 im Einsatz: Betriebs-Nr.';


--
-- Name: COLUMN journal_accountings.skr51_make; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.journal_accountings.skr51_make IS 'SKR51-Marke:AL:Falls SKR51 im Einsatz: Nummer der Marke/des Fabrikats';


--
-- Name: COLUMN journal_accountings.skr51_cost_center; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.journal_accountings.skr51_cost_center IS 'SKR51-KostenStelle:AM:Falls SKR51 im Einsatz: Kostenstellen Nr.';


--
-- Name: COLUMN journal_accountings.skr51_sales_channel; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.journal_accountings.skr51_sales_channel IS 'SKR51-AbsatzKanal:AN:Falls SKR51 im Einsatz: Absatz Kanal Nr.';


--
-- Name: COLUMN journal_accountings.skr51_cost_unit; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.journal_accountings.skr51_cost_unit IS 'SKR51-KostenTraeger:AO:Falls SKR51 im Einsatz: Kosten Träger Nr.';


--
-- Name: COLUMN journal_accountings.previously_used_account_no; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.journal_accountings.previously_used_account_no IS 'VerweisVorherKonto:AP:Seit 2012: Falls der Kontenrahmen umgestellt werden musste, stehen hier zur Info die ursprüglichen Konten vor Umstellung';


--
-- Name: COLUMN journal_accountings.free_form_accounting_text; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.journal_accountings.free_form_accounting_text IS 'Buchungsnebeninformation:AQ:Seit 01/2015: Frei erfassbare Information oder Dokumentenpfad zur Buchungsposition';


--
-- Name: COLUMN journal_accountings.free_form_document_text; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.journal_accountings.free_form_document_text IS 'Belegnebeninformation:AR:Seit 01/2015: Frei erfassbare Information oder Dokumentenpfad zum Beleg';


--
-- Name: labour_types; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.labour_types (
    code character varying(2) NOT NULL,
    description character varying(200),
    CONSTRAINT labour_types_code_check CHECK (((code)::text > ''::text))
);


ALTER TABLE public.labour_types OWNER TO postgres;

--
-- Name: TABLE labour_types; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.labour_types IS 'Eine Arbeitsart wird je Position im Auftrag vergeben.';


--
-- Name: COLUMN labour_types.code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.labour_types.code IS 'Codierung der Arbeitsart';


--
-- Name: COLUMN labour_types.description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.labour_types.description IS 'Bezeichnung';


--
-- Name: labours; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.labours (
    order_number integer NOT NULL,
    order_position integer NOT NULL,
    order_position_line integer NOT NULL,
    subsidiary integer,
    is_invoiced boolean,
    invoice_type integer,
    invoice_number integer,
    employee_no integer,
    mechanic_no integer,
    labour_operation_id character varying(20),
    is_nominal boolean,
    time_units numeric(9,2),
    net_price_in_order numeric(9,2),
    rebate_percent numeric(4,2),
    goodwill_percent numeric(4,1),
    charge_type integer,
    text_line character varying(80),
    usage_value numeric(9,2),
    negative_flag character varying(1),
    labour_type character varying(2)
);


ALTER TABLE public.labours OWNER TO postgres;

--
-- Name: TABLE labours; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.labours IS 'Arbeitszeilen und Textzeilen in Aufträgen und Rechnungen.';


--
-- Name: COLUMN labours.order_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.labours.order_number IS 'Arbeiten beziehen sich auf Aufträge, auch fakturierte oder stornierte Rechnungszeilen bleiben den Aufträgen zugeordnet (1. Keyanteil)';


--
-- Name: COLUMN labours.order_position; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.labours.order_position IS 'Position innerhalb des Auftrages. Jeder Auftrag kann bis zu 9 Positionen enthalten (2. Keyanteil)';


--
-- Name: COLUMN labours.order_position_line; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.labours.order_position_line IS 'Fortlaufende Zeilennummer innerhalb einer Hauptposition. Es können maximal 99 Zeilen pro Position vorhanden sein. In den 99 Zeilen können mehrere Arbeiten mit und ohne Arbeitsnummer vorkommen. (3. Key';


--
-- Name: COLUMN labours.subsidiary; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.labours.subsidiary IS 'Betriebsstätte, in der die Auftragszeile bearbeitet wurde.';


--
-- Name: COLUMN labours.is_invoiced; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.labours.is_invoiced IS 'Diese Arbeitszeile ist aktuell fakturiert (true) oder noch unfakturiert, bzw. storniert (false)';


--
-- Name: COLUMN labours.invoice_type; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.labours.invoice_type IS 'Wenn diese Arbeitszeile fakturiert ist, dann wird hier auf die Rechnung verwiesen (besteht aus invoice_type und invoice_number)';


--
-- Name: COLUMN labours.invoice_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.labours.invoice_number IS 'Zusammen mit invoice_type Verweis auf die Rechnung';


--
-- Name: COLUMN labours.employee_no; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.labours.employee_no IS 'Mitarbeiter, der die Zeile in den Auftrag eingegeben hat';


--
-- Name: COLUMN labours.mechanic_no; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.labours.mechanic_no IS 'Monteur, der die Arbeit ausgeführt hat';


--
-- Name: COLUMN labours.labour_operation_id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.labours.labour_operation_id IS 'Verwendete Arbeitsnummer';


--
-- Name: COLUMN labours.is_nominal; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.labours.is_nominal IS 'Nominale Zeilen (true) werden in Zahlbeträgen angegeben, haben also einen net_price_in_order, aber keine time_units. Alle anderen Zeilen (false) werden mit time_units und net_price_in_order angegeben';


--
-- Name: COLUMN labours.time_units; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.labours.time_units IS 'Anzahl der AW, also Zeiteinheiten, für diese Arbeit, sofern is_nominal false ist. Der Verrechnungssatz pro AW kann über charge_type ermittelt werden';


--
-- Name: COLUMN labours.net_price_in_order; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.labours.net_price_in_order IS 'Nettopreis aus dem Auftrag. Rabatte oder eine Kulanzaufteilung ist hier noch nicht enthalten. Neben dem rebate_percent muss eventuell noch ein Nachlass auf Arbeiten oder auf den Gesamtpreis anteilig a';


--
-- Name: COLUMN labours.rebate_percent; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.labours.rebate_percent IS 'Relativer Nachlass auf diese Arbeit';


--
-- Name: COLUMN labours.goodwill_percent; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.labours.goodwill_percent IS 'Relativer Kulanzanteil des Händlers';


--
-- Name: COLUMN labours.charge_type; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.labours.charge_type IS 'Berechnungsart der Zeile';


--
-- Name: COLUMN labours.text_line; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.labours.text_line IS 'Eine Textzeile. Ein Arbeitstext kann aus mehreren Textzeilen bestehen. Sofern der Arbeitstext zu einer Arbeitsnummer gehört, steht in der ersten Textzeile die Arbeitsnummer. In der letzten Textzeile z';


--
-- Name: COLUMN labours.usage_value; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.labours.usage_value IS 'Einsatzwert / verrechnete Anschaffungskosten. Nur belegt bei Fremdleistungen.';


--
-- Name: COLUMN labours.negative_flag; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.labours.negative_flag IS 'Negativ-Zustand. N = Nachlass. R = reduziert. Ansonsten NULL.';


--
-- Name: COLUMN labours.labour_type; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.labours.labour_type IS 'Arbeitsart der Arbeitszeile, z.B. W = Werkstatt (siehe Tabelle labour_types)';


--
-- Name: labours_compressed; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.labours_compressed (
    order_number integer NOT NULL,
    order_position integer NOT NULL,
    order_position_line_start integer NOT NULL,
    order_position_line_end integer,
    labour_operation_id character varying(20),
    time_units numeric(9,2),
    net_price_in_order numeric(9,2),
    text character varying(1619)
);


ALTER TABLE public.labours_compressed OWNER TO postgres;

--
-- Name: TABLE labours_compressed; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.labours_compressed IS 'Zusammengefasste Arbeitszeilen. Hier sind nur Arbeiten aufgeführt die eine Arbeitsnummer und/oder einen Preis haben. Diese Tabelle wird nicht automatisch durch das Live-Update aktualisiert.';


--
-- Name: COLUMN labours_compressed.order_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.labours_compressed.order_number IS 'Verweis auf Tabelle labours (1. Keyanteil)';


--
-- Name: COLUMN labours_compressed.order_position; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.labours_compressed.order_position IS 'Position in Tabelle labours (2. Keyanteil)';


--
-- Name: COLUMN labours_compressed.order_position_line_start; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.labours_compressed.order_position_line_start IS 'Zeile, in der der Arbeitstext anfängt. Verweist auf Tabelle labours (3. Keyanteil). In dieser Zeile steht in Tabelle labours die Arbeitsnummer, falls eine vergeben wurde.';


--
-- Name: COLUMN labours_compressed.order_position_line_end; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.labours_compressed.order_position_line_end IS 'Zeile, in der der Arbeitstext aufhört. Verweist auf Tabelle labours. In dieser Zeile steht in Tabelle labours der Preis.';


--
-- Name: COLUMN labours_compressed.labour_operation_id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.labours_compressed.labour_operation_id IS 'Verwendete Arbeitsnummer (redundant zu Tabelle labours, verwiesen über order_position_line_start zu order_positoin_line)';


--
-- Name: COLUMN labours_compressed.time_units; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.labours_compressed.time_units IS 'Anzahl der AW, (redundant zu Tabelle labours)';


--
-- Name: COLUMN labours_compressed.net_price_in_order; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.labours_compressed.net_price_in_order IS 'Nettopreis aus dem Auftrag. (redundant zu Tabelle labours)';


--
-- Name: COLUMN labours_compressed.text; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.labours_compressed.text IS 'Arbeitstext aus allen zugehörigen Einzelzeilen. Der Text kann maximal 20 Arbeitszeilen enthalten. Längere Texte werden abgeschnitten, können jedoch über die Tabelle labours rekonstruiert werden.';


--
-- Name: labours_groups; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.labours_groups (
    source character varying(4) NOT NULL,
    labour_number_range character varying(15) NOT NULL,
    description text
);


ALTER TABLE public.labours_groups OWNER TO postgres;

--
-- Name: TABLE labours_groups; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.labours_groups IS 'Arbeitsnummern Kategorien/Nummernkreise';


--
-- Name: COLUMN labours_groups.source; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.labours_groups.source IS 'Herkunftskennzeichen (z.B. ALLG für allgemein oder Fabrikatskürzel)';


--
-- Name: COLUMN labours_groups.labour_number_range; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.labours_groups.labour_number_range IS 'Arbeits-Nummernkreis. Arbeitsnummern in Loco-Soft sind rechtsbündig. Darum enthält das Feld führende Leerzeichen.';


--
-- Name: COLUMN labours_groups.description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.labours_groups.description IS 'Bezeichnung des Arbeitsnummernkreises';


--
-- Name: labours_master; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.labours_master (
    source character varying(4) NOT NULL,
    labour_number character varying(15) NOT NULL,
    mapping_code character varying(10) NOT NULL,
    text text
);


ALTER TABLE public.labours_master OWNER TO postgres;

--
-- Name: TABLE labours_master; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.labours_master IS 'Arbeitsnummernliste';


--
-- Name: COLUMN labours_master.source; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.labours_master.source IS 'Herkunftskennzeichen (z.B. ALLG oder Fabrikatskürzel)';


--
-- Name: COLUMN labours_master.labour_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.labours_master.labour_number IS 'Arbeitsnummer. Arbeitsnummern in Loco-Soft sind rechtsbündig. Darum enthält sie führende Leerzeichen';


--
-- Name: COLUMN labours_master.mapping_code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.labours_master.mapping_code IS 'Zuordnungscode für den Fall, dass diese Arbeitsnummer für eine herstellerspezifische Zuordnung gilt';


--
-- Name: COLUMN labours_master.text; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.labours_master.text IS 'Beschreibung der Arbeit';


--
-- Name: leasing_examples; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.leasing_examples (
    id integer NOT NULL,
    number_rates integer,
    annual_mileage integer,
    special_payment numeric(9,2),
    calculation_basis numeric(9,2),
    calculation_basis_factor numeric(4,2),
    gross_residual_value numeric(9,2),
    gross_residual_value_factor numeric(4,2),
    monthly_rate numeric(9,2),
    exceeding_mileage numeric(9,2),
    under_usage_mileage numeric(9,2),
    bank_customer_no integer,
    source character varying(15),
    referenced_dealer_vehicle_type character varying(1),
    referenced_dealer_vehicle_no integer
);


ALTER TABLE public.leasing_examples OWNER TO postgres;

--
-- Name: TABLE leasing_examples; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.leasing_examples IS 'Beispiel-Finanzierungsangebote';


--
-- Name: COLUMN leasing_examples.id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.leasing_examples.id IS 'Laufende Nummer als Primärschlüssel ohne weitere Bedeutung. Der Wert kann sich zwischen den Exporten ändern';


--
-- Name: COLUMN leasing_examples.number_rates; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.leasing_examples.number_rates IS 'Laufzeit in Monaten';


--
-- Name: COLUMN leasing_examples.annual_mileage; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.leasing_examples.annual_mileage IS 'Enthaltene Laufleistung in Kilometern pro Jahr';


--
-- Name: COLUMN leasing_examples.special_payment; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.leasing_examples.special_payment IS 'Sonderzahlung';


--
-- Name: COLUMN leasing_examples.calculation_basis; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.leasing_examples.calculation_basis IS 'Berechnungsgrundlage';


--
-- Name: COLUMN leasing_examples.calculation_basis_factor; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.leasing_examples.calculation_basis_factor IS 'Faktor zu Berechnungsgrundlage';


--
-- Name: COLUMN leasing_examples.gross_residual_value; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.leasing_examples.gross_residual_value IS 'Restwert inklusive MwSt';


--
-- Name: COLUMN leasing_examples.gross_residual_value_factor; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.leasing_examples.gross_residual_value_factor IS 'Faktor zu (Restwert inklusive MwSt)';


--
-- Name: COLUMN leasing_examples.monthly_rate; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.leasing_examples.monthly_rate IS 'Monatliche Leasingrate inklusive MwSt';


--
-- Name: COLUMN leasing_examples.exceeding_mileage; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.leasing_examples.exceeding_mileage IS 'Leasing Mehrkilometer (Kosten je Kilometer)';


--
-- Name: COLUMN leasing_examples.under_usage_mileage; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.leasing_examples.under_usage_mileage IS 'Leasing Minderkilometer (Erstattung je Kilometer)';


--
-- Name: COLUMN leasing_examples.bank_customer_no; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.leasing_examples.bank_customer_no IS 'Kundennummer der Leasingbank';


--
-- Name: COLUMN leasing_examples.source; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.leasing_examples.source IS 'Dieses Beispiel gehört zu: order=Kaufvertrag,offer=Angebot,dealer_vehicle=Händlerfahrzeug';


--
-- Name: COLUMN leasing_examples.referenced_dealer_vehicle_type; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.leasing_examples.referenced_dealer_vehicle_type IS 'Falls die Finanzierung zu einem Händlerfahrzeug gehört, steht hier die Fahrzeugart (D/G/L/N/V)';


--
-- Name: COLUMN leasing_examples.referenced_dealer_vehicle_no; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.leasing_examples.referenced_dealer_vehicle_no IS 'Falls die Finanzierung zu einem Händlerfahrzeug gehört, steht hier die Kommissionsnummer';


--
-- Name: leasing_examples_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

CREATE SEQUENCE public.leasing_examples_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.leasing_examples_id_seq OWNER TO postgres;

--
-- Name: leasing_examples_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--

ALTER SEQUENCE public.leasing_examples_id_seq OWNED BY public.leasing_examples.id;


--
-- Name: makes; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.makes (
    make_number integer NOT NULL,
    is_actual_make boolean,
    description character varying(200),
    group_name character varying(4),
    make_id_in_group character varying(4),
    internal_labour_group integer,
    is_production_year_visible boolean,
    is_transmission_no_visible boolean,
    is_engine_no_visible boolean,
    is_ricambi_no_visible boolean,
    ricambi_label character varying(40),
    is_preset_finance_stock_rate boolean,
    rate_free_days_new_vehicle integer,
    rate_free_days_demo_vehicle integer,
    special_service_2_interval numeric(4,1),
    special_service_3_interval numeric(4,1),
    CONSTRAINT makes_make_number_check CHECK ((make_number > 0))
);


ALTER TABLE public.makes OWNER TO postgres;

--
-- Name: TABLE makes; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.makes IS 'Fabrikate';


--
-- Name: COLUMN makes.make_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.makes.make_number IS 'Interne Fabrikats-Nummer (1 bis n)';


--
-- Name: COLUMN makes.is_actual_make; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.makes.is_actual_make IS 'Dieser Datensatz gehört zu einem tatsächlich existierenden Fabrikat (true) oder ist ein Platzhalter für frei eingebbare Bezeichnungen (false)';


--
-- Name: COLUMN makes.description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.makes.description IS 'Fabrikatsbezeichnung';


--
-- Name: COLUMN makes.group_name; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.makes.group_name IS 'Dieses Fabrikat gehört zu Konzern xxxx (z.B. VW, GM oder PSA)';


--
-- Name: COLUMN makes.make_id_in_group; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.makes.make_id_in_group IS 'Zuordnung von Loco-Soft Fabrikat zu einem Fabrikat innerhalb des Konzerns über fest verdrahtete Codes. Aktuell nur für den FIAT-Konzern belegt.';


--
-- Name: COLUMN makes.internal_labour_group; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.makes.internal_labour_group IS 'Interner Zuordnung über fest verdrahtete Werte zu Herstellern für die Richtzeitenfindung';


--
-- Name: COLUMN makes.is_production_year_visible; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.makes.is_production_year_visible IS 'Erfassung des Baujahrs in der GUI ermöglichen (true) oder nicht (false)';


--
-- Name: COLUMN makes.is_transmission_no_visible; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.makes.is_transmission_no_visible IS 'Erfassung der Getriebenummer in der GUI ermöglichen (true) oder nicht (false)';


--
-- Name: COLUMN makes.is_engine_no_visible; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.makes.is_engine_no_visible IS 'Erfassung der Motor-Nummer in der GUI ermöglichen (true) oder nicht (false)';


--
-- Name: COLUMN makes.is_ricambi_no_visible; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.makes.is_ricambi_no_visible IS 'Erfassung der Ricambi-Nummer in der GUI ermöglichen (true) oder nicht (false). Die Ricambi-Nummer kann als frei vergebenes Feld verwendet werden.';


--
-- Name: COLUMN makes.ricambi_label; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.makes.ricambi_label IS 'Bezeichnung für das Ricambi-Eingabefeld';


--
-- Name: COLUMN makes.is_preset_finance_stock_rate; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.makes.is_preset_finance_stock_rate IS 'Vorbelegung für Finanzierungen dieses Fabrikats soll auf Stockrate (true) oder erste Rate stehen (false). Bei einer Stockrate wird der nicht finanzierte Anteil am Ende der Laufzeit bezahlt, ansonsten';


--
-- Name: COLUMN makes.rate_free_days_new_vehicle; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.makes.rate_free_days_new_vehicle IS 'Zinsfreie Tage bei Finanzierung (Ankauf durch Händler)für Neufahrzeuge.';


--
-- Name: COLUMN makes.rate_free_days_demo_vehicle; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.makes.rate_free_days_demo_vehicle IS 'Zinsfreie Tage bei Finanzierung (Ankauf durch Händler)für Vorführ-Fahrzeuge';


--
-- Name: COLUMN makes.special_service_2_interval; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.makes.special_service_2_interval IS 'Neben der normalen Wartung kann es zusätzliche Intervalle z.B. für LKW, Bremsen oder Rost geben. Der Händler verwendet diese Möglchkeit aktuell nicht.';


--
-- Name: COLUMN makes.special_service_3_interval; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.makes.special_service_3_interval IS 'Intervall für Sonderuntersuchung (wird von dem Händler nicht genutzt)';


--
-- Name: model_to_fuels; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.model_to_fuels (
    make_number integer NOT NULL,
    model_code character varying(25) NOT NULL,
    code character varying(1) NOT NULL
);


ALTER TABLE public.model_to_fuels OWNER TO postgres;

--
-- Name: TABLE model_to_fuels; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.model_to_fuels IS 'Referenztabelle von Modell auf Kraftstoff';


--
-- Name: COLUMN model_to_fuels.make_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.model_to_fuels.make_number IS 'Interne Fabrikatsnummer';


--
-- Name: COLUMN model_to_fuels.model_code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.model_to_fuels.model_code IS 'Modellcode';


--
-- Name: COLUMN model_to_fuels.code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.model_to_fuels.code IS 'Interne Codierung für Kraftstoff (z.B. für Diesel)';


--
-- Name: models; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.models (
    make_number integer NOT NULL,
    model_code character varying(25) NOT NULL,
    is_actual_model boolean,
    model_currently_available boolean,
    replacing_model_code character varying(25),
    description character varying(200),
    gear_count integer,
    seat_count integer,
    door_count integer,
    cylinder_count integer,
    vehicle_body character varying(2),
    model_labour_group character varying(4),
    has_hour_meter boolean,
    source_extern boolean,
    free_form_vehicle_class character varying(4),
    vin_begin character varying(11),
    vehicle_pool_code character varying(25),
    vehicle_pool_engine_code character varying(5),
    is_manual_transmission boolean,
    is_all_wheel_drive boolean,
    is_plugin_hybride boolean,
    unloaded_weight integer,
    gross_vehicle_weight integer,
    power_kw integer,
    power_kw_at_rotation integer,
    cubic_capacity integer,
    german_kba_hsn character varying(4),
    german_kba_tsn character varying(15),
    annual_tax numeric(9,2),
    model_year numeric(4,0),
    model_year_postfix character varying(1),
    suggested_net_retail_price numeric(9,2),
    suggested_net_shipping_cost numeric(9,2),
    european_pollutant_class character varying(4),
    efficiency_class character varying(4),
    emission_code character varying(4),
    carbondioxid_emission integer,
    nox_exhoust numeric(4,3),
    particle_exhoust numeric(4,3),
    external_schwacke_code character varying(20),
    skr_carrier_flag numeric(2,0),
    free_form_model_specification character varying(3),
    external_technical_type character varying(4),
    european_fuel_consumption_over numeric(4,2),
    european_fuel_consumption_coun numeric(4,2),
    european_fuel_consumption_city numeric(4,2),
    energy_consumption numeric(5,2),
    insurance_class_liability integer,
    insurance_class_part_comprehen integer,
    insurance_class_full_comprehen integer,
    description_vector tsvector GENERATED ALWAYS AS (to_tsvector('simple'::regconfig, (description)::text)) STORED,
    CONSTRAINT models_model_code_check CHECK (((model_code)::text > ''::text))
);


ALTER TABLE public.models OWNER TO postgres;

--
-- Name: TABLE models; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.models IS 'Modelle';


--
-- Name: COLUMN models.make_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.models.make_number IS 'Interne Fabrikatsnummer';


--
-- Name: COLUMN models.model_code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.models.model_code IS 'Modellcode';


--
-- Name: COLUMN models.is_actual_model; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.models.is_actual_model IS 'Dieser Datensatz gehört zu einem tatsächlich existierenden Modell (true) oder ist ein Platzhalter für frei eingebbare Bezeichnungen (false)';


--
-- Name: COLUMN models.model_currently_available; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.models.model_currently_available IS 'Das Modell ist aktuell';


--
-- Name: COLUMN models.replacing_model_code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.models.replacing_model_code IS 'Neuer Modellcode für dieses Modell, nur für interne Zwecke';


--
-- Name: COLUMN models.description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.models.description IS 'Modellbezeichnung';


--
-- Name: COLUMN models.gear_count; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.models.gear_count IS 'Anzahl der Gänge (bei manueller Schaltung und bei automatik Schaltung)';


--
-- Name: COLUMN models.seat_count; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.models.seat_count IS 'Anzahl der Sitze';


--
-- Name: COLUMN models.door_count; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.models.door_count IS 'Anzahl der Türen';


--
-- Name: COLUMN models.cylinder_count; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.models.cylinder_count IS 'Anzahl der Zylinder';


--
-- Name: COLUMN models.vehicle_body; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.models.vehicle_body IS 'Aufbauart';


--
-- Name: COLUMN models.model_labour_group; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.models.model_labour_group IS 'Interne Zuordnung von Modellen zu Richtzeiten';


--
-- Name: COLUMN models.has_hour_meter; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.models.has_hour_meter IS 'In dem Fahrzeug ist ein Betriebsstundenzähler eingebaut (true) - z.B. bei Booten';


--
-- Name: COLUMN models.source_extern; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.models.source_extern IS 'Dieser Datensatz stammt aus einem externen System (true)';


--
-- Name: COLUMN models.free_form_vehicle_class; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.models.free_form_vehicle_class IS 'Frei erfassbare Hinterlegung zur Fahrzeugklasse';


--
-- Name: COLUMN models.vin_begin; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.models.vin_begin IS 'Maximal 11 Zeichen der Fahrgestellnummer für dieses Modell hinterlegbar';


--
-- Name: COLUMN models.vehicle_pool_code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.models.vehicle_pool_code IS 'Dieser Code hat derzeit keine Verwendung';


--
-- Name: COLUMN models.vehicle_pool_engine_code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.models.vehicle_pool_engine_code IS 'Dieser Code hat derzeit keine Verwendung';


--
-- Name: COLUMN models.is_manual_transmission; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.models.is_manual_transmission IS 'Das Fahrzeug verwendet ein manuelles Getriebe (true) oder ein Automatikgetriebe (false)';


--
-- Name: COLUMN models.is_all_wheel_drive; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.models.is_all_wheel_drive IS 'Allradantrieb (true)';


--
-- Name: COLUMN models.is_plugin_hybride; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.models.is_plugin_hybride IS 'Das Fahrzeug hat einen alternativen Antrieb (true)';


--
-- Name: COLUMN models.unloaded_weight; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.models.unloaded_weight IS 'Leergewicht für dieses Modell (das spezifische Leergewicht steht in der Tabelle vehicles)';


--
-- Name: COLUMN models.gross_vehicle_weight; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.models.gross_vehicle_weight IS 'Zulässiges Gesamtgewicht für dieses Modell (das spezifische Gesamtgewicht steht in der Tabelle vehicles';


--
-- Name: COLUMN models.power_kw; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.models.power_kw IS 'Motorleistung in Kilowatt (die spezifische Leistung steht in der Tabelle vehicles)';


--
-- Name: COLUMN models.power_kw_at_rotation; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.models.power_kw_at_rotation IS 'Nenndrehzahl für die Leistung in Kilowatt';


--
-- Name: COLUMN models.cubic_capacity; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.models.cubic_capacity IS 'Hubraum in Kubikzentimetern für dieses Modell (der spezifische Hubraum steht in der Tabelle vehicles';


--
-- Name: COLUMN models.german_kba_hsn; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.models.german_kba_hsn IS 'Deutsche KBA-Nummer (Hersteller-Typ-Nummer) (die spezifische KBA-Nummer steht in der Tabelle vehicles)';


--
-- Name: COLUMN models.german_kba_tsn; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.models.german_kba_tsn IS 'Deutsche KBA-Nummer (Typschlüssel-Nummer) (die spezifische KBA-Nummer steht in der Tabelle vehicles)';


--
-- Name: COLUMN models.annual_tax; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.models.annual_tax IS 'Jährliche Kfz-Steuer in Landeswährung';


--
-- Name: COLUMN models.model_year; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.models.model_year IS 'Modelljahr in dem Format YHYY (9999), z.B. 2016';


--
-- Name: COLUMN models.model_year_postfix; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.models.model_year_postfix IS 'Modelljahr-Postfix, z.B. "C" für das Modelljahr 2015C';


--
-- Name: COLUMN models.suggested_net_retail_price; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.models.suggested_net_retail_price IS 'Empfohlener Verkaufspreis für Neufahrzeug ohne Steuern';


--
-- Name: COLUMN models.suggested_net_shipping_cost; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.models.suggested_net_shipping_cost IS 'Empfohle Überführungskosten für Neufahrzeug ohne Steuerun';


--
-- Name: COLUMN models.european_pollutant_class; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.models.european_pollutant_class IS 'Europäische Emissionsklasse von E1 bis E6';


--
-- Name: COLUMN models.efficiency_class; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.models.efficiency_class IS 'Effizienzklasse von A+ bis G';


--
-- Name: COLUMN models.emission_code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.models.emission_code IS 'Frei vergebbarer Emissionscode';


--
-- Name: COLUMN models.carbondioxid_emission; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.models.carbondioxid_emission IS 'Kohlendioxid-Ausstroß in Gramm pro Kilometer';


--
-- Name: COLUMN models.nox_exhoust; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.models.nox_exhoust IS 'Stickstoffoxid-Ausstoß in Gramm pro Kilometer';


--
-- Name: COLUMN models.particle_exhoust; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.models.particle_exhoust IS 'Partickelausstoß in in Gramm pro Kilometer';


--
-- Name: COLUMN models.external_schwacke_code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.models.external_schwacke_code IS 'Modellcode zu dem externen System "Schwacke"';


--
-- Name: COLUMN models.skr_carrier_flag; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.models.skr_carrier_flag IS 'Kostenträgermerkmal für die Buchhaltung';


--
-- Name: COLUMN models.free_form_model_specification; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.models.free_form_model_specification IS 'Frei erfassbarer Modell-Spezifizierungscode';


--
-- Name: COLUMN models.external_technical_type; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.models.external_technical_type IS 'Technischer Typ aus Herstellersicht (momentan nur für RENAULT verwendet)';


--
-- Name: COLUMN models.european_fuel_consumption_over; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.models.european_fuel_consumption_over IS 'Gesamtverbrauch in Litern pro 100 Kilometern gemäß europäischer Norm';


--
-- Name: COLUMN models.european_fuel_consumption_coun; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.models.european_fuel_consumption_coun IS 'Verbrauch in Litern pro 100 Kilometern gemäß europäischer Norm für Überland-Fahrten';


--
-- Name: COLUMN models.european_fuel_consumption_city; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.models.european_fuel_consumption_city IS 'Verbrauch in Litern pro 100 Kilometern gemäß europäischer Norm für Stadt-Fahrten';


--
-- Name: COLUMN models.energy_consumption; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.models.energy_consumption IS 'Stromverbrauch in Kilowatt pro 100 Kilometern (nur Plugin-Hybrid- oder Elektro-Fahrzeugen)';


--
-- Name: COLUMN models.insurance_class_liability; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.models.insurance_class_liability IS 'Fahrzeugeinstufung der KFZ-Versicherung für Haftpflicht';


--
-- Name: COLUMN models.insurance_class_part_comprehen; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.models.insurance_class_part_comprehen IS 'Fahrzeugeinstufung der KFZ-Versicherung für Teilkasko';


--
-- Name: COLUMN models.insurance_class_full_comprehen; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.models.insurance_class_full_comprehen IS 'Fahrzeugeinstufung der KFZ-Versicherung für Vollkasko';


--
-- Name: nominal_accounts; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.nominal_accounts (
    subsidiary_to_company_ref bigint NOT NULL,
    nominal_account_number bigint NOT NULL,
    account_description text,
    is_profit_loss_account text,
    vat_key text,
    create_date date,
    create_employee_number bigint,
    oldest_accountable_month date
);


ALTER TABLE public.nominal_accounts OWNER TO postgres;

--
-- Name: TABLE nominal_accounts; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.nominal_accounts IS 'Sachkonten, auf die Buchungen verzeichnet sind';


--
-- Name: COLUMN nominal_accounts.subsidiary_to_company_ref; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.nominal_accounts.subsidiary_to_company_ref IS 'BetriebsGruppe:Zuordnung zu der "Betriebsgruppe" bei Buchhaltungssplitt - ansonsten immer 1';


--
-- Name: COLUMN nominal_accounts.nominal_account_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.nominal_accounts.nominal_account_number IS 'SachKontoNr:A:Kontonummer des Sachkontos';


--
-- Name: COLUMN nominal_accounts.account_description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.nominal_accounts.account_description IS 'KontoName:B:Kontenname des Sachkontos';


--
-- Name: COLUMN nominal_accounts.is_profit_loss_account; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.nominal_accounts.is_profit_loss_account IS 'Ergebniskonto:C:Ergebniskonten Wert J, Bestandskonten Wert N, Statistikkonten tragen Wert S';


--
-- Name: COLUMN nominal_accounts.vat_key; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.nominal_accounts.vat_key IS 'UStSchluessel:D:Umsatzsteuerschlüssel, der bei Buchungen auf dieses Konto vorbelegt wird. Ist aber vom User .';


--
-- Name: COLUMN nominal_accounts.create_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.nominal_accounts.create_date IS 'KontoAngelegtAm:E:Seit 12/2012: Datum, an dem das Konto angelegt wurde.';


--
-- Name: COLUMN nominal_accounts.create_employee_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.nominal_accounts.create_employee_number IS 'KontoAngelegtVonMitarbNr:F:Mitarbeiter Nummer, der das Konto angelegt hat (wird seit 5-2012 belegt).';


--
-- Name: COLUMN nominal_accounts.oldest_accountable_month; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.nominal_accounts.oldest_accountable_month IS 'AeltestMonatAnbuchbar:G:Ältester Monat, der aktuell noch bebuchbar ist.';


--
-- Name: orders; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.orders (
    number integer NOT NULL,
    subsidiary integer,
    order_date timestamp without time zone,
    created_employee_no integer,
    updated_employee_no integer,
    estimated_inbound_time timestamp without time zone,
    estimated_outbound_time timestamp without time zone,
    order_print_date date,
    order_taking_employee_no integer,
    order_delivery_employee_no integer,
    vehicle_number integer,
    dealer_vehicle_type character varying(1),
    dealer_vehicle_number integer,
    order_mileage integer,
    order_customer integer,
    paying_customer integer,
    parts_rebate_group_sell integer,
    clearing_delay_type character varying(1),
    has_empty_positions boolean,
    has_open_positions boolean,
    has_closed_positions boolean,
    is_over_the_counter_order boolean,
    lock_by_workstation integer,
    lock_time timestamp without time zone,
    lock_trace character varying(100),
    lock_trigger character varying(100),
    lock_by_employee integer,
    lock_sourcecode character varying(100)
);


ALTER TABLE public.orders OWNER TO postgres;

--
-- Name: TABLE orders; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.orders IS 'Aktuelle Auftrags-Kopfdaten (einheitlich für alle Positionen in dem Auftrag). Ggf. abweichende Werte für fakturierte Positionen sind der Tabelle invoices zu entnehmen.';


--
-- Name: COLUMN orders.number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.orders.number IS 'Auftragsnummer';


--
-- Name: COLUMN orders.subsidiary; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.orders.subsidiary IS 'Zugeordnete Betriebsstätte';


--
-- Name: COLUMN orders.order_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.orders.order_date IS 'Manuell eingegebbares Auftragsdatum und Uhrzeit. Die Urzeit ist in Abhängigkeit von Variable 219 in Programm 912 immer 00:00';


--
-- Name: COLUMN orders.created_employee_no; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.orders.created_employee_no IS 'Mitarbeiter, der die Auftrags-Kopfdaten erstmalig angelegt hat';


--
-- Name: COLUMN orders.updated_employee_no; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.orders.updated_employee_no IS 'Mitarbeiter, der die Auftrags-Kopfdaten zuletzt geändert hat';


--
-- Name: COLUMN orders.estimated_inbound_time; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.orders.estimated_inbound_time IS 'Unverbindlicher Bringtermin. Die Eingabe der Uhrzeit ist nicht verpflichtend.';


--
-- Name: COLUMN orders.estimated_outbound_time; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.orders.estimated_outbound_time IS 'Unverbindlicher Abholtermin. Die Eingabe der Uhrzeit ist nicht verpflichtend.';


--
-- Name: COLUMN orders.order_print_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.orders.order_print_date IS 'Druckdatum des Auftrags';


--
-- Name: COLUMN orders.order_taking_employee_no; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.orders.order_taking_employee_no IS 'Mitarbeiter für die Auftragsannahme';


--
-- Name: COLUMN orders.order_delivery_employee_no; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.orders.order_delivery_employee_no IS 'Mitarbeiter für die Fahrzeugübergabe';


--
-- Name: COLUMN orders.vehicle_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.orders.vehicle_number IS 'Interne Fahrzeugnummer des Fahrzeugs zu diesem Auftrag. Achtung: Das Fahrzeug könnte für bereits abgerechnete Positionen ein anderes gewesen sein.';


--
-- Name: COLUMN orders.dealer_vehicle_type; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.orders.dealer_vehicle_type IS 'Wenn der Auftrags ich auf ein Händlerfahrzeug bezieht, dann steht die Fahrzeugart (erster Teil der Kommissionsnummer)';


--
-- Name: COLUMN orders.dealer_vehicle_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.orders.dealer_vehicle_number IS 'Wenn der Auftrags ich auf ein Händlerfahrzeug bezieht, dann steht die Kommissionsnummer';


--
-- Name: COLUMN orders.order_mileage; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.orders.order_mileage IS 'Auftrags-Kilometerstand in Kilometern. Achtung: Der Auftrags-Kilometerstand kann für bereits abgerechnete Positionen abweichend gewesen sein.';


--
-- Name: COLUMN orders.order_customer; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.orders.order_customer IS 'Beauftragender Kunde laut Auftrag';


--
-- Name: COLUMN orders.paying_customer; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.orders.paying_customer IS 'Kundennummer des Zahlers (kann abweichend von dem beauftragenden Kunden sein). Achtung: Bei bereits abgerechneten Positionen konnten abweichende Zahler angegeben worden sein.';


--
-- Name: COLUMN orders.parts_rebate_group_sell; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.orders.parts_rebate_group_sell IS 'Teile-Rabattgruppe für die Auftragsposition. Achtung: Kann in bereits abgerechneten Positionen abweichen.';


--
-- Name: COLUMN orders.clearing_delay_type; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.orders.clearing_delay_type IS 'Abrechnungs-Verzögerungs-Grund';


--
-- Name: COLUMN orders.has_empty_positions; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.orders.has_empty_positions IS 'TRUE, wenn der Auftrag leere Positionen enthält';


--
-- Name: COLUMN orders.has_open_positions; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.orders.has_open_positions IS 'TRUE, wenn der Auftrag offene, also nicht abgerechnete Positionen enthält';


--
-- Name: COLUMN orders.has_closed_positions; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.orders.has_closed_positions IS 'TRUE, wenn der Auftrag geschlossene, also fakturierte Positionen enthält';


--
-- Name: COLUMN orders.is_over_the_counter_order; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.orders.is_over_the_counter_order IS 'TRUE, wenn der Auftrag ein reiner Barverkaufs-Auftrag für Thekenverkäufe ist';


--
-- Name: COLUMN orders.lock_by_workstation; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.orders.lock_by_workstation IS 'Protokollierung von Datensatz-Sperren: Arbeitsplatznummer, der die Sperre erzeugt hat oder NULL.';


--
-- Name: COLUMN orders.lock_time; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.orders.lock_time IS 'Protokollierung von Datensatz-Sperren: Zeitstempel, an dem der Datensatz mit Sperre zuletzt geändert wurde oder NULL.';


--
-- Name: COLUMN orders.lock_trace; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.orders.lock_trace IS 'Protokollierung von Datensatz-Sperren: Reihenfolge der aufgerufenen Programme bei letztem Update des Datesatzes oder NULL.';


--
-- Name: COLUMN orders.lock_trigger; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.orders.lock_trigger IS 'Protokollierung von Datensatz-Sperren: Dienstname oder UI-Information oder NULL.';


--
-- Name: COLUMN orders.lock_by_employee; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.orders.lock_by_employee IS 'Protokollierung von Datensatz-Sperren: Interne Mitarbeiter-Nr. oder NULL.';


--
-- Name: COLUMN orders.lock_sourcecode; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.orders.lock_sourcecode IS 'Protokollierung von Datensatz-Sperren: Programmstelle oder NULL.';


--
-- Name: part_types; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.part_types (
    type integer NOT NULL,
    description character varying(42)
);


ALTER TABLE public.part_types OWNER TO postgres;

--
-- Name: TABLE part_types; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.part_types IS 'Teilearten';


--
-- Name: COLUMN part_types.type; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.part_types.type IS 'Teileart-Kennzeichen';


--
-- Name: COLUMN part_types.description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.part_types.description IS 'Bezeichnung der Teileart.';


--
-- Name: parts; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.parts (
    order_number integer NOT NULL,
    order_position integer NOT NULL,
    order_position_line integer NOT NULL,
    subsidiary integer,
    is_invoiced boolean,
    invoice_type integer,
    invoice_number integer,
    employee_no integer,
    mechanic_no integer,
    part_number character varying(20) COLLATE pg_catalog."C",
    stock_no integer,
    stock_removal_date date,
    amount numeric(9,2),
    sum numeric(9,2),
    rebate_percent numeric(4,2),
    goodwill_percent numeric(4,1),
    parts_type integer,
    text_line character varying(32),
    usage_value numeric(9,2)
);


ALTER TABLE public.parts OWNER TO postgres;

--
-- Name: TABLE parts; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.parts IS 'Abgänge (Teile und Material in Aufträgen und Rechnungen)';


--
-- Name: COLUMN parts.order_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts.order_number IS 'Teile beziehen sich auf Aufträge, auch fakturierte oder stornierte Rechnungszeilen bleiben den Aufträgen zugeordnet (1. Keyanteil)';


--
-- Name: COLUMN parts.order_position; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts.order_position IS 'Position innerhalb des Auftrages. Jeder Auftrag kann bis zu 9 Positionen enthalten (2. Keyanteil)';


--
-- Name: COLUMN parts.order_position_line; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts.order_position_line IS 'Fortlaufende Zeilennummer innerhalb von order_position.Es können maximal 99 Zeilen pro Position vorhanden sein. In den 99 Zeilen können mehrere Arbeiten mit und ohne Arbeitsnummer vorkommen. (3. Keyan';


--
-- Name: COLUMN parts.subsidiary; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts.subsidiary IS 'Betriebsstätte, in der die Auftragszeile berbeitet wurde.';


--
-- Name: COLUMN parts.is_invoiced; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts.is_invoiced IS 'Diese Teilezeile ist aktuell fakturiert (true) oder noch unfakturiert, bzw. storniert (false)';


--
-- Name: COLUMN parts.invoice_type; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts.invoice_type IS 'Wenn diese Teilezeile fakturiert ist, dann wird hier auf die Rechnung verwiesen.';


--
-- Name: COLUMN parts.invoice_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts.invoice_number IS 'Zusammen mit invoice_type Verweis auf die Rechnung.';


--
-- Name: COLUMN parts.employee_no; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts.employee_no IS 'Mitarbeiter, der die Zeile in den Auftrag eingegeben hat.';


--
-- Name: COLUMN parts.mechanic_no; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts.mechanic_no IS 'Monteur, der die Arbeit ausgeführt hat.';


--
-- Name: COLUMN parts.part_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts.part_number IS 'Verwendete Teilenummer';


--
-- Name: COLUMN parts.stock_no; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts.stock_no IS 'Lagernummer (wenn angegeben bezieht sich das Feld auf Tabelle parts_stock)';


--
-- Name: COLUMN parts.stock_removal_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts.stock_removal_date IS 'Datum, an dem das Teil in den Auftrag eingefügt wurde.';


--
-- Name: COLUMN parts.amount; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts.amount IS 'Anzahl';


--
-- Name: COLUMN parts.sum; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts.sum IS 'Gesamtpreis (einzelpreis des Teils * amount)';


--
-- Name: COLUMN parts.rebate_percent; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts.rebate_percent IS 'Relativer Nachlass auf dieses Teil.';


--
-- Name: COLUMN parts.goodwill_percent; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts.goodwill_percent IS 'Relativer Kulanzanteil des Händlers.';


--
-- Name: COLUMN parts.parts_type; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts.parts_type IS 'Teileart';


--
-- Name: COLUMN parts.text_line; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts.text_line IS 'Bezeichnung';


--
-- Name: COLUMN parts.usage_value; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts.usage_value IS 'Gesamt-Einsatzwert, sofern das Teil fakturiert und der Einsatzwert geprüft wurde. ACHTUNG: Diese Logik könnte sich noch ändern';


--
-- Name: parts_additional_descriptions; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.parts_additional_descriptions (
    part_number character varying(20) NOT NULL COLLATE pg_catalog."C",
    description character varying(50),
    search_description character varying(50) COLLATE pg_catalog."C",
    description_vector tsvector GENERATED ALWAYS AS (to_tsvector('simple'::regconfig, (description)::text)) STORED
);


ALTER TABLE public.parts_additional_descriptions OWNER TO postgres;

--
-- Name: TABLE parts_additional_descriptions; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.parts_additional_descriptions IS 'Teile-Zusatzbezeichnungen';


--
-- Name: COLUMN parts_additional_descriptions.part_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_additional_descriptions.part_number IS 'Teilenummer in Loco-Soft, zu der die Zusatzbezeichnung gehört';


--
-- Name: COLUMN parts_additional_descriptions.description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_additional_descriptions.description IS 'Zusatzbezeichnung';


--
-- Name: COLUMN parts_additional_descriptions.search_description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_additional_descriptions.search_description IS 'Internes Such-Feld';


--
-- Name: parts_inbound_delivery_notes; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.parts_inbound_delivery_notes (
    supplier_number integer NOT NULL,
    year_key integer NOT NULL,
    number_main character varying(10) NOT NULL,
    number_sub character varying(4) NOT NULL,
    counter integer NOT NULL,
    purchase_invoice_year integer,
    purchase_invoice_number character varying(12),
    part_number character varying(20) COLLATE pg_catalog."C",
    stock_no integer,
    amount numeric(9,2),
    delivery_note_date date,
    parts_order_number integer,
    parts_order_note character varying(15),
    deliverers_note character varying(12),
    referenced_order_number integer,
    referenced_order_position integer,
    referenced_order_line integer,
    is_veryfied boolean,
    parts_order_type integer,
    rr_gross_price numeric(9,2),
    purchase_total_net_price numeric(9,2),
    parts_type integer,
    employee_number_veryfied integer,
    employee_number_imported integer,
    employee_number_last integer
);


ALTER TABLE public.parts_inbound_delivery_notes OWNER TO postgres;

--
-- Name: TABLE parts_inbound_delivery_notes; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.parts_inbound_delivery_notes IS 'Teilezugänge aus Lieferscheinen und Rechnungen';


--
-- Name: COLUMN parts_inbound_delivery_notes.supplier_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_inbound_delivery_notes.supplier_number IS 'Lieferanten-Nummer';


--
-- Name: COLUMN parts_inbound_delivery_notes.year_key; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_inbound_delivery_notes.year_key IS 'Jahr mit Jahrhundert des Lieferscheins. Grund: Lieferscheinnummern können sich wiederholen, weshalb die Lieferscheinnummer nur innerhalb eines Jahres eindeutig sein muss';


--
-- Name: COLUMN parts_inbound_delivery_notes.number_main; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_inbound_delivery_notes.number_main IS 'Lieferscheinnummer';


--
-- Name: COLUMN parts_inbound_delivery_notes.number_sub; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_inbound_delivery_notes.number_sub IS 'Ggf. Subnummer des Lieferscheins';


--
-- Name: COLUMN parts_inbound_delivery_notes.counter; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_inbound_delivery_notes.counter IS 'Laufende Nummer der Teileposition innerhalb des Lieferscheins';


--
-- Name: COLUMN parts_inbound_delivery_notes.purchase_invoice_year; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_inbound_delivery_notes.purchase_invoice_year IS 'Jahr (mit Jahrhundert) der Eingangsrechnung';


--
-- Name: COLUMN parts_inbound_delivery_notes.purchase_invoice_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_inbound_delivery_notes.purchase_invoice_number IS 'Nummer der Eingangsrechnung (kann führende Leerzeichen enthalten';


--
-- Name: COLUMN parts_inbound_delivery_notes.part_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_inbound_delivery_notes.part_number IS 'Gelieferte Teilenummer (Teilenummern können führende Leerzeichen enthalten)';


--
-- Name: COLUMN parts_inbound_delivery_notes.stock_no; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_inbound_delivery_notes.stock_no IS 'Lager';


--
-- Name: COLUMN parts_inbound_delivery_notes.amount; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_inbound_delivery_notes.amount IS 'Zugangsmenge';


--
-- Name: COLUMN parts_inbound_delivery_notes.delivery_note_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_inbound_delivery_notes.delivery_note_date IS 'Lieferscheindatum';


--
-- Name: COLUMN parts_inbound_delivery_notes.parts_order_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_inbound_delivery_notes.parts_order_number IS 'Loco-Soft Bestellnummer die zu diesem Lieferschein gehört, oder NULL';


--
-- Name: COLUMN parts_inbound_delivery_notes.parts_order_note; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_inbound_delivery_notes.parts_order_note IS 'Bestellhinweis aus der zugehörigen Bestellung, sofern die Bestellung in Loco-Soft erfasst wurde';


--
-- Name: COLUMN parts_inbound_delivery_notes.deliverers_note; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_inbound_delivery_notes.deliverers_note IS 'Beliebiger Referenztext des Lieferanten, wie z.B. interne Bestellnummern oder bei manchen Herstellern Angaben aus der Bestellung';


--
-- Name: COLUMN parts_inbound_delivery_notes.referenced_order_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_inbound_delivery_notes.referenced_order_number IS 'Bezug zu Auftrag';


--
-- Name: COLUMN parts_inbound_delivery_notes.referenced_order_position; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_inbound_delivery_notes.referenced_order_position IS 'Bezug zu Auftrag-Position';


--
-- Name: COLUMN parts_inbound_delivery_notes.referenced_order_line; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_inbound_delivery_notes.referenced_order_line IS 'Bezug zu Auftrag-Zeile';


--
-- Name: COLUMN parts_inbound_delivery_notes.is_veryfied; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_inbound_delivery_notes.is_veryfied IS 'Die Lieferscheinposition wurde geprüft (TRUE) oder nicht (FALSE)';


--
-- Name: COLUMN parts_inbound_delivery_notes.parts_order_type; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_inbound_delivery_notes.parts_order_type IS 'Loco-Soft Bestellart (für Zuordnung zu Lieferkonditionen)';


--
-- Name: COLUMN parts_inbound_delivery_notes.rr_gross_price; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_inbound_delivery_notes.rr_gross_price IS 'Empfohlener Verkaufspreis je Stück inklusive MwSt. rr_gross_price = recommended retailer gross price';


--
-- Name: COLUMN parts_inbound_delivery_notes.purchase_total_net_price; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_inbound_delivery_notes.purchase_total_net_price IS 'Gesamt-Einkaufspreis (netto)';


--
-- Name: COLUMN parts_inbound_delivery_notes.parts_type; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_inbound_delivery_notes.parts_type IS 'Teileart';


--
-- Name: COLUMN parts_inbound_delivery_notes.employee_number_veryfied; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_inbound_delivery_notes.employee_number_veryfied IS 'Verprobt von Mitarbeiter Nr.';


--
-- Name: COLUMN parts_inbound_delivery_notes.employee_number_imported; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_inbound_delivery_notes.employee_number_imported IS 'Importiert aus elektronischem Lieferschein in Pr.539 durch Mitarbeiter Nr.';


--
-- Name: COLUMN parts_inbound_delivery_notes.employee_number_last; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_inbound_delivery_notes.employee_number_last IS 'Zuletzt geändert durch Mitarbeiter Nr.';


--
-- Name: parts_master; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.parts_master (
    part_number character varying(20) NOT NULL COLLATE pg_catalog."C",
    description character varying(32) COLLATE pg_catalog."de-x-icu",
    rebate_percent numeric(9,5),
    package_unit_type character varying(2),
    package_size integer,
    delivery_size integer,
    weight numeric(9,3),
    warranty_flag character varying(2),
    last_import_date date,
    price_valid_from_date date,
    storage_flag character varying(1),
    rebate_code character varying(4),
    parts_type integer,
    manufacturer_parts_type character varying(4),
    rr_price numeric(9,3),
    price_surcharge_percent numeric(9,5),
    selling_price_base_upe boolean,
    is_price_based_on_usage_value boolean,
    is_price_based_on_spcl_price boolean,
    has_price_common_surcharge boolean,
    allow_price_under_margin boolean,
    allow_price_under_usage_value boolean,
    is_stock_neutral boolean,
    is_stock_neutral_usage_v boolean,
    skr_carrier_flag numeric(2,0),
    price_import_keeps_description boolean,
    country_of_origin character varying(5),
    manufacturer_assembly_group character varying(7),
    has_information_ref boolean,
    has_costs_ref boolean,
    has_special_prices_ref boolean,
    has_special_offer_ref boolean,
    search_description character varying(32) COLLATE pg_catalog."C",
    description_vector tsvector GENERATED ALWAYS AS (to_tsvector('simple'::regconfig, (description)::text)) STORED
);


ALTER TABLE public.parts_master OWNER TO postgres;

--
-- Name: TABLE parts_master; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.parts_master IS 'Teilegrunddaten';


--
-- Name: COLUMN parts_master.part_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_master.part_number IS 'Teilenummer (können in Loco-Soft auch führenden Leerzeichen enthalten)';


--
-- Name: COLUMN parts_master.description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_master.description IS 'Teilebezeihnung';


--
-- Name: COLUMN parts_master.rebate_percent; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_master.rebate_percent IS 'Dieses Feld wird bei ET benötigt, denen kein Rabattcode zugewiesen ist';


--
-- Name: COLUMN parts_master.package_unit_type; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_master.package_unit_type IS 'Gebindeform, z.B. CM = Zentimeter, M = Meter, ST = Stück (rein informativ)';


--
-- Name: COLUMN parts_master.package_size; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_master.package_size IS 'Werden z.B. Dichtringe nur in 20er Packs geliefert, steht hier der Wert 20';


--
-- Name: COLUMN parts_master.delivery_size; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_master.delivery_size IS 'Liefergröße: Üblicherweise 1, außer es wird z.B. ein 205 Liter Fass Öl gekauft aber literweise verkauft';


--
-- Name: COLUMN parts_master.weight; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_master.weight IS 'Gewicht';


--
-- Name: COLUMN parts_master.warranty_flag; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_master.warranty_flag IS 'Steuerung herstellerspezifischer Verhalten in der Erfassung von Garantieanträgen in Loco-Soft, z.B. zur Verwendung einer abweichenden UPE oder für Eingaben einer Seriennummer oder abweichender Teilenu';


--
-- Name: COLUMN parts_master.last_import_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_master.last_import_date IS 'Datum der letzten Aktualisierung durch Import in Programm 951';


--
-- Name: COLUMN parts_master.price_valid_from_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_master.price_valid_from_date IS 'Preis gültig ab Datum';


--
-- Name: COLUMN parts_master.storage_flag; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_master.storage_flag IS 'Lagerkennzeichen zur speicherung herstellerspezifischer Codierungen. Besonderheit: Das Lagerkennzeichen "#" kennzeichnet nicht mehr lieferbare Teile.';


--
-- Name: COLUMN parts_master.rebate_code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_master.rebate_code IS 'Rabattcode zur Ermittlung des Nachlasses bei Einkauf';


--
-- Name: COLUMN parts_master.parts_type; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_master.parts_type IS 'Teileart';


--
-- Name: COLUMN parts_master.manufacturer_parts_type; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_master.manufacturer_parts_type IS 'Herstellerspezifische Typisierung';


--
-- Name: COLUMN parts_master.rr_price; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_master.rr_price IS 'Unverbindliche Preisempfehlung des Herstellers für den Verkauf an Endabnehmer';


--
-- Name: COLUMN parts_master.price_surcharge_percent; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_master.price_surcharge_percent IS 'Prozentualer Aufschlag auf die UPE oder Einsatzwert (abhängig von der Preisbasis/price_basis)';


--
-- Name: COLUMN parts_master.selling_price_base_upe; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_master.selling_price_base_upe IS 'Verkaufspreis ergibt sich aus UPE';


--
-- Name: COLUMN parts_master.is_price_based_on_usage_value; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_master.is_price_based_on_usage_value IS 'Verkaufspreis ergibt sich aus Einsatzwert';


--
-- Name: COLUMN parts_master.is_price_based_on_spcl_price; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_master.is_price_based_on_spcl_price IS 'Verkaufspreis ergibt sich zusätzlich zu UPE oder Einsatzwert durch Sonderpreise';


--
-- Name: COLUMN parts_master.has_price_common_surcharge; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_master.has_price_common_surcharge IS 'Verkaufspreis ergibt sich zusätzlich zu UPE oder Einsatzwert durch allgemeine Aufschläge';


--
-- Name: COLUMN parts_master.allow_price_under_margin; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_master.allow_price_under_margin IS 'Das Teil darf unter Handelsspanne verkauft werden';


--
-- Name: COLUMN parts_master.allow_price_under_usage_value; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_master.allow_price_under_usage_value IS 'Das Teil darf unter Einsatzwert verkauft werden';


--
-- Name: COLUMN parts_master.is_stock_neutral; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_master.is_stock_neutral IS 'ET immer bestandsneutral';


--
-- Name: COLUMN parts_master.is_stock_neutral_usage_v; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_master.is_stock_neutral_usage_v IS 'ET bestandsneutral und manueller Einsatzwert';


--
-- Name: COLUMN parts_master.skr_carrier_flag; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_master.skr_carrier_flag IS 'Kostenträgermerkmal für die Buchhaltung';


--
-- Name: COLUMN parts_master.price_import_keeps_description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_master.price_import_keeps_description IS 'Die Bezeichnung wird durch Importe nicht verändert (TRUE) oder kann durch Importe verändert werden (FALSE)';


--
-- Name: COLUMN parts_master.country_of_origin; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_master.country_of_origin IS 'Manuell eingegebene Lädercodierung des Ursprungslandes oder herstellerspezifische Länder- und Rabattcodierung';


--
-- Name: COLUMN parts_master.manufacturer_assembly_group; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_master.manufacturer_assembly_group IS 'Herstellerspezifische Codierung der Baugruppe';


--
-- Name: COLUMN parts_master.has_information_ref; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_master.has_information_ref IS 'Programminternes Kennzeichen: Zu diesem Datensatz existieren Zusatzinformationen';


--
-- Name: COLUMN parts_master.has_costs_ref; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_master.has_costs_ref IS 'Programminternes Kennzeichen: Zu diesem Datensatz existieren Zusatzkosten';


--
-- Name: COLUMN parts_master.has_special_prices_ref; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_master.has_special_prices_ref IS 'Programminternes Kennzeichen: Zu diesem Datensatz existieren Zusatzpreise';


--
-- Name: COLUMN parts_master.has_special_offer_ref; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_master.has_special_offer_ref IS 'Programminternes Kennzeichen: Zu diesem Datensatz existieren Aktionspreise';


--
-- Name: COLUMN parts_master.search_description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_master.search_description IS 'Suchindex für interne Such- und Sortieraufgaben als Bytes anstatt als Text';


--
-- Name: parts_rebate_codes_buy; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.parts_rebate_codes_buy (
    rebate_group_code integer NOT NULL,
    rebate_code character varying(5) NOT NULL,
    rebate_code_counter integer NOT NULL,
    parts_type_boundary_from integer,
    parts_type_boundary_until integer,
    rebate_percent numeric(9,5),
    description character varying(50)
);


ALTER TABLE public.parts_rebate_codes_buy OWNER TO postgres;

--
-- Name: TABLE parts_rebate_codes_buy; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.parts_rebate_codes_buy IS 'Teile-Rabatt-Codes Einkauf: Einkaufs-Rabattprozente';


--
-- Name: COLUMN parts_rebate_codes_buy.rebate_group_code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_rebate_codes_buy.rebate_group_code IS 'Teile-Rabatt-Gruppe';


--
-- Name: COLUMN parts_rebate_codes_buy.rebate_code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_rebate_codes_buy.rebate_code IS 'Rabattcode (steht in Tabelle parts_rebate_codes_buy)';


--
-- Name: COLUMN parts_rebate_codes_buy.rebate_code_counter; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_rebate_codes_buy.rebate_code_counter IS 'Interner Keyanteil um mehrere Rabattcodes zu einer TRG speichern zu können (wird in Auswertungen etc nicht verwendet)';


--
-- Name: COLUMN parts_rebate_codes_buy.parts_type_boundary_from; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_rebate_codes_buy.parts_type_boundary_from IS 'Dieser Rabattcode gilt für Teile ab der angegebenen Teileart';


--
-- Name: COLUMN parts_rebate_codes_buy.parts_type_boundary_until; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_rebate_codes_buy.parts_type_boundary_until IS 'Dieser Rabattcode gilt für Teile bis zu der angegebenen Teileart';


--
-- Name: COLUMN parts_rebate_codes_buy.rebate_percent; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_rebate_codes_buy.rebate_percent IS 'Nachlass in Prozent';


--
-- Name: COLUMN parts_rebate_codes_buy.description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_rebate_codes_buy.description IS 'Information zu dem Rabattcode';


--
-- Name: parts_rebate_codes_sell; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.parts_rebate_codes_sell (
    rebate_group_code integer NOT NULL,
    rebate_code character varying(5) NOT NULL,
    rebate_code_counter integer NOT NULL,
    parts_type_boundary_from integer,
    parts_type_boundary_until integer,
    rebate_percent numeric(9,5),
    description character varying(50)
);


ALTER TABLE public.parts_rebate_codes_sell OWNER TO postgres;

--
-- Name: TABLE parts_rebate_codes_sell; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.parts_rebate_codes_sell IS 'Teile-Rabatt-Codes Verkauf: Verkaufs-Rabattprozente';


--
-- Name: COLUMN parts_rebate_codes_sell.rebate_group_code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_rebate_codes_sell.rebate_group_code IS 'Teile-Rabatt-Gruppe';


--
-- Name: COLUMN parts_rebate_codes_sell.rebate_code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_rebate_codes_sell.rebate_code IS 'Rabattcode (steht in Tabelle parts_rebate_codes_buy)';


--
-- Name: COLUMN parts_rebate_codes_sell.rebate_code_counter; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_rebate_codes_sell.rebate_code_counter IS 'Interner Keyanteil um mehrere Rabattcodes zu einer TRG speichern zu können (wird in Auswertungen etc nicht verwendet)';


--
-- Name: COLUMN parts_rebate_codes_sell.parts_type_boundary_from; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_rebate_codes_sell.parts_type_boundary_from IS 'Dieser Rabattcode gilt für Teile ab der angegebenen Teileart';


--
-- Name: COLUMN parts_rebate_codes_sell.parts_type_boundary_until; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_rebate_codes_sell.parts_type_boundary_until IS 'Dieser Rabattcode gilt für Teile bis zu der angegebenen Teileart';


--
-- Name: COLUMN parts_rebate_codes_sell.rebate_percent; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_rebate_codes_sell.rebate_percent IS 'Nachlass in Prozent';


--
-- Name: COLUMN parts_rebate_codes_sell.description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_rebate_codes_sell.description IS 'Information zu dem Rabattcode';


--
-- Name: parts_rebate_groups_buy; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.parts_rebate_groups_buy (
    code integer NOT NULL,
    description character varying(25),
    CONSTRAINT parts_rebate_groups_buy_code_check CHECK ((code > 0))
);


ALTER TABLE public.parts_rebate_groups_buy OWNER TO postgres;

--
-- Name: TABLE parts_rebate_groups_buy; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.parts_rebate_groups_buy IS 'Teile-Rabatt-Gruppe Einkauf: Rabattgruppen für den Händler, den er bei seinen Lieferanten hat.';


--
-- Name: COLUMN parts_rebate_groups_buy.code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_rebate_groups_buy.code IS 'Teile-Rabatt-Gruppe';


--
-- Name: COLUMN parts_rebate_groups_buy.description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_rebate_groups_buy.description IS 'Bezeichnung der Rabatt-Gruppe';


--
-- Name: parts_rebate_groups_sell; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.parts_rebate_groups_sell (
    code integer NOT NULL,
    description character varying(25),
    CONSTRAINT parts_rebate_groups_sell_code_check CHECK ((code > 0))
);


ALTER TABLE public.parts_rebate_groups_sell OWNER TO postgres;

--
-- Name: TABLE parts_rebate_groups_sell; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.parts_rebate_groups_sell IS 'Teile-Rabatt-Gruppe Verkauf: Rabattgruppen für Kunden des Händlers';


--
-- Name: COLUMN parts_rebate_groups_sell.code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_rebate_groups_sell.code IS 'Teile-Rabatt-Gruppe';


--
-- Name: COLUMN parts_rebate_groups_sell.description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_rebate_groups_sell.description IS 'Bezeichnung der Rabatt-Gruppe';


--
-- Name: parts_special_offer_prices; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.parts_special_offer_prices (
    part_number character varying(20) NOT NULL COLLATE pg_catalog."C",
    is_active boolean,
    valid_from_date date,
    valid_until_date date,
    price numeric(9,2),
    addition_percent numeric(9,5)
);


ALTER TABLE public.parts_special_offer_prices OWNER TO postgres;

--
-- Name: TABLE parts_special_offer_prices; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.parts_special_offer_prices IS 'Aktionspreise (zeitlich begrenzt) für Teile';


--
-- Name: COLUMN parts_special_offer_prices.part_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_special_offer_prices.part_number IS 'Teilenummer, auf die sich der Aktionspreis in diesem Datensatz beziehen';


--
-- Name: COLUMN parts_special_offer_prices.is_active; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_special_offer_prices.is_active IS 'Der Aktionspreis wird verwendet (TRUE) oder nicht (FALSE)';


--
-- Name: COLUMN parts_special_offer_prices.valid_from_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_special_offer_prices.valid_from_date IS 'Der Aktionspreis gilt ab diesem Datum';


--
-- Name: COLUMN parts_special_offer_prices.valid_until_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_special_offer_prices.valid_until_date IS 'Der Aktionspreis gilt ab diesem Datum';


--
-- Name: COLUMN parts_special_offer_prices.price; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_special_offer_prices.price IS 'Der Aktionspreis';


--
-- Name: COLUMN parts_special_offer_prices.addition_percent; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_special_offer_prices.addition_percent IS 'Prozentualer Aufschlag oder Abschlag zu dem Aktionspreis';


--
-- Name: parts_special_prices; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.parts_special_prices (
    part_number character varying(20) NOT NULL COLLATE pg_catalog."C",
    order_classification_flag character varying(2) NOT NULL,
    is_active boolean,
    price numeric(9,2),
    addition_percent numeric(9,5)
);


ALTER TABLE public.parts_special_prices OWNER TO postgres;

--
-- Name: TABLE parts_special_prices; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.parts_special_prices IS 'Sonderpreise für Teile in Abhängigkeit von Auftragskennzeichen';


--
-- Name: COLUMN parts_special_prices.part_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_special_prices.part_number IS 'Teilenummer, auf die sich die Sonderpreise in diesem Datensatz beziehen';


--
-- Name: COLUMN parts_special_prices.order_classification_flag; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_special_prices.order_classification_flag IS 'Der Sonderpreis gilt für das hier angegebene Auftragskennzeichen';


--
-- Name: COLUMN parts_special_prices.is_active; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_special_prices.is_active IS 'Der Sonderpreis wird verwendet (TRUE) oder nicht (FALSE)';


--
-- Name: COLUMN parts_special_prices.price; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_special_prices.price IS 'Der Sonderpreis';


--
-- Name: COLUMN parts_special_prices.addition_percent; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_special_prices.addition_percent IS 'Prozentualer Aufschlag oder Abschlag zu dem Sonderpreis';


--
-- Name: parts_stock; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.parts_stock (
    part_number character varying(20) NOT NULL COLLATE pg_catalog."C",
    stock_no integer NOT NULL,
    storage_location_1 character varying(8),
    storage_location_2 character varying(8),
    usage_value numeric(9,2),
    stock_level numeric(8,2),
    stock_allocated numeric(8,2),
    minimum_stock_level numeric(8,2),
    has_warn_on_below_min_level boolean,
    maximum_stock_level integer,
    stop_order_flag character varying(1),
    revenue_account_group character varying(4),
    average_sales_statstic numeric(5,2),
    sales_current_year numeric(8,2),
    sales_previous_year numeric(8,2),
    total_buy_value numeric(9,2),
    total_sell_value numeric(9,2),
    provider_flag character varying(1),
    last_outflow_date date,
    last_inflow_date date,
    unevaluated_inflow_positions integer,
    is_disabled_in_parts_platforms boolean,
    lock_by_workstation integer,
    lock_time timestamp without time zone,
    lock_trace character varying(100),
    lock_trigger character varying(100),
    lock_by_employee integer,
    lock_sourcecode character varying(100)
);


ALTER TABLE public.parts_stock OWNER TO postgres;

--
-- Name: TABLE parts_stock; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.parts_stock IS 'Lagerbestände und weitere lager spezifische Teiledaten';


--
-- Name: COLUMN parts_stock.part_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_stock.part_number IS 'Teilenummer, auf die sich die Lagerdaten beziehen';


--
-- Name: COLUMN parts_stock.stock_no; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_stock.stock_no IS 'Lagernummer';


--
-- Name: COLUMN parts_stock.storage_location_1; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_stock.storage_location_1 IS 'Erster von zwei Lagerorten';


--
-- Name: COLUMN parts_stock.storage_location_2; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_stock.storage_location_2 IS 'Zweiter von zwei Lagerorten';


--
-- Name: COLUMN parts_stock.usage_value; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_stock.usage_value IS 'Kumulierter Einsatzwert je Stück';


--
-- Name: COLUMN parts_stock.stock_level; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_stock.stock_level IS 'Anzahl in Bestand';


--
-- Name: COLUMN parts_stock.stock_allocated; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_stock.stock_allocated IS 'Anzahl, die aktuell als im Bestand geführt wird, aber bereits auf Aufträge zugebucht und noch nicht fakturiert ist';


--
-- Name: COLUMN parts_stock.minimum_stock_level; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_stock.minimum_stock_level IS 'Mindest-Lagerbestand';


--
-- Name: COLUMN parts_stock.has_warn_on_below_min_level; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_stock.has_warn_on_below_min_level IS 'Warnung in Fakturierung, wenn Mindestbestand unterschritten wird';


--
-- Name: COLUMN parts_stock.maximum_stock_level; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_stock.maximum_stock_level IS 'Maximaler Lagerbestand';


--
-- Name: COLUMN parts_stock.stop_order_flag; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_stock.stop_order_flag IS 'Bestellsperrung (NULL wenn nicht gesperrt)';


--
-- Name: COLUMN parts_stock.revenue_account_group; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_stock.revenue_account_group IS 'Sondererklöskonto-Gruppen, dieses Feld wird für die BayWa AG in München genutzt';


--
-- Name: COLUMN parts_stock.average_sales_statstic; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_stock.average_sales_statstic IS 'MIPO (Mittlerer Teileabgang in Stück pro Bestell-Periode, kann NULL sein)';


--
-- Name: COLUMN parts_stock.sales_current_year; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_stock.sales_current_year IS 'Verkaufte Stück im laufenden Jahr';


--
-- Name: COLUMN parts_stock.sales_previous_year; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_stock.sales_previous_year IS 'Verkaufte Stück im Vorjahr';


--
-- Name: COLUMN parts_stock.total_buy_value; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_stock.total_buy_value IS 'Einkaufswert im laufenden Jahr';


--
-- Name: COLUMN parts_stock.total_sell_value; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_stock.total_sell_value IS 'Verkaufswert im laufenden Jahr';


--
-- Name: COLUMN parts_stock.provider_flag; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_stock.provider_flag IS 'Manuell hinterlegbares Kennzeichen für abweichende Lieferanten (nicht Originalteile)';


--
-- Name: COLUMN parts_stock.last_outflow_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_stock.last_outflow_date IS 'Erfassung letzter Abgang';


--
-- Name: COLUMN parts_stock.last_inflow_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_stock.last_inflow_date IS 'Erfassung letzter Zugang';


--
-- Name: COLUMN parts_stock.unevaluated_inflow_positions; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_stock.unevaluated_inflow_positions IS 'Ungeprüfte Zugangspositionen';


--
-- Name: COLUMN parts_stock.is_disabled_in_parts_platforms; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_stock.is_disabled_in_parts_platforms IS 'bei Ausgabe an Teile-Börsen dieses Teil sperren';


--
-- Name: COLUMN parts_stock.lock_by_workstation; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_stock.lock_by_workstation IS 'Protokollierung von Datensatz-Sperren: Arbeitsplatznummer, der die Sperre erzeugt hat oder NULL.';


--
-- Name: COLUMN parts_stock.lock_time; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_stock.lock_time IS 'Protokollierung von Datensatz-Sperren: Zeitstempel, an dem der Datensatz mit Sperre zuletzt geändert wurde oder NULL.';


--
-- Name: COLUMN parts_stock.lock_trace; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_stock.lock_trace IS 'Protokollierung von Datensatz-Sperren: Reihenfolge der aufgerufenen Programme bei letztem Update des Datesatzes oder NULL.';


--
-- Name: COLUMN parts_stock.lock_trigger; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_stock.lock_trigger IS 'Protokollierung von Datensatz-Sperren: Dienstname oder UI-Information oder NULL.';


--
-- Name: COLUMN parts_stock.lock_by_employee; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_stock.lock_by_employee IS 'Protokollierung von Datensatz-Sperren: Interne Mitarbeiter-Nr. oder NULL.';


--
-- Name: COLUMN parts_stock.lock_sourcecode; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_stock.lock_sourcecode IS 'Protokollierung von Datensatz-Sperren: Programmstelle oder NULL.';


--
-- Name: parts_supplier_numbers; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.parts_supplier_numbers (
    part_number character varying(20) NOT NULL COLLATE pg_catalog."C",
    external_number character varying(20)
);


ALTER TABLE public.parts_supplier_numbers OWNER TO postgres;

--
-- Name: TABLE parts_supplier_numbers; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.parts_supplier_numbers IS 'Lieferanten-Teile-Nummern';


--
-- Name: COLUMN parts_supplier_numbers.part_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_supplier_numbers.part_number IS 'Teilenummer in Loco-Soft, auf die sich die Hersteller-Teilenummern beziehen';


--
-- Name: COLUMN parts_supplier_numbers.external_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_supplier_numbers.external_number IS 'Hersteller-Teilenummer';


--
-- Name: parts_to_vehicles; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.parts_to_vehicles (
    part_number character varying(20) NOT NULL COLLATE pg_catalog."C",
    unique_reference character varying(20) NOT NULL,
    unique_counter integer NOT NULL,
    note character varying(20),
    vin_pattern character varying(17),
    model_pattern character varying(20),
    model_date_start date,
    model_date_end date
);


ALTER TABLE public.parts_to_vehicles OWNER TO postgres;

--
-- Name: TABLE parts_to_vehicles; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.parts_to_vehicles IS 'Teile-Fahrzeugfilter';


--
-- Name: COLUMN parts_to_vehicles.part_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_to_vehicles.part_number IS 'Teilenummer, auf die sich der Fahrzeugfilter in diesem Datensatz beziehen';


--
-- Name: COLUMN parts_to_vehicles.unique_reference; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_to_vehicles.unique_reference IS 'Interner Keyanteil 2 von 3';


--
-- Name: COLUMN parts_to_vehicles.unique_counter; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_to_vehicles.unique_counter IS 'Interner Keyanteil 3 von 3';


--
-- Name: COLUMN parts_to_vehicles.note; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_to_vehicles.note IS 'Frei vergebbarer Hinweistext für diese Zuordnung';


--
-- Name: COLUMN parts_to_vehicles.vin_pattern; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_to_vehicles.vin_pattern IS 'Suchmaske für Fahrgestellnummer oder NULL';


--
-- Name: COLUMN parts_to_vehicles.model_pattern; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_to_vehicles.model_pattern IS 'Suchmaske für Modellcode oder NULL';


--
-- Name: COLUMN parts_to_vehicles.model_date_start; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_to_vehicles.model_date_start IS 'Baujahr/Modelljahr/Erstzulassung von';


--
-- Name: COLUMN parts_to_vehicles.model_date_end; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.parts_to_vehicles.model_date_end IS 'Baujahr/Modelljahr/Erstzulassung bis';


--
-- Name: privacy_channels; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.privacy_channels (
    channel_code character varying(1) NOT NULL,
    is_business boolean,
    description character varying(200)
);


ALTER TABLE public.privacy_channels OWNER TO postgres;

--
-- Name: TABLE privacy_channels; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.privacy_channels IS 'Kontaktwege im Datenschutz (z.B. eMail privat und eMail geschäftlich)';


--
-- Name: COLUMN privacy_channels.channel_code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.privacy_channels.channel_code IS 'Codierung für den Kontaktweg. Z.B. "E" für eMail privat oder "e" für eMail dienstlich';


--
-- Name: COLUMN privacy_channels.is_business; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.privacy_channels.is_business IS 'true = geschäftlicher/dienstlicher Kontaktweg, false = privater Kontaktweg';


--
-- Name: COLUMN privacy_channels.description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.privacy_channels.description IS 'Beschreibung des Kontaktweges';


--
-- Name: privacy_details; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.privacy_details (
    customer_number integer NOT NULL,
    subsidiary_to_company_ref integer NOT NULL,
    make_name character varying(9) NOT NULL,
    scope_code character varying(1) NOT NULL,
    channel_code character varying(1) NOT NULL,
    is_agreed boolean
);


ALTER TABLE public.privacy_details OWNER TO postgres;

--
-- Name: TABLE privacy_details; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.privacy_details IS 'Inhalte der Datenschutzerklärungen';


--
-- Name: COLUMN privacy_details.customer_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.privacy_details.customer_number IS 'Kundennummer, auf die sich die Datenschutzerklärung bezieht';


--
-- Name: COLUMN privacy_details.subsidiary_to_company_ref; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.privacy_details.subsidiary_to_company_ref IS 'Bei rechtlich getrennten Betrieben wird je Betriebsgruppe eine Erklärung hinterlegt. Hier steht der Hauptbetrieb der Betriebsgruppe (siehe Tabelle subsidiaries)';


--
-- Name: COLUMN privacy_details.make_name; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.privacy_details.make_name IS 'Bei Bezug zu einem Fabrikat steht hier der Fabrikatsname. Ansonsten eine leere Zeichenkette. Der Fabrikatsname kann in Pr.913 frei vergeben werden.';


--
-- Name: COLUMN privacy_details.scope_code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.privacy_details.scope_code IS 'Codierung für den Gültigkeitsbereich (z.B. für Händler oder einen bestimmen Hersteller/Importeur)';


--
-- Name: COLUMN privacy_details.channel_code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.privacy_details.channel_code IS 'Codierung für den Kontaktweg. Z.B. "E" für eMail privat oder "e" für eMail dienstlich';


--
-- Name: COLUMN privacy_details.is_agreed; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.privacy_details.is_agreed IS 'true = Kontakt zugestimmt, ansonsten kein Kontakt erlaubt';


--
-- Name: privacy_protection_consent; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.privacy_protection_consent (
    customer_number integer NOT NULL,
    subsidiary_to_company_ref integer NOT NULL,
    make_name character varying(9) NOT NULL,
    validity_date_start date,
    validity_date_end date,
    created_print_time timestamp without time zone,
    created_employee_no integer,
    last_change_print_time timestamp without time zone,
    last_change_employee_no integer,
    first_ackno_print_time timestamp without time zone,
    first_ackno_employee_no integer,
    last_ackno_print_time timestamp without time zone,
    last_ackno_employee_no integer,
    first_consent_print_time timestamp without time zone,
    first_consent_employee_no integer,
    last_consent_print_time timestamp without time zone,
    last_consent_employee_no integer,
    internal_id bigint
);


ALTER TABLE public.privacy_protection_consent OWNER TO postgres;

--
-- Name: TABLE privacy_protection_consent; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.privacy_protection_consent IS 'Datenschuterklärungen je Kunde mit Gültigkeitszeitraum';


--
-- Name: COLUMN privacy_protection_consent.customer_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.privacy_protection_consent.customer_number IS 'Kundennummer, auf die sich die Datenschutzerklärung bezieht';


--
-- Name: COLUMN privacy_protection_consent.subsidiary_to_company_ref; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.privacy_protection_consent.subsidiary_to_company_ref IS 'Bei rechtlich getrennten Betrieben wird je Betriebsgruppe eine Erklärung hinterlegt. Hier steht der Hauptbetrieb der Betriebsgruppe (siehe Tabelle subsidiaries)';


--
-- Name: COLUMN privacy_protection_consent.make_name; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.privacy_protection_consent.make_name IS 'Bei Bezug zu einem Fabrikat steht hier der Fabrikatsname. Ansonsten eine leere Zeichenkette. Der Fabrikatsname kann in Pr.913 frei vergeben werden.';


--
-- Name: COLUMN privacy_protection_consent.validity_date_start; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.privacy_protection_consent.validity_date_start IS 'Datum, ab wann die Datenschutzerklärung gültig ist/war';


--
-- Name: COLUMN privacy_protection_consent.validity_date_end; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.privacy_protection_consent.validity_date_end IS 'Datum, bis wann die Datenschutzerklärung gültig ist/war';


--
-- Name: COLUMN privacy_protection_consent.created_print_time; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.privacy_protection_consent.created_print_time IS 'Zeitpunkt, an dem der Datensatz erstellt wurde';


--
-- Name: COLUMN privacy_protection_consent.created_employee_no; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.privacy_protection_consent.created_employee_no IS 'Mitarbeiter, der den Datensatz erstellt hat';


--
-- Name: COLUMN privacy_protection_consent.last_change_print_time; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.privacy_protection_consent.last_change_print_time IS 'Zeitpunkt, an dem der Datensatz zuletzt geändert wurde oder NULL';


--
-- Name: COLUMN privacy_protection_consent.last_change_employee_no; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.privacy_protection_consent.last_change_employee_no IS 'Mitarbeiter, der den Datensatz zuletzt geändert hat oder NULL';


--
-- Name: COLUMN privacy_protection_consent.first_ackno_print_time; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.privacy_protection_consent.first_ackno_print_time IS 'Zeitpunkt, an dem die Datenschutz-Bestätigung zuerst gedruckt wurde oder NULL';


--
-- Name: COLUMN privacy_protection_consent.first_ackno_employee_no; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.privacy_protection_consent.first_ackno_employee_no IS 'Mitarbeiter, der die erste Bestätigung gedruckt hat oder NULL';


--
-- Name: COLUMN privacy_protection_consent.last_ackno_print_time; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.privacy_protection_consent.last_ackno_print_time IS 'Zeitpunkt, an dem die Datenschutz-Bestätigung zuletzt gedruckt wurde oder NULL';


--
-- Name: COLUMN privacy_protection_consent.last_ackno_employee_no; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.privacy_protection_consent.last_ackno_employee_no IS 'Mitarbeiter, der die letzte Bestätigung gedruckt hat oder NULL';


--
-- Name: COLUMN privacy_protection_consent.first_consent_print_time; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.privacy_protection_consent.first_consent_print_time IS 'Zeitpunkt, an dem die Datenschutz-Einwilligung zuerst gedruckt wurde oder NULL';


--
-- Name: COLUMN privacy_protection_consent.first_consent_employee_no; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.privacy_protection_consent.first_consent_employee_no IS 'Mitarbeiter, der die erste Einwilligung gedruckt hat oder NULL';


--
-- Name: COLUMN privacy_protection_consent.last_consent_print_time; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.privacy_protection_consent.last_consent_print_time IS 'Zeitpunkt, an dem die Datenschutz-Einwilligung zuletzt gedruckt wurde oder NULL';


--
-- Name: COLUMN privacy_protection_consent.last_consent_employee_no; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.privacy_protection_consent.last_consent_employee_no IS 'Mitarbeiter, der die letzte Einwilligung gedruckt hat oder NULL';


--
-- Name: COLUMN privacy_protection_consent.internal_id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.privacy_protection_consent.internal_id IS 'Loco-Soft interne Vorgangsnummer';


--
-- Name: privacy_scopes; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.privacy_scopes (
    scope_code character varying(1) NOT NULL,
    description character varying(200)
);


ALTER TABLE public.privacy_scopes OWNER TO postgres;

--
-- Name: TABLE privacy_scopes; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.privacy_scopes IS 'Gültigkeitsbereiche für den Datenschutz. Z.B. Händler, Hersteller allgemein oder bestimmte Marken.';


--
-- Name: COLUMN privacy_scopes.scope_code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.privacy_scopes.scope_code IS 'Codierung für den Gültigkeitsbereich (z.B. für Händler oder einen bestimmen Hersteller/Importeur)';


--
-- Name: COLUMN privacy_scopes.description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.privacy_scopes.description IS 'Beschreibung der Gültigkeitsgruppe';


--
-- Name: salutations; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.salutations (
    code character varying(2) NOT NULL,
    main_salutation character varying(20),
    title character varying(86),
    salutation_in_forms character varying(86),
    receiver_salutation character varying(86),
    full_salutation character varying(86),
    multiline_line_1 character varying(86),
    multiline_line_2 character varying(86)
);


ALTER TABLE public.salutations OWNER TO postgres;

--
-- Name: TABLE salutations; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.salutations IS 'Liste der Anreden (Zuweisung von Anredeschlüssel zu Anreden in Formularen oder Briefen)';


--
-- Name: COLUMN salutations.code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.salutations.code IS 'Anredeschlüssel';


--
-- Name: COLUMN salutations.main_salutation; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.salutations.main_salutation IS 'Haupt Anredeschlüssel - siehe Programm 962 "Anredeschlüssel", z.B. Herr/Frau/Fräulein/Firma/An';


--
-- Name: COLUMN salutations.title; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.salutations.title IS 'Titel, z.B Doktor. ACHTUNG: Der Titel ist je Kunde individuell hinterlegt';


--
-- Name: COLUMN salutations.salutation_in_forms; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.salutations.salutation_in_forms IS 'Anrede in Formularen, z.B. Herr Doktor';


--
-- Name: COLUMN salutations.receiver_salutation; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.salutations.receiver_salutation IS 'Anrede im Adressfeld, z.B. Herrn Doktor';


--
-- Name: COLUMN salutations.full_salutation; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.salutations.full_salutation IS 'Anpsrache im Brief, z.b. Sehr geehrter Herr Doktor #nachname#';


--
-- Name: COLUMN salutations.multiline_line_1; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.salutations.multiline_line_1 IS 'Mehrzeilige Adresse (Anrede-Zeile)';


--
-- Name: COLUMN salutations.multiline_line_2; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.salutations.multiline_line_2 IS 'Mehrzeilige Adresse (Namens-Zeile)';


--
-- Name: subsidiaries; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.subsidiaries (
    subsidiary integer NOT NULL,
    description character varying(42),
    subsidiary_to_company_ref integer
);


ALTER TABLE public.subsidiaries OWNER TO postgres;

--
-- Name: TABLE subsidiaries; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.subsidiaries IS 'Liste der Betriebsstätten mit Kennzeichnung rechtlich getrennter Betriebe, bzw. zusammengehöriger Betriebe';


--
-- Name: COLUMN subsidiaries.subsidiary; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.subsidiaries.subsidiary IS 'laufende Betriebsnummer (1 bis n)';


--
-- Name: COLUMN subsidiaries.description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.subsidiaries.description IS 'Bezeichnung der Betriebsstätte laut Pr.911, Variable 1 (Händlerbezeichnung für Listenüberschrift)';


--
-- Name: COLUMN subsidiaries.subsidiary_to_company_ref; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.subsidiaries.subsidiary_to_company_ref IS 'Nummer des ersten Betriebes der Betriebsgruppe. Sollten alle Betriebe zusammengehören steht hier immer der Wert 1. Das Feld ist in manchen Tabellen der Finanzbuchhaltung ein Bestandteil des Keys';


--
-- Name: time_types; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.time_types (
    type integer NOT NULL,
    description character varying(50)
);


ALTER TABLE public.time_types OWNER TO postgres;

--
-- Name: TABLE time_types; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.time_types IS 'Kategorien der Stempelzeiten in Tabelle times';


--
-- Name: COLUMN time_types.type; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.time_types.type IS 'Kennzeichen für Stempelzeiten in Tabelle "times"';


--
-- Name: COLUMN time_types.description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.time_types.description IS 'Bezeichnung der Stempelzeit';


--
-- Name: times; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.times (
    employee_number integer NOT NULL,
    order_number integer NOT NULL,
    start_time timestamp without time zone NOT NULL,
    type integer,
    order_positions character varying(9) NOT NULL,
    end_time timestamp without time zone,
    duration_minutes integer,
    exact_duration_seconds integer
);


ALTER TABLE public.times OWNER TO postgres;

--
-- Name: TABLE times; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.times IS 'Gestempelte Arbeitszeiten und Kommt-/Geht-Zeiten';


--
-- Name: COLUMN times.employee_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.times.employee_number IS 'Mitarbeiter, zu dem diese Stempelzeit gehört';


--
-- Name: COLUMN times.order_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.times.order_number IS 'Optional: Auftragsnummer, auf die sich diese Stempelzeit bezieht, oder die Zahl Null (0), wenn es eine Kommt- oder Geht-Zeit ist';


--
-- Name: COLUMN times.start_time; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.times.start_time IS 'Startzeit für die Stempelzeit auf Aufträge oder die Arbeitsszeit';


--
-- Name: COLUMN times.type; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.times.type IS 'Kennzeichen 1 = gestmpelte Anwesenheitszeit, 2 = gestempelte Zeit auf Aufträge';


--
-- Name: COLUMN times.order_positions; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.times.order_positions IS 'Eine Zeichenkette die angibt, auf welche Auftrags-Positionen gestempelt wurde. Die Position der Zeichen "X" in der Zeichenkette gibt die Positions-Nummer im Auftrag an. Bei Kommt-/Geht-Zeiten ist dies';


--
-- Name: COLUMN times.end_time; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.times.end_time IS 'Endzeitpunkt der Auftrags-Stempelung oder Anwesenheit';


--
-- Name: COLUMN times.duration_minutes; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.times.duration_minutes IS 'Dauer in Minuten';


--
-- Name: COLUMN times.exact_duration_seconds; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.times.exact_duration_seconds IS 'Für genaue Auswertungen wird hier die gesamte Dauer in Sekunden angegeben.';


--
-- Name: transit_customers; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.transit_customers (
    order_number integer NOT NULL,
    order_position integer NOT NULL,
    order_position_line integer NOT NULL,
    first_name character varying(45),
    family_name character varying(45),
    salutation_code character varying(2),
    country character varying(3),
    zip_code character varying(20),
    home_city character varying(25),
    home_street character varying(27),
    phone_number character varying(15),
    fullname_vector tsvector GENERATED ALWAYS AS (to_tsvector('simple'::regconfig, (((first_name)::text || ' '::text) || (family_name)::text))) STORED
);


ALTER TABLE public.transit_customers OWNER TO postgres;

--
-- Name: TABLE transit_customers; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.transit_customers IS 'Namen und Adressdaten von Kunden zu Aufträgen, die nicht erneut erwartete werden und darum nicht als Kunde angelegt wurden.';


--
-- Name: COLUMN transit_customers.order_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.transit_customers.order_number IS 'Dummy-Hinterlegungen beziehen sich auf Aufträge';


--
-- Name: COLUMN transit_customers.order_position; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.transit_customers.order_position IS 'Position innerhalb des Auftrages, sofern die Dummy-Hinterlegung zu einem Barauftrag gehört (sonst zero)';


--
-- Name: COLUMN transit_customers.order_position_line; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.transit_customers.order_position_line IS 'Fortlaufende Zeilennummer innerhalb der Positionen, sofern die Dummy-Hinterlegung zu einem Barauftrag gehört (sonst zero)';


--
-- Name: COLUMN transit_customers.salutation_code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.transit_customers.salutation_code IS 'Anredecode aus Tabelle salutations. Werte 0, 1, 2, 3, 4, 5 oder weitere frei definierbare Werte sind möglich. Der Wert NULL ist auch möglich.';


--
-- Name: transit_vehicles; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.transit_vehicles (
    order_number integer NOT NULL,
    order_position integer NOT NULL,
    order_position_line integer NOT NULL,
    make_number integer,
    make_text character varying(10),
    model_code character varying(16),
    model_text character varying(18),
    color_text character varying(15),
    license_plate character varying(12),
    vin character varying(17),
    first_registration_date date,
    model_vector tsvector GENERATED ALWAYS AS (to_tsvector('simple'::regconfig, (model_text)::text)) STORED
);


ALTER TABLE public.transit_vehicles OWNER TO postgres;

--
-- Name: TABLE transit_vehicles; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.transit_vehicles IS 'Daten von Kundenfahrzeugen zu Aufträgen, die nicht erneut erwartete werden und darum nicht als Fahrzeug angelegt wurden';


--
-- Name: COLUMN transit_vehicles.order_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.transit_vehicles.order_number IS 'Dummy-Hinterlegungen beziehen sich auf Aufträge';


--
-- Name: COLUMN transit_vehicles.order_position; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.transit_vehicles.order_position IS 'Position innerhalb des Auftrages, sofern die Dummy-Hinterlegung zu einem Barauftrag gehört (sonst zero)';


--
-- Name: COLUMN transit_vehicles.order_position_line; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.transit_vehicles.order_position_line IS 'Fortlaufende Zeilennummer innerhalb der Positionen, sofern die Dummy-Hinterlegung zu einem Barauftrag gehört (sonst zero)';


--
-- Name: vat_keys; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.vat_keys (
    subsidiary_to_company_ref bigint NOT NULL,
    vat_key text NOT NULL,
    key_validity_date date,
    branch bigint,
    description text,
    vat_rate bigint,
    create_date date,
    vat_account bigint,
    advanced_turnover_tax_pos bigint
);


ALTER TABLE public.vat_keys OWNER TO postgres;

--
-- Name: TABLE vat_keys; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.vat_keys IS 'USt-Schlüssel und die entsprechenden USt-Sätze';


--
-- Name: COLUMN vat_keys.subsidiary_to_company_ref; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vat_keys.subsidiary_to_company_ref IS 'BetriebsGruppe:Zuordnung zu der "Betriebsgruppe" bei Buchhaltungssplitt - ansonsten immer 1';


--
-- Name: COLUMN vat_keys.vat_key; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vat_keys.vat_key IS 'UStSchluessel:Umsatzsteuerschlüssel innerhalb Loco-Soft';


--
-- Name: COLUMN vat_keys.key_validity_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vat_keys.key_validity_date IS 'GueltigAb:Ab diesem Datum ist der Schlüssel gültig';


--
-- Name: COLUMN vat_keys.branch; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vat_keys.branch IS 'Filiale:Der Steuerschlüssel gilt für Filiale/Betriebsstätte';


--
-- Name: COLUMN vat_keys.description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vat_keys.description IS 'Bezeichnung:Umschreibung des Steuerschlüssels';


--
-- Name: COLUMN vat_keys.vat_rate; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vat_keys.vat_rate IS 'UStSatz:Steuersatz des Steuerschlüssels';


--
-- Name: COLUMN vat_keys.create_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vat_keys.create_date IS 'AngelegtAm:Seit 12/2012: Anlegedatum des Steuerschlüssels';


--
-- Name: COLUMN vat_keys.vat_account; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vat_keys.vat_account IS 'UStKonto:Nummer des für diesen Steuerschlüssel bevorzugt zu verwendenden Sachkontos';


--
-- Name: COLUMN vat_keys.advanced_turnover_tax_pos; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vat_keys.advanced_turnover_tax_pos IS 'UStVAPos:Meldeposition der Umsätze mit diesem Steuerschlüssel innerhalb der USt-Meldung';


--
-- Name: vehicle_accessories_customer; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.vehicle_accessories_customer (
    vehicle_number integer NOT NULL,
    sequence bigint NOT NULL,
    code character varying(20),
    description character varying(40),
    package_reference character varying(10),
    optional boolean,
    price numeric(9,2),
    discountable boolean
);


ALTER TABLE public.vehicle_accessories_customer OWNER TO postgres;

--
-- Name: TABLE vehicle_accessories_customer; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.vehicle_accessories_customer IS 'Fahrzeug-Zubehöre und -Optionen für Kundenfahrzeuge';


--
-- Name: COLUMN vehicle_accessories_customer.vehicle_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicle_accessories_customer.vehicle_number IS 'Zuordnung zu interner Fahrzeugnummer von Kundenfahrzeugen/Fahrzeuggrunddaten';


--
-- Name: COLUMN vehicle_accessories_customer.sequence; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicle_accessories_customer.sequence IS 'Sequenzzähler für Reihenfolge der Zubehöre je Fahrzeug';


--
-- Name: COLUMN vehicle_accessories_customer.code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicle_accessories_customer.code IS 'Zubehör Code (Herstellercode aus Fahrzeugbestellung)';


--
-- Name: COLUMN vehicle_accessories_customer.description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicle_accessories_customer.description IS 'Beschreibung';


--
-- Name: COLUMN vehicle_accessories_customer.package_reference; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicle_accessories_customer.package_reference IS 'Paket-Code. Alle Zubehöre/Optionen eines Paketes haben den gleichen Paket-Code';


--
-- Name: COLUMN vehicle_accessories_customer.optional; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicle_accessories_customer.optional IS 'Ist, bzw. war optional/bestellbar (true) oder serienmäßig (false). Hinweis: Oft ist diese Information nicht hinterlegt und steht somit fälschlich auf optional';


--
-- Name: COLUMN vehicle_accessories_customer.price; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicle_accessories_customer.price IS 'Preis vor Steuern. Bei Kundenfahrzeugen ist das der damalige Preis.';


--
-- Name: COLUMN vehicle_accessories_customer.discountable; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicle_accessories_customer.discountable IS 'Ist/war Rabattierbar ja/nein';


--
-- Name: vehicle_accessories_dealer; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.vehicle_accessories_dealer (
    dealer_vehicle_type character varying(1) NOT NULL,
    dealer_vehicle_number integer NOT NULL,
    sequence bigint NOT NULL,
    code character varying(20),
    description character varying(40),
    package_reference character varying(10),
    optional boolean,
    price numeric(9,2),
    discountable boolean
);


ALTER TABLE public.vehicle_accessories_dealer OWNER TO postgres;

--
-- Name: TABLE vehicle_accessories_dealer; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.vehicle_accessories_dealer IS 'Fahrzeug-Zubehöre und -Optionen für Händlerfahrzeuge';


--
-- Name: COLUMN vehicle_accessories_dealer.dealer_vehicle_type; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicle_accessories_dealer.dealer_vehicle_type IS 'Zubehörer aller Händlerfahrzuege werden Kennnung und Kommissionsnummer im Key aufgeführt';


--
-- Name: COLUMN vehicle_accessories_dealer.dealer_vehicle_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicle_accessories_dealer.dealer_vehicle_number IS 'Zubehörer aller Händlerfahrzuege werden Kennnung und Kommissionsnummer im Key aufgeführt';


--
-- Name: COLUMN vehicle_accessories_dealer.sequence; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicle_accessories_dealer.sequence IS 'Sequenzzähler für Reihenfolge der Zubehöre je Fahrzeug';


--
-- Name: COLUMN vehicle_accessories_dealer.code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicle_accessories_dealer.code IS 'Zubehör Code (Herstellercode aus Fahrzeugbestellung)';


--
-- Name: COLUMN vehicle_accessories_dealer.description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicle_accessories_dealer.description IS 'Beschreibung';


--
-- Name: COLUMN vehicle_accessories_dealer.package_reference; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicle_accessories_dealer.package_reference IS 'Paket-Code. Alle Zubehöre/Optionen eines Paketes haben den gleichen Paket-Code';


--
-- Name: COLUMN vehicle_accessories_dealer.optional; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicle_accessories_dealer.optional IS 'Ist, bzw. war optional/bestellbar (true) oder serienmäßig (false). Hinweis: Oft ist diese Information nicht hinterlegt und steht somit fälschlich auf optional';


--
-- Name: COLUMN vehicle_accessories_dealer.price; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicle_accessories_dealer.price IS 'Preis vor Steuern. Bei Kundenfahrzeugen ist das der damalige Preis.';


--
-- Name: COLUMN vehicle_accessories_dealer.discountable; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicle_accessories_dealer.discountable IS 'Ist/war Rabattierbar ja/nein';


--
-- Name: vehicle_bodys; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.vehicle_bodys (
    code character varying(2) NOT NULL,
    description character varying(200),
    CONSTRAINT vehicle_bodys_code_check CHECK (((code)::text > ''::text))
);


ALTER TABLE public.vehicle_bodys OWNER TO postgres;

--
-- Name: TABLE vehicle_bodys; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.vehicle_bodys IS 'Fahrzeug-Aufbauten';


--
-- Name: COLUMN vehicle_bodys.code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicle_bodys.code IS 'Interne Codierung für Aufbauten (z.B. für SUV oder Kombi)';


--
-- Name: COLUMN vehicle_bodys.description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicle_bodys.description IS 'Aufbau als Text';


--
-- Name: vehicle_buy_types; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.vehicle_buy_types (
    code character varying(1) NOT NULL,
    description character varying(40)
);


ALTER TABLE public.vehicle_buy_types OWNER TO postgres;

--
-- Name: TABLE vehicle_buy_types; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.vehicle_buy_types IS 'Ankaufarten für gebrauchte Fahrzeuge';


--
-- Name: COLUMN vehicle_buy_types.code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicle_buy_types.code IS 'Ankaufsart: (B)etriebs-Fz, (F)reier Zukauf,(I)nzahlungnahme,(L)easing-Rückläufer,(M)iet-Rückläufer,(W)erksfahrzeug';


--
-- Name: COLUMN vehicle_buy_types.description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicle_buy_types.description IS 'Beschreibung der Gebrauchtwagen-Ankaufsart';


--
-- Name: vehicle_pre_owned_codes; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.vehicle_pre_owned_codes (
    code character varying(1) NOT NULL,
    description character varying(40)
);


ALTER TABLE public.vehicle_pre_owned_codes OWNER TO postgres;

--
-- Name: TABLE vehicle_pre_owned_codes; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.vehicle_pre_owned_codes IS 'Jahreswagen-Kennzeichen';


--
-- Name: COLUMN vehicle_pre_owned_codes.code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicle_pre_owned_codes.code IS 'Jahreswagen-Kennzeichen';


--
-- Name: COLUMN vehicle_pre_owned_codes.description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicle_pre_owned_codes.description IS 'Beschreibung des Jahreswagen-Kennzeichens';


--
-- Name: vehicle_sale_types; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.vehicle_sale_types (
    code character varying(1) NOT NULL,
    description character varying(40)
);


ALTER TABLE public.vehicle_sale_types OWNER TO postgres;

--
-- Name: TABLE vehicle_sale_types; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.vehicle_sale_types IS 'Verkaufsarten für Fahrzeuge';


--
-- Name: COLUMN vehicle_sale_types.code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicle_sale_types.code IS 'Fahrzeugart-Verkaufsarten: (B)ar, (F)inanzierung, (L)easing, (T)ausch, (U)nterhändler';


--
-- Name: COLUMN vehicle_sale_types.description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicle_sale_types.description IS 'Beschreibung der Fahrzeug-Verkaufsart';


--
-- Name: vehicle_types; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.vehicle_types (
    code character varying(1) NOT NULL,
    is_new_or_similar boolean,
    description character varying(40)
);


ALTER TABLE public.vehicle_types OWNER TO postgres;

--
-- Name: TABLE vehicle_types; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.vehicle_types IS 'Fahrzeugarten (Teil der Kommissionsnummer in Händlerfahrzeugen)';


--
-- Name: COLUMN vehicle_types.code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicle_types.code IS 'Fahrzeugart-Kennung: (N)eu, (V)orführ, (G)ebraucht, (D)ifferenzbesteuert oder (T)ageszulassung';


--
-- Name: COLUMN vehicle_types.is_new_or_similar; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicle_types.is_new_or_similar IS 'Fahrzeuge dieser Fahrzeugart sind Neufahrzeuge oder wie Neufahrzeuge zu behandeln';


--
-- Name: COLUMN vehicle_types.description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicle_types.description IS 'Beschreibung der Fahrzeugart';


--
-- Name: vehicles; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.vehicles (
    internal_number integer NOT NULL,
    vin character varying(17),
    license_plate character varying(12),
    license_plate_country character varying(3),
    license_plate_season character varying(6),
    make_number integer,
    free_form_make_text character varying(10),
    model_code character varying(25),
    free_form_model_text character varying(40),
    is_roadworthy boolean,
    is_customer_vehicle boolean,
    dealer_vehicle_type character varying(1),
    dealer_vehicle_number integer,
    first_registration_date date,
    readmission_date date,
    next_service_date date,
    next_service_km integer,
    next_service_miles integer,
    production_year numeric(4,0),
    owner_number integer,
    holder_number integer,
    previous_owner_number integer,
    previous_owner_counter integer,
    last_holder_change_date date,
    german_kba_hsn character varying(4),
    german_kba_tsn character varying(15),
    austria_nat_code character varying(15),
    is_prefer_km boolean,
    mileage_km integer,
    mileage_miles integer,
    odometer_reading_date date,
    engine_number character varying(20),
    gear_number character varying(20),
    unloaded_weight integer,
    gross_vehicle_weight integer,
    power_kw integer,
    cubic_capacity integer,
    is_all_accidents_repaired boolean,
    accidents_counter integer,
    has_tyre_pressure_sensor boolean,
    carkey_number character varying(15),
    internal_source_flag character varying(3),
    emission_code character varying(4),
    first_sold_country character varying(3),
    first_sold_dealer_code integer,
    body_paint_code character varying(20),
    body_paint_description character varying(40),
    is_body_paint_metallic boolean,
    interior_paint_code character varying(20),
    interior_paint_description character varying(40),
    trim_code character varying(20),
    trim_description character varying(40),
    fine_dust_label character varying(1),
    internal_assignment character varying(10),
    ricambi_free_input character varying(20),
    document_number character varying(10),
    salesman_number integer,
    sale_date date,
    next_emission_test_date date,
    next_general_inspection_date date,
    next_rust_inspection_date date,
    next_exceptional_inspection_da date,
    last_change_date date,
    last_change_employee_no integer,
    created_date date,
    created_employee_no integer,
    subsidiary integer,
    last_change_subsidiary integer,
    lock_by_workstation integer,
    lock_time timestamp without time zone,
    lock_trace character varying(100),
    lock_trigger character varying(100),
    lock_by_employee integer,
    lock_sourcecode character varying(100),
    free_form_model_text_vector tsvector GENERATED ALWAYS AS (to_tsvector('simple'::regconfig, (free_form_model_text)::text)) STORED,
    CONSTRAINT vehicles_check CHECK (((owner_number > 0) OR (holder_number > 0) OR (owner_number = '-1000000000'::integer)))
);


ALTER TABLE public.vehicles OWNER TO postgres;

--
-- Name: TABLE vehicles; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.vehicles IS 'Fahrzeuggrunddaten';


--
-- Name: COLUMN vehicles.internal_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.internal_number IS 'Interne Nummer des Fahrzeuges (1 bis n oder -1000000000)';


--
-- Name: COLUMN vehicles.vin; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.vin IS 'Fahrzeugidentifikationsnummer (Fahrgestellnummer)';


--
-- Name: COLUMN vehicles.license_plate; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.license_plate IS 'Polizeiliches Kennzeichen';


--
-- Name: COLUMN vehicles.license_plate_country; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.license_plate_country IS 'Ländercode für das Polizeiliche Kennzeichen';


--
-- Name: COLUMN vehicles.license_plate_season; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.license_plate_season IS 'Saisonanteil für das Polizeiliche Kennzeichen';


--
-- Name: COLUMN vehicles.make_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.make_number IS 'Interne Fabrikatsnummer';


--
-- Name: COLUMN vehicles.free_form_make_text; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.free_form_make_text IS 'Bei Fabrikatscodes für allgemeine oder unbekannte Fabrikate steht hier die Fabrikatsbezeichnung';


--
-- Name: COLUMN vehicles.model_code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.model_code IS 'Modellcode. Kann null sein oder die Kombination aus make_number und model_code verweist auf Tabelle models(make_number, model_code)';


--
-- Name: COLUMN vehicles.free_form_model_text; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.free_form_model_text IS 'Bei Modellcodes für allgemeine oder unbekannte Modelle steht hier die Modellbezeichnung';


--
-- Name: COLUMN vehicles.is_roadworthy; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.is_roadworthy IS 'Das Fahrzeug ist fahrbereit (true) oder nicht (false)';


--
-- Name: COLUMN vehicles.is_customer_vehicle; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.is_customer_vehicle IS 'Ist das Fahrzeug momentan ein Kundenfahrzeug (true) oder ein Händlerfahrzeug (false). ACHTUNG: Dieser Datensatz kann sowohl zu Kunden- als auch zu Händlerfahrzeugen gehören';


--
-- Name: COLUMN vehicles.dealer_vehicle_type; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.dealer_vehicle_type IS 'Wenn dieses Fz. im Händlerbestand ist oder war, dann steht hier der Typ, z.B. (N)eu, (V)orführ, (G)ebraucht, (D)ifferenzbesteuert oder (T)ageszulassung des LETZTEN Händlerfahrzeugs.';


--
-- Name: COLUMN vehicles.dealer_vehicle_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.dealer_vehicle_number IS 'Wenn dieses Fz. im Händlerbestand ist oder war, dann steht hier die Kommissionsnummer des Händlerfahrzeugs des LETZTEN Händlerfahrzeugs';


--
-- Name: COLUMN vehicles.first_registration_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.first_registration_date IS 'Erstzulassungsdatum';


--
-- Name: COLUMN vehicles.readmission_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.readmission_date IS 'Wiederzulassungsdatum';


--
-- Name: COLUMN vehicles.next_service_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.next_service_date IS 'Termin der nächsten Wartung ("INSP")';


--
-- Name: COLUMN vehicles.next_service_km; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.next_service_km IS 'Nächste Inspektion bei Km';


--
-- Name: COLUMN vehicles.next_service_miles; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.next_service_miles IS 'Nächste Inspektion bei Meile';


--
-- Name: COLUMN vehicles.production_year; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.production_year IS 'Baujahr in dem Format YHYY (9999), z.B. 2016';


--
-- Name: COLUMN vehicles.owner_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.owner_number IS 'Besitzer-Kundennummer des Fahrzeugs';


--
-- Name: COLUMN vehicles.holder_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.holder_number IS 'Halter-Kundennummer des Fahrzeugs';


--
-- Name: COLUMN vehicles.previous_owner_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.previous_owner_number IS 'Vorbesitzer-Kundennummer des Fahrzeugs';


--
-- Name: COLUMN vehicles.previous_owner_counter; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.previous_owner_counter IS 'Anzahl der Vorbesitzer';


--
-- Name: COLUMN vehicles.last_holder_change_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.last_holder_change_date IS 'Datum, an dem der Halter zuletzt gewechselt wurde';


--
-- Name: COLUMN vehicles.german_kba_hsn; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.german_kba_hsn IS 'Deutsche KBA-Nummer (Hersteller-Typ-Nummer)';


--
-- Name: COLUMN vehicles.german_kba_tsn; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.german_kba_tsn IS 'Deutsche KBA-Nummer (Typschlüssel-Nummer)';


--
-- Name: COLUMN vehicles.austria_nat_code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.austria_nat_code IS 'Österreichischer NationalCode';


--
-- Name: COLUMN vehicles.is_prefer_km; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.is_prefer_km IS 'Laufleistung und Inspektion ist in Kilometern (true) oder Meilen (false) angegeben';


--
-- Name: COLUMN vehicles.mileage_km; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.mileage_km IS 'Laufleistung in Kilometern';


--
-- Name: COLUMN vehicles.mileage_miles; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.mileage_miles IS 'Laufleistung in Meilen';


--
-- Name: COLUMN vehicles.odometer_reading_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.odometer_reading_date IS 'Datum, an dem der Kilometerzähler/Meilenzähler abgelesen wurde';


--
-- Name: COLUMN vehicles.engine_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.engine_number IS 'Motornummer';


--
-- Name: COLUMN vehicles.gear_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.gear_number IS 'Getriebenummer';


--
-- Name: COLUMN vehicles.unloaded_weight; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.unloaded_weight IS 'Leergewicht dieses Fahrzeugs';


--
-- Name: COLUMN vehicles.gross_vehicle_weight; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.gross_vehicle_weight IS 'Zulässiges Gesamtgewicht dieses Fahrzeugs';


--
-- Name: COLUMN vehicles.power_kw; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.power_kw IS 'Motorleistung in Kilowatt';


--
-- Name: COLUMN vehicles.cubic_capacity; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.cubic_capacity IS 'Hubraum in Kubikzentimetern';


--
-- Name: COLUMN vehicles.is_all_accidents_repaired; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.is_all_accidents_repaired IS 'Unfälle/Vorschäden wurden repariert (true) oder nicht (false). Wenn das Fahrzeug keine Schäden hatte = NULL';


--
-- Name: COLUMN vehicles.accidents_counter; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.accidents_counter IS 'Anzahl an Vorschäden/Unfällen';


--
-- Name: COLUMN vehicles.has_tyre_pressure_sensor; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.has_tyre_pressure_sensor IS 'Reifendruckkontrollsystem vorhanden (true)';


--
-- Name: COLUMN vehicles.carkey_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.carkey_number IS 'Zündschlüsselnummer';


--
-- Name: COLUMN vehicles.internal_source_flag; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.internal_source_flag IS 'Internes Herkunftskennzeichen, z.B. aus Fremdsystem';


--
-- Name: COLUMN vehicles.emission_code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.emission_code IS 'Emissionscode';


--
-- Name: COLUMN vehicles.first_sold_country; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.first_sold_country IS 'Land, in dem das Fahrzeug zuerst verkauft wurde (als Neufahrzeug)';


--
-- Name: COLUMN vehicles.first_sold_dealer_code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.first_sold_dealer_code IS 'Händlernummer des verkaufenden Händlers (als Neufahrzeug)';


--
-- Name: COLUMN vehicles.body_paint_code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.body_paint_code IS 'Farbcode für Außenfarbe';


--
-- Name: COLUMN vehicles.body_paint_description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.body_paint_description IS 'Bezeichnung der Außenfarbe';


--
-- Name: COLUMN vehicles.is_body_paint_metallic; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.is_body_paint_metallic IS 'Außenlackierung ist metallic (true) oder nicht (false)';


--
-- Name: COLUMN vehicles.interior_paint_code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.interior_paint_code IS 'Farbcode für Innenfarbe';


--
-- Name: COLUMN vehicles.interior_paint_description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.interior_paint_description IS 'Bezeichnung der Innenfarbe';


--
-- Name: COLUMN vehicles.trim_code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.trim_code IS 'Code für die Innenausstattung, bzw. die Polster';


--
-- Name: COLUMN vehicles.trim_description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.trim_description IS 'Bezeichnung der Innenaustattung, bzw. der Polster';


--
-- Name: COLUMN vehicles.fine_dust_label; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.fine_dust_label IS 'Deutsche Feinstaubplakette. "0" = keine, "2" = rot, "3" = gelb, "4" = grün';


--
-- Name: COLUMN vehicles.internal_assignment; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.internal_assignment IS 'Frei verwendbare interne Zuordnung (Interne Schlüsselung)';


--
-- Name: COLUMN vehicles.ricambi_free_input; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.ricambi_free_input IS 'Ricambi Code oder freie Eingabe (falls für das Fabrikat verwendet)';


--
-- Name: COLUMN vehicles.document_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.document_number IS 'Fahrzeugbrief-Nummer';


--
-- Name: COLUMN vehicles.salesman_number; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.salesman_number IS 'Interne Verkäufernummer, falls das Fahrzeug für den Verkauf einem Mitarbeiter zugeordnet wurde, bzw. falls das Kundenfahrzeug vorher ein Händlerfahrzeug war';


--
-- Name: COLUMN vehicles.sale_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.sale_date IS 'Datum, des Kaufvertrages';


--
-- Name: COLUMN vehicles.next_emission_test_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.next_emission_test_date IS 'Termin der nächsten Abgasuntersuchung ("A.U.")';


--
-- Name: COLUMN vehicles.next_general_inspection_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.next_general_inspection_date IS 'Termin der nächsten Hauptuntersuchung ("H.U.")';


--
-- Name: COLUMN vehicles.next_rust_inspection_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.next_rust_inspection_date IS 'Termin der nächsten Rostuntersuchung (wird von dem Händler nicht verwendet)';


--
-- Name: COLUMN vehicles.next_exceptional_inspection_da; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.next_exceptional_inspection_da IS 'Termin der nächsten Sonderuntersuchung (wird von dem Händler nicht verwendet)';


--
-- Name: COLUMN vehicles.last_change_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.last_change_date IS 'Datum, an dem dieser Datensatz zuletzt geändert wurde';


--
-- Name: COLUMN vehicles.last_change_employee_no; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.last_change_employee_no IS 'Nummer des Mitarbeiters, der diesen Datensatz zuletzt geändert hat';


--
-- Name: COLUMN vehicles.created_date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.created_date IS 'Datum, an dem dieser Datensatz zuerst erstellt wurde';


--
-- Name: COLUMN vehicles.created_employee_no; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.created_employee_no IS 'Nummer des Mitarbeiters, der diesen Datensatz zuerst erstellt hat';


--
-- Name: COLUMN vehicles.subsidiary; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.subsidiary IS 'Betreuende Betriebsstätte';


--
-- Name: COLUMN vehicles.last_change_subsidiary; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.last_change_subsidiary IS 'Betriebsstätte, in der dieser Datensatz zuletzt geändert wurde';


--
-- Name: COLUMN vehicles.lock_by_workstation; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.lock_by_workstation IS 'Protokollierung von Datensatz-Sperren: Arbeitsplatznummer, der die Sperre erzeugt hat oder NULL.';


--
-- Name: COLUMN vehicles.lock_time; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.lock_time IS 'Protokollierung von Datensatz-Sperren: Zeitstempel, an dem der Datensatz mit Sperre zuletzt geändert wurde oder NULL.';


--
-- Name: COLUMN vehicles.lock_trace; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.lock_trace IS 'Protokollierung von Datensatz-Sperren: Reihenfolge der aufgerufenen Programme bei letztem Update des Datesatzes oder NULL.';


--
-- Name: COLUMN vehicles.lock_trigger; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.lock_trigger IS 'Protokollierung von Datensatz-Sperren: Dienstname oder UI-Information oder NULL.';


--
-- Name: COLUMN vehicles.lock_by_employee; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.lock_by_employee IS 'Protokollierung von Datensatz-Sperren: Interne Mitarbeiter-Nr. oder NULL.';


--
-- Name: COLUMN vehicles.lock_sourcecode; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.vehicles.lock_sourcecode IS 'Protokollierung von Datensatz-Sperren: Programmstelle oder NULL.';


--
-- Name: view_invoices; Type: VIEW; Schema: public; Owner: postgres
--

CREATE VIEW public.view_invoices AS
 SELECT i.invoice_date,
    i.subsidiary,
    date_part('day'::text, i.invoice_date) AS day,
    date_part('month'::text, i.invoice_date) AS month,
    date_part('year'::text, i.invoice_date) AS year,
    date_part('week'::text, i.invoice_date) AS week,
    sum(i.job_amount_net) AS labour_amount,
    sum(i.job_rebate) AS labour_rebate_amount,
    sum(i.part_amount_net) AS part_amount,
    sum(i.part_rebate) AS part_rebate_amount,
    count(*) AS invoice_count,
    sum(i.total_net) AS overall,
    v.make_number
   FROM ((public.invoices i
     JOIN public.orders o ON ((o.number = i.order_number)))
     LEFT JOIN public.vehicles v ON ((v.internal_number = o.vehicle_number)))
  WHERE ((i.invoice_type < 7) AND (i.invoice_type <> 5) AND (i.cancelation_date IS NULL))
  GROUP BY i.invoice_date, i.subsidiary, v.make_number;


ALTER TABLE public.view_invoices OWNER TO postgres;

--
-- Name: view_labours_goodwill; Type: VIEW; Schema: public; Owner: postgres
--

CREATE VIEW public.view_labours_goodwill AS
 SELECT i.invoice_date,
    i.subsidiary,
    date_part('day'::text, i.invoice_date) AS day,
    date_part('month'::text, i.invoice_date) AS month,
    date_part('year'::text, i.invoice_date) AS year,
    date_part('week'::text, i.invoice_date) AS week,
    l.charge_type AS type,
    round(((sum(l.net_price_in_order) * ((100)::numeric - l.goodwill_percent)) / (100)::numeric), 2) AS overall,
    v.make_number
   FROM (((public.labours l
     JOIN public.invoices i ON (((i.invoice_number = l.invoice_number) AND (i.invoice_type = l.invoice_type))))
     JOIN public.orders o ON ((o.number = i.order_number)))
     LEFT JOIN public.vehicles v ON ((v.internal_number = o.vehicle_number)))
  WHERE ((l.invoice_type < 7) AND (l.invoice_type <> 5) AND (i.cancelation_date IS NULL) AND (((l.labour_type)::text = 'K'::text) OR ((l.labour_type)::text = 'k'::text) OR ((l.labour_type)::text = 'Ik'::text) OR ((l.labour_type)::text = 'S'::text) OR ((l.labour_type)::text = 's'::text) OR ((l.labour_type)::text = 'Is'::text)))
  GROUP BY i.invoice_date, l.goodwill_percent, l.charge_type, i.subsidiary, v.make_number
  ORDER BY i.invoice_date;


ALTER TABLE public.view_labours_goodwill OWNER TO postgres;

--
-- Name: view_labours_rebate; Type: VIEW; Schema: public; Owner: postgres
--

CREATE VIEW public.view_labours_rebate AS
 SELECT i.invoice_date,
    i.subsidiary,
    date_part('day'::text, i.invoice_date) AS day,
    date_part('month'::text, i.invoice_date) AS month,
    date_part('year'::text, i.invoice_date) AS year,
    date_part('week'::text, i.invoice_date) AS week,
    l.charge_type AS type,
        CASE
            WHEN (l.rebate_percent > (0)::numeric) THEN round((((sum(l.net_price_in_order) * (100)::numeric) / ((100)::numeric - l.rebate_percent)) - sum(l.net_price_in_order)), 2)
            ELSE 0.00
        END AS overall,
    v.make_number
   FROM (((public.labours l
     JOIN public.invoices i ON (((i.invoice_number = l.invoice_number) AND (i.invoice_type = l.invoice_type))))
     JOIN public.orders o ON ((o.number = i.order_number)))
     LEFT JOIN public.vehicles v ON ((v.internal_number = o.vehicle_number)))
  WHERE ((l.invoice_type < 7) AND (l.invoice_type <> 5) AND (i.cancelation_date IS NULL))
  GROUP BY i.invoice_date, l.rebate_percent, l.charge_type, i.subsidiary, v.make_number
  ORDER BY i.invoice_date;


ALTER TABLE public.view_labours_rebate OWNER TO postgres;

--
-- Name: view_labours_usagevalue; Type: VIEW; Schema: public; Owner: postgres
--

CREATE VIEW public.view_labours_usagevalue AS
 SELECT i.invoice_date,
    i.subsidiary,
    date_part('day'::text, i.invoice_date) AS day,
    date_part('month'::text, i.invoice_date) AS month,
    date_part('year'::text, i.invoice_date) AS year,
    date_part('week'::text, i.invoice_date) AS week,
    l.charge_type AS type,
        CASE
            WHEN (sum(l.usage_value) IS NOT NULL) THEN sum(l.usage_value)
            ELSE 0.00
        END AS overall,
    v.make_number
   FROM (((public.labours l
     JOIN public.invoices i ON (((i.invoice_number = l.invoice_number) AND (i.invoice_type = l.invoice_type))))
     JOIN public.orders o ON ((o.number = i.order_number)))
     LEFT JOIN public.vehicles v ON ((v.internal_number = o.vehicle_number)))
  WHERE ((l.invoice_type < 7) AND (l.invoice_type <> 5) AND (i.cancelation_date IS NULL))
  GROUP BY i.invoice_date, l.charge_type, i.subsidiary, v.make_number
  ORDER BY i.invoice_date;


ALTER TABLE public.view_labours_usagevalue OWNER TO postgres;

--
-- Name: view_parts_goodwill; Type: VIEW; Schema: public; Owner: postgres
--

CREATE VIEW public.view_parts_goodwill AS
 SELECT i.invoice_date,
    i.subsidiary,
    date_part('day'::text, i.invoice_date) AS day,
    date_part('month'::text, i.invoice_date) AS month,
    date_part('year'::text, i.invoice_date) AS year,
    date_part('week'::text, i.invoice_date) AS week,
    p.parts_type AS type,
    round(((sum(p.sum) * ((100)::numeric - p.goodwill_percent)) / (100)::numeric), 2) AS overall,
    v.make_number
   FROM ((((public.parts p
     JOIN public.invoices i ON (((i.invoice_number = p.invoice_number) AND (i.invoice_type = p.invoice_type))))
     JOIN public.labours l ON (((p.order_number = l.order_number) AND (p.order_position = l.order_position))))
     JOIN public.orders o ON ((o.number = i.order_number)))
     LEFT JOIN public.vehicles v ON ((v.internal_number = o.vehicle_number)))
  WHERE ((p.invoice_type < 7) AND (p.invoice_type <> 5) AND (i.cancelation_date IS NULL) AND (((l.labour_type)::text = 'K'::text) OR ((l.labour_type)::text = 'k'::text) OR ((l.labour_type)::text = 'Ik'::text) OR ((l.labour_type)::text = 'S'::text) OR ((l.labour_type)::text = 's'::text) OR ((l.labour_type)::text = 'Is'::text)))
  GROUP BY i.invoice_date, p.goodwill_percent, p.parts_type, i.subsidiary, v.make_number
  ORDER BY i.invoice_date;


ALTER TABLE public.view_parts_goodwill OWNER TO postgres;

--
-- Name: view_parts_rebate; Type: VIEW; Schema: public; Owner: postgres
--

CREATE VIEW public.view_parts_rebate AS
 SELECT i.invoice_date,
    i.subsidiary,
    date_part('day'::text, i.invoice_date) AS day,
    date_part('month'::text, i.invoice_date) AS month,
    date_part('year'::text, i.invoice_date) AS year,
    date_part('week'::text, i.invoice_date) AS week,
    p.parts_type AS type,
        CASE
            WHEN (p.rebate_percent > (0)::numeric) THEN round((((sum(p.sum) * (100)::numeric) / ((100)::numeric - p.rebate_percent)) - sum(p.sum)), 2)
            ELSE 0.00
        END AS overall,
    v.make_number
   FROM (((public.parts p
     JOIN public.invoices i ON (((i.invoice_number = p.invoice_number) AND (i.invoice_type = p.invoice_type))))
     JOIN public.orders o ON ((o.number = i.order_number)))
     LEFT JOIN public.vehicles v ON ((v.internal_number = o.vehicle_number)))
  WHERE ((p.invoice_type < 7) AND (p.invoice_type <> 5) AND (i.cancelation_date IS NULL))
  GROUP BY i.invoice_date, p.rebate_percent, p.parts_type, i.subsidiary, v.make_number
  ORDER BY i.invoice_date;


ALTER TABLE public.view_parts_rebate OWNER TO postgres;

--
-- Name: view_parts_usagevalue; Type: VIEW; Schema: public; Owner: postgres
--

CREATE VIEW public.view_parts_usagevalue AS
 SELECT i.invoice_date,
    i.subsidiary,
    date_part('day'::text, i.invoice_date) AS day,
    date_part('month'::text, i.invoice_date) AS month,
    date_part('year'::text, i.invoice_date) AS year,
    date_part('week'::text, i.invoice_date) AS week,
    p.parts_type AS type,
        CASE
            WHEN (sum(p.usage_value) IS NOT NULL) THEN sum(p.usage_value)
            ELSE 0.00
        END AS overall,
    v.make_number
   FROM (((public.parts p
     JOIN public.invoices i ON (((i.invoice_number = p.invoice_number) AND (i.invoice_type = p.invoice_type))))
     JOIN public.orders o ON ((o.number = i.order_number)))
     LEFT JOIN public.vehicles v ON ((v.internal_number = o.vehicle_number)))
  WHERE ((p.invoice_type < 7) AND (p.invoice_type <> 5) AND (i.cancelation_date IS NULL))
  GROUP BY i.invoice_date, p.parts_type, i.subsidiary, v.make_number
  ORDER BY i.invoice_date;


ALTER TABLE public.view_parts_usagevalue OWNER TO postgres;

--
-- Name: wtp_pickup_bring_type; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.wtp_pickup_bring_type (
    type integer NOT NULL,
    description character varying(100)
);


ALTER TABLE public.wtp_pickup_bring_type OWNER TO postgres;

--
-- Name: TABLE wtp_pickup_bring_type; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.wtp_pickup_bring_type IS 'WTP-Termin: Persönlich oder Hol-/Bring-Service';


--
-- Name: COLUMN wtp_pickup_bring_type.type; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.wtp_pickup_bring_type.type IS 'Kennzeichen für Kontaktart zum Kunden für Termine';


--
-- Name: COLUMN wtp_pickup_bring_type.description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.wtp_pickup_bring_type.description IS 'Beschreibung der Kontaktart zum Kunden (persönlich/Hol-/Bring-Service)';


--
-- Name: wtp_progress_status; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.wtp_progress_status (
    code integer NOT NULL,
    description character varying(50)
);


ALTER TABLE public.wtp_progress_status OWNER TO postgres;

--
-- Name: TABLE wtp_progress_status; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.wtp_progress_status IS 'Stempelstatus / Bearbeitungsstatus';


--
-- Name: COLUMN wtp_progress_status.code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.wtp_progress_status.code IS 'Code für den Stempel-Status';


--
-- Name: COLUMN wtp_progress_status.description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.wtp_progress_status.description IS 'Beschreibung des Stempel-Status';


--
-- Name: wtp_urgency; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.wtp_urgency (
    code integer NOT NULL,
    description character varying(50)
);


ALTER TABLE public.wtp_urgency OWNER TO postgres;

--
-- Name: TABLE wtp_urgency; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.wtp_urgency IS 'Dringlichkeitscodierung für Werkstatt-Termine';


--
-- Name: COLUMN wtp_urgency.code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.wtp_urgency.code IS 'Code für die Termin-Dringlichkeit';


--
-- Name: COLUMN wtp_urgency.description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.wtp_urgency.description IS 'Beschreibung der Dringlichkeit';


--
-- Name: wtp_vehicle_status; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.wtp_vehicle_status (
    code integer NOT NULL,
    description character varying(50)
);


ALTER TABLE public.wtp_vehicle_status OWNER TO postgres;

--
-- Name: TABLE wtp_vehicle_status; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.wtp_vehicle_status IS 'Fahrzeug-Status (Anwesenheit, Bearbeitungsstatus)';


--
-- Name: COLUMN wtp_vehicle_status.code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.wtp_vehicle_status.code IS 'Code für den Fahrzeug-Status';


--
-- Name: COLUMN wtp_vehicle_status.description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.wtp_vehicle_status.description IS 'Beschreibung des Fahrzeug-Status';


--
-- Name: year_calendar; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.year_calendar (
    calendar_id integer NOT NULL,
    date date NOT NULL,
    day_off_declaration integer,
    is_school_holid boolean,
    is_public_holid boolean,
    day_note character varying(20)
);


ALTER TABLE public.year_calendar OWNER TO postgres;

--
-- Name: TABLE year_calendar; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.year_calendar IS 'Jahreskalender der Betriebsstätten';


--
-- Name: COLUMN year_calendar.calendar_id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.year_calendar.calendar_id IS 'ID des Jahreskalenders laut Mapping in Tabelle year_calendar_subsidiary_mapping von Betriebsstätte (subsidiary) auf Kalender-ID (calendar_id)';


--
-- Name: COLUMN year_calendar.date; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.year_calendar.date IS 'Datum des Eintrages in dem Jahreskalender';


--
-- Name: COLUMN year_calendar.day_off_declaration; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.year_calendar.day_off_declaration IS 'Einteilung des Kalendereintrages in arbeitsfreie Tage (1 bis 9) oder Arbeitstage (-1), sofern der Tag kein Feiertag ist.';


--
-- Name: COLUMN year_calendar.is_school_holid; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.year_calendar.is_school_holid IS 'Diese Tag liegt in den Schulferien des Bundeslandes der Betriebsstätte';


--
-- Name: COLUMN year_calendar.is_public_holid; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.year_calendar.is_public_holid IS 'Dieser Tag ist ein offizieller Feiertag. Feiertage sindfür die meisten Mitarbeiter immer frei, auch ohne day_off_declaration belegt ist.';


--
-- Name: COLUMN year_calendar.day_note; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.year_calendar.day_note IS 'Tagesnotiz';


--
-- Name: year_calendar_day_off_codes; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.year_calendar_day_off_codes (
    code integer NOT NULL,
    description character varying(50)
);


ALTER TABLE public.year_calendar_day_off_codes OWNER TO postgres;

--
-- Name: TABLE year_calendar_day_off_codes; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.year_calendar_day_off_codes IS 'Kennzeichen für Einträge im Jahreskalender zur Unterscheidung von Arbeitstagen und arbeitsfreien Tagen';


--
-- Name: COLUMN year_calendar_day_off_codes.code; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.year_calendar_day_off_codes.code IS 'Codierung für arbeitsfreie Kalender-Einträge (1 bis 9), bzw. Arbeitstage (-1)';


--
-- Name: COLUMN year_calendar_day_off_codes.description; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.year_calendar_day_off_codes.description IS 'Beschreibung des Arbeitsfrei-Codes';


--
-- Name: year_calendar_subsidiary_mapping; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.year_calendar_subsidiary_mapping (
    subsidiary integer NOT NULL,
    year integer NOT NULL,
    calendar_id integer
);


ALTER TABLE public.year_calendar_subsidiary_mapping OWNER TO postgres;

--
-- Name: TABLE year_calendar_subsidiary_mapping; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public.year_calendar_subsidiary_mapping IS 'In Loco-Soft können mehrere Jahreskalender angelegt werden und jeweils einem oder mehreren Betrieben zugeordnet werden. Die Zuordnung von Kalender zu  Betrieb kann jedes Jahr anders sein.';


--
-- Name: COLUMN year_calendar_subsidiary_mapping.subsidiary; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.year_calendar_subsidiary_mapping.subsidiary IS 'Betriebsstätte (1 bis n)';


--
-- Name: COLUMN year_calendar_subsidiary_mapping.year; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.year_calendar_subsidiary_mapping.year IS 'Jahr, für den dieses Mapping gilt (z.B. 2016)';


--
-- Name: COLUMN year_calendar_subsidiary_mapping.calendar_id; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON COLUMN public.year_calendar_subsidiary_mapping.calendar_id IS 'Jahreskalender-ID (0 bis n)';


--
-- Name: financing_examples id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.financing_examples ALTER COLUMN id SET DEFAULT nextval('public.financing_examples_id_seq'::regclass);


--
-- Name: leasing_examples id; Type: DEFAULT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.leasing_examples ALTER COLUMN id SET DEFAULT nextval('public.leasing_examples_id_seq'::regclass);


--
-- Name: absence_calendar absence_calendar_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.absence_calendar
    ADD CONSTRAINT absence_calendar_pkey PRIMARY KEY (employee_number, date, unique_dummy);


--
-- Name: absence_reasons absence_reasons_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.absence_reasons
    ADD CONSTRAINT absence_reasons_pkey PRIMARY KEY (id);


--
-- Name: absence_types absence_types_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.absence_types
    ADD CONSTRAINT absence_types_pkey PRIMARY KEY (type);


--
-- Name: accounts_characteristics accounts_characteristics_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.accounts_characteristics
    ADD CONSTRAINT accounts_characteristics_pkey PRIMARY KEY (subsidiary_to_company_ref, skr51_branch, skr51_make, skr51_cost_center, skr51_sales_channel, skr51_cost_unit);


--
-- Name: appointments appointments_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.appointments
    ADD CONSTRAINT appointments_pkey PRIMARY KEY (id);


--
-- Name: appointments_text appointments_text_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.appointments_text
    ADD CONSTRAINT appointments_text_pkey PRIMARY KEY (appointment_id);


--
-- Name: charge_type_descriptions charge_type_descriptions_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.charge_type_descriptions
    ADD CONSTRAINT charge_type_descriptions_pkey PRIMARY KEY (type);


--
-- Name: charge_types charge_types_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.charge_types
    ADD CONSTRAINT charge_types_pkey PRIMARY KEY (type, subsidiary);


--
-- Name: clearing_delay_types clearing_delay_types_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.clearing_delay_types
    ADD CONSTRAINT clearing_delay_types_pkey PRIMARY KEY (type);


--
-- Name: codes_customer_def codes_customer_def_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.codes_customer_def
    ADD CONSTRAINT codes_customer_def_pkey PRIMARY KEY (code);


--
-- Name: codes_customer_list codes_customer_list_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.codes_customer_list
    ADD CONSTRAINT codes_customer_list_pkey PRIMARY KEY (customer_number, code);


--
-- Name: codes_vehicle_date_def codes_vehicle_date_def_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.codes_vehicle_date_def
    ADD CONSTRAINT codes_vehicle_date_def_pkey PRIMARY KEY (code);


--
-- Name: codes_vehicle_date codes_vehicle_date_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.codes_vehicle_date
    ADD CONSTRAINT codes_vehicle_date_pkey PRIMARY KEY (vehicle_number, code);


--
-- Name: codes_vehicle_def codes_vehicle_def_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.codes_vehicle_def
    ADD CONSTRAINT codes_vehicle_def_pkey PRIMARY KEY (code);


--
-- Name: codes_vehicle_list codes_vehicle_list_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.codes_vehicle_list
    ADD CONSTRAINT codes_vehicle_list_pkey PRIMARY KEY (vehicle_number, code);


--
-- Name: codes_vehicle_mileage_def codes_vehicle_mileage_def_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.codes_vehicle_mileage_def
    ADD CONSTRAINT codes_vehicle_mileage_def_pkey PRIMARY KEY (code);


--
-- Name: codes_vehicle_mileage codes_vehicle_mileage_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.codes_vehicle_mileage
    ADD CONSTRAINT codes_vehicle_mileage_pkey PRIMARY KEY (vehicle_number, code);


--
-- Name: com_number_types com_number_types_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.com_number_types
    ADD CONSTRAINT com_number_types_pkey PRIMARY KEY (typ);


--
-- Name: configuration_numeric configuration_numeric_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.configuration_numeric
    ADD CONSTRAINT configuration_numeric_pkey PRIMARY KEY (parameter_number, subsidiary);


--
-- Name: configuration configuration_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.configuration
    ADD CONSTRAINT configuration_pkey PRIMARY KEY (type);


--
-- Name: countries countries_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.countries
    ADD CONSTRAINT countries_pkey PRIMARY KEY (code);


--
-- Name: customer_codes customer_codes_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.customer_codes
    ADD CONSTRAINT customer_codes_pkey PRIMARY KEY (code);


--
-- Name: customer_com_numbers customer_com_numbers_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.customer_com_numbers
    ADD CONSTRAINT customer_com_numbers_pkey PRIMARY KEY (customer_number, counter);


--
-- Name: customer_profession_codes customer_profession_codes_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.customer_profession_codes
    ADD CONSTRAINT customer_profession_codes_pkey PRIMARY KEY (code);


--
-- Name: customer_supplier_bank_information customer_supplier_bank_information_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.customer_supplier_bank_information
    ADD CONSTRAINT customer_supplier_bank_information_pkey PRIMARY KEY (customer_number);


--
-- Name: customer_to_customercodes customer_to_customercodes_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.customer_to_customercodes
    ADD CONSTRAINT customer_to_customercodes_pkey PRIMARY KEY (customer_number, customer_code);


--
-- Name: customer_to_professioncodes customer_to_professioncodes_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.customer_to_professioncodes
    ADD CONSTRAINT customer_to_professioncodes_pkey PRIMARY KEY (customer_number, profession_code);


--
-- Name: customers_suppliers customers_suppliers_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.customers_suppliers
    ADD CONSTRAINT customers_suppliers_pkey PRIMARY KEY (customer_number);


--
-- Name: dealer_vehicles dealer_vehicles_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.dealer_vehicles
    ADD CONSTRAINT dealer_vehicles_pkey PRIMARY KEY (dealer_vehicle_type, dealer_vehicle_number);


--
-- Name: document_types document_types_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.document_types
    ADD CONSTRAINT document_types_pkey PRIMARY KEY (document_type_in_journal);


--
-- Name: employees_breaktimes employees_breaktimes_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.employees_breaktimes
    ADD CONSTRAINT employees_breaktimes_pkey PRIMARY KEY (employee_number, validity_date, dayofweek, break_start);


--
-- Name: employees_history employees_history_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.employees_history
    ADD CONSTRAINT employees_history_pkey PRIMARY KEY (employee_number, validity_date);


--
-- Name: employees_worktimes employees_worktimes_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.employees_worktimes
    ADD CONSTRAINT employees_worktimes_pkey PRIMARY KEY (employee_number, validity_date, dayofweek);


--
-- Name: external_customer_references external_customer_references_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.external_customer_references
    ADD CONSTRAINT external_customer_references_pkey PRIMARY KEY (api_type, api_id, customer_number, subsidiary);


--
-- Name: external_reference_parties external_reference_parties_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.external_reference_parties
    ADD CONSTRAINT external_reference_parties_pkey PRIMARY KEY (api_type, api_id);


--
-- Name: financing_examples financing_examples_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.financing_examples
    ADD CONSTRAINT financing_examples_pkey PRIMARY KEY (id);


--
-- Name: financing_examples financing_examples_source_referenced_dealer_vehicle_type_re_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.financing_examples
    ADD CONSTRAINT financing_examples_source_referenced_dealer_vehicle_type_re_key UNIQUE (source, referenced_dealer_vehicle_type, referenced_dealer_vehicle_no);


--
-- Name: fuels fuels_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.fuels
    ADD CONSTRAINT fuels_pkey PRIMARY KEY (code);


--
-- Name: invoice_types invoice_types_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.invoice_types
    ADD CONSTRAINT invoice_types_pkey PRIMARY KEY (type);


--
-- Name: invoices invoices_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.invoices
    ADD CONSTRAINT invoices_pkey PRIMARY KEY (invoice_type, invoice_number);


--
-- Name: journal_accountings journal_accountings_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.journal_accountings
    ADD CONSTRAINT journal_accountings_pkey PRIMARY KEY (subsidiary_to_company_ref, accounting_date, document_type, document_number, position_in_document);


--
-- Name: labour_types labour_types_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.labour_types
    ADD CONSTRAINT labour_types_pkey PRIMARY KEY (code);


--
-- Name: labours_compressed labours_compressed_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.labours_compressed
    ADD CONSTRAINT labours_compressed_pkey PRIMARY KEY (order_number, order_position, order_position_line_start);


--
-- Name: labours_groups labours_groups_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.labours_groups
    ADD CONSTRAINT labours_groups_pkey PRIMARY KEY (source, labour_number_range);


--
-- Name: labours_master labours_master_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.labours_master
    ADD CONSTRAINT labours_master_pkey PRIMARY KEY (source, labour_number, mapping_code);


--
-- Name: labours labours_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.labours
    ADD CONSTRAINT labours_pkey PRIMARY KEY (order_number, order_position, order_position_line);


--
-- Name: leasing_examples leasing_examples_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.leasing_examples
    ADD CONSTRAINT leasing_examples_pkey PRIMARY KEY (id);


--
-- Name: leasing_examples leasing_examples_source_referenced_dealer_vehicle_type_refe_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.leasing_examples
    ADD CONSTRAINT leasing_examples_source_referenced_dealer_vehicle_type_refe_key UNIQUE (source, referenced_dealer_vehicle_type, referenced_dealer_vehicle_no);


--
-- Name: makes makes_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.makes
    ADD CONSTRAINT makes_pkey PRIMARY KEY (make_number);


--
-- Name: model_to_fuels model_to_fuels_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.model_to_fuels
    ADD CONSTRAINT model_to_fuels_pkey PRIMARY KEY (make_number, model_code, code);


--
-- Name: models models_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.models
    ADD CONSTRAINT models_pkey PRIMARY KEY (make_number, model_code);


--
-- Name: nominal_accounts nominal_accounts_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.nominal_accounts
    ADD CONSTRAINT nominal_accounts_pkey PRIMARY KEY (subsidiary_to_company_ref, nominal_account_number);


--
-- Name: orders orders_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.orders
    ADD CONSTRAINT orders_pkey PRIMARY KEY (number);


--
-- Name: part_types part_types_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.part_types
    ADD CONSTRAINT part_types_pkey PRIMARY KEY (type);


--
-- Name: parts_additional_descriptions parts_additional_descriptions_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.parts_additional_descriptions
    ADD CONSTRAINT parts_additional_descriptions_pkey PRIMARY KEY (part_number);


--
-- Name: parts_inbound_delivery_notes parts_inbound_delivery_notes_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.parts_inbound_delivery_notes
    ADD CONSTRAINT parts_inbound_delivery_notes_pkey PRIMARY KEY (supplier_number, year_key, number_main, number_sub, counter);


--
-- Name: parts_master parts_master_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.parts_master
    ADD CONSTRAINT parts_master_pkey PRIMARY KEY (part_number);


--
-- Name: parts parts_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.parts
    ADD CONSTRAINT parts_pkey PRIMARY KEY (order_number, order_position, order_position_line);


--
-- Name: parts_rebate_codes_buy parts_rebate_codes_buy_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.parts_rebate_codes_buy
    ADD CONSTRAINT parts_rebate_codes_buy_pkey PRIMARY KEY (rebate_group_code, rebate_code, rebate_code_counter);


--
-- Name: parts_rebate_codes_sell parts_rebate_codes_sell_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.parts_rebate_codes_sell
    ADD CONSTRAINT parts_rebate_codes_sell_pkey PRIMARY KEY (rebate_group_code, rebate_code, rebate_code_counter);


--
-- Name: parts_rebate_groups_buy parts_rebate_groups_buy_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.parts_rebate_groups_buy
    ADD CONSTRAINT parts_rebate_groups_buy_pkey PRIMARY KEY (code);


--
-- Name: parts_rebate_groups_sell parts_rebate_groups_sell_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.parts_rebate_groups_sell
    ADD CONSTRAINT parts_rebate_groups_sell_pkey PRIMARY KEY (code);


--
-- Name: parts_special_offer_prices parts_special_offer_prices_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.parts_special_offer_prices
    ADD CONSTRAINT parts_special_offer_prices_pkey PRIMARY KEY (part_number);


--
-- Name: parts_special_prices parts_special_prices_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.parts_special_prices
    ADD CONSTRAINT parts_special_prices_pkey PRIMARY KEY (part_number, order_classification_flag);


--
-- Name: parts_stock parts_stock_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.parts_stock
    ADD CONSTRAINT parts_stock_pkey PRIMARY KEY (part_number, stock_no);


--
-- Name: parts_supplier_numbers parts_supplier_numbers_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.parts_supplier_numbers
    ADD CONSTRAINT parts_supplier_numbers_pkey PRIMARY KEY (part_number);


--
-- Name: parts_to_vehicles parts_to_vehicles_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.parts_to_vehicles
    ADD CONSTRAINT parts_to_vehicles_pkey PRIMARY KEY (part_number, unique_reference, unique_counter);


--
-- Name: privacy_channels privacy_channels_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.privacy_channels
    ADD CONSTRAINT privacy_channels_pkey PRIMARY KEY (channel_code);


--
-- Name: privacy_details privacy_details_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.privacy_details
    ADD CONSTRAINT privacy_details_pkey PRIMARY KEY (customer_number, subsidiary_to_company_ref, make_name, scope_code, channel_code);


--
-- Name: privacy_protection_consent privacy_protection_consent_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.privacy_protection_consent
    ADD CONSTRAINT privacy_protection_consent_pkey PRIMARY KEY (customer_number, subsidiary_to_company_ref, make_name);


--
-- Name: privacy_scopes privacy_scopes_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.privacy_scopes
    ADD CONSTRAINT privacy_scopes_pkey PRIMARY KEY (scope_code);


--
-- Name: salutations salutations_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.salutations
    ADD CONSTRAINT salutations_pkey PRIMARY KEY (code);


--
-- Name: subsidiaries subsidiaries_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.subsidiaries
    ADD CONSTRAINT subsidiaries_pkey PRIMARY KEY (subsidiary);


--
-- Name: time_types time_types_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.time_types
    ADD CONSTRAINT time_types_pkey PRIMARY KEY (type);


--
-- Name: times times_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.times
    ADD CONSTRAINT times_pkey PRIMARY KEY (employee_number, order_number, start_time, order_positions);


--
-- Name: transit_customers transit_customers_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.transit_customers
    ADD CONSTRAINT transit_customers_pkey PRIMARY KEY (order_number, order_position, order_position_line);


--
-- Name: transit_vehicles transit_vehicles_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.transit_vehicles
    ADD CONSTRAINT transit_vehicles_pkey PRIMARY KEY (order_number, order_position, order_position_line);


--
-- Name: vat_keys vat_keys_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.vat_keys
    ADD CONSTRAINT vat_keys_pkey PRIMARY KEY (subsidiary_to_company_ref, vat_key);


--
-- Name: vehicle_accessories_customer vehicle_accessories_customer_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.vehicle_accessories_customer
    ADD CONSTRAINT vehicle_accessories_customer_pkey PRIMARY KEY (vehicle_number, sequence);


--
-- Name: vehicle_accessories_dealer vehicle_accessories_dealer_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.vehicle_accessories_dealer
    ADD CONSTRAINT vehicle_accessories_dealer_pkey PRIMARY KEY (dealer_vehicle_type, dealer_vehicle_number, sequence);


--
-- Name: vehicle_bodys vehicle_bodys_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.vehicle_bodys
    ADD CONSTRAINT vehicle_bodys_pkey PRIMARY KEY (code);


--
-- Name: vehicle_buy_types vehicle_buy_types_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.vehicle_buy_types
    ADD CONSTRAINT vehicle_buy_types_pkey PRIMARY KEY (code);


--
-- Name: vehicle_pre_owned_codes vehicle_pre_owned_codes_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.vehicle_pre_owned_codes
    ADD CONSTRAINT vehicle_pre_owned_codes_pkey PRIMARY KEY (code);


--
-- Name: vehicle_sale_types vehicle_sale_types_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.vehicle_sale_types
    ADD CONSTRAINT vehicle_sale_types_pkey PRIMARY KEY (code);


--
-- Name: vehicle_types vehicle_types_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.vehicle_types
    ADD CONSTRAINT vehicle_types_pkey PRIMARY KEY (code);


--
-- Name: vehicles vehicles_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.vehicles
    ADD CONSTRAINT vehicles_pkey PRIMARY KEY (internal_number);


--
-- Name: wtp_pickup_bring_type wtp_pickup_bring_type_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.wtp_pickup_bring_type
    ADD CONSTRAINT wtp_pickup_bring_type_pkey PRIMARY KEY (type);


--
-- Name: wtp_progress_status wtp_progress_status_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.wtp_progress_status
    ADD CONSTRAINT wtp_progress_status_pkey PRIMARY KEY (code);


--
-- Name: wtp_urgency wtp_urgency_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.wtp_urgency
    ADD CONSTRAINT wtp_urgency_pkey PRIMARY KEY (code);


--
-- Name: wtp_vehicle_status wtp_vehicle_status_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.wtp_vehicle_status
    ADD CONSTRAINT wtp_vehicle_status_pkey PRIMARY KEY (code);


--
-- Name: year_calendar_day_off_codes year_calendar_day_off_codes_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.year_calendar_day_off_codes
    ADD CONSTRAINT year_calendar_day_off_codes_pkey PRIMARY KEY (code);


--
-- Name: year_calendar year_calendar_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.year_calendar
    ADD CONSTRAINT year_calendar_pkey PRIMARY KEY (calendar_id, date);


--
-- Name: year_calendar_subsidiary_mapping year_calendar_subsidiary_mapping_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.year_calendar_subsidiary_mapping
    ADD CONSTRAINT year_calendar_subsidiary_mapping_pkey PRIMARY KEY (subsidiary, year);


--
-- Name: appointments_bring_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX appointments_bring_idx ON public.appointments USING btree (bring_timestamp);


--
-- Name: appointments_created_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX appointments_created_idx ON public.appointments USING btree (created_timestamp);


--
-- Name: appointments_license_search_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX appointments_license_search_idx ON public.appointments USING btree (TRIM(BOTH FROM replace((pseudo_license_plate)::text, '-'::text, ' '::text)) COLLATE "C");


--
-- Name: appointments_pseudo_model_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX appointments_pseudo_model_idx ON public.appointments USING btree (lower((pseudo_model_text)::text));


--
-- Name: appointments_pseudo_model_vector_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX appointments_pseudo_model_vector_idx ON public.appointments USING btree (to_tsvector('simple'::regconfig, (pseudo_model_text)::text));


--
-- Name: appointments_pseudo_name_vector_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX appointments_pseudo_name_vector_idx ON public.appointments USING btree (to_tsvector('simple'::regconfig, (pseudo_customer_name)::text));


--
-- Name: appointments_return_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX appointments_return_idx ON public.appointments USING btree (return_timestamp);


--
-- Name: appointmentspseudo_name_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX appointmentspseudo_name_idx ON public.appointments USING btree (lower((pseudo_customer_name)::text));


--
-- Name: com_numbers_ref_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX com_numbers_ref_idx ON public.customer_com_numbers USING btree (is_reference);


--
-- Name: com_numbers_type_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX com_numbers_type_idx ON public.customer_com_numbers USING btree (com_type);


--
-- Name: customers_suppliers_cont_first_last_lower_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX customers_suppliers_cont_first_last_lower_idx ON public.customers_suppliers USING btree (lower((((contact_first_name)::text || ' '::text) || (contact_family_name)::text)));


--
-- Name: customers_suppliers_cont_first_lower_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX customers_suppliers_cont_first_lower_idx ON public.customers_suppliers USING btree (lower((contact_first_name)::text));


--
-- Name: customers_suppliers_cont_last_lower_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX customers_suppliers_cont_last_lower_idx ON public.customers_suppliers USING btree (lower((contact_family_name)::text));


--
-- Name: customers_suppliers_contact_family_name; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX customers_suppliers_contact_family_name ON public.customers_suppliers USING btree (contact_family_name);


--
-- Name: customers_suppliers_contact_first_name; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX customers_suppliers_contact_first_name ON public.customers_suppliers USING btree (contact_first_name);


--
-- Name: customers_suppliers_family_name; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX customers_suppliers_family_name ON public.customers_suppliers USING btree (family_name);


--
-- Name: customers_suppliers_first_name; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX customers_suppliers_first_name ON public.customers_suppliers USING btree (first_name);


--
-- Name: customers_suppliers_name_first_last_lower_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX customers_suppliers_name_first_last_lower_idx ON public.customers_suppliers USING btree (lower((((first_name)::text || ' '::text) || (family_name)::text)));


--
-- Name: customers_suppliers_name_first_lower_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX customers_suppliers_name_first_lower_idx ON public.customers_suppliers USING btree (lower((first_name)::text));


--
-- Name: customers_suppliers_name_first_post_lower_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX customers_suppliers_name_first_post_lower_idx ON public.customers_suppliers USING btree (lower((((first_name)::text || ' '::text) || (name_postfix)::text)));


--
-- Name: customers_suppliers_name_last_lower_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX customers_suppliers_name_last_lower_idx ON public.customers_suppliers USING btree (lower((family_name)::text));


--
-- Name: customers_suppliers_name_postfix_lower_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX customers_suppliers_name_postfix_lower_idx ON public.customers_suppliers USING btree (lower((name_postfix)::text));


--
-- Name: customers_suppliers_name_pre_post_lower_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX customers_suppliers_name_pre_post_lower_idx ON public.customers_suppliers USING btree (lower((((name_prefix)::text || ' '::text) || (name_postfix)::text)));


--
-- Name: customers_suppliers_name_prefix_lower_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX customers_suppliers_name_prefix_lower_idx ON public.customers_suppliers USING btree (lower((name_prefix)::text));


--
-- Name: customers_suppliers_vector_city_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX customers_suppliers_vector_city_idx ON public.customers_suppliers USING btree (to_tsvector('simple'::regconfig, (home_city)::text));


--
-- Name: customers_suppliers_vector_n1_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX customers_suppliers_vector_n1_idx ON public.customers_suppliers USING btree (to_tsvector('simple'::regconfig, (name_prefix)::text));


--
-- Name: customers_suppliers_vector_n2_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX customers_suppliers_vector_n2_idx ON public.customers_suppliers USING btree (to_tsvector('simple'::regconfig, (first_name)::text));


--
-- Name: customers_suppliers_vector_n3_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX customers_suppliers_vector_n3_idx ON public.customers_suppliers USING btree (to_tsvector('simple'::regconfig, (family_name)::text));


--
-- Name: customers_suppliers_vector_n4_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX customers_suppliers_vector_n4_idx ON public.customers_suppliers USING btree (to_tsvector('simple'::regconfig, (name_postfix)::text));


--
-- Name: customers_suppliers_vector_street_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX customers_suppliers_vector_street_idx ON public.customers_suppliers USING btree (to_tsvector('simple'::regconfig, (home_street)::text));


--
-- Name: customers_suppliers_zip_code; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX customers_suppliers_zip_code ON public.customers_suppliers USING btree (zip_code);


--
-- Name: customers_supplierscontact_vector_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX customers_supplierscontact_vector_idx ON public.customers_suppliers USING btree (to_tsvector('simple'::regconfig, (((contact_first_name)::text || ' '::text) || (contact_family_name)::text)));


--
-- Name: dealer_vehicles_out_license_search_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX dealer_vehicles_out_license_search_idx ON public.dealer_vehicles USING btree (TRIM(BOTH FROM replace((out_license_plate)::text, '-'::text, ' '::text)) COLLATE "C");


--
-- Name: labours_line_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX labours_line_idx ON public.labours USING btree (lower((text_line)::text));


--
-- Name: labours_line_vector_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX labours_line_vector_idx ON public.labours USING btree (to_tsvector('simple'::regconfig, (text_line)::text));


--
-- Name: make_desc_lower_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX make_desc_lower_idx ON public.makes USING btree (lower((description)::text));


--
-- Name: make_desc_vector_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX make_desc_vector_idx ON public.makes USING btree (to_tsvector('simple'::regconfig, (description)::text));


--
-- Name: model_desc_lower_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX model_desc_lower_idx ON public.models USING btree (lower((description)::text));


--
-- Name: parts_line_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX parts_line_idx ON public.parts USING btree (lower((text_line)::text));


--
-- Name: parts_line_vector_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX parts_line_vector_idx ON public.parts USING btree (to_tsvector('simple'::regconfig, (text_line)::text));


--
-- Name: parts_lower_derscription_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX parts_lower_derscription_idx ON public.parts_master USING btree (lower((description)::text));


--
-- Name: parts_lower_location2_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX parts_lower_location2_idx ON public.parts_stock USING btree (lower((storage_location_2)::text));


--
-- Name: parts_lower_location_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX parts_lower_location_idx ON public.parts_stock USING btree (lower((storage_location_1)::text));


--
-- Name: parts_search_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX parts_search_idx ON public.parts_master USING btree (search_description);


--
-- Name: parts_suppliers_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX parts_suppliers_idx ON public.parts_supplier_numbers USING btree (external_number);


--
-- Name: parts_vehicle_from_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX parts_vehicle_from_idx ON public.parts_to_vehicles USING btree (model_date_start);


--
-- Name: parts_vehicle_model_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX parts_vehicle_model_idx ON public.parts_to_vehicles USING btree (model_pattern);


--
-- Name: parts_vehicle_to_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX parts_vehicle_to_idx ON public.parts_to_vehicles USING btree (model_date_end);


--
-- Name: parts_vehicle_vin_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX parts_vehicle_vin_idx ON public.parts_to_vehicles USING btree (vin_pattern);


--
-- Name: transit_customers_license_search_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX transit_customers_license_search_idx ON public.transit_vehicles USING btree (TRIM(BOTH FROM replace((license_plate)::text, '-'::text, ' '::text)) COLLATE "C");


--
-- Name: transit_vehicle_model_low_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX transit_vehicle_model_low_idx ON public.transit_vehicles USING btree (lower((model_text)::text));


--
-- Name: vehicles_holder_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX vehicles_holder_idx ON public.vehicles USING btree (holder_number);


--
-- Name: vehicles_license_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX vehicles_license_idx ON public.vehicles USING btree (license_plate COLLATE "C");


--
-- Name: vehicles_license_search_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX vehicles_license_search_idx ON public.vehicles USING btree (TRIM(BOTH FROM replace((license_plate)::text, '-'::text, ' '::text)) COLLATE "C");


--
-- Name: vehicles_make_txt_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX vehicles_make_txt_idx ON public.vehicles USING btree (lower((free_form_make_text)::text));


--
-- Name: vehicles_mod_txt_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX vehicles_mod_txt_idx ON public.vehicles USING btree (lower((free_form_model_text)::text));


--
-- Name: vehicles_owner_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX vehicles_owner_idx ON public.vehicles USING btree (owner_number);


--
-- Name: vin_idx; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX vin_idx ON public.vehicles USING btree (vin);


--
-- Name: absence_calendar absence_calendar_reason_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.absence_calendar
    ADD CONSTRAINT absence_calendar_reason_fkey FOREIGN KEY (reason) REFERENCES public.absence_reasons(id) ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: absence_calendar absence_calendar_type_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.absence_calendar
    ADD CONSTRAINT absence_calendar_type_fkey FOREIGN KEY (type) REFERENCES public.absence_types(type) ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: appointments appointments_progress_status_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.appointments
    ADD CONSTRAINT appointments_progress_status_fkey FOREIGN KEY (progress_status) REFERENCES public.wtp_progress_status(code) ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: appointments appointments_pseudo_vehicle_make_number_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.appointments
    ADD CONSTRAINT appointments_pseudo_vehicle_make_number_fkey FOREIGN KEY (pseudo_vehicle_make_number) REFERENCES public.makes(make_number) ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: appointments appointments_urgency_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.appointments
    ADD CONSTRAINT appointments_urgency_fkey FOREIGN KEY (urgency) REFERENCES public.wtp_urgency(code) ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: appointments appointments_vehicle_status_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.appointments
    ADD CONSTRAINT appointments_vehicle_status_fkey FOREIGN KEY (vehicle_status) REFERENCES public.wtp_vehicle_status(code) ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: charge_types charge_types_type_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.charge_types
    ADD CONSTRAINT charge_types_type_fkey FOREIGN KEY (type) REFERENCES public.charge_type_descriptions(type) ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: codes_customer_list codes_customer_list_code_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.codes_customer_list
    ADD CONSTRAINT codes_customer_list_code_fkey FOREIGN KEY (code) REFERENCES public.codes_customer_def(code) ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: codes_vehicle_date codes_vehicle_date_code_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.codes_vehicle_date
    ADD CONSTRAINT codes_vehicle_date_code_fkey FOREIGN KEY (code) REFERENCES public.codes_vehicle_date_def(code) ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: codes_vehicle_list codes_vehicle_list_code_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.codes_vehicle_list
    ADD CONSTRAINT codes_vehicle_list_code_fkey FOREIGN KEY (code) REFERENCES public.codes_vehicle_def(code) ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: codes_vehicle_mileage codes_vehicle_mileage_code_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.codes_vehicle_mileage
    ADD CONSTRAINT codes_vehicle_mileage_code_fkey FOREIGN KEY (code) REFERENCES public.codes_vehicle_mileage_def(code) ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: customer_to_customercodes customer_to_customercodes_customer_code_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.customer_to_customercodes
    ADD CONSTRAINT customer_to_customercodes_customer_code_fkey FOREIGN KEY (customer_code) REFERENCES public.customer_codes(code) ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: customer_to_professioncodes customer_to_professioncodes_profession_code_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.customer_to_professioncodes
    ADD CONSTRAINT customer_to_professioncodes_profession_code_fkey FOREIGN KEY (profession_code) REFERENCES public.customer_profession_codes(code) ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: dealer_vehicles dealer_vehicles_in_used_vehicle_buy_type_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.dealer_vehicles
    ADD CONSTRAINT dealer_vehicles_in_used_vehicle_buy_type_fkey FOREIGN KEY (in_used_vehicle_buy_type) REFERENCES public.vehicle_buy_types(code) ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: dealer_vehicles dealer_vehicles_out_make_number_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.dealer_vehicles
    ADD CONSTRAINT dealer_vehicles_out_make_number_fkey FOREIGN KEY (out_make_number) REFERENCES public.makes(make_number) ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: dealer_vehicles dealer_vehicles_out_sale_type_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.dealer_vehicles
    ADD CONSTRAINT dealer_vehicles_out_sale_type_fkey FOREIGN KEY (out_sale_type) REFERENCES public.vehicle_sale_types(code) ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: dealer_vehicles dealer_vehicles_pre_owned_car_code_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.dealer_vehicles
    ADD CONSTRAINT dealer_vehicles_pre_owned_car_code_fkey FOREIGN KEY (pre_owned_car_code) REFERENCES public.vehicle_pre_owned_codes(code) ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: invoices invoices_credit_invoice_type_credit_invoice_number_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.invoices
    ADD CONSTRAINT invoices_credit_invoice_type_credit_invoice_number_fkey FOREIGN KEY (credit_invoice_type, credit_invoice_number) REFERENCES public.invoices(invoice_type, invoice_number);


--
-- Name: invoices invoices_invoice_type_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.invoices
    ADD CONSTRAINT invoices_invoice_type_fkey FOREIGN KEY (invoice_type) REFERENCES public.invoice_types(type) ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: journal_accountings journal_accountings_customer_contra_account_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.journal_accountings
    ADD CONSTRAINT journal_accountings_customer_contra_account_fkey FOREIGN KEY (customer_contra_account) REFERENCES public.customers_suppliers(customer_number) ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: journal_accountings journal_accountings_customer_number_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.journal_accountings
    ADD CONSTRAINT journal_accountings_customer_number_fkey FOREIGN KEY (customer_number) REFERENCES public.customers_suppliers(customer_number) ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: journal_accountings journal_accountings_document_type_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.journal_accountings
    ADD CONSTRAINT journal_accountings_document_type_fkey FOREIGN KEY (document_type) REFERENCES public.document_types(document_type_in_journal) ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: journal_accountings journal_accountings_subsidiary_to_company_ref_nominal_cont_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.journal_accountings
    ADD CONSTRAINT journal_accountings_subsidiary_to_company_ref_nominal_cont_fkey FOREIGN KEY (subsidiary_to_company_ref, nominal_contra_account) REFERENCES public.nominal_accounts(subsidiary_to_company_ref, nominal_account_number);


--
-- Name: labours labours_labour_type_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.labours
    ADD CONSTRAINT labours_labour_type_fkey FOREIGN KEY (labour_type) REFERENCES public.labour_types(code) ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: model_to_fuels model_to_fuels_code_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.model_to_fuels
    ADD CONSTRAINT model_to_fuels_code_fkey FOREIGN KEY (code) REFERENCES public.fuels(code) ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: model_to_fuels model_to_fuels_make_number_model_code_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.model_to_fuels
    ADD CONSTRAINT model_to_fuels_make_number_model_code_fkey FOREIGN KEY (make_number, model_code) REFERENCES public.models(make_number, model_code);


--
-- Name: models models_make_number_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.models
    ADD CONSTRAINT models_make_number_fkey FOREIGN KEY (make_number) REFERENCES public.makes(make_number) ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: models models_vehicle_body_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.models
    ADD CONSTRAINT models_vehicle_body_fkey FOREIGN KEY (vehicle_body) REFERENCES public.vehicle_bodys(code) ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: orders orders_clearing_delay_type_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.orders
    ADD CONSTRAINT orders_clearing_delay_type_fkey FOREIGN KEY (clearing_delay_type) REFERENCES public.clearing_delay_types(type) ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: parts_rebate_codes_buy parts_rebate_codes_buy_rebate_group_code_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.parts_rebate_codes_buy
    ADD CONSTRAINT parts_rebate_codes_buy_rebate_group_code_fkey FOREIGN KEY (rebate_group_code) REFERENCES public.parts_rebate_groups_buy(code) ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: parts_rebate_codes_sell parts_rebate_codes_sell_rebate_group_code_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.parts_rebate_codes_sell
    ADD CONSTRAINT parts_rebate_codes_sell_rebate_group_code_fkey FOREIGN KEY (rebate_group_code) REFERENCES public.parts_rebate_groups_sell(code) ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: privacy_details privacy_details_channel_code_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.privacy_details
    ADD CONSTRAINT privacy_details_channel_code_fkey FOREIGN KEY (channel_code) REFERENCES public.privacy_channels(channel_code);


--
-- Name: privacy_details privacy_details_scope_code_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.privacy_details
    ADD CONSTRAINT privacy_details_scope_code_fkey FOREIGN KEY (scope_code) REFERENCES public.privacy_scopes(scope_code);


--
-- Name: times times_type_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.times
    ADD CONSTRAINT times_type_fkey FOREIGN KEY (type) REFERENCES public.time_types(type) ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: transit_vehicles transit_vehicles_make_number_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.transit_vehicles
    ADD CONSTRAINT transit_vehicles_make_number_fkey FOREIGN KEY (make_number) REFERENCES public.makes(make_number) ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: vehicles vehicles_make_number_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.vehicles
    ADD CONSTRAINT vehicles_make_number_fkey FOREIGN KEY (make_number) REFERENCES public.makes(make_number) ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: year_calendar year_calendar_day_off_declaration_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.year_calendar
    ADD CONSTRAINT year_calendar_day_off_declaration_fkey FOREIGN KEY (day_off_declaration) REFERENCES public.year_calendar_day_off_codes(code) ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: SCHEMA public; Type: ACL; Schema: -; Owner: postgres
--

REVOKE USAGE ON SCHEMA public FROM PUBLIC;
GRANT ALL ON SCHEMA public TO PUBLIC;
GRANT USAGE ON SCHEMA public TO loco_auswertung_benutzer;


--
-- Name: TABLE absence_calendar; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.absence_calendar TO loco_auswertung_benutzer;


--
-- Name: TABLE absence_reasons; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.absence_reasons TO loco_auswertung_benutzer;


--
-- Name: TABLE absence_types; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.absence_types TO loco_auswertung_benutzer;


--
-- Name: TABLE accounts_characteristics; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.accounts_characteristics TO loco_auswertung_benutzer;


--
-- Name: TABLE appointments; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.appointments TO loco_auswertung_benutzer;


--
-- Name: TABLE appointments_text; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.appointments_text TO loco_auswertung_benutzer;


--
-- Name: TABLE charge_type_descriptions; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.charge_type_descriptions TO loco_auswertung_benutzer;


--
-- Name: TABLE charge_types; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.charge_types TO loco_auswertung_benutzer;


--
-- Name: TABLE clearing_delay_types; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.clearing_delay_types TO loco_auswertung_benutzer;


--
-- Name: TABLE codes_customer_def; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.codes_customer_def TO loco_auswertung_benutzer;


--
-- Name: TABLE codes_customer_list; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.codes_customer_list TO loco_auswertung_benutzer;


--
-- Name: TABLE codes_vehicle_date; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.codes_vehicle_date TO loco_auswertung_benutzer;


--
-- Name: TABLE codes_vehicle_date_def; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.codes_vehicle_date_def TO loco_auswertung_benutzer;


--
-- Name: TABLE codes_vehicle_def; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.codes_vehicle_def TO loco_auswertung_benutzer;


--
-- Name: TABLE codes_vehicle_list; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.codes_vehicle_list TO loco_auswertung_benutzer;


--
-- Name: TABLE codes_vehicle_mileage; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.codes_vehicle_mileage TO loco_auswertung_benutzer;


--
-- Name: TABLE codes_vehicle_mileage_def; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.codes_vehicle_mileage_def TO loco_auswertung_benutzer;


--
-- Name: TABLE com_number_types; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.com_number_types TO loco_auswertung_benutzer;


--
-- Name: TABLE configuration; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.configuration TO loco_auswertung_benutzer;


--
-- Name: TABLE configuration_numeric; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.configuration_numeric TO loco_auswertung_benutzer;


--
-- Name: TABLE countries; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.countries TO loco_auswertung_benutzer;


--
-- Name: TABLE customer_codes; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.customer_codes TO loco_auswertung_benutzer;


--
-- Name: TABLE customer_com_numbers; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.customer_com_numbers TO loco_auswertung_benutzer;


--
-- Name: TABLE customer_profession_codes; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.customer_profession_codes TO loco_auswertung_benutzer;


--
-- Name: TABLE customer_supplier_bank_information; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.customer_supplier_bank_information TO loco_auswertung_benutzer;


--
-- Name: TABLE customer_to_customercodes; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.customer_to_customercodes TO loco_auswertung_benutzer;


--
-- Name: TABLE customer_to_professioncodes; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.customer_to_professioncodes TO loco_auswertung_benutzer;


--
-- Name: TABLE customers_suppliers; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.customers_suppliers TO loco_auswertung_benutzer;


--
-- Name: TABLE dealer_vehicles; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.dealer_vehicles TO loco_auswertung_benutzer;


--
-- Name: TABLE document_types; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.document_types TO loco_auswertung_benutzer;


--
-- Name: TABLE employees_history; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.employees_history TO loco_auswertung_benutzer;


--
-- Name: TABLE employees; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.employees TO loco_auswertung_benutzer;


--
-- Name: TABLE employees_breaktimes; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.employees_breaktimes TO loco_auswertung_benutzer;


--
-- Name: TABLE employees_worktimes; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.employees_worktimes TO loco_auswertung_benutzer;


--
-- Name: TABLE external_customer_references; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.external_customer_references TO loco_auswertung_benutzer;


--
-- Name: TABLE external_reference_parties; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.external_reference_parties TO loco_auswertung_benutzer;


--
-- Name: TABLE financing_examples; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.financing_examples TO loco_auswertung_benutzer;


--
-- Name: SEQUENCE financing_examples_id_seq; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON SEQUENCE public.financing_examples_id_seq TO loco_auswertung_benutzer;


--
-- Name: TABLE fuels; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.fuels TO loco_auswertung_benutzer;


--
-- Name: TABLE invoice_types; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.invoice_types TO loco_auswertung_benutzer;


--
-- Name: TABLE invoices; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.invoices TO loco_auswertung_benutzer;


--
-- Name: TABLE journal_accountings; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.journal_accountings TO loco_auswertung_benutzer;


--
-- Name: TABLE labour_types; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.labour_types TO loco_auswertung_benutzer;


--
-- Name: TABLE labours; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.labours TO loco_auswertung_benutzer;


--
-- Name: TABLE labours_compressed; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.labours_compressed TO loco_auswertung_benutzer;


--
-- Name: TABLE labours_groups; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.labours_groups TO loco_auswertung_benutzer;


--
-- Name: TABLE labours_master; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.labours_master TO loco_auswertung_benutzer;


--
-- Name: TABLE leasing_examples; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.leasing_examples TO loco_auswertung_benutzer;


--
-- Name: SEQUENCE leasing_examples_id_seq; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON SEQUENCE public.leasing_examples_id_seq TO loco_auswertung_benutzer;


--
-- Name: TABLE makes; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.makes TO loco_auswertung_benutzer;


--
-- Name: TABLE model_to_fuels; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.model_to_fuels TO loco_auswertung_benutzer;


--
-- Name: TABLE models; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.models TO loco_auswertung_benutzer;


--
-- Name: TABLE nominal_accounts; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.nominal_accounts TO loco_auswertung_benutzer;


--
-- Name: TABLE orders; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.orders TO loco_auswertung_benutzer;


--
-- Name: TABLE part_types; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.part_types TO loco_auswertung_benutzer;


--
-- Name: TABLE parts; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.parts TO loco_auswertung_benutzer;


--
-- Name: TABLE parts_additional_descriptions; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.parts_additional_descriptions TO loco_auswertung_benutzer;


--
-- Name: TABLE parts_inbound_delivery_notes; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.parts_inbound_delivery_notes TO loco_auswertung_benutzer;


--
-- Name: TABLE parts_master; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.parts_master TO loco_auswertung_benutzer;


--
-- Name: TABLE parts_rebate_codes_buy; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.parts_rebate_codes_buy TO loco_auswertung_benutzer;


--
-- Name: TABLE parts_rebate_codes_sell; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.parts_rebate_codes_sell TO loco_auswertung_benutzer;


--
-- Name: TABLE parts_rebate_groups_buy; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.parts_rebate_groups_buy TO loco_auswertung_benutzer;


--
-- Name: TABLE parts_rebate_groups_sell; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.parts_rebate_groups_sell TO loco_auswertung_benutzer;


--
-- Name: TABLE parts_special_offer_prices; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.parts_special_offer_prices TO loco_auswertung_benutzer;


--
-- Name: TABLE parts_special_prices; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.parts_special_prices TO loco_auswertung_benutzer;


--
-- Name: TABLE parts_stock; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.parts_stock TO loco_auswertung_benutzer;


--
-- Name: TABLE parts_supplier_numbers; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.parts_supplier_numbers TO loco_auswertung_benutzer;


--
-- Name: TABLE parts_to_vehicles; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.parts_to_vehicles TO loco_auswertung_benutzer;


--
-- Name: TABLE privacy_channels; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.privacy_channels TO loco_auswertung_benutzer;


--
-- Name: TABLE privacy_details; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.privacy_details TO loco_auswertung_benutzer;


--
-- Name: TABLE privacy_protection_consent; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.privacy_protection_consent TO loco_auswertung_benutzer;


--
-- Name: TABLE privacy_scopes; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.privacy_scopes TO loco_auswertung_benutzer;


--
-- Name: TABLE salutations; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.salutations TO loco_auswertung_benutzer;


--
-- Name: TABLE subsidiaries; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.subsidiaries TO loco_auswertung_benutzer;


--
-- Name: TABLE time_types; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.time_types TO loco_auswertung_benutzer;


--
-- Name: TABLE times; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.times TO loco_auswertung_benutzer;


--
-- Name: TABLE transit_customers; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.transit_customers TO loco_auswertung_benutzer;


--
-- Name: TABLE transit_vehicles; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.transit_vehicles TO loco_auswertung_benutzer;


--
-- Name: TABLE vat_keys; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.vat_keys TO loco_auswertung_benutzer;


--
-- Name: TABLE vehicle_accessories_customer; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.vehicle_accessories_customer TO loco_auswertung_benutzer;


--
-- Name: TABLE vehicle_accessories_dealer; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.vehicle_accessories_dealer TO loco_auswertung_benutzer;


--
-- Name: TABLE vehicle_bodys; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.vehicle_bodys TO loco_auswertung_benutzer;


--
-- Name: TABLE vehicle_buy_types; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.vehicle_buy_types TO loco_auswertung_benutzer;


--
-- Name: TABLE vehicle_pre_owned_codes; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.vehicle_pre_owned_codes TO loco_auswertung_benutzer;


--
-- Name: TABLE vehicle_sale_types; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.vehicle_sale_types TO loco_auswertung_benutzer;


--
-- Name: TABLE vehicle_types; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.vehicle_types TO loco_auswertung_benutzer;


--
-- Name: TABLE vehicles; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.vehicles TO loco_auswertung_benutzer;


--
-- Name: TABLE wtp_pickup_bring_type; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.wtp_pickup_bring_type TO loco_auswertung_benutzer;


--
-- Name: TABLE wtp_progress_status; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.wtp_progress_status TO loco_auswertung_benutzer;


--
-- Name: TABLE wtp_urgency; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.wtp_urgency TO loco_auswertung_benutzer;


--
-- Name: TABLE wtp_vehicle_status; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.wtp_vehicle_status TO loco_auswertung_benutzer;


--
-- Name: TABLE year_calendar; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.year_calendar TO loco_auswertung_benutzer;


--
-- Name: TABLE year_calendar_day_off_codes; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.year_calendar_day_off_codes TO loco_auswertung_benutzer;


--
-- Name: TABLE year_calendar_subsidiary_mapping; Type: ACL; Schema: public; Owner: postgres
--

GRANT SELECT ON TABLE public.year_calendar_subsidiary_mapping TO loco_auswertung_benutzer;


--
-- PostgreSQL database dump complete
--

