Payment accounts can be equity; archived accounts excluded from all dropdowns

- Bill payment + expense paid-through pickers now offer bank OR equity
  accounts (reserve-component style payments); label updated to
  'Payment account'
- is_archived=false filter added to every accounting account dropdown:
  journal entries, bills (expense + payment), expenses, invoices/sales
  receipts/receive payments deposit-to, deposits (bank + line source),
  assessments, opening balances, budget detail, reconciliation

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-12 20:38:00 -04:00
parent 920def8826
commit b4014f378c
11 changed files with 19 additions and 14 deletions
@@ -55,7 +55,7 @@ export default function AccountingAssessmentsPage() {
queryKey: ["income-accounts", cid], queryKey: ["income-accounts", cid],
enabled: !!cid, enabled: !!cid,
queryFn: async () => queryFn: async () =>
(await accounting.from("accounts").select("id,name,code").eq("company_id", cid).eq("type", "income").order("code")).data ?? [], (await accounting.from("accounts").select("id,name,code").eq("company_id", cid).eq("type", "income").eq("is_archived", false).order("code")).data ?? [],
}); });
const allSelected = selectedHomeowners.size === (homeowners as any[]).length && (homeowners as any[]).length > 0; const allSelected = selectedHomeowners.size === (homeowners as any[]).length && (homeowners as any[]).length > 0;
+6 -4
View File
@@ -89,7 +89,7 @@ export default function AccountingBillsPage() {
queryKey: ["expense-accounts", cid], queryKey: ["expense-accounts", cid],
enabled: !!cid, enabled: !!cid,
queryFn: async () => queryFn: async () =>
(await accounting.from("accounts").select("id,name,code,type").eq("company_id", cid).eq("type", "expense").order("code")).data ?? [], (await accounting.from("accounts").select("id,name,code,type").eq("company_id", cid).eq("type", "expense").eq("is_archived", false).order("code")).data ?? [],
}); });
const enriched = useMemo( const enriched = useMemo(
@@ -320,7 +320,9 @@ export default function AccountingBillsPage() {
queryKey: ["bank-accounts", cid], queryKey: ["bank-accounts", cid],
enabled: !!cid, enabled: !!cid,
queryFn: async () => queryFn: async () =>
(await accounting.from("accounts").select("id,name,code,balance,is_bank").eq("company_id", cid).eq("is_bank", true).order("code")).data ?? [], // Payment accounts: banks plus equity accounts (e.g. reserve components
// paid directly from equity). Archived accounts never appear.
(await accounting.from("accounts").select("id,name,code,balance,is_bank,type").eq("company_id", cid).or("is_bank.eq.true,type.eq.equity").eq("is_archived", false).order("code")).data ?? [],
}); });
const openPayment = async (b: any) => { const openPayment = async (b: any) => {
@@ -404,7 +406,7 @@ export default function AccountingBillsPage() {
}; };
const savePayment = async () => { const savePayment = async () => {
if (!payBill || !payAccountId) return toast.error("Bank account required"); if (!payBill || !payAccountId) return toast.error("Payment account required");
if (!payAmount || payAmount <= 0) return toast.error("Invalid amount"); if (!payAmount || payAmount <= 0) return toast.error("Invalid amount");
setPaying(true); setPaying(true);
try { try {
@@ -810,7 +812,7 @@ export default function AccountingBillsPage() {
</Select> </Select>
</div> </div>
<div> <div>
<Label>Bank account</Label> <Label>Payment account</Label>
<Select value={payAccountId} onValueChange={setPayAccountId}> <Select value={payAccountId} onValueChange={setPayAccountId}>
<SelectTrigger><SelectValue placeholder="Select account" /></SelectTrigger> <SelectTrigger><SelectValue placeholder="Select account" /></SelectTrigger>
<SelectContent> <SelectContent>
@@ -53,7 +53,7 @@ export default function AccountingBudgetDetailPage({ basePath = "/dashboard/acco
queryKey: ["accounts", cid], queryKey: ["accounts", cid],
enabled: !!cid, enabled: !!cid,
queryFn: async () => queryFn: async () =>
(await accounting.from("accounts").select("*").eq("company_id", cid).order("code")).data ?? [], (await accounting.from("accounts").select("*").eq("company_id", cid).eq("is_archived", false).order("code")).data ?? [],
}); });
const { data: existing = [] } = useQuery({ const { data: existing = [] } = useQuery({
@@ -49,7 +49,7 @@ export default function AccountingDepositsPage() {
queryKey: ["bank-accounts", cid], queryKey: ["bank-accounts", cid],
enabled: !!cid, enabled: !!cid,
queryFn: async () => queryFn: async () =>
(await accounting.from("accounts").select("id,name,code,balance").eq("company_id", cid).eq("is_bank", true).order("code")).data ?? [], (await accounting.from("accounts").select("id,name,code,balance").eq("company_id", cid).eq("is_bank", true).eq("is_archived", false).order("code")).data ?? [],
}); });
// All accounts — for the source-account picker on deposit lines (income, A/R, // All accounts — for the source-account picker on deposit lines (income, A/R,
@@ -58,7 +58,7 @@ export default function AccountingDepositsPage() {
queryKey: ["all-accounts", cid], queryKey: ["all-accounts", cid],
enabled: !!cid, enabled: !!cid,
queryFn: async () => queryFn: async () =>
(await accounting.from("accounts").select("id,name,code,type,balance").eq("company_id", cid).order("type").order("code")).data ?? [], (await accounting.from("accounts").select("id,name,code,type,balance").eq("company_id", cid).eq("is_archived", false).order("type").order("code")).data ?? [],
}); });
const { data: recentDeposits = [] } = useQuery({ const { data: recentDeposits = [] } = useQuery({
@@ -70,7 +70,8 @@ export default function AccountingExpensesPage() {
const { data: accounts = [] } = useQuery({ const { data: accounts = [] } = useQuery({
queryKey: ["bank-accounts", cid], queryKey: ["bank-accounts", cid],
enabled: !!cid, enabled: !!cid,
queryFn: async () => (await accounting.from("accounts").select("id,name").eq("company_id", cid).eq("is_bank", true).order("name")).data ?? [], // Paid-through accounts: banks plus equity accounts; archived hidden.
queryFn: async () => (await accounting.from("accounts").select("id,name").eq("company_id", cid).or("is_bank.eq.true,type.eq.equity").eq("is_archived", false).order("name")).data ?? [],
}); });
const reset = () => { const reset = () => {
@@ -130,6 +130,7 @@ export default function AccountingInvoicesPage() {
.select("id,name,code,balance,is_bank,is_system") .select("id,name,code,balance,is_bank,is_system")
.eq("company_id", cid) .eq("company_id", cid)
.or("is_bank.eq.true,name.eq.Undeposited Funds") .or("is_bank.eq.true,name.eq.Undeposited Funds")
.eq("is_archived", false)
.order("code"); .order("code");
return data ?? []; return data ?? [];
}, },
@@ -50,7 +50,7 @@ export default function AccountingJournalEntriesPage() {
queryKey: ["accounts", cid], queryKey: ["accounts", cid],
enabled: !!cid, enabled: !!cid,
queryFn: async () => queryFn: async () =>
(await accounting.from("accounts").select("*").eq("company_id", cid).order("code")).data ?? [], (await accounting.from("accounts").select("*").eq("company_id", cid).eq("is_archived", false).order("code")).data ?? [],
}); });
const detailEntry = useMemo( const detailEntry = useMemo(
@@ -37,7 +37,7 @@ export default function AccountingOpeningBalancesPage() {
const { data: accounts = [] } = useQuery({ const { data: accounts = [] } = useQuery({
queryKey: ["accounts", cid], queryKey: ["accounts", cid],
enabled: !!cid, enabled: !!cid,
queryFn: async () => (await accounting.from("accounts").select("id,name,code,type").eq("company_id", cid).order("code", { ascending: true })).data ?? [], queryFn: async () => (await accounting.from("accounts").select("id,name,code,type").eq("company_id", cid).eq("is_archived", false).order("code", { ascending: true })).data ?? [],
}); });
const { data: setup } = useQuery({ const { data: setup } = useQuery({
@@ -42,7 +42,7 @@ export default function AccountingReceivePaymentsPage() {
queryKey: ["bank-accounts", cid], queryKey: ["bank-accounts", cid],
enabled: !!cid, enabled: !!cid,
queryFn: async () => queryFn: async () =>
(await accounting.from("accounts").select("id,name,code,balance").eq("company_id", cid).eq("is_bank", true).order("name")).data ?? [], (await accounting.from("accounts").select("id,name,code,balance").eq("company_id", cid).eq("is_bank", true).eq("is_archived", false).order("name")).data ?? [],
}); });
const { data: openInvoices = [] } = useQuery({ const { data: openInvoices = [] } = useQuery({
@@ -90,7 +90,7 @@ export default function AccountingReconcileDetailPage() {
queryKey: ["accounts", cid], queryKey: ["accounts", cid],
enabled: !!cid, enabled: !!cid,
queryFn: async () => queryFn: async () =>
(await accounting.from("accounts").select("id,name,type").eq("company_id", cid).order("name")).data ?? [], (await accounting.from("accounts").select("id,name,type").eq("company_id", cid).eq("is_archived", false).order("name")).data ?? [],
}); });
const { data: txs = [] } = useQuery({ const { data: txs = [] } = useQuery({
@@ -59,7 +59,7 @@ export default function AccountingSalesReceiptsPage() {
queryKey: ["income-accounts", cid], queryKey: ["income-accounts", cid],
enabled: !!cid, enabled: !!cid,
queryFn: async () => queryFn: async () =>
(await accounting.from("accounts").select("id,name,code").eq("company_id", cid).eq("type", "income").order("code")).data ?? [], (await accounting.from("accounts").select("id,name,code").eq("company_id", cid).eq("type", "income").eq("is_archived", false).order("code")).data ?? [],
}); });
const { data: depositAccounts = [] } = useQuery({ const { data: depositAccounts = [] } = useQuery({
@@ -71,6 +71,7 @@ export default function AccountingSalesReceiptsPage() {
.select("id,name,code,is_system") .select("id,name,code,is_system")
.eq("company_id", cid) .eq("company_id", cid)
.or("is_bank.eq.true,name.eq.Undeposited Funds") .or("is_bank.eq.true,name.eq.Undeposited Funds")
.eq("is_archived", false)
.order("code"); .order("code");
return data ?? []; return data ?? [];
}, },