Add investments to All tab, withdrawal on create, modal fixes, and login logo

- Show investment subtable under All accounts tab (was only under Operating/Reserve)
- Add "Withdraw from primary account" switch (on by default) when creating
  investments; creates a journal entry to credit the primary asset account
  and debit the equity offset, keeping the books balanced
- Prevent all account modals from closing on outside click to avoid data loss
- Replace login page text title with the SVG logo

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-21 13:57:40 -05:00
parent d4ae5d1d33
commit 1e40848222
3 changed files with 90 additions and 14 deletions

View File

@@ -173,6 +173,7 @@ export function AccountsPage() {
maturityDate: null as Date | null,
purchaseDate: null as Date | null,
investmentNotes: '',
withdrawFromPrimary: true,
},
validate: {
accountNumber: (v, values) => isInvestmentType(values.accountType) ? null : (v > 0 ? null : 'Required'),
@@ -218,6 +219,7 @@ export function AccountsPage() {
purchase_date: values.purchaseDate ? values.purchaseDate.toISOString().split('T')[0] : null,
current_value: values.principal,
notes: values.investmentNotes || null,
withdraw_from_primary: values.withdrawFromPrimary,
});
}
return api.post('/accounts', values);
@@ -515,13 +517,21 @@ export function AccountsPage() {
</Tabs.List>
<Tabs.Panel value="all" pt="sm">
<AccountTable
accounts={activeAccounts}
onEdit={handleEdit}
onArchive={archiveMutation.mutate}
onSetPrimary={(id) => setPrimaryMutation.mutate(id)}
onAdjustBalance={handleAdjustBalance}
/>
<Stack>
<AccountTable
accounts={activeAccounts}
onEdit={handleEdit}
onArchive={archiveMutation.mutate}
onSetPrimary={(id) => setPrimaryMutation.mutate(id)}
onAdjustBalance={handleAdjustBalance}
/>
{investments.filter(i => i.is_active).length > 0 && (
<>
<Divider label="Investment Accounts" labelPosition="center" my="xs" />
<InvestmentMiniTable investments={investments.filter(i => i.is_active)} onEdit={handleEditInvestment} />
</>
)}
</Stack>
</Tabs.Panel>
<Tabs.Panel value="operating" pt="sm">
<Stack>
@@ -577,6 +587,7 @@ export function AccountsPage() {
onClose={close}
title={editing ? 'Edit Account' : isInvestmentType(form.values.accountType) ? 'New Investment Account' : 'New Account'}
size="md"
closeOnClickOutside={false}
>
<form onSubmit={form.onSubmit((values) => createMutation.mutate(values))}>
<Stack>
@@ -680,6 +691,20 @@ export function AccountsPage() {
maxRows={4}
{...form.getInputProps('investmentNotes')}
/>
<Divider my="xs" />
{(() => {
const primaryAcct = accounts.find(
(a) => a.is_primary && a.fund_type === form.values.fundType && !a.is_system,
);
return (
<Switch
label={`Withdraw from primary account${primaryAcct ? ` (${primaryAcct.name})` : ''}`}
description="Creates a journal entry to deduct the principal from your primary account"
{...form.getInputProps('withdrawFromPrimary', { type: 'checkbox' })}
disabled={!primaryAcct}
/>
);
})()}
</>
)}
@@ -707,7 +732,7 @@ export function AccountsPage() {
</Modal>
{/* Balance Adjustment Modal */}
<Modal opened={adjustOpened} onClose={closeAdjust} title="Adjust Balance" size="md">
<Modal opened={adjustOpened} onClose={closeAdjust} title="Adjust Balance" size="md" closeOnClickOutside={false}>
{adjustingAccount && (
<form onSubmit={adjustForm.onSubmit(handleAdjustSubmit)}>
<Stack>
@@ -762,7 +787,7 @@ export function AccountsPage() {
</Modal>
{/* Investment Edit Modal */}
<Modal opened={invEditOpened} onClose={closeInvEdit} title="Edit Investment Account" size="md">
<Modal opened={invEditOpened} onClose={closeInvEdit} title="Edit Investment Account" size="md" closeOnClickOutside={false}>
{editingInvestment && (
<form onSubmit={invForm.onSubmit((values) => updateInvestmentMutation.mutate(values))}>
<Stack>