From 566b9696f8fe28f7d77fc7283851591de12757ee Mon Sep 17 00:00:00 2001 From: Mattsson <111893710+mattssonn@users.noreply.github.com> Date: Mon, 27 Apr 2026 22:53:52 +0200 Subject: [PATCH] Feat/verification attachments (#371) * feat(attachments): enhance document preview functionality for images and PDFs * feat(reconciliation): enhance transaction matching logic and clarify reconciliation process --- .../bookkeeping/JournalEntryAttachments.tsx | 41 ++++-- lib/ai/feature-flag.ts | 31 +++-- .../__tests__/bank-reconciliation.test.ts | 45 ++++++- lib/reconciliation/bank-reconciliation.ts | 49 +++---- lib/transactions/__tests__/ingest.test.ts | 120 +----------------- lib/transactions/ingest.ts | 56 ++------ 6 files changed, 131 insertions(+), 211 deletions(-) diff --git a/components/bookkeeping/JournalEntryAttachments.tsx b/components/bookkeeping/JournalEntryAttachments.tsx index 34044fe7..2334a848 100644 --- a/components/bookkeeping/JournalEntryAttachments.tsx +++ b/components/bookkeeping/JournalEntryAttachments.tsx @@ -31,13 +31,21 @@ function isImageType(type: string | null): boolean { return type?.startsWith('image/') ?? false } +function isPdfType(type: string | null): boolean { + return type === 'application/pdf' +} + +function isPreviewable(type: string | null): boolean { + return isImageType(type) || isPdfType(type) +} + export default function JournalEntryAttachments({ journalEntryId, onCountChange, }: JournalEntryAttachmentsProps) { const [documents, setDocuments] = useState([]) const [loading, setLoading] = useState(true) - const [expandedImage, setExpandedImage] = useState(null) + const [expandedDoc, setExpandedDoc] = useState(null) const [showUpload, setShowUpload] = useState(false) const [uploadFiles, setUploadFiles] = useState([]) @@ -87,8 +95,8 @@ export default function JournalEntryAttachments({ } const handlePreviewToggle = async (doc: DocumentRecord) => { - if (expandedImage === doc.id) { - setExpandedImage(null) + if (expandedDoc === doc.id) { + setExpandedDoc(null) return } @@ -108,7 +116,7 @@ export default function JournalEntryAttachments({ } } - setExpandedImage(doc.id) + setExpandedDoc(doc.id) } if (loading) { @@ -158,12 +166,12 @@ export default function JournalEntryAttachments({ {documents.map((doc) => (
- {isImageType(doc.mime_type) ? ( + {isPreviewable(doc.mime_type) ? (
{/* Image preview */} - {expandedImage === doc.id && doc.download_url && ( + {expandedDoc === doc.id && doc.download_url && isImageType(doc.mime_type) && (
)} + + {/* PDF preview */} + {expandedDoc === doc.id && doc.download_url && isPdfType(doc.mime_type) && ( +
+