save attachment from email in customer data and - or contracts
This commit is contained in:
@@ -0,0 +1,141 @@
|
||||
/**
|
||||
* Zentrale Konfiguration aller Dokumenten-Ziele für E-Mail-Anhänge.
|
||||
*
|
||||
* Bei neuen Dokumentfeldern einfach hier hinzufügen:
|
||||
* 1. Neues Feld in der entsprechenden Kategorie anlegen
|
||||
* 2. Upload-Route in upload.routes.ts hinzufügen (falls noch nicht vorhanden)
|
||||
* 3. Das Frontend zeigt das neue Feld automatisch an
|
||||
*/
|
||||
|
||||
export interface DocumentTarget {
|
||||
/** Eindeutiger Schlüssel für das Feld */
|
||||
key: string;
|
||||
/** Anzeigename im UI */
|
||||
label: string;
|
||||
/** Datenbankfeld-Name (z.B. 'privacyPolicyPath') */
|
||||
field: string;
|
||||
/** Bedingung für Anzeige: 'BUSINESS' = nur Geschäftskunden, null = immer */
|
||||
condition?: 'BUSINESS' | null;
|
||||
/** Upload-Verzeichnis (relativ zu /uploads/) */
|
||||
directory: string;
|
||||
}
|
||||
|
||||
export interface DocumentTargetConfig {
|
||||
customer: DocumentTarget[];
|
||||
contract: DocumentTarget[];
|
||||
identityDocument: DocumentTarget[];
|
||||
bankCard: DocumentTarget[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Alle verfügbaren Dokumenten-Ziele gruppiert nach Entity-Typ.
|
||||
*
|
||||
* WICHTIG: Bei neuen Feldern hier hinzufügen!
|
||||
*/
|
||||
export const documentTargets: DocumentTargetConfig = {
|
||||
// Dokumente direkt am Kunden
|
||||
customer: [
|
||||
{
|
||||
key: 'privacyPolicy',
|
||||
label: 'Datenschutzerklärung',
|
||||
field: 'privacyPolicyPath',
|
||||
condition: null, // Für alle Kunden
|
||||
directory: 'privacy-policies',
|
||||
},
|
||||
{
|
||||
key: 'businessRegistration',
|
||||
label: 'Gewerbeanmeldung',
|
||||
field: 'businessRegistrationPath',
|
||||
condition: 'BUSINESS', // Nur Geschäftskunden
|
||||
directory: 'business-registrations',
|
||||
},
|
||||
{
|
||||
key: 'commercialRegister',
|
||||
label: 'Handelsregisterauszug',
|
||||
field: 'commercialRegisterPath',
|
||||
condition: 'BUSINESS', // Nur Geschäftskunden
|
||||
directory: 'commercial-registers',
|
||||
},
|
||||
],
|
||||
|
||||
// Dokumente am Vertrag
|
||||
contract: [
|
||||
{
|
||||
key: 'cancellationLetter',
|
||||
label: 'Kündigungsschreiben',
|
||||
field: 'cancellationLetterPath',
|
||||
directory: 'cancellation-letters',
|
||||
},
|
||||
{
|
||||
key: 'cancellationConfirmation',
|
||||
label: 'Kündigungsbestätigung',
|
||||
field: 'cancellationConfirmationPath',
|
||||
directory: 'cancellation-confirmations',
|
||||
},
|
||||
{
|
||||
key: 'cancellationLetterOptions',
|
||||
label: 'Kündigungsschreiben (Optionen)',
|
||||
field: 'cancellationLetterOptionsPath',
|
||||
directory: 'cancellation-letters-options',
|
||||
},
|
||||
{
|
||||
key: 'cancellationConfirmationOptions',
|
||||
label: 'Kündigungsbestätigung (Optionen)',
|
||||
field: 'cancellationConfirmationOptionsPath',
|
||||
directory: 'cancellation-confirmations-options',
|
||||
},
|
||||
],
|
||||
|
||||
// Dokumente an Ausweisen (pro Ausweis-Eintrag)
|
||||
identityDocument: [
|
||||
{
|
||||
key: 'document',
|
||||
label: 'Ausweis-Scan',
|
||||
field: 'documentPath',
|
||||
directory: 'documents',
|
||||
},
|
||||
],
|
||||
|
||||
// Dokumente an Bankkarten (pro Bankkarte)
|
||||
bankCard: [
|
||||
{
|
||||
key: 'document',
|
||||
label: 'Bankkarten-Dokument',
|
||||
field: 'documentPath',
|
||||
directory: 'bank-cards',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
/**
|
||||
* Hilfsfunktion: Gibt alle Kunden-Dokumentziele zurück,
|
||||
* gefiltert nach Kundentyp (PRIVATE/BUSINESS)
|
||||
*/
|
||||
export function getCustomerTargets(customerType: 'PRIVATE' | 'BUSINESS'): DocumentTarget[] {
|
||||
return documentTargets.customer.filter(target => {
|
||||
if (target.condition === null) return true;
|
||||
if (target.condition === 'BUSINESS' && customerType === 'BUSINESS') return true;
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Hilfsfunktion: Gibt alle Vertrags-Dokumentziele zurück
|
||||
*/
|
||||
export function getContractTargets(): DocumentTarget[] {
|
||||
return documentTargets.contract;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hilfsfunktion: Gibt das Ausweis-Dokumentziel zurück
|
||||
*/
|
||||
export function getIdentityDocumentTargets(): DocumentTarget[] {
|
||||
return documentTargets.identityDocument;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hilfsfunktion: Gibt das Bankkarten-Dokumentziel zurück
|
||||
*/
|
||||
export function getBankCardTargets(): DocumentTarget[] {
|
||||
return documentTargets.bankCard;
|
||||
}
|
||||
Reference in New Issue
Block a user