View: dbo.GL_Transaction_Detail__Payroll_Check_Worker_Compensation_Expense__View
View definition
`-- SUMMARY -- This view produces ledger entries that debit the payroll check worker compensation expense accounts. CREATE VIEW dbo.GL_Transaction_Detail__Payroll_Check_Worker_Compensation_Expense__View AS select pbtwcid.payroll_bank_transaction_worker_compensation_item_distribution_KEY , pbtwci.bank_transaction_KEY , bt.checkbook_KEY , wc.client_KEY , pbtwcid.expense__gl_account_KEY AS gl_account_KEY , 1 /* Debit */ as gl_balance_effect_KEY , glt.gl_period_KEY , pbtwcid.premium_amount as gl_transaction_amount , bt.transaction_date as gl_transaction_date , bt.description as gl_transaction_description , left(wccc.description, 120) AS gl_transaction_detail_description , glt.gl_transaction_KEY , bt.reference_number as gl_transaction_reference_number , bt.reference_number_sortable as gl_transaction_reference_number_sortable , CAST(13 AS TINYINT) AS gl_transaction_source_expression_KEY -- GLTransactionSourceExpression.PayrollCheckWorkerCompensationExpense , 2 as gl_transaction_source_KEY -- GLTransactionSource.BankTransaction , bt.bank_transaction_type_KEY as gl_transaction_type_KEY , 0 as is_activity_journal_entry , 101 /* Regular */ as journal_entry_type_KEY , glt.journal_KEY , 1 as source_was_a_distribution , bt.transaction_status_KEY , 0 as sequence_number from dbo.Payroll_Bank_Transaction_Worker_Compensation_Item AS pbtwci inner join dbo.Worker_Compensation as wc on pbtwci.worker_compensation_KEY = wc.worker_compensation_KEY inner join dbo.Worker_Compensation_Class_Code_Detail as wcccd on wc.worker_compensation_class_code_detail_KEY = wcccd.worker_compensation_class_code_detail_KEY inner join dbo.Worker_Compensation_Class_Code as wccc on wcccd.worker_compensation_class_code_KEY = wccc.worker_compensation_class_code_KEY inner join dbo.Bank_Transaction as bt on pbtwci.bank_transaction_KEY = bt.bank_transaction_KEY inner join dbo.Client as c on wc.client_KEY = c.client_KEY inner join dbo.GL_Transaction_N_Bank_Transaction as nbt on pbtwci.bank_transaction_KEY = nbt.bank_transaction_KEY inner join dbo.GL_Transaction as glt on nbt.gl_transaction_KEY = glt.gl_transaction_KEY inner join dbo.Payroll_Bank_Transaction_Worker_Compensation_Item_Distribution as pbtwcid on pbtwci.payroll_bank_transaction_worker_compensation_item_KEY = pbtwcid.payroll_bank_transaction_worker_compensation_item_KEY where bt.bank_transaction_type_KEY = 5 and bt.transaction_status_KEY in (1 /* Live */, 5 /* Unprinted */, 3 /* Voided */, 9 /* ImpoundMemo */, 14 /*ImpoundMemoDeleted*/, 15 /*ImpoundMemoVoided*/) and (bt.data_origin_KEY != 2 -- Payroll Check that came from a CSA client with the TBS or c.csa_client_had_tbs_or_gl_module_marked = 0) -- or GL module marked do not affect accounting. ;`