IO-3065 All manual toggle to include $0 line in part status count.
This commit is contained in:
@@ -2997,6 +2997,7 @@
|
||||
- est_seq
|
||||
- glass_flag
|
||||
- id
|
||||
- include_in_part_cnt
|
||||
- ioucreated
|
||||
- jobid
|
||||
- lbr_amt
|
||||
@@ -3066,6 +3067,7 @@
|
||||
- est_seq
|
||||
- glass_flag
|
||||
- id
|
||||
- include_in_part_cnt
|
||||
- ioucreated
|
||||
- jobid
|
||||
- lbr_amt
|
||||
@@ -3146,6 +3148,7 @@
|
||||
- est_seq
|
||||
- glass_flag
|
||||
- id
|
||||
- include_in_part_cnt
|
||||
- ioucreated
|
||||
- jobid
|
||||
- lbr_amt
|
||||
|
||||
@@ -39,50 +39,50 @@ END;
|
||||
$$;
|
||||
CREATE FUNCTION public.assign_ro_number() RETURNS trigger
|
||||
LANGUAGE plpgsql
|
||||
AS $$
|
||||
begin
|
||||
IF NEW.converted = true and (new.ro_number is null or new.ro_number = '') THEN
|
||||
UPDATE counters
|
||||
SET count = count + 1 where shopid=new.shopid AND countertype = 'ronum'
|
||||
RETURNING concat(prefix,count) into new.ro_number;
|
||||
END IF;
|
||||
RETURN NEW;
|
||||
END;
|
||||
AS $$
|
||||
begin
|
||||
IF NEW.converted = true and (new.ro_number is null or new.ro_number = '') THEN
|
||||
UPDATE counters
|
||||
SET count = count + 1 where shopid=new.shopid AND countertype = 'ronum'
|
||||
RETURNING concat(prefix,count) into new.ro_number;
|
||||
END IF;
|
||||
RETURN NEW;
|
||||
END;
|
||||
$$;
|
||||
CREATE FUNCTION public.audit_trigger() RETURNS trigger
|
||||
LANGUAGE plpgsql SECURITY DEFINER
|
||||
AS $$
|
||||
DECLARE
|
||||
shopid uuid ;
|
||||
email text;
|
||||
BEGIN
|
||||
select b.id, u.email INTO shopid, email from users u join associations a on u.email = a.useremail join bodyshops b on b.id = a.shopid where u.authid = current_setting('hasura.user', 't')::jsonb->>'x-hasura-user-id' and a.active = true;
|
||||
IF TG_OP = 'INSERT'
|
||||
THEN
|
||||
INSERT INTO public.audit_trail (tabname, schemaname, operation, new_val, recordid, bodyshopid, useremail)
|
||||
VALUES (TG_RELNAME, TG_TABLE_SCHEMA, TG_OP, row_to_json(NEW), NEW.id, shopid, email);
|
||||
RETURN NEW;
|
||||
ELSIF TG_OP = 'UPDATE'
|
||||
THEN
|
||||
INSERT INTO public.audit_trail (tabname, schemaname, operation, old_val, new_val, recordid, bodyshopid, useremail)
|
||||
VALUES (TG_RELNAME, TG_TABLE_SCHEMA, TG_OP,
|
||||
json_diff(to_jsonb(OLD), to_jsonb(NEW)) , json_diff(to_jsonb(NEW), to_jsonb(OLD)), OLD.id, shopid, email);
|
||||
RETURN NEW;
|
||||
ELSIF TG_OP = 'DELETE'
|
||||
THEN
|
||||
INSERT INTO public.audit_trail (tabname, schemaname, operation, old_val, recordid, bodyshopid, useremail)
|
||||
VALUES (TG_RELNAME, TG_TABLE_SCHEMA, TG_OP, row_to_json(OLD), OLD.ID, shopid, email);
|
||||
RETURN OLD;
|
||||
END IF;
|
||||
END;
|
||||
AS $$
|
||||
DECLARE
|
||||
shopid uuid ;
|
||||
email text;
|
||||
BEGIN
|
||||
select b.id, u.email INTO shopid, email from users u join associations a on u.email = a.useremail join bodyshops b on b.id = a.shopid where u.authid = current_setting('hasura.user', 't')::jsonb->>'x-hasura-user-id' and a.active = true;
|
||||
IF TG_OP = 'INSERT'
|
||||
THEN
|
||||
INSERT INTO public.audit_trail (tabname, schemaname, operation, new_val, recordid, bodyshopid, useremail)
|
||||
VALUES (TG_RELNAME, TG_TABLE_SCHEMA, TG_OP, row_to_json(NEW), NEW.id, shopid, email);
|
||||
RETURN NEW;
|
||||
ELSIF TG_OP = 'UPDATE'
|
||||
THEN
|
||||
INSERT INTO public.audit_trail (tabname, schemaname, operation, old_val, new_val, recordid, bodyshopid, useremail)
|
||||
VALUES (TG_RELNAME, TG_TABLE_SCHEMA, TG_OP,
|
||||
json_diff(to_jsonb(OLD), to_jsonb(NEW)) , json_diff(to_jsonb(NEW), to_jsonb(OLD)), OLD.id, shopid, email);
|
||||
RETURN NEW;
|
||||
ELSIF TG_OP = 'DELETE'
|
||||
THEN
|
||||
INSERT INTO public.audit_trail (tabname, schemaname, operation, old_val, recordid, bodyshopid, useremail)
|
||||
VALUES (TG_RELNAME, TG_TABLE_SCHEMA, TG_OP, row_to_json(OLD), OLD.ID, shopid, email);
|
||||
RETURN OLD;
|
||||
END IF;
|
||||
END;
|
||||
$$;
|
||||
CREATE FUNCTION public.json_diff(l jsonb, r jsonb) RETURNS jsonb
|
||||
LANGUAGE sql
|
||||
AS $$
|
||||
SELECT jsonb_object_agg(a.key, a.value) FROM
|
||||
( SELECT key, value FROM jsonb_each(l) ) a LEFT OUTER JOIN
|
||||
( SELECT key, value FROM jsonb_each(r) ) b ON a.key = b.key
|
||||
WHERE a.value != b.value OR b.key IS NULL;
|
||||
AS $$
|
||||
SELECT jsonb_object_agg(a.key, a.value) FROM
|
||||
( SELECT key, value FROM jsonb_each(l) ) a LEFT OUTER JOIN
|
||||
( SELECT key, value FROM jsonb_each(r) ) b ON a.key = b.key
|
||||
WHERE a.value != b.value OR b.key IS NULL;
|
||||
$$;
|
||||
CREATE TABLE public.bills (
|
||||
id uuid DEFAULT public.gen_random_uuid() NOT NULL,
|
||||
@@ -211,33 +211,33 @@ CREATE TABLE public.exportlog (
|
||||
);
|
||||
CREATE FUNCTION public.search_exportlog(search text) RETURNS SETOF public.exportlog
|
||||
LANGUAGE plpgsql STABLE
|
||||
AS $$ BEGIN IF search = '' THEN RETURN query
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
exportlog e;
|
||||
ELSE RETURN query
|
||||
SELECT
|
||||
e.*
|
||||
FROM
|
||||
exportlog e
|
||||
LEFT JOIN jobs j on j.id = e.jobid
|
||||
LEFT JOIN payments p
|
||||
ON p.id = e.paymentid
|
||||
LEFT JOIN bills b
|
||||
ON e.billid = b.id
|
||||
WHERE
|
||||
(
|
||||
j.ro_number ILIKE '%' || search || '%'
|
||||
OR b.invoice_number ILIKE '%' || search || '%'
|
||||
OR p.paymentnum ILIKE '%' || search || '%'
|
||||
OR e.useremail ILIKE '%' || search || '%'
|
||||
)
|
||||
AND (e.jobid = j.id
|
||||
or e.paymentid = p.id
|
||||
or e.billid = b.id)
|
||||
;
|
||||
END IF;
|
||||
AS $$ BEGIN IF search = '' THEN RETURN query
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
exportlog e;
|
||||
ELSE RETURN query
|
||||
SELECT
|
||||
e.*
|
||||
FROM
|
||||
exportlog e
|
||||
LEFT JOIN jobs j on j.id = e.jobid
|
||||
LEFT JOIN payments p
|
||||
ON p.id = e.paymentid
|
||||
LEFT JOIN bills b
|
||||
ON e.billid = b.id
|
||||
WHERE
|
||||
(
|
||||
j.ro_number ILIKE '%' || search || '%'
|
||||
OR b.invoice_number ILIKE '%' || search || '%'
|
||||
OR p.paymentnum ILIKE '%' || search || '%'
|
||||
OR e.useremail ILIKE '%' || search || '%'
|
||||
)
|
||||
AND (e.jobid = j.id
|
||||
or e.paymentid = p.id
|
||||
or e.billid = b.id)
|
||||
;
|
||||
END IF;
|
||||
END $$;
|
||||
CREATE TABLE public.jobs (
|
||||
id uuid DEFAULT public.gen_random_uuid() NOT NULL,
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
-- Could not auto-generate a down migration.
|
||||
-- Please write an appropriate down migration for the SQL below:
|
||||
-- alter table "public"."joblines" add column "include_in_part_cnt" boolean
|
||||
-- not null default 'false';
|
||||
@@ -0,0 +1,2 @@
|
||||
alter table "public"."joblines" add column "include_in_part_cnt" boolean
|
||||
not null default 'false';
|
||||
10
hasura/migrations/1736890690896_run_sql_migration/down.sql
Normal file
10
hasura/migrations/1736890690896_run_sql_migration/down.sql
Normal file
@@ -0,0 +1,10 @@
|
||||
-- Could not auto-generate a down migration.
|
||||
-- Please write an appropriate down migration for the SQL below:
|
||||
-- CREATE OR REPLACE VIEW "public"."joblines_status" AS
|
||||
-- SELECT j.jobid,
|
||||
-- j.status,
|
||||
-- count(1) AS count,
|
||||
-- j.part_type
|
||||
-- FROM joblines j
|
||||
-- WHERE ((j.part_type IS NOT NULL) AND (j.part_type <> 'PAE'::text) AND (j.part_type <> 'PAS'::text) AND (j.part_type <> 'PASL'::text) AND ((j.part_qty)::numeric <> (0)::numeric) AND ((j.act_price <> (0)::numeric) OR (j.include_in_part_cnt is TRUE))AND (j.removed IS FALSE))
|
||||
-- GROUP BY j.jobid, j.status, j.part_type;
|
||||
8
hasura/migrations/1736890690896_run_sql_migration/up.sql
Normal file
8
hasura/migrations/1736890690896_run_sql_migration/up.sql
Normal file
@@ -0,0 +1,8 @@
|
||||
CREATE OR REPLACE VIEW "public"."joblines_status" AS
|
||||
SELECT j.jobid,
|
||||
j.status,
|
||||
count(1) AS count,
|
||||
j.part_type
|
||||
FROM joblines j
|
||||
WHERE ((j.part_type IS NOT NULL) AND (j.part_type <> 'PAE'::text) AND (j.part_type <> 'PAS'::text) AND (j.part_type <> 'PASL'::text) AND ((j.part_qty)::numeric <> (0)::numeric) AND ((j.act_price <> (0)::numeric) OR (j.include_in_part_cnt is TRUE))AND (j.removed IS FALSE))
|
||||
GROUP BY j.jobid, j.status, j.part_type;
|
||||
10
hasura/migrations/1736890701752_run_sql_migration/down.sql
Normal file
10
hasura/migrations/1736890701752_run_sql_migration/down.sql
Normal file
@@ -0,0 +1,10 @@
|
||||
-- Could not auto-generate a down migration.
|
||||
-- Please write an appropriate down migration for the SQL below:
|
||||
-- CREATE OR REPLACE VIEW "public"."joblines_status" AS
|
||||
-- SELECT j.jobid,
|
||||
-- j.status,
|
||||
-- count(1) AS count,
|
||||
-- j.part_type
|
||||
-- FROM joblines j
|
||||
-- WHERE ((j.part_type IS NOT NULL) AND (j.part_type <> 'PAE'::text) AND (j.part_type <> 'PAS'::text) AND (j.part_type <> 'PASL'::text) AND ((j.part_qty)::numeric <> (0)::numeric) AND ((j.act_price <> (0)::numeric) OR (j.include_in_part_cnt is TRUE))AND (j.removed IS FALSE))
|
||||
-- GROUP BY j.jobid, j.status, j.part_type;
|
||||
8
hasura/migrations/1736890701752_run_sql_migration/up.sql
Normal file
8
hasura/migrations/1736890701752_run_sql_migration/up.sql
Normal file
@@ -0,0 +1,8 @@
|
||||
CREATE OR REPLACE VIEW "public"."joblines_status" AS
|
||||
SELECT j.jobid,
|
||||
j.status,
|
||||
count(1) AS count,
|
||||
j.part_type
|
||||
FROM joblines j
|
||||
WHERE ((j.part_type IS NOT NULL) AND (j.part_type <> 'PAE'::text) AND (j.part_type <> 'PAS'::text) AND (j.part_type <> 'PASL'::text) AND ((j.part_qty)::numeric <> (0)::numeric) AND ((j.act_price <> (0)::numeric) OR (j.include_in_part_cnt is TRUE))AND (j.removed IS FALSE))
|
||||
GROUP BY j.jobid, j.status, j.part_type;
|
||||
@@ -39,50 +39,50 @@ END;
|
||||
$$;
|
||||
CREATE FUNCTION public.assign_ro_number() RETURNS trigger
|
||||
LANGUAGE plpgsql
|
||||
AS $$
|
||||
begin
|
||||
IF NEW.converted = true and (new.ro_number is null or new.ro_number = '') THEN
|
||||
UPDATE counters
|
||||
SET count = count + 1 where shopid=new.shopid AND countertype = 'ronum'
|
||||
RETURNING concat(prefix,count) into new.ro_number;
|
||||
END IF;
|
||||
RETURN NEW;
|
||||
END;
|
||||
AS $$
|
||||
begin
|
||||
IF NEW.converted = true and (new.ro_number is null or new.ro_number = '') THEN
|
||||
UPDATE counters
|
||||
SET count = count + 1 where shopid=new.shopid AND countertype = 'ronum'
|
||||
RETURNING concat(prefix,count) into new.ro_number;
|
||||
END IF;
|
||||
RETURN NEW;
|
||||
END;
|
||||
$$;
|
||||
CREATE FUNCTION public.audit_trigger() RETURNS trigger
|
||||
LANGUAGE plpgsql SECURITY DEFINER
|
||||
AS $$
|
||||
DECLARE
|
||||
shopid uuid ;
|
||||
email text;
|
||||
BEGIN
|
||||
select b.id, u.email INTO shopid, email from users u join associations a on u.email = a.useremail join bodyshops b on b.id = a.shopid where u.authid = current_setting('hasura.user', 't')::jsonb->>'x-hasura-user-id' and a.active = true;
|
||||
IF TG_OP = 'INSERT'
|
||||
THEN
|
||||
INSERT INTO public.audit_trail (tabname, schemaname, operation, new_val, recordid, bodyshopid, useremail)
|
||||
VALUES (TG_RELNAME, TG_TABLE_SCHEMA, TG_OP, row_to_json(NEW), NEW.id, shopid, email);
|
||||
RETURN NEW;
|
||||
ELSIF TG_OP = 'UPDATE'
|
||||
THEN
|
||||
INSERT INTO public.audit_trail (tabname, schemaname, operation, old_val, new_val, recordid, bodyshopid, useremail)
|
||||
VALUES (TG_RELNAME, TG_TABLE_SCHEMA, TG_OP,
|
||||
json_diff(to_jsonb(OLD), to_jsonb(NEW)) , json_diff(to_jsonb(NEW), to_jsonb(OLD)), OLD.id, shopid, email);
|
||||
RETURN NEW;
|
||||
ELSIF TG_OP = 'DELETE'
|
||||
THEN
|
||||
INSERT INTO public.audit_trail (tabname, schemaname, operation, old_val, recordid, bodyshopid, useremail)
|
||||
VALUES (TG_RELNAME, TG_TABLE_SCHEMA, TG_OP, row_to_json(OLD), OLD.ID, shopid, email);
|
||||
RETURN OLD;
|
||||
END IF;
|
||||
END;
|
||||
AS $$
|
||||
DECLARE
|
||||
shopid uuid ;
|
||||
email text;
|
||||
BEGIN
|
||||
select b.id, u.email INTO shopid, email from users u join associations a on u.email = a.useremail join bodyshops b on b.id = a.shopid where u.authid = current_setting('hasura.user', 't')::jsonb->>'x-hasura-user-id' and a.active = true;
|
||||
IF TG_OP = 'INSERT'
|
||||
THEN
|
||||
INSERT INTO public.audit_trail (tabname, schemaname, operation, new_val, recordid, bodyshopid, useremail)
|
||||
VALUES (TG_RELNAME, TG_TABLE_SCHEMA, TG_OP, row_to_json(NEW), NEW.id, shopid, email);
|
||||
RETURN NEW;
|
||||
ELSIF TG_OP = 'UPDATE'
|
||||
THEN
|
||||
INSERT INTO public.audit_trail (tabname, schemaname, operation, old_val, new_val, recordid, bodyshopid, useremail)
|
||||
VALUES (TG_RELNAME, TG_TABLE_SCHEMA, TG_OP,
|
||||
json_diff(to_jsonb(OLD), to_jsonb(NEW)) , json_diff(to_jsonb(NEW), to_jsonb(OLD)), OLD.id, shopid, email);
|
||||
RETURN NEW;
|
||||
ELSIF TG_OP = 'DELETE'
|
||||
THEN
|
||||
INSERT INTO public.audit_trail (tabname, schemaname, operation, old_val, recordid, bodyshopid, useremail)
|
||||
VALUES (TG_RELNAME, TG_TABLE_SCHEMA, TG_OP, row_to_json(OLD), OLD.ID, shopid, email);
|
||||
RETURN OLD;
|
||||
END IF;
|
||||
END;
|
||||
$$;
|
||||
CREATE FUNCTION public.json_diff(l jsonb, r jsonb) RETURNS jsonb
|
||||
LANGUAGE sql
|
||||
AS $$
|
||||
SELECT jsonb_object_agg(a.key, a.value) FROM
|
||||
( SELECT key, value FROM jsonb_each(l) ) a LEFT OUTER JOIN
|
||||
( SELECT key, value FROM jsonb_each(r) ) b ON a.key = b.key
|
||||
WHERE a.value != b.value OR b.key IS NULL;
|
||||
AS $$
|
||||
SELECT jsonb_object_agg(a.key, a.value) FROM
|
||||
( SELECT key, value FROM jsonb_each(l) ) a LEFT OUTER JOIN
|
||||
( SELECT key, value FROM jsonb_each(r) ) b ON a.key = b.key
|
||||
WHERE a.value != b.value OR b.key IS NULL;
|
||||
$$;
|
||||
CREATE TABLE public.bills (
|
||||
id uuid DEFAULT public.gen_random_uuid() NOT NULL,
|
||||
@@ -211,33 +211,33 @@ CREATE TABLE public.exportlog (
|
||||
);
|
||||
CREATE FUNCTION public.search_exportlog(search text) RETURNS SETOF public.exportlog
|
||||
LANGUAGE plpgsql STABLE
|
||||
AS $$ BEGIN IF search = '' THEN RETURN query
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
exportlog e;
|
||||
ELSE RETURN query
|
||||
SELECT
|
||||
e.*
|
||||
FROM
|
||||
exportlog e
|
||||
LEFT JOIN jobs j on j.id = e.jobid
|
||||
LEFT JOIN payments p
|
||||
ON p.id = e.paymentid
|
||||
LEFT JOIN bills b
|
||||
ON e.billid = b.id
|
||||
WHERE
|
||||
(
|
||||
j.ro_number ILIKE '%' || search || '%'
|
||||
OR b.invoice_number ILIKE '%' || search || '%'
|
||||
OR p.paymentnum ILIKE '%' || search || '%'
|
||||
OR e.useremail ILIKE '%' || search || '%'
|
||||
)
|
||||
AND (e.jobid = j.id
|
||||
or e.paymentid = p.id
|
||||
or e.billid = b.id)
|
||||
;
|
||||
END IF;
|
||||
AS $$ BEGIN IF search = '' THEN RETURN query
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
exportlog e;
|
||||
ELSE RETURN query
|
||||
SELECT
|
||||
e.*
|
||||
FROM
|
||||
exportlog e
|
||||
LEFT JOIN jobs j on j.id = e.jobid
|
||||
LEFT JOIN payments p
|
||||
ON p.id = e.paymentid
|
||||
LEFT JOIN bills b
|
||||
ON e.billid = b.id
|
||||
WHERE
|
||||
(
|
||||
j.ro_number ILIKE '%' || search || '%'
|
||||
OR b.invoice_number ILIKE '%' || search || '%'
|
||||
OR p.paymentnum ILIKE '%' || search || '%'
|
||||
OR e.useremail ILIKE '%' || search || '%'
|
||||
)
|
||||
AND (e.jobid = j.id
|
||||
or e.paymentid = p.id
|
||||
or e.billid = b.id)
|
||||
;
|
||||
END IF;
|
||||
END $$;
|
||||
CREATE TABLE public.jobs (
|
||||
id uuid DEFAULT public.gen_random_uuid() NOT NULL,
|
||||
|
||||
Reference in New Issue
Block a user