diff --git a/client/src/components/contract-form/contract-form.component.jsx b/client/src/components/contract-form/contract-form.component.jsx
index f41933625..6f0125803 100644
--- a/client/src/components/contract-form/contract-form.component.jsx
+++ b/client/src/components/contract-form/contract-form.component.jsx
@@ -68,6 +68,30 @@ export default function ContractFormComponent({
)}
+ {create && (
+
p.scheduledreturn !== c.scheduledreturn}
+ >
+ {() => {
+ const insuranceOver =
+ selectedCar &&
+ selectedCar.insuranceexpires &&
+ moment(selectedCar.insuranceexpires)
+ .endOf("day")
+ .isBefore(moment(form.getFieldValue("scheduledreturn")));
+ if (insuranceOver)
+ return (
+
+
+
+ {t("contracts.labels.insuranceexpired")}
+
+
+ );
+ return <>>;
+ }}
+
+ )}
{() => {
const mileageOver =
- selectedCar &&
- selectedCar.nextservicekm <= form.getFieldValue("kmstart");
-
+ selectedCar && selectedCar.nextservicekm
+ ? selectedCar.nextservicekm <= form.getFieldValue("kmstart")
+ : false;
const dueForService =
selectedCar &&
selectedCar.nextservicedate &&
- moment(selectedCar.nextservicedate).isBefore(
- moment(form.getFieldValue("scheduledreturn"))
- );
-
+ moment(selectedCar.nextservicedate)
+ .endOf("day")
+ .isSameOrBefore(
+ moment(form.getFieldValue("scheduledreturn"))
+ );
if (mileageOver || dueForService)
return (
@@ -117,7 +142,6 @@ export default function ContractFormComponent({
);
-
return <>>;
}}
diff --git a/client/src/components/courtesy-cars-list/courtesy-cars-list.component.jsx b/client/src/components/courtesy-cars-list/courtesy-cars-list.component.jsx
index 2c992990c..e81a71e3e 100644
--- a/client/src/components/courtesy-cars-list/courtesy-cars-list.component.jsx
+++ b/client/src/components/courtesy-cars-list/courtesy-cars-list.component.jsx
@@ -72,7 +72,8 @@ export default function CourtesyCarsList({ loading, courtesycars, refetch }) {
sortOrder:
state.sortedInfo.columnKey === "status" && state.sortedInfo.order,
render: (text, record) => {
- const { nextservicedate, nextservicekm, mileage } = record;
+ const { nextservicedate, nextservicekm, mileage, insuranceexpires } =
+ record;
const mileageOver = nextservicekm ? nextservicekm <= mileage : false;
@@ -80,11 +81,25 @@ export default function CourtesyCarsList({ loading, courtesycars, refetch }) {
nextservicedate &&
moment(nextservicedate).endOf("day").isSameOrBefore(moment());
+ const insuranceOver =
+ insuranceexpires &&
+ moment(insuranceexpires).endOf("day").isBefore(moment());
+
return (
{t(record.status)}
- {(mileageOver || dueForService) && (
-
+ {(mileageOver || dueForService || insuranceOver) && (
+
)}
diff --git a/client/src/graphql/courtesy-car.queries.js b/client/src/graphql/courtesy-car.queries.js
index 4f7bcd0ca..2012e952e 100644
--- a/client/src/graphql/courtesy-car.queries.js
+++ b/client/src/graphql/courtesy-car.queries.js
@@ -29,6 +29,7 @@ export const QUERY_AVAILABLE_CC = gql`
fleetnumber
fuel
id
+ insuranceexpires
make
mileage
model
diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json
index 77cdb8091..76737f090 100644
--- a/client/src/translations/en_us/common.json
+++ b/client/src/translations/en_us/common.json
@@ -747,6 +747,7 @@
"driverinformation": "Driver's Information",
"findcontract": "Find Contract",
"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}}.",
"populatefromjob": "Populate from Job",
"rates": "Contract Rates",
diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json
index 341f86fd7..7527ab6ce 100644
--- a/client/src/translations/es/common.json
+++ b/client/src/translations/es/common.json
@@ -747,6 +747,7 @@
"driverinformation": "",
"findcontract": "",
"findermodal": "",
+ "insuranceexpired": "",
"noteconvertedfrom": "",
"populatefromjob": "",
"rates": "",
diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json
index 7cdabf620..dbb74ea69 100644
--- a/client/src/translations/fr/common.json
+++ b/client/src/translations/fr/common.json
@@ -747,6 +747,7 @@
"driverinformation": "",
"findcontract": "",
"findermodal": "",
+ "insuranceexpired": "",
"noteconvertedfrom": "",
"populatefromjob": "",
"rates": "",