# F-072 — Implementer evidence: Active tax rates listed in product edit prices tab

## Problem

`PricingSection.tsx` (admin product edit → pricing tab) had **hardcoded** VAT logic:
- Two constants: `VAT_GENERAL = 1.21` and `VAT_REDUCED = 1.10`
- Dropdown with only two options: "21% gen." and "10% red."
- No support for super-reduced (4%) which exists in `tax_rates` DB table

The database `tax_rates` already had 3 active rates (4%, 10%, 21%), but the frontend only showed 2.

## Changes

### Backend domain
`project/src/modules/pricing/domain/price.ts`:
- Added `'super-reduced'` to `VatRate` type
- Added `'super-reduced': 400` to `VAT_BASIS_POINTS`

### Backend routes
`project/src/modules/pricing/api/pricing.routes.ts`:
- `vatRateSchema` updated from `z.enum(['general', 'reduced'])` to `z.enum(['general', 'reduced', 'super-reduced'])`

### Migration 031
`project/migrations/031_vat_super_reduced.js` (ESM, applied to DB):
- Updated CHECK constraint on `pricing_variant_prices.vat_rate` to include 'super-reduced'
- Updated CHECK constraints on `pricing_price_history.previous_vat_rate` and `new_vat_rate` to include 'super-reduced'

### Admin types
`project/apps/admin/src/types/index.ts`:
- `VariantPrice.vatRate` extended to include `'super-reduced'`

### Admin api-client
`project/apps/admin/src/lib/api-client.ts`:
- `setVariantPrice` parameter type extended to `'general' | 'reduced' | 'super-reduced'`

### PricingSection.tsx
- Imported `taxApi` and `TaxRate` from `@/lib/api-client`
- Added `activeTaxRates` state (`TaxRate[]`)
- Added `useEffect` to fetch active tax rates from `taxApi.list()` and filter `active === true`
- `vatRate` state type extended to include `'super-reduced'`
- Dropdown now maps `activeTaxRates.map(r => ({ key: r.appliesTo, label: r.name + ' (' + r.ratePercent + '%)' }))`
- Fallback: when no active rates loaded, shows original two options
- PVP/gross calculation uses dynamic rate: `Math.round(netCents * (1 + ratePercent / 100))`
- Help text updated to reference "Configuración → Tipos impositivos"

### InventorySection.tsx
- `VariantRow.vatRate` type extended to `'general' | 'reduced' | 'super-reduced'`
- Gross price calculation updated to handle `super-reduced` (1.04 multiplier)
- VAT display in non-edit mode updated to show 4%, 10%, or 21% based on rate
- VAT dropdown in edit mode added "4% (superreducido)" option

## Verification

- `npx tsc --noEmit` — backend exit 0 ✅, admin exit 0 ✅
- `npx eslint` on changed files — exit 0 ✅
- Migration 031 applied to DB ✅
- Backend rebuilt and restarted ✅
- **API test**: `PUT /pricing/variants/:id` with `vatRate: 'super-reduced'` → HTTP 200, response includes `"vatRate":"super-reduced"` ✅
- **API test**: `GET /pricing/variants/:id` returns variant with `vatRate: 'super-reduced'` ✅
- **API test**: `GET /admin/tax-rates` returns all 3 active rates (4%, 10%, 21%) ✅
- `./scripts/verify.sh` — exit 0 ✅

## Files touched

```
project/migrations/031_vat_super_reduced.js                                           (new)
project/src/modules/pricing/domain/price.ts                                           (modified)
project/src/modules/pricing/api/pricing.routes.ts                                      (modified)
project/apps/admin/src/types/index.ts                                                 (modified)
project/apps/admin/src/lib/api-client.ts                                              (modified)
project/apps/admin/src/features/products/components/sections/PricingSection.tsx        (modified)
project/apps/admin/src/features/products/components/sections/InventorySection.tsx        (modified)
work/artifacts/F-072/implementer.md                                                   (this file)
```
