From 3bf6b8c6c94b718ec2c1f6862c0c709afc0c1f1a Mon Sep 17 00:00:00 2001 From: olsch01 Date: Sun, 8 Mar 2026 19:49:23 -0400 Subject: [PATCH 1/3] fix: update password when adding existing user to new org When an existing user was added to a new organization via the member management UI, the password entered in the form was silently ignored. This caused the user to be unable to log in with the password they were given, since the hash in the database was from their original account creation for a different org. Co-Authored-By: Claude Opus 4.6 --- .../src/modules/organizations/organizations.service.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/backend/src/modules/organizations/organizations.service.ts b/backend/src/modules/organizations/organizations.service.ts index e690bbe..0afff92 100644 --- a/backend/src/modules/organizations/organizations.service.ts +++ b/backend/src/modules/organizations/organizations.service.ts @@ -153,6 +153,14 @@ export class OrganizationsService { existing.role = data.role; return this.userOrgRepository.save(existing); } + // Update password for existing user being added to a new org + if (data.password) { + const passwordHash = await bcrypt.hash(data.password, 12); + await dataSource.query( + `UPDATE shared.users SET password_hash = $1 WHERE id = $2`, + [passwordHash, userId], + ); + } } else { // Create new user const passwordHash = await bcrypt.hash(data.password, 12); From ac72905ecb43ff01efa328828ca77be580fe75de Mon Sep 17 00:00:00 2001 From: olsch01 Date: Tue, 10 Mar 2026 09:17:08 -0400 Subject: [PATCH 2/3] fix: add total_debit/total_credit aggregations to journal entries list The findAll query was missing SUM aggregations, so the frontend received no total_debit/total_credit fields and fell back to displaying $0.00. Co-Authored-By: Claude Opus 4.6 --- backend/src/modules/journal-entries/journal-entries.service.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/backend/src/modules/journal-entries/journal-entries.service.ts b/backend/src/modules/journal-entries/journal-entries.service.ts index 4f67d5c..dc768b0 100644 --- a/backend/src/modules/journal-entries/journal-entries.service.ts +++ b/backend/src/modules/journal-entries/journal-entries.service.ts @@ -13,6 +13,8 @@ export class JournalEntriesService { async findAll(filters: { from?: string; to?: string; accountId?: string; type?: string }) { let sql = ` SELECT je.*, + COALESCE(SUM(jel.debit), 0) as total_debit, + COALESCE(SUM(jel.credit), 0) as total_credit, json_agg(json_build_object( 'id', jel.id, 'account_id', jel.account_id, 'debit', jel.debit, 'credit', jel.credit, 'memo', jel.memo, From b0282b7f8b0887dce2c578923e17a5119070b5ac Mon Sep 17 00:00:00 2001 From: olsch01 Date: Tue, 10 Mar 2026 09:41:26 -0400 Subject: [PATCH 3/3] fix: show P&L debit/credit totals on journal entries list The previous aggregation used simple SUM(debit)/SUM(credit) which always produced equal values for balanced entries. This was misleading for entries with income/expense lines (e.g., monthly actuals). Now, when an entry has income/expense lines, the totals reflect only P&L account activity (expenses as debits, income as credits), excluding the cash offset. For balance-sheet-only entries (opening balances, adjustments), the full entry totals are shown. Co-Authored-By: Claude Opus 4.6 --- .../journal-entries/journal-entries.service.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/backend/src/modules/journal-entries/journal-entries.service.ts b/backend/src/modules/journal-entries/journal-entries.service.ts index dc768b0..95098a3 100644 --- a/backend/src/modules/journal-entries/journal-entries.service.ts +++ b/backend/src/modules/journal-entries/journal-entries.service.ts @@ -13,8 +13,16 @@ export class JournalEntriesService { async findAll(filters: { from?: string; to?: string; accountId?: string; type?: string }) { let sql = ` SELECT je.*, - COALESCE(SUM(jel.debit), 0) as total_debit, - COALESCE(SUM(jel.credit), 0) as total_credit, + CASE + WHEN SUM(CASE WHEN a.account_type IN ('income','expense') THEN 1 ELSE 0 END) > 0 + THEN COALESCE(SUM(CASE WHEN a.account_type IN ('income','expense') THEN jel.debit ELSE 0 END), 0) + ELSE COALESCE(SUM(jel.debit), 0) + END as total_debit, + CASE + WHEN SUM(CASE WHEN a.account_type IN ('income','expense') THEN 1 ELSE 0 END) > 0 + THEN COALESCE(SUM(CASE WHEN a.account_type IN ('income','expense') THEN jel.credit ELSE 0 END), 0) + ELSE COALESCE(SUM(jel.credit), 0) + END as total_credit, json_agg(json_build_object( 'id', jel.id, 'account_id', jel.account_id, 'debit', jel.debit, 'credit', jel.credit, 'memo', jel.memo,