
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE procedure [dbo].[p_acc_account_clients_by_table_id]
	@table_id type_table_id READONLY
as 
	set nocount on;
	
	/*
	[DGE]
	- la table acc_accounts
	- la table acc_invoices;
	- la struncture de la table acc_invoices_operations
	- la table acc_advances
		*/
	
	select	a.*, ac.cur_use_decimals
	from	acc_accounts a
			inner join @table_id t on t.id = a.a_account_id
			inner join acc_currencies ac on ac.cur_currency_code = a.a_currency_code

	SELECT	i.*
	FROM	acc_invoices i
			INNER JOIN @table_id t on t.id = i.inv_invoice_id 
	
	SELECT	o.*
	FROM	acc_invoices_operations o
	WHERE	1 = 2
	
	SELECT	adv.*
	FROM	acc_advances adv
			INNER JOIN @table_id t on t.id = adv.adv_advance_id



GO
