Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions backend/src/docs/frontend-assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
"src/surfaces/finance/bookkeeping-views.js",
"src/surfaces/finance/bookkeeping.js",
"src/surfaces/finance/index.js",
"src/surfaces/finance/inventory.js",
"src/surfaces/finance/invoices.js",
"src/surfaces/finance/overview.js",
"src/surfaces/finance/shared.js",
Expand Down
2 changes: 1 addition & 1 deletion frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
<a id="sponsors-nav-button" class="dk-nav-item workspace-nav-button" href="/sponsors" data-workspace-view="sponsors"><span class="dk-nav-item__icon" aria-hidden="true"><svg viewBox="0 0 24 24"><circle cx="9" cy="8" r="3"/><circle cx="17" cy="9" r="2"/><path d="M3 20c0-4 2-6 6-6s6 2 6 6m1-6c3 0 5 2 5 5"/></svg></span><span class="dk-nav-item__label">CRM</span></a>
<a id="finance-nav-button" class="dk-nav-item workspace-nav-button" href="/finance" data-workspace-view="finance"><span class="dk-nav-item__icon" aria-hidden="true"><svg viewBox="0 0 24 24"><path d="M4 20h16"/><path d="M7 16v-5M12 16V6M17 16v-8"/></svg></span><span class="dk-nav-item__label">Finance</span></a>
<a id="bookkeeping-nav-button" class="dk-nav-item workspace-nav-button" href="/bookkeeping" data-workspace-view="bookkeeping"><span class="dk-nav-item__icon" aria-hidden="true"><svg viewBox="0 0 24 24"><path d="M5 3h14v18H5Z"/><path d="M8 7h8M8 11h8M8 15h3M15 15h1M8 18h3M15 18h1"/></svg></span><span class="dk-nav-item__label">Bookkeeping</span></a>
<a id="inventory-nav-button" class="dk-nav-item workspace-nav-button" href="/invertory" data-workspace-view="bookkeeping" data-bookkeeping-view="inventory"><span class="dk-nav-item__icon" aria-hidden="true"><svg viewBox="0 0 24 24"><path d="M21 8 12 3 3 8v8l9 5 9-5Z"/><path d="m3 8 9 5 9-5M12 13v8"/></svg></span><span class="dk-nav-item__label">Inventory</span></a>
<a id="inventory-nav-button" class="dk-nav-item workspace-nav-button" href="/invertory" data-workspace-view="inventory"><span class="dk-nav-item__icon" aria-hidden="true"><svg viewBox="0 0 24 24"><path d="M21 8 12 3 3 8v8l9 5 9-5Z"/><path d="m3 8 9 5 9-5M12 13v8"/></svg></span><span class="dk-nav-item__label">Inventory</span></a>
</div><div class="dk-nav-group"><h2 class="dk-nav-group__label">Knowledge</h2>
<a class="dk-nav-item workspace-nav-button" href="/operating-model" data-workspace-view="operating-model"><span class="dk-nav-item__icon" aria-hidden="true"><svg viewBox="0 0 24 24"><circle cx="12" cy="5" r="2"/><circle cx="6" cy="18" r="2"/><circle cx="18" cy="18" r="2"/><path d="M12 7v4M6 16v-3h12v3"/></svg></span><span class="dk-nav-item__label">Operating Model</span></a>
<a id="docs-nav-button" class="dk-nav-item workspace-nav-button" href="/processes" data-workspace-view="docs"><span class="dk-nav-item__icon" aria-hidden="true"><svg viewBox="0 0 24 24"><path d="M6 3h9l4 4v14H6Z"/><path d="M14 3v5h5M9 12h7M9 16h7"/></svg></span><span class="dk-nav-item__label">Process Docs</span></a>
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/core/workspace.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const WORKSPACE_PATH_BY_VIEW = Object.freeze({
users: "/users",
finance: "/finance",
bookkeeping: "/bookkeeping",
inventory: "/invertory",
sponsors: "/sponsors/pipeline",
newsletter: "/newsletter",
calendar: "/calendar",
Expand Down Expand Up @@ -63,8 +64,8 @@ export const WORKSPACE_ROUTE_DEFINITIONS = Object.freeze({
tasksSection: "queue",
params: ["month", "q", "account", "dir", "category", "needs", "tx", "view", "agreement"],
},
// The inventory page answers on its own bare path under Bookkeeping.
"/invertory": { view: "bookkeeping", tasksSection: "queue", params: [] },
// Inventory is its own top-level surface; its address is the path.
"/invertory": { view: "inventory", tasksSection: "queue", params: [] },
// Bare /sponsors opens the default tab; every tab and record is a path.
// Directory tabs declare their filter/sort/page params so filter state
// survives navigation, refresh and back/forward through canonical URLs.
Expand Down
6 changes: 1 addition & 5 deletions frontend/src/runtime/application-events.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,7 @@ export function bindApplicationEvents(context) {
button.dataset.workspaceTarget ||
button.dataset.workspaceView ||
"tasks",
// A sub-view entry (Bookkeeping → Inventory) addresses its own
// page, so it navigates by href instead of the parent view.
path: button.dataset.bookkeepingView
? button.getAttribute("href")
: "",
path: "",
},
}),
),
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/runtime/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ const {
getRenderAdminSurfaceView: () => renderAdminSurfaceView,
getRenderBookkeepingSurface: () => renderBookkeepingSurface,
getRenderFinanceOverviewSurface: () => renderFinanceOverviewSurface,
getRenderInventorySurface: () => renderInventorySurface,
getRenderCalendarSurface: () => renderCalendarSurface,
getRenderDocsSurface: () => renderDocsSurface,
getRenderInboxSurface: () => inboxSurface?.renderInbox || (() => undefined),
Expand Down Expand Up @@ -204,6 +205,7 @@ const {
canLeaveFinanceSurface,
renderBookkeepingSurface,
renderFinanceOverviewSurface,
renderInventorySurface,
renderSponsorCrmSurface,
} = createFinanceSurface({
documentList,
Expand Down
6 changes: 2 additions & 4 deletions frontend/src/runtime/surface-composition.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export function createSurfaceComposition(context) {
getRenderAdminSurfaceView,
getRenderBookkeepingSurface,
getRenderFinanceOverviewSurface,
getRenderInventorySurface,
getRenderCalendarSurface,
getRenderDocsSurface,
getRenderInboxSurface,
Expand Down Expand Up @@ -161,6 +162,7 @@ export function createSurfaceComposition(context) {
if (view === "admin") return getRenderAdminSurfaceView()(documents);
if (view === "users") return context.getRenderUsersSurfaceView()();
if (view === "bookkeeping") return getRenderBookkeepingSurface()();
if (view === "inventory") return getRenderInventorySurface()();
if (view === "finance") return getRenderFinanceOverviewSurface()();
if (view === "sponsors") return getRenderSponsorCrmSurface()();
if (view === "newsletter") return getRenderNewsletterSurface()();
Expand Down Expand Up @@ -285,10 +287,6 @@ export function createSurfaceComposition(context) {
body.dataset.workspaceView = activeView;
searchInput.placeholder = "Search work and docs";
for (const button of workspaceNavButtons) {
// Sub-view entries (Bookkeeping → Inventory) follow the surface's own
// ?view= state, which changes without a route commit; renderView owns
// them, the generic pass would wrongly light them on every page.
if (button.dataset.bookkeepingView) continue;
const active = button.dataset.workspaceView === activeView;
button.classList.toggle("is-active", active);
if (active) button.setAttribute("aria-current", "page");
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/shell/startup-orchestration.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
// deferred at bootstrap and shielded from snapshot repaints together, so the
// two can never drift apart.
export const SELF_LOADING_VIEWS = Object.freeze(
new Set(["bookkeeping", "calendar", "finance", "inbox", "newsletter", "podcast", "sponsors", "users"]),
new Set(["bookkeeping", "calendar", "finance", "inbox", "inventory", "newsletter", "podcast", "sponsors", "users"]),
);

// Whether committing this route needs none of the shared snapshots yet. An
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/surfaces/finance/bookkeeping-ledger.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { bookkeepingVendorPresentation } from "./bookkeeping-vendors.js";

// Query parameters the bookkeeping route keeps in the URL.
export const LEDGER_PARAMS = ["month", "q", "account", "dir", "category", "needs", "tx", "view"];
export const SECONDARY_VIEWS = ["files", "package", "invoices", "tuition", "inventory"];
export const SECONDARY_VIEWS = ["files", "package", "invoices", "tuition"];

// The classification columns: "Type" is stored as `subtype`, "Category" as
// `category`. The spreadsheet's Period column is not shown in the table: it
Expand Down
17 changes: 3 additions & 14 deletions frontend/src/surfaces/finance/bookkeeping-markup.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import "../../dakit/collection.js";
// Static shell for the bookkeeping surface. The page is the transaction
// list: header with the month navigator and actions, one filter row, the
// table with its detail pane. Inventory is its own page at /invertory
// reached from the sidebar; files, the accountant package/VAT, tuition
// table with its detail pane. Files, the accountant package/VAT, tuition
// and forwarded invoices are secondary views (?view=…) reached from the
// ⋯ menu.
// ⋯ menu. Inventory is a separate surface at /invertory.
import { financeSectionHead, html } from "./shared.js";
import { periodNavMarkup } from "../period-nav.js";

Expand Down Expand Up @@ -148,18 +147,8 @@ export function bookkeepingSurfaceMarkup() {
${backLink}
<div data-tuition></div>
</section>
<section id="bookkeeping-inventory" class="bookkeeping-section bk-secondary" data-secondary="inventory" aria-labelledby="bookkeeping-inventory-heading" hidden>
${backLink}
${financeSectionHead({
id: "bookkeeping-inventory-heading",
title: "Inventory",
hint: "Physical purchases from the ledger since 2022 — computers, phones, audio, furniture. Scan the ledger after new expenses land.",
actions: html`<button type="button" class="dk-button dk-button--secondary dk-button--sm" data-inventory-scan>Scan ledger</button>`,
})}
<div class="bookkeeping-inventory" data-inventory aria-live="polite">Loading inventory…</div>
</section>
<!-- Lives at the surface root, outside the ledger pane: the pane is hidden
while a secondary view (inventory, files, VAT) is open, and a dialog
while a secondary view (files, VAT) is open, and a dialog
inside a hidden ancestor cannot be shown. -->
<dialog class="surface-dialog bk-transaction-dialog" id="bookkeeping-transaction-dialog" aria-labelledby="bookkeeping-transaction-dialog-title"></dialog>
<dialog class="surface-dialog bookkeeping-entry-dialog">
Expand Down
40 changes: 5 additions & 35 deletions frontend/src/surfaces/finance/bookkeeping.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import { createBookkeepingTransactionModal } from "./bookkeeping-transaction-mod
import { importStatementWithReview, confirmStatementReplacement } from "./bookkeeping-statement-import.js";
import { loadStatementLinkIndex } from "./bookkeeping-statement.js";
import { openBookkeepingDialog } from "./bookkeeping-dialogs.js";
import { createBookkeepingInventory } from "./bookkeeping-inventory.js";
import {
createBookkeepingFinance,
monthlyLedgerEntries,
Expand Down Expand Up @@ -91,12 +90,9 @@ export function createBookkeepingSurface(context) {
let lens = LENS.test(initial.get("month") || "") ? initial.get("month") : "";
let filters = filtersFromParams(initial);
let selectedId = initial.get("tx") || "";
// Inventory answers on its own /invertory address; the other secondary
// views ride ?view= on the ledger path.
const requestedView =
(locationRef?.pathname || "") === "/invertory"
? "inventory"
: initial.get("view") || "";
// Secondary views (files, package/VAT, invoices, tuition) ride ?view= on
// the ledger path; inventory is a separate surface at /invertory.
const requestedView = initial.get("view") || "";
let view = SECONDARY_VIEWS.includes(requestedView) ? requestedView : "";
let defaultLens = "", invoicesMounted = false;
const reconciliationCache = new Map();
Expand Down Expand Up @@ -158,16 +154,15 @@ export function createBookkeepingSurface(context) {
if (view === "tuition" || !historyRef?.replaceState || !locationRef) return;
const params = new URLSearchParams();
// The default month (latest with transactions) stays out of the URL.
// Inventory's address is the path, so its view never rides the query.
const values = {
month: lens === defaultLens ? "" : lens,
...filters,
tx: selectedId,
view: view === "inventory" ? "" : view,
view,
};
for (const name of LEDGER_PARAMS) if (values[name]) params.set(name, values[name]);
const query = params.toString();
const next = `${view === "inventory" ? "/invertory" : "/bookkeeping"}${query ? `?${query}` : ""}`;
const next = `/bookkeeping${query ? `?${query}` : ""}`;
if (`${locationRef.pathname}${locationRef.search}` !== next)
historyRef.replaceState(historyRef.state, "", next);
}
Expand Down Expand Up @@ -229,17 +224,6 @@ export function createBookkeepingSurface(context) {
}
function renderView() {
surface.dataset.bkView = view || "transactions";
// The sidebar's Inventory entry lives outside the surface and follows
// the in-page view, which changes without a route commit. It is owned
// through the surface's own document, so mounts under a DOM subset
// without a sidebar simply skip it.
const navItems = surface.ownerDocument?.querySelectorAll("[data-bookkeeping-view]") ?? [];
for (const item of navItems) {
const active = item.dataset.bookkeepingView === view;
item.classList.toggle("is-active", active);
if (active) item.setAttribute("aria-current", "page");
else item.removeAttribute("aria-current");
}
surface.querySelector("[data-bk-main]").hidden = Boolean(view);
surface.classList.toggle("dk-fill", !view);
surface.querySelectorAll("[data-secondary]").forEach((section) => {
Expand All @@ -250,7 +234,6 @@ export function createBookkeepingSurface(context) {
invoicesMounted = true;
mountInvoiceReview(surface.querySelector("[data-invoice-review]"), context);
}
if (view === "inventory") inventory.renderInventory();
}
function optionList(select, values, allLabel, current) {
select.innerHTML = [
Expand Down Expand Up @@ -609,19 +592,6 @@ export function createBookkeepingSurface(context) {
},
});

const inventory = createBookkeepingInventory({
surface,
api,
escapeHtml,
safeAction,
setStatus: (text) => {
status.textContent = text;
},
todayIsoDate,
// Inventory rows link back to the ledger record they came from.
openTransaction: (id) => openTransaction(id),
});

const navigation = mountBookkeepingNavigation({
surface, status, setLens, lensEntries, todayIsoDate,
prepareExemptions: () => financeSummary.ensure(),
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/surfaces/finance/index.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import { createBookkeepingSurface } from "./bookkeeping.js";
import { createFinanceOverviewSurface } from "./overview.js";
import { createInventorySurface } from "./inventory.js";
import { createSponsorCrmSurface } from "./sponsors.js";
import "./bookkeeping-statement.js";
import "./bookkeeping-transaction-dialog.js";
import "./bookkeeping-transaction-modal.js";

export function createFinanceSurface(context) {
const bookkeeping = createBookkeepingSurface(context);
const inventory = createInventorySurface(context);
const sponsors = createSponsorCrmSurface(context);
const overview = createFinanceOverviewSurface(context);

return {
canLeaveFinanceSurface: sponsors.canLeaveFinanceSurface,
renderBookkeepingSurface: bookkeeping.renderBookkeepingSurface,
renderFinanceOverviewSurface: overview.renderFinanceOverviewSurface,
renderInventorySurface: inventory.renderInventorySurface,
renderSponsorCrmSurface: sponsors.renderSponsorCrmSurface,
};
}
Loading
Loading