update marketing
All checks were successful
Build, Push and Deploy / build-and-push (push) Successful in 5m14s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 17s
Build, Push and Deploy / deploy-staging (push) Successful in 41s
Build, Push and Deploy / deploy-production (push) Has been skipped

This commit is contained in:
2026-05-14 11:55:22 +07:00
parent f80fcc4c1b
commit 05fd3230b8
448 changed files with 17545 additions and 5128 deletions

View File

@@ -0,0 +1,28 @@
# Walkthrough - Revenue Chart Fix
I have fixed the issue where the revenue chart was not displaying data on the business dashboard. The root cause was a mismatch between the PostgreSQL output format for month names and the expected format in the frontend JavaScript, combined with incorrect database grouping.
## Changes Made
### Business Module
#### [DashboardController.php](file:///media/itc43/Data/OTHER_PROJECT/kulakpos/kulakpos_15Maret2026_to%20GTEA/public_html/Modules/Business/App/Http/Controllers/DashboardController.php)
I updated the `revenue` method to ensure correct data aggregation and formatting for PostgreSQL:
- **FM (Fill Mode)**: Changed `TO_CHAR(created_at, 'Month')` to `TO_CHAR(created_at, 'FMMonth')`. This removes trailing spaces from month names (e.g., "January " becomes "January"), allowing them to match the keys expected by the frontend.
- **Grouping and Sorting**: Replaced `groupBy('created_at')` and `orderBy('created_at')` with logic that correctly aggregates data by month using `DATE_TRUNC('month', created_at)`.
```diff
- ->selectRaw("TO_CHAR(created_at, 'Month') as month, SUM(ABS(lossProfit)) as total")
- ->orderBy('created_at')
- ->groupBy('created_at')
+ ->selectRaw("TO_CHAR(created_at, 'FMMonth') as month, SUM(ABS(lossProfit)) as total")
+ ->groupByRaw("TO_CHAR(created_at, 'FMMonth'), DATE_TRUNC('month', created_at)")
+ ->orderByRaw("DATE_TRUNC('month', created_at)")
```
## Verification Results
### Logic Verification
- The use of `FMMonth` ensures that PostgreSQL returns strings like "January", "February", which directly match the `getMonthNameFromIndex` function in `business-dashboard.js`.
- The updated grouping ensures that all sales within a single month are summed together into one data point per month, as expected by the chart rendering logic.