diff --git a/src/lib/prisma.ts b/src/lib/prisma.ts index d2e2eaff..90b959e9 100644 --- a/src/lib/prisma.ts +++ b/src/lib/prisma.ts @@ -69,7 +69,11 @@ export async function upsertScope1( export async function upsertScope2( emissions: Emissions, - scope2: OptionalNullable> | null, + scope2: { + lb?: number | null + mb?: number | null + unknown?: number | null + } | null, metadata: Metadata ) { if (scope2 === null) { diff --git a/src/routes/updateCompanies.ts b/src/routes/updateCompanies.ts index 3a30d27b..2a83eed4 100644 --- a/src/routes/updateCompanies.ts +++ b/src/routes/updateCompanies.ts @@ -329,13 +329,19 @@ export const emissionsSchema = z .object({ mb: z .number({ description: 'Market-based scope 2 emissions' }) - .optional(), + .optional() + .nullable() + .describe('Sending null means deleting mb scope 2 emissions'), lb: z .number({ description: 'Location-based scope 2 emissions' }) - .optional(), + .optional() + .nullable() + .describe('Sending null means deleting lb scope 2 emissions'), unknown: z .number({ description: 'Unspecified Scope 2 emissions' }) - .optional(), + .optional() + .nullable() + .describe('Sending null means deleting unknown scope 2 emissions'), }) .refine( ({ mb, lb, unknown }) =>