improvements: branch reviewed. issues fixed.
This commit is contained in:
@@ -47,4 +47,4 @@ Logical failures: `AppException(ErrorCode.X)` → `errors.X` in en/fa/nl. UI: `g
|
|||||||
|
|
||||||
## Notifications (inbox + live tabs)
|
## Notifications (inbox + live tabs)
|
||||||
|
|
||||||
Header bell: `UserNotification` + Socket.IO. Same `notification.created` also drives sidebar tab badges and soft list refresh on **currently open** Cases/Tasks/Treatment/Orgs pages. A case file upload emits `case-section.changed` on that socket (no inbox row) for the case Files/Messages counts. Inbox + Tasks/Treatment badges use **`CASE_COMPLETED`** (every task in the case done); per-step `TASK_COMPLETED` is timeline-only. Skills: `.cursor/skills/notifications-inbox/SKILL.md`, `.cursor/skills/tab-badges/SKILL.md`.
|
Header bell: `UserNotification` + Socket.IO. Nginx proxies `/socket.io/` to the API in `nginx.conf`, `http-only.conf`, `http-only.dev.conf`, and `nginx.ssl.conf.template`. Same `notification.created` also drives sidebar tab badges and soft list refresh on **currently open** Cases/Tasks/Treatment/Orgs pages. A case file upload emits `case-section.changed` on that socket (no inbox row) for the case Files/Messages counts. Inbox + Tasks/Treatment badges use **`CASE_COMPLETED`** (every task in the case done); per-step `TASK_COMPLETED` is timeline-only. Skills: `.cursor/skills/notifications-inbox/SKILL.md`, `.cursor/skills/tab-badges/SKILL.md`.
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ alwaysApply: false
|
|||||||
- **Send to Exocad:** local DentalDB SQLite write from the case header, every origin, at every screen size, only in Chrome and Edge (`showOpenFilePicker`). Other browsers do not show the button. There is no local helper and no download fallback. A second send updates the same treatment (`importedOrderId`). An empty `externalCode` becomes that Exocad id when the file is written. The browser remembers the file handle only after the DentalDB check. The next send reopens that file when it still exists and skips Browse. A missing file shows Browse again. A file that is not a DentalDB database is not remembered, and Browse stays available. An empty `workParamsSHA` is copied from the newest saved case whose file name ends with `WorkParamsDB.xml` (not `WorkParamsDB-EndoCrown.xml`) onto a new `WorkParamsInfo` and `WorkParamsInfoLocal`. Do not set treatment `flags` to 16. The connect dialog says the feature is experimental and asks for a manual backup; Nudentic is not responsible. A tooth is written only when that work type and material already exist. Monolithic zirconia and PFZ are `Coping`, a pontic is `ReducedPontic`, and the FDI opposite is `Antagonist`/`Healthy` when that pair exists. Parameters come from the fullest saved tooth of the same pair, without shade. A Coping donor is the fullest tooth whose `ImplantType` already matches. `customized_abutment` on that Coping copies `CustomAbutment` only when a saved tooth of the same pair already has it; otherwise that value is not invented. A plain Coping copies `None` when a saved coping has it. Other abutment codes are not mapped. More than one technician is left unset. Client is an exact name, one unique token match, or a new client with the given name, including one word. An empty clinic name still writes the case. A patient name that cannot be split is not written and the toast says why. A new case gets the next `t_schaleId` for that client. After the write, the user can grant the CAD-Data folder so the empty `{date}_{practice}-{tray}` directory is created; cancelling that grant leaves the case in the database. Notes are the comment body. There is no Local database tab. Keep `LocalDbSessionProvider`, the connect dialog, and the file open/write path.
|
- **Send to Exocad:** local DentalDB SQLite write from the case header, every origin, at every screen size, only in Chrome and Edge (`showOpenFilePicker`). Other browsers do not show the button. There is no local helper and no download fallback. A second send updates the same treatment (`importedOrderId`). An empty `externalCode` becomes that Exocad id when the file is written. The browser remembers the file handle only after the DentalDB check. The next send reopens that file when it still exists and skips Browse. A missing file shows Browse again. A file that is not a DentalDB database is not remembered, and Browse stays available. An empty `workParamsSHA` is copied from the newest saved case whose file name ends with `WorkParamsDB.xml` (not `WorkParamsDB-EndoCrown.xml`) onto a new `WorkParamsInfo` and `WorkParamsInfoLocal`. Do not set treatment `flags` to 16. The connect dialog says the feature is experimental and asks for a manual backup; Nudentic is not responsible. A tooth is written only when that work type and material already exist. Monolithic zirconia and PFZ are `Coping`, a pontic is `ReducedPontic`, and the FDI opposite is `Antagonist`/`Healthy` when that pair exists. Parameters come from the fullest saved tooth of the same pair, without shade. A Coping donor is the fullest tooth whose `ImplantType` already matches. `customized_abutment` on that Coping copies `CustomAbutment` only when a saved tooth of the same pair already has it; otherwise that value is not invented. A plain Coping copies `None` when a saved coping has it. Other abutment codes are not mapped. More than one technician is left unset. Client is an exact name, one unique token match, or a new client with the given name, including one word. An empty clinic name still writes the case. A patient name that cannot be split is not written and the toast says why. A new case gets the next `t_schaleId` for that client. After the write, the user can grant the CAD-Data folder so the empty `{date}_{practice}-{tray}` directory is created; cancelling that grant leaves the case in the database. Notes are the comment body. There is no Local database tab. Keep `LocalDbSessionProvider`, the connect dialog, and the file open/write path.
|
||||||
- **One plan:** a live case has one prosthesis plan. Clinic send still uses `treatmentDetailId` as `sourceKey`. Lab-origin cases use the case id. Outsource children use the child case id, or `childId:parentSourceKey` when two selected steps would collide (see Outsource). `LabCaseLine` is gone. Detail and New case use `UnderlineTabs`: Details, Files, Messages. Files and Messages show unread counts (`LabCaseSectionReadState`); opening Details does not clear them. `ATTACHMENT_ADDED` is not a sidebar badge. Origin is one combobox of linked clinics and labs, or a typed name. Dentist/Technician stays optional. Arch jobs (`UA`/`LA`) highlight the read-only FDI chart.
|
- **One plan:** a live case has one prosthesis plan. Clinic send still uses `treatmentDetailId` as `sourceKey`. Lab-origin cases use the case id. Outsource children use the child case id, or `childId:parentSourceKey` when two selected steps would collide (see Outsource). `LabCaseLine` is gone. Detail and New case use `UnderlineTabs`: Details, Files, Messages. Files and Messages show unread counts (`LabCaseSectionReadState`); opening Details does not clear them. `ATTACHMENT_ADDED` is not a sidebar badge. Origin is one combobox of linked clinics and labs, or a typed name. Dentist/Technician stays optional. Arch jobs (`UA`/`LA`) highlight the read-only FDI chart.
|
||||||
- **Case Sheet PDF:** same layout for portrait and landscape (Download PDF menu). One A4 page, scaled to fit — the chart is never split. Header is a flex row: current organization name (one line, 56px line box so html2canvas does not clip the 28px glyphs), Nudentic lockup aligned with that text, share QR at 88px inside a 96px frame with `fill` off (a stretched SVG is dropped by html2canvas; not a table cell). Print root top padding is 16px portrait / 24px landscape so the QR is not clipped; `html2canvas` `scrollY` is 0. The page stays LTR in every locale. On `fa`, the org name is a shrink-wrapped `inline-block` (`direction: ltr` unless the name itself contains Arabic script) with `letter-spacing` and `word-spacing` `0px` — a full-width RTL box gaps Latin words. Party and meta values use `printRtlValueStyle` (Arabic script stays RTL; Latin stays LTR and right-aligned). Section rules keep a 12px gap and 8px padding so the line clears the values; `FA_RULE_DROP` (6px) clears Persian descenders. `onclone` must not overwrite the name span’s direction. Print ink is `prosthesisTypePrintColorFromCatalog` (heaviest family swatch). Prosthesis rows are SVG boxes. Chart is 85% of the page width with capped glyph height, shared upper column widths, outline-only unselected teeth, root vs crown fills, a larger gap under the upper caption, and matching tooth/number/midline gaps on both arches. Bridge marks match the FDI chart: 10px `#009cae` dots on the column boundary in the tooth-to-number gap. `onclone` sizes the lockup SVGs and the organization-name line box. Hex inline styles only. Optional `externalCode` replaces the printed order number and the `case-sheet-{orderNumber}.pdf` filename.
|
- **Case Sheet PDF:** same layout for portrait and landscape (Download PDF menu). One A4 page, scaled to fit — the chart is never split. Header is a flex row: current organization name (one line, 56px line box so html2canvas does not clip the 28px glyphs), Nudentic lockup aligned with that text, share QR at 88px inside a 96px frame with `fill` off (a stretched SVG is dropped by html2canvas; not a table cell). Print root top padding is 16px portrait / 24px landscape so the QR is not clipped; `html2canvas` `scrollY` is 0. The page stays LTR in every locale. On `fa`, the org name is a shrink-wrapped `inline-block` (`direction: ltr` unless the name itself contains Arabic script) with `letter-spacing` and `word-spacing` `0px` — a full-width RTL box gaps Latin words. Party and meta values use `printRtlValueStyle` (Arabic script stays RTL; Latin stays LTR and right-aligned). Section rules keep a 12px gap and 8px padding so the line clears the values; `FA_RULE_DROP` (6px) clears Persian descenders. `onclone` must not overwrite the name span’s direction. Print ink is `prosthesisTypePrintColorFromCatalog` (heaviest family swatch). Prosthesis rows are SVG boxes. Chart is 85% of the page width with capped glyph height, shared upper column widths, outline-only unselected teeth, root vs crown fills, a larger gap under the upper caption, and matching tooth/number/midline gaps on both arches. Bridge marks match the FDI chart: 10px `#009cae` dots on the column boundary in the tooth-to-number gap. `onclone` sizes the lockup SVGs and the organization-name line box. Hex inline styles only. Optional `externalCode` replaces the printed order number and the `case-sheet-{orderNumber}.pdf` filename.
|
||||||
- **Detail chrome:** The header follows the detail panel width (`@container`, not the viewport): two columns (info start, actions end) from `@2xl`, otherwise one stack with the buttons under the info: name and the same QR thumb (`w-24 sm:w-32`) on the first row, mobile/from/date on one wrapping line, then progress bar, external code, **Mark as important**, and billed, stacked and left aligned. Edit / Outsource / Send to Exocad / Get PDF are one equal-width grid (`responsiveFill`, truncating caption): 2 columns when narrow, one column per button from `@xl`, 2 columns in the `@2xl` end column with the QR below. Get PDF is a primary `CaseLifecycleButton` with no icon. Add files uses that button at the treatment action width. **Add case** is a full-width `px-6 py-3 text-base` split (label + mic) matching New treatment and Add detail voice. There is no Comments button, and opening Messages does not scroll the page. File cards: name at the start and checkbox at the end, then a clipped preview, then size over date at the start with the View/Download menu centered at the end. Remove is on that menu (`DELETE /cases/:id/attachments/:attachmentId`, confirm first). An in-progress upload is its own card with a progress bar. The sent-date line reads “Outsource {date}”.
|
- **Detail chrome:** The header follows the detail panel width (`@container`, not the viewport): two columns (info start, actions end) from `@2xl`, otherwise one stack with the buttons under the info: name and the same QR thumb (`w-24 sm:w-32`) on the first row, mobile/from/date on one wrapping line, then progress bar, external code, **Mark as important**, and billed, stacked and left aligned. The destination lab with `TAB_BILLING_EDIT` edits that fee (`PUT /billing/cases/:id/amount`) and the open case updates immediately; anyone else sees the stored fee, or the calculated quote when no fee is stored. Edit / Outsource / Send to Exocad / Get PDF are one equal-width grid (`responsiveFill`, truncating caption): 2 columns when narrow, one column per button from `@xl`, 2 columns in the `@2xl` end column with the QR below. Get PDF is a primary `CaseLifecycleButton` with no icon. Add files uses that button at the treatment action width. **Add case** is a full-width `px-6 py-3 text-base` split (label + mic) matching New treatment and Add detail voice. There is no Comments button, and opening Messages does not scroll the page. File cards: name at the start and checkbox at the end, then a clipped preview, then size over date at the start with the View/Download menu centered at the end. Remove is on that menu (`DELETE /cases/:id/attachments/:attachmentId`, confirm first). An in-progress upload is its own card with a progress bar. The sent-date line reads “Outsource {date}”.
|
||||||
- **Attachments:** no size cap. One file per request, streamed with `orgDiskStorage` (not memory). The client has no axios timeout. The upload queue sits with the toast, so leaving Files or Cases does not cancel it and does not refetch the case; the open case patches from the response. A draft flushes once, then keeps the new file id so autosave does not unlink it. Nginx `/api` uses `client_max_body_size 0`, `send_timeout 3600s`, and `proxy_request_buffering off`. JSON bodies stay on the Express limit; only multipart is unlimited. Production must recreate nginx from the SSL template. Staging also needs the Windows host nginx reloaded. Do not set `Content-Type: multipart/form-data` by hand.
|
- **Attachments:** no size cap. One file per request, streamed with `orgDiskStorage` (not memory). The client has no axios timeout. The upload queue sits with the toast, so leaving Files or Cases does not cancel it and does not refetch the case; the open case patches from the response. A draft flushes once, then keeps the new file id so autosave does not unlink it. Nginx `/api` uses `client_max_body_size 0`, `send_timeout 3600s`, and `proxy_request_buffering off`. JSON bodies stay on the Express limit; only multipart is unlimited. Production must recreate nginx from the SSL template. Staging also needs the Windows host nginx reloaded. Do not set `Content-Type: multipart/form-data` by hand.
|
||||||
- **Drafts rail:** unstarted lab-origin cases sit in a collapsed `TreatmentRailSection`; expands on click or **Add case**. Main list is received + started cases (`drafts=exclude` / `drafts=only`), newest first by `listedAt` (`LAB_CASE_LIST_ORDER_BY`; trigger `lab_cases_listed_at_sync` = `COALESCE(startedAt, sentAt)`). Never `orderBy startedAt, sentAt` and never a `GENERATED ALWAYS` `listedAt`.
|
- **Drafts rail:** unstarted lab-origin cases sit in a collapsed `TreatmentRailSection`; expands on click or **Add case**. Main list is received + started cases (`drafts=exclude` / `drafts=only`), newest first by `listedAt` (`LAB_CASE_LIST_ORDER_BY`; trigger `lab_cases_listed_at_sync` = `COALESCE(startedAt, sentAt)`). Never `orderBy startedAt, sentAt` and never a `GENERATED ALWAYS` `listedAt`.
|
||||||
- **Add case / Start / Delete draft:** `TAB_CASES_EDIT`. The rail button is full width. Its mic uses the existing lab voice apply on that case’s one plan (blank plan replaced, existing jobs merged). No draft yet → create the draft, then record. Delete only unstarted lab-origin drafts (`origin === LAB_INTERNAL && !startedAt`). Comments on Cases accept `TAB_CASES_*` (owners are not blocked by Tasks opt-in).
|
- **Add case / Start / Delete draft:** `TAB_CASES_EDIT`. The rail button is full width. Its mic uses the existing lab voice apply on that case’s one plan (blank plan replaced, existing jobs merged). No draft yet → create the draft, then record. Delete only unstarted lab-origin drafts (`origin === LAB_INTERNAL && !startedAt`). Comments on Cases accept `TAB_CASES_*` (owners are not blocked by Tasks opt-in).
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ alwaysApply: false
|
|||||||
- **Tooth hits:** unrotated full cell, `pointerdown` only (not `click` too — double-toggles). Glyph `pointer-events-none`; nest scale/hover inside the rotate wrapper. Groups: `toothSelectionGroups.ts` (never 1-tooth connected); prune lab `toothProsthesis` on change. Done stores a jobs copy brush; **Clear this tooth** stores a clear brush. Ctrl/Cmd+click, drag, and Shift+range replay either action. Reset brush/range state whenever `detailClientId` changes so actions never cross details/lines.
|
- **Tooth hits:** unrotated full cell, `pointerdown` only (not `click` too — double-toggles). Glyph `pointer-events-none`; nest scale/hover inside the rotate wrapper. Groups: `toothSelectionGroups.ts` (never 1-tooth connected); prune lab `toothProsthesis` on change. Done stores a jobs copy brush; **Clear this tooth** stores a clear brush. Ctrl/Cmd+click, drag, and Shift+range replay either action. Reset brush/range state whenever `detailClientId` changes so actions never cross details/lines.
|
||||||
- **Pontic picker:** Pontic remains selectable for pontic-first entry, but its empty suggestion slot appears only beside an immediate crown/indirect neighbor (filled stays visible). A tooth immediately beside Pontic initially enables Crown, Indirect, and Pontic (Pontic chains are allowed); assigning a Crown immediately enables Implant on that tooth, while Indirect does not. Changing one connected abutment restoration changes every restoration abutment in that Pontic span while preserving each tooth’s root/implant jobs. Removable on an FDI tooth shows the full-arch notice; only partial denture is tooth-selected.
|
- **Pontic picker:** Pontic remains selectable for pontic-first entry, but its empty suggestion slot appears only beside an immediate crown/indirect neighbor (filled stays visible). A tooth immediately beside Pontic initially enables Crown, Indirect, and Pontic (Pontic chains are allowed); assigning a Crown immediately enables Implant on that tooth, while Indirect does not. Changing one connected abutment restoration changes every restoration abutment in that Pontic span while preserving each tooth’s root/implant jobs. Removable on an FDI tooth shows the full-arch notice; only partial denture is tooth-selected.
|
||||||
- **Day strip:** `ScheduleDayPicker` `compact` centered in the header. Timed cards use purpose banners. Unscheduled cards use the same banner from the **first detail’s type only** (live draft for the open card); empty first line keeps chip theming. Trash inherits banner ink. Strip-delete only when `areUnscheduledDetailsStripDeletable` (blank lines or `[]`); persist `[]` then `DELETE /treatments/:id`.
|
- **Day strip:** `ScheduleDayPicker` `compact` centered in the header. Timed cards use purpose banners. Unscheduled cards use the same banner from the **first detail’s type only** (live draft for the open card); empty first line keeps chip theming. Trash inherits banner ink. Strip-delete only when `areUnscheduledDetailsStripDeletable` (blank lines or `[]`); persist `[]` then `DELETE /treatments/:id`.
|
||||||
- **Lab dispatch UI:** due date end-aligned beside title (`sm:flex-row` + `justify-between`; stacks on mobile). Job list is `LabCaseToothJobsList` → `ProsthesisJobLineLabel` (`13 · Pontic - 14 · PFZ Crown`; inherit `text-xs`; no category). Same-type teeth in one detail share a row; Connected badge only for a real bridge. Content clinical field = **Notes** (not case comments). Sent cases: dest/jobs share a row with the Cases QR thumb; tracker + comments are **full width below** the QR.
|
- **Lab dispatch UI:** due date end-aligned beside title (`sm:flex-row` + `justify-between`; stacks on mobile). Job list is `LabCaseToothJobsList` → `ProsthesisJobLineLabel` (`13 · Pontic - 14 · PFZ Crown`; inherit `text-xs`; no category). Same-type teeth in one detail share a row; Connected badge only for a real bridge. Content clinical field = **Notes** (not case comments). Sent cases: dest/jobs share a row with the Cases QR thumb; tracker + comments are **full width below** the QR. The fee line uses the draft’s `billedAmount` (mapped from the API and the send response). A sent case with no fee shows `labFeeSentNeedsAmount`.
|
||||||
- **Lab comments:** shared `LabCaseCommentsPanel` (newest-first; sent=`justify-start`, received=`justify-end`; `viewerSide`) across Treatment / Cases / Tasks / share. Use logical `text-start`/`text-end`, not left/right.
|
- **Lab comments:** shared `LabCaseCommentsPanel` (newest-first; sent=`justify-start`, received=`justify-end`; `viewerSide`) across Treatment / Cases / Tasks / share. Use logical `text-start`/`text-end`, not left/right.
|
||||||
- **Detail chrome:** chips (type + teeth) + Add at top; **Remove** = trash on chip (unsent, including last line; disabled when day-locked / no edit / uploading). Last-line confirm: plan will be empty until Add. Empty `[]` shows `noDetails` (not the type-first overlay). New treatment seeds one blank detail. No delete in type/notes fields.
|
- **Detail chrome:** chips (type + teeth) + Add at top; **Remove** = trash on chip (unsent, including last line; disabled when day-locked / no edit / uploading). Last-line confirm: plan will be empty until Add. Empty `[]` shows `noDetails` (not the type-first overlay). New treatment seeds one blank detail. No delete in type/notes fields.
|
||||||
- **Patient search:** `PatientSearchCombobox` in the **page header** (workspace-wide). Opens today’s strip visit if any, else latest history. No visit/history → inline editor empty state pointing to **New treatment** (never a dialog, never auto-create). **New treatment** stays at the top of the left rail; selected-patient card sits under it. Below `xl`, that card stays on the editor screen; history is the pane behind **History**. Picker: Walk-in first, then a matching full-width card for the current named patient (name + mobile/email, else hint), then search. Never auto-create from the appointment card.
|
- **Patient search:** `PatientSearchCombobox` in the **page header** (workspace-wide). Opens today’s strip visit if any, else latest history. No visit/history → inline editor empty state pointing to **New treatment** (never a dialog, never auto-create). **New treatment** stays at the top of the left rail; selected-patient card sits under it. Below `xl`, that card stays on the editor screen; history is the pane behind **History**. Picker: Walk-in first, then a matching full-width card for the current named patient (name + mobile/email, else hint), then search. Never auto-create from the appointment card.
|
||||||
|
|||||||
@@ -75,8 +75,8 @@ Keep chrome identical: `BillingListToolbar`, outline labels, `AppMoneyInput`, eq
|
|||||||
- One sheet on the Commissions/Salary tab, beside **New commission schedule**. It lists the owner and every active member. `PUT /billing/staff-salaries` updates `Membership.fixedMonthlySalary` and does not create a ledger row or a new sheet.
|
- One sheet on the Commissions/Salary tab, beside **New commission schedule**. It lists the owner and every active member. `PUT /billing/staff-salaries` updates `Membership.fixedMonthlySalary` and does not create a ledger row or a new sheet.
|
||||||
- After the first save, a Staff salary section with one Edit row sits above Commission history. `Organization.staffSalaryUpdatedAt` is that marker.
|
- After the first save, a Staff salary section with one Edit row sits above Commission history. `Organization.staffSalaryUpdatedAt` is that marker.
|
||||||
- The hourly job writes a finished month only. Commission is that month's earnings. Salary is the full sheet amount, snapshotted once; a later edit does not change it. A month the server missed is closed on the next run with the rate on the sheet then. Rows are dated on the last day. The open month is a calculated preview only. Toman uses Jalali months; Dollar/Euro use Gregorian months.
|
- The hourly job writes a finished month only. Commission is that month's earnings. Salary is the full sheet amount, snapshotted once; a later edit does not change it. A month the server missed is closed on the next run with the rate on the sheet then. Rows are dated on the last day. The open month is a calculated preview only. Toman uses Jalali months; Dollar/Euro use Gregorian months.
|
||||||
- Staff summary subtotals come from those closed rows in the active date range: commission + fixed salary = gross. Cash affects net only. Staff cash remains `StaffPayment`.
|
- Staff summary subtotals include the closed rows in the date range and, while the month is open, the unsaved preview. Commission + fixed salary = gross. Cash affects net only. Staff cash remains `StaffPayment`.
|
||||||
- V1 deliberately has no attendance, proration, bonus, or payroll-tax model.
|
- The stored month-end salary is the full sheet amount. The open-month preview is that amount times days elapsed over days in the month. V1 has no attendance, bonus, or payroll-tax model.
|
||||||
|
|
||||||
## Deep links
|
## Deep links
|
||||||
|
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ List item shape: `prosthesisGroups: { prosthesisTypeCode, teeth[], ponticTeeth?
|
|||||||
- **Important + external code** (`TAB_CASES_EDIT`): **Mark as important** is centered in the header on `lg`. Below `lg` the header is one compact stack: name and the desktop QR thumb (`w-24 sm:w-32`) on the first row, mobile / from / date on one wrapping line, the progress bar (no separate “tasks completed” sentence), important and billed on one row, and Edit / Outsource / Get PDF sharing one row (`CaseLifecycleButton` `responsiveFill`). External code is under the progress bar in the start column, same width as the bar (no title; placeholder only); billed price is under important on `lg`. Save code on blur → `PATCH /cases/:id/external-code`. Edit, Outsource, Get PDF, and Add files use `CaseLifecycleButton` (primary, no icon; Treatment Lab dispatch / Chart / Add detail width from `lg` up). **Add case** is full width at New treatment size (`px-6 py-3 text-base`) and, when voice is available, splits like Add detail: label starts a blank draft, the mic records against the open draft (or creates one first). Apply still fills that case’s single plan. There is no second mic on the Details tab. There is no Comments button. Opening Messages does not scroll the page. Start and Delete on a draft use the lifecycle width. The sent-date line is `cases.sentAt` (“Outsource {date}”). File cards (`CaseFilesPanel`): name at the start and checkbox at the end, a clipped preview between them and the footer, then size over date at the start with the View/Download menu centered at the end. Each file being uploaded is its own card with a progress bar (one request per file). The job lives above the page, so leaving Files or Cases does not cancel it; coming back shows the same card. Finishing patches the open case from the upload response. It does not fetch the case again. A draft flushes once before the batch, then keeps the new file id locally so a later autosave does not unlink it. Remove one file from that menu after confirm (`DELETE /cases/:id/attachments/:attachmentId`): a clinic file still on a treatment is unlinked only; a lab upload with `detailId` null and no other case link is deleted from the database and disk. Tasks stays view-only.
|
- **Important + external code** (`TAB_CASES_EDIT`): **Mark as important** is centered in the header on `lg`. Below `lg` the header is one compact stack: name and the desktop QR thumb (`w-24 sm:w-32`) on the first row, mobile / from / date on one wrapping line, the progress bar (no separate “tasks completed” sentence), important and billed on one row, and Edit / Outsource / Get PDF sharing one row (`CaseLifecycleButton` `responsiveFill`). External code is under the progress bar in the start column, same width as the bar (no title; placeholder only); billed price is under important on `lg`. Save code on blur → `PATCH /cases/:id/external-code`. Edit, Outsource, Get PDF, and Add files use `CaseLifecycleButton` (primary, no icon; Treatment Lab dispatch / Chart / Add detail width from `lg` up). **Add case** is full width at New treatment size (`px-6 py-3 text-base`) and, when voice is available, splits like Add detail: label starts a blank draft, the mic records against the open draft (or creates one first). Apply still fills that case’s single plan. There is no second mic on the Details tab. There is no Comments button. Opening Messages does not scroll the page. Start and Delete on a draft use the lifecycle width. The sent-date line is `cases.sentAt` (“Outsource {date}”). File cards (`CaseFilesPanel`): name at the start and checkbox at the end, a clipped preview between them and the footer, then size over date at the start with the View/Download menu centered at the end. Each file being uploaded is its own card with a progress bar (one request per file). The job lives above the page, so leaving Files or Cases does not cancel it; coming back shows the same card. Finishing patches the open case from the upload response. It does not fetch the case again. A draft flushes once before the batch, then keeps the new file id locally so a later autosave does not unlink it. Remove one file from that menu after confirm (`DELETE /cases/:id/attachments/:attachmentId`): a clinic file still on a treatment is unlinked only; a lab upload with `detailId` null and no other case link is deleted from the database and disk. Tasks stays view-only.
|
||||||
- FDI chart (`CaseToothChartPanel`): prosthesis colors + **connected bridge dots** from `selectionGroupId` (`buildCaseConnectedTeeth` / `buildCaseProsthesisRows` in `caseDetailUtils.ts`).
|
- FDI chart (`CaseToothChartPanel`): prosthesis colors + **connected bridge dots** from `selectionGroupId` (`buildCaseConnectedTeeth` / `buildCaseProsthesisRows` in `caseDetailUtils.ts`).
|
||||||
- **Important + external code** (`TAB_CASES_EDIT`): **Mark as important** and the billed price sit under the external code field. The header layout follows the detail panel width (Tailwind container query `@container`, not the viewport). From `@2xl` (42rem) it is two columns (info start, actions end). Narrower, including the split list/detail view on a small laptop and phones, it is one stack with the buttons under the info: name and the desktop QR thumb (`w-24 sm:w-32`) on the first row, mobile / from / date on one wrapping line, then the progress bar (no separate “tasks completed” sentence), external code, important, and billed, stacked. The action buttons (Edit, Outsource, Send to Exocad, Get PDF) are one equal-width grid (`CaseLifecycleButton` `responsiveFill`, truncating caption): 2 columns when the panel is narrow, one equal column per button from `@xl`, 2 columns again in the `@2xl` end column (`@2xl:w-72`), with the QR below. A lone last button spans both columns. Send to Exocad shows at every screen size, but only when the browser can overwrite the picked file (Chrome and Edge). External code is the same width as the progress bar (no title; placeholder only). Save code on blur → `PATCH /cases/:id/external-code`. Add files uses that button at the treatment action width. **Add case** is full width at New treatment size (`px-6 py-3 text-base`) and, when voice is available, splits like Add detail: label starts a blank draft, the mic records against the open draft (or creates one first). Apply still fills that case’s single plan. There is no second mic on the Details tab. There is no Comments button. Opening Messages does not scroll the page. Start and Delete on a draft use the lifecycle width. The sent-date line is `cases.sentAt` (“Outsource {date}”). File cards (`CaseFilesPanel`): name at the start and checkbox at the end, a clipped preview between them and the footer, then size over date at the start with the View/Download menu centered at the end. Each file being uploaded is its own card with a progress bar (one request per file). The job lives above the page, so leaving Files or Cases does not cancel it; coming back shows the same card. Finishing patches the open case from the upload response. It does not fetch the case again. A draft flushes once before the batch, then keeps the new file id locally so a later autosave does not unlink it. Remove one file from that menu after confirm (`DELETE /cases/:id/attachments/:attachmentId`): a clinic file still on a treatment is unlinked only; a lab upload with `detailId` null and no other case link is deleted from the database and disk. Tasks stays view-only.
|
- **Important + external code** (`TAB_CASES_EDIT`): **Mark as important** and the billed price sit under the external code field. The header layout follows the detail panel width (Tailwind container query `@container`, not the viewport). From `@2xl` (42rem) it is two columns (info start, actions end). Narrower, including the split list/detail view on a small laptop and phones, it is one stack with the buttons under the info: name and the desktop QR thumb (`w-24 sm:w-32`) on the first row, mobile / from / date on one wrapping line, then the progress bar (no separate “tasks completed” sentence), external code, important, and billed, stacked. The action buttons (Edit, Outsource, Send to Exocad, Get PDF) are one equal-width grid (`CaseLifecycleButton` `responsiveFill`, truncating caption): 2 columns when the panel is narrow, one equal column per button from `@xl`, 2 columns again in the `@2xl` end column (`@2xl:w-72`), with the QR below. A lone last button spans both columns. Send to Exocad shows at every screen size, but only when the browser can overwrite the picked file (Chrome and Edge). External code is the same width as the progress bar (no title; placeholder only). Save code on blur → `PATCH /cases/:id/external-code`. Add files uses that button at the treatment action width. **Add case** is full width at New treatment size (`px-6 py-3 text-base`) and, when voice is available, splits like Add detail: label starts a blank draft, the mic records against the open draft (or creates one first). Apply still fills that case’s single plan. There is no second mic on the Details tab. There is no Comments button. Opening Messages does not scroll the page. Start and Delete on a draft use the lifecycle width. The sent-date line is `cases.sentAt` (“Outsource {date}”). File cards (`CaseFilesPanel`): name at the start and checkbox at the end, a clipped preview between them and the footer, then size over date at the start with the View/Download menu centered at the end. Each file being uploaded is its own card with a progress bar (one request per file). The job lives above the page, so leaving Files or Cases does not cancel it; coming back shows the same card. Finishing patches the open case from the upload response. It does not fetch the case again. A draft flushes once before the batch, then keeps the new file id locally so a later autosave does not unlink it. Remove one file from that menu after confirm (`DELETE /cases/:id/attachments/:attachmentId`): a clinic file still on a treatment is unlinked only; a lab upload with `detailId` null and no other case link is deleted from the database and disk. Tasks stays view-only.
|
||||||
|
- **Case fee:** only the destination lab (`destinationOrganizationId` on the case detail) with `TAB_BILLING_EDIT` edits the billed amount. Save calls `PUT /billing/cases/:id/amount` and updates the open case through `onCaseUpdated`. Other viewers see the stored fee, or the calculated quote when none is stored.
|
||||||
- **Section badges:** Files counts `ATTACHMENT_ADDED` and Messages counts `LAB_COMMENT` / `CLINIC_COMMENT`, after `LabCaseSectionReadState`, excluding the actor. `GET /cases/:id/section-counts`. `POST /cases/:id/sections/:section/read` only when that tab is open and its count is greater than 0. Opening Details does not clear them. Uploads emit `case-section.changed` to other lab members who can read Cases or Tasks (no inbox card). The existing socket turns that into `tab-badges-changed`. `ATTACHMENT_ADDED` is not a sidebar Cases/Tasks/Treatment count. `LabCaseSectionReadState` has a composite id and stays off the AdminJS allowlist.
|
- **Section badges:** Files counts `ATTACHMENT_ADDED` and Messages counts `LAB_COMMENT` / `CLINIC_COMMENT`, after `LabCaseSectionReadState`, excluding the actor. `GET /cases/:id/section-counts`. `POST /cases/:id/sections/:section/read` only when that tab is open and its count is greater than 0. Opening Details does not clear them. Uploads emit `case-section.changed` to other lab members who can read Cases or Tasks (no inbox card). The existing socket turns that into `tab-badges-changed`. `ATTACHMENT_ADDED` is not a sidebar Cases/Tasks/Treatment count. `LabCaseSectionReadState` has a composite id and stays off the AdminJS allowlist.
|
||||||
- **Attachment uploads:** no size limit in multer, axios, or nginx `/api` (`client_max_body_size 0`, `client_body_timeout 3600s`, `send_timeout 3600s`, `proxy_request_buffering off`, proxy read/send 3600s). The server-level `send_timeout 10` would cut a paused download, so `/api` overrides it. JSON and urlencoded bodies stay on the Express limits; only multipart is unlimited. Files stream to disk via `orgDiskStorage` under `uploads/lab-cases/{orgId}` (treatment uploads use `uploads/treatments`). The attachment row and the case link are one transaction; the disk file is removed only after that transaction commits on delete, and only for a lab-owned upload. A failed activity row does not fail the upload. Do not buffer the file in memory and do not set `Content-Type: multipart/form-data` yourself — that drops the boundary. Releasing this needs `prisma migrate deploy` (the backend container runs it on start; Postgres 15) and a nginx recreate from `nginx.ssl.conf.template`. Staging’s Windows host nginx is a separate paste-and-reload of `windows-edge-http.conf`; Docker alone leaves the 50MB edge. Uploaded bytes live on the backend container disk (`/app/uploads`, no volume) and can fill that disk.
|
- **Attachment uploads:** no size limit in multer, axios, or nginx `/api` (`client_max_body_size 0`, `client_body_timeout 3600s`, `send_timeout 3600s`, `proxy_request_buffering off`, proxy read/send 3600s). The server-level `send_timeout 10` would cut a paused download, so `/api` overrides it. JSON and urlencoded bodies stay on the Express limits; only multipart is unlimited. Files stream to disk via `orgDiskStorage` under `uploads/lab-cases/{orgId}` (treatment uploads use `uploads/treatments`). The attachment row and the case link are one transaction; the disk file is removed only after that transaction commits on delete, and only for a lab-owned upload. A failed activity row does not fail the upload. Do not buffer the file in memory and do not set `Content-Type: multipart/form-data` yourself — that drops the boundary. Releasing this needs `prisma migrate deploy` (the backend container runs it on start; Postgres 15) and a nginx recreate from `nginx.ssl.conf.template`. Staging’s Windows host nginx is a separate paste-and-reload of `windows-edge-http.conf`; Docker alone leaves the 50MB edge. Uploaded bytes live on the backend container disk (`/app/uploads`, no volume) and can fill that disk.
|
||||||
- **Case Sheet PDF** — see below.
|
- **Case Sheet PDF** — see below.
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ Billing notices go to `TAB_BILLING_READ`, including the actor: `BILLING_CASE_FEE
|
|||||||
|
|
||||||
**Inbox card context** is denormalized inside `UserNotificationService.notify()` (`enrichInboxPayload`) from ids already on the payload (`labCaseId`, `taskId`, `fromOrganizationId`). Emit sites stay thin (`{ labCaseId }`, etc.). Inbox list/read does **not** join related tables. Older rows may lack these fields until new events are emitted.
|
**Inbox card context** is denormalized inside `UserNotificationService.notify()` (`enrichInboxPayload`) from ids already on the payload (`labCaseId`, `taskId`, `fromOrganizationId`). Emit sites stay thin (`{ labCaseId }`, etc.). Inbox list/read does **not** join related tables. Older rows may lack these fields until new events are emitted.
|
||||||
|
|
||||||
**Realtime auth:** after access-token refresh (proactive, axios 401 retry, or `checkAuth`), frontend dispatches `dyolink:access-token-refreshed` so `RealtimeProvider` reconnects with the new cookie.
|
**Realtime auth:** after access-token refresh (proactive, axios 401 retry, or `checkAuth`), frontend dispatches `dyolink:access-token-refreshed` so `RealtimeProvider` reconnects with the new cookie. Nginx must proxy `/socket.io/` to the API. That block is in `nginx.conf`, `http-only.conf`, `http-only.dev.conf`, and `nginx.ssl.conf.template`. A `location /` that only reaches Next.js drops the socket.
|
||||||
|
|
||||||
## Frontend UI
|
## Frontend UI
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ Right-column entry is **not** a three-step wizard. Type dropdown + `TreatmentDet
|
|||||||
| Stage | UI | When |
|
| Stage | UI | When |
|
||||||
|-------|-----|------|
|
|-------|-----|------|
|
||||||
| **Treatment** | Type dropdown + `TreatmentDetailAttachmentsStrip`, `FdiToothChart` / `ProsthesisAssignChart`, full-width Notes | Default |
|
| **Treatment** | Type dropdown + `TreatmentDetailAttachmentsStrip`, `FdiToothChart` / `ProsthesisAssignChart`, full-width Notes | Default |
|
||||||
| **Lab** | `LabCasesDispatchPanel` in the chart slot | Lab-dependent type + user clicks **Lab dispatch** (or rail / Go to dispatch). Auto-ensures a shipment draft (teeth/arch not required to create the draft). **No default lab or prosthesis type** on a new detail (including siblings in the same plan). Last **3 sent** labs appear as chips under search — pick is explicit. Comments stay on the dispatch panel. After send, the same case QR as lab Cases is shown (`shareUrl`): dest/jobs share a row with the thumb; tracker + comments are full width below. |
|
| **Lab** | `LabCasesDispatchPanel` in the chart slot | Lab-dependent type + user clicks **Lab dispatch** (or rail / Go to dispatch). Auto-ensures a shipment draft (teeth/arch not required to create the draft). **No default lab or prosthesis type** on a new detail (including siblings in the same plan). Last **3 sent** labs appear as chips under search — pick is explicit. Comments stay on the dispatch panel. After send, the same case QR as lab Cases is shown (`shareUrl`): dest/jobs share a row with the thumb; tracker + comments are full width below. The stored lab fee (`billedAmount` on the lab-case draft, kept from the send response) is shown under that; a sent case with no fee uses `labFeeSentNeedsAmount`, not the pre-send unpriced copy. |
|
||||||
|
|
||||||
- Prosthesis types are assigned on the chart (`ProsthesisAssignChart` + `ProsthesisJobPopover`; stacking / disable / suggestion slots in `pickerPolicy()` in `prosthesisTree.ts`). The picker is two columns (`4fr` wrapping category grid / `1fr` add-ons) with a vertical `border-e` divider. Category and subcategory tiles (and matching leaves) show SVGs from `src/assets/prosthesis-catalog` (served from `public/prosthesis-catalog`) via `ProsthesisCatalogIcon` + `prosthesisCatalogIcons.ts`. Production Docker must copy `public/` into the standalone image (see `.cursor/rules/frontend-assets.mdc`). **Category / filled addon** tiles use `md` icons on a shared `items-end` stage and a reserved two-line label (`/` wraps with `<wbr>`). **Subcategory / leaf** tiles use `sm` icons, one-line ellipsis labels, and vertically center icon+label (`min-h-[4.25rem]`); implant/post-core use a taller box so they stay inside the card. Family pastels: `PROSTHESIS_CATEGORY_COLORS` (indirect/veneer sky, implant green, pontic orange, removable pink, appliance aqua). Screen type names: `prosthesisTypeLabelStyleFromCatalog`; Case Sheet print hex: `prosthesisTypeLabelColorFromCatalog`. Category tiles keep the wrapping `minmax(8rem, 1fr)` grid and stretch to fill the overlay; expanded children use `minmax(10.2rem, 1fr)` with a parent-colored **L** rail sized to the first child card (not a per-card tree). Parent-bar back arrow is black. Child labels stay one line and ellipsize (`…`) when they overflow. **Add detail**, Lab dispatch, and Chart share one control width (`WorkspaceActionLabel` in `TreatmentDetailsEditor`). Indirect children are **Veneer → Inlay → Onlay → Overlay** (same order as the category title). Crown leaves without a dedicated SVG use the monolithic zirconia drawing, not the Crown parent icon. Empty crown suggestion: plus + dashed chip (`addonCrownCanBeAdded`) inside a full-height slot; after a crown is picked the slot stays as the filled type chip. **Pontic** uses that same column whenever `pickerPolicy()` enables the Pontic tile (`addonPonticCanBeAdded`; filled chip after apply; click applies immediately). Arch Upper/Lower/Both is a compact `h-8` segmented control at half the tree column width — it **is** the assignment (`retargetArchJobs`): Both→Upper/Lower drops the other jaw; Upper/Lower→Both copies the type onto the empty jaw; Upper↔Lower moves the job. Chart Upper/Lower arch labels are dashed outline buttons with plus (open the picker; control shows current jobs, or the clicked jaw if none). Category parents use the heaviest family pastel; children only lighten. One **restoration** per tooth (crown / veneer-inlay-onlay-overlay). **Screw-retained** is implant (`stackGroup: implant`, paints the crown) and is itself the restoration — no crown suggestion slot, and Crown / Indirect are disabled. Implant or post & core (without a non-crown restoration) shows a **crown** suggestion slot. A veneer/inlay/onlay/overlay hides the suggestion slot. **Post & core** category is visible but disabled when a restoration or implant is on the tooth. **Implant** category is disabled when post & core is on the tooth. Complete denture / overdenture / appliances / digital use **Upper arch / Lower arch** (`UA`/`LA`). **Partial denture** is tooth-level (select FDI teeth, Removable in the tooth picker); after send it is **one lab job** for all those teeth. Picker leaves are filtered by `chartRegion` so Removable appears in both tooth and arch pickers. Prosthesis FDI teeth **must** have jobs — never persist selected teeth without `toothProsthesis` (`pruneDetailTeethToJobs`). Catalog has no `addonKind` — stacking uses `stackGroup` plus `pickerPolicy()` suggestion slots.
|
- Prosthesis types are assigned on the chart (`ProsthesisAssignChart` + `ProsthesisJobPopover`; stacking / disable / suggestion slots in `pickerPolicy()` in `prosthesisTree.ts`). The picker is two columns (`4fr` wrapping category grid / `1fr` add-ons) with a vertical `border-e` divider. Category and subcategory tiles (and matching leaves) show SVGs from `src/assets/prosthesis-catalog` (served from `public/prosthesis-catalog`) via `ProsthesisCatalogIcon` + `prosthesisCatalogIcons.ts`. Production Docker must copy `public/` into the standalone image (see `.cursor/rules/frontend-assets.mdc`). **Category / filled addon** tiles use `md` icons on a shared `items-end` stage and a reserved two-line label (`/` wraps with `<wbr>`). **Subcategory / leaf** tiles use `sm` icons, one-line ellipsis labels, and vertically center icon+label (`min-h-[4.25rem]`); implant/post-core use a taller box so they stay inside the card. Family pastels: `PROSTHESIS_CATEGORY_COLORS` (indirect/veneer sky, implant green, pontic orange, removable pink, appliance aqua). Screen type names: `prosthesisTypeLabelStyleFromCatalog`; Case Sheet print hex: `prosthesisTypeLabelColorFromCatalog`. Category tiles keep the wrapping `minmax(8rem, 1fr)` grid and stretch to fill the overlay; expanded children use `minmax(10.2rem, 1fr)` with a parent-colored **L** rail sized to the first child card (not a per-card tree). Parent-bar back arrow is black. Child labels stay one line and ellipsize (`…`) when they overflow. **Add detail**, Lab dispatch, and Chart share one control width (`WorkspaceActionLabel` in `TreatmentDetailsEditor`). Indirect children are **Veneer → Inlay → Onlay → Overlay** (same order as the category title). Crown leaves without a dedicated SVG use the monolithic zirconia drawing, not the Crown parent icon. Empty crown suggestion: plus + dashed chip (`addonCrownCanBeAdded`) inside a full-height slot; after a crown is picked the slot stays as the filled type chip. **Pontic** uses that same column whenever `pickerPolicy()` enables the Pontic tile (`addonPonticCanBeAdded`; filled chip after apply; click applies immediately). Arch Upper/Lower/Both is a compact `h-8` segmented control at half the tree column width — it **is** the assignment (`retargetArchJobs`): Both→Upper/Lower drops the other jaw; Upper/Lower→Both copies the type onto the empty jaw; Upper↔Lower moves the job. Chart Upper/Lower arch labels are dashed outline buttons with plus (open the picker; control shows current jobs, or the clicked jaw if none). Category parents use the heaviest family pastel; children only lighten. One **restoration** per tooth (crown / veneer-inlay-onlay-overlay). **Screw-retained** is implant (`stackGroup: implant`, paints the crown) and is itself the restoration — no crown suggestion slot, and Crown / Indirect are disabled. Implant or post & core (without a non-crown restoration) shows a **crown** suggestion slot. A veneer/inlay/onlay/overlay hides the suggestion slot. **Post & core** category is visible but disabled when a restoration or implant is on the tooth. **Implant** category is disabled when post & core is on the tooth. Complete denture / overdenture / appliances / digital use **Upper arch / Lower arch** (`UA`/`LA`). **Partial denture** is tooth-level (select FDI teeth, Removable in the tooth picker); after send it is **one lab job** for all those teeth. Picker leaves are filtered by `chartRegion` so Removable appears in both tooth and arch pickers. Prosthesis FDI teeth **must** have jobs — never persist selected teeth without `toothProsthesis` (`pruneDetailTeethToJobs`). Catalog has no `addonKind` — stacking uses `stackGroup` plus `pickerPolicy()` suggestion slots.
|
||||||
- Detail chips show **type + teeth**, not “Detail N”. Lab-dependent chips use colored sent/unsent text (same size as the label). **Sent** means the linked lab case has `sentAt`. The edit lock is separate: the line stays editable until a lab step is completed. Sent date stays on Lab dispatch.
|
- Detail chips show **type + teeth**, not “Detail N”. Lab-dependent chips use colored sent/unsent text (same size as the label). **Sent** means the linked lab case has `sentAt`. The edit lock is separate: the line stays editable until a lab step is completed. Sent date stays on Lab dispatch.
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ frontend/src/
|
|||||||
|
|
||||||
**Subscriptions (quick ref):** One **Base** plan includes 3 seats (the owner holds one). Extra seats are separate rows with their own end dates. Each owner gets one free month (`User.trialUsedAt`), stamped only after `grantForNewOwner` starts it. Do not set `trialUsedAt` before that call. A later organization gets Base seats that end immediately. Another organization with the same owner that already has `trialEndsAt` or any seat counts as later, even when `trialUsedAt` is still null. Migration `20261018120000_subscription_seats` runs once on deploy: every real organization gets Base for 30 days from that instant, 3 included seats, and an extra seat for each staff member past those 3. It does not set `trialUsedAt` and does not insert charge rows. Disabled members who are not the owner and have no open invite do not take a seat. Migration `20261023140000_drop_unreferenced_legacy_plans` deletes unused `trial`, `Small`, `Medium`, `Large`, and `Enterprise` plans and does not change any end date. Migration `20261111233000_sheet_flag_and_subscription_courtesy` runs once: every existing seat and every non-null `trialEndsAt` gains 60 days (two 30-day subscription months). A date still in the future grows from itself; a date already past grows from that deploy. It does not insert seats or charge rows, and later deploys must not repeat it. Signup ensures the `base` plan. The free month is labeled Trial in the UI; the stored plan name stays `base`. Invitation placeholders (no members, and an invite that is still unaccepted) are left unchanged. During the free month an added seat costs $0 and ends with the base seats. After it, Add seat and Extend selected show the quote and then stop (`SUBSCRIPTION_PAYMENT_UNAVAILABLE`, contact Nudenticco@gmail.com). An overdue occupied seat is read-only. An overdue empty seat cannot be reserved. Owners and `TAB_BILLING_READ` manage Subscriptions. Cards show the assigned user. Other members get a `SEAT_EXPIRING` inbox notice 5 days before their seat ends.
|
**Subscriptions (quick ref):** One **Base** plan includes 3 seats (the owner holds one). Extra seats are separate rows with their own end dates. Each owner gets one free month (`User.trialUsedAt`), stamped only after `grantForNewOwner` starts it. Do not set `trialUsedAt` before that call. A later organization gets Base seats that end immediately. Another organization with the same owner that already has `trialEndsAt` or any seat counts as later, even when `trialUsedAt` is still null. Migration `20261018120000_subscription_seats` runs once on deploy: every real organization gets Base for 30 days from that instant, 3 included seats, and an extra seat for each staff member past those 3. It does not set `trialUsedAt` and does not insert charge rows. Disabled members who are not the owner and have no open invite do not take a seat. Migration `20261023140000_drop_unreferenced_legacy_plans` deletes unused `trial`, `Small`, `Medium`, `Large`, and `Enterprise` plans and does not change any end date. Migration `20261111233000_sheet_flag_and_subscription_courtesy` runs once: every existing seat and every non-null `trialEndsAt` gains 60 days (two 30-day subscription months). A date still in the future grows from itself; a date already past grows from that deploy. It does not insert seats or charge rows, and later deploys must not repeat it. Signup ensures the `base` plan. The free month is labeled Trial in the UI; the stored plan name stays `base`. Invitation placeholders (no members, and an invite that is still unaccepted) are left unchanged. During the free month an added seat costs $0 and ends with the base seats. After it, Add seat and Extend selected show the quote and then stop (`SUBSCRIPTION_PAYMENT_UNAVAILABLE`, contact Nudenticco@gmail.com). An overdue occupied seat is read-only. An overdue empty seat cannot be reserved. Owners and `TAB_BILLING_READ` manage Subscriptions. Cards show the assigned user. Other members get a `SEAT_EXPIRING` inbox notice 5 days before their seat ends.
|
||||||
|
|
||||||
**Billing (quick ref):** Same three-tab hub for CLINIC + LAB (`/billing?view=`). Clinic: `CLINIC_PRICE` / `CLINIC_COMMISSION` + patient receipts + partner payments. Lab: `LAB_PRICE` (prosthesis fees plus an outsourcing tab) / `LAB_COMMISSION` + partner ledger only. Commissions are **fixed amounts**. Automatic `BillingLedgerEntry` obligations come from treatment Approve, a case whose every current-round task is done, and staff commission plus fixed salary after each month ends; Toman uses Jalali months, Dollar/Euro Gregorian. Send stores the case price and does not post the debt. Selecting a party swaps the cash table to an inline obligation+cash ledger with signed amount/net; selected staff also show commission, fixed salary, and gross, including an unsaved preview of the open month through the report day. Partner cash remains shared Accept/Decline; rejected rows stay visible to both but count only for the recorder. Only the exact recorder can edit shared cash, and edits reset acknowledgement. Salary is one editable sheet on Commissions/Salary for the owner and active members; editing it does not change a closed month. Salary and commission may both apply; v1 has no proration/attendance. Price sheets may hide unpriced prosthesis types; existing fee and commission sheets deploy with that box unchecked, and commission sheets cannot turn it on. An active flagged lab sheet blocks clinic dispatch for unsupported jobs. If the flag is off, an unpriced case keeps an empty fee until the destination lab sets it. The pending obligation is created when every step is done. A received or outsourced case notifies that lab’s billing users then, and the link selects the payer on Transactions. Collapsed workflow prices and hidden legacy lines remain preserved. Money inputs: `AppMoneyInput`. See `.cursor/rules/billing.mdc`, `.cursor/skills/billing/SKILL.md`.
|
**Billing (quick ref):** Same three-tab hub for CLINIC + LAB (`/billing?view=`). Clinic: `CLINIC_PRICE` / `CLINIC_COMMISSION` + patient receipts + partner payments. Lab: `LAB_PRICE` (prosthesis fees plus an outsourcing tab) / `LAB_COMMISSION` + partner ledger only. Commissions are **fixed amounts**. Automatic `BillingLedgerEntry` obligations come from treatment Approve, a case whose every current-round task is done, and staff commission plus fixed salary after each month ends; Toman uses Jalali months, Dollar/Euro Gregorian. Send stores the case price and does not post the debt. Selecting a party swaps the cash table to an inline obligation+cash ledger with signed amount/net; selected staff also show commission, fixed salary, and gross, including an unsaved preview of the open month through the report day. Partner cash remains shared Accept/Decline; rejected rows stay visible to both but count only for the recorder. Only the exact recorder can edit shared cash, and edits reset acknowledgement. Salary is one editable sheet on Commissions/Salary for the owner and active members; editing it does not change a closed month. Salary and commission may both apply. The stored month-end salary is the full amount; the open-month preview is that amount times the days elapsed. There is no attendance model. Price sheets may hide unpriced prosthesis types; existing fee and commission sheets deploy with that box unchecked, and commission sheets cannot turn it on. An active flagged lab sheet blocks clinic dispatch for unsupported jobs. If the flag is off, an unpriced case keeps an empty fee until the destination lab sets it. The pending obligation is created when every step is done. A received or outsourced case notifies that lab’s billing users then, and the link selects the payer on Transactions. Collapsed workflow prices and hidden legacy lines remain preserved. Money inputs: `AppMoneyInput`. See `.cursor/rules/billing.mdc`, `.cursor/skills/billing/SKILL.md`.
|
||||||
|
|
||||||
**Lab Tasks tab:** Newest case first (`listedAt`); grouping only for date sort; filters include completed step, origin, due date, assignment, and prosthesis. New tasks are plan-scoped: one scan → prosthesis sections → optional Model design/creation (when any type has `requiresModelSteps`) → packing/shipping. `lineCount` stays 1. `__line__` tasks are independently completable. A type with both dry milling and sintering generates `milling_dry_sinter`; both wet milling and sintering generate `milling_wet_sinter`; both stain and glaze generate `stain_glaze`. A type with only one half keeps that half, and existing task rows are not rewritten. Model design and model create can be outsourced with that line’s teeth, or the whole plan for a historical `__case__` model step; scan, packing, and shipping cannot. Historical `__case__` scan keeps whole-case fan-out. Same-type exclusive steps coalesce across matching teeth; duplicate non-model steps for stacked types become `typeA+typeB` sections. Pontics fold into connected crown/indirect sections. Task identity includes source, first tooth, section type, and workflow code because one section may produce different tooth sets across steps. Job titles use `ProsthesisJobLineLabel`; task assignment is in Cases; only assignee/unassigned pool can update status in Tasks. `CASE_COMPLETED` drives inbox/tab badges only after all case tasks finish. See `.cursor/skills/lab-tasks/SKILL.md`.
|
**Lab Tasks tab:** Newest case first (`listedAt`); grouping only for date sort; filters include completed step, origin, due date, assignment, and prosthesis. New tasks are plan-scoped: one scan → prosthesis sections → optional Model design/creation (when any type has `requiresModelSteps`) → packing/shipping. `lineCount` stays 1. `__line__` tasks are independently completable. A type with both dry milling and sintering generates `milling_dry_sinter`; both wet milling and sintering generate `milling_wet_sinter`; both stain and glaze generate `stain_glaze`. A type with only one half keeps that half, and existing task rows are not rewritten. Model design and model create can be outsourced with that line’s teeth, or the whole plan for a historical `__case__` model step; scan, packing, and shipping cannot. Historical `__case__` scan keeps whole-case fan-out. Same-type exclusive steps coalesce across matching teeth; duplicate non-model steps for stacked types become `typeA+typeB` sections. Pontics fold into connected crown/indirect sections. Task identity includes source, first tooth, section type, and workflow code because one section may produce different tooth sets across steps. Job titles use `ProsthesisJobLineLabel`; task assignment is in Cases; only assignee/unassigned pool can update status in Tasks. `CASE_COMPLETED` drives inbox/tab badges only after all case tasks finish. See `.cursor/skills/lab-tasks/SKILL.md`.
|
||||||
|
|
||||||
|
|||||||
@@ -1787,6 +1787,7 @@ export class CasesService {
|
|||||||
patientDisplayMobile: lc.patientDisplayMobile,
|
patientDisplayMobile: lc.patientDisplayMobile,
|
||||||
partnerClinicOrganizationId: lc.partnerClinicOrganizationId,
|
partnerClinicOrganizationId: lc.partnerClinicOrganizationId,
|
||||||
partnerOrganizationType: lc.partnerClinic?.type.name ?? null,
|
partnerOrganizationType: lc.partnerClinic?.type.name ?? null,
|
||||||
|
destinationOrganizationId: lc.destinationOrganizationId,
|
||||||
calculatedAmount: lc.calculatedAmount?.toString() ?? null,
|
calculatedAmount: lc.calculatedAmount?.toString() ?? null,
|
||||||
billedAmount: lc.billedAmount?.toString() ?? null,
|
billedAmount: lc.billedAmount?.toString() ?? null,
|
||||||
billedAmountManual: lc.billedAmountManual,
|
billedAmountManual: lc.billedAmountManual,
|
||||||
|
|||||||
@@ -900,6 +900,7 @@
|
|||||||
"sendToLab": "Send to lab",
|
"sendToLab": "Send to lab",
|
||||||
"labFeePreview": "Lab fee",
|
"labFeePreview": "Lab fee",
|
||||||
"labFeeNeedsBillingAmount": "This case contains services without a lab fee. You can send it, but the destination lab must set the final amount in Billing.",
|
"labFeeNeedsBillingAmount": "This case contains services without a lab fee. You can send it, but the destination lab must set the final amount in Billing.",
|
||||||
|
"labFeeSentNeedsAmount": "This case was sent without a lab fee. The destination lab sets the final amount in Billing.",
|
||||||
"labDoesNotProvideTypes": "This lab does not provide the following prosthesis services: {types}. Choose another lab or change the case.",
|
"labDoesNotProvideTypes": "This lab does not provide the following prosthesis services: {types}. Choose another lab or change the case.",
|
||||||
"dueDateLabel": "Due date",
|
"dueDateLabel": "Due date",
|
||||||
"dueDateOptional": "optional",
|
"dueDateOptional": "optional",
|
||||||
|
|||||||
@@ -901,6 +901,7 @@
|
|||||||
"sendToLab": "ارسال به لابراتوار",
|
"sendToLab": "ارسال به لابراتوار",
|
||||||
"labFeePreview": "تعرفه لابراتوار",
|
"labFeePreview": "تعرفه لابراتوار",
|
||||||
"labFeeNeedsBillingAmount": "این پرونده شامل خدماتی بدون تعرفه لابراتوار است. ارسال مجاز است، اما لابراتوار مقصد باید مبلغ نهایی را در بخش مالی ثبت کند.",
|
"labFeeNeedsBillingAmount": "این پرونده شامل خدماتی بدون تعرفه لابراتوار است. ارسال مجاز است، اما لابراتوار مقصد باید مبلغ نهایی را در بخش مالی ثبت کند.",
|
||||||
|
"labFeeSentNeedsAmount": "این پرونده بدون تعرفه لابراتوار ارسال شد. لابراتوار مقصد مبلغ نهایی را در بخش مالی ثبت میکند.",
|
||||||
"labDoesNotProvideTypes": "این لابراتوار خدمات پروتز زیر را ارائه نمیدهد: {types}. لابراتوار دیگری انتخاب کنید یا پرونده را تغییر دهید.",
|
"labDoesNotProvideTypes": "این لابراتوار خدمات پروتز زیر را ارائه نمیدهد: {types}. لابراتوار دیگری انتخاب کنید یا پرونده را تغییر دهید.",
|
||||||
"dueDateLabel": "موعد تحویل",
|
"dueDateLabel": "موعد تحویل",
|
||||||
"dueDateOptional": "اختیاری",
|
"dueDateOptional": "اختیاری",
|
||||||
|
|||||||
@@ -900,6 +900,7 @@
|
|||||||
"sendToLab": "Versturen naar lab",
|
"sendToLab": "Versturen naar lab",
|
||||||
"labFeePreview": "Labtarief",
|
"labFeePreview": "Labtarief",
|
||||||
"labFeeNeedsBillingAmount": "Deze case bevat diensten zonder labtarief. Verzenden is toegestaan, maar het bestemmingslab moet het definitieve bedrag in Facturatie instellen.",
|
"labFeeNeedsBillingAmount": "Deze case bevat diensten zonder labtarief. Verzenden is toegestaan, maar het bestemmingslab moet het definitieve bedrag in Facturatie instellen.",
|
||||||
|
"labFeeSentNeedsAmount": "Deze case is verzonden zonder labtarief. Het bestemmingslab stelt het definitieve bedrag in Facturatie in.",
|
||||||
"labDoesNotProvideTypes": "Dit lab levert de volgende prothesediensten niet: {types}. Kies een ander lab of wijzig de case.",
|
"labDoesNotProvideTypes": "Dit lab levert de volgende prothesediensten niet: {types}. Kies een ander lab of wijzig de case.",
|
||||||
"dueDateLabel": "Vervaldatum",
|
"dueDateLabel": "Vervaldatum",
|
||||||
"dueDateOptional": "optioneel",
|
"dueDateOptional": "optioneel",
|
||||||
|
|||||||
@@ -304,7 +304,9 @@ export function CaseDetailPanel({
|
|||||||
const intlLocale = useLocale();
|
const intlLocale = useLocale();
|
||||||
const { settings: currencySettings } = useBillingCurrency(true);
|
const { settings: currencySettings } = useBillingCurrency(true);
|
||||||
const { currentOrganization } = useAuth();
|
const { currentOrganization } = useAuth();
|
||||||
const canEditCaseFee = hasPermission(currentOrganization, 'TAB_BILLING_EDIT');
|
const canEditCaseFee =
|
||||||
|
hasPermission(currentOrganization, 'TAB_BILLING_EDIT') &&
|
||||||
|
currentOrganization?.id === labCase.destinationOrganizationId;
|
||||||
const [feeDraft, setFeeDraft] = useState(
|
const [feeDraft, setFeeDraft] = useState(
|
||||||
stripTrailingDecimalZeros(labCase.billedAmount || labCase.calculatedAmount || ''),
|
stripTrailingDecimalZeros(labCase.billedAmount || labCase.calculatedAmount || ''),
|
||||||
);
|
);
|
||||||
@@ -641,8 +643,13 @@ export function CaseDetailPanel({
|
|||||||
setFeeSaving(true);
|
setFeeSaving(true);
|
||||||
void billingApi
|
void billingApi
|
||||||
.setCaseBilledAmount(labCase.id, parsed)
|
.setCaseBilledAmount(labCase.id, parsed)
|
||||||
.then(() => {
|
.then((saved) => {
|
||||||
toast.showSuccess(tBilling('obligationAmountSaved'));
|
toast.showSuccess(tBilling('obligationAmountSaved'));
|
||||||
|
onCaseUpdated?.({
|
||||||
|
...labCase,
|
||||||
|
billedAmount: saved.data.amount,
|
||||||
|
billedAmountManual: true,
|
||||||
|
});
|
||||||
})
|
})
|
||||||
.catch((error: unknown) => {
|
.catch((error: unknown) => {
|
||||||
toast.showError(
|
toast.showError(
|
||||||
|
|||||||
@@ -499,7 +499,7 @@ export function LabCasesDispatchPanel({
|
|||||||
</p>
|
</p>
|
||||||
) : null}
|
) : null}
|
||||||
{sent && !activeLabCase?.billedAmount ? (
|
{sent && !activeLabCase?.billedAmount ? (
|
||||||
<p className={labBlockedBannerClass}>{t('labFeeNeedsBillingAmount')}</p>
|
<p className={labBlockedBannerClass}>{t('labFeeSentNeedsAmount')}</p>
|
||||||
) : null}
|
) : null}
|
||||||
{quoteLabId &&
|
{quoteLabId &&
|
||||||
unsupportedCodes.length > 0 &&
|
unsupportedCodes.length > 0 &&
|
||||||
|
|||||||
@@ -284,6 +284,9 @@ function mapLabCaseDraftFromApi(lc: PastLabCase): LabCaseDraft {
|
|||||||
dueDate: lc.dueDate ?? null,
|
dueDate: lc.dueDate ?? null,
|
||||||
taskProgress: lc.taskProgress ?? null,
|
taskProgress: lc.taskProgress ?? null,
|
||||||
shareUrl: lc.shareUrl ?? null,
|
shareUrl: lc.shareUrl ?? null,
|
||||||
|
calculatedAmount: lc.calculatedAmount ?? null,
|
||||||
|
billedAmount: lc.billedAmount ?? null,
|
||||||
|
billedAmountManual: Boolean(lc.billedAmountManual),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -386,7 +389,14 @@ function mergeServerIdsIntoLabCases(
|
|||||||
return local.map((lc) => {
|
return local.map((lc) => {
|
||||||
const s = byClientId.get(lc.clientId);
|
const s = byClientId.get(lc.clientId);
|
||||||
if (!s) return lc;
|
if (!s) return lc;
|
||||||
return { ...lc, id: s.id ?? lc.id, shareUrl: s.shareUrl ?? lc.shareUrl };
|
return {
|
||||||
|
...lc,
|
||||||
|
id: s.id ?? lc.id,
|
||||||
|
shareUrl: s.shareUrl ?? lc.shareUrl,
|
||||||
|
calculatedAmount: s.calculatedAmount ?? lc.calculatedAmount,
|
||||||
|
billedAmount: s.billedAmount ?? lc.billedAmount,
|
||||||
|
billedAmountManual: s.billedAmountManual ?? lc.billedAmountManual,
|
||||||
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2774,6 +2784,9 @@ export function TreatmentWorkspace({
|
|||||||
sends: response.data.sends,
|
sends: response.data.sends,
|
||||||
taskProgress: response.data.taskProgress ?? lc.taskProgress,
|
taskProgress: response.data.taskProgress ?? lc.taskProgress,
|
||||||
shareUrl: response.data.shareUrl ?? lc.shareUrl,
|
shareUrl: response.data.shareUrl ?? lc.shareUrl,
|
||||||
|
calculatedAmount: response.data.calculatedAmount ?? lc.calculatedAmount,
|
||||||
|
billedAmount: response.data.billedAmount ?? null,
|
||||||
|
billedAmountManual: Boolean(response.data.billedAmountManual),
|
||||||
}
|
}
|
||||||
: lc,
|
: lc,
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -196,6 +196,7 @@ export interface LabCaseDetail {
|
|||||||
/** Present only for the lab that owns this case. Direct handoffs; no further lab is named. */
|
/** Present only for the lab that owns this case. Direct handoffs; no further lab is named. */
|
||||||
outsourcing?: LabCaseOutsourceHandoff[];
|
outsourcing?: LabCaseOutsourceHandoff[];
|
||||||
shareUrl?: string | null;
|
shareUrl?: string | null;
|
||||||
|
destinationOrganizationId?: string | null;
|
||||||
calculatedAmount?: string | null;
|
calculatedAmount?: string | null;
|
||||||
billedAmount?: string | null;
|
billedAmount?: string | null;
|
||||||
billedAmountManual?: boolean;
|
billedAmountManual?: boolean;
|
||||||
|
|||||||
@@ -131,6 +131,9 @@ export interface PastLabCase {
|
|||||||
attachments?: TreatmentAttachmentMeta[];
|
attachments?: TreatmentAttachmentMeta[];
|
||||||
/** Present on sent cases — same share URL the lab Cases QR encodes. */
|
/** Present on sent cases — same share URL the lab Cases QR encodes. */
|
||||||
shareUrl?: string | null;
|
shareUrl?: string | null;
|
||||||
|
calculatedAmount?: string | null;
|
||||||
|
billedAmount?: string | null;
|
||||||
|
billedAmountManual?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PastTreatment {
|
export interface PastTreatment {
|
||||||
@@ -254,4 +257,7 @@ export interface LabCaseResponse {
|
|||||||
toothProsthesis?: LabCaseToothProsthesisDraft[];
|
toothProsthesis?: LabCaseToothProsthesisDraft[];
|
||||||
attachments?: TreatmentAttachmentMeta[];
|
attachments?: TreatmentAttachmentMeta[];
|
||||||
shareUrl?: string | null;
|
shareUrl?: string | null;
|
||||||
|
calculatedAmount?: string | null;
|
||||||
|
billedAmount?: string | null;
|
||||||
|
billedAmountManual?: boolean;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,23 @@ server {
|
|||||||
proxy_connect_timeout 300;
|
proxy_connect_timeout 300;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Socket.IO (Nest namespace /realtime). Without this, /socket.io/ hits Next.js
|
||||||
|
# and the browser reports "websocket is closed before the connection is established".
|
||||||
|
location /socket.io/ {
|
||||||
|
proxy_pass http://dyolink_backend;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection 'upgrade';
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
proxy_cache_bypass $http_upgrade;
|
||||||
|
proxy_read_timeout 3600s;
|
||||||
|
proxy_send_timeout 3600s;
|
||||||
|
proxy_connect_timeout 300;
|
||||||
|
}
|
||||||
|
|
||||||
location /api {
|
location /api {
|
||||||
proxy_pass http://dyolink_backend;
|
proxy_pass http://dyolink_backend;
|
||||||
proxy_http_version 1.1;
|
proxy_http_version 1.1;
|
||||||
|
|||||||
@@ -66,6 +66,24 @@ server {
|
|||||||
proxy_connect_timeout 300;
|
proxy_connect_timeout 300;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Socket.IO (Nest namespace /realtime). Without this, /socket.io/ hits Next.js
|
||||||
|
# and the browser reports "websocket is closed before the connection is established".
|
||||||
|
location /socket.io/ {
|
||||||
|
set $backend_upstream http://backend:3000;
|
||||||
|
proxy_pass $backend_upstream;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection 'upgrade';
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
proxy_cache_bypass $http_upgrade;
|
||||||
|
proxy_read_timeout 3600s;
|
||||||
|
proxy_send_timeout 3600s;
|
||||||
|
proxy_connect_timeout 300;
|
||||||
|
}
|
||||||
|
|
||||||
location /api {
|
location /api {
|
||||||
set $backend_upstream http://backend:3000;
|
set $backend_upstream http://backend:3000;
|
||||||
proxy_pass $backend_upstream;
|
proxy_pass $backend_upstream;
|
||||||
|
|||||||
Reference in New Issue
Block a user