feat: skip documents still in Agrarmonitor Dateieingang during upload check
Build and Push Multi-Platform Images / build-and-push (push) Successful in 31s
Build and Push Multi-Platform Images / build-and-push (push) Successful in 31s
- Before moving a document back to Posteingang, check if it's still waiting in the Agrarmonitor Dateieingang - If yes: skip silently (upload is pending processing) - If no: move to Posteingang tag as before - Handle 401/403 by clearing the session and aborting the check Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -368,6 +368,35 @@ export class AgrarmonitorPollingService implements OnModuleInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!vorhanden) {
|
if (!vorhanden) {
|
||||||
|
// Prüfen ob Beleg noch im Dateieingang von Agrarmonitor liegt
|
||||||
|
let imDateieingang: boolean;
|
||||||
|
try {
|
||||||
|
imDateieingang = await amClient.eingangsrechnungImDateieingangVorhanden(interneBelegnummer);
|
||||||
|
} catch (err: unknown) {
|
||||||
|
const status = (err as any)?.response?.status;
|
||||||
|
if (status === 401 || status === 403) {
|
||||||
|
this.agrarmonitorService.clearClient();
|
||||||
|
const msg = `Session abgelaufen (${status}) — Upload-Check abgebrochen`;
|
||||||
|
this.logger.warn(msg);
|
||||||
|
result.errors.push(msg);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// Bei Fehler vorsichtig: nicht verschieben
|
||||||
|
const msg = `${interneBelegnummer}: Dateieingang-Check fehlgeschlagen`;
|
||||||
|
this.logger.error(`${msg}: ${err instanceof Error ? err.message : err}`);
|
||||||
|
result.errors.push(msg);
|
||||||
|
await this.delay(500);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (imDateieingang) {
|
||||||
|
// Noch im Dateieingang — wartet auf Verarbeitung, nichts tun
|
||||||
|
result.skipped++;
|
||||||
|
await this.delay(500);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Weder verbucht noch im Dateieingang → zurück in Posteingang
|
||||||
if (!isNaN(tagPosteingangId)) {
|
if (!isNaN(tagPosteingangId)) {
|
||||||
const currentTags: number[] = (doc.tags as number[]) ?? [];
|
const currentTags: number[] = (doc.tags as number[]) ?? [];
|
||||||
const newTags = [...new Set(currentTags.filter(t => t !== tagHochgeladenId).concat([tagPosteingangId]))];
|
const newTags = [...new Set(currentTags.filter(t => t !== tagHochgeladenId).concat([tagPosteingangId]))];
|
||||||
|
|||||||
Reference in New Issue
Block a user