Schedule: gate Completed status on required reports (inspections vs charge-backed events)

Objective

  • Stop treating Completed on the mobile schedule as only “end time is in the past.”
  • For inspection rows and for events tied to a charge (event._chargeId), Completed should also require required reports for the relevant service(s) to be satisfied, using the same primary-only / primary-charge applicability rules as web inspection reports.
  • Leave Up Next (current window [start, end]) and time-only completion for item types that are out of scope (vacation, block, standalone events without _chargeId, eventGroup shells, etc.) unless product decides otherwise.

Background

  • ScheduleCard today sets isCompleted with end.isBefore(now) and isUpNext with start.isBefore(now) && end.isAfter(now) only—no reads of charges, events-on-charge, or report completion (components/schedule/ScheduleCard.tsx).
  • The schedule list is built by combineScheduleItems in lib/scheduleUtils.ts, which attaches nested subItems (events under an inspection). Sub-rows render time and equipment but do not currently surface their own Completed / Up Next badges separate from the parent card.
  • useSchedule already loads inspections with populate: ["charges", "services", "people", "reports"] and events with inspectionPopulated: ["charges", "reports", "people"] (hooks/useSchedule.ts), so much of the data needed for gating may already be on the client—or a computed flag from the API may be preferable to avoid drift with web.
  • Domain relationships (for defining “charge has an event” and linking reports to services) live in backend models such as src/models/inspectionSchema.ts (charges, events, _reportIds), src/models/eventSchema.ts (_chargeId → charge), src/models/chargeSchema.ts (isPrimary, _serviceId), and src/models/reportSchema.ts (_serviceId, _requiredReportTypeId, status, requiredReportIndex).
  • When now is past endtime but reports are still missing, showing plain Completed is misleading—product sign-off is needed on an alternate label or treatment (e.g. Pending reports).

Scope

Attik Mobile

  • Inspection rows (ScheduleItem.type === "inspection"): derive completion only after required slots for charges that do not have any linked Event on that inspection (same inspection, event._chargeId === charge._id) are satisfied, plus the existing applicability rules for primaryOnly vs charge.isPrimary (parity with web / toolsv2 as the source of truth for those rules).
  • Event rows with _chargeId: gate Completed on required reports for that charge’s service until satisfied; events without _chargeId keep time-only completion.
  • Other types: vacations, blocks, standalone events without inspection charge linkage, and eventGroup items—keep current time-based Completed unless product extends scope.
  • Sub-items: grouped events under an inspection (item.subItems in ScheduleCard) may need per-sub-item completion signaling if the parent row alone is insufficient—decision needed with design/product.
  • Map tab (app/(app)/map.tsx) uses combineScheduleItems; confirm whether the same completion semantics should apply anywhere schedule-derived UI shows “completed” (e.g. StopMarker props today are not wired from report state).

Attik Backend (optional but valuable)

  • A single shared computation (endpoint field or shared package) that, given populated inspection + charges + services + required report types + reports + events, returns booleans such as schedule-completion for an inspection and per charge-backed event would reduce divergence between mobile and web—whether to implement server-side vs client-only is a decision for the implementer.

Attik Frontend / web parity

  • Align primaryOnly and primary-charge filtering with whatever web implementation is canonical (see related work on inspection reports if still landing).

References

  • Mobile: attik-mobile/components/schedule/ScheduleCard.tsx, attik-mobile/lib/scheduleUtils.ts, attik-mobile/hooks/useSchedule.ts, attik-mobile/app/(app)/index.tsx
  • Backend: attik-backend/src/models/inspectionSchema.ts, attik-backend/src/models/eventSchema.ts, attik-backend/src/models/chargeSchema.ts, attik-backend/src/models/reportSchema.ts

Please authenticate to join the conversation.

Upvoters
Status

Completed

Board
🏠

Main App

Date

About 2 months ago

Author

Linear

Subscribe to post

Get notified by email when there are changes.