From 68f4237e15e9e31ed3ed77ffff6922c4d2dc94e5 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Thu, 1 Jun 2023 13:27:08 -0700 Subject: [PATCH] IO-2278 Begin parts dispatching including basic items and schema. --- bodyshop_translations.babel | 147 +++++++++++++++++ .../job-detail-lines/job-lines.component.jsx | 15 +- .../job-line-dispatch-button.component.jsx | 152 ++++++++++++++++++ .../print-wrapper/print-wrapper.component.jsx | 16 +- client/src/translations/en_us/common.json | 11 +- client/src/translations/es/common.json | 5 + client/src/translations/fr/common.json | 5 + client/src/utils/TemplateConstants.js | 9 ++ hasura/metadata/tables.yaml | 6 + .../down.sql | 1 + .../up.sql | 18 +++ .../down.sql | 1 + .../up.sql | 18 +++ 13 files changed, 388 insertions(+), 16 deletions(-) create mode 100644 client/src/components/job-line-dispatch-button/job-line-dispatch-button.component.jsx create mode 100644 hasura/migrations/1685561607407_create_table_public_parts_dispatch/down.sql create mode 100644 hasura/migrations/1685561607407_create_table_public_parts_dispatch/up.sql create mode 100644 hasura/migrations/1685561715531_create_table_public_parts_dispatch_lines/down.sql create mode 100644 hasura/migrations/1685561715531_create_table_public_parts_dispatch_lines/up.sql diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index b52de475e..93e8ed2e7 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -19356,6 +19356,27 @@ + + dispatchparts + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + new false @@ -37411,6 +37432,48 @@ + + markexported + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + markforreexport + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + new false @@ -37542,6 +37605,27 @@ + + markreexported + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + payment false @@ -39355,6 +39439,27 @@ + + mpi_final_repair_acct_sheet + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + paint_grid false @@ -40433,6 +40538,27 @@ jobs + + individual_job_note + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + parts_order false @@ -44378,6 +44504,27 @@ + + estimators + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + ins_co_nm_filter false diff --git a/client/src/components/job-detail-lines/job-lines.component.jsx b/client/src/components/job-detail-lines/job-lines.component.jsx index 89debdf45..d3968539e 100644 --- a/client/src/components/job-detail-lines/job-lines.component.jsx +++ b/client/src/components/job-detail-lines/job-lines.component.jsx @@ -45,6 +45,7 @@ import JobLinesExpander from "./job-lines-expander.component"; import { selectBodyshop } from "../../redux/user/user.selectors"; import moment from "moment"; import JobLineConvertToLabor from "../job-line-convert-to-labor/job-line-convert-to-labor.component"; +import JobLineDispatchButton from "../job-line-dispatch-button/job-line-dispatch-button.component"; const mapStateToProps = createStructuredSelector({ bodyshop: selectBodyshop, @@ -440,6 +441,11 @@ export function JobLinesComponent({ )} + + + + + + ); + + return ( + + + + ); +} diff --git a/client/src/components/print-wrapper/print-wrapper.component.jsx b/client/src/components/print-wrapper/print-wrapper.component.jsx index 6d5c3438b..0b088adca 100644 --- a/client/src/components/print-wrapper/print-wrapper.component.jsx +++ b/client/src/components/print-wrapper/print-wrapper.component.jsx @@ -9,9 +9,11 @@ export default function PrintWrapperComponent({ children, id, emailOnly = false, + disabled, }) { const [loading, setLoading] = useState(false); const handlePrint = async (type) => { + if (disabled) return; setLoading(true); await GenerateDocument(templateObject, messageObject, type, id); setLoading(false); @@ -20,8 +22,18 @@ export default function PrintWrapperComponent({ return ( {children || null} - {!emailOnly && handlePrint("p")} />} - handlePrint("e")} /> + {!emailOnly && ( + handlePrint("p")} + style={{ cursor: disabled ? "not-allowed" : null }} + /> + )} + handlePrint("e")} + style={{ cursor: disabled ? "not-allowed" : null }} + /> {loading && } ); diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json index 21983e70f..d47172082 100644 --- a/client/src/translations/en_us/common.json +++ b/client/src/translations/en_us/common.json @@ -1208,6 +1208,7 @@ "joblines": { "actions": { "converttolabor": "Convert amount to Labor.", + "dispatchparts": "Dispatch Parts ({{count}})", "new": "New Line" }, "errors": { @@ -2214,17 +2215,17 @@ "external": "External", "findermodal": "ICBC Payment Finder", "insurance": "Insurance", + "markexported": "Mark Exported", + "markforreexport": "Mark for Re-export", "new": "New Payment", "signup": "Please contact support to sign up for electronic payments.", "title": "Payments", - "totalpayments": "Total Payments", - "markexported": "Mark Exported", - "markforreexport": "Mark for Re-export" + "totalpayments": "Total Payments" }, "successes": { "exported": "Payment(s) exported successfully.", - "markreexported": "Payment marked for re-export successfully", "markexported": "Payment(s) marked exported.", + "markreexported": "Payment marked for re-export successfully", "payment": "Payment created successfully. ", "stripe": "Credit card transaction charged successfully." } @@ -2623,8 +2624,8 @@ "labels": { "atssummary": "ATS Summary", "employeevacation": "Employee Vacations", - "ins_co_nm_filter": "Filter by Insurance Company", "estimators": "Filter by Writer/Customer Rep.", + "ins_co_nm_filter": "Filter by Insurance Company", "intake": "Intake Events", "manual": "Manual Events", "manualevent": "Add Manual Event" diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json index 0ead918b2..f27cbb1d9 100644 --- a/client/src/translations/es/common.json +++ b/client/src/translations/es/common.json @@ -1208,6 +1208,7 @@ "joblines": { "actions": { "converttolabor": "", + "dispatchparts": "", "new": "" }, "errors": { @@ -2214,6 +2215,8 @@ "external": "", "findermodal": "", "insurance": "", + "markexported": "", + "markforreexport": "", "new": "", "signup": "", "title": "", @@ -2222,6 +2225,7 @@ "successes": { "exported": "", "markexported": "", + "markreexported": "", "payment": "", "stripe": "" } @@ -2620,6 +2624,7 @@ "labels": { "atssummary": "", "employeevacation": "", + "estimators": "", "ins_co_nm_filter": "", "intake": "", "manual": "", diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json index 040080a88..957b20f69 100644 --- a/client/src/translations/fr/common.json +++ b/client/src/translations/fr/common.json @@ -1208,6 +1208,7 @@ "joblines": { "actions": { "converttolabor": "", + "dispatchparts": "", "new": "" }, "errors": { @@ -2214,6 +2215,8 @@ "external": "", "findermodal": "", "insurance": "", + "markexported": "", + "markforreexport": "", "new": "", "signup": "", "title": "", @@ -2222,6 +2225,7 @@ "successes": { "exported": "", "markexported": "", + "markreexported": "", "payment": "", "stripe": "" } @@ -2620,6 +2624,7 @@ "labels": { "atssummary": "", "employeevacation": "", + "estimators": "", "ins_co_nm_filter": "", "intake": "", "manual": "", diff --git a/client/src/utils/TemplateConstants.js b/client/src/utils/TemplateConstants.js index 78f2f12f2..a92ad4e07 100644 --- a/client/src/utils/TemplateConstants.js +++ b/client/src/utils/TemplateConstants.js @@ -558,6 +558,15 @@ export const TemplateList = (type, context) => { }), disabled: false, }, + parts_dispatch: { + title: i18n.t("printcenter.jobs.parts_dispatch"), + description: "", + key: "parts_dispatch", + subject: i18n.t("printcenter.subjects.jobs.parts_dispatch", { + ro_number: (context && context.ro_number) || "", + }), + disabled: false, + }, } : {}), ...(!type || type === "appointment" diff --git a/hasura/metadata/tables.yaml b/hasura/metadata/tables.yaml index b86dd17fb..6d50b6049 100644 --- a/hasura/metadata/tables.yaml +++ b/hasura/metadata/tables.yaml @@ -4556,6 +4556,12 @@ template_engine: Kriti url: '{{$base_url}}/opensearch' version: 2 +- table: + name: parts_dispatch + schema: public +- table: + name: parts_dispatch_lines + schema: public - table: name: parts_order_lines schema: public diff --git a/hasura/migrations/1685561607407_create_table_public_parts_dispatch/down.sql b/hasura/migrations/1685561607407_create_table_public_parts_dispatch/down.sql new file mode 100644 index 000000000..42325ddf5 --- /dev/null +++ b/hasura/migrations/1685561607407_create_table_public_parts_dispatch/down.sql @@ -0,0 +1 @@ +DROP TABLE "public"."parts_dispatch"; diff --git a/hasura/migrations/1685561607407_create_table_public_parts_dispatch/up.sql b/hasura/migrations/1685561607407_create_table_public_parts_dispatch/up.sql new file mode 100644 index 000000000..d8c7c2729 --- /dev/null +++ b/hasura/migrations/1685561607407_create_table_public_parts_dispatch/up.sql @@ -0,0 +1,18 @@ +CREATE TABLE "public"."parts_dispatch" ("id" uuid NOT NULL DEFAULT gen_random_uuid(), "created_at" timestamptz NOT NULL DEFAULT now(), "updated_at" timestamptz NOT NULL DEFAULT now(), "jobid" uuid NOT NULL, "number" serial NOT NULL, "employeeid" uuid NOT NULL, "dispatched_at" timestamptz NOT NULL, "dispatched_by" text NOT NULL, PRIMARY KEY ("id") , FOREIGN KEY ("jobid") REFERENCES "public"."jobs"("id") ON UPDATE cascade ON DELETE cascade); +CREATE OR REPLACE FUNCTION "public"."set_current_timestamp_updated_at"() +RETURNS TRIGGER AS $$ +DECLARE + _new record; +BEGIN + _new := NEW; + _new."updated_at" = NOW(); + RETURN _new; +END; +$$ LANGUAGE plpgsql; +CREATE TRIGGER "set_public_parts_dispatch_updated_at" +BEFORE UPDATE ON "public"."parts_dispatch" +FOR EACH ROW +EXECUTE PROCEDURE "public"."set_current_timestamp_updated_at"(); +COMMENT ON TRIGGER "set_public_parts_dispatch_updated_at" ON "public"."parts_dispatch" +IS 'trigger to set value of column "updated_at" to current timestamp on row update'; +CREATE EXTENSION IF NOT EXISTS pgcrypto; diff --git a/hasura/migrations/1685561715531_create_table_public_parts_dispatch_lines/down.sql b/hasura/migrations/1685561715531_create_table_public_parts_dispatch_lines/down.sql new file mode 100644 index 000000000..a12867253 --- /dev/null +++ b/hasura/migrations/1685561715531_create_table_public_parts_dispatch_lines/down.sql @@ -0,0 +1 @@ +DROP TABLE "public"."parts_dispatch_lines"; diff --git a/hasura/migrations/1685561715531_create_table_public_parts_dispatch_lines/up.sql b/hasura/migrations/1685561715531_create_table_public_parts_dispatch_lines/up.sql new file mode 100644 index 000000000..5146e2c7e --- /dev/null +++ b/hasura/migrations/1685561715531_create_table_public_parts_dispatch_lines/up.sql @@ -0,0 +1,18 @@ +CREATE TABLE "public"."parts_dispatch_lines" ("id" uuid NOT NULL DEFAULT gen_random_uuid(), "created_at" timestamptz NOT NULL DEFAULT now(), "updated_at" timestamptz NOT NULL DEFAULT now(), "partsdispatchid" UUID NOT NULL, "joblineid" uuid NOT NULL, "quantity" numeric NOT NULL DEFAULT 1, "accepted_at" timestamptz NOT NULL, PRIMARY KEY ("id") , FOREIGN KEY ("joblineid") REFERENCES "public"."joblines"("id") ON UPDATE cascade ON DELETE cascade); +CREATE OR REPLACE FUNCTION "public"."set_current_timestamp_updated_at"() +RETURNS TRIGGER AS $$ +DECLARE + _new record; +BEGIN + _new := NEW; + _new."updated_at" = NOW(); + RETURN _new; +END; +$$ LANGUAGE plpgsql; +CREATE TRIGGER "set_public_parts_dispatch_lines_updated_at" +BEFORE UPDATE ON "public"."parts_dispatch_lines" +FOR EACH ROW +EXECUTE PROCEDURE "public"."set_current_timestamp_updated_at"(); +COMMENT ON TRIGGER "set_public_parts_dispatch_lines_updated_at" ON "public"."parts_dispatch_lines" +IS 'trigger to set value of column "updated_at" to current timestamp on row update'; +CREATE EXTENSION IF NOT EXISTS pgcrypto;