Fix AI mime-type and enable invoice actions

This commit is contained in:
Hamza-Ayed
2026-04-18 02:17:56 +03:00
parent 9f5b202bb2
commit 066df077b1
2 changed files with 32 additions and 6 deletions

View File

@@ -67,12 +67,19 @@ export class GeminiExtractorService {
Pay close attention to Jordanian Tax Rules (subtotal - discount + tax = grand_total).
`;
// Detect MIME type based on extension
const ext = path.extname(filePath).toLowerCase();
let mimeType = 'image/jpeg';
if (ext === '.pdf') mimeType = 'application/pdf';
else if (ext === '.png') mimeType = 'image/png';
else if (ext === '.webp') mimeType = 'image/webp';
const result = await this.model.generateContent([
prompt,
{
inlineData: {
data: fileData.toString('base64'),
mimeType: 'image/jpeg', // Adjusted based on file extension in prod
mimeType: mimeType,
},
},
]);