12 lines
612 B
YAML
12 lines
612 B
YAML
- args:
|
|
cascade: false
|
|
read_only: false
|
|
sql: "CREATE OR REPLACE FUNCTION public.assign_ibh_number()\n RETURNS trigger\n
|
|
LANGUAGE plpgsql\nAS $function$\n begin\n IF NEW.isinhouse = true
|
|
and (new.invoice_number is null or new.invoice_number = 'ih') THEN\n UPDATE
|
|
counters\n\tSET count = count + 1\n\twhere shopid = (select shopid from jobs
|
|
where jobs.id = new.jobid)\n\tAND countertype = 'ihbnum'\n\tRETURNING concat(prefix,count)
|
|
into new.invoice_number;\n\n END IF;\n RETURN NEW;\n END;\n
|
|
\ $function$;"
|
|
type: run_sql
|