27 lines
851 B
TypeScript
27 lines
851 B
TypeScript
import { prisma, tenantDb } from '../src/config/database.js';
|
|
|
|
const rawUuid = process.argv[2];
|
|
if (!rawUuid) { console.error('Usage: tsx scripts/inspect-cfdi-full.ts <uuid>'); process.exit(1); }
|
|
const uuid = rawUuid.toLowerCase();
|
|
|
|
async function main() {
|
|
const tenants = await prisma.tenant.findMany({
|
|
where: { active: true },
|
|
select: { id: true, rfc: true, databaseName: true },
|
|
});
|
|
|
|
for (const t of tenants) {
|
|
const pool = await tenantDb.getPool(t.id, t.databaseName);
|
|
const { rows } = await pool.query(
|
|
`SELECT * FROM cfdis WHERE LOWER(uuid) = $1`,
|
|
[uuid],
|
|
);
|
|
if (rows.length === 0) continue;
|
|
console.log(`\n[${t.rfc}] CFDI:`);
|
|
console.log(rows[0]);
|
|
}
|
|
|
|
await prisma.$disconnect();
|
|
}
|
|
main().catch(async e => { console.error(e); await prisma.$disconnect().catch(() => {}); process.exit(1); });
|