Debug: two invoices on charge 01a1ea63-391b… were classified as OTHER instead of INVOICE

Open
#5,038 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
typescript
Domain
backend

Research direction

Start by checking accounter_schema.documents for both IDs and tracing the stored files and charge through Deel sync, OCR, manual edits, and Green Invoice sync. Read packages/server/src/modules/deel/helpers/deel.helper.ts and packages/server/src/modules/app-providers/anthropic.ts; identify which path assigned OTHER, then add a regression test for that cause. Done means both records are INVOICE with the correct creditor and debtor, the charge ledger is regenerated, and the fix is merged.

Written by the indexing model from the issue text.

Description

Summary

Two documents on charge 01a1ea63-391b-79dc-9be9-be1d04d7bb72 were saved with type = OTHER ("Other document"). They are invoices and should have been INVOICE.

Document ID Charge ID
01a1ea63-a06d-757e-aac7-ee24279b91c0 01a1ea63-391b-79dc-9be9-be1d04d7bb72
01a1ea63-5a60-7e9c-8a62-097e88150092 01a1ea63-391b-79dc-9be9-be1d04d7bb72

Because the type is OTHER, both documents have no creditor or debtor (figureOutSides returns {} for OTHER). They are also left out of VAT, ledger and match scoring as accounting documents.

Steps

  1. Find which path created the documents. Check accounter_schema.documents for both IDs: file/image URLs, file_hash, creation time, and whether a Deel or Green Invoice record is linked to them. Also check whether the charge has an email-ingestion record.
  2. Check the path's type logic. These are the places in packages/server that can set OTHER:
    • Deel sync: src/modules/deel/helpers/deel.helper.ts, around line 198. It sets DocumentType.Other whenever match.breakdown_contract_type === 'prepaid_billing'. If these are Deel invoices, this is the most likely cause. Confirm whether that rule is right for these invoices.
    • OCR (upload, email ingestion, re-OCR): src/modules/app-providers/anthropic.ts → extractInvoiceDetails. The model picks type from z.enum(DocumentType), so it may have returned OTHER itself. Re-run OCR on the stored files and look at the raw type returned. Then check whether the prompt needs guidance on when to use OTHER versus INVOICE.
    • Manual edits: check whether the type was changed after insert (e.g. by updateDocument).
    • Green Invoice sync: src/modules/green-invoice/helpers/green-invoice.helper.ts maps unknown types to UNPROCESSED, not OTHER, so this path is unlikely. Rule it out anyway.
  3. Fix the cause and add a regression test. Correct the two existing documents' types afterwards (with creditor and debtor) and regenerate the charge's ledger.

Acceptance criteria

  • We know which path set OTHER and why
  • The fix is merged, with a test covering this case
  • Both documents are INVOICE, with correct creditor and debtor
Dominant language
TypeScript
Stars
30
Forks
10
Avg merge
2d 12h
Merged PRs (30d)
276

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Urigo/accounter-fullstack

All issues in Urigo/accounter-fullstack

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.