pelagia-portal/CHANGELOG.md
Claude (review-bot) fd7b31e64d
All checks were successful
PR checks / checks (pull_request) Successful in 49s
PR checks / integration (pull_request) Successful in 32s
feat(reports): drill from cost centre / accounting code into PO History (#126)
Report detail pages now link to the underlying POs, addressing the PR #126
review comment: drilling into a cost centre or accounting code opens PO
History pre-filtered to that dimension and the period in view.

- Cost Centre / Accounting Code detail pages gain a "View POs" link.
- periodRange() maps the on-screen period onto History's approved-date
  window (weekly→month, monthly→FY, yearly→full span); spend is dated by
  approvedAt.
- PO History gains an accountId filter (any tree node, expanded to leaves
  via accountLeafIds()) matching PO-level OR line-item accounts — the same
  basis the reports use.
- History page + CSV/PDF export share one buildPoHistoryWhere() builder so
  they never diverge.
- Tests: unit (periodRange, accountLeafIds) + integration (History account
  filter across PO-level/line-item, with the approved window).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 16:09:54 +05:30

4.8 KiB

Changelog

[Unreleased]

Added

  • Report → PO drill-down (#126) — the Cost Centre and Accounting Code report detail pages gain a "View POs" link that opens PO History pre-filtered to that cost centre / accounting code and the period currently in view (mapped to the approved-date window, since spend is dated by approvedAt). PO History gains an Accounting Code filter that accepts any tree node and matches a PO whose PO-level account or any line-item account falls under that node's leaves. The History page and its CSV/PDF export share one buildPoHistoryWhere builder so they never diverge.
  • Companies (multi-company invoicing) — new Company model and /admin/companies CRUD. A PO is billed under a selected company (name, short code, GST number, address, phone/mobile, contact + invoice email, invoice address). The company's details populate the exported PO header / invoice block.
  • Structured PO numbers (lib/po-number.ts) — COMPANY/VESSEL/ID/FY (e.g. PMS/HNR1/9000/2024-25); Indian financial year; system-generated IDs start at 9000. Imported POs keep their original number.
  • 3-level accounting-code hierarchyAccount.parentId self-relation (Top Category → Sub-Category → Leaf), 6-digit numeric codes seeded from prisma/accounting-codes-data.ts. Only leaf codes are PO-selectable, via a searchable, portal-rendered combobox.
  • Compulsory payment datePurchaseOrder.paymentDate captured when Accounts records a payment; defaults to today, rejects future dates. Backfilled for existing POs from paidAt / the first payment action.
  • Editable PO date (poDate) — the exported PO "Date" now shows poDate ?? approvedAt ?? createdAt (approval date once approved, not creation).
  • Submitter vendor creationcreate_vendor permission lets Technical/Manning add vendors; they are created unverified and become verified when a PO closes/pays with them, on import, or via Manager/Accounts/Admin (verifyVendor).
  • Import PO → Closed/po/import saves a parsed Excel PO directly as CLOSED, auto-detecting the company, matching the vessel by code, and auto-creating the vendor, products, and per-vendor prices.
  • Inventory feature flag (NEXT_PUBLIC_INVENTORY_ENABLED) — site stock/consumption surfaces are gated; the vendor/item catalogue for PO creation stays available. Inventory is incremented at PO approval (not on close).
  • Dashboards — Accounts gains a "Payments Completed This Month" card.
  • Automated issue-to-deploy pipeline — end-to-end flow from a user-reported bug to a production fix without manual intervention on the developer's part:
    • Report Issue button (App/components/layout/report-issue-button.tsx) — any signed-in user can file a bug from the portal header; the server action (report-issue-actions.ts) calls the Forgejo API and attaches portal + claude-queue labels.
    • Claude issue watcher (automation/claude-issue-watcher.ps1) — a Windows Scheduled Task (PelagiaClaudeIssueWatcher) polls Forgejo every 10 minutes, picks up claude-queue issues, and runs Claude Code headlessly to implement and verify a fix. On success the watcher pushes a claude/issue-N branch and opens a PR; on failure it posts a comment and labels the issue claude-failed.
    • Tag-triggered deploy workflow (.forgejo/workflows/deploy.yml) — pushing a v* semver tag triggers the host Forgejo runner on pms1, which checks out the tag, runs pnpm install, builds the app, applies Prisma migrations, and restarts the pm2 process ppms.

Changed

  • Cost centre is now a Vessel only. The earlier Vessel-or-Site cost-centre model was removed: PurchaseOrder.vesselId is required, the costCentreRef encoding is gone, and Vessel no longer links to a Site. Vessels are surfaced as "Cost Centre" throughout the UI (/admin/vessels → "Cost Centre Management").
  • Closed Purchase Orders list: submitters see only their own CLOSED POs; Managers/SuperUsers see all CLOSED POs.
  • Sidebar reorganised into Purchasing and Administration sections (role-aware); "Inventory" renamed to "Purchasing".
  • Items: /admin/products is the editable catalogue; /inventory/items is read-only; both link to a shared item detail page.
  • Profile page is reachable by every role (incl. SSO-only / no-password users, with an email fallback lookup); only approvers can upload an approval signature.
  • Manager dashboard "Approved This Month" now counts by approvedAt (no longer undercounts once a PO progresses past MGR_APPROVED).

Fixed

  • Production P2022 … column does not exist after deploy — caused by shipping code whose Prisma client expected a column before migrate deploy had run. Migrations must be applied before the new build serves traffic (now documented in the README).