Tiếng Việt

Tools / OL-01 / InvoiceXtract

InvoiceXtract

Reads a whole folder of Vietnamese VAT e-invoices and writes them into one Excel file. Any invoice where something doesn't add up is listed separately, with the reason.

01 · The problem

Retyping invoices, one line at a time.

In Vietnam, VAT invoices are issued electronically, as PDF and XML files. Every period an accountant receives a stack of them from different suppliers, and each issuing platform uses its own layout. Getting them into Excel usually means opening each file and retyping the invoice series, number, date, tax code and then every line item.

It's slow, and these are the figures that go into the tax return. One mistyped digit throws off the totals, and finding it again takes about as long as the data entry did.

02 · What it does

Read, cross-check, then write.

  1. Scans a folder, including subfolders, and reads every invoice PDF and XML file in it.
  2. Reads the item table by the actual column headers printed on the invoice rather than fixed positions, so it copes with layouts from different issuers.
  3. When an invoice exists as both PDF and XML, the figures come from the XML, which is the legal original. The PDF becomes an independent cross-check: if the two disagree, the invoice is flagged.
  4. Checks the arithmetic on every line and every invoice: quantity times unit price, tax amounts, subtotals, and the grand total against the amount written out in words on the invoice. A difference of more than 1 dong gets flagged.
  5. Checks that tax codes have 10 or 13 digits and that invoice dates are valid and not in the future.
  6. Runs entirely on your own computer. No internet connection needed, and invoices never leave the machine.

03 · Input and output

A folder in, one Excel file out.

Input

A folder of invoices

  • PDF files with a text layer, as downloaded from the issuer's portal (not scans).
  • The invoices' XML files.
  • Or a mix of both. Other file types are skipped.
Output

One Excel file, three sheets

  • HoaDon (invoices): one row per invoice.
  • ChiTiet (line items): one row per line item.
  • CanKiemTra (to check): invoices that need a second look, with the reason.

Amounts are stored as numbers, dates as dates, and tax codes keep their leading zeros. A log.txt file records any per-file errors.

04 · Current limits

What it can't do yet.

Worth knowing before you use it.

  1. It doesn't read image-only PDFs, such as invoices that were printed and scanned. Those go into the CanKiemTra sheet, with the lookup code when it can be read, so you can download the original XML from the issuer's lookup page. I left OCR out on purpose because of the risk of misreading digits.
  2. The XML reader follows the structure defined in Decree 123/2020 and Circular 78, but so far it has only been tested against sample files, not against real XML from many issuers. With a new issuer, check the first few invoices carefully.
  3. Some issuers' PDF layouts aren't supported yet. Those invoices are written to CanKiemTra and log.txt; they are not silently dropped.
  4. Windows only.
  5. It doesn't log in to the tax authority's e-invoice portal or get past captchas. Downloading the invoices is still up to you.

05 · Screenshots

What the output looks like

Figure 1 · Replace with a screenshot of fake data
Screenshots will use made-up invoices and figures, never client data.

06 · Contact

Want to try it on your invoices?

Send me an email. It helps to mention which e-invoice issuers you usually receive from and roughly how many invoices you handle each period.