Commit Graph

283 Commits

Author SHA1 Message Date
ImanThiyanga a3591d3643 Sync package-lock.json with package.json so npm ci works again
html-to-image and jspdf were added to package.json without being added to
the lockfile, so `npm ci` - which the frontend Dockerfile runs - failed
with the package.json/package-lock.json out-of-sync error. tsc also could
not resolve either module in SalesInvoicePrint.tsx.

Pre-existing and unrelated to the GL account work; found because the GL
Accounts screen could not be build-verified without it.

Adds those two plus their transitive deps. It also drops @emnapi/core and
@emnapi/runtime: both are optional, and required only by the wasm32-wasi /
sharp-wasm32 variants, which linux-x64 never selects in favour of the
native binaries - so the Docker build is unaffected.

Verified: npm ci succeeds, tsc --noEmit is clean, npm run build compiles.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-10-07 13:17:52 +05:30
ImanThiyanga c30ff473f5 Add the GL Accounts settings screen
Pickers are populated from GL's own chart of accounts, postable and active
accounts only, so a user can only choose a code the server will accept. A
stored code GL does not have is shown flagged and still selected rather
than appearing blank, which is the state 11 of the 12 mappings are in until
GL's chart is seeded - the broken mapping stays visible instead of looking
merely unset.

Options come from /gl-account-config rather than the GL proxy: that proxy
is gated on the `ledgers` nav permission while this screen is on
`settings`, and one endpoint keeps the picker and the server-side
validation working from the same list. Gated on the existing `settings` key
so no role_permissions edit is needed.

Saving is disabled outright while GL is unreachable, matching the server,
which refuses to store a mapping it could not verify.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-10-07 13:17:22 +05:30
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
ImanThiyanga 614df3065d Add GL account configuration and role mapping entities
- Introduced GlAccountConfig entity for mapping accounting roles to GL account codes.
- Added GlAccountConfigConfiguration for database configuration of the singleton GL account mapping.
- Created GlAccountRole enum to define accounting roles used in GL postings.
- Enhanced error handling with new error codes for unconfigured and invalid GL accounts.
- Updated existing DbContext to include GlAccountConfig DbSet.
2026-10-07 12:51:15 +05:30
ImanThiyanga 65976c5cd3 Merge branch 'production' into Dev
CI/CD - ERP Core Monorepo / Build & Deploy Frontend (pull_request) Failing after 11m15s
CI/CD - ERP Core Monorepo / Build & Deploy Backend (pull_request) Failing after 12m33s
2026-10-07 06:40:39 +00:00
ImanThiyanga 3c8837e21e Stop the GL account-code check from being able to abort startup
The catch filter only matched DomainException/OperationCanceledException,
so anything else escaped a hosted service and took the host down. One such
path was mine: `"items": null` deserializes over the property initialiser,
so `data.Items.Select(...)` would NullReferenceException straight past the
filter.

Fixed at both ends - the reader tolerates a null or absent items array, and
the catch is now a deliberate catch-all that only lets a genuine host
shutdown through. This is a diagnostic; a diagnostic that can core-dump the
thing it diagnoses is worse than no diagnostic at all.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-10-07 11:53:31 +05:30
ImanThiyanga 63c8c8457f Merge pull request 'Make the GL account-code check report instead of refusing to start' (#105) from Dev into production
Reviewed-on: #105
2026-10-07 06:14:37 +00:00
ImanThiyanga e0601d5a8d Merge branch 'production' into Dev
CI/CD - ERP Core Monorepo / Build & Deploy Frontend (pull_request) Failing after 12m25s
CI/CD - ERP Core Monorepo / Build & Deploy Backend (pull_request) Failing after 13m43s
2026-10-07 06:14:29 +00:00
ImanThiyanga 9eab6372b3 Make the GL account-code check report instead of refusing to start
The check shipped in f753cae threw on a missing code, which core-dumped
erpcore.service on deploy: 11 of the 12 configured Gl*Code values turned
out never to have existed in GL's chart of accounts, so a long-standing
mismatch became an immediate outage.

Detection was the point; refusing to serve the rest of the app was not.
GL already rejects a posting to an unknown account, so the per-flow error
stays the real enforcement — this now logs the whole set at Error once at
boot instead of surfacing one flow at a time.

Hard-fail is still available behind
GeneralLedgerService:FailOnMissingAccountCodes, for once the chart of
accounts is known-good and drift should stop a deploy.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-10-07 11:40:46 +05:30
ImanThiyanga 92f571bbf1 Merge pull request 'Refactor GL period and entry date handling to use BusinessClock for accurate date resolution; add GlAccountCodeValidator for startup validation of configured account codes.' (#104) from Dev into production
Reviewed-on: #104
2026-10-07 05:57:54 +00:00
ImanThiyanga b236b2b126 Merge branch 'production' into Dev
CI/CD - ERP Core Monorepo / Build & Deploy Frontend (pull_request) Failing after 14m6s
CI/CD - ERP Core Monorepo / Build & Deploy Backend (pull_request) Failing after 15m25s
2026-10-07 05:57:43 +00:00
ImanThiyanga f753cae82d Refactor GL period and entry date handling to use BusinessClock for accurate date resolution; add GlAccountCodeValidator for startup validation of configured account codes. 2026-10-07 11:27:12 +05:30
ImanThiyanga 533b642367 Merge pull request 'Fix MariaDB CHECK constraint quoting that crash-looped startup seeding' (#103) from Dev into production
Reviewed-on: #103
2026-10-05 13:02:54 +00:00
ImanThiyanga ea8c8210e5 Merge branch 'production' into Dev
CI/CD - ERP Core Monorepo / Build & Deploy Frontend (pull_request) Failing after 14m4s
CI/CD - ERP Core Monorepo / Build & Deploy Backend (pull_request) Failing after 15m25s
2026-10-05 13:02:47 +00:00
ImanThiyanga c97a7e9ae6 Fix MariaDB CHECK constraint quoting that crash-looped startup seeding
Three CHECK constraints shipped with PostgreSQL identifier quoting left over
from the MySQL port:

  ck_grn_config_singleton       CHECK ("ConfigId" = 1)
  ck_sales_config_singleton     CHECK ("ConfigId" = 1)
  ck_warranty_periods_months    CHECK ("Months" BETWEEN 1 AND 600)

ANSI_QUOTES is not in MariaDB's default sql_mode, so a double-quoted token is a
*string literal*, not an identifier. `"ConfigId" = 1` therefore evaluates as
`'ConfigId' = 1`; MariaDB coerces the string to a number to compare it and,
under strict mode, raises `Truncated incorrect DECIMAL value: 'ConfigId'`.

The DDL creates fine and only breaks at runtime, so this got through the
deploy and then failed every INSERT into grn_config, sales_config and
warranty_periods. That includes DataSeeder's two singleton config rows, which
run immediately after MigrateAsync() in Program.cs — so the service threw
"Database migration succeeded, but startup seeding failed" on every boot and
systemd restart-looped (counter reached 110, each restart dumping core).

Fixed in the entity configurations and repaired on existing databases by
migration 20261005190000_FixCheckConstraintQuotingForMySql, which drops and
re-adds the three constraints with backticks. The drop/add is emitted as raw
SQL rather than DropCheckConstraint because MariaDB spells the removal
DROP CONSTRAINT, not MySQL's DROP CHECK; IF EXISTS keeps it re-runnable on a
database where the broken constraint was already removed by hand.

The identical trap was swept during the port itself; these three were
reintroduced by a feature migration written afterwards.

No data cleanup is needed: the failing inserts never committed, so the
affected tables are empty.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-10-05 18:26:25 +05:30
ImanThiyanga 673ef06856 Merge pull request 'Dev' (#102) from Dev into production
Reviewed-on: #102
2026-10-05 12:11:38 +00:00
ImanThiyanga 16a382a8ea Merge branch 'production' into Dev
CI/CD - ERP Core Monorepo / Build & Deploy Frontend (pull_request) Failing after 10m25s
CI/CD - ERP Core Monorepo / Build & Deploy Backend (pull_request) Failing after 11m42s
2026-10-05 12:11:30 +00:00
ImanThiyanga eae9dbb30d Merge pull request 'update on production db' (#101) from feat/mysql-migration into Dev
Reviewed-on: #101
2026-10-05 12:11:05 +00:00
ImanThiyanga 4efd5bda75 Merge branch 'Dev' into feat/mysql-migration 2026-10-05 12:10:58 +00:00
ImanThiyanga dbf9e841f8 update on production db 2026-10-05 17:40:04 +05:30
ImanThiyanga 0ad5a1a71d Merge pull request 'Dev' (#100) from Dev into production
Reviewed-on: #100
2026-10-05 11:47:07 +00:00
ImanThiyanga c1405da8d2 Merge branch 'production' into Dev
CI/CD - ERP Core Monorepo / Build & Deploy Backend (pull_request) Failing after 11m11s
CI/CD - ERP Core Monorepo / Build & Deploy Frontend (pull_request) Failing after 14m58s
2026-10-05 11:47:00 +00:00
ImanThiyanga cc83a3e59f Merge pull request 'Feat/mysql migration' (#99) from feat/mysql-migration into Dev
Reviewed-on: #99
2026-10-05 11:46:12 +00:00
ImanThiyanga 8706c2557b initiating db migration 2026-10-05 17:15:08 +05:30
ImanThiyanga 9503ea5fe8 fix after migrations 2026-10-05 17:14:42 +05:30
ImanThiyanga 65f58c4000 adding complete db migrations from posgres 2026-10-05 16:11:35 +05:30
ImanThiyanga 9d710349c2 Refactor code structure for improved readability and maintainability; removed redundant code blocks and optimized function calls. 2026-10-05 16:03:31 +05:30
kalana_Thilakarathna 535616c48f Merge pull request 'Dev' (#98) from Dev into production
Reviewed-on: #98
2026-10-05 10:07:55 +00:00
kalana_Thilakarathna c6c9c6a9dd Merge branch 'production' into Dev
CI/CD - ERP Core Monorepo / Build & Deploy Frontend (pull_request) Failing after 13m53s
CI/CD - ERP Core Monorepo / Build & Deploy Backend (pull_request) Failing after 15m25s
2026-10-05 10:07:50 +00:00
kalana_Thilakarathna dedb42365e Merge pull request 'Day end sales fixers' (#97) from day-end-sales-fixers into Dev
Reviewed-on: #97
2026-10-05 10:07:34 +00:00
Sasanka f4ec3b4c65 fixers of day end sales and sales 2026-10-05 13:11:01 +05:30
ashan_rusiru 6c707d88b1 Merge pull request 'sales & grn fixers' (#94) from sales-&-GRN-fixers into production
Reviewed-on: #94
2026-10-04 11:42:29 +00:00
ashan_rusiru 759c512281 Merge branch 'production' into sales-&-GRN-fixers
CI/CD - ERP Core Monorepo / Build & Deploy Backend (pull_request) Failing after 10m50s
CI/CD - ERP Core Monorepo / Build & Deploy Frontend (pull_request) Failing after 14m14s
2026-10-04 11:42:19 +00:00
Sasanka 3d3dbbbb59 sales & grn fixers 2026-10-04 15:31:59 +05:30
ashan_rusiru f4591a193a Merge pull request 'product and sales fixers' (#93) from product-and-sales-fixers into production
Reviewed-on: #93
2026-10-04 06:57:46 +00:00
ashan_rusiru 791d853c72 Merge branch 'production' into product-and-sales-fixers
CI/CD - ERP Core Monorepo / Build & Deploy Frontend (pull_request) Failing after 13m51s
CI/CD - ERP Core Monorepo / Build & Deploy Backend (pull_request) Failing after 15m33s
2026-10-04 06:57:30 +00:00
Sasanka cea433e320 product and sales fixers 2026-09-30 17:06:28 +05:30
ImanThiyanga cba2f91689 Merge pull request 'Dev' (#91) from Dev into production
Reviewed-on: #91
2026-09-25 09:04:19 +00:00
ImanThiyanga 9fd290e256 Merge branch 'production' into Dev
CI/CD - ERP Core Monorepo / Build & Deploy Frontend (pull_request) Failing after 12m38s
CI/CD - ERP Core Monorepo / Build & Deploy Backend (pull_request) Failing after 14m1s
2026-09-25 09:03:39 +00:00
ImanThiyanga 20ecfdc0b2 Merge pull request 'fixing recipts in sales' (#90) from sales-changes into Dev
Reviewed-on: #90
2026-09-25 09:03:21 +00:00
ImanThiyanga dd82f5b5c4 Merge branch 'Dev' into sales-changes 2026-09-25 09:03:15 +00:00
ImanThiyanga ce55d647b5 Merge pull request 'fron build failure fix' (#89) from Dev into production
Reviewed-on: #89
2026-09-25 06:58:55 +00:00
ImanThiyanga 268b6562dc Merge branch 'production' into Dev
CI/CD - ERP Core Monorepo / Build & Deploy Frontend (pull_request) Failing after 12m50s
CI/CD - ERP Core Monorepo / Build & Deploy Backend (pull_request) Failing after 14m24s
2026-09-25 06:58:48 +00:00
ImanThiyanga b389c01dfe fron build failure fix 2026-09-25 12:28:20 +05:30
Sasanka d24072e20a fixing recipts in sales 2026-09-24 17:02:33 +05:30
ashan_rusiru 9185d39c39 Merge pull request 'Dev' (#88) from Dev into production
Reviewed-on: #88
2026-09-24 07:12:59 +00:00
ashan_rusiru a2790c13bb Merge branch 'production' into Dev
CI/CD - ERP Core Monorepo / Build & Deploy Frontend (pull_request) Failing after 13m26s
CI/CD - ERP Core Monorepo / Build & Deploy Backend (pull_request) Failing after 15m18s
2026-09-24 07:12:52 +00:00
ashan_rusiru 940583552a Merge pull request 'Ui fixers and responsivenes' (#87) from ui-fixers-and-responsivenes into Dev
Reviewed-on: #87
2026-09-24 07:09:52 +00:00
Sasanka 049c98298a Ui fixings 2026-09-24 12:30:21 +05:30
Sasanka f5e8e0e5b9 responsiveness and ui fixers 2026-09-23 16:55:46 +05:30