feat(orders): send the order-placement SMS and close Phase 1
The reference texted three audiences on every placed order
(henza_server Api/ApiMobileController::setOrder:733-766). None of it was
wired here — OrdersService had no SmsService at all, so a customer could
place an order and nobody was told: not the customer, not the admins, not
the referring sales expert.
Now, after the transaction commits (so a rolled-back order texts nobody)
and without ever being awaited (D20 — a dead gateway must not fail an
order):
- every mobile in ORDER_ADMIN_MOBILES, with the customer's name and
the rounded gold weight;
- the customer, with distinct text for a normal and an over-limit
suspended order;
- the referring sales expert, looked up on AdminUser (the target's
referring expert is an admin, not a customer as in the reference).
The reference's four hardcoded personal numbers stay out of git, behind
the same env-var pattern as PROFILE_ADMIN_MOBILES.
The «در سیستم ویرایش شد» variant was deliberately not ported: the target
has no order-edit route, so it would be dead code — «عمداً تکرار نشد».
Also fills §2 of the admin matrix, the D1 deliverable that had been
(pending) since the phase opened: 163 rid-guarded routes, 68 distinct
rids, 176 grantable tree keys, and a per-module map to the reference
controllers. Only two enforced rids are ungrantable from the permission
screen (newsletters, persons.list.sellers.view) — filed as PERM-02,
awaiting an owner ruling because it changes the permission vocabulary.
Phase 1 (admin parity) is at its gate. api: 283/283 tests, 26 suites.
پنل: پیامک ثبت سفارش برای مشتری، ادمینها و کارشناس فروش فعال شد.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
759625d2a1
commit
83e5d2868b
@@ -769,3 +769,63 @@ REL-01/REL-02 in ISSUES.
|
||||
build 5/5 · jest 45/45 · admin smoke 43/43 · apps smoke 43/43 ·
|
||||
B2B scan 34 ok / 0 broken · B2B writes 25/25 · auth-smoke 32/32 ·
|
||||
sales-expert 33/33 · name trigger 9/9 · typecheck clean on all four apps.
|
||||
|
||||
---
|
||||
|
||||
## 2026-10-12 — Phase 1 close-out — order SMS (SMS-03) and the §2 rid matrix
|
||||
|
||||
### 1. Order-placement SMS — SMS-03
|
||||
|
||||
- **What:** `OrdersService` now injects `SmsService` and, after the order
|
||||
transaction commits, texts three audiences: the admins listed in
|
||||
`ORDER_ADMIN_MOBILES`, the customer (different text when the order was
|
||||
suspended for exceeding the gram ceiling), and the customer's referring sales
|
||||
expert. Brand «منتزر» replaces «هنزا گلد»; every other character of the four
|
||||
texts is the reference's.
|
||||
- **Why:** the matrix had logged only the suspended-order message as missing. On
|
||||
reading the reference, **all four** messages were absent and `OrdersService`
|
||||
did not inject `SmsService` at all — a customer placing an order was told
|
||||
nothing, and neither was anyone else.
|
||||
- **Reference:** `henza_server/app/Http/Controllers/Api/ApiMobileController.php:733-766`
|
||||
- **Target:** `apps/api/src/modules/orders/orders.service.ts`
|
||||
(`notifyOrderPlaced`, `notifySalesAgent`), `orders.module.ts`, `.env.example`
|
||||
- **Matrix row:** `01-ADMIN-MATRIX.md` §4, SMS-03
|
||||
- **Deliberate non-replication:** the «در سیستم ویرایش شد» variant (`:734-737`)
|
||||
is **not** ported — no target path lets a customer edit a placed order, so the
|
||||
branch could never fire. Annotated «عمداً تکرار نشد — SMS-03» per D4.
|
||||
- **Decisions carried over:** admin numbers come from an env var rather than the
|
||||
reference's four hardcoded personal numbers, matching the existing
|
||||
`PROFILE_ADMIN_MOBILES` pattern; SMS is fire-and-forget per D20, so a dead
|
||||
gateway can never fail an order; the messages are sent **after** the
|
||||
transaction commits, as the reference did, so a rolled-back order texts nobody.
|
||||
`Notify::store` (Firebase push) beside each message stays deferred as PUSH-01.
|
||||
- **Tests:** 6 new cases in `orders.service.spec.ts` (customer placed/suspended
|
||||
text, admin fan-out, no-admins-configured, sales expert, expert without a
|
||||
mobile). Full api suite **283/283**, typecheck clean.
|
||||
- **Found while testing:** the pre-existing "sales expert credit" suite mocked no
|
||||
`adminUser`, so the new agent lookup hit its catch and logged an error while
|
||||
the test still passed green. Mock completed — a passing test now means the
|
||||
path actually ran.
|
||||
|
||||
### 2. §2 of the admin matrix — the D1 rid matrix
|
||||
|
||||
- **What:** filled in the section that had stood as *(pending)* since the phase
|
||||
began, mechanically from the target's `@RequirePermission` decorators and
|
||||
`permissionConst.ts`: 163 rid-guarded routes, 68 distinct rids, 176 tree keys,
|
||||
mapped per module onto the reference controller each one ports.
|
||||
- **Why:** D1 required proof that no admin operation is left without an
|
||||
equivalent permission. It is the last unfinished item of Phase 1.
|
||||
- **Result:** 66 of the 68 enforced rids are grantable from the permission
|
||||
screen. The 2 that are not — `newsletters` and `persons.list.sellers.view` —
|
||||
are logged as **PERM-02**; both are inherited from the reference, whose own
|
||||
`permissionConst.ts` header had already recorded four such rids (the other two
|
||||
now have no route on either side).
|
||||
- **Target:** `docs/parity/01-ADMIN-MATRIX.md` §2
|
||||
- **Note on method:** the first extraction pass read the rid that followed each
|
||||
HTTP decorator and produced an off-by-one map (it claimed
|
||||
`reconcile → wallet.list`). Caught by spot-checking against this CHANGELOG's
|
||||
own stage-1 entry, which records `reconcile → wallet.charge`. The corrected
|
||||
pass was re-verified against five independently documented mappings before any
|
||||
table was written.
|
||||
|
||||
_No data was deleted in this entry._
|
||||
|
||||
Reference in New Issue
Block a user