SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE PROCEDURE [dbo].[p_acc_invoices_print]
	@invoice_id INT
AS
	SET NOCOUNT ON;

	SELECT	v.pols_number, 
			v.pols_policy_situation_id,
			v.pols_policy_id,
			v.pol_client_id,				
			v.pol_branch_id,
			cli_culture_code,
			isnull(clt.clt_language_code,'en-US') AS clt_language_code
			
	FROM	vw_acc_invoices_clients_policy v
			
			INNER JOIN act_clients c	ON c.cli_actor_id = v.pol_client_id
			LEFT JOIN md_cultures clt	ON clt.clt_culture_code = c.cli_culture_code

	WHERE	v.inv_invoice_id = @invoice_id ;


	-- risques
	SELECT	DISTINCT rs.riss_risk_id, rs.riss_risk_situation_id 
	FROM	acc_invoices_risks_situations a
			INNER JOIN ris_risks_situations rs	ON rs.riss_risk_situation_id = a.invris_risk_situation_id
	WHERE	a.invris_invoice_id = @invoice_id



	


	
GO
