Files
Joshua OosthuizenandClaude Sonnet 5 4acbc03b35 Initial commit: multi-company financial management system
Root company app (src/, client/) — GL foundation, AR, and AP:
- Segmented Chart of Accounts (Sage 300-style), double-entry PostingService with
  three-layer balance enforcement (app validation, CHECK constraints, deferred
  DB trigger), gap-free document numbering, RBAC with branch restrictions.
- Accounts Receivable: Customers, Invoices, Credit Notes, Receipts with
  allocation, all posting through PostingService.
- Accounts Payable: Suppliers, Supplier Invoices, Debit Notes, Payments with
  allocation, mirroring AR's posting pattern.
- Tax Codes shared between AR and AP.
- Company-app login is a token handoff from the Account Manager (RS256,
  single-use, company-scoped) rather than a local password.
- Frontend reskinned to the approved mockup: navy sidebar, dashboard, tree-view
  Chart of Accounts, Customer/Supplier 360 pages.

Account Manager (manager/, manager/client/) — central login gateway:
- Password + TOTP 2FA + Google/Microsoft OAuth, company picker, and the RS256
  handoff token issuance that the company app verifies.

Covered by unit + integration tests against a real Postgres database (GL
balance invariants, AR/AP posting correctness and allocation limits, the full
handoff exchange including replay/cross-company/expiry/forgery rejection).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tq2DbEvzHzs13jDFhLaX44
2026-09-03 13:27:19 +02:00

54 lines
1.6 KiB
TypeScript

import { PrismaClient } from '@prisma/client';
import bcrypt from 'bcryptjs';
const prisma = new PrismaClient();
async function main() {
console.log('Seeding operator Person...');
const operatorEmail = 'joosth2002@icloud.com';
const passwordHash = await bcrypt.hash('ChangeMe123!', 12);
const operator = await prisma.person.upsert({
where: { email: operatorEmail },
create: { email: operatorEmail, fullName: 'System Administrator', isOperator: true },
update: { isOperator: true },
});
await prisma.passwordCredential.upsert({
where: { personId: operator.id },
create: { personId: operator.id, passwordHash },
update: {},
});
console.log('Seeding the one manually-provisioned company (Phase A)...');
const company = await prisma.company.upsert({
where: { slug: 'demo' },
create: {
name: 'Demo Company',
slug: 'demo',
status: 'ACTIVE',
port: 5000,
publicUrl: 'http://localhost:5173',
provisionedAt: new Date(),
},
update: { status: 'ACTIVE', publicUrl: 'http://localhost:5173' },
});
await prisma.personCompanyMembership.upsert({
where: { personId_companyId: { personId: operator.id, companyId: company.id } },
create: { personId: operator.id, companyId: company.id },
update: { isActive: true },
});
console.log(`Seed complete. Sign in as ${operatorEmail} with temporary password "ChangeMe123!" — change it after first login.`);
}
main()
.catch((error) => {
console.error(error);
process.exitCode = 1;
})
.finally(async () => {
await prisma.$disconnect();
});