From d585cacdfce363db7e47e81cffc4286071387ab8 Mon Sep 17 00:00:00 2001 From: swtmply Date: Wed, 12 Apr 2023 00:57:13 +0800 Subject: [PATCH 01/24] IO-1412 Fixed column resize --- .../production-list-table.component.jsx | 7 +++++-- .../production-list-table.resizeable.component.jsx | 12 +++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/client/src/components/production-list-table/production-list-table.component.jsx b/client/src/components/production-list-table/production-list-table.component.jsx index 6595476d5..746d956ab 100644 --- a/client/src/components/production-list-table/production-list-table.component.jsx +++ b/client/src/components/production-list-table/production-list-table.component.jsx @@ -81,7 +81,7 @@ export function ProductionListTable({ state, activeStatuses: bodyshop.md_ro_statuses.active_statuses, }).find((e) => e.key === k.key), - width: k.width, + width: k.width ?? 100, }; })) || [] @@ -267,6 +267,8 @@ export function ProductionListTable({ sortOrder: state.sortedInfo.columnKey === c.key && state.sortedInfo.order, title: headerItem(c), + ellipsis: true, + width: c.width ?? 100, onHeaderCell: (column) => ({ width: column.width, onResize: handleResize(index), @@ -276,11 +278,12 @@ export function ProductionListTable({ rowKey="id" loading={loading} dataSource={dataSource} - // scroll={{ x: true }} + scroll={{ x: 1000 }} onChange={handleTableChange} /> ); } + export default connect(mapStateToProps, null)(ProductionListTable); diff --git a/client/src/components/production-list-table/production-list-table.resizeable.component.jsx b/client/src/components/production-list-table/production-list-table.resizeable.component.jsx index 2f1324999..07b47c87a 100644 --- a/client/src/components/production-list-table/production-list-table.resizeable.component.jsx +++ b/client/src/components/production-list-table/production-list-table.resizeable.component.jsx @@ -3,8 +3,18 @@ import { Resizable } from "react-resizable"; export default function ResizableComponent(props) { const { onResize, width, ...restProps } = props; + + if (!width) { + return ; + } + return ( - + ); From 3ed48b26f1443d6e4225cdbfc949f7225ac638cc Mon Sep 17 00:00:00 2001 From: swtmply Date: Wed, 12 Apr 2023 01:44:45 +0800 Subject: [PATCH 02/24] IO-2338 Changed vehicle column to be a hyperlink --- .../production-list-columns.data.js | 10 ++++++---- client/src/graphql/jobs.queries.js | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/client/src/components/production-list-columns/production-list-columns.data.js b/client/src/components/production-list-columns/production-list-columns.data.js index bd2f15817..7d122200d 100644 --- a/client/src/components/production-list-columns/production-list-columns.data.js +++ b/client/src/components/production-list-columns/production-list-columns.data.js @@ -91,11 +91,13 @@ const r = ({ technician, state, activeStatuses, bodyshop }) => { b.v_make_desc + b.v_model_desc ), sortOrder: - state.sortedInfo.columnKey === "ownr" && state.sortedInfo.order, + state.sortedInfo.columnKey === "vehicle" && state.sortedInfo.order, render: (text, record) => ( - {`${record.v_model_yr || ""} ${record.v_make_desc || ""} ${ - record.v_model_desc || "" - } ${record.v_color || ""} ${record.plate_no || ""}`} + {`${ + record.v_model_yr || "" + } ${record.v_make_desc || ""} ${record.v_model_desc || ""} ${ + record.v_color || "" + } ${record.plate_no || ""}`} ), }, { diff --git a/client/src/graphql/jobs.queries.js b/client/src/graphql/jobs.queries.js index dce7aff66..a6273edc4 100644 --- a/client/src/graphql/jobs.queries.js +++ b/client/src/graphql/jobs.queries.js @@ -284,6 +284,7 @@ export const QUERY_JOBS_IN_PRODUCTION = gql` clm_no v_make_desc v_color + vehicleid plate_no actual_in scheduled_completion From 9fa995f00221c0d531874c31232b67045ad9b3ef Mon Sep 17 00:00:00 2001 From: swtmply Date: Wed, 12 Apr 2023 03:13:19 +0800 Subject: [PATCH 03/24] IO-2239 Added totals on cards in job scoreboards --- .../scoreboard-day-stats.component.jsx | 6 +++ .../scoreboard-targets-table.component.jsx | 48 +++++++++++++++++-- client/src/translations/en_us/common.json | 1 + 3 files changed, 52 insertions(+), 3 deletions(-) diff --git a/client/src/components/scoreboard-day-stats/scoreboard-day-stats.component.jsx b/client/src/components/scoreboard-day-stats/scoreboard-day-stats.component.jsx index 36b4a028b..497eab209 100644 --- a/client/src/components/scoreboard-day-stats/scoreboard-day-stats.component.jsx +++ b/client/src/components/scoreboard-day-stats/scoreboard-day-stats.component.jsx @@ -4,6 +4,7 @@ import React from "react"; import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; import { selectBodyshop } from "../../redux/user/user.selectors"; +import { useTranslation } from "react-i18next"; const mapStateToProps = createStructuredSelector({ bodyshop: selectBodyshop, }); @@ -13,6 +14,7 @@ const mapDispatchToProps = (dispatch) => ({ export function ScoreboardDayStats({ bodyshop, date, entries }) { const { dailyPaintTarget, dailyBodyTarget } = bodyshop.scoreboard_target; + const { t } = useTranslation(); //let totalHrs = 0; const paintHrs = entries.reduce((acc, value) => { @@ -41,6 +43,10 @@ export function ScoreboardDayStats({ bodyshop, date, entries }) { label="P" value={paintHrs.toFixed(1)} /> + ); } diff --git a/client/src/components/scoreboard-targets-table/scoreboard-targets-table.component.jsx b/client/src/components/scoreboard-targets-table/scoreboard-targets-table.component.jsx index 6f22b3b8a..558b217b6 100644 --- a/client/src/components/scoreboard-targets-table/scoreboard-targets-table.component.jsx +++ b/client/src/components/scoreboard-targets-table/scoreboard-targets-table.component.jsx @@ -184,14 +184,56 @@ export function ScoreboardTargetsTable({ bodyshop, scoreBoardlist }) { value={(values.todayPaint + values.todayBody).toFixed(1)} /> - + + + - - + + + + + + Date: Wed, 12 Apr 2023 13:02:45 -0700 Subject: [PATCH 04/24] IO-2243 Capture successful CDK posting details. --- hasura/metadata/tables.yaml | 200 +++++++++++++++++- .../down.sql | 4 + .../up.sql | 2 + server/cdk/cdk-job-export.js | 3 + 4 files changed, 198 insertions(+), 11 deletions(-) create mode 100644 hasura/migrations/1681329377686_alter_table_public_exportlog_add_column_metadata/down.sql create mode 100644 hasura/migrations/1681329377686_alter_table_public_exportlog_add_column_metadata/up.sql diff --git a/hasura/metadata/tables.yaml b/hasura/metadata/tables.yaml index a576c160e..6fe62169b 100644 --- a/hasura/metadata/tables.yaml +++ b/hasura/metadata/tables.yaml @@ -761,6 +761,13 @@ table: name: email_audit_trail schema: public + - name: employee_teams + using: + foreign_key_constraint_on: + column: bodyshopid + table: + name: employee_teams + schema: public - name: employees using: foreign_key_constraint_on: @@ -1945,6 +1952,165 @@ - active: _eq: true check: null +- table: + name: employee_team_members + schema: public + object_relationships: + - name: employee + using: + foreign_key_constraint_on: employeeid + - name: employee_team + using: + foreign_key_constraint_on: teamid + insert_permissions: + - role: user + permission: + check: + employee_team: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + columns: + - labor_rates + - percentage + - created_at + - updated_at + - employeeid + - id + - teamid + select_permissions: + - role: user + permission: + columns: + - labor_rates + - percentage + - created_at + - updated_at + - employeeid + - id + - teamid + filter: + employee_team: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + update_permissions: + - role: user + permission: + columns: + - labor_rates + - percentage + - created_at + - updated_at + - employeeid + - id + - teamid + filter: + employee_team: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + check: null + delete_permissions: + - role: user + permission: + backend_only: false + filter: + employee_team: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true +- table: + name: employee_teams + schema: public + object_relationships: + - name: bodyshop + using: + foreign_key_constraint_on: bodyshopid + array_relationships: + - name: employee_team_members + using: + foreign_key_constraint_on: + column: teamid + table: + name: employee_team_members + schema: public + insert_permissions: + - role: user + permission: + check: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + columns: + - active + - name + - created_at + - updated_at + - bodyshopid + - id + select_permissions: + - role: user + permission: + columns: + - active + - name + - created_at + - updated_at + - bodyshopid + - id + filter: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + update_permissions: + - role: user + permission: + columns: + - active + - bodyshopid + - name + - updated_at + filter: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + check: null - table: name: employee_vacation schema: public @@ -2045,6 +2211,13 @@ table: name: allocations schema: public + - name: employee_team_members + using: + foreign_key_constraint_on: + column: employeeid + table: + name: employee_team_members + schema: public - name: employee_vacations using: foreign_key_constraint_on: @@ -2218,30 +2391,32 @@ - active: _eq: true columns: - - id - - created_at - - updated_at - - jobid - billid + - bodyshopid + - created_at + - id + - jobid + - message + - metadata - paymentid - successful - - message - - bodyshopid + - updated_at - useremail select_permissions: - role: user permission: columns: - - successful - - message - - useremail - - created_at - - updated_at - billid - bodyshopid + - created_at - id - jobid + - message + - metadata - paymentid + - successful + - updated_at + - useremail filter: bodyshop: associations: @@ -2493,6 +2668,7 @@ _eq: true columns: - act_price + - act_price_before_ppc - ah_detail_line - alt_co_id - alt_overrd @@ -2559,6 +2735,7 @@ permission: columns: - act_price + - act_price_before_ppc - ah_detail_line - alt_co_id - alt_overrd @@ -2637,6 +2814,7 @@ permission: columns: - act_price + - act_price_before_ppc - ah_detail_line - alt_co_id - alt_overrd diff --git a/hasura/migrations/1681329377686_alter_table_public_exportlog_add_column_metadata/down.sql b/hasura/migrations/1681329377686_alter_table_public_exportlog_add_column_metadata/down.sql new file mode 100644 index 000000000..3c175e747 --- /dev/null +++ b/hasura/migrations/1681329377686_alter_table_public_exportlog_add_column_metadata/down.sql @@ -0,0 +1,4 @@ +-- Could not auto-generate a down migration. +-- Please write an appropriate down migration for the SQL below: +-- alter table "public"."exportlog" add column "metadata" jsonb +-- null; diff --git a/hasura/migrations/1681329377686_alter_table_public_exportlog_add_column_metadata/up.sql b/hasura/migrations/1681329377686_alter_table_public_exportlog_add_column_metadata/up.sql new file mode 100644 index 000000000..621b8481c --- /dev/null +++ b/hasura/migrations/1681329377686_alter_table_public_exportlog_add_column_metadata/up.sql @@ -0,0 +1,2 @@ +alter table "public"."exportlog" add column "metadata" jsonb + null; diff --git a/server/cdk/cdk-job-export.js b/server/cdk/cdk-job-export.js index d5fb6b295..3987d21bc 100644 --- a/server/cdk/cdk-job-export.js +++ b/server/cdk/cdk-job-export.js @@ -224,6 +224,7 @@ async function CdkSelectedCustomer(socket, selectedCustomerId) { } finally { //Ensure we always insert logEvents //GQL to insert logevents. + CdkBase.createLogEvent( socket, "DEBUG", @@ -1213,6 +1214,7 @@ async function GenerateTransWips(socket) { wips.push(item); }); + socket.transWips = wips; return wips; } @@ -1388,6 +1390,7 @@ async function MarkJobExported(socket, jobid) { jobid: jobid, successful: true, useremail: socket.user.email, + metadata: socket.transWips, }, bill: { exported: true, From 3d9a07bd393014de7e332d6c45467a7e2fbc7d30 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Wed, 12 Apr 2023 13:08:39 -0700 Subject: [PATCH 05/24] Include employee team changes from Payroll Based Changes. --- hasura/metadata/tables.yaml | 22 +++++++++---------- .../down.sql | 1 + .../up.sql | 18 +++++++++++++++ .../down.sql | 1 + .../up.sql | 18 +++++++++++++++ 5 files changed, 48 insertions(+), 12 deletions(-) create mode 100644 hasura/migrations/1681155844658_create_table_public_employee_teams/down.sql create mode 100644 hasura/migrations/1681155844658_create_table_public_employee_teams/up.sql create mode 100644 hasura/migrations/1681156265693_create_table_public_employee_team_members/down.sql create mode 100644 hasura/migrations/1681156265693_create_table_public_employee_team_members/up.sql diff --git a/hasura/metadata/tables.yaml b/hasura/metadata/tables.yaml index 6fe62169b..0055e4b7a 100644 --- a/hasura/metadata/tables.yaml +++ b/hasura/metadata/tables.yaml @@ -2391,32 +2391,30 @@ - active: _eq: true columns: - - billid - - bodyshopid - - created_at - id + - created_at + - updated_at - jobid - - message - - metadata + - billid - paymentid - successful - - updated_at + - message + - bodyshopid - useremail select_permissions: - role: user permission: columns: + - successful + - message + - useremail + - created_at + - updated_at - billid - bodyshopid - - created_at - id - jobid - - message - - metadata - paymentid - - successful - - updated_at - - useremail filter: bodyshop: associations: diff --git a/hasura/migrations/1681155844658_create_table_public_employee_teams/down.sql b/hasura/migrations/1681155844658_create_table_public_employee_teams/down.sql new file mode 100644 index 000000000..1639caf73 --- /dev/null +++ b/hasura/migrations/1681155844658_create_table_public_employee_teams/down.sql @@ -0,0 +1 @@ +DROP TABLE "public"."employee_teams"; diff --git a/hasura/migrations/1681155844658_create_table_public_employee_teams/up.sql b/hasura/migrations/1681155844658_create_table_public_employee_teams/up.sql new file mode 100644 index 000000000..994e15280 --- /dev/null +++ b/hasura/migrations/1681155844658_create_table_public_employee_teams/up.sql @@ -0,0 +1,18 @@ +CREATE TABLE "public"."employee_teams" ("id" uuid NOT NULL DEFAULT gen_random_uuid(), "created_at" timestamptz NOT NULL DEFAULT now(), "updated_at" timestamptz NOT NULL DEFAULT now(), "bodyshopid" uuid NOT NULL, "name" text NOT NULL, "active" boolean NOT NULL DEFAULT true, PRIMARY KEY ("id") , FOREIGN KEY ("bodyshopid") REFERENCES "public"."bodyshops"("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_employee_teams_updated_at" +BEFORE UPDATE ON "public"."employee_teams" +FOR EACH ROW +EXECUTE PROCEDURE "public"."set_current_timestamp_updated_at"(); +COMMENT ON TRIGGER "set_public_employee_teams_updated_at" ON "public"."employee_teams" +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/1681156265693_create_table_public_employee_team_members/down.sql b/hasura/migrations/1681156265693_create_table_public_employee_team_members/down.sql new file mode 100644 index 000000000..14ab424ce --- /dev/null +++ b/hasura/migrations/1681156265693_create_table_public_employee_team_members/down.sql @@ -0,0 +1 @@ +DROP TABLE "public"."employee_team_members"; diff --git a/hasura/migrations/1681156265693_create_table_public_employee_team_members/up.sql b/hasura/migrations/1681156265693_create_table_public_employee_team_members/up.sql new file mode 100644 index 000000000..e6a32938f --- /dev/null +++ b/hasura/migrations/1681156265693_create_table_public_employee_team_members/up.sql @@ -0,0 +1,18 @@ +CREATE TABLE "public"."employee_team_members" ("id" uuid NOT NULL DEFAULT gen_random_uuid(), "created_at" timestamptz NOT NULL DEFAULT now(), "updated_at" timestamptz NOT NULL DEFAULT now(), "teamid" uuid NOT NULL, "employeeid" uuid NOT NULL, "labor_rates" jsonb NOT NULL DEFAULT jsonb_build_object(), "percentage" numeric NOT NULL DEFAULT 0, PRIMARY KEY ("id") , FOREIGN KEY ("teamid") REFERENCES "public"."employee_teams"("id") ON UPDATE cascade ON DELETE cascade, FOREIGN KEY ("employeeid") REFERENCES "public"."employees"("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_employee_team_members_updated_at" +BEFORE UPDATE ON "public"."employee_team_members" +FOR EACH ROW +EXECUTE PROCEDURE "public"."set_current_timestamp_updated_at"(); +COMMENT ON TRIGGER "set_public_employee_team_members_updated_at" ON "public"."employee_team_members" +IS 'trigger to set value of column "updated_at" to current timestamp on row update'; +CREATE EXTENSION IF NOT EXISTS pgcrypto; From 1460fa6fd73cc82e9688c64adc9012f72060c237 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Wed, 12 Apr 2023 13:13:51 -0700 Subject: [PATCH 06/24] Add ppc field to job lines. --- .../down.sql | 4 ++++ .../up.sql | 2 ++ 2 files changed, 6 insertions(+) create mode 100644 hasura/migrations/1679343513178_alter_table_public_joblines_add_column_act_price_before_ppc/down.sql create mode 100644 hasura/migrations/1679343513178_alter_table_public_joblines_add_column_act_price_before_ppc/up.sql diff --git a/hasura/migrations/1679343513178_alter_table_public_joblines_add_column_act_price_before_ppc/down.sql b/hasura/migrations/1679343513178_alter_table_public_joblines_add_column_act_price_before_ppc/down.sql new file mode 100644 index 000000000..641b06fc4 --- /dev/null +++ b/hasura/migrations/1679343513178_alter_table_public_joblines_add_column_act_price_before_ppc/down.sql @@ -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 "act_price_before_ppc" numeric +-- null; diff --git a/hasura/migrations/1679343513178_alter_table_public_joblines_add_column_act_price_before_ppc/up.sql b/hasura/migrations/1679343513178_alter_table_public_joblines_add_column_act_price_before_ppc/up.sql new file mode 100644 index 000000000..c817ce67a --- /dev/null +++ b/hasura/migrations/1679343513178_alter_table_public_joblines_add_column_act_price_before_ppc/up.sql @@ -0,0 +1,2 @@ +alter table "public"."joblines" add column "act_price_before_ppc" numeric + null; From f48fb7130edabcb7bde0209e758789dc778f77ba Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Wed, 12 Apr 2023 13:16:18 -0700 Subject: [PATCH 07/24] IO-2137 Adjust PBS company name logic for posting. --- server/accounting/pbs/pbs-job-export.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/accounting/pbs/pbs-job-export.js b/server/accounting/pbs/pbs-job-export.js index ee0b3c8a8..cfbe71a19 100644 --- a/server/accounting/pbs/pbs-job-export.js +++ b/server/accounting/pbs/pbs-job-export.js @@ -249,10 +249,10 @@ async function QueryCustomersFromDms(socket) { SerialNumber: socket.JobData.bodyshop.pbs_serialnumber, //ContactId: "00000000000000000000000000000000", // ContactCode: socket.JobData.owner.accountingid, - FirstName: socket.JobData.ownr_co_nm + FirstName: socket.JobData.ownr_fn, + LastName: socket.JobData.ownr_co_nm ? socket.JobData.ownr_co_nm - : socket.JobData.ownr_fn, - LastName: socket.JobData.ownr_ln, + : socket.JobData.ownr_ln, PhoneNumber: socket.JobData.ownr_ph1, EmailAddress: socket.JobData.ownr_ea, // ModifiedSince: "0001-01-01T00:00:00.0000000Z", From a3375e615283644972981ec68098aa9839716e6f Mon Sep 17 00:00:00 2001 From: swtmply Date: Wed, 12 Apr 2023 01:44:45 +0800 Subject: [PATCH 08/24] IO-2238 Changed vehicle column to be a hyperlink --- .../production-list-columns.data.js | 10 ++++++---- client/src/graphql/jobs.queries.js | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/client/src/components/production-list-columns/production-list-columns.data.js b/client/src/components/production-list-columns/production-list-columns.data.js index bd2f15817..7d122200d 100644 --- a/client/src/components/production-list-columns/production-list-columns.data.js +++ b/client/src/components/production-list-columns/production-list-columns.data.js @@ -91,11 +91,13 @@ const r = ({ technician, state, activeStatuses, bodyshop }) => { b.v_make_desc + b.v_model_desc ), sortOrder: - state.sortedInfo.columnKey === "ownr" && state.sortedInfo.order, + state.sortedInfo.columnKey === "vehicle" && state.sortedInfo.order, render: (text, record) => ( - {`${record.v_model_yr || ""} ${record.v_make_desc || ""} ${ - record.v_model_desc || "" - } ${record.v_color || ""} ${record.plate_no || ""}`} + {`${ + record.v_model_yr || "" + } ${record.v_make_desc || ""} ${record.v_model_desc || ""} ${ + record.v_color || "" + } ${record.plate_no || ""}`} ), }, { diff --git a/client/src/graphql/jobs.queries.js b/client/src/graphql/jobs.queries.js index dce7aff66..a6273edc4 100644 --- a/client/src/graphql/jobs.queries.js +++ b/client/src/graphql/jobs.queries.js @@ -284,6 +284,7 @@ export const QUERY_JOBS_IN_PRODUCTION = gql` clm_no v_make_desc v_color + vehicleid plate_no actual_in scheduled_completion From f3714cea1e9090d1ab769c8da8917953cabef519 Mon Sep 17 00:00:00 2001 From: swtmply Date: Wed, 12 Apr 2023 03:13:19 +0800 Subject: [PATCH 09/24] IO-2239 Added totals on cards in job scoreboards --- .../scoreboard-day-stats.component.jsx | 6 +++ .../scoreboard-targets-table.component.jsx | 48 +++++++++++++++++-- client/src/translations/en_us/common.json | 1 + 3 files changed, 52 insertions(+), 3 deletions(-) diff --git a/client/src/components/scoreboard-day-stats/scoreboard-day-stats.component.jsx b/client/src/components/scoreboard-day-stats/scoreboard-day-stats.component.jsx index 36b4a028b..497eab209 100644 --- a/client/src/components/scoreboard-day-stats/scoreboard-day-stats.component.jsx +++ b/client/src/components/scoreboard-day-stats/scoreboard-day-stats.component.jsx @@ -4,6 +4,7 @@ import React from "react"; import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; import { selectBodyshop } from "../../redux/user/user.selectors"; +import { useTranslation } from "react-i18next"; const mapStateToProps = createStructuredSelector({ bodyshop: selectBodyshop, }); @@ -13,6 +14,7 @@ const mapDispatchToProps = (dispatch) => ({ export function ScoreboardDayStats({ bodyshop, date, entries }) { const { dailyPaintTarget, dailyBodyTarget } = bodyshop.scoreboard_target; + const { t } = useTranslation(); //let totalHrs = 0; const paintHrs = entries.reduce((acc, value) => { @@ -41,6 +43,10 @@ export function ScoreboardDayStats({ bodyshop, date, entries }) { label="P" value={paintHrs.toFixed(1)} /> + ); } diff --git a/client/src/components/scoreboard-targets-table/scoreboard-targets-table.component.jsx b/client/src/components/scoreboard-targets-table/scoreboard-targets-table.component.jsx index 6f22b3b8a..558b217b6 100644 --- a/client/src/components/scoreboard-targets-table/scoreboard-targets-table.component.jsx +++ b/client/src/components/scoreboard-targets-table/scoreboard-targets-table.component.jsx @@ -184,14 +184,56 @@ export function ScoreboardTargetsTable({ bodyshop, scoreBoardlist }) { value={(values.todayPaint + values.todayBody).toFixed(1)} /> - + + + - - + + + + + + Date: Wed, 12 Apr 2023 13:02:45 -0700 Subject: [PATCH 10/24] IO-2243 Capture successful CDK posting details. --- hasura/metadata/tables.yaml | 200 +++++++++++++++++- .../down.sql | 4 + .../up.sql | 2 + server/cdk/cdk-job-export.js | 3 + 4 files changed, 198 insertions(+), 11 deletions(-) create mode 100644 hasura/migrations/1681329377686_alter_table_public_exportlog_add_column_metadata/down.sql create mode 100644 hasura/migrations/1681329377686_alter_table_public_exportlog_add_column_metadata/up.sql diff --git a/hasura/metadata/tables.yaml b/hasura/metadata/tables.yaml index a576c160e..6fe62169b 100644 --- a/hasura/metadata/tables.yaml +++ b/hasura/metadata/tables.yaml @@ -761,6 +761,13 @@ table: name: email_audit_trail schema: public + - name: employee_teams + using: + foreign_key_constraint_on: + column: bodyshopid + table: + name: employee_teams + schema: public - name: employees using: foreign_key_constraint_on: @@ -1945,6 +1952,165 @@ - active: _eq: true check: null +- table: + name: employee_team_members + schema: public + object_relationships: + - name: employee + using: + foreign_key_constraint_on: employeeid + - name: employee_team + using: + foreign_key_constraint_on: teamid + insert_permissions: + - role: user + permission: + check: + employee_team: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + columns: + - labor_rates + - percentage + - created_at + - updated_at + - employeeid + - id + - teamid + select_permissions: + - role: user + permission: + columns: + - labor_rates + - percentage + - created_at + - updated_at + - employeeid + - id + - teamid + filter: + employee_team: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + update_permissions: + - role: user + permission: + columns: + - labor_rates + - percentage + - created_at + - updated_at + - employeeid + - id + - teamid + filter: + employee_team: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + check: null + delete_permissions: + - role: user + permission: + backend_only: false + filter: + employee_team: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true +- table: + name: employee_teams + schema: public + object_relationships: + - name: bodyshop + using: + foreign_key_constraint_on: bodyshopid + array_relationships: + - name: employee_team_members + using: + foreign_key_constraint_on: + column: teamid + table: + name: employee_team_members + schema: public + insert_permissions: + - role: user + permission: + check: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + columns: + - active + - name + - created_at + - updated_at + - bodyshopid + - id + select_permissions: + - role: user + permission: + columns: + - active + - name + - created_at + - updated_at + - bodyshopid + - id + filter: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + update_permissions: + - role: user + permission: + columns: + - active + - bodyshopid + - name + - updated_at + filter: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + check: null - table: name: employee_vacation schema: public @@ -2045,6 +2211,13 @@ table: name: allocations schema: public + - name: employee_team_members + using: + foreign_key_constraint_on: + column: employeeid + table: + name: employee_team_members + schema: public - name: employee_vacations using: foreign_key_constraint_on: @@ -2218,30 +2391,32 @@ - active: _eq: true columns: - - id - - created_at - - updated_at - - jobid - billid + - bodyshopid + - created_at + - id + - jobid + - message + - metadata - paymentid - successful - - message - - bodyshopid + - updated_at - useremail select_permissions: - role: user permission: columns: - - successful - - message - - useremail - - created_at - - updated_at - billid - bodyshopid + - created_at - id - jobid + - message + - metadata - paymentid + - successful + - updated_at + - useremail filter: bodyshop: associations: @@ -2493,6 +2668,7 @@ _eq: true columns: - act_price + - act_price_before_ppc - ah_detail_line - alt_co_id - alt_overrd @@ -2559,6 +2735,7 @@ permission: columns: - act_price + - act_price_before_ppc - ah_detail_line - alt_co_id - alt_overrd @@ -2637,6 +2814,7 @@ permission: columns: - act_price + - act_price_before_ppc - ah_detail_line - alt_co_id - alt_overrd diff --git a/hasura/migrations/1681329377686_alter_table_public_exportlog_add_column_metadata/down.sql b/hasura/migrations/1681329377686_alter_table_public_exportlog_add_column_metadata/down.sql new file mode 100644 index 000000000..3c175e747 --- /dev/null +++ b/hasura/migrations/1681329377686_alter_table_public_exportlog_add_column_metadata/down.sql @@ -0,0 +1,4 @@ +-- Could not auto-generate a down migration. +-- Please write an appropriate down migration for the SQL below: +-- alter table "public"."exportlog" add column "metadata" jsonb +-- null; diff --git a/hasura/migrations/1681329377686_alter_table_public_exportlog_add_column_metadata/up.sql b/hasura/migrations/1681329377686_alter_table_public_exportlog_add_column_metadata/up.sql new file mode 100644 index 000000000..621b8481c --- /dev/null +++ b/hasura/migrations/1681329377686_alter_table_public_exportlog_add_column_metadata/up.sql @@ -0,0 +1,2 @@ +alter table "public"."exportlog" add column "metadata" jsonb + null; diff --git a/server/cdk/cdk-job-export.js b/server/cdk/cdk-job-export.js index d5fb6b295..3987d21bc 100644 --- a/server/cdk/cdk-job-export.js +++ b/server/cdk/cdk-job-export.js @@ -224,6 +224,7 @@ async function CdkSelectedCustomer(socket, selectedCustomerId) { } finally { //Ensure we always insert logEvents //GQL to insert logevents. + CdkBase.createLogEvent( socket, "DEBUG", @@ -1213,6 +1214,7 @@ async function GenerateTransWips(socket) { wips.push(item); }); + socket.transWips = wips; return wips; } @@ -1388,6 +1390,7 @@ async function MarkJobExported(socket, jobid) { jobid: jobid, successful: true, useremail: socket.user.email, + metadata: socket.transWips, }, bill: { exported: true, From 614549a5452f561c6f8c9d4e9b1442e0034841b5 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Wed, 12 Apr 2023 13:08:39 -0700 Subject: [PATCH 11/24] Include employee team changes from Payroll Based Changes. --- hasura/metadata/tables.yaml | 22 +++++++++---------- .../down.sql | 1 + .../up.sql | 18 +++++++++++++++ .../down.sql | 1 + .../up.sql | 18 +++++++++++++++ 5 files changed, 48 insertions(+), 12 deletions(-) create mode 100644 hasura/migrations/1681155844658_create_table_public_employee_teams/down.sql create mode 100644 hasura/migrations/1681155844658_create_table_public_employee_teams/up.sql create mode 100644 hasura/migrations/1681156265693_create_table_public_employee_team_members/down.sql create mode 100644 hasura/migrations/1681156265693_create_table_public_employee_team_members/up.sql diff --git a/hasura/metadata/tables.yaml b/hasura/metadata/tables.yaml index 6fe62169b..0055e4b7a 100644 --- a/hasura/metadata/tables.yaml +++ b/hasura/metadata/tables.yaml @@ -2391,32 +2391,30 @@ - active: _eq: true columns: - - billid - - bodyshopid - - created_at - id + - created_at + - updated_at - jobid - - message - - metadata + - billid - paymentid - successful - - updated_at + - message + - bodyshopid - useremail select_permissions: - role: user permission: columns: + - successful + - message + - useremail + - created_at + - updated_at - billid - bodyshopid - - created_at - id - jobid - - message - - metadata - paymentid - - successful - - updated_at - - useremail filter: bodyshop: associations: diff --git a/hasura/migrations/1681155844658_create_table_public_employee_teams/down.sql b/hasura/migrations/1681155844658_create_table_public_employee_teams/down.sql new file mode 100644 index 000000000..1639caf73 --- /dev/null +++ b/hasura/migrations/1681155844658_create_table_public_employee_teams/down.sql @@ -0,0 +1 @@ +DROP TABLE "public"."employee_teams"; diff --git a/hasura/migrations/1681155844658_create_table_public_employee_teams/up.sql b/hasura/migrations/1681155844658_create_table_public_employee_teams/up.sql new file mode 100644 index 000000000..994e15280 --- /dev/null +++ b/hasura/migrations/1681155844658_create_table_public_employee_teams/up.sql @@ -0,0 +1,18 @@ +CREATE TABLE "public"."employee_teams" ("id" uuid NOT NULL DEFAULT gen_random_uuid(), "created_at" timestamptz NOT NULL DEFAULT now(), "updated_at" timestamptz NOT NULL DEFAULT now(), "bodyshopid" uuid NOT NULL, "name" text NOT NULL, "active" boolean NOT NULL DEFAULT true, PRIMARY KEY ("id") , FOREIGN KEY ("bodyshopid") REFERENCES "public"."bodyshops"("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_employee_teams_updated_at" +BEFORE UPDATE ON "public"."employee_teams" +FOR EACH ROW +EXECUTE PROCEDURE "public"."set_current_timestamp_updated_at"(); +COMMENT ON TRIGGER "set_public_employee_teams_updated_at" ON "public"."employee_teams" +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/1681156265693_create_table_public_employee_team_members/down.sql b/hasura/migrations/1681156265693_create_table_public_employee_team_members/down.sql new file mode 100644 index 000000000..14ab424ce --- /dev/null +++ b/hasura/migrations/1681156265693_create_table_public_employee_team_members/down.sql @@ -0,0 +1 @@ +DROP TABLE "public"."employee_team_members"; diff --git a/hasura/migrations/1681156265693_create_table_public_employee_team_members/up.sql b/hasura/migrations/1681156265693_create_table_public_employee_team_members/up.sql new file mode 100644 index 000000000..e6a32938f --- /dev/null +++ b/hasura/migrations/1681156265693_create_table_public_employee_team_members/up.sql @@ -0,0 +1,18 @@ +CREATE TABLE "public"."employee_team_members" ("id" uuid NOT NULL DEFAULT gen_random_uuid(), "created_at" timestamptz NOT NULL DEFAULT now(), "updated_at" timestamptz NOT NULL DEFAULT now(), "teamid" uuid NOT NULL, "employeeid" uuid NOT NULL, "labor_rates" jsonb NOT NULL DEFAULT jsonb_build_object(), "percentage" numeric NOT NULL DEFAULT 0, PRIMARY KEY ("id") , FOREIGN KEY ("teamid") REFERENCES "public"."employee_teams"("id") ON UPDATE cascade ON DELETE cascade, FOREIGN KEY ("employeeid") REFERENCES "public"."employees"("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_employee_team_members_updated_at" +BEFORE UPDATE ON "public"."employee_team_members" +FOR EACH ROW +EXECUTE PROCEDURE "public"."set_current_timestamp_updated_at"(); +COMMENT ON TRIGGER "set_public_employee_team_members_updated_at" ON "public"."employee_team_members" +IS 'trigger to set value of column "updated_at" to current timestamp on row update'; +CREATE EXTENSION IF NOT EXISTS pgcrypto; From 2eb81dde37c906fef9483c5560f50a31f40ad416 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Wed, 12 Apr 2023 13:13:51 -0700 Subject: [PATCH 12/24] Add ppc field to job lines. --- .../down.sql | 4 ++++ .../up.sql | 2 ++ 2 files changed, 6 insertions(+) create mode 100644 hasura/migrations/1679343513178_alter_table_public_joblines_add_column_act_price_before_ppc/down.sql create mode 100644 hasura/migrations/1679343513178_alter_table_public_joblines_add_column_act_price_before_ppc/up.sql diff --git a/hasura/migrations/1679343513178_alter_table_public_joblines_add_column_act_price_before_ppc/down.sql b/hasura/migrations/1679343513178_alter_table_public_joblines_add_column_act_price_before_ppc/down.sql new file mode 100644 index 000000000..641b06fc4 --- /dev/null +++ b/hasura/migrations/1679343513178_alter_table_public_joblines_add_column_act_price_before_ppc/down.sql @@ -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 "act_price_before_ppc" numeric +-- null; diff --git a/hasura/migrations/1679343513178_alter_table_public_joblines_add_column_act_price_before_ppc/up.sql b/hasura/migrations/1679343513178_alter_table_public_joblines_add_column_act_price_before_ppc/up.sql new file mode 100644 index 000000000..c817ce67a --- /dev/null +++ b/hasura/migrations/1679343513178_alter_table_public_joblines_add_column_act_price_before_ppc/up.sql @@ -0,0 +1,2 @@ +alter table "public"."joblines" add column "act_price_before_ppc" numeric + null; From e5b8d003ec771c787be3cd5485d774b16f3d0d66 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Wed, 12 Apr 2023 13:16:18 -0700 Subject: [PATCH 13/24] IO-2137 Adjust PBS company name logic for posting. --- server/accounting/pbs/pbs-job-export.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/accounting/pbs/pbs-job-export.js b/server/accounting/pbs/pbs-job-export.js index ee0b3c8a8..cfbe71a19 100644 --- a/server/accounting/pbs/pbs-job-export.js +++ b/server/accounting/pbs/pbs-job-export.js @@ -249,10 +249,10 @@ async function QueryCustomersFromDms(socket) { SerialNumber: socket.JobData.bodyshop.pbs_serialnumber, //ContactId: "00000000000000000000000000000000", // ContactCode: socket.JobData.owner.accountingid, - FirstName: socket.JobData.ownr_co_nm + FirstName: socket.JobData.ownr_fn, + LastName: socket.JobData.ownr_co_nm ? socket.JobData.ownr_co_nm - : socket.JobData.ownr_fn, - LastName: socket.JobData.ownr_ln, + : socket.JobData.ownr_ln, PhoneNumber: socket.JobData.ownr_ph1, EmailAddress: socket.JobData.ownr_ea, // ModifiedSince: "0001-01-01T00:00:00.0000000Z", From ec45454b3d7daad7d1eba29bd2e86d989f0da8e1 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Thu, 13 Apr 2023 09:25:52 -0700 Subject: [PATCH 14/24] IO-2244 Restrict claimable productive hours based on remaining hours --- bodyshop_translations.babel | 189 ++++++++++++++++++ .../labor-allocations-table.utility.js | 4 - .../shop-info/shop-info.general.component.jsx | 7 + .../tech-job-clock-out-button.component.jsx | 67 ++++++- .../time-ticket-modal.component.jsx | 79 ++++++-- client/src/graphql/bodyshop.queries.js | 2 + client/src/translations/en_us/common.json | 6 +- client/src/translations/es/common.json | 5 +- client/src/translations/fr/common.json | 5 +- hasura/metadata/tables.yaml | 26 ++- .../down.sql | 4 + .../up.sql | 2 + 12 files changed, 360 insertions(+), 36 deletions(-) create mode 100644 hasura/migrations/1681331289298_alter_table_public_bodyshops_add_column_tt_enforce_hours_for_tech_console/down.sql create mode 100644 hasura/migrations/1681331289298_alter_table_public_bodyshops_add_column_tt_enforce_hours_for_tech_console/up.sql diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index 23707d6e7..f453df8c6 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -8864,6 +8864,27 @@ + + tt_enforce_hours_for_tech_console + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + use_fippa false @@ -17310,6 +17331,27 @@ + + total + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + totals false @@ -33806,6 +33848,27 @@ errors + + deleting + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + noaccess false @@ -34367,6 +34430,27 @@ + + deleteconfirm + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + existing_owners false @@ -34477,6 +34561,27 @@ successes + + delete + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + save false @@ -44980,6 +45085,27 @@ + + hoursenteredmorethanavailable + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + @@ -47292,6 +47418,27 @@ errors + + deleting + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + noaccess false @@ -47916,6 +48063,27 @@ labels + + deleteconfirm + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + fromvehicle false @@ -48005,6 +48173,27 @@ successes + + delete + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + save false diff --git a/client/src/components/labor-allocations-table/labor-allocations-table.utility.js b/client/src/components/labor-allocations-table/labor-allocations-table.utility.js index 2ce5b4a0b..d236de913 100644 --- a/client/src/components/labor-allocations-table/labor-allocations-table.utility.js +++ b/client/src/components/labor-allocations-table/labor-allocations-table.utility.js @@ -6,10 +6,6 @@ export const CalculateAllocationsTotals = ( timetickets, adjustments = [] ) => { - console.log( - "🚀 ~ file: labor-allocations-table.utility.js ~ line 9 ~ adjustments", - adjustments - ); const responsibilitycenters = bodyshop.md_responsibility_centers; const jobCodes = joblines.map((item) => item.mod_lbr_ty); //.filter((value, index, self) => self.indexOf(value) === index && !!value); diff --git a/client/src/components/shop-info/shop-info.general.component.jsx b/client/src/components/shop-info/shop-info.general.component.jsx index 3e9b1ed2c..32ac5aa5d 100644 --- a/client/src/components/shop-info/shop-info.general.component.jsx +++ b/client/src/components/shop-info/shop-info.general.component.jsx @@ -589,6 +589,13 @@ export default function ShopInfoGeneral({ form }) { > + + + e.id === (technician && technician.id) @@ -129,6 +141,51 @@ export function TechClockOffButton({ required: true, //message: t("general.validation.required"), }, + ({ getFieldValue }) => ({ + validator(rule, value) { + console.log( + bodyshop.tt_enforce_hours_for_tech_console + ); + if (!bodyshop.tt_enforce_hours_for_tech_console) { + return Promise.resolve(); + } + if ( + !value || + getFieldValue("cost_center") === null || + !lineTicketData + ) + return Promise.resolve(); + + //Check the cost center, + const totals = CalculateAllocationsTotals( + bodyshop, + lineTicketData.joblines, + lineTicketData.timetickets, + lineTicketData.jobs_by_pk.lbr_adjustments + ); + + const fieldTypeToCheck = + bodyshop.cdk_dealerid || bodyshop.pbs_serialnumber + ? "mod_lbr_ty" + : "cost_center"; + + const costCenterDiff = totals.find( + (total) => + total[fieldTypeToCheck] === + getFieldValue("cost_center") + )?.difference; + + if (value > costCenterDiff) + return Promise.reject( + t( + "timetickets.validation.hoursenteredmorethanavailable" + ) + ); + else { + return Promise.resolve(); + } + }, + }), ]} > @@ -178,7 +235,11 @@ export function TechClockOffButton({ {!isShiftTicket && ( - + )} diff --git a/client/src/components/time-ticket-modal/time-ticket-modal.component.jsx b/client/src/components/time-ticket-modal/time-ticket-modal.component.jsx index 6f61fccf0..6451a2c94 100644 --- a/client/src/components/time-ticket-modal/time-ticket-modal.component.jsx +++ b/client/src/components/time-ticket-modal/time-ticket-modal.component.jsx @@ -1,4 +1,4 @@ -import { useQuery } from "@apollo/client"; +import { useLazyQuery, useQuery } from "@apollo/client"; import { Form, Input, InputNumber, Select, Switch } from "antd"; import React from "react"; import { useTranslation } from "react-i18next"; @@ -18,6 +18,7 @@ import LayoutFormRow from "../layout-form-row/layout-form-row.component"; import LoadingSkeleton from "../loading-skeleton/loading-skeleton.component"; import { HasRbacAccess } from "../rbac-wrapper/rbac-wrapper.component"; import TimeTicketList from "../time-ticket-list/time-ticket-list.component"; +import { CalculateAllocationsTotals } from "../labor-allocations-table/labor-allocations-table.utility"; const mapStateToProps = createStructuredSelector({ bodyshop: selectBodyshop, @@ -38,7 +39,11 @@ export function TimeTicketModalComponent({ employeeSelectDisabled, }) { const { t } = useTranslation(); - + const [loadLineTicketData, { called, loading, data: lineTicketData }] = + useLazyQuery(GET_LINE_TICKET_BY_PK, { + fetchPolicy: "network-only", + nextFetchPolicy: "network-only", + }); const CostCenterSelect = ({ emps, value, ...props }) => { return (