Validation and confirmation messages.

This commit is contained in:
Patrick Fic
2023-08-03 14:14:01 -07:00
parent 1d7f1cccba
commit 3e8660bb61
9 changed files with 127 additions and 39 deletions

View File

@@ -46289,6 +46289,27 @@
</translation> </translation>
</translations> </translations>
</concept_node> </concept_node>
<concept_node>
<name>payall</name>
<definition_loaded>false</definition_loaded>
<description></description>
<comment></comment>
<default_text></default_text>
<translations>
<translation>
<language>en-US</language>
<approved>false</approved>
</translation>
<translation>
<language>es-MX</language>
<approved>false</approved>
</translation>
<translation>
<language>fr-CA</language>
<approved>false</approved>
</translation>
</translations>
</concept_node>
<concept_node> <concept_node>
<name>shiftalreadyclockedon</name> <name>shiftalreadyclockedon</name>
<definition_loaded>false</definition_loaded> <definition_loaded>false</definition_loaded>
@@ -47249,6 +47270,27 @@
</translation> </translation>
</translations> </translations>
</concept_node> </concept_node>
<concept_node>
<name>payall</name>
<definition_loaded>false</definition_loaded>
<description></description>
<comment></comment>
<default_text></default_text>
<translations>
<translation>
<language>en-US</language>
<approved>false</approved>
</translation>
<translation>
<language>es-MX</language>
<approved>false</approved>
</translation>
<translation>
<language>fr-CA</language>
<approved>false</approved>
</translation>
</translations>
</concept_node>
</children> </children>
</folder_node> </folder_node>
<folder_node> <folder_node>

View File

@@ -1,5 +1,14 @@
import { Button, Card, Col, Row, Space, Table, Typography } from "antd"; import {
import { SyncOutlined } from '@ant-design/icons' Button,
Card,
Col,
Row,
Space,
Table,
Typography,
notification,
} from "antd";
import { SyncOutlined } from "@ant-design/icons";
import axios from "axios"; import axios from "axios";
import _ from "lodash"; import _ from "lodash";
import React, { useEffect, useMemo, useState } from "react"; import React, { useEffect, useMemo, useState } from "react";
@@ -225,10 +234,34 @@ export function PayrollLaborAllocationsTable({
<Space> <Space>
<Button <Button
onClick={async () => { onClick={async () => {
await axios.post("/payroll/payall", { const response = await axios.post("/payroll/payall", {
jobid: jobId, jobid: jobId,
}); });
if (refetch) refetch();
if (response.status === 200) {
if (response.data.success) {
notification.open({
type: "success",
message: t("timetickets.successes.payall"),
});
} else {
notification.open({
type: "error",
message: t("timetickets.errors.payall", {
error: response.data.error,
}),
});
}
if (refetch) refetch();
} else {
notification.open({
type: "error",
message: t("timetickets.errors.payall", {
error: JSON.stringify(""),
}),
});
}
}} }}
> >
{t("timetickets.actions.payall")} {t("timetickets.actions.payall")}
@@ -242,7 +275,7 @@ export function PayrollLaborAllocationsTable({
refetch(); refetch();
}} }}
> >
<SyncOutlined/> <SyncOutlined />
</Button> </Button>
</Space> </Space>
} }

View File

@@ -1,4 +1,8 @@
import Icon, { SearchOutlined, ScheduleOutlined } from "@ant-design/icons"; import Icon, {
SearchOutlined,
ScheduleOutlined,
UserAddOutlined,
} from "@ant-design/icons";
import { Layout, Menu } from "antd"; import { Layout, Menu } from "antd";
import React, { useState } from "react"; import React, { useState } from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
@@ -68,19 +72,28 @@ export function TechSider({
<Link to={`/tech/joblookup`}>{t("menus.tech.joblookup")}</Link> <Link to={`/tech/joblookup`}>{t("menus.tech.joblookup")}</Link>
</Menu.Item> </Menu.Item>
{Enhanced_Payroll.treatment === "on" ? ( {Enhanced_Payroll.treatment === "on" ? (
<Menu.Item <>
key="3" <Menu.Item
disabled={!!!technician} key="TechAssignedProdJobs"
icon={<Icon component={FaBusinessTime} />} disabled={!!!technician}
onClick={() => { icon={<UserAddOutlined />}
setTimeTicketTaskContext({ >
actions: {}, <Link to={`/tech/assigned`}> {t("menus.tech.assignedjobs")}</Link>
context: { jobid: null }, </Menu.Item>
}); <Menu.Item
}} key="3"
> disabled={!!!technician}
{t("menus.tech.claimtask")} icon={<Icon component={FaBusinessTime} />}
</Menu.Item> onClick={() => {
setTimeTicketTaskContext({
actions: {},
context: { jobid: null },
});
}}
>
{t("menus.tech.claimtask")}
</Menu.Item>
</>
) : ( ) : (
<Menu.Item <Menu.Item
key="3" key="3"
@@ -107,13 +120,7 @@ export function TechSider({
> >
<Link to={`/tech/board`}> {t("menus.tech.productionboard")}</Link> <Link to={`/tech/board`}> {t("menus.tech.productionboard")}</Link>
</Menu.Item> </Menu.Item>
<Menu.Item
key="TechAssignedProdJobs"
disabled={!!!technician}
icon={<Icon component={BsKanban} />}
>
<Link to={`/tech/assigned`}> {t("menus.tech.assignedjobs")}</Link>
</Menu.Item>
<Menu.Item <Menu.Item
key="7" key="7"
disabled={!!!technician} disabled={!!!technician}

View File

@@ -74,7 +74,7 @@ export function TimeTicketTaskModalComponent({
<Form.Item dependencies={["task"]}> <Form.Item dependencies={["task"]}>
{() => { {() => {
const { task } = form.getFieldsValue(); const { task } = form.getFieldsValue();
const theTaskPreset = bodyshop.md_tasks_presets.presets.find( const theTaskPreset = bodyshop.md_tasks_presets?.presets?.find(
(tp) => tp.name === task (tp) => tp.name === task
); );

View File

@@ -178,7 +178,7 @@ export function TechAssignedProdJobs({
}, },
}, },
{ {
title: t("jobs.labels.actions"), title: t("general.labels.actions"),
dataIndex: "actions", dataIndex: "actions",
key: "actions", key: "actions",
render: (text, record) => ( render: (text, record) => (

View File

@@ -2746,6 +2746,7 @@
"deleting": "Error deleting time ticket. {{message}}", "deleting": "Error deleting time ticket. {{message}}",
"noemployeeforuser": "Unable to use Shift Clock", "noemployeeforuser": "Unable to use Shift Clock",
"noemployeeforuser_sub": "An employee record has not been created for this user. Please create one before using the shift clock. ", "noemployeeforuser_sub": "An employee record has not been created for this user. Please create one before using the shift clock. ",
"payall": "Error flagging hours. {{error}}",
"shiftalreadyclockedon": "You are already clocked onto a shift. Unable to create shift entry." "shiftalreadyclockedon": "You are already clocked onto a shift. Unable to create shift entry."
}, },
"fields": { "fields": {
@@ -2796,7 +2797,8 @@
"clockedout": "Clocked out successfully.", "clockedout": "Clocked out successfully.",
"committed": "Time Tickets Committed Successfully", "committed": "Time Tickets Committed Successfully",
"created": "Time ticket entered successfully.", "created": "Time ticket entered successfully.",
"deleted": "Time ticket deleted successfully." "deleted": "Time ticket deleted successfully.",
"payall": "All hours paid out successfully."
}, },
"validation": { "validation": {
"clockoffmustbeafterclockon": "Clock off time must be the same or after clock in time.", "clockoffmustbeafterclockon": "Clock off time must be the same or after clock in time.",

View File

@@ -2746,6 +2746,7 @@
"deleting": "", "deleting": "",
"noemployeeforuser": "", "noemployeeforuser": "",
"noemployeeforuser_sub": "", "noemployeeforuser_sub": "",
"payall": "",
"shiftalreadyclockedon": "" "shiftalreadyclockedon": ""
}, },
"fields": { "fields": {
@@ -2796,7 +2797,8 @@
"clockedout": "", "clockedout": "",
"committed": "", "committed": "",
"created": "", "created": "",
"deleted": "" "deleted": "",
"payall": ""
}, },
"validation": { "validation": {
"clockoffmustbeafterclockon": "", "clockoffmustbeafterclockon": "",

View File

@@ -2746,6 +2746,7 @@
"deleting": "", "deleting": "",
"noemployeeforuser": "", "noemployeeforuser": "",
"noemployeeforuser_sub": "", "noemployeeforuser_sub": "",
"payall": "",
"shiftalreadyclockedon": "" "shiftalreadyclockedon": ""
}, },
"fields": { "fields": {
@@ -2796,7 +2797,8 @@
"clockedout": "", "clockedout": "",
"committed": "", "committed": "",
"created": "", "created": "",
"deleted": "" "deleted": "",
"payall": ""
}, },
"validation": { "validation": {
"clockoffmustbeafterclockon": "", "clockoffmustbeafterclockon": "",

View File

@@ -32,7 +32,7 @@ exports.payall = async function (req, res) {
const { employeeHash, assignmentHash } = CalculateExpectedHoursForJob(job); const { employeeHash, assignmentHash } = CalculateExpectedHoursForJob(job);
const ticketHash = CalculateTicketsHoursForJob(job); const ticketHash = CalculateTicketsHoursForJob(job);
if (assignmentHash.unassigned > 0) { if (assignmentHash.unassigned > 0) {
res.json({ success: false, error: "Unassigned hours." }); res.json({ success: false, error: "Not all hours have been assigned." });
return; return;
} }
@@ -65,7 +65,7 @@ exports.payall = async function (req, res) {
cost_center: cost_center:
job.bodyshop.md_responsibility_centers.defaults.costs[key], job.bodyshop.md_responsibility_centers.defaults.costs[key],
flat_rate: true, flat_rate: true,
memo: `*SYS-PAY* Add unflagged hours. (${req.user.email})`, memo: `Add unflagged hours. (${req.user.email})`,
}); });
}); });
} else { } else {
@@ -83,7 +83,7 @@ exports.payall = async function (req, res) {
job.bodyshop.md_responsibility_centers.defaults.costs[ job.bodyshop.md_responsibility_centers.defaults.costs[
path.mod_lbr_ty path.mod_lbr_ty
], ],
memo: `*SYS-PAY* Add unflagged hours. (${req.user.email})`, memo: `Add unflagged hours. (${req.user.email})`,
}); });
} }
} else if (diff.op === "update") { } else if (diff.op === "update") {
@@ -102,7 +102,7 @@ exports.payall = async function (req, res) {
job.bodyshop.md_responsibility_centers.defaults.costs[ job.bodyshop.md_responsibility_centers.defaults.costs[
path.mod_lbr_ty path.mod_lbr_ty
], ],
memo: `*SYS-PAY* Adjust flagged hours per assignment. (${req.user.email})`, memo: `Adjust flagged hours per assignment. (${req.user.email})`,
}); });
} else { } else {
//Has to be a delete //Has to be a delete
@@ -124,7 +124,7 @@ exports.payall = async function (req, res) {
cost_center: cost_center:
job.bodyshop.md_responsibility_centers.defaults.costs[key], job.bodyshop.md_responsibility_centers.defaults.costs[key],
flat_rate: true, flat_rate: true,
memo: `*SYS-PAY* Remove flagged hours per assignment. (${req.user.email})`, memo: `Remove flagged hours per assignment. (${req.user.email})`,
}); });
}); });
} else { } else {
@@ -142,7 +142,7 @@ exports.payall = async function (req, res) {
path.mod_lbr_ty path.mod_lbr_ty
], ],
flat_rate: true, flat_rate: true,
memo: `*SYS-PAY* Remove flagged hours per assignment. (${req.user.email})`, memo: `Remove flagged hours per assignment. (${req.user.email})`,
}); });
} }
} }
@@ -163,10 +163,10 @@ exports.payall = async function (req, res) {
jobid, jobid,
{ {
jobid: jobid, jobid: jobid,
error, error: JSON.stringify(error),
} }
); );
res.status(503).send(); res.status(400).json({ error: error.message });
} }
}; };