diff --git a/client/src/components/labor-allocations-table/labor-allocations-table.component.jsx b/client/src/components/labor-allocations-table/labor-allocations-table.component.jsx index 420bcb7c6..88cd67a45 100644 --- a/client/src/components/labor-allocations-table/labor-allocations-table.component.jsx +++ b/client/src/components/labor-allocations-table/labor-allocations-table.component.jsx @@ -1,5 +1,5 @@ import { EditFilled } from "@ant-design/icons"; -import { Card, Col, Row, Space, Table } from "antd"; +import { Card, Col, Row, Space, Table, Typography } from "antd"; import _ from "lodash"; import React, { useEffect, useMemo, useState } from "react"; import { useTranslation } from "react-i18next"; @@ -188,6 +188,19 @@ export function LaborAllocationsTable({ setState({ ...state, filteredInfo: filters, sortedInfo: sorter }); }; + const summary = + totals && + totals.reduce( + (acc, val) => { + acc.hrs_total += val.total; + acc.hrs_claimed += val.claimed; + acc.adjustments += val.adjustments; + acc.difference += val.difference; + return acc; + }, + { hrs_total: 0, hrs_claimed: 0, adjustments: 0, difference: 0 } + ); + return ( @@ -201,6 +214,27 @@ export function LaborAllocationsTable({ scroll={{ x: true, }} + summary={() => ( + + + + {t("general.labels.totals")} + + + + {summary.hrs_total.toFixed(1)} + + + {summary.hrs_claimed.toFixed(1)} + + + {summary.adjustments.toFixed(1)} + + + {summary.difference.toFixed(1)} + + + )} /> 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 02afcb107..2ce5b4a0b 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 @@ -39,7 +39,7 @@ export const CalculateAllocationsTotals = ( }, 0), }; - r.difference = (r.total + r.adjustments - r.claimed).toFixed(2); + r.difference = r.total + r.adjustments - r.claimed; acc.push(r); return acc; }, []);