SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE procedure [dbo].[p_rep_tax_bdx_details]
	@bordereau_id int
as 

	set nocount on;

	select	client_name = c.adr_complete_name, 
			ps.pols_number, 
			i.inv_start_date, i.inv_end_date, i.inv_invoice_id,

			taxes = bdrd_taxes

			-- net à payer - à calculer au niveau de l'état
	from	acc_bordereaux b
			inner join acc_bordereaux_details bd				on	bd.bdrd_bordereau_id = b.bdr_bordereau_id


			inner join acc_invoices i							on	i.inv_invoice_id = bd.bdrd_invoice_id
			inner join pol_policies_situations ps				on	ps.pols_policy_situation_id = i.inv_policy_situation_id
			inner join pol_policies p							on	p.pol_policy_id = ps.pols_policy_id
			inner join vw_act_clients c							on	c.act_actor_id = p.pol_client_id


	where	b.bdr_bordereau_id = @bordereau_id





GO
