Resolved trigger issue for payment/ihb numbers.
This commit is contained in:
@@ -0,0 +1 @@
|
||||
[]
|
||||
10
hasura/migrations/1614196246406_run_sql_migration/up.yaml
Normal file
10
hasura/migrations/1614196246406_run_sql_migration/up.yaml
Normal 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
|
||||
@@ -0,0 +1 @@
|
||||
[]
|
||||
11
hasura/migrations/1614196402453_run_sql_migration/up.yaml
Normal file
11
hasura/migrations/1614196402453_run_sql_migration/up.yaml
Normal 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
|
||||
Reference in New Issue
Block a user