martes, 28 de agosto de 2018

Get exchange rate in iDempiere

CREATE OR REPLACE FUNCTION adempiere.fnc_hm_gettasacambio(timestamp without time zone)
 RETURNS numeric
 LANGUAGE plpgsql
AS $function$
    DECLARE
    _tasa NUMERIC;
BEGIN
    SELECT
        cr.multiplyrate
    FROM
        adempiere.c_conversion_rate AS cr
    WHERE
        cr.ad_client_id      = 1000000
        AND (cr.c_currency_id=100 AND cr.c_currency_id_to=209)

        AND cr.validfrom     = $1
            INTO _tasa;

    _tasa := COALESCE (_tasa, 1);

    RETURN _tasa;
END;
$function$

No hay comentarios:

Publicar un comentario