feat: Implement Jalali calendar support for dashboard charts
- Added support for Jalali calendar in the dashboard, allowing charts to display data based on the current Jalali month and year. - Updated the API to return `patients_year`, `patients_month`, and `revenue_year` parameters for the dashboard charts. - Refactored the dashboard controller to handle Jalali date calculations and queries. - Modified the frontend components to utilize the new Jalali date parameters and reflect changes in the UI. - Removed the status column from the NewAppointmentsTable as status management is now handled on the appointments page. - Added tests to ensure the correct functioning of the new Jalali chart period features.
This commit is contained in:
+23
-5
@@ -16,6 +16,11 @@ Returns stats and today's schedule for the authenticated clinic owner.
|
||||
|-------|------|---------|-------------|
|
||||
| `from` | int (unix) | start of current month | Period start for patient/revenue stats |
|
||||
| `to` | int (unix) | now | Period end for patient/revenue stats |
|
||||
| `patients_year` | int (Jalali) | current Jalali year | Year of the month drawn by `charts.appointments_by_day` |
|
||||
| `patients_month` | int `1..12` | current Jalali month | Jalali month drawn by `charts.appointments_by_day` |
|
||||
| `revenue_year` | int (Jalali) | current Jalali year | Jalali year drawn by `charts.revenue_by_month` |
|
||||
|
||||
`patients_year` / `revenue_year` are clamped to `1300..1500` and `patients_month` to `1..12`.
|
||||
|
||||
### Response `200`
|
||||
|
||||
@@ -45,10 +50,14 @@ Returns stats and today's schedule for the authenticated clinic owner.
|
||||
"revenue_by_day": [
|
||||
{ "label": "۷ خرداد", "amount_rials": 3200000 }
|
||||
],
|
||||
"revenue_by_month": [
|
||||
{ "label": "فروردین", "amount_rials": 3200000 }
|
||||
],
|
||||
"appointments_by_day": [
|
||||
{ "label": "۷ خرداد", "count": 9 }
|
||||
{ "label": "۱", "count": 9 }
|
||||
]
|
||||
},
|
||||
"charts_period": { "patients_year": 1405, "patients_month": 4, "revenue_year": 1405 },
|
||||
"period": { "from": 1717200000, "to": 1719792000 },
|
||||
"today_appointments": [
|
||||
{
|
||||
@@ -79,8 +88,11 @@ Returns stats and today's schedule for the authenticated clinic owner.
|
||||
- `total_patients` — distinct patients ever (no period filter)
|
||||
- `revenue_period_rials` — sum of `final_price_rials` from all patient sessions in the period
|
||||
- `today_payments_rials` / `week_payments_rials` — revenue for today / the last 7 days
|
||||
- `charts.revenue_by_day` / `charts.appointments_by_day` — last 7 days series (Jalali day label); revenue drives the «میزان درآمد» area chart, appointments the «نمودار تعداد مراجعین» bar chart
|
||||
- `today_appointments` — up to 5 records, ordered by `slot_start ASC`; each row carries `patient_mobile`, `doctor_name` (personnel), `service_name` (nullable — booked service item), and `slot_end` for the «لیست نوبتهای جدید» dashboard table
|
||||
- `charts.appointments_by_day` — «نمودار تعداد بیماران»: one entry per day of the requested Jalali month (28–31 entries), label = Jalali day number in Persian digits, empty days are `count: 0`
|
||||
- `charts.revenue_by_month` — «میزان درآمد»: exactly 12 entries, one per Jalali month of `revenue_year`, label = Persian month name
|
||||
- `charts.revenue_by_day` — last 7 days; kept only as the source of `today_payments_rials` / `week_payments_rials`, not drawn by the dashboard charts
|
||||
- `charts_period` — the effective (post-clamp) chart period, so the UI can reflect what was actually rendered
|
||||
- `today_appointments` — up to 5 records, ordered by `slot_start ASC`; each row carries `patient_mobile`, `doctor_name` (personnel), `service_name` (nullable — booked service item), and `slot_end` for the «لیست نوبتهای جدید» dashboard table (that table renders read-only — `status` is still returned but no longer shown)
|
||||
- `doctors` — all doctors belonging to this clinic; each includes their appointment count for today
|
||||
|
||||
### Errors
|
||||
@@ -103,6 +115,9 @@ Returns stats and today's schedule for the authenticated doctor.
|
||||
|-------|------|---------|-------------|
|
||||
| `from` | int (unix) | start of current month | Period start for patient/revenue stats |
|
||||
| `to` | int (unix) | now | Period end for patient/revenue stats |
|
||||
| `patients_year` | int (Jalali) | current Jalali year | Year of the month drawn by `charts.appointments_by_day` |
|
||||
| `patients_month` | int `1..12` | current Jalali month | Jalali month drawn by `charts.appointments_by_day` |
|
||||
| `revenue_year` | int (Jalali) | current Jalali year | Jalali year drawn by `charts.revenue_by_month` |
|
||||
|
||||
### Response `200`
|
||||
|
||||
@@ -130,8 +145,10 @@ Returns stats and today's schedule for the authenticated doctor.
|
||||
},
|
||||
"charts": {
|
||||
"revenue_by_day": [ { "label": "۷ خرداد", "amount_rials": 3200000 } ],
|
||||
"appointments_by_day": [ { "label": "۷ خرداد", "count": 4 } ]
|
||||
"revenue_by_month": [ { "label": "فروردین", "amount_rials": 3200000 } ],
|
||||
"appointments_by_day": [ { "label": "۱", "count": 4 } ]
|
||||
},
|
||||
"charts_period": { "patients_year": 1405, "patients_month": 4, "revenue_year": 1405 },
|
||||
"period": { "from": 1717200000, "to": 1719792000 },
|
||||
"today_appointments": [
|
||||
{
|
||||
@@ -161,6 +178,7 @@ Returns stats and today's schedule for the authenticated doctor.
|
||||
- `avg_rating` — rounded to 1 decimal; `null` if no ratings yet
|
||||
- `clinics` — all clinics the doctor belongs to
|
||||
- `sms_wallet_balance`, `unique_patients_count`, `revenue_period_rials` — same semantics as clinic dashboard
|
||||
- `charts.*`, `charts_period` — same Jalali-period semantics as the clinic dashboard; `revenue_by_day` / `revenue_by_month` are omitted entirely when the caller may not see financials (see the note at the end of this file)
|
||||
|
||||
### Errors
|
||||
|
||||
@@ -281,7 +299,7 @@ In a **clinic context** the response is restricted to that clinic:
|
||||
to that clinic;
|
||||
* the financial fields are **omitted entirely** — `revenue_period_rials`, `today_payments_rials`,
|
||||
`week_payments_rials`, `sms_wallet_balance`, `unique_patients_count`, `total_patients`, and
|
||||
`charts.revenue_by_day`. They describe the doctor's personal practice and have no meaning inside
|
||||
`charts.revenue_by_day`, and `charts.revenue_by_month`. They describe the doctor's personal practice and have no meaning inside
|
||||
someone else's clinic. They return only in the personal context, or for the clinic's own owner
|
||||
holding `payments.view`;
|
||||
* `clinics` comes back as `[]` — the "کلینیکهای من" list belongs to the personal dashboard.
|
||||
|
||||
Reference in New Issue
Block a user