fix(representation): count only online bookings in the agent panel
The agent's own dashboard (dashboard/summary and doctors/performance) counted every appointment belonging to their doctors, so the bookings a secretary types into the panel — which earn the agent nothing — sat next to a commission column that ignored them. Both now count only bookings that came from the agent's own site, matching the monthly/yearly report. The per-doctor income column is also scoped to this agent, since a doctor may have been under another one before. Adds a backfill for the bookings paid before city domains resolved to an agent: they carry neither booking_representation_id nor a FinancialBreakdown, and neither can be recovered by replaying the request. Both are derived from payments.frontend_address, the address the payment was started from. The recovered breakdown is dated to the payment, not to the run, or a year of commission would land in "today". Dry-run by default; re-running is a no-op, and a payment whose domain does not match the doctor's owner is reported and skipped rather than retried forever. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -284,6 +284,15 @@ Get yearly earnings dashboard for a representation.
|
||||
|
||||
## پنل نماینده (ROLE_REPRESENTATION)
|
||||
|
||||
> **شمارش نوبت:** `dashboard/summary` و `doctors/performance` هم فقط نوبتهای آنلاینِ همین نماینده را میشمارند (`appointments.booking_representation_id`). نوبتی که منشی در پنل ثبت میکند شمرده نمیشود. ستون درآمدِ هر پزشک هم فقط سهم همین نماینده است، نه سهم نمایندگان قبلیِ آن پزشک.
|
||||
>
|
||||
> **بازسازی گذشته:** نوبتهای آنلاینی که پیش از نگاشت دامنهی شهری پرداخت شدهاند نه `booking_representation_id` دارند و نه ردیف `FinancialBreakdown`. دستور زیر هر دو را از روی `payments.frontend_address` میسازد؛ بدون `--force` فقط گزارش میدهد و تاریخ ردیف مالی روی لحظهی پرداخت مینشیند، نه لحظهی اجرا:
|
||||
>
|
||||
> ```
|
||||
> php bin/console app:representation:backfill-online-commission [--force]
|
||||
> ```
|
||||
|
||||
|
||||
این endpointها برای کاربرِ دارای نقش `ROLE_REPRESENTATION` در پنل ادمین (`/admin`) هستند. مالکیت همیشه از کاربر جاری (`#[CurrentUser]` + `findByUser`) تعیین میشود؛ هیچ uuid/id ورودی برای تعیین مالکیت پذیرفته نمیشود.
|
||||
|
||||
> **Permission (همهی این بخش):** `ROLE_REPRESENTATION`
|
||||
|
||||
Reference in New Issue
Block a user