Added fundamentals for v2 rule set intro.
This commit is contained in:
@@ -1,16 +1,15 @@
|
||||
import { WarningOutlined } from "@ant-design/icons";
|
||||
import { useMutation } from "@apollo/client";
|
||||
import { DatePicker, message, Spin } from "antd";
|
||||
import { DatePicker, message, notification, Spin } from "antd";
|
||||
import moment from "moment";
|
||||
import React, { useState } from "react";
|
||||
import { UPDATE_JOB } from "../../../graphql/jobs.queries";
|
||||
import ipcTypes from "../../../ipc.types";
|
||||
import { CalculateVehicleAge } from "../../../ipc/ipc-estimate-utils";
|
||||
import { DateFormat } from "../../../util/constants";
|
||||
import { ChangeOfRuleSet, DateFormat } from "../../../util/constants";
|
||||
const { ipcRenderer } = window;
|
||||
|
||||
export default function CloseDateDisplayMolecule({ job, jobId, close_date }) {
|
||||
const [editMode, setEditMode] = useState(false);
|
||||
const [value, setValue] = useState(moment(close_date));
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [updateJob] = useMutation(UPDATE_JOB);
|
||||
@@ -21,8 +20,17 @@ export default function CloseDateDisplayMolecule({ job, jobId, close_date }) {
|
||||
});
|
||||
setLoading(true);
|
||||
setValue(newDate);
|
||||
console.log("New R4P Date", newDate);
|
||||
//Recalculate vehicle age.
|
||||
const requires_reimport = ChangeOfRuleSet({
|
||||
prevDateMoment: job.close_date ? moment(job.close_date) : moment(),
|
||||
newDateMoment: newDate ? newDate : moment(),
|
||||
});
|
||||
if (requires_reimport) {
|
||||
notification.open({
|
||||
type: "warning",
|
||||
message:
|
||||
"Changing the R4P date has changed the applicable ruleset. Please re-import the job for accurate scoring.",
|
||||
});
|
||||
}
|
||||
|
||||
const result = await updateJob({
|
||||
variables: {
|
||||
@@ -30,6 +38,7 @@ export default function CloseDateDisplayMolecule({ job, jobId, close_date }) {
|
||||
job: {
|
||||
close_date: newDate,
|
||||
v_age: CalculateVehicleAge({ ...job, close_date: newDate }),
|
||||
requires_reimport: job.requires_reimport || requires_reimport,
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -42,23 +51,15 @@ export default function CloseDateDisplayMolecule({ job, jobId, close_date }) {
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
if (editMode)
|
||||
return (
|
||||
<div onBlur={() => setEditMode(false)}>
|
||||
<DatePicker
|
||||
value={value && value.isValid() ? value : null}
|
||||
onChange={handleChange}
|
||||
format='MM/DD/YYYY'
|
||||
/>
|
||||
{loading && <Spin size="small" />}
|
||||
</div>
|
||||
);
|
||||
|
||||
return (
|
||||
<div style={{ cursor: "pointer" }} onClick={() => setEditMode(true)}>
|
||||
{value && value.isValid() ? (
|
||||
value.format(DateFormat)
|
||||
) : (
|
||||
<div>
|
||||
<DatePicker
|
||||
value={value && value.isValid() ? value : null}
|
||||
onChange={handleChange}
|
||||
format={DateFormat}
|
||||
/>
|
||||
{loading && <Spin size="small" />}
|
||||
{value && !value.isValid() && (
|
||||
<div>
|
||||
<span>No date set.</span>
|
||||
<WarningOutlined style={{ marginLeft: ".5rem", color: "orange" }} />
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Descriptions, PageHeader, Skeleton, Tooltip } from "antd";
|
||||
import { Alert, Descriptions, PageHeader, Skeleton, Tooltip } from "antd";
|
||||
import React from "react";
|
||||
import CurrencyFormatterAtom from "../../atoms/currency-formatter/currency-formatter.atom";
|
||||
import ErrorResultAtom from "../../atoms/error-result/error-result.atom";
|
||||
@@ -27,7 +27,21 @@ export default function JobsDetailDescriptionMolecule({ loading, job }) {
|
||||
ghost={false}
|
||||
title={job.clm_no}
|
||||
subTitle={job.ins_co_nm}
|
||||
extra={[<DeleteJobAtom key="delete" jobId={job.id} />]}
|
||||
extra={[
|
||||
job.requires_reimport && (
|
||||
<Tooltip
|
||||
key="reimport"
|
||||
title="There are different rules that apply for claims submitted in different periods. In order to ensure accurate calculation, you must import this job again to determine which parts are eligible for parts autonomy. This happened because the R4P date was changed between these periods."
|
||||
>
|
||||
<Alert
|
||||
type="warning"
|
||||
showIcon
|
||||
message="A change in R4P date changed the applicable rules. Reimport this job for accurate scoring."
|
||||
/>
|
||||
</Tooltip>
|
||||
),
|
||||
<DeleteJobAtom key="delete" jobId={job.id} />,
|
||||
]}
|
||||
>
|
||||
<Descriptions column={{ xxl: 5, xl: 4, lg: 3, md: 3, sm: 2, xs: 1 }}>
|
||||
<Descriptions.Item label="Owner">{`${job.ownr_fn} ${job.ownr_ln}`}</Descriptions.Item>
|
||||
@@ -41,12 +55,6 @@ export default function JobsDetailDescriptionMolecule({ loading, job }) {
|
||||
<JobGroupMolecule jobId={job.id} group={job.group} job={job} />
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="Age">{job.v_age}</Descriptions.Item>
|
||||
<Descriptions.Item label="Loss Date">
|
||||
{job.loss_date
|
||||
? moment(job.loss_date).format(DateFormat)
|
||||
: "No Loss Date"}
|
||||
</Descriptions.Item>
|
||||
|
||||
<Descriptions.Item
|
||||
label={
|
||||
<Tooltip title="This is the date you will submit for payment from MPI. This should always be the latest date in the case of supplements.">
|
||||
@@ -60,7 +68,6 @@ export default function JobsDetailDescriptionMolecule({ loading, job }) {
|
||||
close_date={job.close_date}
|
||||
/>
|
||||
</Descriptions.Item>
|
||||
|
||||
<Descriptions.Item label="Last Updated">
|
||||
<TimeAgoFormatter>{job.updated_at}</TimeAgoFormatter>
|
||||
</Descriptions.Item>
|
||||
@@ -69,6 +76,11 @@ export default function JobsDetailDescriptionMolecule({ loading, job }) {
|
||||
job.joblines.filter((i) => !i.ignore && i.db_ref !== "900511")
|
||||
.length}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="Loss Date">
|
||||
{job.loss_date
|
||||
? moment(job.loss_date).format(DateFormat)
|
||||
: "No Loss Date"}
|
||||
</Descriptions.Item>
|
||||
</Descriptions>
|
||||
</PageHeader>
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { WarningOutlined } from "@ant-design/icons";
|
||||
import { WarningOutlined, CloudUploadOutlined } from "@ant-design/icons";
|
||||
import { List } from "antd";
|
||||
import React from "react";
|
||||
import { connect } from "react-redux";
|
||||
@@ -63,6 +63,12 @@ export function JobsListItemMolecule({
|
||||
style={{ marginLeft: ".5rem", color: "orange" }}
|
||||
/>
|
||||
)}
|
||||
{item.requires_reimport && (
|
||||
<CloudUploadOutlined
|
||||
title="A change in R4P date changed the applicable rules. Import this job again for accurate scoring."
|
||||
style={{ marginLeft: ".5rem", color: "tomato" }}
|
||||
/>
|
||||
)}
|
||||
</strong>
|
||||
<span style={{ fontStyle: "italic" }}>
|
||||
<TimeAgoFormatter>{item.updated_at}</TimeAgoFormatter>
|
||||
|
||||
@@ -34,7 +34,7 @@ export function ReportingDatesMolecule({ queryReportingData }) {
|
||||
rules={[{ type: "array", required: true }]}
|
||||
>
|
||||
<DatePicker.RangePicker
|
||||
format="YYYY-MM-DD"
|
||||
format="MM/DD/YYYY"
|
||||
ranges={{
|
||||
Today: [moment(), moment()],
|
||||
"Last 14 days": [moment().subtract(14, "days"), moment()],
|
||||
@@ -45,6 +45,7 @@ export function ReportingDatesMolecule({ queryReportingData }) {
|
||||
moment().startOf("month").subtract(1, "month"),
|
||||
moment().startOf("month").subtract(1, "month").endOf("month"),
|
||||
],
|
||||
|
||||
"This Month": [
|
||||
moment().startOf("month"),
|
||||
moment().endOf("month"),
|
||||
@@ -64,6 +65,10 @@ export function ReportingDatesMolecule({ queryReportingData }) {
|
||||
.add(1, "quarter")
|
||||
.subtract(1, "day"),
|
||||
],
|
||||
"Last 3 Months": [
|
||||
moment().startOf("month").subtract(3, "month"),
|
||||
moment().startOf("month").subtract(1, "month").endOf("month"),
|
||||
],
|
||||
}}
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { Input, Table } from "antd";
|
||||
import { CloudUploadOutlined } from "@ant-design/icons";
|
||||
import { Alert, Input, Space, Table } from "antd";
|
||||
import moment from "moment";
|
||||
import React, { useState } from "react";
|
||||
import { useMemo } from "react";
|
||||
import { connect } from "react-redux";
|
||||
import { Link } from "react-router-dom";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
@@ -41,7 +43,15 @@ export function ReportingJobsListMolecule({
|
||||
key: "clm_no",
|
||||
render: (text, record) => (
|
||||
<Link onClick={() => setSelectedJobId(record.id)} to={"/"}>
|
||||
{text}
|
||||
<Space>
|
||||
{text}
|
||||
{record.requires_reimport && (
|
||||
<CloudUploadOutlined
|
||||
title="A change in R4P date changed the applicable rules. Import this job again for accurate scoring."
|
||||
style={{ marginLeft: ".5rem", color: "tomato" }}
|
||||
/>
|
||||
)}
|
||||
</Space>
|
||||
</Link>
|
||||
),
|
||||
sorter: (a, b) => alphaSort(a.clm_no, b.clm_no),
|
||||
@@ -146,8 +156,20 @@ export function ReportingJobsListMolecule({
|
||||
)
|
||||
: reportData;
|
||||
|
||||
const ErroredRecords = useMemo(
|
||||
() => reportData.filter((r) => r.requires_reimport).length,
|
||||
[reportData]
|
||||
);
|
||||
|
||||
return (
|
||||
<div>
|
||||
{ErroredRecords > 0 && (
|
||||
<Alert
|
||||
showIcon
|
||||
message={`${ErroredRecords} job(s) may have innacurate data due to R4P and applicable rule changes. Please import them again.`}
|
||||
type="warning"
|
||||
/>
|
||||
)}
|
||||
<Table
|
||||
title={() => (
|
||||
<Input.Search
|
||||
@@ -177,7 +199,9 @@ export function ReportingJobsListMolecule({
|
||||
<Table.Summary.Cell index={0}>
|
||||
<strong>Totals</strong>
|
||||
</Table.Summary.Cell>
|
||||
<Table.Summary.Cell index={1}>{`${data.length} record(s)`}</Table.Summary.Cell>
|
||||
<Table.Summary.Cell
|
||||
index={1}
|
||||
>{`${data.length} record(s)`}</Table.Summary.Cell>
|
||||
<Table.Summary.Cell index={2}></Table.Summary.Cell>
|
||||
<Table.Summary.Cell index={3}></Table.Summary.Cell>
|
||||
<Table.Summary.Cell index={4}></Table.Summary.Cell>
|
||||
|
||||
@@ -60,7 +60,7 @@ export function ReportingTotalsStatsMolecule({ reportingLoading, scoreCard }) {
|
||||
valueStyle={{
|
||||
color: scoreCard.variancePc < 0 ? "tomato" : "seagreen",
|
||||
}}
|
||||
value={(scoreCard.variancePc * 100).toFixed(2)}
|
||||
value={((scoreCard.variancePc || 0) * 100).toFixed(2)}
|
||||
suffix="%"
|
||||
/>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user