# WP6 — Print the stock card's movements

**Repo:** FE (`/home/moonui2/public_html/moon-erp`) · **Branch:** `hazemdev2` · **Depends on WP4** · **BE change:** none

## Goal

> «الحركات يمكن طباعتها»

The stock card has **no print capability of any kind** today — no `window.print()`, no `@media print`,
no export, no print button. Add one.

## Settled decision — the report pattern, not the document pattern

The app has three printing mechanisms. Use the **second**:

| Pattern | Where it's used | Use it here? |
|---|---|---|
| `PrintService` + templates (`src/app/shared/print/`) | ~30 **document** screens (invoices, issues, vouchers) | ❌ built for templated documents with logo/totals blocks; a stock card is a report |
| ✅ **`window.print()` + a `@media print` block in the component SCSS** | customer-statements · supplier-statements · cash-movement · production BMR · consignment return slip | ✅ **this one** — the house pattern for every statement/report screen |
| `ExportService` (Excel/PDF) | inventory reports, `app-data-table` | ❌ owner decision §9 Q3: print only in this run |

**Read these two before writing anything** and follow their shape:
- `src/app/features/sales/customer-statements/customer-statements.component.ts:325` (`printStatement()`)
  with `customer-statements.component.scss:219-236` — hides the filter bar, sets `break-inside: avoid`
  and `print-color-adjust: exact`.
- `src/app/features/production/consignment/consignment.component.ts:892` with
  `consignment.component.scss:479-497` — the most recent inventory-adjacent example, using the
  `body * { visibility: hidden }` + `.x-print, .x-print * { visibility: visible }` isolation trick.

## ⚠️ The two traps that make a naive print wrong

1. **The card opens on the CURRENT WEEK by default** (`stock-card.component.ts:178-184`), not on all
   history. A user who prints without noticing gets one week and believes it is everything.
   **The printed header must state the period, the warehouse and the item explicitly.**
2. **The movements table is client-paginated at 25 rows** (`html:408`). A naive `window.print()`
   prints only the visible page. **The print must cover every loaded entry**, not the current page.
   (The data is already all in memory — `getStockCardFilteredAll()` auto-paginates at `per_page=50`
   across all pages, `stock-balance.service.ts:183`.)

## What to build

1. A print button in the card's header bar (`html:10-23` currently holds only a back button and the
   item identity).
2. A print stylesheet that hides the chrome — filter bar, back button, action buttons, navigation —
   and prints the movements table full-length.
3. A **printed header**: item name + code, the **date range**, the **warehouse** filter in effect, and
   the opening balance if the screen already knows it.
4. A **printed footer/summary**: total in, total out, closing balance.
5. The printed table must include the **«المصدر المباشر» column from WP4** — knowing which production
   order consumed the material is the whole reason the owner asked for both features. Read WP4's
   report/commit first so the column renders identically on paper.
6. RTL-correct. The existing report print blocks handle this — follow them, don't invent.

## Acceptance criteria

1. Printing on a range with **more than 25 movements** prints **all** of them, not 25.
2. The printed header states the item, the date range and the warehouse — so a printout can never be
   mistaken for "all history" when it is one week.
3. Filters, buttons and navigation do not appear on paper.
4. The direct-source column appears and is readable (a printed link shows its **text**, not a URL).
5. Totals in/out and the closing balance appear.
6. RTL layout correct in the print preview.
7. Nothing about the on-screen rendering changes.
8. `npx ng build --base-href /app/` green; `npx tsc --noEmit` no new errors.

## Environment / rules

- ⛔ **NEVER** `git checkout` / `restore` / `stash` on `src/assets/i18n/ar.json` or `en.json`.
  Additive edits only; a new key goes in BOTH files.
- Builds are pre-authorized. **Do NOT deploy to `/app`** — the orchestrator deploys.
- `chown moonui2:moonui2` every edited file. Commit on `hazemdev2`, conventional. **No push, no merge.**
- moonui2 ONLY — never `/home/moonui`. Never print a git remote URL.
- You cannot open a browser. Verify by reading the markup/CSS and by matching the reference
  implementations. **Say plainly in your report that the print output was not visually verified** —
  the orchestrator flags it for the owner's pass.

## Out of scope

Excel/PDF export (owner decision §9 Q3 — print only in this run) · a server-side print endpoint (none
exists for inventory) · the stock-balances screen · any backend change.
