forked from brmlab/brmbar-github
0010: lookup item currency id
This commit is contained in:
parent
8ee51a23d9
commit
9d8827ccbd
1 changed files with 9 additions and 2 deletions
|
@ -63,10 +63,17 @@ DECLARE
|
|||
v_cost NUMERIC;
|
||||
v_profit NUMERIC;
|
||||
v_transaction_id public.transactions.id%TYPE;
|
||||
v_item_currency_id public.accounts.currency%TYPE;
|
||||
BEGIN
|
||||
-- Get item's currency
|
||||
SELECT currency
|
||||
INTO v_item_currency_id
|
||||
FROM public.accounts
|
||||
WHERE id=i_item_id;
|
||||
|
||||
-- Get the buy and sell rates from the stored functions
|
||||
v_buy_rate := public.find_buy_rate(i_item_id, i_target_currency_id);
|
||||
v_sell_rate := public.find_sell_rate(i_item_id, i_target_currency_id);
|
||||
v_buy_rate := public.find_buy_rate(v_item_currency_id, i_target_currency_id);
|
||||
v_sell_rate := public.find_sell_rate(v_item_currency_id, i_target_currency_id);
|
||||
|
||||
-- Calculate cost and profit
|
||||
v_cost := i_amount * v_sell_rate;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue