diff --git a/electron/audit/audit-ipc.js b/electron/audit/audit-ipc.js index 5182ff2..7420d69 100644 --- a/electron/audit/audit-ipc.js +++ b/electron/audit/audit-ipc.js @@ -15,45 +15,60 @@ ipcMain.on(ipcTypes.default.audit.toMain.browseForFile, async (event, { sheetNam }); if (!result.canceled) { try { + var obj = xlsx.parse(result.filePaths[0], { cellDates: true }); store.set("auditFilePath", result.filePaths); - var obj = xlsx.parse(result.filePaths[0], { cellDates: true }); // parses a file - - const detailSheet = obj.find((sheet) => sheet.name === sheetName); - const claimsArray = []; - let foundHeaderRow, foundTotalRow; - detailSheet.data.forEach((line) => { - //Check the first element. If it's claim number, we have our header row. the next one is important. - if (!foundHeaderRow && line[0] === "Claim Number") { - foundHeaderRow = true; - } else if (foundHeaderRow && !foundTotalRow && line[0] && line[0] !== "Grand Total") { - //Add it to the array - const row = { - clm_no: line[0].startsWith("00") ? line[0].slice(2) : line[0], - close_date: line[1], - v_model_yr: line[3], - v_makedesc: line[4], - v_model: line[5], - under20kmiles: line[6], - pan_total: line[7], - paa_total: line[8], - pal_total: line[9], - pam_total: line[10], - eligible_db_price_total: Math.round((line[11] + Number.EPSILON) * 100) / 100, - eligible_act_price_total: Math.round((line[12] + Number.EPSILON) * 100) / 100, - expected_rps_dollars: Math.round((line[15] + Number.EPSILON) * 100) / 100, - actual_rps_dollars: Math.round((line[16] + Number.EPSILON) * 100) / 100 - }; - claimsArray.push(row); - } else { - // foundTotalRow = true; - } + event.sender.send(ipcTypes.default.audit.toRenderer.auditFilePath, { + filePath: result.filePaths[0], + sheets: obj.map((sheet) => sheet.name) }); - - event.sender.send(ipcTypes.default.audit.toRenderer.auditClaimsArray, claimsArray); } catch (error) { - console.log("ot some sort of err", error); + console.log("Got some sort of err", error); log.error("Error when trying to read audit xlsx file", error); - event.sender.send(ipcTypes.default.audit.toRenderer.auditError, error.message); + event.sender.send(ipcTypes.default.audit.toRenderer.auditError, error.meFssage); } } }); + +ipcMain.on(ipcTypes.default.audit.toMain.runAudit, async (event, { sheetName }) => { + try { + const filePaths = store.get("auditFilePath"); + var obj = xlsx.parse(filePaths[0], { cellDates: true }); // parses a file + + const detailSheet = obj.find((sheet) => sheet.name === sheetName); + const claimsArray = []; + let foundHeaderRow, foundTotalRow; + detailSheet.data.forEach((line) => { + //Check the first element. If it's claim number, we have our header row. the next one is important. + if (!foundHeaderRow && line[0] === "Claim Number") { + foundHeaderRow = true; + } else if (foundHeaderRow && !foundTotalRow && line[0] && line[0] !== "Grand Total") { + //Add it to the array + const row = { + clm_no: line[0].startsWith("00") ? line[0].slice(2) : line[0], + close_date: line[1], + v_model_yr: line[3], + v_makedesc: line[4], + v_model: line[5], + under20kmiles: line[6], + pan_total: line[7], + paa_total: line[8], + pal_total: line[9], + pam_total: line[10], + eligible_db_price_total: Math.round((line[11] + Number.EPSILON) * 100) / 100, + eligible_act_price_total: Math.round((line[12] + Number.EPSILON) * 100) / 100, + expected_rps_dollars: Math.round((line[15] + Number.EPSILON) * 100) / 100, + actual_rps_dollars: Math.round((line[16] + Number.EPSILON) * 100) / 100 + }; + claimsArray.push(row); + } else { + // foundTotalRow = true; + } + }); + + event.sender.send(ipcTypes.default.audit.toRenderer.auditClaimsArray, claimsArray); + } catch (error) { + console.log("ot some sort of err", error); + log.error("Error when trying to read audit xlsx file", error); + event.sender.send(ipcTypes.default.audit.toRenderer.auditError, error.message); + } +}); diff --git a/electron/changelog.json b/electron/changelog.json index a2a4778..50b031e 100644 --- a/electron/changelog.json +++ b/electron/changelog.json @@ -146,7 +146,12 @@ }, "1.2.0": { "title": "Release Notes for 1.2.0", - "date": "05/51/2024", + "date": "05/21/2024", "notes": "New Features\n* Introducing Score Card Auditing. Simply select your MPI scorecard and instantly compare it to your RPS score card to find discrepancies. Available in your side bar\n\nImprovements\n* Added additional models to SUV and Van databases for better detection.\n* Only -01 and -99 claims will now be brought into RPS.\n* Under the hood fixes and improvements." + }, + "1.2.1": { + "title": "Release Notes for 1.2.1", + "date": "05/23/2024", + "notes": "Improvements\n* UI improvements for audit functionality." } } diff --git a/package.json b/package.json index 7d7fcfe..b3f4573 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "productName": "ImEX RPS", "author": "ImEX Systems Inc. ", "description": "ImEX RPS", - "version": "1.2.0", + "version": "1.2.1", "main": "electron/main.js", "homepage": "./", "dependencies": { diff --git a/src/components/molecules/reporting-dates/reporting-dates.molecule.jsx b/src/components/molecules/reporting-dates/reporting-dates.molecule.jsx index 48d2bbc..cdaaf9e 100644 --- a/src/components/molecules/reporting-dates/reporting-dates.molecule.jsx +++ b/src/components/molecules/reporting-dates/reporting-dates.molecule.jsx @@ -48,11 +48,6 @@ export function ReportingDatesMolecule({ queryReportingData }) { diff --git a/src/components/organisms/audit-results/audit-results.organism.jsx b/src/components/organisms/audit-results/audit-results.organism.jsx index 1e7c6c1..2644666 100644 --- a/src/components/organisms/audit-results/audit-results.organism.jsx +++ b/src/components/organisms/audit-results/audit-results.organism.jsx @@ -1,4 +1,4 @@ -import { Card, Col, Divider, Space, Table, Tooltip } from "antd"; +import { Card, Col, Divider, Empty, Result, Space, Table, Tooltip } from "antd"; import Dinero from "dinero.js"; import React from "react"; import { connect } from "react-redux"; @@ -28,16 +28,19 @@ export function AuditResultsOrganism({ auditLoading, setSelectedJobId, selectAud title: "Claim No.", sorter: (a, b) => alphaSort(a.clm_no, b.clm_no), dataIndex: "clm_no", - render: (text, record) => ( - setSelectedJobId(record.id)} to={"/"}> - {text} - - ) + render: (text, record) => + record.id ? ( + setSelectedJobId(record.id)} to={"/"}> + {text} + + ) : ( + text + ) }, { key: "close_date", width: "12%", - title: "[RPS] R4P", + title: "[ImEX RPS] R4P", dataIndex: "close_date", defaultSortOrder: "ascend", sorter: (a, b) => dateSort(a.close_date, b.close_date), @@ -59,7 +62,7 @@ export function AuditResultsOrganism({ auditLoading, setSelectedJobId, selectAud { key: "actual_rps", width: "12%", - title: " Actual RPS ", + title: " Actual RPS", dataIndex: ["audit", "jobRpsDollars"], render: (text, record) => record?.jobRpsDollars @@ -74,11 +77,19 @@ export function AuditResultsOrganism({ auditLoading, setSelectedJobId, selectAud width: "12%", title: "Claim No.", sorter: (a, b) => alphaSort(a.rps.clm_no, b.rps.clm_no), - dataIndex: ["rps", "clm_no"] + dataIndex: ["rps", "clm_no"], + render: (text, record) => + record.rps?.id ? ( + setSelectedJobId(record.rps.id)} to={"/"}> + {text} + + ) : ( + text + ) }, { key: "close_date", - title: "[RPS] R4P", + title: "[ImEX RPS] R4P", dataIndex: "close_date", defaultSortOrder: "ascend", sorter: (a, b) => dateSort(a.rps.close_date, b.rps.close_date), @@ -99,11 +110,11 @@ export function AuditResultsOrganism({ auditLoading, setSelectedJobId, selectAud { key: "expected_rps", width: "12%", - title: "Expected RPS (RPS/Audit)", + title: "Expected RPS (ImEX RPS/Audit)", dataIndex: ["audit", "expectedRpsDollars"], render: (text, record) => ( }> - {record.rps.expectedRpsDollars.toFormat()} + {record.rps.expectedRpsDollars.toFormat()} {Dinero({ amount: Math.round(record.audit.expected_rps_dollars * 100) }).toFormat()} @@ -113,11 +124,11 @@ export function AuditResultsOrganism({ auditLoading, setSelectedJobId, selectAud { key: "actual_rps", width: "12%", - title: " Actual RPS (RPS/Audit)", + title: " Actual RPS (ImEX RPS/Audit)", dataIndex: ["audit", "jobRpsDollars"], render: (text, record) => ( }> - {record.rps.jobRpsDollars.toFormat()} + {record.rps.jobRpsDollars.toFormat()} {Dinero({ amount: Math.round(record.audit.actual_rps_dollars * 100) }).toFormat()} @@ -125,27 +136,51 @@ export function AuditResultsOrganism({ auditLoading, setSelectedJobId, selectAud ) } ]; + + if (Object.keys(selectAuditData).length === 0) + return ( + + + No audit has been run yet. Please select a date range and audit file to view results. + } + /> + + + ); + return ( <> - + + }} /> - +
+ }} /> @@ -157,6 +192,9 @@ export function AuditResultsOrganism({ auditLoading, setSelectedJobId, selectAud pagination={false} dataSource={selectAuditData?.expectedMismatch} rowKey="clm_no" + locale={{ + emptyText: + }} /> @@ -168,6 +206,9 @@ export function AuditResultsOrganism({ auditLoading, setSelectedJobId, selectAud pagination={false} dataSource={selectAuditData?.actualMismatch} rowKey="clm_no" + locale={{ + emptyText: + }} /> diff --git a/src/components/pages/audit/audit.page.jsx b/src/components/pages/audit/audit.page.jsx index 4612080..4f4b7fe 100644 --- a/src/components/pages/audit/audit.page.jsx +++ b/src/components/pages/audit/audit.page.jsx @@ -1,6 +1,6 @@ import { PrinterFilled } from "@ant-design/icons"; -import { Alert, Button, Card, Col, DatePicker, Form, Input, Result, Row, Space } from "antd"; -import React, { useRef } from "react"; +import { Alert, Button, Card, Col, DatePicker, Form, Input, Result, Row, Select, Space } from "antd"; +import React, { useEffect, useRef, useState } from "react"; import { connect } from "react-redux"; import { useReactToPrint } from "react-to-print"; import { createStructuredSelector } from "reselect"; @@ -26,13 +26,36 @@ const mapDispatchToProps = (dispatch) => ({ export default connect(mapStateToProps, mapDispatchToProps)(AuditPage); export function AuditPage({ auditError, queryReportingData, bodyshop }) { - const handleBrowseForFile = async ({ sheetName, dateRange }) => { - queryReportingData({ - startDate: dateRange[0] || dayjs("2024-03-01"), - endDate: dateRange[1] || dayjs("2024-03-31") + const [form] = Form.useForm(); + const [sheets, setSheets] = useState([]); + useEffect(() => { + ipcRenderer.on(ipcTypes.audit.toRenderer.auditFilePath, async (event, { filePath, sheets }) => { + setSheets(sheets); + if (sheets.includes("Shop RPS Claim Detail")) { + form.setFieldsValue({ sheetName: "Shop RPS Claim Detail" }); + } + form.setFieldsValue({ filePath }); }); - ipcRenderer.send(ipcTypes.audit.toMain.browseForFile, { sheetName }); + + return () => { + //ipcRenderer.removeListener(ipcTypes.audit.toRenderer.auditFilePath); + }; + }, [form]); + + const handleBrowseForFile = async () => { + const { dateRange } = form.getFieldsValue(); + queryReportingData({ + startDate: dateRange[0], + endDate: dateRange[1] + }); + ipcRenderer.send(ipcTypes.audit.toMain.browseForFile, {}); }; + + const handleRunAudit = async ({ sheetName, dateRange }) => { + console.log("🚀 ~ handleRunAudit ~ sheetName:", sheetName); + ipcRenderer.send(ipcTypes.audit.toMain.runAudit, { sheetName }); + }; + const componentRef = useRef(); const handlePrint = useReactToPrint({ content: () => componentRef.current, @@ -53,7 +76,7 @@ export function AuditPage({ auditError, queryReportingData, bodyshop }) { -
+ + + + + {() => { + const disabled = !form.getFieldsValue().dateRange; + return ( + + ); + }} + + - + {/* */} +