Invoice Validation
Verify invoice authenticity and status directly with Vietnam's Tax Authority (CQT).
Overview
| Feature | Description |
|---|---|
| Service | TVanService.validateInvoice() |
| Data Source | CQT (Tax Authority) |
| Use Case | Verify received invoices |
Use Cases
- Validate supplier invoices before payment
- Verify invoice hasn't been cancelled
- Check invoice replacement status
- Audit compliance verification
Validate Invoice
typescript
import { TVanService } from '@nx-3rd/t-van';
async validateInvoice(invoiceNumber: string, sellerTaxCode: string) {
const result = await this.tvanService.validateInvoice({
invoiceNumber: invoiceNumber,
sellerTaxCode: sellerTaxCode,
invoiceDate: new Date('2024-01-15'),
});
return {
isValid: result.isValid,
invoiceStatus: result.status,
totalAmount: result.totalAmount,
buyerTaxCode: result.buyerTaxCode,
};
}Response Structure
json
{
"isValid": true,
"status": "VALID",
"invoiceNumber": "AA/24E0001234",
"sellerTaxCode": "0123456789",
"sellerName": "Company ABC",
"buyerTaxCode": "9876543210",
"buyerName": "Your Company",
"invoiceDate": "2024-01-15",
"totalAmount": 1100000,
"vatAmount": 100000
}Invoice Status
| Status | Description |
|---|---|
| VALID | Invoice is valid and accepted |
| CANCELLED | Invoice has been cancelled |
| REPLACED | Invoice replaced by another |
| NOT_FOUND | Invoice not found in CQT |
Validation Flow
REST API
http
POST /api/t-van/invoice/validate
Content-Type: application/json
{
"invoiceNumber": "AA/24E0001234",
"sellerTaxCode": "0123456789",
"invoiceDate": "2024-01-15"
}Error Handling
typescript
try {
const result = await this.tvanService.validateInvoice(params);
return result;
} catch (error) {
if (error.code === 'INVOICE_NOT_FOUND') {
return { isValid: false, status: 'NOT_FOUND' };
}
throw error;
}Best Practices
| Practice | Description |
|---|---|
| Validate before payment | Always check before paying supplier |
| Keep validation records | Log all validation results |
| Re-validate periodically | Invoices can be cancelled later |
| Alert on failures | Notify when validation fails |