Batch-Buendelung (Phase 2): xlsx + Sammel-PDF + FTP + Cron
All checks were successful
Build & Deploy / deploy (push) Successful in 25s
All checks were successful
Build & Deploy / deploy (push) Successful in 25s
Neuer Endpunkt POST /api/batch/build (Token) und Cron (03:00 Europe/Berlin): buendelt offene batch_submissions JE ZUGANG (api_client) zu einer xlsx (Schema Firma/Vorname/Nachname/Zeile1-3/PLZ/Stadt/Land) + einer Sammel- Druck-PDF (alle mitgelieferten Druck-PDFs 1:1) und laedt beide per FTP(S) in die Wurzel. Dateiname <api_client_id>_<YYYY-MM-DD>(.xlsx/.pdf); manuelle Laeufe mit Uhrzeit-Suffix (kein Ueberschreiben des Tageslaufs). Text-only- Datensaetze (ohne PDF) bleiben offen (manuelle Schreibvorlage), nicht im Buendel. Sa+So gemeinsam am Montag (Sonntag-Lauf uebersprungen). Neue Pakete: exceljs, basic-ftp. FTP-Config via ENV (SKRIFT_FTP_HOST/PORT/ USER/PASSWORD/SECURE), Passwort nur in ENV. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -110,4 +110,22 @@ async function fetchRenderFormats() {
|
||||
);
|
||||
}
|
||||
|
||||
module.exports = { fetchOrder, updateOrder, addStatusHistory, fetchRenderFormats, fetchOrdersMinimal, fetchAssetBuffer };
|
||||
/** Offene (pending) Batch-Übermittlungen MIT Druck-PDF, optional je Zugang.
|
||||
* Text-only-Datensätze (ohne PDF) werden bewusst NICHT gebündelt. */
|
||||
async function fetchBatchPending(clientId) {
|
||||
const filter = 'filter[status][_eq]=pending&filter[pdf_file][_nnull]=true'
|
||||
+ (clientId != null ? `&filter[api_client][_eq]=${encodeURIComponent(clientId)}` : '');
|
||||
const fields = 'id,api_client,firma,vorname,nachname,zeile1,zeile2,zeile3,plz,stadt,land,pdf_file';
|
||||
return (await directusFetch(`/items/batch_submissions?${filter}&sort=date_created&limit=-1&fields=${fields}`)) || [];
|
||||
}
|
||||
|
||||
/** Markiert Datensätze als gebündelt (nach erfolgreichem FTP-Upload). */
|
||||
async function markBatchBundled(ids, bundleName) {
|
||||
if (!ids || !ids.length) return;
|
||||
return directusFetch('/items/batch_submissions', {
|
||||
method: 'PATCH',
|
||||
body: JSON.stringify({ keys: ids, data: { status: 'bundled', bundle_name: bundleName, bundled_at: new Date().toISOString() } }),
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = { fetchOrder, updateOrder, addStatusHistory, fetchRenderFormats, fetchOrdersMinimal, fetchAssetBuffer, fetchBatchPending, markBatchBundled };
|
||||
|
||||
Reference in New Issue
Block a user