feature/IO-3587-Comission-Cut - Implement

This commit is contained in:
Dave
2026-03-12 12:19:34 -04:00
parent b9b3e2c2aa
commit c7bb1a9c32
26 changed files with 1110 additions and 600 deletions

View File

@@ -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({
<Button
disabled={!hasTimeTicketAccess}
onClick={async () => {
const response = await axios.post("/payroll/payall", {
jobid: jobId
});
try {
const response = await axios.post("/payroll/payall", {
jobid: jobId
});
if (response.status === 200) {
if (response.data.success !== false) {
notification.success({
title: t("timetickets.successes.payall")
});
if (response.status === 200) {
if (response.data.success !== false) {
notification.success({
title: t("timetickets.successes.payall")
});
} else {
notification.error({
title: t("timetickets.errors.payall", {
error: response.data.error
})
});
}
if (refetch) refetch();
} else {
notification.error({
title: t("timetickets.errors.payall", {
error: response.data.error
error: JSON.stringify("")
})
});
}
if (refetch) refetch();
} else {
} catch (error) {
notification.error({
title: t("timetickets.errors.payall", {
error: JSON.stringify("")
error: getRequestErrorMessage(error)
})
});
}
@@ -241,10 +258,7 @@ export function PayrollLaborAllocationsTable({
</Button>
<Button
onClick={async () => {
const { data } = await axios.post("/payroll/calculatelabor", {
jobid: jobId
});
setTotals(data);
await loadTotals();
refetch();
}}
icon={<SyncOutlined />}