The repo CHANGELOG had fallen behind. Adds [Unreleased] entries for the recently shipped work and a README for the previously undocumented PdfService. Added (changelog): - Reports — Purchasing spend analytics (cost centres + accounting codes). - Email PO to vendor + the PdfService microservice (cached per PO). - EpfoService + PdfService microservices and their release auto-deploy. - Unsaved-changes prompt on PO create/edit (#18). - Crew login-on-hire for management ranks. - Delivery Locations (#19), T&C catalogue (#11), advance payment (#92). Fixed (changelog): - "Email to vendor" never rendered (auth middleware bounced the svc fetch) — #127. - Reports charts all one colour (RSC client/server boundary) — #120. New: PdfService/README.md (endpoints, token/origin security, env, app integration). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
7.2 KiB
7.2 KiB
Changelog
[Unreleased]
Added
- Reports — Purchasing spend analytics (
view_analytics: Manager / SuperUser / Auditor / Admin) —/reports/cost-centresand/reports/accounting-codes, each an index → drill-down → detail. KPI tiles, comparison + trend charts (one colour per item), Top-N tables, per-row sparklines, and CSV export; URL-driven filters (granularity Weekly / Monthly / Yearly, financial year, Top/Bottom-N, an "Add to graph" custom comparison). Spend = post-approval POs byapprovedAt/totalAmount, allocated across each PO's line-item accounting codes. Pure, unit-tested core inlib/reports.ts. - Email PO to vendor (issue #14) — one-click Outlook draft to the vendor's primary contact with a 7-day download link to the PO PDF. Rendered by the new PdfService microservice (Express + Playwright → headless Chromium) and stored in R2; the PDF is cached per PO, so repeat sends reuse the copy and only refresh the link.
- Microservices —
EpfoService(UAN / EPFO assisted-lookup proxy; live portal nav stubbed behindEPFO_LIVE) andPdfService(PO → PDF) joinGstService. All three are auto-deployed on each release tag via the rootecosystem.config.js+deploy.yml(pm2 startOrReload … --update-env). - Unsaved-changes prompt (issue #18) — leaving the PO create/edit screen with unsaved edits offers Save as draft / Discard / Stay (in-app navigation) or the browser's native warning (refresh / close).
- Crew login on hire (crewing, feature-flagged) — onboarding, direct placement, and admin crew-create accept an explicit login email + initial password for management ranks (
Rank.grantsLogin), creating theSITE_STAFFlogin in one step. - Delivery Locations (issue #19) — admin-managed
Company+address list backing the PO "Place of Delivery" dropdown, gated bymanage_delivery_locations(Manager / SuperUser / Admin). - Terms & Conditions catalogue (issue #11) — admin-managed, user-defined T&C categories + clauses feeding a dynamic PO terms editor; the chosen rows are a JSON snapshot on
PurchaseOrder.terms. - Advance payment on approval (issue #92) — the approving Manager sets how much is paid first; the resolved absolute amount is stored on
PurchaseOrder.suggestedAdvancePaymentand prefills the first Accounts payment. - Companies (multi-company invoicing) — new
Companymodel and/admin/companiesCRUD. A PO is billed under a selected company (name, shortcode, 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 hierarchy —
Account.parentIdself-relation (Top Category → Sub-Category → Leaf), 6-digit numeric codes seeded fromprisma/accounting-codes-data.ts. Only leaf codes are PO-selectable, via a searchable, portal-rendered combobox. - Compulsory payment date —
PurchaseOrder.paymentDatecaptured when Accounts records a payment; defaults to today, rejects future dates. Backfilled for existing POs frompaidAt/ the first payment action. - Editable PO date (
poDate) — the exported PO "Date" now showspoDate ?? approvedAt ?? createdAt(approval date once approved, not creation). - Submitter vendor creation —
create_vendorpermission 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/importsaves a parsed Excel PO directly asCLOSED, 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 attachesportal+claude-queuelabels. - Claude issue watcher (
automation/claude-issue-watcher.ps1) — a Windows Scheduled Task (PelagiaClaudeIssueWatcher) polls Forgejo every 10 minutes, picks upclaude-queueissues, and runs Claude Code headlessly to implement and verify a fix. On success the watcher pushes aclaude/issue-Nbranch and opens a PR; on failure it posts a comment and labels the issueclaude-failed. - Tag-triggered deploy workflow (
.forgejo/workflows/deploy.yml) — pushing av*semver tag triggers thehostForgejo runner on pms1, which checks out the tag, runspnpm install, builds the app, applies Prisma migrations, and restarts the pm2 processppms.
- Report Issue button (
Changed
- Cost centre is now a Vessel only. The earlier Vessel-or-Site cost-centre model was removed:
PurchaseOrder.vesselIdis required, thecostCentreRefencoding is gone, andVesselno longer links to aSite. Vessels are surfaced as "Cost Centre" throughout the UI (/admin/vessels→ "Cost Centre Management"). - Closed Purchase Orders list: submitters see only their own
CLOSEDPOs; Managers/SuperUsers see allCLOSEDPOs. - Sidebar reorganised into Purchasing and Administration sections (role-aware); "Inventory" renamed to "Purchasing".
- Items:
/admin/productsis the editable catalogue;/inventory/itemsis 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 pastMGR_APPROVED).
Fixed
- "Email to vendor" never rendered a real PDF (issue #14) — the auth middleware redirected PdfService's unauthenticated
svc-token export fetch to/loginbefore the route's token check ran, so the bypass never executed./api/po/<id>/exportis now allowed through when itssvctoken matchesPDF_SERVICE_TOKEN(lib/pdf-export-auth.ts); everything else stays auth-gated. - Reports comparison charts all rendered one colour —
SERIES_COLORSlived in a"use client"module and was imported by the server-component report pages, where a plain value becomes a client-reference proxy (soSERIES_COLORS[i]wasundefinedand recharts fell back to its default stroke). Moved the palette to a dependency-free shared module (lib/report-colors.ts). - Production
P2022 … column does not existafter deploy — caused by shipping code whose Prisma client expected a column beforemigrate deployhad run. Migrations must be applied before the new build serves traffic (now documented in the README).