Added in house invoice numbering to database triggers IO-460

This commit is contained in:
Patrick Fic
2020-12-23 08:44:18 -08:00
parent a0d90d2b1f
commit c8532f668b
31 changed files with 354 additions and 3 deletions

View File

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

View File

@@ -0,0 +1,11 @@
- args:
cascade: true
read_only: false
sql: "CREATE OR REPLACE FUNCTION public.assign_ibh_number()\r\n RETURNS trigger\r\n
LANGUAGE plpgsql\r\nAS $function$\r\n begin\r\n IF NEW.isinhouse
= true and (new.invoice_number is null or new.invoice_number = '') THEN\r\n
\ UPDATE counters\r\n\tSET count = count + 1\r\n\tfrom jobs\r\n\twhere
jobs.id=new.jobid and counters.shopid = jobs.shopid AND countertype = 'ihbnum'\r\n\tRETURNING
concat(prefix,count) into new.invoice_number;\r\n\r\n END IF;\r\n RETURN
NEW;\r\n END;\r\n $function$\r\n;"
type: run_sql