feat(sat): reporte diario de errores SAT por proxy
- Agrega tabla sat_proxy_errors con proxy_usado, error_code, stage, message. - sat-client.service.ts expone proxyInfo usado en cada conexión SAT. - sat.service.ts registra errores de bloqueo/devolución del SAT en sat_proxy_errors y guarda proxyUsed en sat_sync_jobs. - Nuevo job sat-proxy-report.job.ts: cron 8 AM CDMX, envía email a ADMIN_EMAIL con errores de las últimas 24h agrupados por proxy/error_code. - Template de email sat-proxy-report.ts y método sendSatProxyReport. - Registra el cron en src/index.ts. - Actualiza docs/SAT-SYNC-IMPLEMENTATION.md.
This commit is contained in:
25
apps/api/scripts/sync-contribuyente.ts
Normal file
25
apps/api/scripts/sync-contribuyente.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { startSync } from '../src/services/sat/sat.service.js';
|
||||
|
||||
async function main() {
|
||||
const [tenantId, contribuyenteId, rfc, dateFromStr, dateToStr] = process.argv.slice(2);
|
||||
|
||||
if (!tenantId || !contribuyenteId || !rfc) {
|
||||
console.error('Uso: npx tsx scripts/sync-contribuyente.ts <tenantId> <contribuyenteId> <rfc> [dateFrom] [dateTo]');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const dateFrom = dateFromStr ? new Date(dateFromStr) : new Date(new Date().getFullYear() - 6, 0, 1);
|
||||
const dateTo = dateToStr ? new Date(dateToStr) : new Date();
|
||||
|
||||
try {
|
||||
console.log(`[SYNC] Iniciando sync para ${rfc} (${contribuyenteId}) en tenant ${tenantId}`);
|
||||
console.log(`[SYNC] Rango: ${dateFrom.toISOString()} → ${dateTo.toISOString()}`);
|
||||
const jobId = await startSync(tenantId, 'initial', dateFrom, dateTo, contribuyenteId);
|
||||
console.log(`[SYNC] Job iniciado: ${jobId}`);
|
||||
} catch (error: any) {
|
||||
console.error('[SYNC] Error:', error.message || error);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
||||
Reference in New Issue
Block a user