
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE PROCEDURE [dbo].[p_acc_account_solde_by_client_id]
	@client_id int 									-- id de l'acteur
	
AS

	/*
	Solde du client
	*/

	select	a.a_currency_code, vir_solde = sum(a.a_amount)
	from	acc_accounts a
			left join acc_invoices i on i.inv_invoice_id = a.a_account_id 
	where	a.a_actor_id = @client_id
	and		a_type_code != 'A'								-- les acomptes sont "hors solde"
	and		isnull(i.inv_operation_code__last, '') not in ('CR', 'INF', 'AWR', 'AN')	-- DGE 14/09/2024 - 0001287: Solde client erroné (#6271) - exclure les AN
	group by a_currency_code

GO
