From 6c67abe935140257f546d108ba0129e244a2389f Mon Sep 17 00:00:00 2001 From: Tony Date: Thu, 3 Dec 2026 01:13:45 -0600 Subject: [PATCH 1/2] =?UTF-8?q?v2.9283=20=E2=80=94=20My=20Time:=20a=20week?= =?UTF-8?q?=20at=20the=20office=20reads=20as=20the=20bids=20you=20kept=20(?= =?UTF-8?q?punch=20list=20#469)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In This week detail and Last week detail the office job's row reads Bids · 7 when any of its days kept a list, with the office job on hover, and opens to one line of labels above the notes typed that week. A label carries no hours: how a day's hours fall on its bids is punch list #475's question. The person answered the calls on 2026-12-03. Co-Authored-By: Claude Fable 5.2 --- docs/GLOSSARY.md | 3 + docs/recent-features/v2.9283.md | 53 ++++++ src/components/DashboardMyTimeSection.tsx | 48 +++++- ...oardMyTimeSection.weekBids.render.test.tsx | 152 ++++++++++++++++++ .../dashboard/MyTimeWeekBidLabels.tsx | 56 +++++++ .../help/see-the-time-i-have-added-up.md | 8 + src/content/releaseNotes/v2.9283.ts | 15 ++ src/hooks/useMyTimeWeekBids.ts | 116 +++++++++++++ src/lib/dashboard/myTimeWeekBids.test.ts | 92 +++++++++++ src/lib/dashboard/myTimeWeekBids.ts | 118 ++++++++++++++ to-dos/bids-on-my-time/README.md | 21 ++- 11 files changed, 670 insertions(+), 12 deletions(-) create mode 100644 docs/recent-features/v2.9283.md create mode 100644 src/components/DashboardMyTimeSection.weekBids.render.test.tsx create mode 100644 src/components/dashboard/MyTimeWeekBidLabels.tsx create mode 100644 src/content/releaseNotes/v2.9283.ts create mode 100644 src/hooks/useMyTimeWeekBids.ts create mode 100644 src/lib/dashboard/myTimeWeekBids.test.ts create mode 100644 src/lib/dashboard/myTimeWeekBids.ts diff --git a/docs/GLOSSARY.md b/docs/GLOSSARY.md index 8ae905562a..618641bae5 100644 --- a/docs/GLOSSARY.md +++ b/docs/GLOSSARY.md @@ -4540,6 +4540,9 @@ Since v2.9282 the Job Mode card's header counts the bids of the day so far while That count is the clock out's own, the bids the person changed with a kept list winning, read from the person's own day for the roles that work on bids, and a day with no bid yet keeps the job's header. A press on it opens **Your bids today** in a window, read when it opens, with **Keep my list · N bids** (`clock/BidDayKeepWindow.tsx`, the window *Done for the day* opens too). An empty list names a typed note only on the clock out's sheet, and everywhere else it names the next press that is there (`bidDayEmptyWords`). +Since v2.9283 the office job's row in My time's **This week detail** and **Last week detail** reads **Bids · 7** when any of its days kept a list, with the office job on hover, and counts the bids of those days (`lib/dashboard/myTimeWeekBids.ts`, `hooks/useMyTimeWeekBids.ts`, the person's answers of 2026-12-03). +Opened, that row draws one line of labels above its notes, the first three and **All 7 bids** (`dashboard/MyTimeWeekBidLabels.tsx`), and a label carries no hours, since how a day's hours fall on its bids is punch list #475's question. +Its notes leave out the list a clock out wrote into them before v2.9158 (`weekRowTypedNotes`). **Database**: `user_bid_activity`, `bid_day_entries`, `bump_user_bid_activity`, `get_my_bid_day`, `save_my_bid_day` · kernels `lib/bids/bidInFront.ts`, `lib/clock/bidDay.ts`, `lib/clock/bidDayLabels.ts` · hooks `useBidActivityBeat`, `useClockOutBidDay`, `useSessionsBidDay` · guides `/help/clock-out-with-the-bids-of-the-day`, `/help/approve-my-teams-hours` diff --git a/docs/recent-features/v2.9283.md b/docs/recent-features/v2.9283.md new file mode 100644 index 0000000000..8bc81edf3d --- /dev/null +++ b/docs/recent-features/v2.9283.md @@ -0,0 +1,53 @@ +# v2.9283 — My Time: a week at the office reads as the bids you kept (2026-12-03) + +Punch list #469, the week's office-job row. Client only. No migration, no function change, nothing owed on prod. It reads `bid_day_entries` through the read People → Hours already makes (`fetchKeptBidDays`), under the same row policies. + +## What was asked + +The owner, 2026-12-02: a day spent on bids is to look like the bids worked on, not like the office job the clock was on. The card named *the week's office-job row reading as bids* and drew nothing for it. + +## What the row is + +My time's *This week detail* and *Last week detail* are one row a job for the whole week, with that job's hours, opened to the notes typed that week with hours a note. It is not one row a session. So the office job's row is a week's row. + +## The calls, and the person's answers (2026-12-03) + +- **What the row says:** its label reads *Bids · 7* with the office job on hover. Opened, it shows the typed notes with their hours as before, and one line of labels above them. No hours on a bid. The pick. +- **A week where only some days kept a list:** the row reads as bids when any of its days kept a list, and counts the bids of those days. The pick. +- **Punch list #473's gap line on the week's list:** not drawn there. The pick. That card's line was closed in v2.9282's change. + +## What it does + +- The office job's row reads **Bids · N** in the job's place when a day it covers kept a list. Its hover reads *Bids · N, on* and the office job. +- N is the bids kept on the days the row covers: days with a session on the office job, in that week. A bid kept on two days counts once. A bid taken off a list is not counted. +- Opened, the row draws one line of labels above its notes: three at most, then **All N bids**, which turns to **Fewer**. A label is the bid's colour, its number, its name and what was done. Solid is a changed bid. Dashed is an opened or added one. +- **No label carries hours.** How a day's hours fall on its bids is punch list #475's question, and this row does not answer it. +- A week with no kept list, a row on a job in the field and the *No job or bid* row read as before. + +## How + +- New kernel `src/lib/dashboard/myTimeWeekBids.ts`: `weekOfficeRowBids` (the days the row covers, the bids kept on them, the order and what was done, the label over `bidDayJobWords`) and `weekRowTypedNotes` (a note without the list an old clock out wrote, same notes added). +- New hook `src/hooks/useMyTimeWeekBids.ts`: the office job's id once and only when a session of the two weeks sits on a job, then one read of the kept rows for both weeks and the bids' names, only when a session sits on the office job. A read that fails leaves every row as its job. +- New `src/components/dashboard/MyTimeWeekBidLabels.tsx`: the line of labels. +- `DashboardMyTimeSection.tsx`: the hook, and `renderBreakdownList` takes the office row's bids. + +## Chosen in the build, to be read by the owner + +- **A label on this row is not a press.** The bid opens from People → Hours and from the Bids page. +- **What was done** on a bid reads from the day that gave it the most time. +- **On a person's own section** the reads are made only for a role that works on bids. On another person's section the row policies decide who gets rows, as on People → Hours. +- **Old notes.** A note that a clock out filled with the list before v2.9158 shows only its typed part on this row, and notes that then read the same are one line. + +## Tests + +- `myTimeWeekBids.test.ts` (7 cases): any day kept, only the row's days and week, a bid taken off, the order and the words, no hours on a label, and the typed notes. +- `DashboardMyTimeSection.weekBids.render.test.tsx` (3 cases): the label, the hover, the labels line with its press, the notes under it, one read for the person alone, a week with no list, and no read off the office job or for a role that does not work on bids. +- Not seen in a browser: this thread signs in to nothing. + +## Words + +The guide `see-the-time-i-have-added-up` has a new section, *Read the week job by job*. The glossary's *Bids of the day*. The card `to-dos/bids-on-my-time/README.md`: built, with what the build chose and the look. + +## The look owed + +On the card under *The look owed for the week's row*. It needs a day with a kept list on the office job: the real sign-in as a ZZ Test person who works on bids that the card's other looks wait on. diff --git a/src/components/DashboardMyTimeSection.tsx b/src/components/DashboardMyTimeSection.tsx index d863fcd1d9..b18685a881 100644 --- a/src/components/DashboardMyTimeSection.tsx +++ b/src/components/DashboardMyTimeSection.tsx @@ -10,6 +10,10 @@ import { PersonalTimeOffModal } from './PersonalTimeOffModal' import { DashboardMyTimePicture } from './dashboard/DashboardMyTimePicture' import { MyTimeCanWorkLine } from './dashboard/MyTimeCanWorkLine' import { MyTimeBidDay } from './dashboard/MyTimeBidDay' +import { MyTimeWeekBidLabels } from './dashboard/MyTimeWeekBidLabels' +import { useMyTimeWeekBids } from '../hooks/useMyTimeWeekBids' +import { worksOnBids } from '../lib/clock/bidDay' +import { weekRowTypedNotes, type WeekOfficeRowBids } from '../lib/dashboard/myTimeWeekBids' import { MY_TIME_WEEKS, buildMyTimeWeeks, myTimeSessionSeconds, type MyTimeDay, type MyTimeWeek } from '../lib/dashboard/myTimeWeeks' import { payWeeksEndingAt } from '../lib/people/utilization' import { useLedgerPrefixMap } from '../contexts/LedgerDisplayPrefixContext' @@ -24,13 +28,19 @@ function formatHours(seconds: number): string { function renderBreakdownList( items: BreakdownItem[], expandedKeys: Set, - onToggleKey: (key: string) => void + onToggleKey: (key: string) => void, + /** The office job's row reading as its bids (punch list #469), or null to draw every row as its job. */ + officeBids: WeekOfficeRowBids | null = null, + /** The bids as an old clock out's list named them, left out of that row's notes. */ + listNames: readonly string[] = [], ) { return (
    {items.map((item, idx) => { const hasChildren = item.children && item.children.length > 0 const isExpanded = hasChildren && expandedKeys.has(item.key) + const bids = officeBids && item.type === 'job' && item.jobId === officeBids.jobId ? officeBids : null + const children = bids && item.children ? weekRowTypedNotes(item.children, listNames) : (item.children ?? []) const isLastItem = idx === items.length - 1 const hasSubRows = hasChildren && isExpanded return ( @@ -60,14 +70,19 @@ function renderBreakdownList( {isExpanded ? '▼' : '▶'} - - {item.label} + + {bids ? bids.label : item.label} {hasSubRows && (
      - {item.children!.map((sub, subIdx) => { + {bids ? ( +
    • + +
    • + ) : null} + {children.map((sub, subIdx) => { const truncated = sub.notes.length > 50 ? sub.notes.slice(0, 47) + '…' : sub.notes return (
    • @@ -156,7 +171,7 @@ type Props = { export default function DashboardMyTimeSection({ userId, hoursDaysCorrect, disableDayEditor = false, onWeekSeconds }: Props) { const prefixMap = useLedgerPrefixMap() - const { user: authUser } = useAuth() + const { user: authUser, role } = useAuth() const myTimeSubjectDisplayName = useMemo(() => { if (authUser?.id === userId) return displayNameFromAuthUser(authUser)?.trim() || 'You' return 'User' @@ -190,6 +205,23 @@ export default function DashboardMyTimeSection({ userId, hoursDaysCorrect, disab const selectedWeek = chosenWeek != null && chosenWeek >= 0 && chosenWeek < weeks.length ? chosenWeek : currentWeek const showsLastWeek = currentWeek > 0 && selectedWeek === currentWeek - 1 + // The office job's row of this week and of last week reads as its bids where a day kept a list (punch list #469). + // On a person's own section the read is made only for a role that works on bids. On another's, row policies decide. + const detailWeeks = useMemo(() => { + if (!read) return [] + const payWeeks = payWeeksEndingAt(read.todayYmd, MY_TIME_WEEKS) + return payWeeks.slice(-2).map((w) => ({ start: w.start, end: w.end })) + }, [read]) + const weekBids = useMyTimeWeekBids({ + enabled: authUser?.id === userId ? worksOnBids(role) : true, + userId, + sessions: read?.sessions ?? null, + weeks: detailWeeks, + prefixMap, + }) + const thisWeekStart = detailWeeks[detailWeeks.length - 1]?.start ?? '' + const lastWeekStart = detailWeeks.length > 1 ? (detailWeeks[0]?.start ?? '') : '' + const myTimeModalSessions = useMemo(() => (editorDate && read ? read.sessions.filter((s) => s.work_date === editorDate) : []), [editorDate, read]) useEffect(() => { @@ -583,7 +615,7 @@ export default function DashboardMyTimeSection({ userId, hoursDaysCorrect, disab else next.add(key) return next }) - }) + }, weekBids.rowOf(lastWeekStart), weekBids.listNames) : renderBreakdownList(breakdown, expandedKeys, (key) => { setExpandedKeys((prev) => { const next = new Set(prev) @@ -591,7 +623,7 @@ export default function DashboardMyTimeSection({ userId, hoursDaysCorrect, disab else next.add(key) return next }) - }))} + }, weekBids.rowOf(thisWeekStart), weekBids.listNames))} )}
      ({ + role: 'estimator', + sessions: [] as Array>, + kept: vi.fn(), + names: vi.fn(), + officeJob: vi.fn(), +})) + +vi.mock('../lib/supabase', async () => { + const { makeSupabaseStub } = await import('../test/renderSmokeMocks') + const stub = makeSupabaseStub() + const answer = (data: unknown) => { + const b: Record = {} + for (const m of ['select', 'eq', 'is', 'gte', 'lte', 'in', 'order', 'range', 'limit']) b[m] = () => b + b.then = (f?: (v: unknown) => unknown, r?: (e: unknown) => unknown) => Promise.resolve({ data, error: null }).then(f, r) + return b + } + return { + supabase: { + ...stub, + from: (table: string) => (table === 'clock_sessions' ? answer(h.sessions) : stub.from()), + rpc: (name: string) => + name === 'get_jobs_ledger_by_ids' + ? answer([ + { id: '00000000-0000-0000-0000-00000000aaaa', hcp_number: '100', click_number: '', job_name: 'ZZ Test Office', job_address: '1 Test St', service_type_id: null }, + { id: '00000000-0000-0000-0000-00000000bbbb', hcp_number: '502', click_number: '', job_name: 'ZZ Test Field Job', job_address: '2 Test St', service_type_id: null }, + ]) + : stub.rpc(), + }, + } +}) +vi.mock('../hooks/useAuth', async () => { + const { makeUseAuthValue } = await import('../test/renderSmokeMocks') + const useAuth = () => makeUseAuthValue({ role: h.role }) + return { useAuth, useOptionalAuth: useAuth } +}) +vi.mock('../lib/clock/bidDayLabelsIo', () => ({ fetchKeptBidDays: h.kept, fetchBidLabelNames: h.names })) +vi.mock('../lib/overheadOfficeJobSettings', () => ({ fetchOverheadOfficeJobLedgerIdFromAppSettings: h.officeJob })) +vi.mock('../lib/bids/bidJobsOpenedIo', () => ({ loadJobsOpenedFromBids: async () => [] })) + +import { renderWithProviders, SMOKE_AUTH_USER_ID } from '../test/renderSmokeMocks' +import { todayYmdInAppTz } from '../utils/dateUtils' +import DashboardMyTimeSection from './DashboardMyTimeSection' + +const today = todayYmdInAppTz() +const session = (id: string, job: string, notes: string, hoursAgo: number) => ({ + id, + clocked_in_at: new Date(Date.now() - hoursAgo * 3_600_000).toISOString(), + clocked_out_at: new Date(Date.now() - (hoursAgo - 1) * 3_600_000).toISOString(), + work_date: today, + notes, + job_ledger_id: job, + bid_id: null, + approved_at: null, + origin: 'manual', + salary_segment_index: null, +}) +const bid = (n: number) => `0b1d0000-0000-4000-8000-0000000b${n}` +const keptRow = (n: number, over: Record = {}) => ({ user_id: SMOKE_AUTH_USER_ID, work_date: today, bid_id: bid(n), state: 'kept', source: 'app', seen_seconds: 600 + n, tabs: ['pricing'], changes: 2, seen: null, ...over }) +const nameRow = (n: number) => ({ id: bid(n), bid_number: `${n}`, project_name: `ZZ Test Bid ${n}`, service_type_id: null }) + +function draw() { + renderWithProviders() +} + +async function openDetail() { + fireEvent.click(await screen.findByRole('button', { name: /This week detail/ })) +} + +afterEach(() => { + cleanup() + h.role = 'estimator' + h.sessions = [] + h.kept.mockReset() + h.names.mockReset() + h.officeJob.mockReset() +}) + +describe('DashboardMyTimeSection — the week’s office-job row reading as bids (punch list #469)', { timeout: 15_000 }, () => { + it('says Bids · 4 in the office job’s place, with the job on hover, and draws the labels above the notes', async () => { + h.sessions = [session('s1', OFFICE, 'Called the GC', 5), session('s2', FIELD, 'Set the tub', 3)] + h.officeJob.mockResolvedValue(OFFICE) + h.kept.mockResolvedValue([keptRow(412), keptRow(431), keptRow(398, { changes: 0, tabs: ['submission-followup'] }), keptRow(420, { source: 'person', seen_seconds: null, tabs: [], changes: 0 })]) + h.names.mockResolvedValue([nameRow(412), nameRow(431), nameRow(398), nameRow(420)]) + draw() + await openDetail() + const row = await screen.findByText('Bids · 4') + expect(row.getAttribute('title')).toMatch(/^Bids · 4, on .*100.*ZZ Test Office/) + // The field job's row keeps its job. + expect(screen.getByText(/ZZ Test Field Job/)).toBeTruthy() + + const line = screen.getByTestId('my-time-week-bid-labels') + const shown = [...line.querySelectorAll('[data-label-kind]')] + expect(shown.map((l) => l.getAttribute('data-label-kind'))).toEqual(['changed', 'changed', 'opened']) + expect(line.textContent).toContain('ZZ Test Bid 431') + expect(line.textContent).toContain('priced') + expect(line.textContent).not.toMatch(/hrs|minutes/) + // The notes typed that week stay under the labels, with their hours. + expect(screen.getByText('Called the GC')).toBeTruthy() + + fireEvent.click(within(line).getByRole('button', { name: 'All 4 bids' })) + expect(line.querySelectorAll('[data-label-kind]')).toHaveLength(4) + expect(within(line).getByRole('button', { name: 'Fewer' })).toBeTruthy() + // One read of the kept rows for the weeks on screen, for this person alone. + expect(h.kept).toHaveBeenCalledTimes(1) + expect(h.kept.mock.calls[0]![0]).toEqual([SMOKE_AUTH_USER_ID]) + }) + + it('leaves the row as the office job in a week that kept no list', async () => { + h.sessions = [session('s1', OFFICE, 'Called the GC', 5)] + h.officeJob.mockResolvedValue(OFFICE) + h.kept.mockResolvedValue([]) + draw() + await openDetail() + await screen.findByText(/ZZ Test Office/) + await waitFor(() => expect(h.kept).toHaveBeenCalled()) + expect(screen.queryByText(/^Bids · /)).toBeNull() + expect(screen.queryByTestId('my-time-week-bid-labels')).toBeNull() + expect(h.names).not.toHaveBeenCalled() + }) + + it('reads no kept list for a week with no day on the office job, or for a role that does not work on bids', async () => { + h.sessions = [session('s2', FIELD, 'Set the tub', 3)] + h.officeJob.mockResolvedValue(OFFICE) + draw() + await openDetail() + await screen.findByText(/ZZ Test Field Job/) + await waitFor(() => expect(h.officeJob).toHaveBeenCalled()) + expect(h.kept).not.toHaveBeenCalled() + cleanup() + + h.officeJob.mockClear() + h.role = 'helpers' + h.sessions = [session('s1', OFFICE, 'Swept the shop', 5)] + draw() + await openDetail() + await screen.findByText(/ZZ Test Office/) + expect(h.officeJob).not.toHaveBeenCalled() + expect(h.kept).not.toHaveBeenCalled() + }) +}) diff --git a/src/components/dashboard/MyTimeWeekBidLabels.tsx b/src/components/dashboard/MyTimeWeekBidLabels.tsx new file mode 100644 index 0000000000..13ed271265 --- /dev/null +++ b/src/components/dashboard/MyTimeWeekBidLabels.tsx @@ -0,0 +1,56 @@ +import { useState, type CSSProperties } from 'react' +import { LABELS_SHOWN, bidDayMoreLabel } from '../../lib/clock/bidDayLabels' +import type { WeekBidLabel } from '../../lib/dashboard/myTimeWeekBids' + +/** + * The bids of a week's office-job row on My time, as one line of labels above its notes (punch list #469). The + * first three show, then a press for the rest. A label is the bid's colour, its number, its name and what was + * done: solid for a bid that was changed, dashed for one opened or added. It carries no hours, since how a day's + * hours fall on its bids is punch list #475's question. The labels are the kernel's (`myTimeWeekBids.ts`). + */ + +const muted: CSSProperties = { color: 'var(--text-muted)' } + +function labelStyle(label: WeekBidLabel): CSSProperties { + return { + display: 'inline-flex', + alignItems: 'center', + gap: 6, + maxWidth: '100%', + border: `1px ${label.kind === 'changed' ? 'solid' : 'dashed'} var(--border-strong)`, + borderRadius: 7, + background: 'var(--surface)', + fontSize: '0.78rem', + padding: '2px 9px 2px 3px', + } +} + +export function MyTimeWeekBidLabels({ labels }: { labels: readonly WeekBidLabel[] }) { + const [all, setAll] = useState(false) + const shown = all ? labels : labels.slice(0, LABELS_SHOWN) + const more = bidDayMoreLabel(labels.length, all) + return ( +
      + {shown.map((l) => ( + + + + {l.number} {l.name} + {l.jobLabel ? · {l.jobLabel} : null} + · {l.did} + + + ))} + {more ? ( + + ) : null} +
      + ) +} diff --git a/src/content/help/see-the-time-i-have-added-up.md b/src/content/help/see-the-time-i-have-added-up.md index 3edf72e32f..0cb5c5c69f 100644 --- a/src/content/help/see-the-time-i-have-added-up.md +++ b/src/content/help/see-the-time-i-have-added-up.md @@ -37,6 +37,14 @@ Open a day that kept a list, and its bids show above the day's hours. Each bid i You can keep the list more than once a day. If you are on salary and never clock out, keep the list here before you stop. See [clock out with the bids I worked on today](/help/clock-out-with-the-bids-of-the-day). +## Read the week job by job + +Under the picture, press **This week detail**. Each row is one job with its time for the week. Press a row to see the notes you typed. + +Did you keep a list of bids on a day at the office? Then the office row reads {{chip:gray|Bids · 7}}. The number is the bids you kept that week. Hold the pointer on the row to see the office job. + +Open that row to see the bids as labels above your notes. A label says what was done on the bid. A label has no hours. + ## When a day is marked A day with an amber mark is a day nobody clocked out of. The clock stopped itself at midnight, so the time on it is too long. diff --git a/src/content/releaseNotes/v2.9283.ts b/src/content/releaseNotes/v2.9283.ts new file mode 100644 index 0000000000..09ba8ca9e0 --- /dev/null +++ b/src/content/releaseNotes/v2.9283.ts @@ -0,0 +1,15 @@ +import type { ReleaseNote } from '../../lib/releaseNotes' + +const note: ReleaseNote = { + version: 'v2.9283', + date: '2026-12-03', + title: 'My Time: a week at the office reads as the bids you kept', + kind: 'feature', + highlights: [ + 'In This week detail and Last week detail, the office row now reads Bids · 7 when you kept a list of bids on any of its days. Hold the pointer on it to see the office job.', + 'Open the row to see the bids as labels above your notes: the first three, then All 7 bids for the rest. Each label says what was done on the bid.', + 'A label shows no hours. Your notes keep their hours, and the row keeps the week\'s total.', + ], +} + +export default note diff --git a/src/hooks/useMyTimeWeekBids.ts b/src/hooks/useMyTimeWeekBids.ts new file mode 100644 index 0000000000..4aadd0a7f5 --- /dev/null +++ b/src/hooks/useMyTimeWeekBids.ts @@ -0,0 +1,116 @@ +import { useEffect, useMemo, useState } from 'react' +import { loadJobsOpenedFromBids } from '../lib/bids/bidJobsOpenedIo' +import { bidBoardJobLinkLabel } from '../lib/bids/bidBoardJobLinks' +import { fetchBidLabelNames, fetchKeptBidDays, type BidDayBidNameRow, type BidDayKeptDbRow } from '../lib/clock/bidDayLabelsIo' +import { weekOfficeRowBids, type WeekKeptRow, type WeekOfficeRowBids } from '../lib/dashboard/myTimeWeekBids' +import { formatBidLedgerNumberLabel, formatBidLedgerShortLine, resolveBidLedgerPrefix, type LedgerPrefixMap } from '../lib/ledgerDisplayPrefixes' +import { fetchOverheadOfficeJobLedgerIdFromAppSettings } from '../lib/overheadOfficeJobSettings' + +type Week = { start: string; end: string } +type Loaded = { key: string; officeJobId: string; rows: BidDayKeptDbRow[]; names: BidDayBidNameRow[]; jobs: Map } + +export type MyTimeWeekBids = { + /** The office job's row of the week that starts on this day, reading as its bids, or null to leave it as the job. */ + rowOf: (weekStart: string) => WeekOfficeRowBids | null + /** The bids of these weeks as an old clock out's list named them, to leave that list out of a note. */ + listNames: string[] +} + +const NONE: MyTimeWeekBids = { rowOf: () => null, listNames: [] } + +/** + * The kept lists behind My time's week rows (punch list #469). One read of the office job's id, then, only when a + * session of these weeks sits on it, one read of the person's kept rows for the weeks and the names of their bids. + * The rule is `lib/dashboard/myTimeWeekBids.ts`. A read that fails leaves every row as its job. + */ +export function useMyTimeWeekBids(opts: { + enabled: boolean + userId: string + sessions: ReadonlyArray<{ work_date: string; job_ledger_id: string | null }> | null + /** The weeks whose rows are drawn: this week and last week. */ + weeks: readonly Week[] + prefixMap: LedgerPrefixMap +}): MyTimeWeekBids { + const { enabled, userId, sessions, weeks, prefixMap } = opts + const from = weeks.reduce((min, w) => (min === '' || w.start < min ? w.start : min), '') + const to = weeks.reduce((max, w) => (w.end > max ? w.end : max), '') + const onAJob = useMemo(() => !!sessions?.some((s) => s.job_ledger_id && s.work_date >= from && s.work_date <= to), [sessions, from, to]) + + /** undefined until read; null when the company has no office job set. */ + const [officeJobId, setOfficeJobId] = useState(undefined) + const needsOffice = enabled && onAJob && officeJobId === undefined + useEffect(() => { + if (!needsOffice) return + let stale = false + void fetchOverheadOfficeJobLedgerIdFromAppSettings() + .then((id) => { + if (!stale) setOfficeJobId(id ?? null) + }) + .catch(() => { + if (!stale) setOfficeJobId(null) + }) + return () => { + stale = true + } + }, [needsOffice]) + + const onOffice = useMemo( + () => !!officeJobId && !!sessions?.some((s) => s.job_ledger_id === officeJobId && s.work_date >= from && s.work_date <= to), + [sessions, officeJobId, from, to], + ) + const key = enabled && onOffice && officeJobId && from && to ? `${userId}|${officeJobId}|${from}|${to}` : '' + const [loaded, setLoaded] = useState(null) + useEffect(() => { + if (!key || !officeJobId) return + let stale = false + void (async () => { + try { + const rows = await fetchKeptBidDays([userId], from, to) + if (stale) return + if (rows.length === 0) { + setLoaded({ key, officeJobId, rows, names: [], jobs: new Map() }) + return + } + const bidIds = [...new Set(rows.map((r) => r.bid_id))] + const [names, opened] = await Promise.all([fetchBidLabelNames(bidIds), loadJobsOpenedFromBids(bidIds).catch(() => [])]) + if (stale) return + const jobs = new Map() + // Newest first: a bid that opened two jobs shows the newest. + for (const j of opened) if (!jobs.has(j.bidId)) jobs.set(j.bidId, bidBoardJobLinkLabel(j.hcpNumber)) + setLoaded({ key, officeJobId, rows, names, jobs }) + } catch { + /* no labels: every row reads as its job, as it always has */ + } + })() + return () => { + stale = true + } + }, [key, officeJobId, userId, from, to]) + + return useMemo(() => { + if (!loaded || loaded.key !== key || loaded.rows.length === 0 || !sessions) return NONE + const nameRow = new Map(loaded.names.map((b) => [b.id, b])) + const nameOf = (bidId: string) => { + const b = nameRow.get(bidId) + if (!b) return { number: 'A bid', name: 'you cannot open', jobLabel: loaded.jobs.get(bidId) ?? null } + return { + number: formatBidLedgerNumberLabel(resolveBidLedgerPrefix(b.service_type_id, prefixMap), b.bid_number), + name: (b.project_name ?? '').trim() || '—', + jobLabel: loaded.jobs.get(bidId) ?? null, + } + } + const kept: WeekKeptRow[] = loaded.rows.map((r) => ({ + workDate: r.work_date, + bidId: r.bid_id, + state: r.state === 'off' ? 'off' : 'kept', + source: r.source === 'person' ? 'person' : 'app', + seenSeconds: r.seen_seconds, + tabs: r.tabs ?? [], + changes: r.changes ?? 0, + })) + const byWeek = new Map() + for (const w of weeks) byWeek.set(w.start, weekOfficeRowBids({ officeJobId: loaded.officeJobId, sessions, kept, weekStart: w.start, weekEnd: w.end, nameOf })) + const listNames = loaded.names.map((b) => formatBidLedgerShortLine(prefixMap, b.service_type_id, b.bid_number, b.project_name)) + return { rowOf: (weekStart: string) => byWeek.get(weekStart) ?? null, listNames } + }, [loaded, key, sessions, weeks, prefixMap]) +} diff --git a/src/lib/dashboard/myTimeWeekBids.test.ts b/src/lib/dashboard/myTimeWeekBids.test.ts new file mode 100644 index 0000000000..4e57e66a7c --- /dev/null +++ b/src/lib/dashboard/myTimeWeekBids.test.ts @@ -0,0 +1,92 @@ +import { describe, expect, it } from 'vitest' +import { weekOfficeRowBids, weekRowTypedNotes, type WeekKeptRow } from './myTimeWeekBids' + +// A made-up week, Sunday 2026-11-22 to Saturday 2026-11-28. Every bid and job here is made up. +const OFFICE = 'job-office' +const WEEK = { weekStart: '2026-11-22', weekEnd: '2026-11-28' } +const nameOf = (bidId: string) => ({ number: `BP${bidId.slice(1)}`, name: `ZZ Test ${bidId}`, jobLabel: bidId === 'b398' ? 'J1007' : null }) +const kept = (workDate: string, bidId: string, over: Partial = {}): WeekKeptRow => ({ workDate, bidId, state: 'kept', source: 'app', seenSeconds: 600, tabs: ['pricing'], changes: 2, ...over }) +const office = (day: string) => ({ work_date: day, job_ledger_id: OFFICE }) + +describe('weekOfficeRowBids', () => { + it('reads as bids when any day of the row kept a list, and counts the bids of those days', () => { + const row = weekOfficeRowBids({ + officeJobId: OFFICE, + sessions: [office('2026-11-23'), office('2026-11-24'), office('2026-11-25')], + // Monday kept two bids, Tuesday kept one of them again. Wednesday kept nothing. + kept: [kept('2026-11-23', 'b412'), kept('2026-11-23', 'b398'), kept('2026-11-24', 'b412')], + ...WEEK, + nameOf, + }) + expect(row?.label).toBe('Bids · 2') + expect(row?.jobId).toBe(OFFICE) + expect(row?.labels.map((l) => l.number)).toEqual(['BP412', 'BP398']) + }) + + it('leaves the row as the office job with no kept list, with no office job set, and with no day on the office job', () => { + expect(weekOfficeRowBids({ officeJobId: OFFICE, sessions: [office('2026-11-23')], kept: [], ...WEEK, nameOf })).toBeNull() + expect(weekOfficeRowBids({ officeJobId: null, sessions: [office('2026-11-23')], kept: [kept('2026-11-23', 'b412')], ...WEEK, nameOf })).toBeNull() + expect(weekOfficeRowBids({ officeJobId: OFFICE, sessions: [{ work_date: '2026-11-23', job_ledger_id: 'job-field' }], kept: [kept('2026-11-23', 'b412')], ...WEEK, nameOf })).toBeNull() + }) + + it('counts only the days the row covers: a list kept on a day in the field, or in another week, is left out', () => { + const row = weekOfficeRowBids({ + officeJobId: OFFICE, + sessions: [office('2026-11-23'), { work_date: '2026-11-24', job_ledger_id: 'job-field' }, office('2026-11-16')], + kept: [kept('2026-11-23', 'b412'), kept('2026-11-24', 'b420'), kept('2026-11-16', 'b431')], + ...WEEK, + nameOf, + }) + expect(row?.label).toBe('Bids · 1') + expect(row?.labels.map((l) => l.bidId)).toEqual(['b412']) + }) + + it('leaves out a bid taken off the list', () => { + const row = weekOfficeRowBids({ officeJobId: OFFICE, sessions: [office('2026-11-23')], kept: [kept('2026-11-23', 'b412'), kept('2026-11-23', 'b398', { state: 'off' })], ...WEEK, nameOf }) + expect(row?.label).toBe('Bids · 1') + }) + + it('says what was done on each, the changed ones first and the most work first, and carries no hours', () => { + const row = weekOfficeRowBids({ + officeJobId: OFFICE, + sessions: [office('2026-11-23'), office('2026-11-24')], + kept: [ + kept('2026-11-23', 'b420', { changes: 0, seenSeconds: 900, tabs: ['submission-followup'] }), + kept('2026-11-23', 'b412', { seenSeconds: 300, tabs: ['counts'] }), + kept('2026-11-24', 'b412', { seenSeconds: 1200, tabs: ['pricing', 'takeoffs'] }), + kept('2026-11-24', 'b398', { seenSeconds: 2400, tabs: ['takeoffs'] }), + kept('2026-11-24', 'b500', { source: 'person', seenSeconds: null, tabs: [], changes: 0 }), + ], + ...WEEK, + nameOf, + }) + expect(row?.labels.map((l) => `${l.number} ${l.kind} ${l.did}`)).toEqual(['BP398 changed takeoff', 'BP412 changed priced', 'BP420 opened follow-up', 'BP500 added added']) + expect(row?.labels[0]?.jobLabel).toBe('J1007') + expect(row?.labels.every((l) => !('seconds' in l) && !('size' in l))).toBe(true) + expect(new Set(row?.labels.map((l) => l.color)).size).toBe(4) + }) +}) + +describe('weekRowTypedNotes', () => { + const names = ['BP412 · ZZ Test Ridgeway Clinic'] + + it('leaves out the list an old clock out wrote, and adds the hours of notes that then read the same', () => { + const out = weekRowTypedNotes( + [ + { notes: 'BP412 · ZZ Test Ridgeway Clinic: 5 minutes, Pricing\nCalled the GC', seconds: 3600 }, + { notes: 'Called the GC', seconds: 1800 }, + { notes: 'BP412 · ZZ Test Ridgeway Clinic: 1 minute, Followup', seconds: 7200 }, + { notes: 'Unspecified', seconds: 600 }, + ], + names, + ) + expect(out).toEqual([ + { notes: 'Unspecified', seconds: 7800 }, + { notes: 'Called the GC', seconds: 5400 }, + ]) + }) + + it('leaves a typed note as it is', () => { + expect(weekRowTypedNotes([{ notes: 'Site walk with the super', seconds: 900 }], names)).toEqual([{ notes: 'Site walk with the super', seconds: 900 }]) + }) +}) diff --git a/src/lib/dashboard/myTimeWeekBids.ts b/src/lib/dashboard/myTimeWeekBids.ts new file mode 100644 index 0000000000..8ecbe9a3fb --- /dev/null +++ b/src/lib/dashboard/myTimeWeekBids.ts @@ -0,0 +1,118 @@ +import { BID_DAY_COLORS } from '../clock/bidDay' +import { bidDayDidWord, bidDayJobWords, bidDayTypedNote, type BidDayLabelKind, type BidLabelName } from '../clock/bidDayLabels' + +/** + * The week's office-job row on My time, reading as its bids (punch list #469). + * + * The week's detail is one row a job for the whole week, opened to the notes typed that week with hours a note. + * The person's answers of 2026-12-03: the office job's row says 'Bids · 7' when any of its days kept a list, and + * counts the bids of those days. Opened, it draws one line of labels above the notes. A label carries no hours: + * how a day's hours fall on its bids is punch list #475's question, and this row does not answer it. + * + * It changes what the row says and nothing about where the hours are costed. + */ + +/** One row of `bid_day_entries`, with its day. */ +export type WeekKeptRow = { + workDate: string + bidId: string + state: 'kept' | 'off' + source: 'app' | 'person' + seenSeconds: number | null + /** Tab keys, the most time first. */ + tabs: readonly string[] + changes: number +} + +export type WeekBidLabel = { + bidId: string + number: string + name: string + /** Shown beside the name when the bid opened a job: 'J1007'. */ + jobLabel: string | null + kind: BidDayLabelKind + /** What was done, in a word or two: 'priced', 'follow-up', 'added'. */ + did: string + color: string +} + +export type WeekOfficeRowBids = { + /** The office job, whose row this is. */ + jobId: string + /** 'Bids · 7', in the job's place. */ + label: string + /** One a bid, the changed ones first and the most work first. */ + labels: WeekBidLabel[] +} + +const KIND_RANK: Record = { changed: 0, opened: 1, added: 2 } + +export function weekOfficeRowBids(input: { + officeJobId: string | null + /** The week's sessions, with the day and the job of each. */ + sessions: ReadonlyArray<{ work_date: string; job_ledger_id: string | null }> + /** The person's kept rows. Rows of other days are left out here. */ + kept: readonly WeekKeptRow[] + weekStart: string + weekEnd: string + nameOf: (bidId: string) => BidLabelName +}): WeekOfficeRowBids | null { + const { officeJobId, weekStart, weekEnd } = input + if (!officeJobId) return null + const days = new Set() + for (const s of input.sessions) { + if (s.job_ledger_id === officeJobId && s.work_date >= weekStart && s.work_date <= weekEnd) days.add(s.work_date) + } + if (days.size === 0) return null + + type Sum = { bidId: string; app: boolean; changes: number; seconds: number; tabs: string[]; tabsSeconds: number } + const byBid = new Map() + for (const r of input.kept) { + if (r.state !== 'kept' || !r.bidId || !days.has(r.workDate)) continue + const sum = byBid.get(r.bidId) ?? { bidId: r.bidId, app: false, changes: 0, seconds: 0, tabs: [], tabsSeconds: -1 } + const seconds = Math.max(0, r.seenSeconds ?? 0) + if (r.source === 'app') sum.app = true + sum.changes += Math.max(0, r.changes) + sum.seconds += seconds + // What was done reads from the day that gave the bid the most time. + if (r.tabs.length > 0 && seconds > sum.tabsSeconds) { + sum.tabs = [...r.tabs] + sum.tabsSeconds = seconds + } + byBid.set(r.bidId, sum) + } + if (byBid.size === 0) return null + + const sums = [...byBid.values()].map((s) => { + const kind: BidDayLabelKind = !s.app ? 'added' : s.changes > 0 ? 'changed' : 'opened' + return { ...s, kind, name: input.nameOf(s.bidId) } + }) + sums.sort((a, b) => KIND_RANK[a.kind] - KIND_RANK[b.kind] || b.seconds - a.seconds || a.name.number.localeCompare(b.name.number) || a.bidId.localeCompare(b.bidId)) + const labels: WeekBidLabel[] = sums.map((s, i) => ({ + bidId: s.bidId, + number: s.name.number, + name: s.name.name, + jobLabel: s.name.jobLabel ?? null, + kind: s.kind, + did: bidDayDidWord(s.kind, s.tabs), + color: BID_DAY_COLORS[i % BID_DAY_COLORS.length] ?? BID_DAY_COLORS[0], + })) + const label = bidDayJobWords({ bids: labels.length, onBid: false, jobId: officeJobId, officeJobId }) + return label ? { jobId: officeJobId, label, labels } : null +} + +export const WEEK_NOTE_UNSPECIFIED = 'Unspecified' + +/** + * The row's notes without the list a clock out wrote into them before v2.9158. Notes that read the same once the + * list is left out are one line, with their hours added. `listNames` are the week's bids as the list named them. + */ +export function weekRowTypedNotes(children: ReadonlyArray<{ notes: string; seconds: number }>, listNames: readonly string[]): Array<{ notes: string; seconds: number }> { + const byNote = new Map() + for (const c of children) { + const typed = c.notes === WEEK_NOTE_UNSPECIFIED ? '' : bidDayTypedNote(c.notes, listNames) + const key = typed || WEEK_NOTE_UNSPECIFIED + byNote.set(key, (byNote.get(key) ?? 0) + c.seconds) + } + return [...byNote.entries()].map(([notes, seconds]) => ({ notes, seconds })).sort((a, b) => b.seconds - a.seconds) +} diff --git a/to-dos/bids-on-my-time/README.md b/to-dos/bids-on-my-time/README.md index 79b69065ab..431aa442c0 100644 --- a/to-dos/bids-on-my-time/README.md +++ b/to-dos/bids-on-my-time/README.md @@ -2,7 +2,7 @@ name: "Hours and My time: the bids of a day as labels, not as a description" number: 469 group: ready -status: asked 2026-12-01 by the owner with a picture of People → Hours · the clock-out list and the Hours row read in the code the same day · the card and the mock-up written · step 1, the kernel, is v2.9153 (2026-12-02) · the owner's answer the same day: the day is to look like the bids worked on in place of the office job · his second answer the same day: the times of the kept bids may ride with the kept list · step 2, the labels on People → Hours, is v2.9158 · step 2a, the stretches kept with the list, is v2.9160 with its migration · step 3's first piece, today's bids on My Time with a press that keeps the list, is v2.9165 · step 2b, the bar of the day under a session on People → Hours, is v2.9189 · step 3's second piece, the day's bids in the day editor, is v2.9194 · the person answered six calls on the rest of My time on 2026-12-03 · the Job Mode card's header counting the day's bids, with a press that opens the list, is v2.9282 +status: asked 2026-12-01 by the owner with a picture of People → Hours · the clock-out list and the Hours row read in the code the same day · the card and the mock-up written · step 1, the kernel, is v2.9153 (2026-12-02) · the owner's answer the same day: the day is to look like the bids worked on in place of the office job · his second answer the same day: the times of the kept bids may ride with the kept list · step 2, the labels on People → Hours, is v2.9158 · step 2a, the stretches kept with the list, is v2.9160 with its migration · step 3's first piece, today's bids on My Time with a press that keeps the list, is v2.9165 · step 2b, the bar of the day under a session on People → Hours, is v2.9189 · step 3's second piece, the day's bids in the day editor, is v2.9194 · the person answered six calls on the rest of My time on 2026-12-03 · the Job Mode card's header counting the day's bids, with a press that opens the list, is v2.9282 · the week's office-job row on My time reading as bids is v2.9283 summary: > An estimator's day is clocked to the office job, and the bids she worked on are written into that session's description. The owner wants the bids labelled on her time instead, in a way that @@ -13,9 +13,9 @@ summary: > as labels beside the hours, with what was done on each, a bar of where the bids fell in the day and an honest line of how much of the day the app saw. The note goes back to what a person typed. The session stays on the office job, so pay is not touched. -next: The week's office-job row on My time reading as bids (answered, below). Then a bid's own page, and the Schedule and Dispatch pages, whose calls are not put yet. +next: A bid's own page, and the Schedule and Dispatch pages. Their calls are not put to the person yet. My time is done. size: M as a train of six (S · S · M · S · S · not sized); steps 1, 2, 2a and 2b and the first piece of step 3 are built -ver: v2.9282 +ver: v2.9283 blocker: Nothing. opinion: build — the rows are saved already and read by the office already, and the line they are drawn as today tells a reader less than nothing --- @@ -197,7 +197,20 @@ Two things changed from the first plan while building it. 6. Delete the ZZ Test sessions and the kept row, or name them in the note. 7. *Still owed from before:* the clock-out list with two bids (F469-2), step 2a's rows with `seen` pairs, step 2b's bar under a session on People → Hours (v2.9189), and the day editor's block (v2.9194). -**Left, in order:** the week's office-job row on My time reading as bids (answered above as W1 and W2), a bid's own page, and the Schedule and Dispatch pages. The calls for the last two are not put yet. +**The week's row is built (v2.9283, 2026-12-03).** In My time's *This week detail* and *Last week detail*, the office job's row reads *Bids · 7* when any of its days kept a list, with the office job on hover. It counts the bids kept on the days the row covers. Opened, it draws one line of labels above the notes: the first three, then *All 7 bids*. A label is the bid's colour, its number, its name and what was done, solid for a changed bid and dashed for an opened or added one. **No label carries hours**, and the notes keep their hours as before (`lib/dashboard/myTimeWeekBids.ts`, `useMyTimeWeekBids`, `MyTimeWeekBidLabels`). + +- **What it reads.** The office job's id once, and only when a session of the two weeks sits on a job. Then, only when one sits on the office job, one read of the person's kept rows for both weeks and the names of their bids. On a person's own section the reads are made only for a role that works on bids. On another person's section the row policies decide, as on People → Hours. +- **Chosen in the build, to be read by the owner.** A label on this row is not a press: the bid opens from People → Hours and from the Bids page. What was done on a bid reads from the day that gave it the most time. A note that an old clock out filled with the list shows only its typed part, and notes that then read the same are one line with their hours added. The *No job or bid* row is left as it is. +- **With this, My time is done.** The gap line is not drawn on the week's list, by the answer to W3. + +**The look owed for the week's row, not made.** It needs a day with a kept list on the office job, so the same real sign-in as the looks above, or a read-only look at a real estimator's week by the dev on People, if the person allows it. + +1. Dashboard, My Time, **This week detail**. The office job's row reads *Bids · N*. Hold the pointer on it: the office job's name shows. +2. The row is open. One line of labels sits above the notes, three at most, then **All N bids**. Press it: every label shows, and the press reads **Fewer**. +3. No label shows hours. The notes under the labels keep their hours, and the row's total is the week's hours on the office job. +4. A week with no kept list still reads as the office job. At 390 wide the labels wrap and nothing scrolls sideways. + +**Left, in order:** a bid's own page, and the Schedule and Dispatch pages. The calls for both are not put yet. **Other places that draw a session's note** still show a list written before v2.9158 as words: the pending cell's popover, the approvals queue, Align, the week's sessions window, the match window and the Dashboard's My Team. A follow-up, not this card's train. From 5afea98ef8ba0bc53bc45e6b80bb3590e47fe23c Mon Sep 17 00:00:00 2001 From: Tony Date: Thu, 3 Dec 2026 01:49:20 -0600 Subject: [PATCH 2/2] to-dos: cards #469 and #475, the person's answers of 2026-12-03 (a bid's own page, Schedule and Dispatch, and the plan for splitting a day) Co-Authored-By: Claude Fable 5.2 --- to-dos/bid-hours-split.md | 52 +++++++++++++++++++++++++++----- to-dos/bids-on-my-time/README.md | 33 ++++++++++++++++++-- 2 files changed, 74 insertions(+), 11 deletions(-) diff --git a/to-dos/bid-hours-split.md b/to-dos/bid-hours-split.md index 2959106ce2..0379bbbef5 100644 --- a/to-dos/bid-hours-split.md +++ b/to-dos/bid-hours-split.md @@ -2,7 +2,7 @@ name: "A day on the office job that kept bids: its hours split onto those bids, so a bid shows what it cost to bid" number: 475 group: gated -status: asked 2026-12-02 by the owner, answering card #469's question · what clocking onto a bid does today read in the code the same day · nothing built · the first call answered by the person on 2026-12-02: only the hours seen move to a bid · calls 2 to 5 answered by the person the same day: an opened bid takes its time, a bid added by hand takes an even share, the split reaches back, and a salaried estimator follows the same rule · asked how call 3 sits with call 1, the person asked for the best way to fit how a day on bids really goes, so nothing of the split is built until a plan has been put to them +status: asked 2026-12-02 by the owner, answering card #469's question · what clocking onto a bid does today read in the code the same day · nothing built · the first call answered by the person on 2026-12-02: only the hours seen move to a bid · calls 2 to 5 answered by the person the same day: an opened bid takes its time, a bid added by hand takes an even share, the split reaches back, and a salaried estimator follows the same rule · asked how call 3 sits with call 1, the person asked for the best way to fit how a day on bids really goes, so nothing of the split is built until a plan has been put to them · the plan was put on 2026-12-03 as three ways on one made-up day with eight calls, and the person answered all eight · nothing built summary: > An estimator's day is clocked to the office job, so its hours are overhead. The bids of that day are kept as a list (card #445) and drawn as labels (card #469), and the list gives a bid no @@ -11,11 +11,11 @@ summary: > the bids the person kept, by the time the app saw each one. Pay and approval do not change. Cost reports do: overhead goes down and bid labor goes up. The weak point is the part of the day the app did not see, and the rule for those hours is the first call. -next: A short plan for the person: two or three ways to split a day, each drawn on one made-up day of one bid at a time with jumps to answer questions on others, with a pick marked. -ask: owner · decide · Which way of splitting a day fits how the work goes: one bid at a time, with jumps to answer questions on others? -size: M, not broken into steps until the code that costs a bid's labor is walked -blocker: The plan and the person's pick from it. Calls 1, 3 and 4 wait on that pick. -opinion: build to the rule the person picked — only the hours seen move to a bid, so every figure has a reason the app can show, and a bid's cost reads low and says so +next: The person reads what their answers mean for a build, under *The plan and the answers*, and says build. Then the read on the database, the kernel that splits a day, and the bid's cost reading it. +ask: owner · read · Read what the eight answers mean for a build, the made-up day under them first, and say build. +size: L as a train of four (S the read on the database · M the kernel and the bid's cost · S People → Overhead · M the salaried path) +blocker: The person's word to build. Their answers are to a plan, and no write on prod has a yes. +opinion: build to the answers — the bid in hand keeps the clock, worked out when a cost is read, so no day on prod is rewritten and the rule can still be tuned --- # A day's office hours split onto its bids (#475) @@ -42,7 +42,7 @@ For a day on the office job with a kept list, share the session's hours over the - **Pay does not change.** The session stays on the office job, with its hours and its approval as they are. - **Cost reports change.** Overhead labor goes down by the hours that move, and each bid's labor goes up. -- **It needs a change in the database.** Where it goes is not walked yet. It is either rows in `people_crew_bids` written from the kept list, or a reading of the kept list beside them. The walk comes after the first call. +- **It needs a change in the database.** Walked on 2026-12-03 and answered: a reading of the kept list when a cost is read, through one new read function, with no row written. See *The plan and the answers*. ## The calls @@ -61,6 +61,42 @@ For a day on the office job with a kept list, share the session's hours over the - **Their yes covers the rule, not a write.** Reaching back changes cost figures people have already read. It is made either by a write over the kept days on prod, or worked out when a cost is read with nothing rewritten. Which one is not known until the code is walked, and it is put to the person before any write on prod. 5. **A salaried estimator. Decided 2026-12-02: the same rule.** The person's words: *The same rule*. It is built as a second step, after the hourly path is walked and built. Their hours come from the salaried workday, not a session, and that path is not walked yet. +## The plan and the answers (the person, 2026-12-03) + +The plan drew three ways on one made-up day and put eight calls, each with a pick. The person pressed an answer to each. **The answers are to the plan. Nothing is built, and no write on prod has a yes.** + +**The made-up day.** An estimator is on the office job from 8:00 to 12:00 and from 1:00 to 5:00. The app saw 3 h 40 of the 8 hours. She worked two bids in turn, answered a question on a third, and took a phone call on a fourth that she added by hand. What really happened: 3 h 50, 2 h 45, 10 min, 15 min, and 1 hour on no bid. + +| The way | First bid | Second bid | The question | The call, by hand | Overhead | +|---|---|---|---|---|---| +| What really happened | 3 h 50 | 2 h 45 | 10 min | 15 min | 1 h 00 | +| 1. Only what the app saw | 1 h 30 | 2 h 00 | 10 min | nothing | 4 h 20 | +| 2. The rest to the bids added by hand | 1 h 30 | 2 h 00 | 10 min | 4 h 20 | nothing | +| 3. The bid in hand keeps the clock, as put with 30 minutes and a 15-minute jump | 3 h 30 | 2 h 30 | 10 min | 15 min | 1 h 35 | +| **3 as answered**, to the clock's stop, a jump being a bid opened and not changed | **3 h 40** | **3 h 30** | **10 min** | **15 min** | **25 min** | + +| The call | The answer | +|---|---| +| P1. The way. | **The bid in hand keeps the clock.** A person works one bid at a time. Time the app did not see belongs to the bid in hand. A jump to another bid takes its own minutes and the clock goes back. | +| P2. How long a bid in hand keeps the clock when nothing more is seen. | **To the clock's stop.** The pick put was 30 minutes. On the made-up day the last 90 minutes, email and filing among them, land on the second bid. | +| P3. What counts as a jump. | **A bid opened and not changed.** The pick put was a bid seen for under 15 minutes. | +| P4. A bid added by hand. | **The clock-out list asks *About how long?*** with four presses: 15 min, 30 min, 1 hour, 2 hours. It starts on 15 minutes. The time comes out of the time the app did not see. This takes the place of call 3's even share. | +| P5. Days kept before the times of day were kept, which is before 2026-12-02. | **Seen time only, and the cost says so.** Those days hold each bid's minutes and no times, so the way above cannot run on them. This is how call 4's reach back is made for them. | +| P6. Where the split is worked out. | **When a bid's cost is read, with no row written.** The reach back is then free and can be taken back, and P2 and P3 can change later without rewriting a day. | +| P7. People → Overhead, which already counts time clocked on a bid as estimating. | **The hours show under the bid there.** The pick put was no change. It is a second reader to change. | +| P8. The wage, for a person with two rates. | **The rate those hours were paid at.** | + +**What the answers mean for a build, in the reading of the session that put them. The person reads this before anything is built.** + +- **P3 fits the rows as they are kept.** A kept bid says for the whole day whether it was changed. So a bid changed that day takes the hand whenever it is seen, and a bid only opened that day is always a jump, whatever its length. +- **A clock stop empties the hand.** The minutes after a clock in, before any bid is seen, are overhead. This was in the plan's walk of the day and was not put as its own call. +- **Call 1 no longer holds as first answered.** Hours the app did not see now move to the bid in hand. +- **P6 still owes prod one thing.** An estimator can open a bid's labor and can read only their own kept list. So the bid's hours come from one new read function that answers hours a bid a day to everyone who sees that labor today, with no list of who looked at what. That is a migration and a push. It writes no row. +- **What reads the split after the first step.** Bid Costs, Labor and Pricing. People → Overhead is its own step (P7). The week's money page and the dev seat's copy of the cost do not read it until each is taught to. +- **P8 needs the two-rate rule read in the code first.** The salaried path is still the last step and is not walked. + +**What the code walk found, 2026-12-03.** A bid's labor is one row a person a day, `people_crew_bids`, a percent of the whole day. A trigger rewrites it from the clock sessions on every clock press, approval and edit, so a row written from outside is wiped. A day on the office job gives that row nothing. Nothing that costs a bid reads the kept list. + ## What this card leaves alone - Pay, approval and the session's job. @@ -69,4 +105,4 @@ For a day on the office job with a kept list, share the session's hours over the ## How to verify -Not written until the plan is. Every look uses ZZ Test bids and a test login, and no real person's hours or wage. +Not written until the first step is built. Every look uses ZZ Test bids and a test login, and no real person's hours or wage. diff --git a/to-dos/bids-on-my-time/README.md b/to-dos/bids-on-my-time/README.md index 431aa442c0..4ae7321a2c 100644 --- a/to-dos/bids-on-my-time/README.md +++ b/to-dos/bids-on-my-time/README.md @@ -2,7 +2,7 @@ name: "Hours and My time: the bids of a day as labels, not as a description" number: 469 group: ready -status: asked 2026-12-01 by the owner with a picture of People → Hours · the clock-out list and the Hours row read in the code the same day · the card and the mock-up written · step 1, the kernel, is v2.9153 (2026-12-02) · the owner's answer the same day: the day is to look like the bids worked on in place of the office job · his second answer the same day: the times of the kept bids may ride with the kept list · step 2, the labels on People → Hours, is v2.9158 · step 2a, the stretches kept with the list, is v2.9160 with its migration · step 3's first piece, today's bids on My Time with a press that keeps the list, is v2.9165 · step 2b, the bar of the day under a session on People → Hours, is v2.9189 · step 3's second piece, the day's bids in the day editor, is v2.9194 · the person answered six calls on the rest of My time on 2026-12-03 · the Job Mode card's header counting the day's bids, with a press that opens the list, is v2.9282 · the week's office-job row on My time reading as bids is v2.9283 +status: asked 2026-12-01 by the owner with a picture of People → Hours · the clock-out list and the Hours row read in the code the same day · the card and the mock-up written · step 1, the kernel, is v2.9153 (2026-12-02) · the owner's answer the same day: the day is to look like the bids worked on in place of the office job · his second answer the same day: the times of the kept bids may ride with the kept list · step 2, the labels on People → Hours, is v2.9158 · step 2a, the stretches kept with the list, is v2.9160 with its migration · step 3's first piece, today's bids on My Time with a press that keeps the list, is v2.9165 · step 2b, the bar of the day under a session on People → Hours, is v2.9189 · step 3's second piece, the day's bids in the day editor, is v2.9194 · the person answered six calls on the rest of My time on 2026-12-03 · the Job Mode card's header counting the day's bids, with a press that opens the list, is v2.9282 · the week's office-job row on My time reading as bids is v2.9283 · the person answered six calls on a bid's own page and on Schedule and Dispatch on 2026-12-03, nothing of either built summary: > An estimator's day is clocked to the office job, and the bids she worked on are written into that session's description. The owner wants the bids labelled on her time instead, in a way that @@ -13,7 +13,7 @@ summary: > as labels beside the hours, with what was done on each, a bar of where the bids fell in the day and an honest line of how much of the day the app saw. The note goes back to what a person typed. The session stays on the office job, so pay is not touched. -next: A bid's own page, and the Schedule and Dispatch pages. Their calls are not put to the person yet. My time is done. +next: A bid's own page, then the Schedule and Dispatch pages, each starting with its read on the database. The person answered their six calls on 2026-12-03. My time is done. size: M as a train of six (S · S · M · S · S · not sized); steps 1, 2, 2a and 2b and the first piece of step 3 are built ver: v2.9283 blocker: Nothing. @@ -120,6 +120,33 @@ The card drew none of the steps left, and its one rule was *kept* bids. Six call | W2. A week where only some days kept a list. | **The row reads as bids when any of its days kept a list**, and counts the bids of those days. | | W3. Punch list #473's gap line on the week's list. | **Not drawn there.** The week's list holds no two sessions side by side. #473's line about it is closed. | +## The calls on a bid's own page and on Schedule and Dispatch (the person, 2026-12-03) + +Both steps were walked in the code first. Six calls were put to the person, each with a pick, and they pressed an answer to each. + +**What the walk found.** + +- There is no page for one bid. A bid opens inside the Bids page's tabs. The History window already says who did what and when for one bid, and it opens from the bid's title on every tab. +- Schedule and Dispatch draw schedule blocks, which are the plan. They never draw a clock session. A weekday office block is made for each person on the office roster. +- A kept list exists only after a day's clock out. So only a day already past, or today once the list is kept, can read as bids. +- The kept list's read rule lets a person read their own days and lets the office read everyone's: a dev, a controller, an assistant, and a master with pay access. An estimator, a superintendent and a master without pay access read only their own. + +| The call | The answer | +|---|---| +| V. Who sees the bids another person kept, on a bid's page and on the Schedule. Both are open to people the read rule leaves out. | **Everyone who can open the page.** The pick put was to leave the rule. The person chose the wider read. It is a change on the database, so each step starts with a migration and a push. | +| B1. Where a bid shows who had it in front. | **The History window**, as its own chip, *On the clock*. | +| B2. What a line says. | **The person, the day, what was done, and the size the app saw** from five minutes up: *Dana Whitlock · Tue 1 Dec · changed · 50 min seen*. No hours on the clock, which is punch list #475's ground. | +| S1. Which pages. | **The Schedule page and Dispatch Mode's Schedule tab.** Not Job Mode's own schedule, and not a person's schedule on their sheet. | +| S2. An office block on a day whose bids were kept. | **Its title reads *Bids · 9*** where the office job stood, with the office job on hover. **A press on the block shows the labels.** No label is drawn in the cell. | +| S3. A block on a day with no kept list. | **It reads as the office job, as now.** The app does not guess a day's bids. | + +**Chosen with the calls and not put as calls, to be read by the person.** + +- The wider read is one read function a page, never a wider rule on the table. One answers a bid's lines to whoever can open that bid. One answers the kept bids of people and days to whoever can open the Schedule. +- Neither read hands out the times of day a bid was in front. Those stay with the office, as the yes on People → Hours had it. +- A bid a person took off their list is not shown. On a bid, the newest day is first and a press on a line opens nothing. +- A kept day with no office block draws nothing on the Schedule, since those pages draw blocks. + ## Where it plugs in Almost all of it is client code. No table is new. The card first said one read might need a wider door, and step 1 checked it: the kept rows hold no times, so step 2a adds one column to `bid_day_entries` and `save_my_bid_day` takes it (*Where it stands*). @@ -210,7 +237,7 @@ Two things changed from the first plan while building it. 3. No label shows hours. The notes under the labels keep their hours, and the row's total is the week's hours on the office job. 4. A week with no kept list still reads as the office job. At 390 wide the labels wrap and nothing scrolls sideways. -**Left, in order:** a bid's own page, and the Schedule and Dispatch pages. The calls for both are not put yet. +**Left, in order:** a bid's own page, and the Schedule and Dispatch pages. Their calls are answered under *The calls on a bid's own page and on Schedule and Dispatch*. Neither is built. **Other places that draw a session's note** still show a list written before v2.9158 as words: the pending cell's popover, the approvals queue, Align, the week's sessions window, the match window and the Dashboard's My Team. A follow-up, not this card's train.