f46ba8cadc
style(admin): increase max-width of admin page and adjust table styles fix(n8n): enhance workflow import and publishing process fix(workflows): update SQL queries for fetching and updating sales orders feat(migrations): normalize rental types and enhance email guard for individuell rentals feat(migrations): add RPC for updating deposit in sales orders fix(migrations): ensure individuell orders persist net/vat components and backfill existing records test: update last run status to failed
30 lines
992 B
PL/PgSQL
30 lines
992 B
PL/PgSQL
-- 14-sales-order-set-deposit.sql
|
|
-- Adds sales_order_set_deposit RPC for updating deposit from admin pricing tab.
|
|
|
|
-- =============================================================================
|
|
-- A. RPC: sales_order_set_deposit
|
|
-- =============================================================================
|
|
|
|
create or replace function public.sales_order_set_deposit(p_so_id uuid, p_deposit_eur integer)
|
|
returns void
|
|
language plpgsql
|
|
security invoker
|
|
as $$
|
|
begin
|
|
update public.sales_orders
|
|
set deposit_eur = p_deposit_eur, updated_at = now()
|
|
where id = p_so_id;
|
|
if not found then
|
|
raise exception 'sales order % not found', p_so_id;
|
|
end if;
|
|
end;
|
|
$$;
|
|
|
|
grant execute on function public.sales_order_set_deposit(uuid, integer) to authenticated;
|
|
|
|
-- =============================================================================
|
|
-- B. Schema reload
|
|
-- =============================================================================
|
|
|
|
notify pgrst, 'reload schema';
|