feat(subscription): allow admin to delete a granted subscription

Granting stacks a new row and extends the existing expiry, so a mistaken
grant had no way back: the report tab was read-only and no endpoint deleted
a subscription (only DELETE .../subscription/period/{uuid}, a different
resource).

Adds DELETE /api/v1/admin/subscription/{uuid}. Payment-backed subscriptions
are refused with 409 — deleting one would leave the sales report with a
payment that owns nothing; refunds are the correct path there.

The report tab gets a per-row delete with a confirm dialog, plus a button
that jumps to the grant tab so add and remove live in the same place.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
hamed
2026-08-19 21:59:12 +03:30
co-authored by Claude Opus 5
parent 5eb3bd586f
commit a1584c3296
6 changed files with 239 additions and 3 deletions
+29
View File
@@ -340,6 +340,35 @@ callback مشترک همهٔ درگاه‌ها و همهٔ نوع‌های پر
> پلن. پس اعطای پلنی پایین‌تر از پلن فعال، عملاً پلن مؤثر مقصد را کاهش می‌دهد. پنل
> ادمین قبل از ثبت این حالت تأیید می‌گیرد؛ خودِ endpoint جلوی آن را نمی‌گیرد.
### DELETE /api/v1/admin/subscription/{uuid}
**Permission:** `ROLE_ADMIN` — حذف اشتراک، برای برگرداندن اعطای اشتباه
`uuid` همان `uuid` ردیف گزارش است. حذف سخت است، نه soft delete: رکورد از
`clinic_subscriptions` پاک می‌شود و پلن مؤثر مقصد به اشتراک فعال بعدی یا به `free`
برمی‌گردد.
اشتراکِ متصل به پرداخت حذف نمی‌شود. سند مالی‌اش باید بماند و مسیر درست آن استرداد
وجه است.
**Response 200**
```json
{
"success": true,
"data": null
}
```
| وضعیت | کد | حالت |
|-------|----|------|
| 404 | ERR_SUBSCRIPTION_NOT_FOUND | uuid یافت نشد |
| 409 | ERR_CONFLICT_001 | اشتراک به پرداخت متصل است |
| 401 | ERR_AUTH_001 | بدون توکن |
| 403 | — | توکن معتبر ولی بدون `ROLE_ADMIN` |
> مسیر `DELETE /api/v1/admin/subscription/period/{uuid}` جداست و دورهٔ پلن را
> غیرفعال می‌کند، نه اشتراکِ یک مقصد را.
### GET /api/v1/admin/subscription/active/{entityType}/{entityUuid}
**Permission:** `ROLE_ADMIN` — اشتراک فعالِ یک مقصد، برای نمایش پیش از اعطا