fix(insurance): let a clinic owner save the visit price of a member doctor
The pricing rows are keyed by the *target* tenant, but the tenant filter pins every read to the environment of whoever is asking. A clinic owner setting the free-visit price for one of their doctors was therefore blind to the row that already existed: each save inserted another one — the unique key does not stop it, because insurance_id is NULL for the free-visit row and MySQL does not treat NULLs as equal — and the following read was blind in the same way, so the panel kept showing the old value. From the outside it simply looked like the field would not save. Reads now run outside the filter, the same exception the tenant-insurance repository already makes for the same reason, with authorization still coming from resolveTargetEntity(). findOneForInsurance() takes the newest row so a tenant that already accumulated duplicates converges on the last value the user entered, and a migration collapses those leftovers. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -410,6 +410,12 @@ entity جاری از `#[CurrentUser]` resolve میشود: نقش `ROLE_DOCTOR
|
||||
|
||||
با `doctor_uuid`، دسترسی اینگونه بررسی میشود: `ROLE_ADMIN`، خودِ پزشک، مالک کلینیکی که پزشک عضو آن است، یا پزشکِ عضو همان کلینیک با مجوز `services.view` (برای `PUT`: `services.update`). در غیر این صورت `403 ERR_ACCESS_DENIED`؛ پزشکِ ناموجود `404 ERR_NOT_FOUND_001`. بدون این پارامتر رفتار قبلی (موجودیت کاربر جاری) دستنخورده است.
|
||||
|
||||
> ℹ️ ردیفهای قیمتگذاری با `doctor_uuid` بیرون از TenantFilter خوانده میشوند: مقصدِ این
|
||||
> تنظیم پزشک است در حالی که محیط فعالِ مالکِ کلینیک، خودِ کلینیک است. مجوزش همان بررسی
|
||||
> بالاست. تا پیش از این، خواندن به محیط کاربر محدود میشد و ردیف موجود دیده نمیشد —
|
||||
> هر ذخیره یک ردیف تازه میساخت (قیدِ یکتا ردیفِ ویزیت آزاد را نمیگیرد چون `insurance_id`
|
||||
> آنجا `NULL` است) و مقدار ذخیرهشده هرگز به پنل برنمیگشت.
|
||||
|
||||
### Response `200`
|
||||
```json
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user