feat(reports): financial hasData existence flag (service + route)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -630,3 +630,23 @@ export async function getExpenseLedger(
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Window-independent existence check: does this port have any payment OR
|
||||
* expense? Drives the Financial report-level empty state.
|
||||
*/
|
||||
export async function financialHasData(portId: string): Promise<boolean> {
|
||||
const [pay, exp] = await Promise.all([
|
||||
db
|
||||
.select({ one: sql<number>`1` })
|
||||
.from(payments)
|
||||
.where(eq(payments.portId, portId))
|
||||
.limit(1),
|
||||
db
|
||||
.select({ one: sql<number>`1` })
|
||||
.from(expenses)
|
||||
.where(eq(expenses.portId, portId))
|
||||
.limit(1),
|
||||
]);
|
||||
return pay.length > 0 || exp.length > 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user