[Bug] PDF/CSV export shows i18n translation keys instead of column names (e.g. "expense.field.payment_account" instead of "Payment Account")
## Description
When exporting Expenses to PDF (or CSV), the column headers display raw i18n translation keys instead of the resolved human-readable column names.
**Expected headers:**
`Payment Account | Reference No | Payment Date | Description | Expense Account | Amount | Line Description`
**Actual headers:**
`expense.field.payment_account | expense.field.reference_no | expense.field.payment_date | expense.field.description | expense.field.expense_account | expense.field.amount | expense.field.line_description`
## Root cause
The translation file at `packages/server/dist/i18n/en/expense.json` correctly maps the keys:
```json
{
"field.payment_date": "Payment Date",
"field.payment_account": "Payment Account",
"field.amount": "Amount",
...
}
```
But the export code passes the fully-qualified key (`expense.field.payment_account`) to the i18n resolver, which looks it up as-is. Since the JSON file keys don't include the `expense.` namespace prefix (they're just `field.payment_account`), the lookup fails and the raw key is rendered.
The i18n namespace prefix (`expense.`) needs to be stripped before the lookup, or the resolver needs to be namespace-aware.
## Steps to reproduce
1. Self-hosted Bigcapital (latest Docker images)
2. Create any expense
3. Go to Expenses list
4. Click Export → PDF (or Print)
5. Observe column headers show `expense.field.payment_account` etc.
## Environment
- **Version:** `bigcapitalhq/server:latest` + `bigcapitalhq/webapp:latest` (pulled 2026-04-12)
- **Deploy method:** Docker Compose (`docker-compose.prod.yml`)
- **OS:** Ubuntu 24.04
- **Language setting:** English
- **Gotenberg:** v7 (as specified in the prod compose)
## Screenshots
PDF export shows:
```
expense.field.payment_account expense.field.reference_no expense.field.payment_date expense.field.description expense.field.expense_account expense.field.amount expense.field.line_description Branch
Owners Funds EXP-011 01 Mar 2026 Massive Stocks API... Software & Subscriptions 1,920.00 Massive API annual...
```
Note: the data rows are correct — only the header row is broken.
## Suggested fix
In the expense export service, when resolving column header translations, strip the entity namespace prefix before the i18n lookup. For example:
- Current: `i18n.t('expense.field.payment_account')` → lookup fails → renders raw key
- Fixed: `i18n.t('field.payment_account', { ns: 'expense' })` → resolves to "Payment Account"
Or adjust the i18n resolver to automatically scope lookups by the entity namespace when rendering export templates.
1 条评论