kingRayhan
Investigation: why "My income (Today): ৳0.00" even when the rider earned
Traced app → rider API → production DB. Income shows ৳0.00 because of two bugs on the same code path. The primary/blocking one is in the rider API; there is also a date-order bug in the app. Fixing only the app is NOT enough — verified against the DB.
GraphQL query used for income
Operation myOverallReport (MyReportInput), from over_all_report_data.provider.dart:
query MyOverallReport($input: MyReportInput) {
myOverallReport(input: $input) {
totalCancelledDeliveriesCount
totalCashCollectedFromCustomer
totalIncome
totalSuccessfulDeliveriesCount
}
}
Resolver: dinebd__api.rider → report.resolver.ts → report.service.ts myOverallReport().
GraphQL query used for the order / earnings list
Operation myOrderHistory (MyOrderHistoryInput), from delivery_history_data.provider.dart — paginated, status: DELIVERED, one node per delivery:
query MyOrderHistory($input: MyOrderHistoryInput) {
myOrderHistory(input: $input) {
meta { currentPage hasNextPage totalCount totalPages }
nodes {
_id createdAt deliveredAt deliveryUID
riderFare status updatedAt
customer { name }
pickupLocation { lat lng address }
destinationLocation { lat lng address }
}
}
}
Input the app sends for "today" (the wire payload)
over_all_report_bloc.dart → _fetchTodayOverAllReport, dates via dateFormatV3 = "yyyy-MM-dd" (date-only):
endDate = now(); // "2026-07-08" (today)
startDate = now() + 1 day; // "2026-07-09" (tomorrow)
→ variables sent:
{ "input": { "startDate": "2026-07-09", "endDate": "2026-07-08" } }
Bug 1 — rider app: date range is REVERSED
startDate (tomorrow) is after endDate (today). The custom-range handler _fetchOverAllReport swaps them too (endDate = event.startDate; startDate = event.endDate). So the API receives $gte tomorrow AND $lte today → empty range.
Bug 2 — rider API (BLOCKING): date-only string collapses to midnight, $lte excludes the whole day
report.service.ts (myOverallReport):
deliveryMatch['createdAt'] = {
$gte: new Date(dateRange[0]), // "2026-05-27" -> 2026-05-27T00:00:00 (midnight)
$lte: new Date(dateRange[1]), // "2026-05-27" -> 2026-05-27T00:00:00 (midnight) <-- kills the day
};
new Date("yyyy-MM-dd") = midnight. For a single day (start==end) the window is 00:00:00 .. 00:00:00 → matches nothing during the day.
DB proof (rider 654cc3b2…, 27 May = a day with real earnings ৳478.62 / 2 deliveries)
| Scenario | Range built | Result |
|---|---|---|
| Fix date ORDER only (same-day, date-only strings) | 00:00:00 → 00:00:00 | ৳0.00 / 0 ❌ |
| Multi-day range (27May → 28May) | 00:00:00 → next midnight | ৳478.62 / 2 ✅ |
| Proper start/end of day | 00:00:00 → 23:59:59.999 | ৳478.62 / 2 ✅ |
→ Fixing the app's date order alone still returns ৳0.00. The API end-of-day fix is what unblocks income.
Fix
Rider API — report.service.ts (primary): normalize the range. date-fns is already used in delivery-chart.resolver.ts in the same repo (which is why the chart works and this report doesn't).
import { startOfDay, endOfDay } from 'date-fns';
deliveryMatch['createdAt'] = {
$gte: startOfDay(new Date(dateRange[0])),
$lte: endOfDay(new Date(dateRange[1])),
};
Apply the same fix to cancelledDeliveryMatch (second identical block in the file) or cancelled counts stay broken. Also consider matching on deliveredAt (when the rider earned) rather than createdAt — the myOrderHistory list already keys on deliveredAt, so the two are currently inconsistent.
Rider app — over_all_report_bloc.dart (secondary): send startDate ≤ endDate in both _fetchTodayOverAllReport and _fetchOverAllReport. Needed for correctness, but does not by itself make income appear.
Note: for the current rider on 8 Jul, latest DELIVERED was 28 Jun (3 all-time), so today genuinely is 0 — but the feature is broken for any earning day, which is the real issue here.