# WP2 — FE: "Production order issues" tab in the warehouse reports screen

## Goal
Add a new tab/report to the existing warehouse reports screen that lets the storekeeper pick a production order (+ optional date range) and see, per material, how much was issued to it — quantity, unit, planned-vs-issued, إذن-صرف numbers/dates — plus cost columns shown ONLY to users who may see cost. Excel/PDF export like the other reports.

## Exact files (FE repo = /home/moonui2/public_html/moon-erp)
- `src/app/features/inventory-reports/inventory-reports.component.ts` + `.html` (+ `.scss` if needed) — the existing warehouse-reports screen (route `/core/inventory-reports`, perm `inventory.reports.view`). Add a new tab/section "Production order issues" (تقرير المصروف على أمر إنتاج). Follow the SAME tab/pattern the component already uses for its other reports (movement summary, warehouse summary, etc.) — mirror one existing tab for structure, loading state, and export.
- `src/app/core/services/inventory-report.service.ts` — add a method `productionOrderIssues(productionOrderId, from?, to?)` calling `GET {apiUrl}/inventory/reports/production-order-issues?production_order_id=&from=&to=`.
- Need a production-order picker: reuse the existing production-order service/list (search `src/app/core/services/production-order.service.ts` → `list()`/`listAll()`), a `p-select`/autocomplete of orders (order_number + product name).
- i18n: add keys under the appropriate block in `src/assets/i18n/ar.json` + `en.json` (labels: report title, columns — material, issued qty, unit, planned, إذن صرف numbers, date, unit cost, total cost, totals).

## BE contract (WP1 landed, commit 78880d6da — CONFIRMED)
`GET /api/inventory/reports/production-order-issues?production_order_id={id}&from={date}&to={date}` returns:
```json
{ "data": {
  "production_order": { "id", "order_number", "product_name" },
  "materials": [ { "product_id","product_name","product_code","unit_name",
                   "planned_quantity","issued_quantity",
                   "issue_numbers":["ISS-..."],"last_issued_at",
                   "unit_cost","total_cost" } ],   // unit_cost/total_cost present ONLY if can_view_cost
  "totals": { "issued_quantity","total_cost" },     // total_cost only if can_view_cost
  "can_view_cost": true|false
} }
```
- **Cost columns:** show the `unit_cost`/`total_cost` columns (and totals.total_cost) ONLY when `data.can_view_cost === true`. Drive it off the response `can_view_cost` flag (authoritative — the BE already gates it). Optionally also guard with `*appCan="'inventory.reports.production_issue_cost'"` for belt-and-suspenders, but the response flag is the source of truth (a non-holder gets the fields omitted anyway).
- `production_order_id` is required — the report only loads after an order is picked.

## Acceptance
- New "Production order issues" tab visible in the warehouse reports screen (`/core/inventory-reports`).
- Pick a production order (+ optional date range) → table lists each issued material with qty/unit/planned/إذن-صرف numbers/date + totals.
- A user WITH the cost permission sees unit cost + total cost columns; a user WITHOUT it sees the same report with NO cost columns (driven by `can_view_cost`).
- Excel/PDF export works for the tab (reuse the screen's existing export mechanism).
- `ng build` green.

## Tests
Angular has skipTests — gate is `npx ng build --base-href /app/` GREEN. Manual/e2e on /app after deploy.

## Flags
FE only. No BE change. Conventional commit `feat(inventory): ...` on hazemdev2. Do NOT deploy or touch main.

## Self-verify (Codex)
- `npx ng build --base-href /app/` from /home/moonui2/public_html/moon-erp → green (only the pre-existing CommonJS-interop warnings are acceptable; no errors).
- grep that the new tab/service method compile and there are no leftover TODOs.
- Report: commit SHA, the tab name, the service method, the i18n keys added, how cost columns are gated (can_view_cost), ng build result.
