Skip to content

Faktura-scan behavior

Documented against app commit ed7d6935. The same text lives in docs/agent/faktura-scan.md in the app repo.

Pulls invoice PDFs into the inbox, classifies them, and creates bogføringer from the rows a user has reviewed. The posting those rows become is docs/agent/transactions.md. The inbox after that is docs/agent/faktura-indbakke.md.

Middleware: auth.check, module:bogforing, account, year.

The scheduler entries for imap:fetch-invoices and invoices:scan are commented out in app/Console/Kernel.php. Nothing runs every fifteen minutes. Fetch and classify happen only when someone uses these pages. Company IMAP and Gmail settings are docs/agent/admin.md.

PathViewWhat it is
GET /bogforings/faktura-scanresources/views/pages/invoicescan/page1.blade.phpFetch from the mailbox and classify new PDFs.
GET /bogforings/faktura-scan/reviewresources/views/pages/invoicescan/page2.blade.phpReview classified documents, fix the supplier and modkonto, and create bilag.

Page 1 regions: fetch, the list of new files, skip, and classify. Page 2 regions: the PDF preview, supplier match, modkonto, asset order, archive rows, and create.

All of these are InvoiceScanController.

CallMethodWrites
POST /bogforings/faktura-scan/fetchfetchReads the company mailbox and stores new PDFs as invoice_imgs for this account. Does not create a bogføring.
POST /bogforings/faktura-scan/classifyclassifySends selected images to the invoice extraction provider and stores the parsed fields on the image.
POST /bogforings/faktura-scan/skip/{id}skipMarks an image skipped so fetch will not offer it again.
POST /bogforings/faktura-scan/skip-doc/{id}skipDocAISkips extraction for one document.
POST /bogforings/faktura-scan/process-oneprocessOneRuns extraction for a single image.
POST /bogforings/faktura-scan/process-archive-oneprocessArchiveOneSame for an archive row.
POST /bogforings/faktura-scan/rotate-pdfrotatePdfRewrites the stored PDF.
POST /bogforings/faktura-scan/create-suppliercreateSupplierInserts a leverandør from the review form.
POST /bogforings/faktura-scan/update-supplier-modkontoupdateSupplierModkontoSaves the default modkonto number on that leverandør.
POST /bogforings/faktura-scan/assign-assetassignAssetAttaches a page asset to a document.
POST /bogforings/faktura-scan/reorder-assetsreorderAssetsStores the page order.
POST /bogforings/faktura-scan/merge-assetsmergeAssetsMerges assets into one document.
POST /bogforings/faktura-scan/createcreateInvoicesCreates bogføringer from reviewed rows, and stores archive metadata from archive_rows.

createInvoices resolves the leverandør, takes account_id from the image path, and resolves the modkonto number to the kontoplan row for the invoice date’s year. It then creates the header and lines through the same services as a manual bilag (BogforingService::store and BogforingTransactionService::store), with invoice_img_id set. An empty payload returns 422 Ingen rækker at gemme. A failed row is reported and the others continue.

Do not document ProductSubsController or the old invoice controllers here. They are not on this path.