Resolved trigger issue for payment/ihb numbers.

This commit is contained in:
Patrick Fic
2021-02-24 11:53:42 -08:00
parent 25869368b9
commit 7f02c130a2
4 changed files with 23 additions and 0 deletions

View File

@@ -0,0 +1 @@
[]

View File

@@ -0,0 +1,10 @@
- args:
cascade: false
read_only: false
sql: "CREATE OR REPLACE FUNCTION public.assign_payment_number()\n RETURNS trigger\n
LANGUAGE plpgsql\nAS $function$\nBEGIN\n\tIF (new.paymentnum IS NULL\n\t\tOR
new.paymentnum = 'pnew') THEN\n\tUPDATE\n\t\tcounters\n\tSET\n\t\tcount = count
+ 1\n\tWHERE\n\t\tshopid = (\n\t\t\tSELECT\n\t\t\t\tshopid\n\t\t\tFROM\n\t\t\t\tjobs\n\t\t\tWHERE\n\t\t\t\tjobs.id
= new.jobid)\n\t\t\tAND countertype = 'paymentnum'\n\t\tRETURNING\n\t\t\tconcat(prefix,
count) INTO new.paymentnum;\nEND IF;\n\tRETURN NEW;\nEND;\n$function$;"
type: run_sql

View File

@@ -0,0 +1 @@
[]

View File

@@ -0,0 +1,11 @@
- 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