mirror of
https://github.com/renee-png/acmcc.git
synced 2026-06-21 09:50:01 +00:00
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:
@@ -55,7 +55,7 @@ export default function AccountingAssessmentsPage() {
|
||||
queryKey: ["income-accounts", cid],
|
||||
enabled: !!cid,
|
||||
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;
|
||||
|
||||
@@ -89,7 +89,7 @@ export default function AccountingBillsPage() {
|
||||
queryKey: ["expense-accounts", cid],
|
||||
enabled: !!cid,
|
||||
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(
|
||||
@@ -320,7 +320,9 @@ export default function AccountingBillsPage() {
|
||||
queryKey: ["bank-accounts", cid],
|
||||
enabled: !!cid,
|
||||
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) => {
|
||||
@@ -404,7 +406,7 @@ export default function AccountingBillsPage() {
|
||||
};
|
||||
|
||||
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");
|
||||
setPaying(true);
|
||||
try {
|
||||
@@ -810,7 +812,7 @@ export default function AccountingBillsPage() {
|
||||
</Select>
|
||||
</div>
|
||||
<div>
|
||||
<Label>Bank account</Label>
|
||||
<Label>Payment account</Label>
|
||||
<Select value={payAccountId} onValueChange={setPayAccountId}>
|
||||
<SelectTrigger><SelectValue placeholder="Select account" /></SelectTrigger>
|
||||
<SelectContent>
|
||||
|
||||
@@ -53,7 +53,7 @@ export default function AccountingBudgetDetailPage({ basePath = "/dashboard/acco
|
||||
queryKey: ["accounts", cid],
|
||||
enabled: !!cid,
|
||||
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({
|
||||
|
||||
@@ -49,7 +49,7 @@ export default function AccountingDepositsPage() {
|
||||
queryKey: ["bank-accounts", cid],
|
||||
enabled: !!cid,
|
||||
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,
|
||||
@@ -58,7 +58,7 @@ export default function AccountingDepositsPage() {
|
||||
queryKey: ["all-accounts", cid],
|
||||
enabled: !!cid,
|
||||
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({
|
||||
|
||||
@@ -70,7 +70,8 @@ export default function AccountingExpensesPage() {
|
||||
const { data: accounts = [] } = useQuery({
|
||||
queryKey: ["bank-accounts", 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 = () => {
|
||||
|
||||
@@ -130,6 +130,7 @@ export default function AccountingInvoicesPage() {
|
||||
.select("id,name,code,balance,is_bank,is_system")
|
||||
.eq("company_id", cid)
|
||||
.or("is_bank.eq.true,name.eq.Undeposited Funds")
|
||||
.eq("is_archived", false)
|
||||
.order("code");
|
||||
return data ?? [];
|
||||
},
|
||||
|
||||
@@ -50,7 +50,7 @@ export default function AccountingJournalEntriesPage() {
|
||||
queryKey: ["accounts", cid],
|
||||
enabled: !!cid,
|
||||
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(
|
||||
|
||||
@@ -37,7 +37,7 @@ export default function AccountingOpeningBalancesPage() {
|
||||
const { data: accounts = [] } = useQuery({
|
||||
queryKey: ["accounts", 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({
|
||||
|
||||
@@ -42,7 +42,7 @@ export default function AccountingReceivePaymentsPage() {
|
||||
queryKey: ["bank-accounts", cid],
|
||||
enabled: !!cid,
|
||||
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({
|
||||
|
||||
@@ -90,7 +90,7 @@ export default function AccountingReconcileDetailPage() {
|
||||
queryKey: ["accounts", cid],
|
||||
enabled: !!cid,
|
||||
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({
|
||||
|
||||
@@ -59,7 +59,7 @@ export default function AccountingSalesReceiptsPage() {
|
||||
queryKey: ["income-accounts", cid],
|
||||
enabled: !!cid,
|
||||
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({
|
||||
@@ -71,6 +71,7 @@ export default function AccountingSalesReceiptsPage() {
|
||||
.select("id,name,code,is_system")
|
||||
.eq("company_id", cid)
|
||||
.or("is_bank.eq.true,name.eq.Undeposited Funds")
|
||||
.eq("is_archived", false)
|
||||
.order("code");
|
||||
return data ?? [];
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user