forked from brmlab/brmbar-github
0015: find_buy_rate takes currency ID
This commit is contained in:
parent
f962586e3a
commit
76a484ea5e
1 changed files with 8 additions and 5 deletions
|
@ -44,12 +44,15 @@ DECLARE
|
||||||
v_buy_rate NUMERIC;
|
v_buy_rate NUMERIC;
|
||||||
v_cost NUMERIC;
|
v_cost NUMERIC;
|
||||||
v_transaction_id public.transactions.id%TYPE;
|
v_transaction_id public.transactions.id%TYPE;
|
||||||
|
v_item_currency_id public.accounts.currency%TYPE;
|
||||||
BEGIN
|
BEGIN
|
||||||
-- this could fail and it would generate exception in python
|
-- Get item's currency
|
||||||
-- FIXME: convert v_buy_rate < 0 into python exception
|
SELECT currency
|
||||||
v_buy_rate := public.find_buy_rate(i_item_id, i_target_currency_id);
|
INTO STRICT v_item_currency_id
|
||||||
-- this could fail and it would generate exception in python, even though it is not used
|
FROM public.accounts
|
||||||
--v_sell_rate := public.find_sell_rate(i_item_id, i_target_currency_id);
|
WHERE id=i_item_id;
|
||||||
|
-- Get the buy rates from the stored functions
|
||||||
|
v_buy_rate := public.find_buy_rate(v_item_currency_id, i_target_currency_id);
|
||||||
|
|
||||||
-- Calculate cost and profit
|
-- Calculate cost and profit
|
||||||
v_cost := i_amount * v_buy_rate;
|
v_cost := i_amount * v_buy_rate;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue