Skip to content

Invoice XML Format

Overview

The legal e-invoice XML (TT78 / Decree 123/2020/ND-CP) is generated, signed and submitted entirely by VNPAY (viiAPI). BANA exchanges JSON only: @nx/invoice builds a JSON issuance request via _buildInvoiceRequest and never produces XML locally (no xml2js, no XML signing, no XSD validation in BANA).

The structure below is the GDT-defined schema the provider emits, kept here as reference for understanding the issued artifact - not something BANA generates.

What @nx/invoice Does

StepFormatOwner
Issuance requestJSON@nx/invoice builds via _buildInvoiceRequest, sends through @nx/iiapi
Legal XML generationXML (TT78 / Decree 123)VNPAY (provider)
XML signing + GDT submissionXMLVNPAY (provider)
Provider responseJSON@nx/invoice persists (invoiceNumber, status)

XML Structure

XML Example

Provider-generated artifact (VNPAY); shown for reference. BANA neither builds nor signs this.

xml
<?xml version="1.0" encoding="UTF-8"?>
<HDon>
  <DLHDon>
    <TTChung>
      <PBan>2.0.0</PBan>              <!-- XML Version -->
      <THDon>Hóa đơn GTGT</THDon>     <!-- Invoice Type Name -->
      <KHMSHDon>1</KHMSHDon>          <!-- Template Code -->
      <KHHDon>C25TAA</KHHDon>         <!-- Template Symbol -->
      <SHDon>00000001</SHDon>         <!-- Invoice Number (provider-allocated) -->
      <NLap>2025-01-20</NLap>         <!-- Issue Date -->
      <DVTTe>VND</DVTTe>              <!-- Currency -->
      <TGia>1</TGia>                  <!-- Exchange Rate -->
      <HTTToan>TM/CK</HTTToan>        <!-- Payment Method -->
    </TTChung>
    <NDHDon>
      <NBan>
        <Ten>Công ty TNHH ABC</Ten>
        <MST>0123456789</MST>
        <DChi>123 Nguyễn Huệ, Q1, TP.HCM</DChi>
      </NBan>
      <NMua>
        <Ten>Khách hàng XYZ</Ten>
        <MST>9876543210</MST>
        <DChi>456 Lê Lợi, Q1, TP.HCM</DChi>
      </NMua>
      <DSHHDVu>
        <HHDVu>
          <TChat>1</TChat>
          <STT>1</STT>
          <THHDVu>Sản phẩm A</THHDVu>
          <DVTinh>Cái</DVTinh>
          <SLuong>2</SLuong>
          <DGia>100000</DGia>
          <ThTien>200000</ThTien>
          <TSuat>10%</TSuat>
        </HHDVu>
      </DSHHDVu>
      <TToan>
        <TgTCThue>200000</TgTCThue>
        <TgTThue>20000</TgTThue>
        <TgTTTBSo>220000</TgTTTBSo>
        <TgTTTBChu>Hai trăm hai mươi nghìn đồng</TgTTTBChu>
      </TToan>
    </NDHDon>
  </DLHDon>
  <DSCKS>
    <NBan>
      <Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
        <!-- Seller's Digital Signature (provider-side) -->
      </Signature>
    </NBan>
  </DSCKS>
</HDon>

Field Reference

GDT-defined schema, generated provider-side. Reference only.

TTChung (General Information)

ElementRequiredDescriptionFormat
PBanYesXML Version"2.0.0"
THDonYesInvoice Type NameText
KHMSHDonYesTemplate Code1-6
KHHDonYesTemplate SymbolMax 6 chars
SHDonYesInvoice Number8 digits
MHSoYesModel NumberPattern: ##GTKT#/###
NLapYesIssue DateYYYY-MM-DD
DVTTeYesCurrencyISO 4217 (VND)
TGiaYesExchange RateDecimal
HTTToanYesPayment MethodTM/CK/TM-CK

NBan (Seller)

ElementRequiredDescription
TenYesCompany Name
MSTYesTax Code (10 or 13 digits)
DChiYesAddress
SDThoaiNoPhone Number
DCTDTuNoEmail
STKNHangNoBank Account
TNHangNoBank Name

NMua (Buyer)

ElementRequiredDescription
TenYesCustomer Name
MSTB2B OnlyTax Code
DChiNoAddress
HVTNMHangNoContact Person

HHDVu (Line Item)

ElementRequiredDescription
TChatYesNature: 1=Goods, 2=Service
STTYesLine Number
MHHDVuNoProduct Code
THHDVuYesProduct Name
DVTinhYesUnit of Measure
SLuongYesQuantity
DGiaYesUnit Price
TLCKhauNoDiscount Percent
STCKhauNoDiscount Amount
ThTienYesLine Total (before VAT)
TSuatYesVAT Rate

TToan (Totals)

ElementRequiredDescription
TgTCThueYesTotal before VAT
TgTThueYesTotal VAT
TgTTTBSoYesGrand Total (number)
TgTTTBChuYesGrand Total (words)

VAT Rates

RateCodeDescription
0%0%Export, tax-free goods
5%5%Essential goods
8%8%Standard rate (temporary reduction)
10%10%Standard rate
KCTKCTNot subject to VAT
KKKNTKKKNTNon-taxable items

Proprietary and Confidential. Unauthorized copying, distribution, or use of this software is strictly prohibited.