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 9b96febaf..bffc9cfcb 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 @@ -1,12 +1,14 @@ import { CalendarOutlined } from "@ant-design/icons"; import { Card, Col, Row, Statistic } from "antd"; -import React from "react"; +import React, { useMemo } from "react"; import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; import { selectBodyshop } from "../../redux/user/user.selectors"; import ScoreboardJobsList from "../scoreboard-jobs-list/scoreboard-jobs-list.component"; import * as Util from "./scoreboard-targets-table.util"; +import _ from "lodash"; +import moment from "moment"; const mapStateToProps = createStructuredSelector({ bodyshop: selectBodyshop, @@ -16,25 +18,78 @@ const mapDispatchToProps = (dispatch) => ({ }); const rowGutter = [16, 16]; -const statSpans = { xs: 24, sm: 6 }; +const statSpans = { xs: 24, sm: 3 }; export function ScoreboardTargetsTable({ bodyshop, scoreBoardlist }) { const { t } = useTranslation(); + const values = useMemo(() => { + const dateHash = _.groupBy(scoreBoardlist, "date"); + console.log( + "🚀 ~ file: scoreboard-targets-table.component.jsx ~ line 31 ~ values ~ dateHash", + dateHash + ); + + let ret = { + todayBody: 0, + todayPaint: 0, + weeklyPaint: 0, + weeklyBody: 0, + toDateBody: 0, + toDatePaint: 0, + }; + + const today = moment().tz(bodyshop.timezone); + if (dateHash[today.format("YYYY-MM-DD")]) { + dateHash[today.format("YYYY-MM-DD")].forEach((d) => { + ret.todayBody = ret.todayBody + d.bodyhrs; + ret.todayPaint = ret.todayPaint + d.painthrs; + }); + } + + let StartOfWeek = moment().tz(bodyshop.timezone).startOf("week"); + while (StartOfWeek.isSameOrBefore(today)) { + if (dateHash[StartOfWeek.format("YYYY-MM-DD")]) { + dateHash[StartOfWeek.format("YYYY-MM-DD")].forEach((d) => { + ret.weeklyBody = ret.weeklyBody + d.bodyhrs; + ret.weeklyPaint = ret.weeklyPaint + d.painthrs; + }); + } + StartOfWeek = StartOfWeek.add(1, "day"); + } + + let startOfMonth = moment().tz(bodyshop.timezone).startOf("month"); + while (startOfMonth.isSameOrBefore(today)) { + if (dateHash[startOfMonth.format("YYYY-MM-DD")]) { + dateHash[startOfMonth.format("YYYY-MM-DD")].forEach((d) => { + ret.toDateBody = ret.toDateBody + d.bodyhrs; + ret.toDatePaint = ret.toDatePaint + d.painthrs; + }); + } + startOfMonth = startOfMonth.add(1, "day"); + } + + return ret; + }, [scoreBoardlist, bodyshop.timezone]); + console.log( + "🚀 ~ file: scoreboard-targets-table.component.jsx ~ line 51 ~ values ~ values", + values + ); + return ( } > - + } /> - + + + + + + + + + + @@ -78,6 +151,9 @@ export function ScoreboardTargetsTable({ bodyshop, scoreBoardlist }) { prefix="P" /> + + + + + + + + + diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json index c8a03c46d..57b0cc0f7 100644 --- a/client/src/translations/en_us/common.json +++ b/client/src/translations/en_us/common.json @@ -1557,7 +1557,7 @@ "partstotal": "Parts Total (ex. Taxes)", "plitooltips": { "billtotal": "The total amount of all bill lines that have been posted against this RO (not including credits, taxes, or labor adjustments).", - "creditmemos": "The total amount of all credit memos entered. This amount does not reflect any parts returns created.", + "creditmemos": "The total amount of all returns created. This amount does not reflect credit memos that have been posted.", "creditsnotreceived": "The total amount of returns created for this job that do not have a corresponding credit memo posted. An amount greater than $0 indicates that vendors have not provided requested credit memos.", "discrep1": "If the discrepancy is not $0, you may have one of the following:

\n\n\n
\nThere may be additional issues not listed above that prevent this job from reconciling.", "discrep2": "If the discrepancy is not $0, you may have one of the following:

\n\n\n
\nThere may be additional issues not listed above that prevent this job from reconciling.", @@ -2320,9 +2320,12 @@ }, "labels": { "asoftodaytarget": "As of Today", + "dailyactual": "Actual (D)", "dailytarget": "Daily", "monthlytarget": "Monthly", "targets": "Targets", + "todateactual": "Actual (MTD)", + "weeklyactual": "Actual (W)", "weeklytarget": "Weekly", "workingdays": "Working Days / Month" }, diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json index 3fa3cf7ec..a0055bdf3 100644 --- a/client/src/translations/es/common.json +++ b/client/src/translations/es/common.json @@ -2320,9 +2320,12 @@ }, "labels": { "asoftodaytarget": "", + "dailyactual": "", "dailytarget": "", "monthlytarget": "", "targets": "", + "todateactual": "", + "weeklyactual": "", "weeklytarget": "", "workingdays": "" }, diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json index f6ab1802d..882ae32a2 100644 --- a/client/src/translations/fr/common.json +++ b/client/src/translations/fr/common.json @@ -2320,9 +2320,12 @@ }, "labels": { "asoftodaytarget": "", + "dailyactual": "", "dailytarget": "", "monthlytarget": "", "targets": "", + "todateactual": "", + "weeklyactual": "", "weeklytarget": "", "workingdays": "" },