USE [LOCOSOFT]
GO

CREATE SCHEMA import
GO

/****** Object:  Table [import].[absence_calendar]    Script Date: 02.10.2019 13:41:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [import].[absence_calendar](
	[employee_number] [int] NOT NULL,
	[date] [datetime] NOT NULL,
	[unique_dummy] [int] NOT NULL,
	[type] [varchar](10) NULL,
	[is_payed] [smallint] NULL,
	[day_contingent] [numeric](4, 2) NULL,
	[reason] [varchar](10) NULL,
	[booking_flag] [varchar](10) NULL,
 CONSTRAINT [absence_calendar_temp_20180403051118_pkey] PRIMARY KEY CLUSTERED 
(
	[employee_number] ASC,
	[date] ASC,
	[unique_dummy] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [import].[absence_reasons]    Script Date: 02.10.2019 13:41:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [import].[absence_reasons](
	[id] [varchar](10) NOT NULL,
	[description] [varchar](50) NULL,
	[is_annual_vacation] [smallint] NULL,
 CONSTRAINT [absence_reasons_temp_20180403051147_pkey] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [import].[absence_types]    Script Date: 02.10.2019 13:41:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [import].[absence_types](
	[type] [varchar](10) NOT NULL,
	[description] [varchar](50) NULL,
 CONSTRAINT [absence_types_temp_20180403051149_pkey] PRIMARY KEY CLUSTERED 
(
	[type] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [import].[accounts_characteristics]    Script Date: 02.10.2019 13:41:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [import].[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] [varchar](50) NULL,
	[skr51_make_description] [varchar](50) NULL,
	[skr51_cost_center_name] [varchar](50) NULL,
	[skr51_sales_channel_name] [varchar](50) NULL,
	[skr51_cost_unit_name] [varchar](50) NULL,
 CONSTRAINT [accounts_characteristics_temp_20180403051152_pkey] PRIMARY KEY CLUSTERED 
(
	[subsidiary_to_company_ref] ASC,
	[skr51_branch] ASC,
	[skr51_make] ASC,
	[skr51_cost_center] ASC,
	[skr51_sales_channel] ASC,
	[skr51_cost_unit] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [import].[charge_type_descriptions]    Script Date: 02.10.2019 13:41:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [import].[charge_type_descriptions](
	[type] [int] NOT NULL,
	[description] [varchar](100) NULL,
 CONSTRAINT [charge_type_descriptions_temp_20180403051215_pkey] PRIMARY KEY CLUSTERED 
(
	[type] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [import].[charge_types]    Script Date: 02.10.2019 13:41:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [import].[charge_types](
	[type] [int] NOT NULL,
	[subsidiary] [int] NOT NULL,
	[timeunit_rate] [numeric](9, 3) NULL,
	[department] [int] NULL,

 CONSTRAINT [charge_types_temp_20180403051210_pkey] PRIMARY KEY CLUSTERED 
(
	[type] ASC,
	[subsidiary] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [import].[clearing_delay_types]    Script Date: 02.10.2019 13:41:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [import].[clearing_delay_types](
	[type] [varchar](10) NOT NULL,
	[description] [varchar](50) NULL,

 CONSTRAINT [clearing_delay_types_temp_20180403051217_pkey] PRIMARY KEY CLUSTERED 
(
	[type] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [import].[codes_vehicle_date]    Script Date: 02.10.2019 13:41:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [import].[codes_vehicle_date](
	[vehicle_number] [int] NOT NULL,
	[code] [varchar](10) NOT NULL,
	[date] [datetime] NULL,
 CONSTRAINT [pk_codes_vehicle_date] PRIMARY KEY CLUSTERED 
(
	[vehicle_number] ASC,
	[code] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [import].[codes_vehicle_date_def]    Script Date: 02.10.2019 13:41:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [import].[codes_vehicle_date_def](
	[code] [varchar](10) NOT NULL,
	[is_defined_by_dms] [varchar](10) NULL,
	[month_increase_factor] [int] NULL,
	[show_in_211_from_or_to] [varchar](10) NULL,
	[is_backdate_on_exceeding] [varchar](10) NULL,
	[description] [varchar](100) NULL,
 CONSTRAINT [pk_codes_vehicle_date_def] PRIMARY KEY CLUSTERED 
(
	[code] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [import].[codes_vehicle_def]    Script Date: 02.10.2019 13:41:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [import].[codes_vehicle_def](
	[code] [varchar](10) NOT NULL,
	[is_defined_by_dms] [varchar](10) NULL,
	[format] [varchar](10) NULL,
	[length] [int] NULL,
	[decimal] [int] NULL,
	[description] [varchar](100) NULL,
 CONSTRAINT [pk_codes_vehicle_def] PRIMARY KEY CLUSTERED 
(
	[code] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [import].[codes_vehicle_list]    Script Date: 02.10.2019 13:41:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [import].[codes_vehicle_list](
	[vehicle_number] [int] NOT NULL,
	[code] [varchar](10) NOT NULL,
	[value_format] [varchar](10) NULL,
	[value_text] [varchar](100) NULL,
	[value_numeric] [numeric](18, 9) NULL,
	[value_date] [datetime] NULL,
 CONSTRAINT [pk_codes_vehicle_list] PRIMARY KEY CLUSTERED 
(
	[vehicle_number] ASC,
	[code] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [import].[codes_vehicle_mileage]    Script Date: 02.10.2019 13:41:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [import].[codes_vehicle_mileage](
	[vehicle_number] [int] NOT NULL,
	[code] [varchar](10) NOT NULL,
	[kilometer] [int] NULL,
 CONSTRAINT [pk_codes_vehicle_mileage] PRIMARY KEY CLUSTERED 
(
	[vehicle_number] ASC,
	[code] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [import].[codes_vehicle_mileage_def]    Script Date: 02.10.2019 13:41:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [import].[codes_vehicle_mileage_def](
	[code] [varchar](10) NOT NULL,
	[is_defined_by_dms] [varchar](10) NULL,
	[mileage_increase_factor] [int] NULL,
	[show_in_211_from_or_to] [varchar](10) NULL,
	[description] [varchar](100) NULL,
 CONSTRAINT [pk_codes_vehicle_mileage_def] PRIMARY KEY CLUSTERED 
(
	[code] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [import].[com_number_types]    Script Date: 02.10.2019 13:41:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [import].[com_number_types](
	[typ] [varchar](10) NOT NULL,
	[description] [varchar](50) NULL,
	[is_office_number] [smallint] NULL,
 CONSTRAINT [com_number_types_temp_20180403051220_pkey] PRIMARY KEY CLUSTERED 
(
	[typ] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [import].[customer_codes]    Script Date: 02.10.2019 13:41:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [import].[customer_codes](
	[code] [int] NOT NULL,
	[description] [varchar](50) NULL,
 CONSTRAINT [customer_codes_temp_20180403051844_pkey] PRIMARY KEY CLUSTERED 
(
	[code] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [import].[customer_com_numbers]    Script Date: 02.10.2019 13:41:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [import].[customer_com_numbers](
	[customer_number] [int] NOT NULL,
	[counter] [bigint] NOT NULL,
	[com_type] [varchar](10) NULL,
	[is_reference] [smallint] NULL,
	[only_on_1st_tab] [smallint] NULL,
	[address] [varchar](100) NULL,
	[has_contact_person_fields] [smallint] NULL,
	[contact_salutation] [varchar](50) NULL,
	[contact_firstname] [varchar](100) NULL,
	[contact_lastname] [varchar](100) NULL,
	[contact_description] [varchar](100) NULL,
	[note] [varchar](100) NULL,
 CONSTRAINT [customer_com_numbers_temp_20180403051846_pkey] PRIMARY KEY CLUSTERED 
(
	[customer_number] ASC,
	[counter] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [import].[customer_to_customercodes]    Script Date: 02.10.2019 13:41:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [import].[customer_to_customercodes](
	[customer_number] [int] NOT NULL,
	[customer_code] [int] NOT NULL,
 CONSTRAINT [customer_to_customercodes_temp_20180403052118_pkey] PRIMARY KEY CLUSTERED 
(
	[customer_number] ASC,
	[customer_code] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [import].[customers_suppliers]    Script Date: 02.10.2019 13:41:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [import].[customers_suppliers](
	[customer_number] [int] NOT NULL,
	[subsidiary] [int] NULL,
	[is_supplier] [smallint] NULL,
	[is_natural_person] [smallint] NULL,
	[is_dummy_customer] [smallint] NULL,
	[salutation_code] [varchar](50) NULL,
	[name_prefix] [varchar](50) NULL,
	[first_name] [varchar](50) NULL,
	[family_name] [varchar](50) NULL,
	[name_postfix] [varchar](50) NULL,
	[country_code] [varchar](10) NULL,
	[zip_code] [varchar](50) NULL,
	[home_city] [varchar](50) NULL,
	[home_street] [varchar](50) NULL,
	[parts_rebate_group_buy] [int] NULL,
	[parts_rebate_group_sell] [int] NULL,
	[rebate_labour_percent] [numeric](9, 5) NULL,
	[rebate_material_percent] [numeric](9, 5) NULL,
	[rebate_new_vehicles_percent] [numeric](9, 5) NULL,
	[cash_discount_percent] [numeric](9, 5) NULL,
	[vat_id_number] [varchar](50) NULL,
	[vat_id_number_checked_date] [datetime] NULL,
    [vat_id_free_code_1] [int] NULL,
    [vat_id_free_code_2] [int] NULL,
	[birthday] [datetime] NULL,
	[last_contact] [datetime] NULL,
	[preferred_com_number_type] [varchar](10) NULL,
	[created_date] [datetime] NULL,
	[created_employee_no] [int] NULL,
	[updated_date] [datetime] NULL,
	[updated_employee_no] [int] NULL,
	[name_updated_date] [datetime] NULL,
	[name_updated_employee_no] [int] NULL,
 CONSTRAINT [customers_suppliers_temp_20180403051222_pkey] PRIMARY KEY CLUSTERED 
(
	[customer_number] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [import].[dealer_vehicles]    Script Date: 02.10.2019 13:41:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [import].[dealer_vehicles](
	[dealer_vehicle_type] [varchar](10) NOT NULL,
	[dealer_vehicle_number] [int] NOT NULL,
	[vehicle_number] [int] NULL,
	[location] [varchar](50) NULL,
	[buyer_customer_no] [int] NULL,
	[deregistration_date] [datetime] NULL,
	[refinancing_start_date] [datetime] NULL,
	[refinancing_end_date] [datetime] NULL,
	[refinancing_value] [numeric](9, 2) NULL,
	[refinancing_refundment] [numeric](9, 2) NULL,
	[refinancing_bank_customer_no] [int] NULL,
	[refinanc_interest_free_date] [datetime] NULL,
	[in_subsidiary] [int] NULL,
	[in_buy_salesman_number] [int] NULL,
	[in_buy_order_no] [varchar](50) NULL,
	[in_buy_order_no_date] [datetime] NULL,
	[in_buy_invoice_no] [varchar](50) NULL,
	[in_buy_invoice_no_date] [datetime] NULL,
	[in_buy_edp_order_no] [varchar](50) NULL,
	[in_buy_edp_order_no_date] [datetime] NULL,
	[in_opel_production_no] [varchar](50) NULL,
	[in_is_trade_in_ken] [varchar](10) NULL,
	[in_is_trade_in_kom] [int] NULL,
	[in_used_vehicle_buy_type] [varchar](10) NULL,
	[in_buy_list_price] [numeric](9, 2) NULL,
	[in_arrival_date] [datetime] NULL,
	[in_expected_arrival_date] [datetime] NULL,
	[in_accounting_document_type] [varchar](10) NULL,
	[in_accounting_document_number] [int] NULL,
	[in_accounting_document_date] [datetime] NULL,
	[in_acntg_exceptional_group] [varchar](10) NULL,
	[in_acntg_cost_unit_new_vehicle] [numeric](2, 0) NULL,
	[in_accounting_make] [numeric](2, 0) NULL,
	[in_registration_reference] [varchar](50) NULL,
	[in_expected_repair_cost] [numeric](9, 2) NULL,
	[in_order_status] [varchar](10) NULL,
	[out_subsidiary] [int] NULL,
	[out_is_ready_for_sale] [varchar](10) NULL,
	[out_ready_for_sale_date] [datetime] NULL,
	[out_sale_type] [varchar](10) NULL,
	[out_sales_contract_number] [int] NULL,
	[out_sales_contract_date] [datetime] NULL,
	[out_is_sales_contract_confrmed] [varchar](10) NULL,
	[out_salesman_number_1] [int] NULL,
	[out_salesman_number_2] [int] NULL,
	[out_desired_shipment_date] [datetime] NULL,
	[out_is_registration_included] [varchar](10) NULL,
	[out_recommended_retail_price] [numeric](9, 2) NULL,
	[out_extra_expenses] [numeric](9, 2) NULL,
	[out_sale_price] [numeric](9, 2) NULL,
	[out_sale_price_dealer] [numeric](9, 2) NULL,
	[out_sale_price_minimum] [numeric](9, 2) NULL,
	[out_sale_price_internet] [numeric](9, 2) NULL,
	[out_estimated_invoice_value] [numeric](9, 2) NULL,
	[out_discount_percent_vehicle] [numeric](9, 5) NULL,
	[out_discount_percent_accessory] [numeric](9, 5) NULL,
	[out_order_number] [int] NULL,
	[out_invoice_type] [int] NULL,
	[out_invoice_number] [int] NULL,
	[out_invoice_date] [datetime] NULL,
	[out_deposit_invoice_type] [int] NULL,
	[out_deposit_invoice_number] [int] NULL,
	[out_deposit_value] [numeric](9, 2) NULL,
	[out_license_plate] [varchar](50) NULL,
	[out_make_number] [int] NULL,
	[out_model_code] [varchar](50) NULL,
	[out_license_plate_country] [varchar](50) NULL,
	[out_license_plate_season] [varchar](50) NULL,
	[calc_basic_charge] [numeric](9, 2) NULL,
	[calc_accessory] [numeric](9, 2) NULL,
	[calc_extra_expenses] [numeric](9, 2) NULL,
	[calc_usage_value_encr_external] [numeric](9, 2) NULL,
	[calc_usage_value_encr_internal] [numeric](9, 2) NULL,
	[calc_usage_value_encr_other] [numeric](9, 2) NULL,
	[calc_total_writedown] [numeric](9, 2) NULL,
	[calc_cost_percent_stockingdays] [numeric](3, 0) NULL,
	[calc_interest_percent_stkdays] [numeric](6, 3) NULL,
	[calc_actual_payed_interest] [numeric](9, 2) NULL,
	[calc_commission_for_arranging] [numeric](9, 2) NULL,
	[calc_commission_for_salesman] [numeric](9, 2) NULL,
	[calc_cost_internal_invoices] [numeric](9, 2) NULL,
	[calc_cost_other] [numeric](9, 2) NULL,
	[calc_sales_aid] [numeric](9, 2) NULL,
	[calc_sales_aid_finish] [numeric](9, 2) NULL,
	[calc_sales_aid_bonus] [numeric](9, 2) NULL,
	[calc_returns_workshop] [numeric](9, 2) NULL,
	[exclusive_reserved_employee_no] [int] NULL,
	[exclusive_reserved_until] [datetime] NULL,
	[pre_owned_car_code] [varchar](10) NULL,
	[is_sale_internet] [varchar](10) NULL,
	[is_sale_prohibit] [varchar](10) NULL,
	[is_agency_business] [varchar](10) NULL,
	[is_rental_or_school_vehicle] [varchar](10) NULL,
	[previous_owner_number] [int] NULL,
	[mileage_km] [int] NULL,
	[mileage_miles] [int] NULL,
	[memo] [varchar](255) NULL,
	[keys_box_number] [int] NULL,
	[last_change_date] [datetime] NULL,
	[last_change_employee_no] [int] NULL,
	[created_date] [datetime] NULL,
	[created_employee_no] [int] NULL,
	[financing_example_ref] [int] NULL,
    [leasing_example_ref] [int] NULL,
 CONSTRAINT [pk_dealer_vehicles] PRIMARY KEY CLUSTERED 
(
	[dealer_vehicle_type] ASC,
	[dealer_vehicle_number] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [import].[document_types]    Script Date: 02.10.2019 13:41:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [import].[document_types](
	[document_type_in_journal] [varchar](255) NOT NULL,
	[document_type_description] [varchar](255) NULL,
 CONSTRAINT [document_types_temp_20180403052123_pkey] PRIMARY KEY CLUSTERED 
(
	[document_type_in_journal] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [import].[employees]    Script Date: 02.10.2019 13:41:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [import].[employees](
	[employee_number] [int] NOT NULL,
	[validity_date] [datetime] NULL,
	[is_latest_record] [smallint] NULL,
	[subsidiary] [int] NULL,
	[has_constant_salary] [smallint] NULL,
	[name] [varchar](50) NULL,
	[initials] [varchar](10) NULL,
	[customer_number] [int] NULL,
	[mechanic_number] [int] NULL,
	[salesman_number] [int] NULL,
	[is_business_executive] [smallint] NULL,
	[is_master_craftsman] [smallint] NULL,
	[employment_date] [datetime] NULL,
	[termination_date] [datetime] NULL,
	[leave_date] [datetime] NULL,
	[is_flextime] [smallint] NULL,
	[break_time_registration] [varchar](10) NULL,
	[productivity_factor] [decimal](2,1),
 CONSTRAINT [employees_temp_20180403052145624678_pkey] PRIMARY KEY CLUSTERED 
(
	[employee_number] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [import].[employees_breaktimes]    Script Date: 02.10.2019 13:41:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [import].[employees_breaktimes](
	[is_latest_record] [smallint] NULL,
	[employee_number] [int] NOT NULL,
	[validity_date] [datetime] NOT NULL,
	[dayofweek] [int] NOT NULL,
	[break_start] [decimal](6, 3) NOT NULL,
	[break_end] [decimal](6, 3) NULL,
 CONSTRAINT [employees_breaktimes_temp_20180403052126_pkey] PRIMARY KEY CLUSTERED 
(
	[employee_number] ASC,
	[validity_date] ASC,
	[dayofweek] ASC,
	[break_start] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO

/****** Object:  Table [import].[employees_history]    Script Date: 02.10.2019 13:41:14 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [import].[employees_history](
	[employee_number] [int] NOT NULL,
	[validity_date] [datetime] NOT NULL,
	[is_latest_record] [smallint] NULL,
	[subsidiary] [int] NULL,
	[has_constant_salary] [smallint] NULL,
	[name] [varchar](50) NULL,
	[initials] [varchar](10) NULL,
	[customer_number] [int] NULL,
	[mechanic_number] [int] NULL,
	[salesman_number] [int] NULL,
	[is_business_executive] [smallint] NULL,
	[is_master_craftsman] [smallint] NULL,
	[employment_date] [datetime] NULL,
	[termination_date] [datetime] NULL,
	[leave_date] [datetime] NULL,
	[is_flextime] [smallint] NULL,
	[break_time_registration] [varchar](10) NULL,
	[productivity_factor] [decimal](2,1),
 CONSTRAINT [employees_history_temp_20180403052128_pkey] PRIMARY KEY CLUSTERED 
(
	[employee_number] ASC,
	[validity_date] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [import].[employees_worktimes]    Script Date: 02.10.2019 13:41:14 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [import].[employees_worktimes](
	[is_latest_record] [smallint] NULL,
	[employee_number] [int] NOT NULL,
	[validity_date] [datetime] NOT NULL,
	[dayofweek] [int] NOT NULL,
	[work_duration] [decimal](6, 3) NULL,
	[worktime_start] [decimal](6, 3) NULL,
	[worktime_end] [decimal](6, 3) NULL,
 CONSTRAINT [employees_worktimes_temp_20180403052130_pkey] PRIMARY KEY CLUSTERED 
(
	[employee_number] ASC,
	[validity_date] ASC,
	[dayofweek] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [import].[fuels]    Script Date: 02.10.2019 13:41:14 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [import].[fuels](
	[code] [varchar](10) NOT NULL,
	[description] [varchar](255) NULL,
 CONSTRAINT [fuels_temp_20180403052131_pkey] PRIMARY KEY CLUSTERED 
(
	[code] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [import].[invoice_types]    Script Date: 02.10.2019 13:41:14 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [import].[invoice_types](
	[type] [int] NOT NULL,
	[description] [varchar](255) NULL,
 CONSTRAINT [invoice_types_temp_20180403052756_pkey] PRIMARY KEY CLUSTERED 
(
	[type] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [import].[invoices]    Script Date: 02.10.2019 13:41:14 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [import].[invoices](
	[invoice_type] [int] NOT NULL,
	[invoice_number] [int] NOT NULL,
	[subsidiary] [int] NULL,
	[order_number] [int] NULL,
	[paying_customer] [int] NULL,
	[order_customer] [int] NULL,
	[invoice_date] [datetime] NULL,
	[service_date] [datetime] NULL,
	[is_canceled] [smallint] NULL,
	[cancelation_number] [int] NULL,
	[cancelation_date] [datetime] NULL,
	[cancelation_employee] [int] NULL,
	[is_own_vehicle] [smallint] NULL,
	[is_credit] [smallint] NULL,
	[credit_invoice_type] [int] NULL,
	[credit_invoice_number] [int] NULL,
	[odometer_reading] [int] NULL,
	[creating_employee] [int] NULL,
	[internal_cost_account] [int] NULL,
	[vehicle_number] [int] NULL,
	[full_vat_basevalue] [numeric](9, 2) NULL,
	[full_vat_percentage] [numeric](4, 2) NULL,
	[full_vat_value] [numeric](18, 2) NULL,
	[reduced_vat_basevalue] [numeric](9, 2) NULL,
	[reduced_vat_percentage] [numeric](4, 2) NULL,
	[reduced_vat_value] [numeric](18, 2) NULL,
	[used_part_vat_value] [numeric](9, 2) NULL,
	[job_amount_net] [numeric](18, 2) NULL,
	[job_amount_gross] [numeric](18, 2) NULL,
	[job_rebate] [numeric](9, 2) NULL,
	[part_amount_net] [numeric](18, 2) NULL,
	[part_amount_gross] [numeric](18, 2) NULL,
	[part_rebate] [numeric](9, 2) NULL,
	[part_disposal] [numeric](9, 2) NULL,
	[total_gross] [numeric](18, 2) NULL,
	[total_net] [numeric](18, 2) NULL,
 CONSTRAINT [invoices_temp_20180403052133_pkey] PRIMARY KEY CLUSTERED 
(
	[invoice_type] ASC,
	[invoice_number] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [import].[journal_accountings]    Script Date: 02.10.2019 13:41:14 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [import].[journal_accountings](
	[accounting_date] [datetime] NOT NULL,
	[document_type] [varchar](255) NOT NULL,
	[document_number] [bigint] NOT NULL,
	[position_in_document] [bigint] NOT NULL,
	[customer_number] [bigint] NULL,
	[nominal_account_number] [bigint] NULL,
	[is_balanced] [varchar](10) NULL,
	[clearing_number] [bigint] NULL,
	[document_date] [datetime] NULL,
	[posted_value] [bigint] NULL,
	[debit_or_credit] [varchar](10) NULL,
	[posted_count] [bigint] NULL,
	[branch_number] [bigint] NULL,
	[customer_contra_account] [bigint] NULL,
	[nominal_contra_account] [bigint] NULL,
	[contra_account_text] [varchar](50) NULL,
	[account_form_page_number] [bigint] NULL,
	[account_form_page_line] [bigint] NULL,
	[serial_number_each_month] [bigint] NULL,
	[employee_number] [bigint] NULL,
	[invoice_date] [varchar](50) NULL,
	[invoice_number] [varchar](50) NULL,
	[dunning_level] [varchar](50) NULL,
	[last_dunning_date] [varchar](50) NULL,
	[journal_page] [bigint] NULL,
	[journal_line] [bigint] NULL,
	[cash_discount] [bigint] NULL,
	[term_of_payment] [bigint] NULL,
	[posting_text] [varchar](100) NULL,
	[vehicle_reference] [varchar](50) NULL,
	[vat_id_number] [varchar](50) NULL,
	[account_statement_number] [bigint] NULL,
	[account_statement_page] [bigint] NULL,
	[vat_key] [varchar](50) NULL,
	[days_for_cash_discount] [bigint] NULL,
	[day_of_actual_accounting] [datetime] NULL,
	[skr51_branch] [bigint] NULL,
	[skr51_make] [bigint] NULL,
	[skr51_cost_center] [bigint] NULL,
	[skr51_sales_channel] [bigint] NULL,
	[skr51_cost_unit] [bigint] NULL,
	[previously_used_account_no] [varchar](50) NULL,
	[free_form_accounting_text] [varchar](255) NULL,
	[free_form_document_text] [varchar](255) NULL,
 CONSTRAINT [journal_accountings_import_20180403120809_pkey] PRIMARY KEY CLUSTERED 
(
	[accounting_date] ASC,
	[document_type] ASC,
	[document_number] ASC,
	[position_in_document] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [import].[labour_types]    Script Date: 02.10.2019 13:41:14 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [import].[labour_types](
	[code] [varchar](10) NOT NULL,
	[description] [varchar](255) NULL,
 CONSTRAINT [labour_types_temp_20180403071554_pkey] PRIMARY KEY CLUSTERED 
(
	[code] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [import].[labours]    Script Date: 02.10.2019 13:41:14 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [import].[labours](
	[order_number] [int] NOT NULL,
	[order_position] [int] NOT NULL,
	[order_position_line] [int] NOT NULL,
	[subsidiary] [int] NULL,
	[is_invoiced] [smallint] NULL,
	[invoice_type] [int] NULL,
	[invoice_number] [int] NULL,
	[employee_no] [int] NULL,
	[mechanic_no] [int] NULL,
	[labour_operation_id] [varchar](50) NULL,
	[is_nominal] [smallint] NULL,
	[time_units] [varchar](50) NULL,
	[net_price_in_order] [numeric](9, 2) NULL,
	[rebate_percent] [numeric](4, 2) NULL,
	[goodwill_percent] [numeric](4, 1) NULL,
	[charge_type] [int] NOT NULL,
	[text_line] [varchar](100) NULL,
	[usage_value] [decimal](9,2),
 CONSTRAINT [labours_temp_20180403070609_pkey] PRIMARY KEY CLUSTERED 
(
	[order_number] ASC,
	[order_position] ASC,
	[order_position_line] ASC,
	[charge_type] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO

/****** Object:  Table [import].[makes]    Script Date: 02.10.2019 13:41:14 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [import].[makes](
	[make_number] [int] NOT NULL,
	[is_actual_make] [smallint] NULL,
	[description] [varchar](255) NULL,
	[group_name] [varchar](10) NULL,
	[make_id_in_group] [varchar](10) NULL,
	[internal_labour_group] [int] NULL,
	[is_production_year_visible] [smallint] NULL,
	[is_transmission_no_visible] [smallint] NULL,
	[is_engine_no_visible] [smallint] NULL,
	[is_ricambi_no_visible] [smallint] NULL,
	[ricambi_label] [varchar](50) NULL,
	[is_preset_finance_stock_rate] [smallint] NULL,
	[rate_free_days_new_vehicle] [int] NULL,
	[rate_free_days_demo_vehicle] [int] NULL,
	[special_service_2_interval] [numeric](4, 1) NULL,
	[special_service_3_interval] [numeric](4, 1) NULL,
 CONSTRAINT [makes_temp_20180403071556_pkey] PRIMARY KEY CLUSTERED 
(
	[make_number] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [import].[model_to_fuels]    Script Date: 02.10.2019 13:41:14 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [import].[model_to_fuels](
	[make_number] [int] NOT NULL,
	[model_code] [varchar](50) NOT NULL,
	[code] [varchar](10) NOT NULL,
 CONSTRAINT [model_to_fuels_temp_20180403072157_pkey] PRIMARY KEY CLUSTERED 
(
	[make_number] ASC,
	[model_code] ASC,
	[code] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [import].[models]    Script Date: 02.10.2019 13:41:14 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [import].[models](
	[make_number] [int] NOT NULL,
	[model_code] [varchar](50) NOT NULL,
	[is_actual_model] [smallint] NULL,
	[model_currently_available] [smallint] NULL,
	[replacing_model_code] [varchar](50) NULL,
	[description] [varchar](255) NULL,
	[gear_count] [int] NULL,
	[seat_count] [int] NULL,
	[door_count] [int] NULL,
	[cylinder_count] [int] NULL,
	[vehicle_body] [varchar](10) NULL,
	[model_labour_group] [varchar](10) NULL,
	[has_hour_meter] [smallint] NULL,
	[source_extern] [smallint] NULL,
	[free_form_vehicle_class] [varchar](10) NULL,
	[vin_begin] [varchar](50) NULL,
	[vehicle_pool_code] [varchar](50) NULL,
	[vehicle_pool_engine_code] [varchar](10) NULL,
	[is_manual_transmission] [smallint] NULL,
	[is_all_wheel_drive] [smallint] NULL,
	[is_plugin_hybride] [smallint] NULL,
	[unloaded_weight] [int] NULL,
	[gross_vehicle_weight] [int] NULL,
	[power_kw] [int] NULL,
	[power_kw_at_rotation] [int] NULL,
	[cubic_capacity] [int] NULL,
	[german_kba_hsn] [varchar](10) NULL,
	[german_kba_tsn] [varchar](50) NULL,
	[annual_tax] [numeric](9, 2) NULL,
	[model_year] [varchar](50) NULL,
	[model_year_postfix] [varchar](10) NULL,
	[suggested_net_retail_price] [numeric](9, 2) NULL,
	[suggested_net_shipping_cost] [numeric](9, 2) NULL,
	[european_pollutant_class] [varchar](10) NULL,
	[efficiency_class] [varchar](10) NULL,
	[emission_code] [varchar](10) NULL,
	[carbondioxid_emission] [int] NULL,
	[nox_exhoust] [numeric](4, 3) NULL,
	[particle_exhoust] [numeric](4, 3) NULL,
	[external_schwacke_code] [varchar](50) NULL,
	[skr_carrier_flag] [int] NULL,
	[free_form_model_specification] [varchar](10) NULL,
	[external_technical_type] [varchar](10) NULL,
	[european_fuel_consumption_over] [numeric](4, 2) NULL,
	[european_fuel_consumption_coun] [numeric](4, 2) NULL,
	[european_fuel_consumption_city] [numeric](4, 2) NULL,
	[energy_consumption] [varchar](50) NULL,
	[insurance_class_liability] [int] NULL,
	[insurance_class_part_comprehen] [int] NULL,
	[insurance_class_full_comprehen] [int] NULL,
 CONSTRAINT [models_temp_20180403071559_pkey] PRIMARY KEY CLUSTERED 
(
	[make_number] ASC,
	[model_code] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [import].[nominal_accounts]    Script Date: 02.10.2019 13:41:14 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [import].[nominal_accounts](
	[subsidiary_to_company_ref] [bigint] NOT NULL,
	[nominal_account_number] [bigint] NOT NULL,
	[account_description] [varchar](255) NULL,
	[is_profit_loss_account] [varchar](255) NULL,
	[vat_key] [varchar](255) NULL,
	[create_date] [datetime] NULL,
	[create_employee_number] [bigint] NULL,
	[oldest_accountable_month] [datetime] NULL,
 CONSTRAINT [nominal_accounts_temp_20180403072205_pkey] PRIMARY KEY CLUSTERED 
(
	[nominal_account_number] ASC,
	[subsidiary_to_company_ref] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [import].[order_positions]    Script Date: 02.10.2019 13:41:14 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [import].[order_positions](
	[order_number] [int] NOT NULL,
	[order_position] [int] NOT NULL,
	[labour_type] [varchar](10) NULL,
	[subsidiary] [int] NULL,
	[is_invoiced] [smallint] NULL,
	[invoice_type] [int] NULL,
	[invoice_number] [int] NULL,
	[order_date] [datetime] NULL,
	[estimated_inbound_time] [datetime] NULL,
	[estimated_outbound_time] [datetime] NULL,
	[order_print_date] [datetime] NULL,
	[order_taking_employee_no] [int] NULL,
	[order_delivery_employee_no] [int] NULL,
	[vehicle_number] [int] NULL,
	[dealer_vehicle_type] [varchar](10),
    [dealer_vehicle_number] [int],
	[order_mileage] [int] NULL,
	[order_customer] [int] NULL,
	[paying_customer] [int] NULL,
	[holder_number] [int] NULL,
	[parts_rebate_group_sell] [int] NULL,
	[clearing_delay_type] [varchar](10) NULL,
 CONSTRAINT [order_positions_temp_20180403072206_pkey] PRIMARY KEY CLUSTERED 
(
	[order_number] ASC,
	[order_position] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [import].[part_types]    Script Date: 02.10.2019 13:41:14 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [import].[part_types](
	[type] [int] NOT NULL,
	[description] [varchar](50) NULL,
 CONSTRAINT [part_types_temp_20180403073033_pkey] PRIMARY KEY CLUSTERED 
(
	[type] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [import].[parts]    Script Date: 02.10.2019 13:41:14 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [import].[parts](
	[order_number] [int] NOT NULL,
	[order_position] [int] NOT NULL,
	[order_position_line] [int] NOT NULL,
	[subsidiary] [int] NULL,
	[is_invoiced] [smallint] NULL,
	[invoice_type] [int] NULL,
	[invoice_number] [int] NULL,
	[employee_no] [int] NULL,
	[mechanic_no] [int] NULL,
	[part_number] [varchar](50) NULL,
	[stock_no] [int] NULL,
	[stock_removal_date] [datetime] NULL,
	[amount] [numeric](9, 2) NULL,
	[sum] [numeric](9, 2) NULL,
	[rebate_percent] [numeric](4, 2) NULL,
	[goodwill_percent] [numeric](4, 1) NULL,
	[parts_type] [int] NULL,
	[text_line] [varchar](50) NULL,
	[usage_value] [decimal](9,2),
 CONSTRAINT [parts_temp_20180403072452_pkey] PRIMARY KEY CLUSTERED 
(
	[order_number] ASC,
	[order_position] ASC,
	[order_position_line] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [import].[parts_rebate_groups_buy]    Script Date: 02.10.2019 13:41:14 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [import].[parts_rebate_groups_buy](
	[code] [int] NOT NULL,
	[description] [varchar](50) NULL,
 CONSTRAINT [parts_rebate_groups_buy_temp_20180403073031_pkey] PRIMARY KEY CLUSTERED 
(
	[code] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [import].[parts_rebate_groups_sell]    Script Date: 02.10.2019 13:41:14 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [import].[parts_rebate_groups_sell](
	[code] [int] NOT NULL,
	[description] [varchar](50) NULL,
 CONSTRAINT [parts_rebate_groups_sell_temp_20180403073032_pkey] PRIMARY KEY CLUSTERED 
(
	[code] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [import].[time_types]    Script Date: 02.10.2019 13:41:14 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [import].[time_types](
	[type] [int] NOT NULL,
	[description] [varchar](50) NULL,
 CONSTRAINT [time_types_temp_20180403073113_pkey] PRIMARY KEY CLUSTERED 
(
	[type] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [import].[times]    Script Date: 02.10.2019 13:41:14 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [import].[times](
	[employee_number] [int] NOT NULL,
	[order_number] [int] NOT NULL,
	[start_time] [datetime] NOT NULL,
	[type] [int] NULL,
	[order_positions] [varchar](10) NOT NULL,
	[end_time] [datetime] NULL,
	[duration_minutes] [int] NULL,
	[exact_duration_seconds] [bigint] NULL,
 CONSTRAINT [times_temp_20180403073035_pkey] PRIMARY KEY CLUSTERED 
(
	[employee_number] ASC,
	[order_number] ASC,
	[start_time] ASC,
	[order_positions] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [import].[vat_keys]    Script Date: 02.10.2019 13:41:14 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [import].[vat_keys](
	[subsidiary_to_company_ref] [bigint] NOT NULL,
	[vat_key] [varchar](255) NOT NULL,
	[key_validity_date] [datetime] NULL,
	[branch] [bigint] NULL,
	[description] [varchar](255) NULL,
	[vat_rate] [bigint] NULL,
	[create_date] [datetime] NULL,
	[vat_account] [bigint] NULL,
	[advanced_turnover_tax_pos] [bigint] NULL,
 CONSTRAINT [vat_keys_temp_20180403073114_pkey] PRIMARY KEY CLUSTERED 
(
	[vat_key] ASC,
	[subsidiary_to_company_ref] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [import].[vehicle_bodys]    Script Date: 02.10.2019 13:41:14 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [import].[vehicle_bodys](
	[code] [varchar](10) NOT NULL,
	[description] [varchar](255) NULL,
 CONSTRAINT [vehicle_bodys_temp_20180403073935_pkey] PRIMARY KEY CLUSTERED 
(
	[code] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [import].[vehicle_buy_types]    Script Date: 02.10.2019 13:41:14 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [import].[vehicle_buy_types](
	[code] [varchar](10) NOT NULL,
	[description] [varchar](100) NULL,
 CONSTRAINT [pk_vehicle_buy_types] PRIMARY KEY CLUSTERED 
(
	[code] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [import].[vehicle_pre_owned_codes]    Script Date: 02.10.2019 13:41:14 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [import].[vehicle_pre_owned_codes](
	[code] [varchar](10) NOT NULL,
	[description] [varchar](100) NULL,
 CONSTRAINT [pk_vehicle_pre_owned_codes] PRIMARY KEY CLUSTERED 
(
	[code] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [import].[vehicle_sale_types]    Script Date: 02.10.2019 13:41:14 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [import].[vehicle_sale_types](
	[code] [varchar](10) NOT NULL,
	[description] [varchar](100) NULL,
 CONSTRAINT [pk_vehicle_sale_types] PRIMARY KEY CLUSTERED 
(
	[code] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [import].[vehicles]    Script Date: 02.10.2019 13:41:14 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [import].[vehicles](
	[internal_number] [int] NOT NULL,
	[vin] [varchar](50) NULL,
	[license_plate] [varchar](50) NULL,
	[license_plate_country] [varchar](10) NULL,
	[license_plate_season] [varchar](10) NULL,
	[make_number] [int] NULL,
	[free_form_make_text] [varchar](10) NULL,
	[model_code] [varchar](50) NULL,
	[free_form_model_text] [varchar](50) NULL,
	[is_roadworthy] [smallint] NULL,
	[is_customer_vehicle] [smallint] NULL,
	[dealer_vehicle_type] [varchar](10) NULL,
	[dealer_vehicle_number] [int] NULL,
	[first_registration_date] [varchar](50) NULL,
	[readmission_date] [datetime] NULL,
	[next_service_date] [datetime] NULL,
	[next_service_km] [int] NULL,
	[next_service_miles] [int] NULL,
	[production_year] [varchar](50) NULL,
	[owner_number] [int] NULL,
	[holder_number] [int] NULL,
	[previous_owner_number] [int] NULL,
	[previous_owner_counter] [int] NULL,
	[last_holder_change_date] [datetime] NULL,
	[german_kba_hsn] [varchar](10) NULL,
	[german_kba_tsn] [varchar](50) NULL,
	[austria_nat_code] [varchar](50) NULL,
	[is_prefer_km] [smallint] NULL,
	[mileage_km] [int] NULL,
	[mileage_miles] [int] NULL,
	[odometer_reading_date] [datetime] NULL,
	[engine_number] [varchar](50) NULL,
	[gear_number] [varchar](50) NULL,
	[unloaded_weight] [int] NULL,
	[gross_vehicle_weight] [int] NULL,
	[power_kw] [int] NULL,
	[cubic_capacity] [int] NULL,
	[is_all_accidents_repaired] [smallint] NULL,
	[accidents_counter] [int] NULL,
	[has_tyre_pressure_sensor] [smallint] NULL,
	[carkey_number] [varchar](50) NULL,
	[internal_source_flag] [varchar](10) NULL,
	[emission_code] [varchar](10) NULL,
	[first_sold_country] [varchar](10) NULL,
	[first_sold_dealer_code] [int] NULL,
	[body_paint_code] [varchar](50) NULL,
	[body_paint_description] [varchar](50) NULL,
	[is_body_paint_metallic] [smallint] NULL,
	[interior_paint_code] [varchar](50) NULL,
	[interior_paint_description] [varchar](50) NULL,
	[trim_code] [varchar](50) NULL,
	[trim_description] [varchar](50) NULL,
	[fine_dust_label] [varchar](10) NULL,
	[internal_assignment] [varchar](10) NULL,
	[ricambi_free_input] [varchar](50) NULL,
	[document_number] [varchar](10) NULL,
	[salesman_number] [int] NULL,
	[sale_date] [varchar](50) NULL,
	[next_emission_test_date] [datetime] NULL,
	[next_general_inspection_date] [datetime] NULL,
	[next_rust_inspection_date] [datetime] NULL,
	[next_exceptional_inspection_da] [datetime] NULL,
	[last_change_date] [datetime] NULL,
	[last_change_employee_no] [int] NULL,
	[created_date] [datetime] NULL,
	[created_employee_no] [int] NULL,
	[last_change_subsidiary] [int] NULL,
 CONSTRAINT [vehicles_temp_20180403073115_pkey] PRIMARY KEY CLUSTERED 
(
	[internal_number] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [import].[year_calendar]    Script Date: 02.10.2019 13:41:15 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [import].[year_calendar](
	[calendar_id] [int] NOT NULL,
	[date] [datetime] NOT NULL,
	[day_off_declaration] [int] NULL,
	[is_school_holid] [smallint] NULL,
	[is_public_holid] [smallint] NULL,
	[day_note] [varchar](50) NULL,
 CONSTRAINT [year_calendar_temp_20180403073936_pkey] PRIMARY KEY CLUSTERED 
(
	[calendar_id] ASC,
	[date] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [import].[year_calendar_day_off_codes]    Script Date: 02.10.2019 13:41:15 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [import].[year_calendar_day_off_codes](
	[code] [int] NOT NULL,
	[description] [varchar](50) NULL,
 CONSTRAINT [year_calendar_day_off_codes_temp_20180403073938_pkey] PRIMARY KEY CLUSTERED 
(
	[code] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [import].[year_calendar_subsidiary_mapping]    Script Date: 02.10.2019 13:41:15 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [import].[year_calendar_subsidiary_mapping](
	[subsidiary] [int] NOT NULL,
	[year] [int] NOT NULL,
	[calendar_id] [int] NULL,

 CONSTRAINT [year_calendar_subsidiary_mapping_temp_20180403073940_pkey] PRIMARY KEY CLUSTERED 
(
	[subsidiary] ASC,
	[year] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [import].[absence_calendar] ADD  DEFAULT ('0') FOR [employee_number]
GO
ALTER TABLE [import].[absence_calendar] ADD  DEFAULT ('0000-00-00') FOR [date]
GO
ALTER TABLE [import].[absence_calendar] ADD  DEFAULT ('0') FOR [unique_dummy]
GO
ALTER TABLE [import].[absence_reasons] ADD  DEFAULT ('') FOR [id]
GO
ALTER TABLE [import].[absence_types] ADD  DEFAULT ('') FOR [type]
GO
ALTER TABLE [import].[accounts_characteristics] ADD  DEFAULT ('0') FOR [skr51_branch]
GO
ALTER TABLE [import].[accounts_characteristics] ADD  DEFAULT ('0') FOR [skr51_make]
GO
ALTER TABLE [import].[accounts_characteristics] ADD  DEFAULT ('0') FOR [skr51_cost_center]
GO
ALTER TABLE [import].[accounts_characteristics] ADD  DEFAULT ('0') FOR [skr51_sales_channel]
GO
ALTER TABLE [import].[accounts_characteristics] ADD  DEFAULT ('0') FOR [skr51_cost_unit]
GO
ALTER TABLE [import].[charge_type_descriptions] ADD  DEFAULT ('0') FOR [type]
GO
ALTER TABLE [import].[charge_types] ADD  DEFAULT ('0') FOR [type]
GO
ALTER TABLE [import].[charge_types] ADD  DEFAULT ('0') FOR [subsidiary]
GO
ALTER TABLE [import].[clearing_delay_types] ADD  DEFAULT ('') FOR [type]
GO
ALTER TABLE [import].[com_number_types] ADD  CONSTRAINT [DF__com_number___typ__412EB0B6]  DEFAULT ('') FOR [typ]
GO
ALTER TABLE [import].[customer_codes] ADD  DEFAULT ('0') FOR [code]
GO
ALTER TABLE [import].[customer_com_numbers] ADD  DEFAULT ('0') FOR [customer_number]
GO
ALTER TABLE [import].[customer_com_numbers] ADD  DEFAULT ('0') FOR [counter]
GO
ALTER TABLE [import].[customer_to_customercodes] ADD  DEFAULT ('0') FOR [customer_number]
GO
ALTER TABLE [import].[customer_to_customercodes] ADD  DEFAULT ('0') FOR [customer_code]
GO
ALTER TABLE [import].[customers_suppliers] ADD  CONSTRAINT [DF__customers__custo__7CCECB3B]  DEFAULT ('0') FOR [customer_number]
GO
ALTER TABLE [import].[document_types] ADD  DEFAULT ('') FOR [document_type_in_journal]
GO
ALTER TABLE [import].[employees] ADD  DEFAULT ('0') FOR [employee_number]
GO
ALTER TABLE [import].[employees_history] ADD  DEFAULT ('0') FOR [employee_number]
GO
ALTER TABLE [import].[employees_history] ADD  DEFAULT ('0000-00-00') FOR [validity_date]
GO
ALTER TABLE [import].[fuels] ADD  DEFAULT ('') FOR [code]
GO
ALTER TABLE [import].[invoice_types] ADD  DEFAULT ('0') FOR [type]
GO
ALTER TABLE [import].[invoices] ADD  DEFAULT ('0') FOR [invoice_type]
GO
ALTER TABLE [import].[invoices] ADD  DEFAULT ('0') FOR [invoice_number]
GO
ALTER TABLE [import].[journal_accountings] ADD  CONSTRAINT [DF__journal_a__accou__4C6B5938]  DEFAULT ('2010-01-01 00:00:00') FOR [accounting_date]
GO
ALTER TABLE [import].[journal_accountings] ADD  CONSTRAINT [DF__journal_a__docum__4D5F7D71]  DEFAULT ('') FOR [document_type]
GO
ALTER TABLE [import].[journal_accountings] ADD  CONSTRAINT [DF__journal_a__docum__4E53A1AA]  DEFAULT ('0') FOR [document_number]
GO
ALTER TABLE [import].[journal_accountings] ADD  CONSTRAINT [DF__journal_a__posit__4F47C5E3]  DEFAULT ('0') FOR [position_in_document]
GO
ALTER TABLE [import].[labour_types] ADD  CONSTRAINT [DF__labour_typ__code__74AE54BC]  DEFAULT ('') FOR [code]
GO
ALTER TABLE [import].[labours] ADD  DEFAULT ('0') FOR [order_number]
GO
ALTER TABLE [import].[labours] ADD  DEFAULT ('0') FOR [order_position]
GO
ALTER TABLE [import].[labours] ADD  DEFAULT ('0') FOR [order_position_line]
GO
ALTER TABLE [import].[labours] ADD  DEFAULT ('0') FOR [charge_type]
GO
ALTER TABLE [import].[makes] ADD  DEFAULT ('0') FOR [make_number]
GO
ALTER TABLE [import].[model_to_fuels] ADD  DEFAULT ('0') FOR [make_number]
GO
ALTER TABLE [import].[model_to_fuels] ADD  DEFAULT ('') FOR [model_code]
GO
ALTER TABLE [import].[model_to_fuels] ADD  DEFAULT ('') FOR [code]
GO
ALTER TABLE [import].[models] ADD  DEFAULT ('0') FOR [make_number]
GO
ALTER TABLE [import].[models] ADD  DEFAULT ('') FOR [model_code]
GO
ALTER TABLE [import].[nominal_accounts] ADD  CONSTRAINT [DF_nominal_accounts_subsidiary_to_company_ref]  DEFAULT ((0)) FOR [subsidiary_to_company_ref]
GO
ALTER TABLE [import].[nominal_accounts] ADD  CONSTRAINT [DF__nominal_a__nomin__13B23093]  DEFAULT ('0') FOR [nominal_account_number]
GO
ALTER TABLE [import].[order_positions] ADD  CONSTRAINT [DF__order_pos__order__14270015]  DEFAULT ('0') FOR [order_number]
GO
ALTER TABLE [import].[order_positions] ADD  CONSTRAINT [DF__order_pos__order__151B244E]  DEFAULT ('0') FOR [order_position]
GO
ALTER TABLE [import].[part_types] ADD  DEFAULT ('0') FOR [type]
GO
ALTER TABLE [import].[parts] ADD  DEFAULT ('0') FOR [order_number]
GO
ALTER TABLE [import].[parts] ADD  DEFAULT ('0') FOR [order_position]
GO
ALTER TABLE [import].[parts] ADD  DEFAULT ('0') FOR [order_position_line]
GO
ALTER TABLE [import].[parts_rebate_groups_buy] ADD  DEFAULT ('0') FOR [code]
GO
ALTER TABLE [import].[parts_rebate_groups_sell] ADD  DEFAULT ('0') FOR [code]
GO
ALTER TABLE [import].[time_types] ADD  DEFAULT ('0') FOR [type]
GO
ALTER TABLE [import].[times] ADD  DEFAULT ('0') FOR [employee_number]
GO
ALTER TABLE [import].[times] ADD  DEFAULT ('0') FOR [order_number]
GO
ALTER TABLE [import].[times] ADD  DEFAULT ('0') FOR [start_time]
GO
ALTER TABLE [import].[times] ADD  DEFAULT ('') FOR [order_positions]
GO
ALTER TABLE [import].[vat_keys] ADD  CONSTRAINT [DF_vat_keys_subsidiary_to_company_ref]  DEFAULT ((0)) FOR [subsidiary_to_company_ref]
GO
ALTER TABLE [import].[vat_keys] ADD  CONSTRAINT [DF__vat_keys__vat_ke__210C2BB1]  DEFAULT ('') FOR [vat_key]
GO
ALTER TABLE [import].[vehicle_bodys] ADD  DEFAULT ('') FOR [code]
GO
ALTER TABLE [import].[vehicles] ADD  CONSTRAINT [DF__vehicles__intern__3864608B]  DEFAULT ('0') FOR [internal_number]
GO
ALTER TABLE [import].[year_calendar] ADD  DEFAULT ('0') FOR [calendar_id]
GO
ALTER TABLE [import].[year_calendar] ADD  DEFAULT ('0000-00-00') FOR [date]
GO
ALTER TABLE [import].[year_calendar_day_off_codes] ADD  DEFAULT ('0') FOR [code]
GO
ALTER TABLE [import].[year_calendar_subsidiary_mapping] ADD  DEFAULT ('0') FOR [subsidiary]
GO
ALTER TABLE [import].[year_calendar_subsidiary_mapping] ADD  DEFAULT ('0') FOR [year]
GO