Back to board

Rider app: show daily income summary when rider signs out

dinebd__mobileapp.rider#186

Description

Requested by client (Mr. Eamin, DineBD CEO) via WhatsApp, 3 Jul 2026. Evidence: WhatsApp export "Rider App Bugs" — IMG-20260623-WA0009.jpg ("My income: ৳0.00" circled, caption: "When sign out this should show daily income").

What to build

When a rider signs out, show a summary of the day's income so the rider ends the shift knowing what they earned — e.g. an interstitial on the logout confirmation (or immediately after) showing today's income, deliveries completed, and cash collected, consistent with the Earning activities screen.

Acceptance criteria

  • [ ] Logout flow displays today's income, delivery count, and cash collected before the session ends
  • [ ] Figures match the Earning activities screen for the same day
  • [ ] Flow still completes cleanly if the summary fetch fails (logout is never blocked)

Blocked by

None - can start immediately

Evidence

My income 0.00 circled by client with request to show daily income at sign outOpen image in new tab
Comments (1)
Synced 11 Jul 2026, 09:21

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.riderreport.resolver.tsreport.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.

Details
In Review🤷‍♂️ LowRider Appclosed
Repository
graphland-dev/dinebd__mobileapp.rider
Issue
#186
Author
kingRayhan
Created
3 Jul 2026, 04:34
Updated
11 Jul 2026, 06:10
enhancement