Repository navigation
[codex] Align reader and staff loans with the server calendar - #58
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
There was a problem hiding this comment.
Important
The offline loan cache drops effective_due_at and is_overdue. When offline, the reader's Library tab goes back to the raw status and the stored due date, which is the bug this PR fixes.
Reviewed changes
This review covers the single commit that adds the server calendar facts to reader and staff loan models and passes them through the status, grouping and date helpers.
- Model fields:
LoanItemandStaffLoandecode nullableeffective_due_at/is_overdueand exposedisplayDueAt = effectiveDueAt ?: dueAt. - Status mapping:
StatusMapping.calendarStatusswaps onlyin_corsoandin_ritardobased on a non-nullis_overdue. The newloan(LoanItem),loan(StaffLoan)andloanGroup(LoanItem)overloads now driveloanNeedsAttentionandloanDate. - Reader UI:
LibraryScreengroups rows and picks the chip through the calendar-aware overloads. - Staff UI:
loanChip,loanDateLineand the loan detail "Due" line use the server decision anddisplayDueAt. The edit form still starts from the storeddueAt. - Tests: 9 JVM tests in
CalendarLoanAlignmentTestand 2 desk flows inCalendarLoanAlignmentFlowTest.
⚠️ Offline Library view goes back to the stale status and date
LibraryRepository.loans() writes each successful response to Room through LoanItem.toCached. CachedLoan has no columns for the new fields, so toCached/toLoanItem silently drop them. When offline, loansCached() rebuilds LoanItems with isOverdue == null and effectiveDueAt == null. A loan whose due day fell on a closure then shows in red under "Overdue" with the stored date, while the same screen online shows "On loan" with the first open day.
Technical details
# Persist calendar facts in the offline loan cache
## Affected sites
- app/src/main/java/com/pinakes/app/data/local/LibraryCache.kt:16-37 — `CachedLoan` has no `effectiveDueAt` / `isOverdue` columns
- app/src/main/java/com/pinakes/app/data/local/LibraryCache.kt:75-85 — `LoanItem.toCached` / `CachedLoan.toLoanItem` don't carry them
- app/src/main/java/com/pinakes/app/data/local/AppDatabase.kt:17 — schema `version = 3`
## Required outcome
- A loan rebuilt from the cache gives the same `StatusMapping.loanGroup` / `loan` / `loanDate` results as the network `LoanItem` it came from.
- Room schema bumped so existing installs rebuild the table. `fallbackToDestructiveMigration` is already set and the cache rebuilds from the server.
## Suggested approach
- Add `val effectiveDueAt: String? = null` and `val isOverdue: Boolean? = null` to `CachedLoan`, map both ways, and bump `AppDatabase` to version 4.
- Add a round-trip assertion (`LoanItem` → `toCached` → `toLoanItem`) for the closure case to the existing cache tests.ℹ️ Copy-scan sheet still shows the stored due date
StaffCopyScanScreen.kt:366 renders loan.dueAt for a StaffLoan. The chip just above it now comes from the calendar-aware loanChip. After a closure, the scan sheet can show an "On loan" chip next to a due date that has already passed. Switching it to loan.displayDueAt would match StaffLoanDetailScreen and loanDateLine.
claude-opus-5-5 | 𝕏
…ting Release 1.12.0: the same-day handover switch, with the server calendar loans (#58)

A loan whose original due day was later closed can still be on time on its first usable return day. The app previously showed the stored deadline and raw status, so reader groups and staff badges could disagree with the calendar and the actions offered by the server.
Read the additive
effective_due_atand nullableis_overduefields from reader and staff loan responses. Lists, badges and loan details follow those server facts; edit forms retain the storeddue_at. Older servers continue to use the previous date/status fallback, and returned loans and uncollected requests retain their own timeline. Backend counterpart: fabiodalez-dev/Pinakes#521.Validation:
:app:assembleDebugand:app:lintDebugpass.Final review covered serialization compatibility, reader grouping, staff badges, dates, available actions and preservation of the nominal edit date. No additional actionable findings remain in this diff.