Skip to content

URD: Tax & Invoice

ModuleCORE-10Versionv0.4
StatusIn-progressDate2026-05-30

1. Purpose

Define the user-facing requirements for staying tax-compliant when selling. The module records the merchant's tax identity, applies the correct tax rules to products, and turns a completed payment into a legal Vietnamese electronic invoice that can be delivered to the buyer and submitted to the tax authority — with adjustment, cancellation, and buyer self-service claims along the way.

2. Scope

IncludedExcluded
Seller tax identity (tax code / MST, name, address)Authoritative tax-code registry (tax authority owns it)
Tax-group rule templates applied onto productsTax-rate calculation at sale time (pricing engine)
VN administrative reference data (provinces, wards, units)PDF rendering of the invoice (provider-side)
Merchant invoice profile + encrypted provider credentialsPayment capture (Payment module)
Invoice issuance lifecycle (queued → issued / failed / cancelled)Order lifecycle (Orders module)
Provider integration: VNPAY / VNIS via iiapi + T-VANMultiple providers beyond the current iiapi/T-VAN set
Tax-authority (CQT) submission and status trackingTax declaration / filing automation
Invoice adjustment, replacement, cancellationCross-merchant settlement
Invoice request + buyer self-service claim (QR)
Channel routing + profile sharing across branches
Immutable audit trail for every invoice event

3. Definitions

TermDefinition
Tax identity (MST)The seller's tax registration code, business name, and address printed as the seller on every invoice
Tax groupA reusable rule template that decides which tax applies to which products
Invoice profileA merchant's invoicing setup linking the tax identity to a provider
ProviderThe e-invoice gateway (currently VNPAY / VNIS via iiapi) that issues the legal invoice
Tax authority (CQT)Vietnam's tax authority, reached through the T-VAN network for submission and validation
IssuanceThe act of turning an order into a numbered, legal e-invoice via a provider
Buyer claimA buyer self-serving their own invoice by scanning a receipt QR before a deadline
Audit trailThe immutable record of every state change an invoice goes through

4. Conceptual Model

Conceptual only — full schema lives in the taxation and invoice developer domain models.

5. Functional Requirements

One table per functional area. <AREA> codes match the test-case IDs. Priority = MoSCoW (Must / Should / Could / Won't).

5.1 Tax Identity (TAX)

IDPRequirement
URD-TAX-001MRegister the seller tax identity (MST, business name, address) used on issued invoices
URD-TAX-002MLook up Vietnamese provinces, wards, and administrative units when entering addresses
URD-TAX-003STax code is validated for correct Vietnamese format before it is accepted

5.2 Tax Groups (GRP)

IDPRequirement
URD-GRP-001MDefine a tax-group rule template that classifies which tax applies to which products
URD-GRP-002MApplying a tax group provisions the correct tax onto its matching products
URD-GRP-003MChanging or removing a product reconciles its applied tax automatically
URD-GRP-004SA tax group is only usable when compatible with the merchant's tax method

5.3 Invoice Configuration (CFG)

IDPRequirement
URD-CFG-001MCreate a merchant invoice profile linked to the seller tax identity
URD-CFG-002MConnect a provider (VNPAY / VNIS via iiapi) with credentials stored encrypted
URD-CFG-003MConfigure per invoice type the serial, category, tax method, and issuance policy
URD-CFG-004MRoute each sale channel to the provider config that should issue its invoices
URD-CFG-005MConfigure a retry policy (max retries + delay schedule) for failed issuance
URD-CFG-006SShare an invoice profile across branches (private / all-branches / whitelist)
URD-CFG-007SGuided onboarding wizard for step-by-step provider setup

5.4 Invoice Lifecycle (INV)

IDPRequirement
URD-INV-001MQueue an invoice for issuance automatically on a successful payment
URD-INV-002MIssue the invoice via the provider and capture its number + tax-authority code
URD-INV-003MTrack invoice status (pending → processing → success / failed / cancelled)
URD-INV-004MRetry a failed issuance per the configured policy
URD-INV-005MSubmit the issued invoice to the tax authority (CQT via T-VAN) when enabled, and track its status
URD-INV-006MRecord an immutable audit trail entry for every invoice event
URD-INV-007MAdjust an issued invoice (correction linked to the original)
URD-INV-008MReplace or cancel an issued invoice with a reason
URD-INV-009SProcess inbound provider webhooks with signature validation to update status

5.5 Invoice Request & Buyer Claim (REQ)

IDPRequirement
URD-REQ-001MCapture buyer info (name, tax code, address, email) for an invoice
URD-REQ-002MDirect flow: cashier collects buyer info and issues the invoice
URD-REQ-003SBuyer self-service: receipt QR with a claim token and deadline
URD-REQ-004SClaim lifecycle: pending → claimed / expired
URD-REQ-005SDeliver the invoice / claim link by receipt QR, email, or SMS

5.6 Issuance Modes (MOD)

IDPRequirement
URD-MOD-001MReal-time: issue immediately on payment
URD-MOD-002SManual: cashier-initiated issuance at the counter
URD-MOD-003SScheduled: batch issuance by a scheduled job
URD-MOD-004SBuyer self-service: buyer claims and issues via QR

6. Acceptance Criteria

AC-INV-01: Issue on payment
GivenWhenThen
A successful payment for an orderThe payment-success event is receivedAn invoice is queued for issuance
The provider acceptsIssuance completesInvoice number + tax-authority code are recorded; status is success
The provider rejectsIssuance failsA retry is scheduled per policy
Max retries exceededLast retry failsStatus is failed; the failure is recorded in the audit trail
AC-INV-02: Buyer self-service claim
GivenWhenThen
A receipt with a valid claim QRBuyer opens the link before the deadlineBuyer can submit their info
Buyer submits infoSubmission succeedsThe invoice is issued with the buyer details
The deadline has passedBuyer opens the linkThe claim is expired and no invoice is issued
AC-INV-03: Tax-authority submission
GivenWhenThen
Tax-authority submission is enabledAn invoice is issuedThe invoice is submitted to CQT via T-VAN
CQT acceptsThe response returnsThe invoice status is updated to accepted
CQT rejectsThe response returnsThe status records the rejection reason
AC-GRP-01: Tax-group provisioning
GivenWhenThen
A tax group matching a productThe product is created or updatedThe correct tax is applied onto that product
A product is removedThe change is processedIts applied tax is reconciled / removed

7. Constraints & Non-Goals

Constraints

IDConstraint
C-01One active invoice profile per merchant
C-02One active config mapping per sale channel
C-03Provider credentials are stored encrypted
C-04The invoice audit trail is immutable
C-05A claim token is unique and bound to a single invoice request
C-06All records use soft-delete; nothing is physically removed

Non-Goals

  • Multiple invoice providers beyond the current iiapi / T-VAN set
  • PDF rendering of the invoice (produced provider-side)
  • Tax-rate calculation at sale time (owned by the pricing engine)
  • Tax declaration / filing automation

8. Version History

DateAuthorDescriptionVer
2026-02-26P. Do — Product OwnerInitial user storiesv0.1
2026-02-27QECode-level assessment, requirement adjustmentsv0.2
2026-04-16P. Do — Product OwnerVNPAY IIAPI + T-VAN + buyer-claim modelv0.3
2026-05-30MigrationRestructured to module-docs convention; AREA codes realigned to taxation + invoice buildv0.4

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