rrScratch3 - Progress Commit
This commit is contained in:
@@ -51,17 +51,20 @@ function normalizeJobAllocations(ack) {
|
||||
* is now done on the backend via buildRogogFromAllocations/buildRolaborFromRogog.
|
||||
* This component just renders the preview from `ack.rogg` / `ack.rolabor`.
|
||||
*/
|
||||
export function RrAllocationsSummary({ socket, bodyshop, jobId, title, onAllocationsChange }) {
|
||||
export function RrAllocationsSummary({ socket, bodyshop, jobId, title, onAllocationsChange, opCode }) {
|
||||
const { t } = useTranslation();
|
||||
const [roggPreview, setRoggPreview] = useState(null);
|
||||
const [rolaborPreview, setRolaborPreview] = useState(null);
|
||||
const [error, setError] = useState(null);
|
||||
|
||||
// Prefer the user-selected OpCode (from DmsContainer), fall back to config default
|
||||
const effectiveOpCode = useMemo(() => opCode || resolveRROpCodeFromBodyshop(bodyshop), [opCode, bodyshop]);
|
||||
|
||||
const fetchAllocations = useCallback(() => {
|
||||
if (!socket || !jobId) return;
|
||||
|
||||
try {
|
||||
socket.emit("rr-calculate-allocations", jobId, (ack) => {
|
||||
socket.emit("rr-calculate-allocations", { jobId, opCode: effectiveOpCode }, (ack) => {
|
||||
if (ack && ack.ok === false) {
|
||||
setRoggPreview(null);
|
||||
setRolaborPreview(null);
|
||||
@@ -101,14 +104,12 @@ export function RrAllocationsSummary({ socket, bodyshop, jobId, title, onAllocat
|
||||
onAllocationsChange([]);
|
||||
}
|
||||
}
|
||||
}, [socket, jobId, t, onAllocationsChange]);
|
||||
}, [socket, jobId, t, onAllocationsChange, effectiveOpCode]);
|
||||
|
||||
useEffect(() => {
|
||||
fetchAllocations();
|
||||
}, [fetchAllocations]);
|
||||
|
||||
const opCode = resolveRROpCodeFromBodyshop(bodyshop);
|
||||
|
||||
const segmentLabelMap = {
|
||||
partsExtras: "Parts/Extras",
|
||||
laborTaxable: "Taxable Labor",
|
||||
@@ -117,8 +118,11 @@ export function RrAllocationsSummary({ socket, bodyshop, jobId, title, onAllocat
|
||||
|
||||
const roggRows = useMemo(() => {
|
||||
if (!roggPreview || !Array.isArray(roggPreview.ops)) return [];
|
||||
|
||||
const rows = [];
|
||||
roggPreview.ops.forEach((op) => {
|
||||
const rowOpCode = opCode || op.opCode;
|
||||
|
||||
(op.lines || []).forEach((line, idx) => {
|
||||
const baseDesc = line.itemDesc;
|
||||
const segmentKind = op.segmentKind;
|
||||
@@ -128,7 +132,7 @@ export function RrAllocationsSummary({ socket, bodyshop, jobId, title, onAllocat
|
||||
|
||||
rows.push({
|
||||
key: `${op.jobNo}-${idx}`,
|
||||
opCode: op.opCode,
|
||||
opCode: rowOpCode,
|
||||
jobNo: op.jobNo,
|
||||
breakOut: line.breakOut,
|
||||
itemType: line.itemType,
|
||||
@@ -145,22 +149,27 @@ export function RrAllocationsSummary({ socket, bodyshop, jobId, title, onAllocat
|
||||
});
|
||||
});
|
||||
return rows;
|
||||
}, [roggPreview]);
|
||||
}, [roggPreview, opCode]);
|
||||
|
||||
const rolaborRows = useMemo(() => {
|
||||
if (!rolaborPreview || !Array.isArray(rolaborPreview.ops)) return [];
|
||||
return rolaborPreview.ops.map((op, idx) => ({
|
||||
key: `${op.jobNo}-${idx}`,
|
||||
opCode: op.opCode,
|
||||
jobNo: op.jobNo,
|
||||
custPayTypeFlag: op.custPayTypeFlag,
|
||||
custTxblNtxblFlag: op.custTxblNtxblFlag,
|
||||
payType: op.bill?.payType,
|
||||
amtType: op.amount?.amtType,
|
||||
custPrice: op.amount?.custPrice,
|
||||
totalAmt: op.amount?.totalAmt
|
||||
}));
|
||||
}, [rolaborPreview]);
|
||||
|
||||
return rolaborPreview.ops.map((op, idx) => {
|
||||
const rowOpCode = opCode || op.opCode;
|
||||
|
||||
return {
|
||||
key: `${op.jobNo}-${idx}`,
|
||||
opCode: rowOpCode,
|
||||
jobNo: op.jobNo,
|
||||
custPayTypeFlag: op.custPayTypeFlag,
|
||||
custTxblNtxblFlag: op.custTxblNtxblFlag,
|
||||
payType: op.bill?.payType,
|
||||
amtType: op.amount?.amtType,
|
||||
custPrice: op.amount?.custPrice,
|
||||
totalAmt: op.amount?.totalAmt
|
||||
};
|
||||
});
|
||||
}, [rolaborPreview, opCode]);
|
||||
|
||||
// Totals for ROGOG (sum custPrice + dlrCost over all lines)
|
||||
const roggTotals = useMemo(() => {
|
||||
@@ -221,9 +230,10 @@ export function RrAllocationsSummary({ socket, bodyshop, jobId, title, onAllocat
|
||||
children: (
|
||||
<>
|
||||
<Typography.Paragraph type="secondary" style={{ marginBottom: 8 }}>
|
||||
OpCode: <strong>{opCode}</strong>. Only centers with RR GOG mapping (rr_gogcode & rr_item_type) are
|
||||
included. Totals below reflect exactly what will be sent in ROGOG.
|
||||
OpCode: <strong>{effectiveOpCode}</strong>. Only centers with RR GOG mapping (rr_gogcode & rr_item_type)
|
||||
are included. Totals below reflect exactly what will be sent in ROGOG.
|
||||
</Typography.Paragraph>
|
||||
|
||||
<Table
|
||||
pagination={false}
|
||||
columns={roggColumns}
|
||||
|
||||
Reference in New Issue
Block a user