feat(cfdi): add autocomplete for emisor and receptor filters
- Add /cfdi/emisores and /cfdi/receptores API endpoints - Search by RFC or nombre with ILIKE - Show suggestions dropdown while typing (min 2 chars) - Click suggestion to select and populate filter input - Show loading state while searching Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -387,6 +387,28 @@ export async function deleteCfdi(schema: string, id: string): Promise<void> {
|
||||
await prisma.$queryRawUnsafe(`DELETE FROM "${schema}".cfdis WHERE id = $1`, id);
|
||||
}
|
||||
|
||||
export async function getEmisores(schema: string, search: string, limit: number = 10): Promise<{ rfc: string; nombre: string }[]> {
|
||||
const result = await prisma.$queryRawUnsafe<{ rfc: string; nombre: string }[]>(`
|
||||
SELECT DISTINCT rfc_emisor as rfc, nombre_emisor as nombre
|
||||
FROM "${schema}".cfdis
|
||||
WHERE rfc_emisor ILIKE $1 OR nombre_emisor ILIKE $1
|
||||
ORDER BY nombre_emisor
|
||||
LIMIT $2
|
||||
`, `%${search}%`, limit);
|
||||
return result;
|
||||
}
|
||||
|
||||
export async function getReceptores(schema: string, search: string, limit: number = 10): Promise<{ rfc: string; nombre: string }[]> {
|
||||
const result = await prisma.$queryRawUnsafe<{ rfc: string; nombre: string }[]>(`
|
||||
SELECT DISTINCT rfc_receptor as rfc, nombre_receptor as nombre
|
||||
FROM "${schema}".cfdis
|
||||
WHERE rfc_receptor ILIKE $1 OR nombre_receptor ILIKE $1
|
||||
ORDER BY nombre_receptor
|
||||
LIMIT $2
|
||||
`, `%${search}%`, limit);
|
||||
return result;
|
||||
}
|
||||
|
||||
export async function getResumenCfdis(schema: string, año: number, mes: number) {
|
||||
const result = await prisma.$queryRawUnsafe<[{
|
||||
total_ingresos: number;
|
||||
|
||||
Reference in New Issue
Block a user