Merge in EULA changes & update to AR Tracking schema.

This commit is contained in:
Patrick Fic
2024-01-22 11:52:42 -08:00
parent 9274742520
commit d61ed03ef1
13 changed files with 119 additions and 3 deletions

View File

@@ -2442,7 +2442,7 @@
_eq: X-Hasura-User-Id
columns:
- address
- buisness_name
- business_name
- date_accepted
- eulaid
- first_name
@@ -2454,7 +2454,7 @@
permission:
columns:
- address
- buisness_name
- business_name
- first_name
- last_name
- phone_number
@@ -2676,6 +2676,31 @@
- table:
name: job_ar_schema
schema: public
object_relationships:
- name: job
using:
foreign_key_constraint_on: id
select_permissions:
- role: user
permission:
columns:
- id
- ro_number
- clm_total
- total_payments
- balance
- date_invoiced
- shopid
filter:
job:
bodyshop:
associations:
_and:
- active:
_eq: true
- user:
authid:
_eq: X-Hasura-User-Id
- table:
name: job_conversations
schema: public
@@ -4164,11 +4189,16 @@
- name: job_status_transition
definition:
enable_manual: true
insert:
columns: '*'
update:
columns:
- status
retry_conf:
interval_sec: 10
num_retries: 0
timeout_sec: 60
webhook_from_env: HASURA_API_URL
webhook: https://worktest.home.irony.online
headers:
- name: event-secret
value_from_env: EVENT_SECRET

View File

@@ -0,0 +1 @@
alter table "public"."eula_acceptances" rename column "business_name" to "buisness_name";

View File

@@ -0,0 +1 @@
alter table "public"."eula_acceptances" rename column "buisness_name" to "business_name";

View File

@@ -0,0 +1 @@
alter table "public"."eula_acceptances" alter column "phone_number" set not null;

View File

@@ -0,0 +1 @@
alter table "public"."eula_acceptances" alter column "phone_number" drop not null;

View File

@@ -0,0 +1 @@
alter table "public"."eula_acceptances" alter column "address" set not null;

View File

@@ -0,0 +1 @@
alter table "public"."eula_acceptances" alter column "address" drop not null;

View File

@@ -0,0 +1,4 @@
-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- alter table "public"."job_ar_schema" add column "shopid" uuid
-- null;

View File

@@ -0,0 +1,2 @@
alter table "public"."job_ar_schema" add column "shopid" uuid
null;

View File

@@ -0,0 +1 @@
alter table "public"."job_ar_schema" drop constraint "job_ar_schema_id_fkey";

View File

@@ -0,0 +1,5 @@
alter table "public"."job_ar_schema"
add constraint "job_ar_schema_id_fkey"
foreign key ("id")
references "public"."jobs"
("id") on update restrict on delete restrict;

View File

@@ -0,0 +1,35 @@
-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- CREATE OR REPLACE FUNCTION public.jobs_ar_summary ()
-- RETURNS SETOF job_ar_schema
-- LANGUAGE plpgsql
-- STABLE
-- AS $function$
-- BEGIN
--
-- RETURN query
-- select
-- j.id,
-- j.ro_number,
-- j.clm_total,
-- coalesce (p.total_payments,0) as total_payments,
-- j.clm_total - coalesce (p.total_payments,0) as balance,
-- j.date_invoiced,
-- j.shopid
-- from
-- jobs j
-- left join (
-- select
-- p.jobid,
-- coalesce (sum(p.amount),0) as total_payments
-- from
-- payments p
-- group by
-- p.jobid
-- ) p on
-- j.id = p.jobid
-- where j.remove_from_ar = false and j.date_invoiced is not null and j.clm_total - coalesce (p.total_payments,0) > 0;
--
--
-- END
-- $function$;

View File

@@ -0,0 +1,33 @@
CREATE OR REPLACE FUNCTION public.jobs_ar_summary ()
RETURNS SETOF job_ar_schema
LANGUAGE plpgsql
STABLE
AS $function$
BEGIN
RETURN query
select
j.id,
j.ro_number,
j.clm_total,
coalesce (p.total_payments,0) as total_payments,
j.clm_total - coalesce (p.total_payments,0) as balance,
j.date_invoiced,
j.shopid
from
jobs j
left join (
select
p.jobid,
coalesce (sum(p.amount),0) as total_payments
from
payments p
group by
p.jobid
) p on
j.id = p.jobid
where j.remove_from_ar = false and j.date_invoiced is not null and j.clm_total - coalesce (p.total_payments,0) > 0;
END
$function$;