# Common brief — client mtw39 requests (read this first)

Owner (2026-10-24): «كل التعديلات دي اعملها كلها بتوصياتك ونفذ وشغّل… متسألنيش، نفّذ للآخر وبعدين قولي». Source: WhatsApp list from client Emad (mtw39 — nutrition clinic chain with warehouses/pharmacy/POS). The screenshots are in `/home/moonui3/public_html/knowledge-base/plans/client-mtw39-requests/design/client-msg-{1..5}.png` (read them with the Read tool if your WP is about a print/receipt). Decisions in `../LEDGER.md` «Decisions» are binding — don't re-litigate them; if one is technically impossible, do the closest thing and report the deviation.

## Environment (moonui3 — never touch /home/moonui or /home/moonui2 or their DBs)
- BE: /home/moonui3/moon-erp-be (Laravel 12, nwidart Modules/*), branch hazemdev3. PHP CLI = /opt/cpanel/ea-php82/root/usr/bin/php (bare `php` is the wrong SAPI). Composer: `$PHP composer.phar …`.
- FE: /home/moonui3/public_html/moon-erp (Angular 21 standalone + PrimeNG 21, signals), branch hazemdev3. Build check: `cd /home/moonui3/public_html/moon-erp && npx ng build --base-href /app/` (pre-authorized; other agents edit the tree at the same time — if the build fails ONLY in a file you didn't touch, report it, don't fix it). Do NOT deploy — the orchestrator deploys.
- Dev DB moonui3_dev_be (live). ⛔ NEVER migrate:fresh / migrate:refresh / db:wipe / RefreshDatabase against it. New migrations: use YOUR timestamp range from your brief, run `$PHP artisan migrate --force` on dev in the same step. Migrations must also run on SQLite (tests).
- Tests: Pest on SQLite. Write tests for BE changes and run ONLY your new/changed test files (`$PHP artisan test <path>`). Never run whole module suites. Never report a test as passing that you did not run. Remember SQLite accepts non-existent columns — call your endpoint once against dev MySQL too (tinker or HTTP) when you add columns.
- Several agents work in the SAME working trees at once on disjoint files. Touch only the files of your WP; for shared files (ar.json/en.json, routes/api.php, permission/role seeders, setting-definition seeders, app.routes, sidebar menu config) make small anchored Edit-tool edits only (never Write the whole file, re-read right before editing, never reformat). Do NOT commit, do NOT git add/stash/reset/checkout — the orchestrator commits. Never revert someone else's changes.
- After editing BE files as root: `chown moonui3:moonui3 <files>`; then `$PHP artisan optimize:clear` (and `$PHP composer.phar dump-autoload` if you add classes).
- i18n: add keys to BOTH src/assets/i18n/ar.json and en.json under your own namespace (Arabic primary, Egyptian-friendly wording). Do NOT bump I18N_VERSION. After editing, validate both files with `node -e "JSON.parse(require('fs').readFileSync(p))"`.
- API: header X-Authorization Bearer; money decimal(12,3); per_page capped at 25 (use listAll in FE). Permissions via Spatie: catalogue + StandardRolesSeeder + module dependency maps + a bridge migration granting new perms to the right existing roles on existing installs (follow the pattern of existing *Grant*Permissions* seeders/migrations in the module).
- Settings: Modules\Core\Services\SettingsService (get/set/getBool); definitions via the module's setting-definition seeder (run that seeder on dev after editing). New behaviour that changes existing installs is behind a setting unless the brief says otherwise.
- GL/money ([FIN]): post through the existing journal services/types the module already uses; every posting has a reversal on cancel; never post for a company whose feature switch is off; amounts decimal(12,3). Write a test per posting path (balanced, right accounts, reversal).
- UI: RTL-first, PrimeNG 21, match the surrounding component style; owner wants things easy and in place (no hunting through settings screens). Print layouts: thermal 80mm must actually fit 72mm printable width.
- Style: match surrounding code (comments, naming, idiom). Fix in the shared layer, not per screen.
- Report back (final message): files changed, migrations run on dev, settings added (key + default), permissions added, tests written + which you ran (with result), what you could NOT verify, deviations/decisions. Factual, concise.
