return: integer
lang: plpgsql
parameters:
  p0:
    type: text
    name: _numero_sejour
src: |
  DECLARE
  	_montant_fj integer;
  BEGIN
  
  	SELECT SUM(montant_encours) INTO _montant_fj
  	FROM activite.p_factures_lignes_c
  		JOIN activite.p_factures ON p_factures.no_facture = p_factures_lignes_c.no_facture
  		JOIN activite.t_prestations ON t_prestations.oid = p_factures_lignes_c.prestation_id
  	WHERE p_factures.no_sejour = _numero_sejour
  		AND t_prestations.code = 'FJ'
  	;
  	
  	RETURN _montant_fj
  	;
  END;