SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO
CREATE   VIEW [xtract].[journal_accountings] AS

SELECT [client_db]
     , [subsidiary_to_company_ref]
     , [accounting_date]
     , [document_type]
     , [document_number]
     , [position_in_document]
     , [customer_number]
     , [nominal_account_number]
--      , [is_balanced]
     , [clearing_number]
     , [document_date]
     , [posted_value]
     , [debit_or_credit]
     , [posted_count]
     , [branch_number]
--      , [customer_contra_account]
--      , [nominal_contra_account]
--      , [contra_account_text]
--      , [account_form_page_number]
--      , [account_form_page_line]
--      , [serial_number_each_month]
     , [employee_number]
     , [invoice_date]
     , [invoice_number]
     , [dunning_level]
--      , [last_dunning_date]
--      , [journal_page]
--      , [journal_line]
--      , [cash_discount]
--      , [term_of_payment]
     , [posting_text]
     , [vehicle_reference]
--      , [vat_id_number]
--      , [account_statement_number]
--      , [account_statement_page]
--      , [vat_key]
--      , [days_for_cash_discount]
--      , [day_of_actual_accounting]
     , [skr51_branch]
     , [skr51_make]
     , [skr51_cost_center]
     , [skr51_sales_channel]
     , [skr51_cost_unit]
--      , [previously_used_account_no]
--      , [free_form_accounting_text]
--      , [free_form_document_text]
     , "posted_value" * iif(("debit_or_credit" = 'H'), -1, 1) / 100 AS "Betrag"
     , "posted_count" * iif(("debit_or_credit" = 'H'), -1, 1) / 100 AS "Menge"

FROM [LOCOSOFT].[dbo].[journal_accountings]
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

GO
