Merge remote-tracking branch 'origin/master-AIO' into feature/IO-2433-esignature

This commit is contained in:
Patrick Fic
2026-03-23 12:57:38 -07:00
44 changed files with 1555 additions and 317 deletions

View File

@@ -2696,6 +2696,27 @@
</translation> </translation>
</translations> </translations>
</concept_node> </concept_node>
<concept_node>
<name>oem_partno</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>quantity</name> <name>quantity</name>
<definition_loaded>false</definition_loaded> <definition_loaded>false</definition_loaded>
@@ -3684,6 +3705,48 @@
</translation> </translation>
</translations> </translations>
</concept_node> </concept_node>
<concept_node>
<name>feedback_placeholder</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>
<name>feedback_prompt</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>generic_failure</name> <name>generic_failure</name>
<definition_loaded>false</definition_loaded> <definition_loaded>false</definition_loaded>
@@ -3831,6 +3894,27 @@
</translation> </translation>
</translations> </translations>
</concept_node> </concept_node>
<concept_node>
<name>submit_feedback</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>
<concept_node> <concept_node>
@@ -8641,6 +8725,27 @@
</translation> </translation>
</translations> </translations>
</concept_node> </concept_node>
<concept_node>
<name>manual-line</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>partsqueue</name> <name>partsqueue</name>
<definition_loaded>false</definition_loaded> <definition_loaded>false</definition_loaded>
@@ -17816,6 +17921,468 @@
<folder_node> <folder_node>
<name>labels</name> <name>labels</name>
<children> <children>
<concept_node>
<name>banner_message</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>
<name>banner_status_connected</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>
<name>banner_status_disconnected</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>
<name>clear_logs</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>
<name>collapse_all</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>
<name>color_json</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>
<name>copied</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>
<name>copy</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>
<name>copy_request</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>
<name>copy_response</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>
<name>details</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>
<name>expand_all</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>
<name>hide_details</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>
<name>log_level</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>
<name>plain_json</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>
<name>provider_cdk</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>
<name>provider_dms</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>
<name>provider_fortellis</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>
<name>provider_pbs</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>
<name>provider_reynolds</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>
<name>reconnect</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>
<name>reconnected_export_service</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>refreshallocations</name> <name>refreshallocations</name>
<definition_loaded>false</definition_loaded> <definition_loaded>false</definition_loaded>
@@ -17837,6 +18404,153 @@
</translation> </translation>
</translations> </translations>
</concept_node> </concept_node>
<concept_node>
<name>request_xml</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>
<name>response_xml</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>
<name>rr_validation_message</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>
<name>rr_validation_notice_description</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>
<name>rr_validation_notice_title</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>
<name>transport_ws</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>
<name>transport_wss</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>
</children> </children>
@@ -20590,6 +21304,27 @@
</translation> </translation>
</translations> </translations>
</concept_node> </concept_node>
<concept_node>
<name>done</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>download</name> <name>download</name>
<definition_loaded>false</definition_loaded> <definition_loaded>false</definition_loaded>
@@ -23009,6 +23744,27 @@
</translation> </translation>
</translations> </translations>
</concept_node> </concept_node>
<concept_node>
<name>validationerror</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>view</name> <name>view</name>
<definition_loaded>false</definition_loaded> <definition_loaded>false</definition_loaded>
@@ -23423,6 +24179,27 @@
<folder_node> <folder_node>
<name>validation</name> <name>validation</name>
<children> <children>
<concept_node>
<name>array</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>dateRangeExceeded</name> <name>dateRangeExceeded</name>
<definition_loaded>false</definition_loaded> <definition_loaded>false</definition_loaded>
@@ -57452,6 +58229,27 @@
</translation> </translation>
</translations> </translations>
</concept_node> </concept_node>
<concept_node>
<name>work_in_progress_labour_summary</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>work_in_progress_payables</name> <name>work_in_progress_payables</name>
<definition_loaded>false</definition_loaded> <definition_loaded>false</definition_loaded>
@@ -57473,6 +58271,27 @@
</translation> </translation>
</translations> </translations>
</concept_node> </concept_node>
<concept_node>
<name>work_in_progress_payables_summary</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>
</children> </children>

View File

@@ -0,0 +1,118 @@
import { DislikeOutlined, LikeOutlined } from "@ant-design/icons";
import { Button, Form, Input, Radio, Space } from "antd";
import axios from "axios";
import { useState } from "react";
import { useNotification } from "../../contexts/Notifications/notificationContext.jsx";
import { useTranslation } from "react-i18next";
import { connect } from "react-redux";
import { selectBodyshop } from "../../redux/user/user.selectors.js";
import { createStructuredSelector } from "reselect";
const mapStateToProps = createStructuredSelector({
bodyshop: selectBodyshop
});
function BillAiFeedback({ billForm, rawAIData, bodyshop }) {
const { t } = useTranslation();
const [form] = Form.useForm();
const [submitting, setSubmitting] = useState(false);
const notification = useNotification();
//Need to sanitize becuase we pass as form data to include the attachment.
const sanitizeBillFormValues = (value) => {
const seen = new WeakSet();
return JSON.stringify(
value,
(key, v) => {
if (key === "originFileObj") return undefined;
if (key === "thumbUrl") return undefined;
if (key === "preview") return undefined;
if (typeof v === "function") return undefined;
if (v && typeof v === "object") {
if (seen.has(v)) return "[Circular]";
seen.add(v);
}
return v;
},
0
);
};
const getAttachmentFromBillFormUpload = () => {
const uploads = billForm?.getFieldValue?.("upload") || [];
const files = uploads.map((u) => u?.originFileObj).filter(Boolean);
return (
files.find((f) => f?.type === "application/pdf") ||
files.find((f) => isString(f?.name) && f.name.toLowerCase().endsWith(".pdf")) ||
files[0] ||
null
);
};
const submitFeedback = async ({ rating, comments }) => {
setSubmitting(true);
try {
const billFormValues = billForm.getFieldsValue(true);
const formData = new FormData();
formData.append("rating", rating);
formData.append("comments", comments || "");
formData.append("billFormValues", sanitizeBillFormValues(billFormValues));
formData.append("rawAIData", sanitizeBillFormValues(rawAIData));
formData.append("shopname", bodyshop?.shopname || "");
const attachmentFile = getAttachmentFromBillFormUpload();
if (attachmentFile) {
formData.append("billPdf", attachmentFile, attachmentFile.name || "bill.pdf");
}
await axios.post("/ai/bill-feedback", formData);
notification.success({
title: "Thanks — feedback submitted"
});
form.resetFields();
} catch (error) {
notification.error({
title: "Failed to submit feedback",
description: error?.response?.data?.message || error?.message
});
} finally {
setSubmitting(false);
}
};
const isString = (v) => typeof v === "string";
return (
<Form form={form} onFinish={submitFeedback} requiredMark={false}>
<Space wrap align="top" size="small">
<Form.Item name="rating" label={t("bills.labels.ai.feedback_prompt")} rules={[{ required: true }]}>
<Radio.Group optionType="button" buttonStyle="solid">
<Radio.Button value="up">
<LikeOutlined />
</Radio.Button>
<Radio.Button value="down">
<DislikeOutlined />
</Radio.Button>
</Radio.Group>
</Form.Item>
<Space wrap size="small" orientation="vertical">
<Form.Item name="comments">
<Input.TextArea
rows={3}
style={{ minWidth: "400px" }}
placeholder={t("bills.labels.ai.feedback_placeholder")}
/>
</Form.Item>
<Button onClick={() => form.submit()} loading={submitting} disabled={submitting}>
{t("bills.labels.ai.submit_feedback")}
</Button>
</Space>
</Space>
</Form>
);
}
export default connect(mapStateToProps, null)(BillAiFeedback);

View File

@@ -23,7 +23,8 @@ function BillEnterAiScan({
fileInputRef, fileInputRef,
scanLoading, scanLoading,
setScanLoading, setScanLoading,
setIsAiScan setIsAiScan,
setRawAIData
}) { }) {
const notification = useNotification(); const notification = useNotification();
const { t } = useTranslation(); const { t } = useTranslation();
@@ -57,6 +58,7 @@ function BillEnterAiScan({
} }
setScanLoading(false); setScanLoading(false);
setRawAIData(data.data);
// Update form with the extracted data // Update form with the extracted data
if (data?.data?.billForm) { if (data?.data?.billForm) {
form.setFieldsValue(data.data.billForm); form.setFieldsValue(data.data.billForm);
@@ -147,6 +149,7 @@ function BillEnterAiScan({
setScanLoading(false); setScanLoading(false);
form.setFieldsValue(data.data.billForm); form.setFieldsValue(data.data.billForm);
setRawAIData(data.data);
await form.validateFields(["billlines"], { recursive: true }); await form.validateFields(["billlines"], { recursive: true });
notification.success({ notification.success({

View File

@@ -1,6 +1,6 @@
import { useApolloClient, useMutation } from "@apollo/client/react"; import { useApolloClient, useMutation } from "@apollo/client/react";
import { useTreatmentsWithConfig } from "@splitsoftware/splitio-react"; import { useTreatmentsWithConfig } from "@splitsoftware/splitio-react";
import { Button, Checkbox, Form, Modal, Space } from "antd"; import { Button, Checkbox, Divider, Form, Modal, Space } from "antd";
import _ from "lodash"; import _ from "lodash";
import { useEffect, useMemo, useRef, useState } from "react"; import { useEffect, useMemo, useRef, useState } from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
@@ -28,6 +28,7 @@ import { CalculateBillTotal } from "../bill-form/bill-form.totals.utility";
import { handleUpload as handleLocalUpload } from "../documents-local-upload/documents-local-upload.utility"; import { handleUpload as handleLocalUpload } from "../documents-local-upload/documents-local-upload.utility";
import { handleUpload as handleUploadToImageProxy } from "../documents-upload-imgproxy/documents-upload-imgproxy.utility"; import { handleUpload as handleUploadToImageProxy } from "../documents-upload-imgproxy/documents-upload-imgproxy.utility";
import { handleUpload } from "../documents-upload/documents-upload.utility"; import { handleUpload } from "../documents-upload/documents-upload.utility";
import BillAiFeedback from "../bill-ai-feedback/bill-ai-feedback.component.jsx";
const mapStateToProps = createStructuredSelector({ const mapStateToProps = createStructuredSelector({
billEnterModal: selectBillEnterModal, billEnterModal: selectBillEnterModal,
@@ -53,6 +54,7 @@ function BillEnterModalContainer({ billEnterModal, toggleModalVisible, bodyshop,
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [scanLoading, setScanLoading] = useState(false); const [scanLoading, setScanLoading] = useState(false);
const [isAiScan, setIsAiScan] = useState(false); const [isAiScan, setIsAiScan] = useState(false);
const [rawAIData, setRawAIData] = useState(null);
const client = useApolloClient(); const client = useApolloClient();
const [generateLabel, setGenerateLabel] = useLocalStorage("enter_bill_generate_label", false); const [generateLabel, setGenerateLabel] = useLocalStorage("enter_bill_generate_label", false);
const notification = useNotification(); const notification = useNotification();
@@ -387,6 +389,7 @@ function BillEnterModalContainer({ billEnterModal, toggleModalVisible, bodyshop,
billlines: [] billlines: []
}); });
setIsAiScan(false); setIsAiScan(false);
setRawAIData(null);
// form.resetFields(); // form.resetFields();
} else { } else {
toggleModalVisible(); toggleModalVisible();
@@ -404,6 +407,7 @@ function BillEnterModalContainer({ billEnterModal, toggleModalVisible, bodyshop,
} }
setScanLoading(false); setScanLoading(false);
setIsAiScan(false); setIsAiScan(false);
setRawAIData(null);
toggleModalVisible(); toggleModalVisible();
} }
}; };
@@ -429,6 +433,7 @@ function BillEnterModalContainer({ billEnterModal, toggleModalVisible, bodyshop,
} }
setScanLoading(false); setScanLoading(false);
setIsAiScan(false); setIsAiScan(false);
setRawAIData(null);
} }
}, [billEnterModal.open, form, formValues]); }, [billEnterModal.open, form, formValues]);
@@ -456,6 +461,7 @@ function BillEnterModalContainer({ billEnterModal, toggleModalVisible, bodyshop,
scanLoading={scanLoading} scanLoading={scanLoading}
setScanLoading={setScanLoading} setScanLoading={setScanLoading}
setIsAiScan={setIsAiScan} setIsAiScan={setIsAiScan}
setRawAIData={setRawAIData}
/> />
)} )}
</Space> </Space>
@@ -471,26 +477,34 @@ function BillEnterModalContainer({ billEnterModal, toggleModalVisible, bodyshop,
setLoading(false); setLoading(false);
}} }}
footer={ footer={
<Space> <Space orientation="vertical">
<Checkbox checked={generateLabel} onChange={(e) => setGenerateLabel(e.target.checked)}> {isAiScan && (
{t("bills.labels.generatepartslabel")} <>
</Checkbox> <BillAiFeedback billForm={form} rawAIData={rawAIData} />
<Button onClick={handleCancel}>{t("general.actions.cancel")}</Button> <Divider orientation="horizontal" />
<Button loading={loading} onClick={() => form.submit()} id="save-bill-enter-modal"> </>
{t("general.actions.save")}
</Button>
{billEnterModal.context && billEnterModal.context.id ? null : (
<Button
type="primary"
loading={loading}
onClick={() => {
setEnterAgain(true);
}}
id="save-and-new-bill-enter-modal"
>
{t("general.actions.saveandnew")}
</Button>
)} )}
<Space wrap align="top">
<Checkbox checked={generateLabel} onChange={(e) => setGenerateLabel(e.target.checked)}>
{t("bills.labels.generatepartslabel")}
</Checkbox>
<Button onClick={handleCancel}>{t("general.actions.cancel")}</Button>
<Button loading={loading} onClick={() => form.submit()} id="save-bill-enter-modal">
{t("general.actions.save")}
</Button>
{billEnterModal.context && billEnterModal.context.id ? null : (
<Button
type="primary"
loading={loading}
onClick={() => {
setEnterAgain(true);
}}
id="save-and-new-bill-enter-modal"
>
{t("general.actions.saveandnew")}
</Button>
)}
</Space>
</Space> </Space>
} }
destroyOnHidden destroyOnHidden

View File

@@ -41,7 +41,7 @@ export function EmailOverlayComponent({ emailConfig, form, selectedMediaState, b
const emailsToMenu = { const emailsToMenu = {
items: [ items: [
...bodyshop.employees ...bodyshop.employees
.filter((e) => e.user_email) .filter((e) => e.user_email && e.active === true)
.map((e, idx) => ({ .map((e, idx) => ({
key: idx, key: idx,
label: `${e.first_name} ${e.last_name}`, label: `${e.first_name} ${e.last_name}`,
@@ -59,7 +59,7 @@ export function EmailOverlayComponent({ emailConfig, form, selectedMediaState, b
const menuCC = { const menuCC = {
items: [ items: [
...bodyshop.employees ...bodyshop.employees
.filter((e) => e.user_email) .filter((e) => e.user_email && e.active === true)
.map((e, idx) => ({ .map((e, idx) => ({
key: idx, key: idx,
label: `${e.first_name} ${e.last_name}`, label: `${e.first_name} ${e.last_name}`,

View File

@@ -25,6 +25,7 @@ const Eula = ({ currentEula, currentUser, acceptEula }) => {
const handleScroll = useCallback( const handleScroll = useCallback(
(e) => { (e) => {
if (!e.target) return;
const bottom = e.target.scrollHeight - 100 <= e.target.scrollTop + e.target.clientHeight; const bottom = e.target.scrollHeight - 100 <= e.target.scrollTop + e.target.clientHeight;
if (bottom && !hasEverScrolledToBottom) { if (bottom && !hasEverScrolledToBottom) {
setHasEverScrolledToBottom(true); setHasEverScrolledToBottom(true);
@@ -36,7 +37,9 @@ const Eula = ({ currentEula, currentUser, acceptEula }) => {
); );
useEffect(() => { useEffect(() => {
handleScroll({ target: markdownCardRef.current }); if (markdownCardRef.current) {
handleScroll({ target: markdownCardRef.current });
}
}, [handleScroll]); }, [handleScroll]);
const handleChange = useCallback(() => { const handleChange = useCallback(() => {

View File

@@ -33,7 +33,7 @@ import JobLinesBillRefernece from "../job-lines-bill-reference/job-lines-bill-re
import { useTreatmentsWithConfig } from "@splitsoftware/splitio-react"; import { useTreatmentsWithConfig } from "@splitsoftware/splitio-react";
import _ from "lodash"; import _ from "lodash";
import { FaTasks } from "react-icons/fa"; import { FaTasks } from "react-icons/fa";
import { selectBodyshop } from "../../redux/user/user.selectors"; import { selectAuthLevel, selectBodyshop } from "../../redux/user/user.selectors";
import dayjs from "../../utils/day"; import dayjs from "../../utils/day";
import InstanceRenderManager from "../../utils/instanceRenderMgr"; import InstanceRenderManager from "../../utils/instanceRenderMgr";
import { HasFeatureAccess } from "../feature-wrapper/feature-wrapper.component"; import { HasFeatureAccess } from "../feature-wrapper/feature-wrapper.component";
@@ -49,6 +49,7 @@ import JobLinesPartPriceChange from "./job-lines-part-price-change.component";
import JobLinesExpanderSimple from "./jobs-lines-expander-simple.component"; import JobLinesExpanderSimple from "./jobs-lines-expander-simple.component";
import { logImEXEvent } from "../../firebase/firebase.utils"; import { logImEXEvent } from "../../firebase/firebase.utils";
import { useNotification } from "../../contexts/Notifications/notificationContext.jsx"; import { useNotification } from "../../contexts/Notifications/notificationContext.jsx";
import { HasRbacAccess } from "../rbac-wrapper/rbac-wrapper.component.jsx";
const UPDATE_JOB_LINES_LOCATION_BULK = gql` const UPDATE_JOB_LINES_LOCATION_BULK = gql`
mutation UPDATE_JOB_LINES_LOCATION_BULK($ids: [uuid!]!, $location: String!) { mutation UPDATE_JOB_LINES_LOCATION_BULK($ids: [uuid!]!, $location: String!) {
@@ -66,7 +67,8 @@ const mapStateToProps = createStructuredSelector({
bodyshop: selectBodyshop, bodyshop: selectBodyshop,
jobRO: selectJobReadOnly, jobRO: selectJobReadOnly,
technician: selectTechnician, technician: selectTechnician,
isPartsEntry: selectIsPartsEntry isPartsEntry: selectIsPartsEntry,
authLevel: selectAuthLevel
}); });
const mapDispatchToProps = (dispatch) => ({ const mapDispatchToProps = (dispatch) => ({
@@ -94,7 +96,8 @@ export function JobLinesComponent({
setTaskUpsertContext, setTaskUpsertContext,
billsQuery, billsQuery,
handlePartsOrderOnRowClick, handlePartsOrderOnRowClick,
isPartsEntry isPartsEntry,
authLevel
}) { }) {
const [deleteJobLine] = useMutation(DELETE_JOB_LINE_BY_PK); const [deleteJobLine] = useMutation(DELETE_JOB_LINE_BY_PK);
const [bulkUpdateLocations] = useMutation(UPDATE_JOB_LINES_LOCATION_BULK); const [bulkUpdateLocations] = useMutation(UPDATE_JOB_LINES_LOCATION_BULK);
@@ -386,18 +389,20 @@ export function JobLinesComponent({
key: "actions", key: "actions",
render: (text, record) => ( render: (text, record) => (
<Space> <Space>
{(record.manual_line || jobIsPrivate) && !technician && ( {(record.manual_line || jobIsPrivate) &&
<Button !technician &&
disabled={jobRO} HasRbacAccess({ bodyshop, authLevel, action: "jobs:manual-line" }) && (
onClick={() => { <Button
setJobLineEditContext({ disabled={jobRO}
actions: { refetch: refetch, submit: form && form.submit }, onClick={() => {
context: { ...record, jobid: job.id } setJobLineEditContext({
}); actions: { refetch: refetch, submit: form && form.submit },
}} context: { ...record, jobid: job.id }
icon={<EditFilled />} });
/> }}
)} icon={<EditFilled />}
/>
)}
<Button <Button
title={t("tasks.buttons.create")} title={t("tasks.buttons.create")}
onClick={() => { onClick={() => {
@@ -410,29 +415,30 @@ export function JobLinesComponent({
}} }}
icon={<FaTasks />} icon={<FaTasks />}
/> />
{(record.manual_line || jobIsPrivate) &&
{(record.manual_line || jobIsPrivate) && !technician && ( !technician &&
<Button HasRbacAccess({ bodyshop, authLevel, action: "jobs:manual-line" }) && (
disabled={jobRO} <Button
onClick={async () => { disabled={jobRO}
await deleteJobLine({ onClick={async () => {
variables: { joblineId: record.id }, await deleteJobLine({
update(cache) { variables: { joblineId: record.id },
cache.modify({ update(cache) {
fields: { cache.modify({
joblines(existingJobLines, { readField }) { fields: {
return existingJobLines.filter((jlRef) => record.id !== readField("id", jlRef)); joblines(existingJobLines, { readField }) {
return existingJobLines.filter((jlRef) => record.id !== readField("id", jlRef));
}
} }
} });
}); }
} });
}); await axios.post("/job/totalsssu", { id: job.id });
await axios.post("/job/totalsssu", { id: job.id }); if (refetch) refetch();
if (refetch) refetch(); }}
}} icon={<DeleteFilled />}
icon={<DeleteFilled />} />
/> )}
)}
</Space> </Space>
) )
} }
@@ -657,7 +663,7 @@ export function JobLinesComponent({
<Button id="repair-data-mark-button">{t("jobs.actions.mark")}</Button> <Button id="repair-data-mark-button">{t("jobs.actions.mark")}</Button>
</Dropdown> </Dropdown>
{!isPartsEntry && ( {!isPartsEntry && HasRbacAccess({ bodyshop, authLevel, action: "jobs:manual-line" }) && (
<Button <Button
disabled={jobRO || technician} disabled={jobRO || technician}
onClick={() => { onClick={() => {

View File

@@ -144,18 +144,11 @@ export default function JobTotalsTableLabor({ job }) {
{t("jobs.labels.mapa")} {t("jobs.labels.mapa")}
{InstanceRenderManager({ {InstanceRenderManager({
imex: imex:
job.materials?.mapa && (job.materials?.mapa ?? job.materials?.MAPA)?.cal_maxdlr > 0 &&
job.materials.mapa.cal_maxdlr && t("jobs.labels.threshhold", { amount: (job.materials.mapa ?? job.materials.MAPA).cal_maxdlr }),
job.materials.mapa.cal_maxdlr > 0 &&
t("jobs.labels.threshhold", {
amount: job.materials.mapa.cal_maxdlr
}),
rome: rome:
job.materials?.MAPA && job.materials?.MAPA?.cal_maxdlr !== undefined &&
job.materials.MAPA.cal_maxdlr !== undefined && t("jobs.labels.threshhold", { amount: job.materials.MAPA.cal_maxdlr })
t("jobs.labels.threshhold", {
amount: job.materials.MAPA.cal_maxdlr
})
})} })}
</Space> </Space>
</ResponsiveTable.Summary.Cell> </ResponsiveTable.Summary.Cell>
@@ -190,18 +183,11 @@ export default function JobTotalsTableLabor({ job }) {
{t("jobs.labels.mash")} {t("jobs.labels.mash")}
{InstanceRenderManager({ {InstanceRenderManager({
imex: imex:
job.materials?.mash && (job.materials?.mash ?? job.materials?.MASH)?.cal_maxdlr > 0 &&
job.materials.mash.cal_maxdlr && t("jobs.labels.threshhold", { amount: (job.materials.mash ?? job.materials.MASH).cal_maxdlr }),
job.materials.mash.cal_maxdlr > 0 &&
t("jobs.labels.threshhold", {
amount: job.materials.mash.cal_maxdlr
}),
rome: rome:
job.materials?.MASH && job.materials?.MASH?.cal_maxdlr !== undefined &&
job.materials.MASH.cal_maxdlr !== undefined && t("jobs.labels.threshhold", { amount: job.materials.MASH.cal_maxdlr })
t("jobs.labels.threshhold", {
amount: job.materials.MASH.cal_maxdlr
})
})} })}
</Space> </Space>
</ResponsiveTable.Summary.Cell> </ResponsiveTable.Summary.Cell>

View File

@@ -69,7 +69,9 @@ export function JobsAdminClass({ bodyshop, job }) {
</Form> </Form>
<Popconfirm title={t("jobs.labels.changeclass")} onConfirm={() => form.submit()}> <Popconfirm title={t("jobs.labels.changeclass")} onConfirm={() => form.submit()}>
<Button loading={loading}>{t("general.actions.save")}</Button> <Button loading={loading} type="primary">
{t("general.actions.save")}
</Button>
</Popconfirm> </Popconfirm>
</div> </div>
); );

View File

@@ -157,7 +157,7 @@ export function JobsAdminDatesChange({ insertAuditTrail, job }) {
</LayoutFormRow> </LayoutFormRow>
</Form> </Form>
<Button loading={loading} onClick={() => form.submit()}> <Button loading={loading} type="primary" onClick={() => form.submit()}>
{t("general.actions.save")} {t("general.actions.save")}
</Button> </Button>
</div> </div>

View File

@@ -54,7 +54,7 @@ export default function JobAdminOwnerReassociate({ job }) {
</Form.Item> </Form.Item>
</Form> </Form>
<div>{t("jobs.labels.associationwarning")}</div> <div>{t("jobs.labels.associationwarning")}</div>
<Button loading={loading} onClick={() => form.submit()}> <Button loading={loading} type="primary" onClick={() => form.submit()}>
{t("general.actions.save")} {t("general.actions.save")}
</Button> </Button>
</div> </div>

View File

@@ -54,7 +54,7 @@ export default function JobAdminOwnerReassociate({ job }) {
</Form.Item> </Form.Item>
</Form> </Form>
<div>{t("jobs.labels.associationwarning")}</div> <div>{t("jobs.labels.associationwarning")}</div>
<Button loading={loading} onClick={() => form.submit()}> <Button loading={loading} type="primary" onClick={() => form.submit()}>
{t("general.actions.save")} {t("general.actions.save")}
</Button> </Button>
</div> </div>

View File

@@ -138,7 +138,7 @@ export function JobsCloseLines({ bodyshop, job, jobRO }) {
showSearch={{ showSearch={{
optionFilterProp: "children", optionFilterProp: "children",
filterOption: (input, option) => filterOption: (input, option) =>
option.children.toLowerCase().indexOf(input.toLowerCase()) >= 0 option?.value?.toLowerCase().indexOf(input?.toLowerCase()) >= 0
}} }}
disabled={jobRO} disabled={jobRO}
options={bodyshop.md_responsibility_centers.profits.map((p) => ({ options={bodyshop.md_responsibility_centers.profits.map((p) => ({
@@ -166,7 +166,7 @@ export function JobsCloseLines({ bodyshop, job, jobRO }) {
showSearch={{ showSearch={{
optionFilterProp: "children", optionFilterProp: "children",
filterOption: (input, option) => filterOption: (input, option) =>
option.children.toLowerCase().indexOf(input.toLowerCase()) >= 0 option?.value?.toLowerCase().indexOf(input?.toLowerCase()) >= 0
}} }}
disabled={jobRO} disabled={jobRO}
options={bodyshop.md_responsibility_centers.profits.map((p) => ({ options={bodyshop.md_responsibility_centers.profits.map((p) => ({

View File

@@ -70,6 +70,12 @@ export function PartsOrderListTableComponent({
const [deletePartsOrder] = useMutation(DELETE_PARTS_ORDER); const [deletePartsOrder] = useMutation(DELETE_PARTS_ORDER);
const parts_orders = billsQuery.data ? billsQuery.data.parts_orders : []; const parts_orders = billsQuery.data ? billsQuery.data.parts_orders : [];
const enrichedPartsOrders = parts_orders.map((order) => ({
...order,
invoice_number: order.bill?.invoice_number
}));
const { refetch } = billsQuery; const { refetch } = billsQuery;
const recordActions = (record, showView = false) => ( const recordActions = (record, showView = false) => (
@@ -222,7 +228,12 @@ export function PartsOrderListTableComponent({
dataIndex: "order_number", dataIndex: "order_number",
key: "order_number", key: "order_number",
sorter: (a, b) => alphaSort(a.invoice_number, b.invoice_number), sorter: (a, b) => alphaSort(a.invoice_number, b.invoice_number),
sortOrder: state.sortedInfo.columnKey === "invoice_number" && state.sortedInfo.order sortOrder: state.sortedInfo.columnKey === "invoice_number" && state.sortedInfo.order,
render: (text, record) => (
<span>
{record.order_number} {record.invoice_number && `(${record.invoice_number})`}
</span>
)
}, },
{ {
title: t("parts_orders.fields.order_date"), title: t("parts_orders.fields.order_date"),
@@ -272,10 +283,10 @@ export function PartsOrderListTableComponent({
setState({ ...state, filteredInfo: filters, sortedInfo: sorter }); setState({ ...state, filteredInfo: filters, sortedInfo: sorter });
}; };
const filteredPartsOrders = parts_orders const filteredPartsOrders = enrichedPartsOrders
? searchText === "" ? searchText === ""
? parts_orders ? enrichedPartsOrders
: parts_orders.filter( : enrichedPartsOrders.filter(
(b) => (b) =>
(b.order_number || "").toString().toLowerCase().includes(searchText.toLowerCase()) || (b.order_number || "").toString().toLowerCase().includes(searchText.toLowerCase()) ||
(b.vendor.name || "").toLowerCase().includes(searchText.toLowerCase()) (b.vendor.name || "").toLowerCase().includes(searchText.toLowerCase())

View File

@@ -1,7 +1,7 @@
import Icon from "@ant-design/icons"; import Icon from "@ant-design/icons";
import { useMutation } from "@apollo/client/react"; import { useMutation } from "@apollo/client/react";
import { Button, Input, Popover, Tooltip } from "antd"; import { Button, Input, Popover, Tooltip } from "antd";
import { useState } from "react"; import { useState, useRef } from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { FaRegStickyNote } from "react-icons/fa"; import { FaRegStickyNote } from "react-icons/fa";
import { UPDATE_JOB } from "../../graphql/jobs.queries"; import { UPDATE_JOB } from "../../graphql/jobs.queries";
@@ -9,10 +9,10 @@ import { logImEXEvent } from "../../firebase/firebase.utils";
export default function ProductionListColumnComment({ record, usePortal = false }) { export default function ProductionListColumnComment({ record, usePortal = false }) {
const { t } = useTranslation(); const { t } = useTranslation();
const [note, setNote] = useState(record.comment || ""); const [note, setNote] = useState(record.comment || "");
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
const textAreaRef = useRef(null);
const rafIdRef = useRef(null);
const [updateAlert] = useMutation(UPDATE_JOB); const [updateAlert] = useMutation(UPDATE_JOB);
@@ -38,23 +38,35 @@ export default function ProductionListColumnComment({ record, usePortal = false
}; };
const handleOpenChange = (flag) => { const handleOpenChange = (flag) => {
if (rafIdRef.current) {
cancelAnimationFrame(rafIdRef.current);
rafIdRef.current = null;
}
setOpen(flag); setOpen(flag);
if (flag) setNote(record.comment || ""); if (flag) {
setNote(record.comment || "");
rafIdRef.current = requestAnimationFrame(() => {
rafIdRef.current = null;
if (textAreaRef.current?.focus) {
try {
textAreaRef.current.focus({ preventScroll: true });
} catch {
textAreaRef.current.focus();
}
}
});
}
}; };
const content = ( const content = (
<div <div style={{ width: "30em" }} onClick={(e) => e.stopPropagation()} onPointerDown={(e) => e.stopPropagation()}>
style={{ width: "30em" }}
onClick={(e) => e.stopPropagation()}
onPointerDown={(e) => e.stopPropagation()}
>
<Input.TextArea <Input.TextArea
id={`job-comment-${record.id}`} id={`job-comment-${record.id}`}
name="comment" name="comment"
rows={5} rows={5}
value={note} value={note}
onChange={handleChange} onChange={handleChange}
autoFocus ref={textAreaRef}
allowClear allowClear
style={{ marginBottom: "1em" }} style={{ marginBottom: "1em" }}
/> />
@@ -73,7 +85,7 @@ export default function ProductionListColumnComment({ record, usePortal = false
content={content} content={content}
trigger="click" trigger="click"
destroyOnHidden destroyOnHidden
styles={{ body: { padding: '12px' } }} styles={{ body: { padding: "12px" } }}
{...(usePortal ? { getPopupContainer: (trigger) => trigger.parentElement || document.body } : {})} {...(usePortal ? { getPopupContainer: (trigger) => trigger.parentElement || document.body } : {})}
> >
<div <div

View File

@@ -1,7 +1,7 @@
import Icon from "@ant-design/icons"; import Icon from "@ant-design/icons";
import { useMutation } from "@apollo/client/react"; import { useMutation } from "@apollo/client/react";
import { Button, Input, Popover, Space } from "antd"; import { Button, Input, Popover, Space } from "antd";
import { useCallback, useState } from "react"; import { useCallback, useRef, useState } from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { FaRegStickyNote } from "react-icons/fa"; import { FaRegStickyNote } from "react-icons/fa";
import { logImEXEvent } from "../../firebase/firebase.utils"; import { logImEXEvent } from "../../firebase/firebase.utils";
@@ -20,6 +20,8 @@ function ProductionListColumnProductionNote({ record, setNoteUpsertContext, useP
const { t } = useTranslation(); const { t } = useTranslation();
const [note, setNote] = useState(record.production_vars?.note || ""); const [note, setNote] = useState(record.production_vars?.note || "");
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
const textAreaRef = useRef(null);
const rafIdRef = useRef(null);
const [updateAlert] = useMutation(UPDATE_JOB); const [updateAlert] = useMutation(UPDATE_JOB);
@@ -52,25 +54,37 @@ function ProductionListColumnProductionNote({ record, setNoteUpsertContext, useP
const handleOpenChange = useCallback( const handleOpenChange = useCallback(
(flag) => { (flag) => {
if (rafIdRef.current) {
cancelAnimationFrame(rafIdRef.current);
rafIdRef.current = null;
}
setOpen(flag); setOpen(flag);
if (flag) setNote(record.production_vars?.note || ""); if (flag) {
setNote(record.production_vars?.note || "");
rafIdRef.current = requestAnimationFrame(() => {
rafIdRef.current = null;
if (textAreaRef.current?.focus) {
try {
textAreaRef.current.focus({ preventScroll: true });
} catch {
textAreaRef.current.focus();
}
}
});
}
}, },
[record] [record]
); );
const content = ( const content = (
<div <div style={{ width: "30em" }} onClick={(e) => e.stopPropagation()} onPointerDown={(e) => e.stopPropagation()}>
style={{ width: "30em" }}
onClick={(e) => e.stopPropagation()}
onPointerDown={(e) => e.stopPropagation()}
>
<Input.TextArea <Input.TextArea
id={`job-production-note-${record.id}`} id={`job-production-note-${record.id}`}
name="production_note" name="production_note"
rows={5} rows={5}
value={note} value={note}
onChange={handleChange} onChange={handleChange}
autoFocus ref={textAreaRef}
allowClear allowClear
style={{ marginBottom: "1em" }} style={{ marginBottom: "1em" }}
/> />
@@ -102,7 +116,7 @@ function ProductionListColumnProductionNote({ record, setNoteUpsertContext, useP
content={content} content={content}
trigger="click" trigger="click"
destroyOnHidden destroyOnHidden
styles={{ body: { padding: '12px' } }} styles={{ body: { padding: "12px" } }}
{...(usePortal ? { getPopupContainer: (trigger) => trigger.parentElement || document.body } : {})} {...(usePortal ? { getPopupContainer: (trigger) => trigger.parentElement || document.body } : {})}
> >
<div <div

View File

@@ -26,6 +26,7 @@ const ret = {
"jobs:partsqueue": 4, "jobs:partsqueue": 4,
"jobs:checklist-view": 2, "jobs:checklist-view": 2,
"jobs:list-ready": 1, "jobs:list-ready": 1,
"jobs:manual-line": 1,
"jobs:void": 5, "jobs:void": 5,
"bills:enter": 2, "bills:enter": 2,

View File

@@ -435,6 +435,19 @@ export function ShopInfoRbacComponent({ bodyshop }) {
> >
<InputNumber /> <InputNumber />
</Form.Item>, </Form.Item>,
<Form.Item
key="jobs:manual-line"
label={t("bodyshop.fields.rbac.jobs.manual-line")}
rules={[
{
required: true
//message: t("general.validation.required"),
}
]}
name={["md_rbac", "jobs:manual-line"]}
>
<InputNumber />
</Form.Item>,
<Form.Item <Form.Item
key="jobs:partsqueue" key="jobs:partsqueue"
label={t("bodyshop.fields.rbac.jobs.partsqueue")} label={t("bodyshop.fields.rbac.jobs.partsqueue")}

View File

@@ -66,10 +66,9 @@ export function TechClockInContainer({ setTimeTicketContext, technician, bodysho
employeeid: technician.id, employeeid: technician.id,
date: date:
typeof bodyshop.timezone === "string" typeof bodyshop.timezone === "string"
? // TODO: Client Update - This may be broken ? dayjs(theTime).tz(bodyshop.timezone).format("YYYY-MM-DD")
dayjs.tz(theTime, bodyshop.timezone).format("YYYY-MM-DD")
: typeof bodyshop.timezone === "number" : typeof bodyshop.timezone === "number"
? dayjs(theTime).format("YYYY-MM-DD").utcOffset(bodyshop.timezone) ? dayjs(theTime).utcOffset(bodyshop.timezone).format("YYYY-MM-DD")
: dayjs(theTime).format("YYYY-MM-DD"), : dayjs(theTime).format("YYYY-MM-DD"),
clockon: dayjs(theTime), clockon: dayjs(theTime),
jobid: values.jobid, jobid: values.jobid,

View File

@@ -25,10 +25,7 @@ const mapDispatchToProps = (dispatch) => ({
}); });
export function TechLookupJobsDrawer({ bodyshop, setPrintCenterContext }) { export function TechLookupJobsDrawer({ bodyshop, setPrintCenterContext }) {
const breakpoints = Grid.useBreakpoint(); const screens = Grid.useBreakpoint();
const selectedBreakpoint = Object.entries(breakpoints)
.filter(([, isOn]) => !!isOn)
.slice(-1)[0];
const bpoints = { const bpoints = {
xs: "100%", xs: "100%",
@@ -36,10 +33,16 @@ export function TechLookupJobsDrawer({ bodyshop, setPrintCenterContext }) {
md: "100%", md: "100%",
lg: "100%", lg: "100%",
xl: "90%", xl: "90%",
xxl: "85%" xxl: "90%"
}; };
const drawerPercentage = selectedBreakpoint ? bpoints[selectedBreakpoint[0]] : "100%"; let drawerPercentage = "100%";
if (screens.xxl) drawerPercentage = bpoints.xxl;
else if (screens.xl) drawerPercentage = bpoints.xl;
else if (screens.lg) drawerPercentage = bpoints.lg;
else if (screens.md) drawerPercentage = bpoints.md;
else if (screens.sm) drawerPercentage = bpoints.sm;
else if (screens.xs) drawerPercentage = bpoints.xs;
const location = useLocation(); const location = useLocation();
const history = useNavigate(); const history = useNavigate();

View File

@@ -91,6 +91,10 @@ export const QUERY_PARTS_BILLS_BY_JOBID = gql`
order_number order_number
comments comments
user_email user_email
bill {
id
invoice_number
}
} }
parts_dispatch(where: { jobid: { _eq: $jobid } }) { parts_dispatch(where: { jobid: { _eq: $jobid } }) {
id id

View File

@@ -1375,6 +1375,9 @@ export const QUERY_JOB_FOR_DUPE = gql`
agt_ph2x agt_ph2x
area_of_damage area_of_damage
cat_no cat_no
cieca_pfl
cieca_pfo
cieca_pft
cieca_stl cieca_stl
cieca_ttl cieca_ttl
clm_addr1 clm_addr1
@@ -1452,6 +1455,7 @@ export const QUERY_JOB_FOR_DUPE = gql`
labor_rate_desc labor_rate_desc
labor_rate_id labor_rate_id
local_tax_rate local_tax_rate
materials
other_amount_payable other_amount_payable
owner_owing owner_owing
ownerid ownerid

View File

@@ -142,13 +142,13 @@ export function ExportLogsPageComponent() {
<div> <div>
<ul> <ul>
{message.map((m, idx) => ( {message.map((m, idx) => (
<li key={idx}>{m}</li> <li key={idx}>{typeof m === "object" ? JSON.stringify(m) : m}</li>
))} ))}
</ul> </ul>
</div> </div>
); );
} else { } else {
return <div>{record.message}</div>; return <div>{typeof message === "object" ? JSON.stringify(message) : message}</div>;
} }
} }
} }

View File

@@ -10,14 +10,12 @@ import JobsCreateOwnerInfoContainer from "../../components/jobs-create-owner-inf
import JobsCreateVehicleInfoContainer from "../../components/jobs-create-vehicle-info/jobs-create-vehicle-info.container"; import JobsCreateVehicleInfoContainer from "../../components/jobs-create-vehicle-info/jobs-create-vehicle-info.container";
import JobCreateContext from "../../pages/jobs-create/jobs-create.context"; import JobCreateContext from "../../pages/jobs-create/jobs-create.context";
export default function JobsCreateComponent({ form }) { export default function JobsCreateComponent({ form, isSubmitting }) {
const [pageIndex, setPageIndex] = useState(0); const [pageIndex, setPageIndex] = useState(0);
const [errorMessage, setErrorMessage] = useState(null); const [errorMessage, setErrorMessage] = useState(null);
const [state] = useContext(JobCreateContext); const [state] = useContext(JobCreateContext);
const { t } = useTranslation(); const { t } = useTranslation();
const steps = [ const steps = [
{ {
title: t("jobs.labels.create.vehicleinfo"), title: t("jobs.labels.create.vehicleinfo"),
@@ -42,11 +40,9 @@ export default function JobsCreateComponent({ form }) {
const next = () => { const next = () => {
setPageIndex(pageIndex + 1); setPageIndex(pageIndex + 1);
console.log("Next");
}; };
const prev = () => { const prev = () => {
setPageIndex(pageIndex - 1); setPageIndex(pageIndex - 1);
console.log("Previous");
}; };
const ProgressButtons = ({ top }) => { const ProgressButtons = ({ top }) => {
@@ -79,17 +75,19 @@ export default function JobsCreateComponent({ form }) {
{pageIndex === steps.length - 1 && ( {pageIndex === steps.length - 1 && (
<Button <Button
type="primary" type="primary"
loading={isSubmitting}
onClick={() => { onClick={() => {
form form
.validateFields() .validateFields()
.then(() => { .then(() => {
// NO OP form.submit();
}) })
.catch((error) => console.log("error", error)); .catch((error) => {
form.submit(); console.log("error", error);
});
}} }}
> >
Done {t("general.actions.done")}
</Button> </Button>
)} )}
</Space> </Space>
@@ -146,13 +144,11 @@ export default function JobsCreateComponent({ form }) {
) : ( ) : (
<div> <div>
<ProgressButtons top /> <ProgressButtons top />
{errorMessage ? ( {errorMessage ? (
<div> <div>
<AlertComponent title={errorMessage} type="error" /> <AlertComponent title={errorMessage} type="error" />
</div> </div>
) : null} ) : null}
{steps.map((item, idx) => ( {steps.map((item, idx) => (
<div <div
key={idx} key={idx}

View File

@@ -46,6 +46,7 @@ function JobsCreateContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, curr
}); });
const [form] = Form.useForm(); const [form] = Form.useForm();
const [state, setState] = contextState; const [state, setState] = contextState;
const [isSubmitting, setIsSubmitting] = useState(false);
const [insertJob] = useMutation(INSERT_NEW_JOB); const [insertJob] = useMutation(INSERT_NEW_JOB);
const [loadOwner, remoteOwnerData] = useLazyQuery(QUERY_OWNER_FOR_JOB_CREATION); const [loadOwner, remoteOwnerData] = useLazyQuery(QUERY_OWNER_FOR_JOB_CREATION);
@@ -83,16 +84,19 @@ function JobsCreateContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, curr
newJobId: resp.data.insert_jobs.returning[0].id newJobId: resp.data.insert_jobs.returning[0].id
}); });
logImEXEvent("manual_job_create_completed", {}); logImEXEvent("manual_job_create_completed", {});
setIsSubmitting(false);
}) })
.catch((error) => { .catch((error) => {
notification.error({ notification.error({
title: t("jobs.errors.creating", { error: error }) title: t("jobs.errors.creating", { error: error })
}); });
setState({ ...state, error: error }); setState({ ...state, error: error });
setIsSubmitting(false);
}); });
}; };
const handleFinish = (values) => { const handleFinish = (values) => {
setIsSubmitting(true);
let job = Object.assign( let job = Object.assign(
{}, {},
values, values,
@@ -297,7 +301,7 @@ function JobsCreateContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, curr
}) })
}} }}
> >
<JobsCreateComponent form={form} /> <JobsCreateComponent form={form} isSubmitting={isSubmitting} />
</Form> </Form>
</RbacWrapper> </RbacWrapper>
</JobCreateContext.Provider> </JobCreateContext.Provider>

View File

@@ -231,13 +231,16 @@
"overall": "Overall" "overall": "Overall"
}, },
"disclaimer_title": "AI Scan Beta Disclaimer", "disclaimer_title": "AI Scan Beta Disclaimer",
"feedback_placeholder": "Tell us what worked, what didn't, and what could be better.",
"feedback_prompt": "Was this AI scan helpful?",
"generic_failure": "Failed to process invoice.", "generic_failure": "Failed to process invoice.",
"multipage": "The is a multi-page document. Processing will take a few moments.", "multipage": "The is a multi-page document. Processing will take a few moments.",
"processing": "Analyzing Bill", "processing": "Analyzing Bill",
"scan": "AI Bill Scanner", "scan": "AI Bill Scanner",
"scancomplete": "AI Scan Complete", "scancomplete": "AI Scan Complete",
"scanfailed": "AI Scan Failed", "scanfailed": "AI Scan Failed",
"scanstarted": "AI Scan Started" "scanstarted": "AI Scan Started",
"submit_feedback": "Submit Feedback"
}, },
"bill_lines": "Bill Lines", "bill_lines": "Bill Lines",
"bill_total": "Bill Total Amount", "bill_total": "Bill Total Amount",
@@ -519,6 +522,7 @@
"list-active": "Jobs -> List Active", "list-active": "Jobs -> List Active",
"list-all": "Jobs -> List All", "list-all": "Jobs -> List All",
"list-ready": "Jobs -> List Ready", "list-ready": "Jobs -> List Ready",
"manual-line": "Jobs -> Manual Line",
"partsqueue": "Jobs -> Parts Queue", "partsqueue": "Jobs -> Parts Queue",
"void": "Jobs -> Void" "void": "Jobs -> Void"
}, },
@@ -1074,36 +1078,36 @@
"earlyrorequired.message": "This job requires an early Repair Order to be created before posting to Reynolds. Please use the admin panel to create the early RO first." "earlyrorequired.message": "This job requires an early Repair Order to be created before posting to Reynolds. Please use the admin panel to create the early RO first."
}, },
"labels": { "labels": {
"refreshallocations": "Refresh to see DMS Allocations.", "banner_message": "Posting to {{provider}} | {{transport}} | {{status}}",
"provider_reynolds": "Reynolds",
"provider_fortellis": "Fortellis",
"provider_cdk": "CDK",
"provider_pbs": "PBS",
"provider_dms": "DMS",
"transport_wss": "(WSS)",
"transport_ws": "(WS)",
"banner_status_connected": "Connected", "banner_status_connected": "Connected",
"banner_status_disconnected": "Disconnected", "banner_status_disconnected": "Disconnected",
"banner_message": "Posting to {{provider}} | {{transport}} | {{status}}",
"reconnected_export_service": "Reconnected to {{provider}} Export Service",
"rr_validation_message": "Repair Order created in Reynolds. Complete validation in Reynolds, then click Finished/Close to finalize.",
"rr_validation_notice_title": "Reynolds RO created",
"rr_validation_notice_description": "Complete validation in Reynolds, then click Finished/Close to finalize and mark this export complete.",
"color_json": "Color JSON",
"plain_json": "Plain JSON",
"collapse_all": "Collapse All",
"expand_all": "Expand All",
"log_level": "Log Level",
"clear_logs": "Clear Logs", "clear_logs": "Clear Logs",
"reconnect": "Reconnect", "collapse_all": "Collapse All",
"details": "Details", "color_json": "Color JSON",
"hide_details": "Hide details",
"copy": "Copy",
"copied": "Copied", "copied": "Copied",
"copy": "Copy",
"copy_request": "Copy Request", "copy_request": "Copy Request",
"copy_response": "Copy Response", "copy_response": "Copy Response",
"details": "Details",
"expand_all": "Expand All",
"hide_details": "Hide details",
"log_level": "Log Level",
"plain_json": "Plain JSON",
"provider_cdk": "CDK",
"provider_dms": "DMS",
"provider_fortellis": "Fortellis",
"provider_pbs": "PBS",
"provider_reynolds": "Reynolds",
"reconnect": "Reconnect",
"reconnected_export_service": "Reconnected to {{provider}} Export Service",
"refreshallocations": "Refresh to see DMS Allocations.",
"request_xml": "Request XML", "request_xml": "Request XML",
"response_xml": "Response XML" "response_xml": "Response XML",
"rr_validation_message": "Repair Order created in Reynolds. Complete validation in Reynolds, then click Finished/Close to finalize.",
"rr_validation_notice_description": "Complete validation in Reynolds, then click Finished/Close to finalize and mark this export complete.",
"rr_validation_notice_title": "Reynolds RO created",
"transport_ws": "(WS)",
"transport_wss": "(WSS)"
} }
}, },
"documents": { "documents": {
@@ -1295,6 +1299,7 @@
"delete": "Delete", "delete": "Delete",
"deleteall": "Delete All", "deleteall": "Delete All",
"deselectall": "Deselect All", "deselectall": "Deselect All",
"done": "Done",
"download": "Download", "download": "Download",
"edit": "Edit", "edit": "Edit",
"gotoadmin": "Go to Admin Panel", "gotoadmin": "Go to Admin Panel",
@@ -3373,8 +3378,10 @@
"void_ros": "Void ROs", "void_ros": "Void ROs",
"work_in_progress_committed_labour": "Work in Progress - Committed Labor", "work_in_progress_committed_labour": "Work in Progress - Committed Labor",
"work_in_progress_jobs": "Work in Progress - Jobs", "work_in_progress_jobs": "Work in Progress - Jobs",
"work_in_progress_labour": "Work in Progress - Labor", "work_in_progress_labour": "Work in Progress - Labor (Detail)",
"work_in_progress_payables": "Work in Progress - Payables" "work_in_progress_labour_summary": "Work in Progress - Labor (Summary)",
"work_in_progress_payables": "Work in Progress - Payables (Detail)",
"work_in_progress_payables_summary": "Work in Progress - Payables (Summary)"
} }
}, },
"schedule": { "schedule": {

View File

@@ -231,13 +231,16 @@
"overall": "" "overall": ""
}, },
"disclaimer_title": "", "disclaimer_title": "",
"feedback_placeholder": "",
"feedback_prompt": "",
"generic_failure": "", "generic_failure": "",
"multipage": "", "multipage": "",
"processing": "", "processing": "",
"scan": "", "scan": "",
"scancomplete": "", "scancomplete": "",
"scanfailed": "", "scanfailed": "",
"scanstarted": "" "scanstarted": "",
"submit_feedback": ""
}, },
"bill_lines": "", "bill_lines": "",
"bill_total": "", "bill_total": "",
@@ -519,6 +522,7 @@
"list-active": "", "list-active": "",
"list-all": "", "list-all": "",
"list-ready": "", "list-ready": "",
"manual-line": "",
"partsqueue": "", "partsqueue": "",
"void": "" "void": ""
}, },
@@ -1074,36 +1078,36 @@
"earlyrorequired.message": "" "earlyrorequired.message": ""
}, },
"labels": { "labels": {
"refreshallocations": "", "banner_message": "",
"provider_reynolds": "",
"provider_fortellis": "",
"provider_cdk": "",
"provider_pbs": "",
"provider_dms": "",
"transport_wss": "",
"transport_ws": "",
"banner_status_connected": "", "banner_status_connected": "",
"banner_status_disconnected": "", "banner_status_disconnected": "",
"banner_message": "",
"reconnected_export_service": "",
"rr_validation_message": "",
"rr_validation_notice_title": "",
"rr_validation_notice_description": "",
"color_json": "",
"plain_json": "",
"collapse_all": "",
"expand_all": "",
"log_level": "",
"clear_logs": "", "clear_logs": "",
"reconnect": "", "collapse_all": "",
"details": "", "color_json": "",
"hide_details": "",
"copy": "",
"copied": "", "copied": "",
"copy": "",
"copy_request": "", "copy_request": "",
"copy_response": "", "copy_response": "",
"details": "",
"expand_all": "",
"hide_details": "",
"log_level": "",
"plain_json": "",
"provider_cdk": "",
"provider_dms": "",
"provider_fortellis": "",
"provider_pbs": "",
"provider_reynolds": "",
"reconnect": "",
"reconnected_export_service": "",
"refreshallocations": "",
"request_xml": "", "request_xml": "",
"response_xml": "" "response_xml": "",
"rr_validation_message": "",
"rr_validation_notice_description": "",
"rr_validation_notice_title": "",
"transport_ws": "",
"transport_wss": ""
} }
}, },
"documents": { "documents": {
@@ -1295,6 +1299,7 @@
"delete": "Borrar", "delete": "Borrar",
"deleteall": "", "deleteall": "",
"deselectall": "", "deselectall": "",
"done": "",
"download": "", "download": "",
"edit": "Editar", "edit": "Editar",
"gotoadmin": "", "gotoadmin": "",
@@ -3374,7 +3379,9 @@
"work_in_progress_committed_labour": "", "work_in_progress_committed_labour": "",
"work_in_progress_jobs": "", "work_in_progress_jobs": "",
"work_in_progress_labour": "", "work_in_progress_labour": "",
"work_in_progress_payables": "" "work_in_progress_labour_summary": "",
"work_in_progress_payables": "",
"work_in_progress_payables_summary": ""
} }
}, },
"schedule": { "schedule": {

View File

@@ -231,13 +231,16 @@
"overall": "" "overall": ""
}, },
"disclaimer_title": "", "disclaimer_title": "",
"feedback_placeholder": "",
"feedback_prompt": "",
"generic_failure": "", "generic_failure": "",
"multipage": "", "multipage": "",
"processing": "", "processing": "",
"scan": "", "scan": "",
"scancomplete": "", "scancomplete": "",
"scanfailed": "", "scanfailed": "",
"scanstarted": "" "scanstarted": "",
"submit_feedback": ""
}, },
"bill_lines": "", "bill_lines": "",
"bill_total": "", "bill_total": "",
@@ -519,6 +522,7 @@
"list-active": "", "list-active": "",
"list-all": "", "list-all": "",
"list-ready": "", "list-ready": "",
"manual-line": "",
"partsqueue": "", "partsqueue": "",
"void": "" "void": ""
}, },
@@ -1074,36 +1078,36 @@
"earlyrorequired.message": "" "earlyrorequired.message": ""
}, },
"labels": { "labels": {
"refreshallocations": "", "banner_message": "",
"provider_reynolds": "",
"provider_fortellis": "",
"provider_cdk": "",
"provider_pbs": "",
"provider_dms": "",
"transport_wss": "",
"transport_ws": "",
"banner_status_connected": "", "banner_status_connected": "",
"banner_status_disconnected": "", "banner_status_disconnected": "",
"banner_message": "",
"reconnected_export_service": "",
"rr_validation_message": "",
"rr_validation_notice_title": "",
"rr_validation_notice_description": "",
"color_json": "",
"plain_json": "",
"collapse_all": "",
"expand_all": "",
"log_level": "",
"clear_logs": "", "clear_logs": "",
"reconnect": "", "collapse_all": "",
"details": "", "color_json": "",
"hide_details": "",
"copy": "",
"copied": "", "copied": "",
"copy": "",
"copy_request": "", "copy_request": "",
"copy_response": "", "copy_response": "",
"details": "",
"expand_all": "",
"hide_details": "",
"log_level": "",
"plain_json": "",
"provider_cdk": "",
"provider_dms": "",
"provider_fortellis": "",
"provider_pbs": "",
"provider_reynolds": "",
"reconnect": "",
"reconnected_export_service": "",
"refreshallocations": "",
"request_xml": "", "request_xml": "",
"response_xml": "" "response_xml": "",
"rr_validation_message": "",
"rr_validation_notice_description": "",
"rr_validation_notice_title": "",
"transport_ws": "",
"transport_wss": ""
} }
}, },
"documents": { "documents": {
@@ -1295,6 +1299,7 @@
"delete": "Effacer", "delete": "Effacer",
"deleteall": "", "deleteall": "",
"deselectall": "", "deselectall": "",
"done": "",
"download": "", "download": "",
"edit": "modifier", "edit": "modifier",
"gotoadmin": "", "gotoadmin": "",
@@ -3374,7 +3379,9 @@
"work_in_progress_committed_labour": "", "work_in_progress_committed_labour": "",
"work_in_progress_jobs": "", "work_in_progress_jobs": "",
"work_in_progress_labour": "", "work_in_progress_labour": "",
"work_in_progress_payables": "" "work_in_progress_labour_summary": "",
"work_in_progress_payables": "",
"work_in_progress_payables_summary": ""
} }
}, },
"schedule": { "schedule": {

View File

@@ -1717,6 +1717,20 @@ export const TemplateList = (type, context) => {
group: "jobs", group: "jobs",
featureNameRestricted: "timetickets" featureNameRestricted: "timetickets"
}, },
work_in_progress_labour_summary: {
title: i18n.t("reportcenter.templates.work_in_progress_labour_summary"),
description: "",
subject: i18n.t("reportcenter.templates.work_in_progress_labour_summary"),
key: "work_in_progress_labour_summary",
//idtype: "vendor",
disabled: false,
rangeFilter: {
object: i18n.t("reportcenter.labels.objects.jobs"),
field: i18n.t("jobs.fields.date_open")
},
group: "jobs",
featureNameRestricted: "timetickets"
},
work_in_progress_committed_labour: { work_in_progress_committed_labour: {
title: i18n.t("reportcenter.templates.work_in_progress_committed_labour"), title: i18n.t("reportcenter.templates.work_in_progress_committed_labour"),
description: "", description: "",
@@ -1746,6 +1760,20 @@ export const TemplateList = (type, context) => {
group: "jobs", group: "jobs",
featureNameRestricted: "bills" featureNameRestricted: "bills"
}, },
work_in_progress_payables_summary: {
title: i18n.t("reportcenter.templates.work_in_progress_payables_summary"),
description: "",
subject: i18n.t("reportcenter.templates.work_in_progress_payables_summary"),
key: "work_in_progress_payables_summary",
//idtype: "vendor",
disabled: false,
rangeFilter: {
object: i18n.t("reportcenter.labels.objects.jobs"),
field: i18n.t("jobs.fields.date_open")
},
group: "jobs",
featureNameRestricted: "bills"
},
lag_time: { lag_time: {
title: i18n.t("reportcenter.templates.lag_time"), title: i18n.t("reportcenter.templates.lag_time"),
description: "", description: "",

0
localstack/init/10-bootstrap.sh Normal file → Executable file
View File

View File

@@ -130,12 +130,13 @@ exports.default = async (req, res) => {
async function QueryVendorRecord(oauthClient, qbo_realmId, req, bill) { async function QueryVendorRecord(oauthClient, qbo_realmId, req, bill) {
try { try {
const url = urlBuilder(
qbo_realmId,
"query",
`select * From vendor where DisplayName = '${StandardizeName(bill.vendor.name)}'`
);
const result = await oauthClient.makeApiCall({ const result = await oauthClient.makeApiCall({
url: urlBuilder( url: url,
qbo_realmId,
"query",
`select * From vendor where DisplayName = '${StandardizeName(bill.vendor.name)}'`
),
method: "POST", method: "POST",
headers: { headers: {
"Content-Type": "application/json" "Content-Type": "application/json"
@@ -150,6 +151,11 @@ async function QueryVendorRecord(oauthClient, qbo_realmId, req, bill) {
bodyshopid: bill.job.shopid, bodyshopid: bill.job.shopid,
email: req.user.email email: req.user.email
}); });
logger.log("qbo-payables-query", "DEBUG", req.user.email, null, {
method: "QueryVendorRecord",
call: url,
result: result.json
});
return result.json?.QueryResponse?.Vendor?.[0]; return result.json?.QueryResponse?.Vendor?.[0];
} catch (error) { } catch (error) {
@@ -167,8 +173,9 @@ async function InsertVendorRecord(oauthClient, qbo_realmId, req, bill) {
DisplayName: StandardizeName(bill.vendor.name) DisplayName: StandardizeName(bill.vendor.name)
}; };
try { try {
const url = urlBuilder(qbo_realmId, "vendor");
const result = await oauthClient.makeApiCall({ const result = await oauthClient.makeApiCall({
url: urlBuilder(qbo_realmId, "vendor"), url: url,
method: "POST", method: "POST",
headers: { headers: {
"Content-Type": "application/json" "Content-Type": "application/json"
@@ -184,6 +191,12 @@ async function InsertVendorRecord(oauthClient, qbo_realmId, req, bill) {
bodyshopid: bill.job.shopid, bodyshopid: bill.job.shopid,
email: req.user.email email: req.user.email
}); });
logger.log("qbo-payments-insert", "DEBUG", req.user.email, null, {
method: "InsertVendorRecord",
call: url,
Vendor: Vendor,
result: result.json
});
if (result.status >= 400) { if (result.status >= 400) {
throw new Error(JSON.stringify(result.json.Fault)); throw new Error(JSON.stringify(result.json.Fault));
@@ -274,11 +287,12 @@ async function InsertBill(oauthClient, qbo_realmId, req, bill, vendor, bodyshop)
VendorRef: { VendorRef: {
value: vendor.Id value: vendor.Id
}, },
...(vendor.TermRef && !bill.is_credit_memo && { ...(vendor.TermRef &&
SalesTermRef: { !bill.is_credit_memo && {
value: vendor.TermRef.value SalesTermRef: {
} value: vendor.TermRef.value
}), }
}),
TxnDate: moment(bill.date) TxnDate: moment(bill.date)
//.tz(bill.job.bodyshop.timezone) //.tz(bill.job.bodyshop.timezone)
.format("YYYY-MM-DD"), .format("YYYY-MM-DD"),
@@ -318,8 +332,9 @@ async function InsertBill(oauthClient, qbo_realmId, req, bill, vendor, bodyshop)
[logKey]: logValue [logKey]: logValue
}); });
try { try {
const url = urlBuilder(qbo_realmId, bill.is_credit_memo ? "vendorcredit" : "bill");
const result = await oauthClient.makeApiCall({ const result = await oauthClient.makeApiCall({
url: urlBuilder(qbo_realmId, bill.is_credit_memo ? "vendorcredit" : "bill"), url: url,
method: "POST", method: "POST",
headers: { headers: {
"Content-Type": "application/json" "Content-Type": "application/json"
@@ -335,6 +350,12 @@ async function InsertBill(oauthClient, qbo_realmId, req, bill, vendor, bodyshop)
bodyshopid: bill.job.shopid, bodyshopid: bill.job.shopid,
email: req.user.email email: req.user.email
}); });
logger.log("qbo-payables-insert", "DEBUG", req.user.email, null, {
method: "InsertBill",
call: url,
postingObj: bill.is_credit_memo ? VendorCredit : billQbo,
result: result.json
});
if (result.status >= 400) { if (result.status >= 400) {
throw new Error(JSON.stringify(result.json.Fault)); throw new Error(JSON.stringify(result.json.Fault));

View File

@@ -82,14 +82,7 @@ exports.default = async (req, res) => {
if (isThreeTier || (!isThreeTier && twoTierPref === "name")) { if (isThreeTier || (!isThreeTier && twoTierPref === "name")) {
//Insert the name/owner and account for whether the source should be the ins co in 3 tier.. //Insert the name/owner and account for whether the source should be the ins co in 3 tier..
ownerCustomerTier = await QueryOwner( ownerCustomerTier = await QueryOwner(oauthClient, qbo_realmId, req, payment.job, insCoCustomerTier);
oauthClient,
qbo_realmId,
req,
payment.job,
isThreeTier,
insCoCustomerTier
);
//Query for the owner itself. //Query for the owner itself.
if (!ownerCustomerTier) { if (!ownerCustomerTier) {
ownerCustomerTier = await InsertOwner( ownerCustomerTier = await InsertOwner(
@@ -229,8 +222,9 @@ async function InsertPayment(oauthClient, qbo_realmId, req, payment, parentRef)
paymentQbo paymentQbo
}); });
try { try {
const url = urlBuilder(qbo_realmId, "payment");
const result = await oauthClient.makeApiCall({ const result = await oauthClient.makeApiCall({
url: urlBuilder(qbo_realmId, "payment"), url: url,
method: "POST", method: "POST",
headers: { headers: {
"Content-Type": "application/json" "Content-Type": "application/json"
@@ -246,6 +240,12 @@ async function InsertPayment(oauthClient, qbo_realmId, req, payment, parentRef)
bodyshopid: payment.job.shopid, bodyshopid: payment.job.shopid,
email: req.user.email email: req.user.email
}); });
logger.log("qbo-payments-insert", "DEBUG", req.user.email, null, {
method: "InsertPayment",
call: url,
paymentQbo: paymentQbo,
result: result.json
});
if (result.status >= 400) { if (result.status >= 400) {
throw new Error(JSON.stringify(result.json.Fault)); throw new Error(JSON.stringify(result.json.Fault));
@@ -428,8 +428,9 @@ async function InsertCreditMemo(oauthClient, qbo_realmId, req, payment, parentRe
paymentQbo paymentQbo
}); });
try { try {
const url = urlBuilder(qbo_realmId, "creditmemo");
const result = await oauthClient.makeApiCall({ const result = await oauthClient.makeApiCall({
url: urlBuilder(qbo_realmId, "creditmemo"), url: url,
method: "POST", method: "POST",
headers: { headers: {
"Content-Type": "application/json" "Content-Type": "application/json"
@@ -445,6 +446,12 @@ async function InsertCreditMemo(oauthClient, qbo_realmId, req, payment, parentRe
bodyshopid: req.user.bodyshopid, bodyshopid: req.user.bodyshopid,
email: req.user.email email: req.user.email
}); });
logger.log("qbo-metadata-query", "DEBUG", req.user.email, null, {
method: "InsertCreditMemo",
call: url,
paymentQbo: paymentQbo,
result: result.json
});
if (result.status >= 400) { if (result.status >= 400) {
throw new Error(JSON.stringify(result.json.Fault)); throw new Error(JSON.stringify(result.json.Fault));

View File

@@ -213,12 +213,13 @@ exports.default = async (req, res) => {
async function QueryInsuranceCo(oauthClient, qbo_realmId, req, job) { async function QueryInsuranceCo(oauthClient, qbo_realmId, req, job) {
try { try {
const url = urlBuilder(
qbo_realmId,
"query",
`select * From Customer where DisplayName = '${StandardizeName(job.ins_co_nm.trim())}' and Active = true`
);
const result = await oauthClient.makeApiCall({ const result = await oauthClient.makeApiCall({
url: urlBuilder( url: url,
qbo_realmId,
"query",
`select * From Customer where DisplayName = '${StandardizeName(job.ins_co_nm.trim())}' and Active = true`
),
method: "POST", method: "POST",
headers: { headers: {
"Content-Type": "application/json" "Content-Type": "application/json"
@@ -233,6 +234,11 @@ async function QueryInsuranceCo(oauthClient, qbo_realmId, req, job) {
jobid: job.id, jobid: job.id,
email: req.user.email email: req.user.email
}); });
logger.log("qbo-receivables-query", "DEBUG", req.user.email, job.id, {
method: "QueryInsuranceCo",
call: url,
result: result.json
});
return result.json?.QueryResponse?.Customer?.[0]; return result.json?.QueryResponse?.Customer?.[0];
} catch (error) { } catch (error) {
@@ -266,8 +272,9 @@ async function InsertInsuranceCo(oauthClient, qbo_realmId, req, job, bodyshop) {
} }
}; };
try { try {
const url = urlBuilder(qbo_realmId, "customer");
const result = await oauthClient.makeApiCall({ const result = await oauthClient.makeApiCall({
url: urlBuilder(qbo_realmId, "customer"), url: url,
method: "POST", method: "POST",
headers: { headers: {
"Content-Type": "application/json" "Content-Type": "application/json"
@@ -283,6 +290,12 @@ async function InsertInsuranceCo(oauthClient, qbo_realmId, req, job, bodyshop) {
jobid: job.id, jobid: job.id,
email: req.user.email email: req.user.email
}); });
logger.log("qbo-receivables-insert", "DEBUG", req.user.email, job.id, {
method: "InsertInsuranceCo",
call: url,
customerObj: Customer,
result: result.json
});
return result.json?.Customer; return result.json?.Customer;
} catch (error) { } catch (error) {
@@ -298,12 +311,13 @@ exports.InsertInsuranceCo = InsertInsuranceCo;
async function QueryOwner(oauthClient, qbo_realmId, req, job, parentTierRef) { async function QueryOwner(oauthClient, qbo_realmId, req, job, parentTierRef) {
const ownerName = generateOwnerTier(job, true, null); const ownerName = generateOwnerTier(job, true, null);
const url = urlBuilder(
qbo_realmId,
"query",
`select * From Customer where DisplayName = '${StandardizeName(ownerName)}' and Active = true`
);
const result = await oauthClient.makeApiCall({ const result = await oauthClient.makeApiCall({
url: urlBuilder( url: url,
qbo_realmId,
"query",
`select * From Customer where DisplayName = '${StandardizeName(ownerName)}' and Active = true`
),
method: "POST", method: "POST",
headers: { headers: {
"Content-Type": "application/json" "Content-Type": "application/json"
@@ -318,6 +332,11 @@ async function QueryOwner(oauthClient, qbo_realmId, req, job, parentTierRef) {
jobid: job.id, jobid: job.id,
email: req.user.email email: req.user.email
}); });
logger.log("qbo-receivables-query", "DEBUG", req.user.email, job.id, {
method: "QueryOwner",
call: url,
result: result.json
});
return result.json?.QueryResponse?.Customer?.find((x) => x.ParentRef?.value === parentTierRef?.Id); return result.json?.QueryResponse?.Customer?.find((x) => x.ParentRef?.value === parentTierRef?.Id);
} }
@@ -347,8 +366,9 @@ async function InsertOwner(oauthClient, qbo_realmId, req, job, isThreeTier, pare
: {}) : {})
}; };
try { try {
const url = urlBuilder(qbo_realmId, "customer");
const result = await oauthClient.makeApiCall({ const result = await oauthClient.makeApiCall({
url: urlBuilder(qbo_realmId, "customer"), url: url,
method: "POST", method: "POST",
headers: { headers: {
"Content-Type": "application/json" "Content-Type": "application/json"
@@ -364,6 +384,12 @@ async function InsertOwner(oauthClient, qbo_realmId, req, job, isThreeTier, pare
jobid: job.id, jobid: job.id,
email: req.user.email email: req.user.email
}); });
logger.log("qbo-receivables-insert", "DEBUG", req.user.email, job.id, {
method: "InsertOwner",
call: url,
customerObj: Customer,
result: result.json
});
return result.json?.Customer; return result.json?.Customer;
} catch (error) { } catch (error) {
@@ -378,12 +404,13 @@ async function InsertOwner(oauthClient, qbo_realmId, req, job, isThreeTier, pare
exports.InsertOwner = InsertOwner; exports.InsertOwner = InsertOwner;
async function QueryJob(oauthClient, qbo_realmId, req, job, parentTierRef) { async function QueryJob(oauthClient, qbo_realmId, req, job, parentTierRef) {
const url = urlBuilder(
qbo_realmId,
"query",
`select * From Customer where DisplayName = '${job.ro_number}' and Active = true`
);
const result = await oauthClient.makeApiCall({ const result = await oauthClient.makeApiCall({
url: urlBuilder( url: url,
qbo_realmId,
"query",
`select * From Customer where DisplayName = '${job.ro_number}' and Active = true`
),
method: "POST", method: "POST",
headers: { headers: {
"Content-Type": "application/json" "Content-Type": "application/json"
@@ -398,6 +425,11 @@ async function QueryJob(oauthClient, qbo_realmId, req, job, parentTierRef) {
jobid: job.id, jobid: job.id,
email: req.user.email email: req.user.email
}); });
logger.log("qbo-receivables-query", "DEBUG", req.user.email, job.id, {
method: "QueryJob",
call: url,
result: result.json
});
const customers = result.json?.QueryResponse?.Customer; const customers = result.json?.QueryResponse?.Customer;
return customers && (parentTierRef ? customers.find((x) => x.ParentRef.value === parentTierRef.Id) : customers[0]); return customers && (parentTierRef ? customers.find((x) => x.ParentRef.value === parentTierRef.Id) : customers[0]);
@@ -423,8 +455,9 @@ async function InsertJob(oauthClient, qbo_realmId, req, job, parentTierRef) {
} }
}; };
try { try {
const url = urlBuilder(qbo_realmId, "customer");
const result = await oauthClient.makeApiCall({ const result = await oauthClient.makeApiCall({
url: urlBuilder(qbo_realmId, "customer"), url: url,
method: "POST", method: "POST",
headers: { headers: {
"Content-Type": "application/json" "Content-Type": "application/json"
@@ -440,6 +473,12 @@ async function InsertJob(oauthClient, qbo_realmId, req, job, parentTierRef) {
jobid: job.id, jobid: job.id,
email: req.user.email email: req.user.email
}); });
logger.log("qbo-receivables-insert", "DEBUG", req.user.email, job.id, {
method: "InsertJob",
call: url,
customerObj: Customer,
result: result.json
});
if (result.status >= 400) { if (result.status >= 400) {
throw new Error(JSON.stringify(result.json.Fault)); throw new Error(JSON.stringify(result.json.Fault));

View File

@@ -0,0 +1,73 @@
const { isString } = require("lodash");
const { sendServerEmail } = require("../email/sendemail");
const logger = require("../utils/logger");
const { raw } = require("express");
const SUPPORT_EMAIL = "patrick@imexsystems.ca";
const safeJsonParse = (maybeJson) => {
if (!isString(maybeJson)) return null;
try {
return JSON.parse(maybeJson);
} catch {
return null;
}
};
const handleBillAiFeedback = async (req, res) => {
try {
const rating = req.body?.rating;
const comments = isString(req.body?.comments) ? req.body?.comments?.trim() : "";
const billFormValues = safeJsonParse(req.body?.billFormValues);
const rawAIData = safeJsonParse(req.body?.rawAIData);
const jobid = billFormValues?.jobid || billFormValues?.jobId || "unknown";
const shopname = req.body?.shopname || "unknown";
const subject = `Bill AI Feedback (${rating === "up" ? "+" : "-"}) Shop=${shopname} jobid=${jobid}`;
const text = [
`User: ${req?.user?.email || "unknown"}`,
`Rating: ${rating}`,
comments ? `Comments: ${comments}` : "Comments: (none)",
"",
"Form Values (User):",
JSON.stringify(billFormValues, null, 4),
"",
"Raw AI Data:",
JSON.stringify(rawAIData, null, 4)
]
.filter(Boolean)
.join("\n");
const attachments = [];
if (req.file?.buffer) {
attachments.push({
filename: req.file.originalname || `bill-${jobid}.pdf`,
content: req.file.buffer,
contentType: req.file.mimetype || "application/pdf"
});
}
await sendServerEmail({
to: [SUPPORT_EMAIL],
subject,
type: "text",
text,
attachments
});
return res.json({ success: true });
} catch (error) {
logger.log("bill-ai-feedback-error", "ERROR", req?.user?.email, null, {
message: error?.message,
stack: error?.stack
});
return res.status(500).json({ message: "Failed to submit feedback" });
}
};
module.exports = {
handleBillAiFeedback
};

View File

@@ -212,7 +212,8 @@ async function processSinglePageDocument(pdfBuffer) {
return { return {
...processedData, ...processedData,
originalTextractResponse: result //Removed as this is a large object that provides minimal value to send to client.
// originalTextractResponse: result
}; };
} }
@@ -392,7 +393,8 @@ async function handleTextractNotification(message) {
status: 'COMPLETED', status: 'COMPLETED',
data: { data: {
...processedData, ...processedData,
originalTextractResponse: originalResponse //Removed as this is a large object that provides minimal value to send to client.
// originalTextractResponse: originalResponse
}, },
completedAt: new Date().toISOString() completedAt: new Date().toISOString()
} }

View File

@@ -66,7 +66,12 @@ exports.default = async function ReloadCdkMakes(req, res) {
} catch (error) { } catch (error) {
logger.log("cdk-replace-makes-models-error", "ERROR", req.user.email, null, { logger.log("cdk-replace-makes-models-error", "ERROR", req.user.email, null, {
cdk_dealerid, cdk_dealerid,
error error: {
message: error?.message,
stack: error?.stack,
name: error?.name,
code: error?.code
}
}); });
res.status(500).json(error); res.status(500).json(error);
} }
@@ -105,7 +110,12 @@ async function GetCdkMakes(req, cdk_dealerid) {
} catch (error) { } catch (error) {
logger.log("cdk-replace-makes-models-error", "ERROR", req.user.email, null, { logger.log("cdk-replace-makes-models-error", "ERROR", req.user.email, null, {
cdk_dealerid, cdk_dealerid,
error error: {
message: error?.message,
stack: error?.stack,
name: error?.name,
code: error?.code
}
}); });
throw new Error(error); throw new Error(error);
@@ -141,7 +151,12 @@ async function GetFortellisMakes(req, cdk_dealerid) {
} catch (error) { } catch (error) {
logger.log("fortellis-replace-makes-models-error", "ERROR", req.user.email, null, { logger.log("fortellis-replace-makes-models-error", "ERROR", req.user.email, null, {
cdk_dealerid, cdk_dealerid,
error error: {
message: error?.message,
stack: error?.stack,
name: error?.name,
code: error?.code
}
}); });
throw new Error(error); throw new Error(error);

View File

@@ -44,7 +44,7 @@ const logEmail = async (req, email) => {
} }
}; };
const sendServerEmail = async ({ subject, text, to = [] }) => { const sendServerEmail = async ({ subject, text, to = [], attachments }) => {
if (process.env.NODE_ENV === undefined) return; if (process.env.NODE_ENV === undefined) return;
try { try {
@@ -57,6 +57,7 @@ const sendServerEmail = async ({ subject, text, to = [] }) => {
to: ["support@imexsystems.ca", ...to], to: ["support@imexsystems.ca", ...to],
subject: subject, subject: subject,
text: text, text: text,
attachments: attachments,
ses: { ses: {
// optional extra arguments for SendRawEmail // optional extra arguments for SendRawEmail
Tags: [ Tags: [

View File

@@ -959,7 +959,7 @@ async function UpdateDmsVehicle({ socket, redisHelpers, JobData, DMSVeh, DMSCust
delete DMSVehToSend.inventoryAccount; delete DMSVehToSend.inventoryAccount;
!DMSVehToSend.vehicle.engineNumber && delete DMSVehToSend.vehicle.engineNumber; !DMSVehToSend.vehicle.engineNumber && delete DMSVehToSend.vehicle.engineNumber;
!DMSVehToSend.vehicle.saleClassValue && DMSVehToSend.vehicle.saleClassValue === "MISC"; !DMSVehToSend.vehicle.saleClassValue && (DMSVehToSend.vehicle.saleClassValue = "MISC");
!DMSVehToSend.vehicle.exteriorColor && delete DMSVehToSend.vehicle.exteriorColor; !DMSVehToSend.vehicle.exteriorColor && delete DMSVehToSend.vehicle.exteriorColor;
const result = await MakeFortellisCall({ const result = await MakeFortellisCall({

View File

@@ -315,7 +315,12 @@ function CalculateRatesTotals(ratesList) {
if (item.mod_lbr_ty) { if (item.mod_lbr_ty) {
//Check to see if it has 0 hours and a price instead. //Check to see if it has 0 hours and a price instead.
//Extend for when there are hours and a price. //Extend for when there are hours and a price.
if (item.lbr_op === "OP14" && item.act_price > 0 && (!item.part_type || item.mod_lb_hrs === 0) && !IsAdditionalCost(item)) { if (
item.lbr_op === "OP14" &&
item.act_price > 0 &&
(!item.part_type || item.mod_lb_hrs === 0) &&
!IsAdditionalCost(item)
) {
//Scenario where SGI may pay out hours using a part price. //Scenario where SGI may pay out hours using a part price.
if (!ret[item.mod_lbr_ty.toLowerCase()].total) { if (!ret[item.mod_lbr_ty.toLowerCase()].total) {
ret[item.mod_lbr_ty.toLowerCase()].total = Dinero(); ret[item.mod_lbr_ty.toLowerCase()].total = Dinero();
@@ -339,38 +344,30 @@ function CalculateRatesTotals(ratesList) {
let subtotal = Dinero({ amount: 0 }); let subtotal = Dinero({ amount: 0 });
let rates_subtotal = Dinero({ amount: 0 }); let rates_subtotal = Dinero({ amount: 0 });
for (const property in ret) { for (const [property, values] of Object.entries(ret)) {
//Skip calculating mapa and mash if we got the amounts. //Skip calculating mapa and mash if we got the amounts.
if (!((property === "mapa" && hasMapaLine) || (property === "mash" && hasMashLine))) { const shouldSkipCalculation = (property === "mapa" && hasMapaLine) || (property === "mash" && hasMashLine);
if (!ret[property].total) {
ret[property].total = Dinero(); if (!shouldSkipCalculation) {
} values.total ??= Dinero();
let threshold;
//Check if there is a max for this type. //Check if there is a max for this type and apply it.
if (ratesList.materials && ratesList.materials[property]) { const maxDollar =
// ratesList.materials?.[property]?.cal_maxdlr || ratesList.materials?.[property.toUpperCase()]?.cal_maxdlr;
if (ratesList.materials[property].cal_maxdlr && ratesList.materials[property].cal_maxdlr > 0) { const threshold = maxDollar > 0 ? Dinero({ amount: Math.round(maxDollar * 100) }) : null;
//It has an upper threshhold.
threshold = Dinero({
amount: Math.round(ratesList.materials[property].cal_maxdlr * 100)
});
}
}
const total = Dinero({ const total = Dinero({
amount: Math.round((ret[property].rate || 0) * 100) amount: Math.round((values.rate || 0) * 100)
}).multiply(ret[property].hours); }).multiply(values.hours);
if (threshold && total.greaterThanOrEqual(threshold)) { values.total = values.total.add(threshold && total.greaterThanOrEqual(threshold) ? threshold : total);
ret[property].total = ret[property].total.add(threshold);
} else {
ret[property].total = ret[property].total.add(total);
}
} }
subtotal = subtotal.add(ret[property].total); subtotal = subtotal.add(values.total);
if (property !== "mapa" && property !== "mash") rates_subtotal = rates_subtotal.add(ret[property].total); if (property !== "mapa" && property !== "mash") {
rates_subtotal = rates_subtotal.add(values.total);
}
} }
ret.subtotal = subtotal; ret.subtotal = subtotal;

View File

@@ -4,9 +4,14 @@ const multer = require("multer");
const validateFirebaseIdTokenMiddleware = require("../middleware/validateFirebaseIdTokenMiddleware"); const validateFirebaseIdTokenMiddleware = require("../middleware/validateFirebaseIdTokenMiddleware");
const withUserGraphQLClientMiddleware = require("../middleware/withUserGraphQLClientMiddleware"); const withUserGraphQLClientMiddleware = require("../middleware/withUserGraphQLClientMiddleware");
const { handleBillOcr, handleBillOcrStatus } = require("../ai/bill-ocr/bill-ocr"); const { handleBillOcr, handleBillOcrStatus } = require("../ai/bill-ocr/bill-ocr");
const { handleBillAiFeedback } = require("../ai/bill-ai-feedback");
// Configure multer for form data parsing // Configure multer for form data parsing (memory storage)
const upload = multer(); const upload = multer({
limits: {
fileSize: 5 * 1024 * 1024 // 5MB
}
});
router.use(validateFirebaseIdTokenMiddleware); router.use(validateFirebaseIdTokenMiddleware);
router.use(withUserGraphQLClientMiddleware); router.use(withUserGraphQLClientMiddleware);
@@ -14,4 +19,6 @@ router.use(withUserGraphQLClientMiddleware);
router.post("/bill-ocr", upload.single('billScan'), handleBillOcr); router.post("/bill-ocr", upload.single('billScan'), handleBillOcr);
router.get("/bill-ocr/status/:textractJobId", handleBillOcrStatus); router.get("/bill-ocr/status/:textractJobId", handleBillOcrStatus);
router.post("/bill-feedback", upload.single("billPdf"), handleBillAiFeedback);
module.exports = router; module.exports = router;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -205,8 +205,7 @@ const updateRRRepairOrderWithFullData = async (args) => {
const { client, opts } = buildClientAndOpts(bodyshop); const { client, opts } = buildClientAndOpts(bodyshop);
// For full data update after early RO, we still use "Insert" referenceId // For full data update after early RO, use the RR update route.
// because we're inserting the job operations for the first time
const finalOpts = { const finalOpts = {
...opts, ...opts,
envelope: { envelope: {
@@ -214,7 +213,7 @@ const updateRRRepairOrderWithFullData = async (args) => {
sender: { sender: {
...(opts?.envelope?.sender || {}), ...(opts?.envelope?.sender || {}),
task: "BSMRO", task: "BSMRO",
referenceId: "Insert" referenceId: "Update"
} }
} }
}; };
@@ -317,32 +316,45 @@ const updateRRRepairOrderWithFullData = async (args) => {
opCode opCode
}); });
// Add roNo for linking to existing RO // Update the existing RO created during the early RO step.
payload.finalUpdate = "N";
payload.roNo = String(roNo); payload.roNo = String(roNo);
payload.outsdRoNo = job?.ro_number || job?.id || undefined; payload.outsdRoNo = job?.ro_number || job?.id || undefined;
// Keep rolabor - it's needed to register the job/OpCode accounts in Reynolds // RR update rejects placeholder non-labor ROLABOR rows with zero labor prices.
// Without this, Reynolds won't recognize the OpCode when we send rogg operations // Keep only the actual labor jobs in ROLABOR and let ROGOG carry parts/extras.
// The rolabor section tells Reynolds "these jobs exist" even with minimal data if (payload.rolabor?.ops?.length && payload.rogg?.ops?.length) {
const laborJobNos = new Set(
payload.rogg.ops
.filter((op) => op?.segmentKind === "laborTaxable" || op?.segmentKind === "laborNonTaxable")
.map((op) => String(op.jobNo))
);
CreateRRLogEvent(socket, "INFO", "Preparing full data for early RO (using create with roNo)", { payload.rolabor.ops = payload.rolabor.ops.filter((op) => laborJobNos.has(String(op?.jobNo)));
if (!payload.rolabor.ops.length) {
delete payload.rolabor;
}
}
CreateRRLogEvent(socket, "INFO", "Preparing full data update for existing RR RO", {
roNo: String(roNo), roNo: String(roNo),
hasRolabor: !!payload.rolabor, hasRolabor: !!payload.rolabor,
rolaborCount: payload.rolabor?.ops?.length || 0,
hasRogg: !!payload.rogg, hasRogg: !!payload.rogg,
payload payload
}); });
// Use createRepairOrder (not update) with the roNo to link to the existing early RO const response = await client.updateRepairOrder(payload, finalOpts);
// Reynolds will merge this with the existing RO header
const response = await client.createRepairOrder(payload, finalOpts);
CreateRRLogEvent( CreateRRLogEvent(
socket, socket,
"INFO", "INFO",
"Sending full data for early RO (using create with roNo)", "RR full data update sent for existing RO",
withRRRequestXml(response, { withRRRequestXml(response, {
roNo: String(roNo), roNo: String(roNo),
hasRolabor: !!payload.rolabor, hasRolabor: !!payload.rolabor,
rolaborCount: payload.rolabor?.ops?.length || 0,
hasRogg: !!payload.rogg, hasRogg: !!payload.rogg,
payload, payload,
response response

View File

@@ -368,8 +368,9 @@ const buildRogogFromAllocations = (allocations, { opCode, payType = "Cust", roNo
* *
* We still keep a 1:1 mapping with GOG ops: each op gets a corresponding * We still keep a 1:1 mapping with GOG ops: each op gets a corresponding
* OpCodeLaborInfo entry using the same JobNo and the same tax flag as its * OpCodeLaborInfo entry using the same JobNo and the same tax flag as its
* GOG line. Labor-specific details (hrs/rate) remain zeroed out, and the * GOG line. Labor-specific hours/rate remain zeroed out, but actual labor
* DMS can ignore non-labor ops by virtue of the zero hours/amounts. * sale amounts are mirrored into ROLABOR for labor segments so RR receives
* the expected labor pricing on updates. Non-labor ops remain zeroed.
* *
* @param {Object} rogg - result of buildRogogFromAllocations * @param {Object} rogg - result of buildRogogFromAllocations
* @param {Object} opts * @param {Object} opts
@@ -388,6 +389,8 @@ const buildRolaborFromRogog = (rogg, { payType = "Cust" } = {}) => {
const txFlag = firstLine.custTxblNtxblFlag ?? "N"; const txFlag = firstLine.custTxblNtxblFlag ?? "N";
const linePayType = firstLine.custPayTypeFlag || "C"; const linePayType = firstLine.custPayTypeFlag || "C";
const isLaborSegment = op.segmentKind === "laborTaxable" || op.segmentKind === "laborNonTaxable";
const laborAmount = isLaborSegment ? String(firstLine?.amount?.custPrice ?? "0") : "0";
return { return {
opCode: op.opCode, opCode: op.opCode,
@@ -403,8 +406,8 @@ const buildRolaborFromRogog = (rogg, { payType = "Cust" } = {}) => {
amount: { amount: {
payType, payType,
amtType: "Job", amtType: "Job",
custPrice: "0", custPrice: laborAmount,
totalAmt: "0" totalAmt: laborAmount
} }
}; };
}); });