Compare commits

...

14 Commits

Author SHA1 Message Date
Allan Carr
52cf4f3d1f IO-2893 Enhance disable of editing of tickets
Signed-off-by: Allan Carr <allan.carr@thinkimex.com>
2024-09-05 11:27:51 -07:00
Allan Carr
c994eaaa8e IO-2893 Correct RBACs for editing tickets
Signed-off-by: Allan Carr <allan.carr@thinkimex.com>
2024-08-29 13:48:39 -07:00
Allan Carr
517d8f4163 IO-2893 Editing Shift Tickets
Signed-off-by: Allan Carr <allan.carr@thinkimex.com>
2024-08-29 13:39:21 -07:00
Allan Carr
6e8122849a Merged in release/2024-08-23 (pull request #1665)
IO-2890 Update Time
2024-08-24 06:57:41 +00:00
Allan Carr
932979d5fb Merged in feature/IO-2890-Kaizen-Datapump-Cron (pull request #1663)
IO-2890 Update Time
2024-08-24 06:56:34 +00:00
Allan Carr
b04ae84941 IO-2890 Update Time
Signed-off-by: Allan Carr <allan.carr@thinkimex.com>
2024-08-23 23:56:37 -07:00
Dave Richer
f7ef32c58d Merged in release/2024-08-23 (pull request #1662)
Release/2024 08 23
2024-08-24 02:08:03 +00:00
Dave Richer
f7108b4b8c Merged in feature/IO-2834-Enhance-DateTime-Picker (pull request #1660)
- Final DateTimePicker update
2024-08-23 19:59:32 +00:00
Dave Richer
882038a794 - Final DateTimePicker update
Signed-off-by: Dave Richer <dave@imexsystems.ca>
2024-08-23 15:55:54 -04:00
Allan Carr
aec23fe46b Merged in feature/IO-2890-Kaizen-Datapump-Cron (pull request #1657)
IO-2890 Kaizen Datapump Cron

Approved-by: Dave Richer
2024-08-23 15:51:58 +00:00
Allan Carr
35ac0b0c6a IO-2890 Kaizen Datapump Cron
Signed-off-by: Allan Carr <allan.carr@thinkimex.com>
2024-08-22 16:36:00 -07:00
Allan Carr
2a2a0f8961 Merged in feature/IO-2520-Kaizen-Data-Pump (pull request #1655)
IO-2520 Change Logging back to default and adjust start and end to be default

Approved-by: Dave Richer
2024-08-22 20:28:01 +00:00
Allan Carr
d9902b9744 Merged in feature/IO-2895-Adjustment-to-bottom (pull request #1654)
IO-2895 Adjustment to Bottom Line
2024-08-22 20:12:46 +00:00
Allan Carr
f82478a362 IO-2895 Adjustment to Bottom Line
Signed-off-by: Allan Carr <allan.carr@thinkimex.com>
2024-08-22 13:11:00 -07:00
5 changed files with 155 additions and 235 deletions

View File

@@ -3,7 +3,7 @@ import PropTypes from "prop-types";
import React, { useCallback, useState } from "react";
import { useTranslation } from "react-i18next";
import dayjs from "../../utils/day";
import { dateFormats, dateTimeFormats } from "./formats.js";
import { fuzzyMatchDate } from "./formats.js";
const DateTimePicker = ({ value, onChange, onBlur, id, onlyFuture, onlyToday, isDateOnly = false, ...restProps }) => {
const [isManualInput, setIsManualInput] = useState(false);
@@ -11,79 +11,34 @@ const DateTimePicker = ({ value, onChange, onBlur, id, onlyFuture, onlyToday, is
const handleChange = useCallback(
(newDate) => {
if (newDate === null && onChange) {
onChange(null);
} else if (newDate && onChange) {
onChange(newDate);
if (onChange) {
onChange(newDate || null);
}
setIsManualInput(false);
},
[onChange]
);
const normalizeDateTimeString = (input) => {
const upperV = input.toUpperCase().replaceAll(".", "/").replaceAll("-", "/");
const [datePart, ...timeParts] = upperV.split(" ");
if (timeParts.length === 0) {
return datePart; // If there's no time part, just return the date part.
}
const timePart = timeParts.join(" "); // In case there are multiple spaces, join them back
// Normalize the time part by ensuring there's a space before AM/PM if not already present
const normalizedTime = timePart.replace(/(\d{1,2})(:\d{2})?\s?(AM|PM)/, "$1$2 $3");
// Combine the date part with the normalized time part
return `${datePart} ${normalizedTime}`.trim();
};
const handleBlur = useCallback(
(e) => {
// Bail if this is not a manual input
if (!isManualInput) {
return;
}
// Reset manual input flag
setIsManualInput(false);
const v = e.target.value;
const v = e?.target?.value;
if (!v) return;
const upperV = normalizeDateTimeString(v);
let parsedDate;
let parsedDate = isDateOnly ? fuzzyMatchDate(v)?.startOf("day") : fuzzyMatchDate(v);
for (const format of isDateOnly ? dateFormats : dateTimeFormats) {
parsedDate = dayjs(upperV, format);
if (parsedDate.isValid()) break;
}
if (parsedDate && parsedDate.isValid()) {
if (isDateOnly) {
parsedDate = parsedDate.startOf("day");
}
if (value && value.isValid && value.isValid()) {
parsedDate = parsedDate.set({
hours: value.hours(),
minutes: value.minutes(),
seconds: value.seconds(),
milliseconds: value.milliseconds()
});
}
if (onlyFuture) {
if (dayjs().subtract(1, "day").isBefore(parsedDate)) {
onChange(parsedDate);
} else {
onChange(dayjs().startOf("day"));
}
} else {
onChange(parsedDate);
}
if (parsedDate && onChange) {
onChange(parsedDate);
}
},
[isManualInput, isDateOnly, onlyFuture, onChange, value]
[isManualInput, isDateOnly, onChange]
);
const handleKeyDown = useCallback(

View File

@@ -1,96 +1,63 @@
export const dateTimeFormats = [
// Four-digit year with time
"M/D/YYYY h:mm A", // Example: 1/5/2023 9:00 AM
"M/D/YYYY h:mmA", // Example: 1/5/2023 9:00AM
"M/D/YYYY h A", // Example: 1/5/2023 9 AM
"M/D/YYYY hA", // Example: 1/5/2023 9AM
"M/D/YYYY hh:mm A", // Example: 1/5/2023 02:25 PM
"M/D/YYYY hh:mm:ss A", // Example: 1/5/2023 02:25:45 PM
import dayjs from "../../utils/day";
"MM/D/YYYY h:mm A", // Example: 12/5/2023 9:00 AM
"MM/D/YYYY h:mmA", // Example: 12/5/2023 9:00AM
"MM/D/YYYY h A", // Example: 12/5/2023 9 AM
"MM/D/YYYY hA", // Example: 12/5/2023 9AM
"MM/D/YYYY hh:mm A", // Example: 12/5/2023 02:25 PM
"MM/D/YYYY hh:mm:ss A", // Example: 12/5/2023 02:25:45 PM
"M/DD/YYYY h:mm A", // Example: 1/25/2023 9:00 AM
"M/DD/YYYY h:mmA", // Example: 1/25/2023 9:00AM
"M/DD/YYYY h A", // Example: 1/25/2023 9 AM
"M/DD/YYYY hA", // Example: 1/25/2023 9AM
"M/DD/YYYY hh:mm A", // Example: 1/25/2023 02:25 PM
"M/DD/YYYY hh:mm:ss A", // Example: 1/25/2023 02:25:45 PM
"MM/DD/YYYY h:mm A", // Example: 12/25/2023 9:00 AM
"MM/DD/YYYY h:mmA", // Example: 12/25/2023 9:00AM
"MM/DD/YYYY h A", // Example: 12/25/2023 9 AM
"MM/DD/YYYY hA", // Example: 12/25/2023 9AM
"MM/DD/YYYY hh:mm A", // Example: 12/25/2023 02:25 PM
"MM/DD/YYYY hh:mm:ss A", // Example: 12/25/2023 02:25:45 PM
// Two-digit year with time
"M/D/YY h:mm A", // Example: 1/5/23 9:00 AM
"M/D/YY h:mmA", // Example: 1/5/23 9:00AM
"M/D/YY h A", // Example: 1/5/23 9 AM
"M/D/YY hA", // Example: 1/5/23 9AM
"M/D/YY hh:mm A", // Example: 1/5/23 02:25 PM
"M/D/YY hh:mm:ss A", // Example: 1/5/23 02:25:45 PM
"MM/D/YY h:mm A", // Example: 12/5/23 9:00 AM
"MM/D/YY h:mmA", // Example: 12/5/23 9:00AM
"MM/D/YY h A", // Example: 12/5/23 9 AM
"MM/D/YY hA", // Example: 12/5/23 9AM
"MM/D/YY hh:mm A", // Example: 12/5/23 02:25 PM
"MM/D/YY hh:mm:ss A", // Example: 12/5/23 02:25:45 PM
"M/DD/YY h:mm A", // Example: 1/25/23 9:00 AM
"M/DD/YY h:mmA", // Example: 1/25/23 9:00AM
"M/DD/YY h A", // Example: 1/25/23 9 AM
"M/DD/YY hA", // Example: 1/25/23 9AM
"M/DD/YY hh:mm A", // Example: 1/25/23 02:25 PM
"M/DD/YY hh:mm:ss A", // Example: 1/25/23 02:25:45 PM
"MM/DD/YY h:mm A", // Example: 12/25/23 9:00 AM
"MM/DD/YY h:mmA", // Example: 12/25/23 9:00AM
"MM/DD/YY h A", // Example: 12/25/23 9 AM
"MM/DD/YY hA", // Example: 12/25/23 9AM
"MM/DD/YY hh:mm A", // Example: 12/25/23 02:25 PM
"MM/DD/YY hh:mm:ss A", // Example: 12/25/23 02:25:45 PM
// Four-digit year without time
"M/D/YYYY", // Example: 1/5/2023
"MM/D/YYYY", // Example: 12/5/2023
"M/DD/YYYY", // Example: 1/25/2023
"MM/DD/YYYY", // Example: 12/25/2023
// Two-digit year without time
"M/D/YY", // Example: 1/5/23
"MM/D/YY", // Example: 12/5/23
"M/DD/YY", // Example: 1/25/23
"MM/DD/YY" // Example: 12/25/23
];
// CONFIRMED
export const dateFormats = [
const dateFormats = [
"MMDDYYYY",
"MMDDYY",
// Four-digit year
"M/D/YYYY", // Example: 1/5/2023
"MM/D/YYYY", // Example: 12/5/2023
"M/DD/YYYY", // Example: 1/25/2023
"MM/DD/YYYY", // Example: 12/25/2023
// Two-digit year
"M/D/YY", // Example: 1/5/23
"MM/D/YY", // Example: 12/5/23
"M/DD/YY", // Example: 1/25/23
"MM/DD/YY", // Example: 12/25/23
// Explicitly handle single-digit month and day
"M/D/YY", // Example: 1/5/23
"M/D/YYYY", // Example: 1/5/2023
"M/DD/YY", // Example: 1/25/23
"M/DD/YYYY", // Example: 1/25/2023
"MM/D/YY", // Example: 12/5/23
"MM/D/YYYY" // Example: 12/5/2023
"M/D/YYYY",
"MM/D/YYYY",
"M/DD/YYYY",
"MM/DD/YYYY",
"M/D/YY",
"MM/D/YY",
"M/DD/YY",
"MM/DD/YY"
];
const timeFormats = ["h:mm A", "h:mmA", "h A", "hA", "hh:mm A", "hh:mm:ss A"];
const dateTimeFormats = [
...["M/D/YYYY", "MM/D/YYYY", "M/DD/YYYY", "MM/DD/YYYY", "M/D/YY", "MM/D/YY", "M/DD/YY", "MM/DD/YY"].flatMap(
(dateFormat) => timeFormats.map((timeFormat) => `${dateFormat} ${timeFormat}`)
),
...["MMDDYYYY", "MMDDYY"].flatMap((dateFormat) => timeFormats.map((timeFormat) => `${dateFormat} ${timeFormat}`)),
"M/D/YYYY",
"MM/D/YYYY",
"M/DD/YYYY",
"MM/DD/YYYY",
"M/D/YY",
"MM/D/YY",
"M/DD/YY",
"MM/DD/YY",
"MMDDYYYY",
"MMDDYY"
];
const sanitizeInput = (input) =>
input
.trim()
.toUpperCase()
.replace(/\s*(am|pm)\s*/i, " $1")
.replaceAll(".", "/")
.replaceAll("-", "/");
export const fuzzyMatchDate = (dateString) => {
const sanitizedInput = sanitizeInput(dateString);
for (const format of dateFormats) {
const parsedDate = dayjs(sanitizedInput, format, true);
if (parsedDate.isValid()) {
return parsedDate;
}
}
for (const format of dateTimeFormats) {
const parsedDateTime = dayjs(sanitizedInput, format, true);
if (parsedDateTime.isValid()) {
return parsedDateTime; // Return the dayjs object
}
}
return null; // If no matching format is found
};

View File

@@ -1,6 +1,6 @@
import { EditFilled, SyncOutlined } from "@ant-design/icons";
import { useSplitTreatments } from "@splitsoftware/splitio-react";
import { Button, Card, Checkbox, Space, Table } from "antd";
import dayjs from "../../utils/day";
import React, { useMemo, useState } from "react";
import { useTranslation } from "react-i18next";
import { connect } from "react-redux";
@@ -10,10 +10,10 @@ import { setModalContext } from "../../redux/modals/modals.actions";
import { selectAuthLevel, selectBodyshop, selectCurrentUser } from "../../redux/user/user.selectors";
import { DateFormatter, DateTimeFormatter } from "../../utils/DateFormatter";
import { onlyUnique } from "../../utils/arrayHelper";
import dayjs from "../../utils/day";
import { alphaSort, dateSort } from "../../utils/sorters";
import RbacWrapper, { HasRbacAccess } from "../rbac-wrapper/rbac-wrapper.component";
import { HasRbacAccess } from "../rbac-wrapper/rbac-wrapper.component";
import TimeTicketEnterButton from "../time-ticket-enter-button/time-ticket-enter-button.component";
import { useSplitTreatments } from "@splitsoftware/splitio-react";
const mapStateToProps = createStructuredSelector({
bodyshop: selectBodyshop,
@@ -52,6 +52,10 @@ export function TimeTicketList({
splitKey: bodyshop.imexshopid
});
const canEditCommittedTimeTickets = HasRbacAccess({ bodyshop, authLevel, action: "timetickets:editcommitted" });
const canEditTimeTickets = HasRbacAccess({ bodyshop, authLevel, action: "timetickets:edit" });
const canEditShiftTickets = HasRbacAccess({ bodyshop, authLevel, action: "timetickets:shiftedit" });
const totals = useMemo(() => {
if (timetickets)
return timetickets.reduce(
@@ -65,6 +69,18 @@ export function TimeTicketList({
return { productivehrs: 0, actualhrs: 0 };
}, [timetickets]);
const isDisabled = (record) => {
if (disabled === true || !record.id) return true;
const isShiftTicket = !record.ciecacode;
const isCommitted = record.committed_at;
if (isShiftTicket) {
return !(canEditShiftTickets && (!isCommitted || canEditCommittedTimeTickets));
}
return !(canEditTimeTickets && (!isCommitted || canEditCommittedTimeTickets));
};
const columns = [
...(Enhanced_Payroll.treatment === "on"
? [
@@ -206,76 +222,55 @@ export function TimeTicketList({
return null;
}
}
},
}
]),
{
title: t("timetickets.fields.created_by"),
dataIndex: "created_by",
key: "created_by",
sorter: (a, b) => alphaSort(a.created_by, b.created_by),
sortOrder: state.sortedInfo.columnKey === "created_by" && state.sortedInfo.order,
render: (text, record) => record.created_by
},
// {
// title: "Pay",
// dataIndex: "pay",
// key: "pay",
// render: (text, record) =>
// Dinero({ amount: Math.round(record.rate * 100) })
// .multiply(record.flat_rate ? record.productivehrs : record.actualhrs)
// .toFormat("$0.00"),
// },
{
title: t("general.labels.actions"),
dataIndex: "actions",
key: "actions",
render: (text, record) => (
<Space wrap>
{techConsole && (
<TimeTicketEnterButton
actions={{ refetch }}
context={{ id: record.id, timeticket: record }}
disabled={!record.job || disabled}
>
<EditFilled />
</TimeTicketEnterButton>
)}
{!techConsole && (
<RbacWrapper
action="timetickets:edit"
noauth={() => {
return <div />;
}}
>
<TimeTicketEnterButton
actions={{ refetch }}
context={{
id: record.id,
timeticket: record
}}
disabled={
HasRbacAccess({
bodyshop,
authLevel: authLevel,
action: "timetickets:editcommitted"
}) &&
HasRbacAccess({
bodyshop,
authLevel: authLevel,
action: "timetickets:shiftedit"
})
? disabled
: !record.jobid
}
>
<EditFilled />
</TimeTicketEnterButton>
</RbacWrapper>
)}
</Space>
)
}
{
title: t("timetickets.fields.created_by"),
dataIndex: "created_by",
key: "created_by",
sorter: (a, b) => alphaSort(a.created_by, b.created_by),
sortOrder: state.sortedInfo.columnKey === "created_by" && state.sortedInfo.order,
render: (text, record) => record.created_by
},
// {
// title: "Pay",
// dataIndex: "pay",
// key: "pay",
// render: (text, record) =>
// Dinero({ amount: Math.round(record.rate * 100) })
// .multiply(record.flat_rate ? record.productivehrs : record.actualhrs)
// .toFormat("$0.00"),
// },
{
title: t("general.labels.actions"),
dataIndex: "actions",
key: "actions",
render: (text, record) => (
<Space wrap>
{techConsole && (
<TimeTicketEnterButton
actions={{ refetch }}
context={{ id: record.id, timeticket: record }}
disabled={!record.job || disabled}
>
<EditFilled />
</TimeTicketEnterButton>
)}
{!techConsole && (
<TimeTicketEnterButton
actions={{ refetch }}
context={{
id: record.id,
timeticket: record
}}
disabled={isDisabled(record)}
>
<EditFilled />
</TimeTicketEnterButton>
)}
</Space>
)
}
];
const handleTableChange = (pagination, filters, sorter) => {

View File

@@ -1,3 +1,11 @@
- name: Kaizen Data Pump
webhook: '{{HASURA_API_URL}}/data/kaizen'
schedule: 30 5 * * *
include_in_metadata: true
payload: {}
headers:
- name: x-imex-auth
value_from_env: DATAPUMP_AUTH
- name: Task Reminders
webhook: '{{HASURA_API_URL}}/tasks-remind-handler'
schedule: '*/15 * * * *'

View File

@@ -965,22 +965,17 @@ function CalculateTaxesTotals(job, otherTotals) {
}
});
if (job.adjustment_bottom_line) {
const subtotal_before_adjustment = subtotal.add(Dinero({ amount: Math.round(job.adjustment_bottom_line * -100) }));
const percent_of_adjustment =
Math.round(
subtotal_before_adjustment.toUnit() /
(job.adjustment_bottom_line > 0 ? job.adjustment_bottom_line : job.adjustment_bottom_line * -1)
) / 100;
Object.keys(taxableAmountsByTier).forEach((taxTierKey) => {
taxable_adjustment = taxableAmountsByTier[taxTierKey].multiply(percent_of_adjustment);
if (job.adjustment_bottom_line > 0) {
taxableAmountsByTier[taxTierKey] = taxableAmountsByTier[taxTierKey].add(taxable_adjustment);
} else {
taxableAmountsByTier[taxTierKey] = taxableAmountsByTier[taxTierKey].subtract(taxable_adjustment);
if (job.adjustment_bottom_line && job.adjustment_bottom_line !== 0) {
for (let tyCounter = 1; tyCounter <= 5; tyCounter++) {
if (IsTrueOrYes(pfp["PAN"][`prt_tx_in${tyCounter}`])) {
//This amount is taxable for this type.
taxableAmountsByTier[`ty${tyCounter}Tax`] = taxableAmountsByTier[`ty${tyCounter}Tax`].add(
Dinero({
amount: Math.round(job.adjustment_bottom_line * 100)
})
);
}
});
}
}
const remainingTaxableAmounts = taxableAmountsByTier;