From c7bb1a9c322918e446e0ddf83fd8dfdd3c1766f9 Mon Sep 17 00:00:00 2001 From: Dave Date: Thu, 12 Mar 2026 12:19:34 -0400 Subject: [PATCH] feature/IO-3587-Comission-Cut - Implement --- .../read-only-form-item.component.jsx | 2 +- ...or-allocations-table.payroll.component.jsx | 54 +- .../shop-info.task-presets.component.jsx | 52 +- .../shop-employee-teams.form.component.jsx | 323 +++++------ .../time-ticket-task-modal.component.jsx | 22 +- .../time-ticket-task-modal.container.jsx | 11 +- .../tt-approvals-list.component.jsx | 16 +- .../tt-approve-button.component.jsx | 18 +- client/src/graphql/bodyshop.queries.js | 4 + client/src/graphql/employee_teams.queries.js | 12 + client/src/graphql/timetickets.queries.js | 4 + client/src/graphql/tt-approvals.queries.js | 19 + hasura/metadata/tables.yaml | 12 + .../down.sql | 4 + .../up.sql | 2 + .../down.sql | 4 + .../up.sql | 2 + .../down.sql | 4 + .../up.sql | 2 + .../down.sql | 4 + .../up.sql | 2 + server/graphql-client/queries.js | 104 +--- server/payroll/calculate-totals.js | 66 +-- server/payroll/claim-task.js | 99 +++- server/payroll/pay-all.js | 501 +++++++++++------- server/payroll/payroll.test.js | 367 +++++++++++++ 26 files changed, 1110 insertions(+), 600 deletions(-) create mode 100644 hasura/migrations/1773331250571_alter_table_public_employee_team_members_add_column_payout_method/down.sql create mode 100644 hasura/migrations/1773331250571_alter_table_public_employee_team_members_add_column_payout_method/up.sql create mode 100644 hasura/migrations/1773331301662_alter_table_public_employee_team_members_add_column_commission_rates/down.sql create mode 100644 hasura/migrations/1773331301662_alter_table_public_employee_team_members_add_column_commission_rates/up.sql create mode 100644 hasura/migrations/1773331441524_alter_table_public_timetickets_add_column_payout_context/down.sql create mode 100644 hasura/migrations/1773331441524_alter_table_public_timetickets_add_column_payout_context/up.sql create mode 100644 hasura/migrations/1773331546522_alter_table_public_tt_approval_queue_add_column_payout_context/down.sql create mode 100644 hasura/migrations/1773331546522_alter_table_public_tt_approval_queue_add_column_payout_context/up.sql create mode 100644 server/payroll/payroll.test.js diff --git a/client/src/components/form-items-formatted/read-only-form-item.component.jsx b/client/src/components/form-items-formatted/read-only-form-item.component.jsx index 786d6a1a0..fc9a4df56 100644 --- a/client/src/components/form-items-formatted/read-only-form-item.component.jsx +++ b/client/src/components/form-items-formatted/read-only-form-item.component.jsx @@ -11,7 +11,7 @@ const mapDispatchToProps = () => ({ }); const ReadOnlyFormItem = ({ bodyshop, value, type = "text" }) => { - if (!value) return null; + if (value === null || value === undefined || value === "") return null; switch (type) { case "employee": { const emp = bodyshop.employees.find((e) => e.id === value); diff --git a/client/src/components/labor-allocations-table/labor-allocations-table.payroll.component.jsx b/client/src/components/labor-allocations-table/labor-allocations-table.payroll.component.jsx index 3bcc32f14..02a9366f6 100644 --- a/client/src/components/labor-allocations-table/labor-allocations-table.payroll.component.jsx +++ b/client/src/components/labor-allocations-table/labor-allocations-table.payroll.component.jsx @@ -21,6 +21,8 @@ const mapStateToProps = createStructuredSelector({ technician: selectTechnician }); +const getRequestErrorMessage = (error) => error?.response?.data?.error || error?.message || ""; + export function PayrollLaborAllocationsTable({ jobId, joblines, @@ -43,16 +45,23 @@ export function PayrollLaborAllocationsTable({ }); const notification = useNotification(); - useEffect(() => { - async function CalculateTotals() { + const loadTotals = async () => { + try { const { data } = await axios.post("/payroll/calculatelabor", { jobid: jobId }); setTotals(data); + } catch (error) { + setTotals([]); + notification.error({ + title: getRequestErrorMessage(error) + }); } + }; + useEffect(() => { if (!!joblines && !!timetickets && !!bodyshop) { - CalculateTotals(); + loadTotals(); } if (!jobId) setTotals([]); }, [joblines, timetickets, bodyshop, adjustments, jobId]); @@ -210,28 +219,36 @@ export function PayrollLaborAllocationsTable({