0010: fix v_transaction_id

This commit is contained in:
Dominik Pantůček 2025-07-12 18:04:56 +02:00
parent ee2b945299
commit 81366fd2bb

View file

@ -77,17 +77,17 @@ BEGIN
-- the item (decrease stock)
INSERT INTO public.transaction_splits (transaction, side, account, amount, memo)
VALUES (i_transaction_id, 'credit', i_item_id, i_amount,
VALUES (v_transaction_id, 'credit', i_item_id, i_amount,
i_other_memo);
-- the user
INSERT INTO public.transaction_splits (transaction, side, account, amount, memo)
VALUES (i_transaction_id, 'debit', i_user_id, v_cost,
VALUES (v_transaction_id, 'debit', i_user_id, v_cost,
(SELECT "name" FROM public.accounts WHERE id = i_item_id));
-- the profit
INSERT INTO public.transaction_splits (transaction, side, account, amount, memo)
VALUES (i_transaction_id, 'debit', (SELECT account_id FROM accounts WHERE name = 'BrmBar Profits'), v_profit, (SELECT 'Margin on ' || "name" FROM public.accounts WHERE id = i_item_id));
VALUES (v_transaction_id, 'debit', (SELECT account_id FROM accounts WHERE name = 'BrmBar Profits'), v_profit, (SELECT 'Margin on ' || "name" FROM public.accounts WHERE id = i_item_id));
-- Return the cost
RETURN v_cost;