feature/IO-3357-Reynolds-and-Reynolds-DMS-API-Integration Clean up posting form
This commit is contained in:
@@ -29,7 +29,6 @@ function normalizeRrList(list) {
|
|||||||
if (!custNo) return null;
|
if (!custNo) return null;
|
||||||
const vinOwner = !!(row.vinOwner ?? row.isVehicleOwner);
|
const vinOwner = !!(row.vinOwner ?? row.isVehicleOwner);
|
||||||
|
|
||||||
// Pass through address from backend if present; tolerate various shapes
|
|
||||||
const address =
|
const address =
|
||||||
row.address && typeof row.address === "object"
|
row.address && typeof row.address === "object"
|
||||||
? {
|
? {
|
||||||
@@ -47,7 +46,6 @@ function normalizeRrList(list) {
|
|||||||
.filter(Boolean);
|
.filter(Boolean);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Small formatter used by the RR Address column render
|
|
||||||
function rrAddressToString(addr) {
|
function rrAddressToString(addr) {
|
||||||
if (!addr) return "";
|
if (!addr) return "";
|
||||||
const parts = [
|
const parts = [
|
||||||
@@ -89,16 +87,12 @@ export function DmsCustomerSelector({ bodyshop, jobid }) {
|
|||||||
const rrHasVinOwner = rrOwnerSet.size > 0;
|
const rrHasVinOwner = rrOwnerSet.size > 0;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// RR takes precedence
|
|
||||||
if (dms === "rr") {
|
if (dms === "rr") {
|
||||||
const handleRrSelectCustomer = (list) => {
|
const handleRrSelectCustomer = (list) => {
|
||||||
const normalized = normalizeRrList(list);
|
const normalized = normalizeRrList(list);
|
||||||
|
|
||||||
setOpen(true);
|
setOpen(true);
|
||||||
setDmsType("rr");
|
setDmsType("rr");
|
||||||
setcustomerList(normalized);
|
setcustomerList(normalized);
|
||||||
|
|
||||||
// PRESELECT VIN OWNER (first one if multiple)
|
|
||||||
const firstOwner = normalized.find((r) => r.vinOwner)?.custNo;
|
const firstOwner = normalized.find((r) => r.vinOwner)?.custNo;
|
||||||
setSelectedCustomer(firstOwner ? String(firstOwner) : null);
|
setSelectedCustomer(firstOwner ? String(firstOwner) : null);
|
||||||
};
|
};
|
||||||
@@ -142,7 +136,6 @@ export function DmsCustomerSelector({ bodyshop, jobid }) {
|
|||||||
}
|
}
|
||||||
}, [dms, Fortellis?.treatment, wsssocket]);
|
}, [dms, Fortellis?.treatment, wsssocket]);
|
||||||
|
|
||||||
// Safety: if owner info arrives later or list changes, keep the owner preselected.
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (dmsType !== "rr" || !rrHasVinOwner) return;
|
if (dmsType !== "rr" || !rrHasVinOwner) return;
|
||||||
const firstOwner = (customerList.find((c) => c.vinOwner) || {}).custNo;
|
const firstOwner = (customerList.find((c) => c.vinOwner) || {}).custNo;
|
||||||
@@ -157,7 +150,6 @@ export function DmsCustomerSelector({ bodyshop, jobid }) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there is a VIN owner, only allow owner selection
|
|
||||||
if (dmsType === "rr" && rrHasVinOwner && !rrOwnerSet.has(String(selectedCustomer))) {
|
if (dmsType === "rr" && rrHasVinOwner && !rrOwnerSet.has(String(selectedCustomer))) {
|
||||||
message.warning(
|
message.warning(
|
||||||
"This VIN is already assigned in Reynolds. Only the VIN owner can be selected. To choose a different customer, change ownership in Reynolds first."
|
"This VIN is already assigned in Reynolds. Only the VIN owner can be selected. To choose a different customer, change ownership in Reynolds first."
|
||||||
@@ -187,15 +179,12 @@ export function DmsCustomerSelector({ bodyshop, jobid }) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const onUseGeneric = () => {
|
const onUseGeneric = () => {
|
||||||
if (dmsType === "rr" && rrHasVinOwner) return;
|
if (dmsType === "rr" && rrHasVinOwner) return; // not rendered in RR, but keep guard
|
||||||
const generic = bodyshop.cdk_configuration?.generic_customer_number || null;
|
const generic = bodyshop.cdk_configuration?.generic_customer_number || null;
|
||||||
|
|
||||||
if (dmsType === "rr") {
|
if (dmsType === "rr") {
|
||||||
if (generic) {
|
// Not rendered in RR anymore
|
||||||
wsssocket.emit("rr-selected-customer", { jobId: jobid, custNo: String(generic) }, (ack) => {
|
return;
|
||||||
if (!ack?.ok && ack?.error) message.error(ack.error);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
setOpen(false);
|
|
||||||
} else if (Fortellis.treatment === "on") {
|
} else if (Fortellis.treatment === "on") {
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
wsssocket.emit("fortellis-selected-customer", { selectedCustomerId: generic, jobid });
|
wsssocket.emit("fortellis-selected-customer", { selectedCustomerId: generic, jobid });
|
||||||
@@ -357,12 +346,14 @@ export function DmsCustomerSelector({ bodyshop, jobid }) {
|
|||||||
<Button onClick={onUseSelected} disabled={!selectedCustomer}>
|
<Button onClick={onUseSelected} disabled={!selectedCustomer}>
|
||||||
{t("jobs.actions.dms.useselected")}
|
{t("jobs.actions.dms.useselected")}
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
|
||||||
onClick={onUseGeneric}
|
{/* Hide "Use Generic" entirely in RR mode */}
|
||||||
disabled={dmsType === "rr" ? rrHasVinOwner : !bodyshop.cdk_configuration?.generic_customer_number}
|
{dmsType !== "rr" && (
|
||||||
>
|
<Button onClick={onUseGeneric} disabled={!bodyshop.cdk_configuration?.generic_customer_number}>
|
||||||
{t("jobs.actions.dms.usegeneric")}
|
{t("jobs.actions.dms.usegeneric")}
|
||||||
</Button>
|
</Button>
|
||||||
|
)}
|
||||||
|
|
||||||
<Button onClick={onCreateNew} disabled={dmsType === "rr" ? rrHasVinOwner : false}>
|
<Button onClick={onCreateNew} disabled={dmsType === "rr" ? rrHasVinOwner : false}>
|
||||||
{t("jobs.actions.dms.createnewcustomer")}
|
{t("jobs.actions.dms.createnewcustomer")}
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -1,17 +1,19 @@
|
|||||||
// DmsPostForm updated
|
|
||||||
import { DeleteFilled, DownOutlined, ReloadOutlined } from "@ant-design/icons";
|
import { DeleteFilled, DownOutlined, ReloadOutlined } from "@ant-design/icons";
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
Card,
|
Card,
|
||||||
|
Col,
|
||||||
Divider,
|
Divider,
|
||||||
Dropdown,
|
Dropdown,
|
||||||
Form,
|
Form,
|
||||||
Input,
|
Input,
|
||||||
InputNumber,
|
InputNumber,
|
||||||
|
Row,
|
||||||
Select,
|
Select,
|
||||||
Space,
|
Space,
|
||||||
Statistic,
|
Statistic,
|
||||||
Switch,
|
Switch,
|
||||||
|
Tooltip,
|
||||||
Typography
|
Typography
|
||||||
} from "antd";
|
} from "antd";
|
||||||
import Dinero from "dinero.js";
|
import Dinero from "dinero.js";
|
||||||
@@ -26,7 +28,6 @@ import DmsCdkMakes from "../dms-cdk-makes/dms-cdk-makes.component";
|
|||||||
import DmsCdkMakesRefetch from "../dms-cdk-makes/dms-cdk-makes.refetch.component";
|
import DmsCdkMakesRefetch from "../dms-cdk-makes/dms-cdk-makes.refetch.component";
|
||||||
import DateTimePicker from "../form-date-time-picker/form-date-time-picker.component.jsx";
|
import DateTimePicker from "../form-date-time-picker/form-date-time-picker.component.jsx";
|
||||||
import CurrencyInput from "../form-items-formatted/currency-form-item.component";
|
import CurrencyInput from "../form-items-formatted/currency-form-item.component";
|
||||||
import LayoutFormRow from "../layout-form-row/layout-form-row.component";
|
|
||||||
import { useSocket } from "../../contexts/SocketIO/useSocket";
|
import { useSocket } from "../../contexts/SocketIO/useSocket";
|
||||||
import { useSplitTreatments } from "@splitsoftware/splitio-react";
|
import { useSplitTreatments } from "@splitsoftware/splitio-react";
|
||||||
import { useEffect, useMemo, useState } from "react";
|
import { useEffect, useMemo, useState } from "react";
|
||||||
@@ -53,13 +54,13 @@ export function DmsPostForm({ bodyshop, socket, job, logsRef }) {
|
|||||||
// Figure out DMS once and reuse
|
// Figure out DMS once and reuse
|
||||||
const dms = useMemo(() => determineDmsType(bodyshop), [bodyshop]);
|
const dms = useMemo(() => determineDmsType(bodyshop), [bodyshop]);
|
||||||
|
|
||||||
// RR advisors state
|
// ---------------- RR Advisors (unchanged behavior) ----------------
|
||||||
const [advisors, setAdvisors] = useState([]);
|
const [advisors, setAdvisors] = useState([]);
|
||||||
const [advLoading, setAdvLoading] = useState(false);
|
const [advLoading, setAdvLoading] = useState(false);
|
||||||
|
|
||||||
// Normalize advisor fields coming from various shapes
|
// Normalize advisor fields coming from various shapes
|
||||||
const getAdvisorNumber = (a) => a?.advisorId;
|
const getAdvisorNumber = (a) => a?.advisorId;
|
||||||
const getAdvisorLabel = (a) => `${a?.firstName} ${a?.lastName}`?.trim();
|
const getAdvisorLabel = (a) => `${a?.firstName || ""} ${a?.lastName || ""}`.trim();
|
||||||
|
|
||||||
const fetchRrAdvisors = (refresh = false) => {
|
const fetchRrAdvisors = (refresh = false) => {
|
||||||
if (!wsssocket) return;
|
if (!wsssocket) return;
|
||||||
@@ -84,6 +85,7 @@ export function DmsPostForm({ bodyshop, socket, job, logsRef }) {
|
|||||||
const list = ack.result ?? [];
|
const list = ack.result ?? [];
|
||||||
setAdvisors(Array.isArray(list) ? list : []);
|
setAdvisors(Array.isArray(list) ? list : []);
|
||||||
} else if (ack) {
|
} else if (ack) {
|
||||||
|
// Preserve original logging semantics
|
||||||
console.error("Something went wrong fetching DMS Advisors");
|
console.error("Something went wrong fetching DMS Advisors");
|
||||||
}
|
}
|
||||||
setAdvLoading(false);
|
setAdvLoading(false);
|
||||||
@@ -95,13 +97,13 @@ export function DmsPostForm({ bodyshop, socket, job, logsRef }) {
|
|||||||
if (dms === "rr") fetchRrAdvisors(false);
|
if (dms === "rr") fetchRrAdvisors(false);
|
||||||
}, [dms, bodyshop?.id]);
|
}, [dms, bodyshop?.id]);
|
||||||
|
|
||||||
|
// ---------------- Payers helpers (non-RR) ----------------
|
||||||
const handlePayerSelect = (value, index) => {
|
const handlePayerSelect = (value, index) => {
|
||||||
form.setFieldsValue({
|
form.setFieldsValue({
|
||||||
payers: form.getFieldValue("payers").map((payer, mapIndex) => {
|
payers: (form.getFieldValue("payers") || []).map((payer, mapIndex) => {
|
||||||
if (index !== mapIndex) return payer;
|
if (index !== mapIndex) return payer;
|
||||||
const cdkPayer =
|
const cdkPayer =
|
||||||
bodyshop.cdk_configuration.payers && bodyshop.cdk_configuration.payers.find((i) => i.name === value);
|
bodyshop.cdk_configuration.payers && bodyshop.cdk_configuration.payers.find((i) => i.name === value);
|
||||||
|
|
||||||
if (!cdkPayer) return payer;
|
if (!cdkPayer) return payer;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -113,38 +115,30 @@ export function DmsPostForm({ bodyshop, socket, job, logsRef }) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// ---------------- Submit (RR precedence preserved) ----------------
|
||||||
const handleFinish = (values) => {
|
const handleFinish = (values) => {
|
||||||
// 1) RR takes precedence regardless of Fortellis split
|
// RR takes precedence regardless of Fortellis split
|
||||||
if (dms === "rr") {
|
if (dms === "rr") {
|
||||||
// values will now include advisorNo from the RR dropdown
|
// values will include advisorNo (and makeOverride if provided)
|
||||||
wsssocket.emit("rr-export-job", {
|
wsssocket.emit("rr-export-job", {
|
||||||
bodyshopId: bodyshop?.id,
|
bodyshopId: bodyshop?.id,
|
||||||
jobId: job.id,
|
jobId: job.id,
|
||||||
job,
|
job,
|
||||||
txEnvelope: values
|
txEnvelope: values
|
||||||
});
|
});
|
||||||
|
} else if (Fortellis.treatment === "on") {
|
||||||
|
// Fallback to existing Fortellis behavior
|
||||||
|
wsssocket.emit("fortellis-export-job", {
|
||||||
|
jobid: job.id,
|
||||||
|
txEnvelope: { ...values, SubscriptionID: bodyshop.cdk_dealerid }
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
// 2) Fallback to existing behavior
|
// CDK/PBS/etc.
|
||||||
if (Fortellis.treatment === "on") {
|
socket.emit(`${dms}-export-job`, { jobid: job.id, txEnvelope: values });
|
||||||
wsssocket.emit("fortellis-export-job", {
|
|
||||||
jobid: job.id,
|
|
||||||
txEnvelope: {
|
|
||||||
...values,
|
|
||||||
SubscriptionID: bodyshop.cdk_dealerid
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
// cdk/pbs/etc.
|
|
||||||
socket.emit(`${dms}-export-job`, {
|
|
||||||
jobid: job.id,
|
|
||||||
txEnvelope: values
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (logsRef?.current) {
|
// Scroll logs into view (original behavior)
|
||||||
logsRef.current.scrollIntoView({ behavior: "smooth" });
|
logsRef?.current?.scrollIntoView({ behavior: "smooth" });
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -153,6 +147,7 @@ export function DmsPostForm({ bodyshop, socket, job, logsRef }) {
|
|||||||
form={form}
|
form={form}
|
||||||
layout="vertical"
|
layout="vertical"
|
||||||
onFinish={handleFinish}
|
onFinish={handleFinish}
|
||||||
|
style={{ width: "100%" }}
|
||||||
initialValues={{
|
initialValues={{
|
||||||
story: `${t("jobs.labels.dms.defaultstory", {
|
story: `${t("jobs.labels.dms.defaultstory", {
|
||||||
ro_number: job.ro_number,
|
ro_number: job.ro_number,
|
||||||
@@ -160,7 +155,7 @@ export function DmsPostForm({ bodyshop, socket, job, logsRef }) {
|
|||||||
ins_co_nm: job.ins_co_nm || "N/A",
|
ins_co_nm: job.ins_co_nm || "N/A",
|
||||||
clm_po: `${job.clm_no ? `${job.clm_no} ` : ""}${job.po_number || ""}`
|
clm_po: `${job.clm_no ? `${job.clm_no} ` : ""}${job.po_number || ""}`
|
||||||
}).trim()}.${
|
}).trim()}.${
|
||||||
job.area_of_damage && job.area_of_damage.impact1
|
job.area_of_damage?.impact1
|
||||||
? " " +
|
? " " +
|
||||||
t("jobs.labels.dms.damageto", {
|
t("jobs.labels.dms.damageto", {
|
||||||
area_of_damage: (job.area_of_damage && job.area_of_damage.impact1.padStart(2, "0")) || "UNKNOWN"
|
area_of_damage: (job.area_of_damage && job.area_of_damage.impact1.padStart(2, "0")) || "UNKNOWN"
|
||||||
@@ -168,94 +163,151 @@ export function DmsPostForm({ bodyshop, socket, job, logsRef }) {
|
|||||||
: ""
|
: ""
|
||||||
}`.slice(0, 239),
|
}`.slice(0, 239),
|
||||||
inservicedate: dayjs(
|
inservicedate: dayjs(
|
||||||
`${(job.v_model_yr && (job.v_model_yr < 100 ? (job.v_model_yr >= (dayjs().year() + 1) % 100 ? 1900 + parseInt(job.v_model_yr) : 2000 + parseInt(job.v_model_yr)) : job.v_model_yr)) || 2019}-01-01`
|
`${
|
||||||
|
(job.v_model_yr &&
|
||||||
|
(job.v_model_yr < 100
|
||||||
|
? job.v_model_yr >= (dayjs().year() + 1) % 100
|
||||||
|
? 1900 + parseInt(job.v_model_yr, 10)
|
||||||
|
: 2000 + parseInt(job.v_model_yr, 10)
|
||||||
|
: job.v_model_yr)) ||
|
||||||
|
2019
|
||||||
|
}-01-01`
|
||||||
)
|
)
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<LayoutFormRow grow>
|
{/* TOP ROW — bottom-aligned so the Refresh button sits flush */}
|
||||||
|
<Row gutter={[16, 12]} align="bottom">
|
||||||
{dms !== "rr" && (
|
{dms !== "rr" && (
|
||||||
<Form.Item
|
<Col xs={24} sm={12} md={8} lg={6}>
|
||||||
name="journal"
|
<Form.Item
|
||||||
label={t("jobs.fields.dms.journal")}
|
name="journal"
|
||||||
initialValue={bodyshop.cdk_configuration?.default_journal}
|
label={t("jobs.fields.dms.journal")}
|
||||||
rules={[{ required: true }]}
|
initialValue={bodyshop.cdk_configuration?.default_journal}
|
||||||
>
|
rules={[{ required: true }]}
|
||||||
<Input />
|
>
|
||||||
</Form.Item>
|
<Input />
|
||||||
|
</Form.Item>
|
||||||
|
</Col>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* RR Advisor Number dropdown */}
|
|
||||||
{dms === "rr" && (
|
|
||||||
<Form.Item
|
|
||||||
name="advisorNo"
|
|
||||||
label={t("jobs.fields.dms.advisor")}
|
|
||||||
rules={[{ required: true }]}
|
|
||||||
style={{ minWidth: 260 }}
|
|
||||||
>
|
|
||||||
<Select
|
|
||||||
loading={advLoading}
|
|
||||||
placeholder={t("general.actions.select", "Select...")}
|
|
||||||
popupMatchSelectWidth
|
|
||||||
options={advisors
|
|
||||||
.map((a) => {
|
|
||||||
const value = getAdvisorNumber(a);
|
|
||||||
if (value == null) return null;
|
|
||||||
return { value: String(value), label: getAdvisorLabel(a) || String(value) };
|
|
||||||
})
|
|
||||||
.filter(Boolean)}
|
|
||||||
notFoundContent={advLoading ? t("general.loading") : t("general.none")}
|
|
||||||
/>
|
|
||||||
</Form.Item>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<Form.Item name="kmin" label={t("jobs.fields.kmin")} initialValue={job?.kmin} rules={[{ required: true }]}>
|
|
||||||
<InputNumber disabled />
|
|
||||||
</Form.Item>
|
|
||||||
<Form.Item name="kmout" label={t("jobs.fields.kmout")} initialValue={job?.kmout} rules={[{ required: true }]}>
|
|
||||||
<InputNumber disabled />
|
|
||||||
</Form.Item>
|
|
||||||
|
|
||||||
{dms === "rr" && (
|
{dms === "rr" && (
|
||||||
<Form.Item label=" " colon={false}>
|
<>
|
||||||
<Button onClick={() => fetchRrAdvisors(true)} icon={<ReloadOutlined />} loading={advLoading}>
|
{/* Advisor + inline Refresh (restores original behavior with better UX) */}
|
||||||
{t("general.actions.refresh")}
|
<Col xs={24} sm={24} md={12} lg={8}>
|
||||||
</Button>
|
<Form.Item name="advisorNo" label={t("jobs.fields.dms.advisor")} rules={[{ required: true }]}>
|
||||||
</Form.Item>
|
<Space.Compact block>
|
||||||
)}
|
<Select
|
||||||
</LayoutFormRow>
|
style={{ flex: 1 }}
|
||||||
|
loading={advLoading}
|
||||||
|
allowClear
|
||||||
|
placeholder={t("general.actions.select", "Select...")}
|
||||||
|
popupMatchSelectWidth
|
||||||
|
options={advisors
|
||||||
|
.map((a) => {
|
||||||
|
const value = getAdvisorNumber(a);
|
||||||
|
if (value == null) return null;
|
||||||
|
return { value: String(value), label: getAdvisorLabel(a) || String(value) };
|
||||||
|
})
|
||||||
|
.filter(Boolean)}
|
||||||
|
notFoundContent={advLoading ? t("general.loading") : t("general.none")}
|
||||||
|
/>
|
||||||
|
<Tooltip title={t("general.actions.refresh")}>
|
||||||
|
<Button
|
||||||
|
aria-label={t("general.actions.refresh")}
|
||||||
|
icon={<ReloadOutlined />}
|
||||||
|
onClick={() => fetchRrAdvisors(true)}
|
||||||
|
loading={advLoading}
|
||||||
|
/>
|
||||||
|
</Tooltip>
|
||||||
|
</Space.Compact>
|
||||||
|
</Form.Item>
|
||||||
|
</Col>
|
||||||
|
|
||||||
|
{/* Make Override (RR only, beside Advisor) */}
|
||||||
|
<Col xs={24} sm={12} md={12} lg={8}>
|
||||||
|
<Form.Item name="makeOverride" label={t("jobs.fields.dms.make_override")}>
|
||||||
|
<Input allowClear placeholder={t("general.actions.optional")} />
|
||||||
|
</Form.Item>
|
||||||
|
</Col>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<Col xs={12} sm={8} md={6} lg={4}>
|
||||||
|
<Form.Item name="kmin" label={t("jobs.fields.kmin")} initialValue={job?.kmin} rules={[{ required: true }]}>
|
||||||
|
<InputNumber style={{ width: "100%" }} disabled />
|
||||||
|
</Form.Item>
|
||||||
|
</Col>
|
||||||
|
|
||||||
|
<Col xs={12} sm={8} md={6} lg={4}>
|
||||||
|
<Form.Item
|
||||||
|
name="kmout"
|
||||||
|
label={t("jobs.fields.kmout")}
|
||||||
|
initialValue={job?.kmout}
|
||||||
|
rules={[{ required: true }]}
|
||||||
|
>
|
||||||
|
<InputNumber style={{ width: "100%" }} disabled />
|
||||||
|
</Form.Item>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
|
||||||
|
{/* CDK vehicle details (unchanged behavior) */}
|
||||||
{bodyshop.cdk_dealerid && (
|
{bodyshop.cdk_dealerid && (
|
||||||
<div>
|
<>
|
||||||
<LayoutFormRow style={{ justifyContent: "center" }} grow>
|
<Row gutter={[16, 12]}>
|
||||||
<Form.Item name="dms_make" label={t("jobs.fields.dms.dms_make")} rules={[{ required: true }]}>
|
<Col xs={24} sm={12} md={8}>
|
||||||
<Input />
|
<Form.Item name="dms_make" label={t("jobs.fields.dms.dms_make")} rules={[{ required: true }]}>
|
||||||
</Form.Item>
|
<Input />
|
||||||
<Form.Item name="dms_model" label={t("jobs.fields.dms.dms_model")} rules={[{ required: true }]}>
|
</Form.Item>
|
||||||
<Input />
|
</Col>
|
||||||
</Form.Item>
|
<Col xs={24} sm={12} md={8}>
|
||||||
<Form.Item name="inservicedate" label={t("jobs.fields.dms.inservicedate")}>
|
<Form.Item name="dms_model" label={t("jobs.fields.dms.dms_model")} rules={[{ required: true }]}>
|
||||||
<DateTimePicker isDateOnly />
|
<Input />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
</LayoutFormRow>
|
</Col>
|
||||||
<Space>
|
<Col xs={24} sm={12} md={8}>
|
||||||
<DmsCdkMakes form={form} job={job} />
|
<Form.Item name="inservicedate" label={t("jobs.fields.dms.inservicedate")}>
|
||||||
<DmsCdkMakesRefetch />
|
<DateTimePicker isDateOnly />
|
||||||
<Form.Item name="dms_unsold" label={t("jobs.fields.dms.dms_unsold")} initialValue={false}>
|
</Form.Item>
|
||||||
<Switch />
|
</Col>
|
||||||
</Form.Item>
|
</Row>
|
||||||
<Form.Item name="dms_model_override" label={t("jobs.fields.dms.dms_model_override")} initialValue={false}>
|
|
||||||
<Switch />
|
<Row gutter={[16, 12]} align="middle">
|
||||||
</Form.Item>
|
<Col>
|
||||||
</Space>
|
<DmsCdkMakes form={form} job={job} />
|
||||||
</div>
|
</Col>
|
||||||
|
<Col>
|
||||||
|
<DmsCdkMakesRefetch />
|
||||||
|
</Col>
|
||||||
|
<Col>
|
||||||
|
<Form.Item name="dms_unsold" label={t("jobs.fields.dms.dms_unsold")} initialValue={false}>
|
||||||
|
<Switch />
|
||||||
|
</Form.Item>
|
||||||
|
</Col>
|
||||||
|
<Col>
|
||||||
|
<Form.Item
|
||||||
|
name="dms_model_override"
|
||||||
|
label={t("jobs.fields.dms.dms_model_override")}
|
||||||
|
initialValue={false}
|
||||||
|
>
|
||||||
|
<Switch />
|
||||||
|
</Form.Item>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<Form.Item name="story" label={t("jobs.fields.dms.story")} rules={[{ required: true }]}>
|
<Row gutter={[16, 12]}>
|
||||||
<Input.TextArea maxLength={240} />
|
<Col span={24}>
|
||||||
</Form.Item>
|
<Form.Item name="story" label={t("jobs.fields.dms.story")} rules={[{ required: true }]}>
|
||||||
|
<Input.TextArea maxLength={240} />
|
||||||
|
</Form.Item>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
|
||||||
<Divider />
|
<Divider />
|
||||||
<Space size="large" wrap align="center">
|
|
||||||
|
{/* Totals (unchanged) */}
|
||||||
|
<Space size="large" wrap align="center" style={{ marginBottom: 16 }}>
|
||||||
<Statistic
|
<Statistic
|
||||||
title={t("jobs.fields.ded_amt")}
|
title={t("jobs.fields.ded_amt")}
|
||||||
value={Dinero(job.job_totals.totals.custPayable.deductible).toFormat()}
|
value={Dinero(job.job_totals.totals.custPayable.deductible).toFormat()}
|
||||||
@@ -270,119 +322,145 @@ export function DmsPostForm({ bodyshop, socket, job, logsRef }) {
|
|||||||
/>
|
/>
|
||||||
</Space>
|
</Space>
|
||||||
|
|
||||||
{dms !== "rr" && (
|
{/* Non-RR payers list (parity with original) */}
|
||||||
<Form.List name={["payers"]}>
|
{dms !== "rd" && (
|
||||||
{(fields, { add, remove }) => (
|
<>
|
||||||
<div>
|
<Divider />
|
||||||
{fields.map((field, index) => (
|
|
||||||
<Form.Item key={field.key}>
|
|
||||||
<Space wrap>
|
|
||||||
<Form.Item
|
|
||||||
label={t("jobs.fields.dms.payer.name")}
|
|
||||||
key={`${index}name`}
|
|
||||||
name={[field.name, "name"]}
|
|
||||||
rules={[{ required: true }]}
|
|
||||||
>
|
|
||||||
<Select style={{ minWidth: "15rem" }} onSelect={(value) => handlePayerSelect(value, index)}>
|
|
||||||
{bodyshop.cdk_configuration?.payers &&
|
|
||||||
bodyshop.cdk_configuration.payers.map((payer) => (
|
|
||||||
<Select.Option key={payer.name}>{payer.name}</Select.Option>
|
|
||||||
))}
|
|
||||||
</Select>
|
|
||||||
</Form.Item>
|
|
||||||
|
|
||||||
<Form.Item
|
<Form.List name={["payers"]}>
|
||||||
label={t("jobs.fields.dms.payer.dms_acctnumber")}
|
{(fields, { add, remove }) => (
|
||||||
key={`${index}dms_acctnumber`}
|
<div>
|
||||||
name={[field.name, "dms_acctnumber"]}
|
{fields.map((field, index) => (
|
||||||
rules={[{ required: true }]}
|
<Card
|
||||||
>
|
key={field.key}
|
||||||
<Input disabled />
|
size="small"
|
||||||
</Form.Item>
|
style={{ marginBottom: 12 }}
|
||||||
|
title={`${t("jobs.fields.dms.payer.payer_type")} #${index + 1}`}
|
||||||
|
extra={
|
||||||
|
<Tooltip title={t("jobs.actions.remove", "Remove")}>
|
||||||
|
<Button
|
||||||
|
type="text"
|
||||||
|
danger
|
||||||
|
icon={<DeleteFilled />}
|
||||||
|
aria-label={t("jobs.actions.remove", "Remove")}
|
||||||
|
onClick={() => remove(field.name)}
|
||||||
|
/>
|
||||||
|
</Tooltip>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<Row gutter={[16, 8]} align="middle">
|
||||||
|
<Col xs={24} sm={12} md={8} lg={6}>
|
||||||
|
<Form.Item
|
||||||
|
label={t("jobs.fields.dms.payer.name")}
|
||||||
|
name={[field.name, "name"]}
|
||||||
|
rules={[{ required: true }]}
|
||||||
|
>
|
||||||
|
<Select style={{ minWidth: "15rem" }} onSelect={(value) => handlePayerSelect(value, index)}>
|
||||||
|
{bodyshop.cdk_configuration?.payers?.map((payer) => (
|
||||||
|
<Select.Option key={payer.name}>{payer.name}</Select.Option>
|
||||||
|
))}
|
||||||
|
</Select>
|
||||||
|
</Form.Item>
|
||||||
|
</Col>
|
||||||
|
|
||||||
<Form.Item
|
<Col xs={24} sm={12} md={8} lg={6}>
|
||||||
label={t("jobs.fields.dms.payer.amount")}
|
<Form.Item
|
||||||
key={`${index}amount`}
|
label={t("jobs.fields.dms.payer.dms_acctnumber")}
|
||||||
name={[field.name, "amount"]}
|
name={[field.name, "dms_acctnumber"]}
|
||||||
rules={[{ required: true }]}
|
rules={[{ required: true }]}
|
||||||
>
|
>
|
||||||
<CurrencyInput min={0} />
|
<Input disabled />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
</Col>
|
||||||
|
|
||||||
<Form.Item
|
<Col xs={24} sm={12} md={8} lg={5}>
|
||||||
label={
|
<Form.Item
|
||||||
<div>
|
label={t("jobs.fields.dms.payer.amount")}
|
||||||
{t("jobs.fields.dms.payer.controlnumber")}{" "}
|
name={[field.name, "amount"]}
|
||||||
<Dropdown
|
rules={[{ required: true }]}
|
||||||
menu={{
|
>
|
||||||
items:
|
<CurrencyInput min={0} />
|
||||||
bodyshop.cdk_configuration.controllist?.map((key, idx) => ({
|
</Form.Item>
|
||||||
key: idx,
|
</Col>
|
||||||
label: key.name,
|
|
||||||
onClick: () => {
|
|
||||||
form.setFieldsValue({
|
|
||||||
payers: form.getFieldValue("payers").map((row, mapIndex) => {
|
|
||||||
if (index !== mapIndex) return row;
|
|
||||||
return {
|
|
||||||
...row,
|
|
||||||
controlnumber: key.controlnumber
|
|
||||||
};
|
|
||||||
})
|
|
||||||
});
|
|
||||||
}
|
|
||||||
})) ?? []
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<a href=" #" onClick={(e) => e.preventDefault()}>
|
|
||||||
<DownOutlined />
|
|
||||||
</a>
|
|
||||||
</Dropdown>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
key={`${index}controlnumber`}
|
|
||||||
name={[field.name, "controlnumber"]}
|
|
||||||
rules={[{ required: true }]}
|
|
||||||
>
|
|
||||||
<Input />
|
|
||||||
</Form.Item>
|
|
||||||
|
|
||||||
<Form.Item shouldUpdate>
|
<Col xs={24} sm={12} md={10} lg={7}>
|
||||||
{() => {
|
<Form.Item
|
||||||
const payers = form.getFieldValue("payers");
|
label={
|
||||||
const row = payers?.[index];
|
<div>
|
||||||
const cdkPayer =
|
{t("jobs.fields.dms.payer.controlnumber")}{" "}
|
||||||
bodyshop.cdk_configuration.payers &&
|
<Dropdown
|
||||||
bodyshop.cdk_configuration.payers.find((i) => i && row && i.name === row.name);
|
trigger={["click"]}
|
||||||
if (i18n.exists(`jobs.fields.${cdkPayer?.control_type}`))
|
menu={{
|
||||||
return <div>{cdkPayer && t(`jobs.fields.${cdkPayer?.control_type}`)}</div>;
|
items:
|
||||||
else if (i18n.exists(`jobs.fields.dms.control_type.${cdkPayer?.control_type}`)) {
|
bodyshop.cdk_configuration.controllist?.map((key, idx) => ({
|
||||||
return <div>{cdkPayer && t(`jobs.fields.dms.control_type.${cdkPayer?.control_type}`)}</div>;
|
key: idx,
|
||||||
} else {
|
label: key.name,
|
||||||
return null;
|
onClick: () => {
|
||||||
}
|
form.setFieldsValue({
|
||||||
}}
|
payers: (form.getFieldValue("payers") || []).map((row, mapIndex) => {
|
||||||
</Form.Item>
|
if (index !== mapIndex) return row;
|
||||||
|
return { ...row, controlnumber: key.controlnumber };
|
||||||
|
})
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})) ?? []
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{/* Anchor trigger restored (was missing) */}
|
||||||
|
<a href="#" onClick={(e) => e.preventDefault()}>
|
||||||
|
<DownOutlined />
|
||||||
|
</a>
|
||||||
|
</Dropdown>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
name={[field.name, "controlnumber"]}
|
||||||
|
rules={[{ required: true }]}
|
||||||
|
>
|
||||||
|
<Input />
|
||||||
|
</Form.Item>
|
||||||
|
</Col>
|
||||||
|
|
||||||
<DeleteFilled onClick={() => remove(field.name)} />
|
<Col xs={24}>
|
||||||
</Space>
|
<Form.Item shouldUpdate noStyle>
|
||||||
|
{() => {
|
||||||
|
const payers = form.getFieldValue("payers");
|
||||||
|
const row = payers?.[index];
|
||||||
|
const cdkPayer =
|
||||||
|
bodyshop.cdk_configuration.payers &&
|
||||||
|
bodyshop.cdk_configuration.payers.find((i) => i && row && i.name === row.name);
|
||||||
|
if (i18n.exists(`jobs.fields.${cdkPayer?.control_type}`))
|
||||||
|
return <div>{cdkPayer && t(`jobs.fields.${cdkPayer?.control_type}`)}</div>;
|
||||||
|
else if (i18n.exists(`jobs.fields.dms.control_type.${cdkPayer?.control_type}`)) {
|
||||||
|
return (
|
||||||
|
<div>{cdkPayer && t(`jobs.fields.dms.control_type.${cdkPayer?.control_type}`)}</div>
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
</Form.Item>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
</Card>
|
||||||
|
))}
|
||||||
|
<Form.Item>
|
||||||
|
<Button
|
||||||
|
disabled={!(fields.length < 3)}
|
||||||
|
onClick={() => {
|
||||||
|
if (fields.length < 3) add();
|
||||||
|
}}
|
||||||
|
style={{ width: "100%" }}
|
||||||
|
>
|
||||||
|
{t("jobs.actions.dms.addpayer")}
|
||||||
|
</Button>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
))}
|
</div>
|
||||||
<Form.Item>
|
)}
|
||||||
<Button
|
</Form.List>
|
||||||
disabled={!(fields.length < 3)}
|
</>
|
||||||
onClick={() => {
|
|
||||||
if (fields.length < 3) add();
|
|
||||||
}}
|
|
||||||
style={{ width: "100%" }}
|
|
||||||
>
|
|
||||||
{t("jobs.actions.dms.addpayer")}
|
|
||||||
</Button>
|
|
||||||
</Form.Item>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</Form.List>
|
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{/* Validation gates & summary (unchanged logic) */}
|
||||||
<Form.Item shouldUpdate>
|
<Form.Item shouldUpdate>
|
||||||
{() => {
|
{() => {
|
||||||
// 1) Sum allocated payers
|
// 1) Sum allocated payers
|
||||||
@@ -393,31 +471,31 @@ export function DmsPostForm({ bodyshop, socket, job, logsRef }) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// 2) Subtotal from socket.allocationsSummary (existing behavior)
|
// 2) Subtotal from socket.allocationsSummary (existing behavior)
|
||||||
const totals = socket
|
const totals =
|
||||||
? socket.allocationsSummary &&
|
socket && socket.allocationsSummary
|
||||||
socket.allocationsSummary.reduce(
|
? socket.allocationsSummary.reduce(
|
||||||
(acc, val) => ({
|
(acc, val) => ({
|
||||||
totalSale: acc.totalSale.add(Dinero(val.sale)),
|
totalSale: acc.totalSale.add(Dinero(val.sale)),
|
||||||
totalCost: acc.totalCost.add(Dinero(val.cost))
|
totalCost: acc.totalCost.add(Dinero(val.cost))
|
||||||
}),
|
}),
|
||||||
{ totalSale: Dinero(), totalCost: Dinero() }
|
{ totalSale: Dinero(), totalCost: Dinero() }
|
||||||
)
|
)
|
||||||
: { totalSale: Dinero(), totalCost: Dinero() };
|
: { totalSale: Dinero(), totalCost: Dinero() };
|
||||||
|
|
||||||
const discrep = totals ? totals.totalSale.subtract(totalAllocated) : Dinero();
|
const discrep = totals ? totals.totalSale.subtract(totalAllocated) : Dinero();
|
||||||
|
|
||||||
// 3) New: validation gates
|
// 3) Validation gates
|
||||||
const advisorOk = dms !== "rr" || !!form.getFieldValue("advisorNo");
|
const advisorOk = dms !== "rr" || !!form.getFieldValue("advisorNo");
|
||||||
|
|
||||||
// Require at least one complete payer row
|
// Require at least one complete payer row for non-RR
|
||||||
const payersOk =
|
const payersOk =
|
||||||
dms === "rr" ||
|
dms === "rr" ||
|
||||||
(payers.length > 0 &&
|
(payers.length > 0 &&
|
||||||
payers.every((p) => p?.name && p.dms_acctnumber && (p.amount ?? "") !== "" && p.controlnumber));
|
payers.every((p) => p?.name && p.dms_acctnumber && (p.amount ?? "") !== "" && p.controlnumber));
|
||||||
|
|
||||||
// 4) Disable rules:
|
// 4) Disable rules:
|
||||||
// - For non-RR: keep the original discrepancy rule (must have summary and zero discrepancy)
|
// - For non-RR: must have summary and zero discrepancy
|
||||||
// - For RR: ignore discrepancy rule, but require advisor + payer rows
|
// - For RR: ignore discrepancy rule, but require advisor
|
||||||
const nonRrDiscrepancyGate = dms !== "rr" && (socket.allocationsSummary ? discrep.getAmount() !== 0 : true);
|
const nonRrDiscrepancyGate = dms !== "rr" && (socket.allocationsSummary ? discrep.getAmount() !== 0 : true);
|
||||||
|
|
||||||
const disablePost = !advisorOk || !payersOk || nonRrDiscrepancyGate;
|
const disablePost = !advisorOk || !payersOk || nonRrDiscrepancyGate;
|
||||||
|
|||||||
@@ -1212,6 +1212,7 @@
|
|||||||
},
|
},
|
||||||
"general": {
|
"general": {
|
||||||
"actions": {
|
"actions": {
|
||||||
|
"optional": "Optional",
|
||||||
"add": "Add",
|
"add": "Add",
|
||||||
"autoupdate": "{{app}} will automatically update in {{time}} seconds. Please save all changes.",
|
"autoupdate": "{{app}} will automatically update in {{time}} seconds. Please save all changes.",
|
||||||
"calculate": "Calculate",
|
"calculate": "Calculate",
|
||||||
@@ -1777,6 +1778,8 @@
|
|||||||
"id": "DMS ID",
|
"id": "DMS ID",
|
||||||
"inservicedate": "In Service Date",
|
"inservicedate": "In Service Date",
|
||||||
"journal": "Journal #",
|
"journal": "Journal #",
|
||||||
|
"make_override": "Make Override",
|
||||||
|
"advisor": "Advisor #",
|
||||||
"lines": "Posting Lines",
|
"lines": "Posting Lines",
|
||||||
"name1": "Customer Name",
|
"name1": "Customer Name",
|
||||||
"payer": {
|
"payer": {
|
||||||
@@ -1784,7 +1787,8 @@
|
|||||||
"control_type": "Control Type",
|
"control_type": "Control Type",
|
||||||
"controlnumber": "Control Number",
|
"controlnumber": "Control Number",
|
||||||
"dms_acctnumber": "DMS Account #",
|
"dms_acctnumber": "DMS Account #",
|
||||||
"name": "Payer Name"
|
"name": "Payer Name",
|
||||||
|
"payer_type": "Payer"
|
||||||
},
|
},
|
||||||
"sale": "Sale",
|
"sale": "Sale",
|
||||||
"sale_dms_acctnumber": "Sale DMS Acct #",
|
"sale_dms_acctnumber": "Sale DMS Acct #",
|
||||||
|
|||||||
Reference in New Issue
Block a user