IO-2557 New CC Contract Warnings

Signed-off-by: Allan Carr <allan.carr@thinkimex.com>
This commit is contained in:
Allan Carr
2024-02-20 09:19:30 -08:00
parent 2427c14b7b
commit 83bd485597
6 changed files with 43 additions and 10 deletions

View File

@@ -68,6 +68,30 @@ export default function ContractFormComponent({
<FormDateTimePicker /> <FormDateTimePicker />
</Form.Item> </Form.Item>
)} )}
{create && (
<Form.Item
shouldUpdate={(p, c) => p.scheduledreturn !== c.scheduledreturn}
>
{() => {
const insuranceOver =
selectedCar &&
selectedCar.insuranceexpires &&
moment(selectedCar.insuranceexpires)
.endOf("day")
.isBefore(moment(form.getFieldValue("scheduledreturn")));
if (insuranceOver)
return (
<Space direction="vertical" style={{ color: "tomato" }}>
<span>
<WarningFilled style={{ marginRight: ".3rem" }} />
{t("contracts.labels.insuranceexpired")}
</span>
</Space>
);
return <></>;
}}
</Form.Item>
)}
</LayoutFormRow> </LayoutFormRow>
<LayoutFormRow grow> <LayoutFormRow grow>
<Form.Item <Form.Item
@@ -90,16 +114,17 @@ export default function ContractFormComponent({
> >
{() => { {() => {
const mileageOver = const mileageOver =
selectedCar && selectedCar && selectedCar.nextservicekm
selectedCar.nextservicekm <= form.getFieldValue("kmstart"); ? selectedCar.nextservicekm <= form.getFieldValue("kmstart")
: false;
const dueForService = const dueForService =
selectedCar && selectedCar &&
selectedCar.nextservicedate && selectedCar.nextservicedate &&
moment(selectedCar.nextservicedate).isBefore( moment(selectedCar.nextservicedate)
moment(form.getFieldValue("scheduledreturn")) .endOf("day")
); .isSameOrBefore(
moment(form.getFieldValue("scheduledreturn"))
);
if (mileageOver || dueForService) if (mileageOver || dueForService)
return ( return (
<Space direction="vertical" style={{ color: "tomato" }}> <Space direction="vertical" style={{ color: "tomato" }}>
@@ -117,7 +142,6 @@ export default function ContractFormComponent({
</span> </span>
</Space> </Space>
); );
return <></>; return <></>;
}} }}
</Form.Item> </Form.Item>

View File

@@ -72,7 +72,8 @@ export default function CourtesyCarsList({ loading, courtesycars, refetch }) {
sortOrder: sortOrder:
state.sortedInfo.columnKey === "status" && state.sortedInfo.order, state.sortedInfo.columnKey === "status" && state.sortedInfo.order,
render: (text, record) => { render: (text, record) => {
const { nextservicedate, nextservicekm, mileage } = record; const { nextservicedate, nextservicekm, mileage, insuranceexpires } =
record;
const mileageOver = nextservicekm ? nextservicekm <= mileage : false; const mileageOver = nextservicekm ? nextservicekm <= mileage : false;
@@ -80,10 +81,14 @@ export default function CourtesyCarsList({ loading, courtesycars, refetch }) {
nextservicedate && nextservicedate &&
moment(nextservicedate).endOf("day").isSameOrBefore(moment()); moment(nextservicedate).endOf("day").isSameOrBefore(moment());
const insuranceOver =
insuranceexpires &&
moment(insuranceexpires).endOf("day").isBefore(moment());
return ( return (
<Space> <Space>
{t(record.status)} {t(record.status)}
{(mileageOver || dueForService) && ( {(mileageOver || dueForService || insuranceOver) && (
<Tooltip title={t("contracts.labels.cardueforservice")}> <Tooltip title={t("contracts.labels.cardueforservice")}>
<WarningFilled style={{ color: "tomato" }} /> <WarningFilled style={{ color: "tomato" }} />
</Tooltip> </Tooltip>

View File

@@ -29,6 +29,7 @@ export const QUERY_AVAILABLE_CC = gql`
fleetnumber fleetnumber
fuel fuel
id id
insuranceexpires
make make
mileage mileage
model model

View File

@@ -747,6 +747,7 @@
"driverinformation": "Driver's Information", "driverinformation": "Driver's Information",
"findcontract": "Find Contract", "findcontract": "Find Contract",
"findermodal": "Contract Finder", "findermodal": "Contract Finder",
"insuranceexpired": "The courtesy car insurance expires before the car is expected to return.",
"noteconvertedfrom": "R.O. created from converted Courtesy Car Contract {{agreementnumber}}.", "noteconvertedfrom": "R.O. created from converted Courtesy Car Contract {{agreementnumber}}.",
"populatefromjob": "Populate from Job", "populatefromjob": "Populate from Job",
"rates": "Contract Rates", "rates": "Contract Rates",

View File

@@ -747,6 +747,7 @@
"driverinformation": "", "driverinformation": "",
"findcontract": "", "findcontract": "",
"findermodal": "", "findermodal": "",
"insuranceexpired": "",
"noteconvertedfrom": "", "noteconvertedfrom": "",
"populatefromjob": "", "populatefromjob": "",
"rates": "", "rates": "",

View File

@@ -747,6 +747,7 @@
"driverinformation": "", "driverinformation": "",
"findcontract": "", "findcontract": "",
"findermodal": "", "findermodal": "",
"insuranceexpired": "",
"noteconvertedfrom": "", "noteconvertedfrom": "",
"populatefromjob": "", "populatefromjob": "",
"rates": "", "rates": "",