@@ -106,85 +106,89 @@ export function ProductionListDetail({
|
||||
{error && <AlertComponent error={JSON.stringify(error)} />}
|
||||
{!loading && data && (
|
||||
<div>
|
||||
<Space direction="vertical">
|
||||
<CardTemplate
|
||||
title={t("jobs.labels.employeeassignments")}
|
||||
loading={loading}
|
||||
>
|
||||
<JobEmployeeAssignments job={data.jobs_by_pk} refetch={refetch} />
|
||||
</CardTemplate>
|
||||
<Descriptions bordered column={1}>
|
||||
<Descriptions.Item label={t("jobs.fields.ro_number")}>
|
||||
{theJob.ro_number || ""}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label={t("jobs.fields.alt_transport")}>
|
||||
<Space>
|
||||
{data.jobs_by_pk.alt_transport || ""}
|
||||
<JobAtChange job={data.jobs_by_pk} />
|
||||
</Space>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label={t("jobs.fields.clm_no")}>
|
||||
{theJob.clm_no || ""}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label={t("jobs.fields.ins_co_nm")}>
|
||||
{theJob.ins_co_nm || ""}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label={t("jobs.fields.owner")}>
|
||||
<Space>
|
||||
<OwnerNameDisplay ownerObject={theJob} />
|
||||
{!technician ? (
|
||||
<>
|
||||
<StartChatButton
|
||||
phone={data.jobs_by_pk.ownr_ph1}
|
||||
jobid={data.jobs_by_pk.id}
|
||||
/>
|
||||
<StartChatButton
|
||||
phone={data.jobs_by_pk.ownr_ph2}
|
||||
jobid={data.jobs_by_pk.id}
|
||||
/>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<PhoneNumberFormatter>
|
||||
{data.jobs_by_pk.ownr_ph1}
|
||||
</PhoneNumberFormatter>
|
||||
<PhoneNumberFormatter>
|
||||
{data.jobs_by_pk.ownr_ph2}
|
||||
</PhoneNumberFormatter>
|
||||
</>
|
||||
)}
|
||||
</Space>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label={t("jobs.fields.vehicle")}>
|
||||
{`${theJob.v_model_yr || ""} ${theJob.v_color || ""} ${
|
||||
theJob.v_make_desc || ""
|
||||
} ${theJob.v_model_desc || ""}`}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label={t("jobs.fields.clm_total")}>
|
||||
<CurrencyFormatter>{theJob.clm_total}</CurrencyFormatter>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label={t("jobs.fields.actual_in")}>
|
||||
<DateFormatter>{theJob.actual_in}</DateFormatter>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label={t("jobs.fields.scheduled_completion")}>
|
||||
<DateFormatter>{theJob.scheduled_completion}</DateFormatter>
|
||||
</Descriptions.Item>
|
||||
</Descriptions>
|
||||
<JobDetailCardsPartsComponent
|
||||
loading={loading}
|
||||
data={data ? data.jobs_by_pk : null}
|
||||
/>
|
||||
<JobDetailCardsNotesComponent
|
||||
loading={loading}
|
||||
data={data ? data.jobs_by_pk : null}
|
||||
/>
|
||||
{!bodyshop.uselocalmediaserver && (
|
||||
<CardTemplate
|
||||
title={t("jobs.labels.employeeassignments")}
|
||||
loading={loading}
|
||||
>
|
||||
<JobEmployeeAssignments job={data.jobs_by_pk} refetch={refetch} />
|
||||
</CardTemplate>
|
||||
<div style={{ height: "8px" }} />
|
||||
<Descriptions bordered column={1}>
|
||||
<Descriptions.Item label={t("jobs.fields.ro_number")}>
|
||||
{theJob.ro_number || ""}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label={t("jobs.fields.alt_transport")}>
|
||||
<Space>
|
||||
{data.jobs_by_pk.alt_transport || ""}
|
||||
<JobAtChange job={data.jobs_by_pk} />
|
||||
</Space>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label={t("jobs.fields.clm_no")}>
|
||||
{theJob.clm_no || ""}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label={t("jobs.fields.ins_co_nm")}>
|
||||
{theJob.ins_co_nm || ""}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label={t("jobs.fields.owner")}>
|
||||
<Space>
|
||||
<OwnerNameDisplay ownerObject={theJob} />
|
||||
{!technician ? (
|
||||
<>
|
||||
<StartChatButton
|
||||
phone={data.jobs_by_pk.ownr_ph1}
|
||||
jobid={data.jobs_by_pk.id}
|
||||
/>
|
||||
<StartChatButton
|
||||
phone={data.jobs_by_pk.ownr_ph2}
|
||||
jobid={data.jobs_by_pk.id}
|
||||
/>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<PhoneNumberFormatter>
|
||||
{data.jobs_by_pk.ownr_ph1}
|
||||
</PhoneNumberFormatter>
|
||||
<PhoneNumberFormatter>
|
||||
{data.jobs_by_pk.ownr_ph2}
|
||||
</PhoneNumberFormatter>
|
||||
</>
|
||||
)}
|
||||
</Space>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label={t("jobs.fields.vehicle")}>
|
||||
{`${theJob.v_model_yr || ""} ${theJob.v_color || ""} ${
|
||||
theJob.v_make_desc || ""
|
||||
} ${theJob.v_model_desc || ""}`}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label={t("jobs.fields.clm_total")}>
|
||||
<CurrencyFormatter>{theJob.clm_total}</CurrencyFormatter>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label={t("jobs.fields.actual_in")}>
|
||||
<DateFormatter>{theJob.actual_in}</DateFormatter>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label={t("jobs.fields.scheduled_completion")}>
|
||||
<DateFormatter>{theJob.scheduled_completion}</DateFormatter>
|
||||
</Descriptions.Item>
|
||||
</Descriptions>
|
||||
<div style={{ height: "8px" }} />
|
||||
<JobDetailCardsPartsComponent
|
||||
loading={loading}
|
||||
data={data ? data.jobs_by_pk : null}
|
||||
/>
|
||||
<div style={{ height: "8px" }} />
|
||||
<JobDetailCardsNotesComponent
|
||||
loading={loading}
|
||||
data={data ? data.jobs_by_pk : null}
|
||||
/>
|
||||
{!bodyshop.uselocalmediaserver && (
|
||||
<>
|
||||
<div style={{ height: "8px" }} />
|
||||
<JobDetailCardsDocumentsComponent
|
||||
loading={loading}
|
||||
data={data ? data.jobs_by_pk : null}
|
||||
/>
|
||||
)}
|
||||
</Space>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</Drawer>
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
- function:
|
||||
name: jobs_ar_summary
|
||||
schema: public
|
||||
- function:
|
||||
name: search_bills
|
||||
schema: public
|
||||
|
||||
@@ -2673,6 +2673,9 @@
|
||||
- table:
|
||||
name: ioevents
|
||||
schema: public
|
||||
- table:
|
||||
name: job_ar_schema
|
||||
schema: public
|
||||
- table:
|
||||
name: job_conversations
|
||||
schema: public
|
||||
@@ -3812,6 +3815,7 @@
|
||||
- referral_source
|
||||
- referral_source_extra
|
||||
- regie_number
|
||||
- remove_from_ar
|
||||
- ro_number
|
||||
- scheduled_completion
|
||||
- scheduled_delivery
|
||||
@@ -4093,6 +4097,7 @@
|
||||
- referral_source
|
||||
- referral_source_extra
|
||||
- regie_number
|
||||
- remove_from_ar
|
||||
- ro_number
|
||||
- scheduled_completion
|
||||
- scheduled_delivery
|
||||
|
||||
33
hasura/migrations/1705693552101_run_sql_migration/down.sql
Normal file
33
hasura/migrations/1705693552101_run_sql_migration/down.sql
Normal file
@@ -0,0 +1,33 @@
|
||||
-- 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 jobs
|
||||
-- LANGUAGE plpgsql
|
||||
-- STABLE
|
||||
-- AS $function$
|
||||
-- BEGIN
|
||||
--
|
||||
-- RETURN query
|
||||
-- select
|
||||
-- j.id,
|
||||
-- j.shopid,
|
||||
-- j.ro_number,
|
||||
-- j.clm_total,
|
||||
-- p.total_payments,
|
||||
-- j.clm_total - p.total_payments as balance
|
||||
-- from
|
||||
-- jobs j
|
||||
-- left join (
|
||||
-- select
|
||||
-- p.jobid,
|
||||
-- sum(p.amount) as total_payments
|
||||
-- from
|
||||
-- payments p
|
||||
-- group by
|
||||
-- p.jobid
|
||||
-- ) p on
|
||||
-- j.id = p.jobid ;
|
||||
--
|
||||
--
|
||||
-- END
|
||||
-- $function$;
|
||||
31
hasura/migrations/1705693552101_run_sql_migration/up.sql
Normal file
31
hasura/migrations/1705693552101_run_sql_migration/up.sql
Normal file
@@ -0,0 +1,31 @@
|
||||
CREATE OR REPLACE FUNCTION public.jobs_ar_summary ()
|
||||
RETURNS SETOF jobs
|
||||
LANGUAGE plpgsql
|
||||
STABLE
|
||||
AS $function$
|
||||
BEGIN
|
||||
|
||||
RETURN query
|
||||
select
|
||||
j.id,
|
||||
j.shopid,
|
||||
j.ro_number,
|
||||
j.clm_total,
|
||||
p.total_payments,
|
||||
j.clm_total - p.total_payments as balance
|
||||
from
|
||||
jobs j
|
||||
left join (
|
||||
select
|
||||
p.jobid,
|
||||
sum(p.amount) as total_payments
|
||||
from
|
||||
payments p
|
||||
group by
|
||||
p.jobid
|
||||
) p on
|
||||
j.id = p.jobid ;
|
||||
|
||||
|
||||
END
|
||||
$function$;
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE "public"."job_ar_schema";
|
||||
@@ -0,0 +1 @@
|
||||
CREATE TABLE "public"."job_ar_schema" ("id" uuid NOT NULL, "ro_number" text, "clm_total" numeric NOT NULL, "total_payments" numeric NOT NULL DEFAULT 0, "balance" numeric NOT NULL DEFAULT 0, PRIMARY KEY ("id") );
|
||||
34
hasura/migrations/1705693896379_run_sql_migration/down.sql
Normal file
34
hasura/migrations/1705693896379_run_sql_migration/down.sql
Normal file
@@ -0,0 +1,34 @@
|
||||
-- Could not auto-generate a down migration.
|
||||
-- Please write an appropriate down migration for the SQL below:
|
||||
-- DROP FUNCTION public.jobs_ar_summary;
|
||||
--
|
||||
-- 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,
|
||||
-- p.total_payments,
|
||||
-- j.clm_total - p.total_payments as balance
|
||||
-- from
|
||||
-- jobs j
|
||||
-- left join (
|
||||
-- select
|
||||
-- p.jobid,
|
||||
-- sum(p.amount) as total_payments
|
||||
-- from
|
||||
-- payments p
|
||||
-- group by
|
||||
-- p.jobid
|
||||
-- ) p on
|
||||
-- j.id = p.jobid ;
|
||||
--
|
||||
--
|
||||
-- END
|
||||
-- $function$;
|
||||
32
hasura/migrations/1705693896379_run_sql_migration/up.sql
Normal file
32
hasura/migrations/1705693896379_run_sql_migration/up.sql
Normal file
@@ -0,0 +1,32 @@
|
||||
DROP FUNCTION public.jobs_ar_summary;
|
||||
|
||||
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,
|
||||
p.total_payments,
|
||||
j.clm_total - p.total_payments as balance
|
||||
from
|
||||
jobs j
|
||||
left join (
|
||||
select
|
||||
p.jobid,
|
||||
sum(p.amount) as total_payments
|
||||
from
|
||||
payments p
|
||||
group by
|
||||
p.jobid
|
||||
) p on
|
||||
j.id = p.jobid ;
|
||||
|
||||
|
||||
END
|
||||
$function$;
|
||||
32
hasura/migrations/1705694146809_run_sql_migration/down.sql
Normal file
32
hasura/migrations/1705694146809_run_sql_migration/down.sql
Normal file
@@ -0,0 +1,32 @@
|
||||
-- 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,
|
||||
-- p.total_payments,
|
||||
-- j.clm_total - p.total_payments as balance
|
||||
-- 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 ;
|
||||
--
|
||||
--
|
||||
-- END
|
||||
-- $function$;
|
||||
30
hasura/migrations/1705694146809_run_sql_migration/up.sql
Normal file
30
hasura/migrations/1705694146809_run_sql_migration/up.sql
Normal file
@@ -0,0 +1,30 @@
|
||||
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,
|
||||
p.total_payments,
|
||||
j.clm_total - p.total_payments as balance
|
||||
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 ;
|
||||
|
||||
|
||||
END
|
||||
$function$;
|
||||
32
hasura/migrations/1705694176838_run_sql_migration/down.sql
Normal file
32
hasura/migrations/1705694176838_run_sql_migration/down.sql
Normal file
@@ -0,0 +1,32 @@
|
||||
-- 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,
|
||||
-- p.total_payments,
|
||||
-- j.clm_total - p.total_payments as balance
|
||||
-- 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 ;
|
||||
--
|
||||
--
|
||||
-- END
|
||||
-- $function$;
|
||||
30
hasura/migrations/1705694176838_run_sql_migration/up.sql
Normal file
30
hasura/migrations/1705694176838_run_sql_migration/up.sql
Normal file
@@ -0,0 +1,30 @@
|
||||
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,
|
||||
p.total_payments,
|
||||
j.clm_total - p.total_payments as balance
|
||||
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 ;
|
||||
|
||||
|
||||
END
|
||||
$function$;
|
||||
32
hasura/migrations/1705696451631_run_sql_migration/down.sql
Normal file
32
hasura/migrations/1705696451631_run_sql_migration/down.sql
Normal file
@@ -0,0 +1,32 @@
|
||||
-- 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
|
||||
-- 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 ;
|
||||
--
|
||||
--
|
||||
-- END
|
||||
-- $function$;
|
||||
30
hasura/migrations/1705696451631_run_sql_migration/up.sql
Normal file
30
hasura/migrations/1705696451631_run_sql_migration/up.sql
Normal file
@@ -0,0 +1,30 @@
|
||||
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
|
||||
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 ;
|
||||
|
||||
|
||||
END
|
||||
$function$;
|
||||
@@ -0,0 +1,4 @@
|
||||
-- Could not auto-generate a down migration.
|
||||
-- Please write an appropriate down migration for the SQL below:
|
||||
-- alter table "public"."jobs" add column "remove_from_ar" boolean
|
||||
-- not null default 'false';
|
||||
@@ -0,0 +1,2 @@
|
||||
alter table "public"."jobs" add column "remove_from_ar" boolean
|
||||
not null default 'false';
|
||||
33
hasura/migrations/1705698426997_run_sql_migration/down.sql
Normal file
33
hasura/migrations/1705698426997_run_sql_migration/down.sql
Normal file
@@ -0,0 +1,33 @@
|
||||
-- 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
|
||||
-- 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;
|
||||
--
|
||||
--
|
||||
-- END
|
||||
-- $function$;
|
||||
31
hasura/migrations/1705698426997_run_sql_migration/up.sql
Normal file
31
hasura/migrations/1705698426997_run_sql_migration/up.sql
Normal file
@@ -0,0 +1,31 @@
|
||||
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
|
||||
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;
|
||||
|
||||
|
||||
END
|
||||
$function$;
|
||||
@@ -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 "date_invoiced" timestamptz
|
||||
-- null;
|
||||
@@ -0,0 +1,2 @@
|
||||
alter table "public"."job_ar_schema" add column "date_invoiced" timestamptz
|
||||
null;
|
||||
34
hasura/migrations/1705698534883_run_sql_migration/down.sql
Normal file
34
hasura/migrations/1705698534883_run_sql_migration/down.sql
Normal file
@@ -0,0 +1,34 @@
|
||||
-- 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,
|
||||
-- j.date_invoiced,
|
||||
-- coalesce (p.total_payments,0) as total_payments,
|
||||
-- j.clm_total - coalesce (p.total_payments,0) as balance
|
||||
-- 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;
|
||||
--
|
||||
--
|
||||
-- END
|
||||
-- $function$;
|
||||
32
hasura/migrations/1705698534883_run_sql_migration/up.sql
Normal file
32
hasura/migrations/1705698534883_run_sql_migration/up.sql
Normal file
@@ -0,0 +1,32 @@
|
||||
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,
|
||||
j.date_invoiced,
|
||||
coalesce (p.total_payments,0) as total_payments,
|
||||
j.clm_total - coalesce (p.total_payments,0) as balance
|
||||
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;
|
||||
|
||||
|
||||
END
|
||||
$function$;
|
||||
34
hasura/migrations/1705698593644_run_sql_migration/down.sql
Normal file
34
hasura/migrations/1705698593644_run_sql_migration/down.sql
Normal file
@@ -0,0 +1,34 @@
|
||||
-- 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
|
||||
-- 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;
|
||||
--
|
||||
--
|
||||
-- END
|
||||
-- $function$;
|
||||
32
hasura/migrations/1705698593644_run_sql_migration/up.sql
Normal file
32
hasura/migrations/1705698593644_run_sql_migration/up.sql
Normal file
@@ -0,0 +1,32 @@
|
||||
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
|
||||
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;
|
||||
|
||||
|
||||
END
|
||||
$function$;
|
||||
34
hasura/migrations/1705698876975_run_sql_migration/down.sql
Normal file
34
hasura/migrations/1705698876975_run_sql_migration/down.sql
Normal file
@@ -0,0 +1,34 @@
|
||||
-- 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
|
||||
-- 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 balance > 0;
|
||||
--
|
||||
--
|
||||
-- END
|
||||
-- $function$;
|
||||
32
hasura/migrations/1705698876975_run_sql_migration/up.sql
Normal file
32
hasura/migrations/1705698876975_run_sql_migration/up.sql
Normal file
@@ -0,0 +1,32 @@
|
||||
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
|
||||
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 balance > 0;
|
||||
|
||||
|
||||
END
|
||||
$function$;
|
||||
34
hasura/migrations/1705700945994_run_sql_migration/down.sql
Normal file
34
hasura/migrations/1705700945994_run_sql_migration/down.sql
Normal file
@@ -0,0 +1,34 @@
|
||||
-- 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
|
||||
-- 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$;
|
||||
32
hasura/migrations/1705700945994_run_sql_migration/up.sql
Normal file
32
hasura/migrations/1705700945994_run_sql_migration/up.sql
Normal file
@@ -0,0 +1,32 @@
|
||||
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
|
||||
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$;
|
||||
Reference in New Issue
Block a user