primer commit
This commit is contained in:
commit
2be35d7e55
17 files changed
+2709
No files matched your search
@@ -0,0 +1,62 @@
|
||||
```mermaid
|
||||
flowchart TD
|
||||
subgraph Daemon["🚀 Daemon (main.py)"]
|
||||
A["Inicio"] --> B{"Día activo y<br>en horario?"}
|
||||
B -->|No| C["Esperar"]
|
||||
C --> B
|
||||
B -->|Sí| D["Token válido?"]
|
||||
D -->|No| E["get_token_headless()<br>channel=chrome headless=True<br>→ get_token.py headless=False"]
|
||||
E --> F["token.json"]
|
||||
D -->|Sí| F
|
||||
end
|
||||
|
||||
subgraph HANA["📊 Obtener pendientes"]
|
||||
F --> G["Consultar HANA<br>obtener_pendientes()"]
|
||||
G --> H["542 documentos<br>en OPCH"]
|
||||
H --> I["Filtrar contra<br>fallas_descarga.db"]
|
||||
I --> J["🆕 Nuevos<br>(sin falla previa)"]
|
||||
I --> K["🔄 Reintentos<br>(fallas pendientes)"]
|
||||
end
|
||||
|
||||
subgraph Nuevos["📄 Procesar nuevos"]
|
||||
L["Por cada nuevo:"] --> M["consultar_cpe()<br>GET api-cpe.sunat.gob.pe<br>/v1/.../{ruc}-{tipo}-{serie}-{num}-2"]
|
||||
M --> N{"Status?"}
|
||||
N -->|200| O["descargar_archivo()<br>XML (02) / PDF (01) / CDR (03)"]
|
||||
O --> P["ZIP → extraer en<br>descargas/"]
|
||||
P --> Q["marcar_pdf/xml_descargado()<br>UPDATE HANA OPCH"]
|
||||
Q --> R["✅ OK"]
|
||||
N -->|401| S["⚠️ TokenExpiredError"]
|
||||
S --> T["Renovar token"]
|
||||
T --> M
|
||||
N -->|500/404/otros| U["registrar_falla()<br>→ SQLite con backoff"]
|
||||
end
|
||||
|
||||
subgraph Reintentos["🔄 Procesar reintentos"]
|
||||
V["Por cada reintento<br>(backoff cumplido):"] --> W["consultar_cpe()"]
|
||||
W --> X{"Status?"}
|
||||
X -->|200| Y["descargar_archivo()"]
|
||||
Y --> Z["marcar_pdf/xml_descargado()"]
|
||||
Z --> AA["eliminar_falla()<br>DELETE FROM fallas"]
|
||||
AA --> AB["✅ OK + 🗑️ quitado de SQLite"]
|
||||
X -->|401| AC["Renovar token → reintentar"]
|
||||
X -->|500/404/otros| AD["actualizar_falla()<br>incrementar intento<br>→ próximo backoff"]
|
||||
end
|
||||
|
||||
AD --> AF["sincronizar_a_smb()<br>montar SMB<br>rsync PDF/XML → NAS<br>limpiar JSON/ZIP"]
|
||||
|
||||
AF --> AE["Esperar intervalo<br>→ próximo ciclo"]
|
||||
R --> AF
|
||||
U --> AD
|
||||
AB --> AF
|
||||
|
||||
style A fill:#1a1a2e,stroke:#e94560,color:#fff
|
||||
style E fill:#16213e,stroke:#0f3460,color:#fff
|
||||
style G fill:#0f3460,stroke:#e94560,color:#fff
|
||||
style M fill:#533483,stroke:#e94560,color:#fff
|
||||
style O fill:#1a1a2e,stroke:#e94560,color:#fff
|
||||
style P fill:#16213e,stroke:#0f3460,color:#fff
|
||||
style Q fill:#0f3460,stroke:#e94560,color:#fff
|
||||
style U fill:#3d0000,stroke:#ff4444,color:#fff
|
||||
style AA fill:#003300,stroke:#44ff44,color:#fff
|
||||
style AD fill:#3d0000,stroke:#ff4444,color:#fff
|
||||
```
|
||||
Reference in new issue
Block a user