View: dbo.Etl_Helper_Ledger_Entry_Journal_Entry_Credits_Debits_View
View definition
CREATE VIEW dbo.Etl_Helper_Ledger_Entry_Journal_Entry_Credits_Debits_View
AS
SELECT
-- Unique key
glt.gl_transaction_KEY,
ledger_entry_type_KEY = 1, /* Journal Entry Credits Debits*/
jed.journal_entry_distribution_KEY,
-- Ledger entry payload
je.client_KEY,
glt.journal_KEY,
glt.gl_period_KEY,
jed.gl_account_KEY,
gl_accounting_method_KEY = NULL,
gl_balance_effect_KEY = CASE
WHEN ((jed.amount < 0))
THEN 2 /* Credit */
ELSE 1 /* Debit */
END,
gl_transaction_type_KEY = je.journal_entry_type_KEY,
je.transaction_status_KEY,
gl_transaction_date = je.transaction_date,
gl_transaction_amount = CASE
WHEN ((jed.amount < 0))
THEN - jed.amount
ELSE jed.amount
END,
gl_transaction_description = je.description,
gl_transaction_detail_description = jed.description,
gl_transaction_reference_number = je.reference_number,
gl_transaction_reference_number_sortable = je.reference_number_sortable,
-- Standard supplemental information
gl_transaction_source_expression_KEY = CAST(7 AS TINYINT), -- GLTransactionSourceExpression.JournalEntry
gl_transaction_source_KEY = 1, -- GLTransactionSource.JournalEntry
je.is_activity_journal_entry,
je.journal_entry_type_KEY,
source_was_a_distribution = cast(1 AS BIT),
jed.sequence_number,
je.workpaper_reference,
distribution_workpaper_reference = jed.workpaper_reference,
-- Custom supplemental information
nje.journal_entry_KEY,
je.auto_reversing,
je.journal_entry_misstatement_type_KEY,
je.schedule_m3_tax_code_attribute_KEY
FROM dbo.GL_Transaction AS glt
INNER JOIN dbo.GL_Transaction_N_Journal_Entry AS nje
ON glt.gl_transaction_KEY = nje.gl_transaction_KEY
INNER JOIN dbo.Journal_Entry AS je
ON nje.journal_entry_KEY = je.journal_entry_KEY
INNER JOIN dbo.Journal_Entry_Distribution AS jed
ON nje.journal_entry_KEY = jed.journal_entry_KEY
;