# Two owner tasks — 2026-08-08

Owner, verbatim: «عيزين اضافه الطباعه في اذن الاضافه زي الصرف. كمان ضيف في اذن الصرف عمود جديد فيه
اسمه عميل التول لاذن الصرف ويظهر الوسم التشغيلي او امر الانتاج الي مصروف عليها ان وجد».

Repos: BE `/home/moonui2/moon-erp-be` · FE `/home/moonui2/public_html/moon-erp` · branch `hazemdev2`.

---

## Established by the orchestrator before dispatch — do NOT re-derive

**Task 1 — printing the stock receipt.** The stock **issue** already prints:
`stock-issues.component.ts` injects `PrintService`, imports `STOCK_ISSUE_PRINT_CONFIG` from
`stock-issues/stock-issue-print.config.ts` (128 lines), fetches the full document and calls
`printService.print(CONFIG, res.data, this.companyInfo())` in `printStockIssue()` (~line 1279).
It also seeds `companyInfo` via `printService.getCompanyWithLogo()` (~line 221).

`stock-receipts.component.ts` has **zero** occurrences of "print". So the receipt has no printing at
all, and the issue's config is the template to mirror.

**Task 2 — what is already there, and what is genuinely missing.**

| Piece | Status |
|---|---|
| Production order / job tag on the issue **list** | ✅ already shown — `stock-issues.component.html:21` renders `reference_type_label` + `reference_number` |
| …on the issue **detail dialog** | ✅ already shown — same file, ~line 683 |
| …on the **printout** | ✅ already shown — `stock-issue-print.config.ts:47-58` |
| …exposed by the API | ✅ `InventoryIssueResource` emits `reference_type_label` (line 30) and `reference_number` (line 34); `referenceNumber()` resolves a **production order** to its `order_number` and a **job tag** to its name |
| **Toll customer on the issue lines** | 🔴 **MISSING — this is the actual work.** `InventoryIssueItemResource` exposes `product_name` and no toll customer at all |

So task 2 reduces to: **surface the toll customer per line**, and verify the reference display is
genuinely visible in all three places (it is — confirm, don't rebuild).

---

## Task 1 — print the stock receipt (إذن الإضافة)

**Repo:** FE only.

Create `stock-receipts/stock-receipt-print.config.ts` mirroring `stock-issue-print.config.ts`, and
wire a print action into `stock-receipts.component.ts` exactly as `printStockIssue()` does.

Notes that matter:
- The issue's config is **quantities only, no prices** — because a goods-issue document carries no
  money. **A receipt is different**: it has unit cost and total cost, and the receipt screen shows
  them. Decide whether the printed receipt shows values, and **say why in your report**.
  Recommendation: include them — a goods-*in* document is what the storekeeper checks against the
  supplier's delivery note. But argue it rather than copying the issue blindly.
- The issue reuses `buildSignatureSection` for a receiver's signature. A receipt wants the same idea
  with the roles reversed (delivered by / received by). Reuse the shared helper; don't fork it.
- Follow the existing `settingKeyPrefix` convention (`print.stock_issue` → `print.stock_receipt`) so
  the receipt inherits the same template-selection machinery.
- Any new i18n key goes into **both** `ar.json` and `en.json`.

**Acceptance:** the receipt prints with company header, document number, date, warehouse, supplier /
source, the lines, and a signature block; the on-screen behaviour is unchanged; `ng build` and
`tsc --noEmit` green.

---

## Task 2 — toll customer column on the stock issue

**Repo:** BE + FE.

### Backend
Expose the line product's toll customer on `InventoryIssueItemResource` — `toll_customer_id` +
`toll_customer_name`, mirroring the convention already used by `ProductResource`
(`name_ar ?: name`, via `whenLoaded`).

⚠️ **Eager-load it.** `Product::tollCustomer()` exists. Reading it per row is one query per line;
add it to the controller's `with(...)` so it stays one query per page. This project has already had
to fix that exact N+1 shape once.

### Frontend
The issue line grid uses `TxColumnLayout` with `docKey = 'inventory.issue'`
(`stock-issues.component.ts:100,105`), and its columns are declared in `DOC_CONFIG_REGISTRY`
(`doc-config.service.ts:119-133`). Add a `toll_customer` LINE field there and render the column in
the grid, following exactly how the neighbouring columns are rendered.

- Show «—» when the product has no toll customer (**most products don't** — see the reality check).
- The column must be hideable from Settings → Documents like its neighbours; it is not locked.
- Reuse an existing i18n key if one fits; a new key goes into **both** files.

### Also verify (do not rebuild)
The production order / job tag already renders in the list, the detail dialog and the printout.
**Confirm all three still show it after your change** and say so in your report. If the owner's
intent was to also put the reference on the printed *line* grid or somewhere it genuinely is not,
report that rather than guessing.

**Acceptance:** a line whose product has a toll customer shows the name; one without shows «—»;
the column hides/reorders like the others; query count does not grow per line; `ng build` and
`tsc --noEmit` green; `pest Modules/Inventory` shows zero new failures.

---

## Reality check for testing

On `moonui2_dev_be` only **2 products out of ~17,000** carry a `toll_customer_id`. The column will
be empty on almost every row **here** — that is the data, not a bug. The populated data is on prod.
Find one of the two and verify against it.

## Environment / rules (both tasks)

- ⛔ **NEVER** `git checkout` / `git restore` / `git stash` on `src/assets/i18n/ar.json` or `en.json`
  — they were destroyed that way once. Additive edits only.
- Tests: `cd /home/moonui2/moon-erp-be && /opt/cpanel/ea-php82/root/usr/bin/php -d memory_limit=1G vendor/bin/pest --filter='…'`
  (bare `php` is php-cgi → "Undefined constant STDOUT"). Run your own file + `pest Modules/Inventory`.
- ⛔ **Pest loads every test file into ONE process** — prefix every top-level helper with its file's
  subject. Duplicate top-level function = fatal redeclare, exit 255, zero output.
- ⛔ NEVER `migrate:fresh` / `migrate:refresh` / `db:wipe` on `moonui2_dev_be` — not binlogged.
- `./vendor/bin/pint` on touched files only. `chown moonui2:moonui2` every edited file.
  `bash local-deploy.sh` after BE edits. Builds pre-authorized. **Do NOT deploy to `/app`.**
- Bilingual `[Unreleased]` CHANGELOG bullet per task — both are user-visible.
- Commit on `hazemdev2`, conventional. **Do not push, do not merge.** Verify the branch first.
- **Commit as soon as your tests are green** rather than batching — several agents here have lost
  their shell mid-run and left work uncommitted.
- moonui2 ONLY — never `/home/moonui`. Never print a git remote URL.
