From ad74072061b25f8c97c0de3ff581f13ae84c59ef Mon Sep 17 00:00:00 2001 From: renee-png Date: Thu, 18 Jun 2026 23:18:56 -0400 Subject: [PATCH] Transaction dialogs: allow all account types as the category Banking deposit/payment + bulk-categorize and the reconcile add-transaction dialog previously limited the category to income (deposits) or expense (payments). Now every account type is selectable, grouped by Income / Expense / Assets / Liabilities / Equity (with codes); the direction's natural type is listed first. Co-Authored-By: Claude Opus 4.8 --- .../accounting/AccountingBankingPage.tsx | 51 ++++++++++--------- .../AccountingReconcileDetailPage.tsx | 24 ++++++--- 2 files changed, 43 insertions(+), 32 deletions(-) diff --git a/src/pages/accounting/AccountingBankingPage.tsx b/src/pages/accounting/AccountingBankingPage.tsx index c97a3d4..141e2c8 100644 --- a/src/pages/accounting/AccountingBankingPage.tsx +++ b/src/pages/accounting/AccountingBankingPage.tsx @@ -156,6 +156,17 @@ export default function AccountingBankingPage() { const bankAccounts = useMemo(() => (accounts as any[]).filter((a) => a.is_bank), [accounts]); const incomeAccounts = useMemo(() => (accounts as any[]).filter((a) => a.type === "income"), [accounts]); const expenseAccounts = useMemo(() => (accounts as any[]).filter((a) => a.type === "expense"), [accounts]); + // All account types are selectable as the offsetting account/category — the + // natural type for the direction (income for deposits, expense for payments) + // is listed first, then the rest (assets, liabilities, equity). + const coaGroupsFor = (type: "credit" | "debit") => { + const g = (t: string) => (accounts as any[]).filter((a) => a.type === t); + const order = type === "credit" + ? ["income", "expense", "asset", "liability", "equity"] + : ["expense", "income", "asset", "liability", "equity"]; + const label: Record = { income: "Income", expense: "Expense", asset: "Assets", liability: "Liabilities", equity: "Equity" }; + return order.map((t) => ({ label: label[t], items: g(t) })).filter((grp) => grp.items.length > 0); + }; const { data: vendors = [] } = useQuery({ queryKey: ["vendors-lookup", cid], @@ -541,7 +552,6 @@ export default function AccountingBankingPage() { }); }; - const coaOptions = txForm.type === "credit" ? incomeAccounts : expenseAccounts; const saveTransfer = async () => { const { from_account_id, to_account_id, date, memo } = transfer; @@ -797,22 +807,14 @@ export default function AccountingBankingPage() { @@ -999,19 +1001,20 @@ export default function AccountingBankingPage() { )}
- + diff --git a/src/pages/accounting/AccountingReconcileDetailPage.tsx b/src/pages/accounting/AccountingReconcileDetailPage.tsx index 063efb6..82da21d 100644 --- a/src/pages/accounting/AccountingReconcileDetailPage.tsx +++ b/src/pages/accounting/AccountingReconcileDetailPage.tsx @@ -15,7 +15,7 @@ import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter, DialogDescription, } from "@/components/ui/dialog"; import { - Select, SelectContent, SelectItem, SelectTrigger, SelectValue, + Select, SelectContent, SelectItem, SelectTrigger, SelectValue, SelectGroup, SelectLabel, } from "@/components/ui/select"; import { Table, TableHeader, TableRow, TableHead, TableBody, TableCell } from "@/components/ui/table"; import { ArrowLeft, CheckCircle2, AlertTriangle, FileDown, Search, Loader2, ArrowUp, ArrowDown, ChevronsUpDown, Plus, Ban, Pencil } from "lucide-react"; @@ -136,7 +136,7 @@ export default function AccountingReconcileDetailPage() { queryKey: ["accounts", cid, "recon"], enabled: !!cid, queryFn: async () => - (await accounting.from("accounts").select("id,name,type,is_bank").eq("company_id", cid).eq("is_archived", false).order("name")).data ?? [], + (await accounting.from("accounts").select("id,name,code,type,is_bank").eq("company_id", cid).eq("is_archived", false).order("code")).data ?? [], }); const { data: vendors = [] } = useQuery({ @@ -856,15 +856,23 @@ export default function AccountingReconcileDetailPage() { placeholder={addTx.type === "credit" ? "e.g. Interest earned" : "e.g. Bank service charge"} />
- +