
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE procedure [dbo].[p_acc_cts_bordereaux_select]
	@branch_id		int,
	@date_from		date,
	@date_to		date,
	@table_code_short type_table_code_short READONLY
as

	set nocount on;
	
	-- acc_bordereaux, acc_account
	select	b.ctsb_bordereau_id,
			vir_branch_code = a.act_internal_reference,
			b.ctsb_type_code,
			b.ctsb_user_code,
			b.ctsb_operation_utc_date,
			b.ctsb_reference_date,
			b.ctsb_currency_code
	from	acc_cts_bordereaux b
			inner join act_actors a on a.act_actor_id = b.ctsb_branch_id 
	where	b.ctsb_branch_id = @branch_id
	and		b.ctsb_reference_date between @date_from and @date_to 
	and		b.ctsb_type_code in ( select t.code_short from @table_code_short t)

GO
