diff --git a/client/src/components/jobs-close-lines/jobs-close-lines.component.jsx b/client/src/components/jobs-close-lines/jobs-close-lines.component.jsx index f1a1bf3f2..e6bdc5321 100644 --- a/client/src/components/jobs-close-lines/jobs-close-lines.component.jsx +++ b/client/src/components/jobs-close-lines/jobs-close-lines.component.jsx @@ -42,6 +42,10 @@ export function JobsCloseLines({ bodyshop, job, jobRO }) { {fields.map((field, index) => ( + {/* Hidden field to preserve jobline ID */} + { setLoading(true); + + // Validate that all joblines have valid IDs + const joblinesWithIds = values.joblines.filter(jl => jl && jl.id); + if (joblinesWithIds.length !== values.joblines.length) { + notification.error({ + title: t("jobs.errors.invalidjoblines"), + message: t("jobs.errors.missingjoblineids") + }); + setLoading(false); + return; + } + const result = await client.mutate({ mutation: generateJobLinesUpdatesForInvoicing(values.joblines) }); if (result.errors) { + setLoading(false); return; // Abandon the rest of the close. } diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json index d1f215e60..c95876666 100644 --- a/client/src/translations/en_us/common.json +++ b/client/src/translations/en_us/common.json @@ -1676,7 +1676,9 @@ "deleted": "Error deleting Job. {{error}}", "exporting": "Error exporting Job. {{error}}", "exporting-partner": "Unable to connect to partner application. Please ensure it is running and logged in.", + "invalidjoblines": "Job has invalid job lines.", "invoicing": "Error invoicing Job. {{error}}", + "missingjoblineids": "Missing job line IDs for job lines.", "noaccess": "This Job does not exist or you do not have access to it.", "nodamage": "No damage points on estimate.", "nodates": "No dates specified for this Job.", diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json index 1b9c1f08d..70cd2b5da 100644 --- a/client/src/translations/es/common.json +++ b/client/src/translations/es/common.json @@ -1674,7 +1674,9 @@ "deleted": "Error al eliminar el trabajo.", "exporting": "", "exporting-partner": "", + "invalidjoblines": "", "invoicing": "", + "missingjoblineids": "", "noaccess": "Este trabajo no existe o no tiene acceso a él.", "nodamage": "", "nodates": "No hay fechas especificadas para este trabajo.", diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json index 490063ba1..e199a33b2 100644 --- a/client/src/translations/fr/common.json +++ b/client/src/translations/fr/common.json @@ -1674,7 +1674,9 @@ "deleted": "Erreur lors de la suppression du travail.", "exporting": "", "exporting-partner": "", + "invalidjoblines": "", "invoicing": "", + "missingjoblineids": "", "noaccess": "Ce travail n'existe pas ou vous n'y avez pas accès.", "nodamage": "", "nodates": "Aucune date spécifiée pour ce travail.",