ImanThiyanga c41aed9a80 Move the GL account mapping out of appsettings into validated master data
The per-module Gl*Code appsettings keys pinned GL's account *codes* in
ERPCore's config, while GL generates codes positionally and refuses a
requested one. Nothing connected the two, so "1100 means Inventory" held
only because someone once created accounts in a particular order - and on
2026-10-07 eleven of the twelve configured codes turned out never to have
existed in GL. Every GRN, adjustment, day-end, invoice and FIFO posting had
been failing with "Account <code> not found".

The mapping is now master data in gl_account_config, keyed by accounting
role rather than by module, and GlAccountConfigService validates every
submitted code against GL's live chart of accounts before storing it. A
code GL does not have, or cannot post to, is refused with the role named -
so the mismatch is unrepresentable rather than merely detected. Correcting
a mapping no longer needs a redeploy.

Notes:
- Fails closed on save (503 if GL is unreachable), deliberately opposite to
  the startup validator, which must still let the app serve.
- Non-postable accounts are rejected too: GL rejects a journal line against
  one, so storing it only defers the failure. The auto-created 1000
  Bank/Cash header is exactly that trap.
- The settings endpoint also serves the selectable accounts, because
  GeneralLedgerController is gated on `ledgers` while this is on `settings`
  - and it keeps the picker and the validation list the same data.
- Reading an unmapped role throws naming the role, instead of posting ""
  and letting GL return an opaque 404 from inside a transaction.
- The appsettings keys are now seed-only: DataSeeder copies them in once so
  existing deployments keep their current mapping. No runtime fallback, or
  there would be two sources of truth again.
- The 32 read sites across 11 services collapsed to 12 roles, since every
  module carried the same value for a given role.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-10-07 13:04:49 +05:30
2026-10-05 17:40:04 +05:30

ERP System — Inventory & Supply Chain (Phase 1)

A modular ERP built in phases. Phase 1 delivers Inventory & Supply Chain: master data, procurement, goods receipt, and stock management with FIFO costing, multi-warehouse, single-tenant.

Monorepo: a .NET 10 REST API backend and a Next.js frontend, with all documentation under docs/.

Repository layout

erp-monorepo/
├── Backend/      # ASP.NET Core Web API (.NET 10, PostgreSQL) + PROGRESS.md
├── Frontend/     # Next.js (App Router, TypeScript) + PROGRESS.md
└── docs/         # all documentation — START AT docs/00-CORE.md

Start here

All work begins at docs/00-CORE.md — the hub. It defines structure, tech stack, backend setup, and routes you to the right doc.

Doc Purpose
docs/00-CORE.md Hub: structure, stack, backend init, routing
docs/01-DOC-GUIDE.md Doc map, reading order, tracking conventions
docs/10-BACKEND-PHASE1.md Backend spec: SRS + ER model + architecture
docs/11-BACKEND-PHASE1.md Backend API reference (complete req/res)
docs/20-FRONTEND.md Frontend user-flows + rules + validation posture
Backend/PROGRESS.md, Frontend/PROGRESS.md Change checklists (git-shared)

Prerequisites

  • .NET 10 SDK (dotnet --version → 10.0.x)
  • PostgreSQL running on localhost
  • dotnet-ef tool (dotnet tool install --global dotnet-ef)
  • Node.js (for the frontend)

Run the backend

# create the database in your local Postgres first, e.g.:
#   createdb -U postgres ERPCore   (or: CREATE DATABASE "ERPCore"; in psql)
cd Backend/ERPCore
# set Username/Password in appsettings.Development.json to your local Postgres login
dotnet ef database update
dotnet run
  • Swagger UI: https://localhost:<port>/swagger
  • Health: https://localhost:<port>/health → Healthy

Full setup (packages, folder scaffold, Program.cs wiring) is in docs/00-CORE.md §5.

Run the frontend

cd Frontend
cp .env.local.example .env.local      # set NEXT_PUBLIC_API_BASE_URL=https://localhost:<port>
npm install
npm run dev

Configuration & secrets

  • Three appsettings files: base (appsettings.json, placeholders only), Development (localhost), Production (env vars).
  • Local dev only currently. Before any shared/staging/production use, move secrets to User Secrets (dev) and environment variables (prod), keep appsettings.Development.json / appsettings.Production.json out of git, and rotate any credential ever committed.

Tech stack

Backend: .NET 10, ASP.NET Core Web API, EF Core 10, PostgreSQL (Npgsql), JWT bearer auth, Serilog, Swashbuckle/Swagger, HealthChecks. Layering: Controller → Service → Repository → UnitOfWork, DTOs at the controller boundary, FIFO in a domain service. Frontend: Next.js (App Router) + TypeScript, plain React hooks, dependency-free validation (client for UX; server is authoritative).

Conventions

  • Documentation: one source of truth per topic; edit in place; navigate from docs/00-CORE.md.
  • Progress: update the relevant PROGRESS.md in the same commit as the code (docs/01-DOC-GUIDE.md §6).

Roadmap (future phases)

Sales & CRM · Manufacturing & Production · QC/QA · Accounting · HRM. Phase 1 reserves the integration seams (GL-ready journal entries, reservation status, goods-issue movement, inspection hold, user identity) so later phases integrate without a schema migration.

S
Description
No description provided
Readme 43 MiB
Languages
TypeScript 50.4%
C# 47.8%
Python 1.7%
CSS 0.1%