Anrede-Verhältnis Du/Sie pro Kunde + Geburtstagsgruß respektiert Anrede
Schema: - Customer.useInformalAddress: Boolean (Default: false = Sie) - Auch bei Firmenkunden verfügbar (Chef kann man auch duzen) Frontend: - Neues Pflichtfeld "Anrede per" (Du/Sie) im Kunden-Formular - Anzeige als Badge in CustomerDetail-Stammdaten Geburtstagsgruß im Portal: - Bei Du: "Herzlichen Glückwunsch, Max! Alles Gute zu deinem 42. Geburtstag!" - Bei Sie: "Herzlichen Glückwunsch, Herr Müller! Alles Gute zu Ihrem 42. Geburtstag!" - Konsistent auch bei nachträglichen Glückwünschen (hattest/hatten, bist/sind etc.) - Backend liefert firstName, lastName, salutation und useInformalAddress Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -166,6 +166,9 @@ model Customer {
|
||||
// Geburtstagsmodal: Jahr in dem dem Kunden der Geburtstagsgruß gezeigt wurde (vermeidet mehrfaches Anzeigen)
|
||||
lastBirthdayGreetingYear Int?
|
||||
|
||||
// Anrede-Verhältnis: true = Du (informell), false = Sie (formell, Default)
|
||||
useInformalAddress Boolean @default(false)
|
||||
|
||||
user User?
|
||||
addresses Address[]
|
||||
bankCards BankCard[]
|
||||
|
||||
@@ -140,6 +140,9 @@ export interface MyBirthdayCheck {
|
||||
isToday: boolean;
|
||||
daysAgo: number; // 0 = heute, >0 = x Tage her
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
salutation: string | null;
|
||||
useInformalAddress: boolean;
|
||||
age: number;
|
||||
}
|
||||
|
||||
@@ -153,6 +156,9 @@ export async function checkMyBirthday(customerId: number): Promise<MyBirthdayChe
|
||||
where: { id: customerId },
|
||||
select: {
|
||||
firstName: true,
|
||||
lastName: true,
|
||||
salutation: true,
|
||||
useInformalAddress: true,
|
||||
birthDate: true,
|
||||
lastBirthdayGreetingYear: true,
|
||||
},
|
||||
@@ -160,13 +166,20 @@ export async function checkMyBirthday(customerId: number): Promise<MyBirthdayChe
|
||||
|
||||
if (!customer?.birthDate) return null;
|
||||
|
||||
const baseInfo = {
|
||||
firstName: customer.firstName,
|
||||
lastName: customer.lastName,
|
||||
salutation: customer.salutation,
|
||||
useInformalAddress: customer.useInformalAddress,
|
||||
};
|
||||
|
||||
const today = new Date();
|
||||
today.setHours(0, 0, 0, 0);
|
||||
const thisYear = today.getFullYear();
|
||||
|
||||
// Schon dieses Jahr angezeigt?
|
||||
if (customer.lastBirthdayGreetingYear === thisYear) {
|
||||
return { show: false, isToday: false, daysAgo: 0, firstName: customer.firstName, age: 0 };
|
||||
return { show: false, isToday: false, daysAgo: 0, ...baseInfo, age: 0 };
|
||||
}
|
||||
|
||||
const birthday = new Date(thisYear, customer.birthDate.getMonth(), customer.birthDate.getDate());
|
||||
@@ -177,7 +190,7 @@ export async function checkMyBirthday(customerId: number): Promise<MyBirthdayChe
|
||||
|
||||
// Nur wenn heute oder in den letzten 7 Tagen (diff: 0–7)
|
||||
if (diff < 0 || diff > 7) {
|
||||
return { show: false, isToday: false, daysAgo: 0, firstName: customer.firstName, age: 0 };
|
||||
return { show: false, isToday: false, daysAgo: 0, ...baseInfo, age: 0 };
|
||||
}
|
||||
|
||||
const age = calculateAge(customer.birthDate, today);
|
||||
@@ -186,7 +199,7 @@ export async function checkMyBirthday(customerId: number): Promise<MyBirthdayChe
|
||||
show: true,
|
||||
isToday: diff === 0,
|
||||
daysAgo: diff,
|
||||
firstName: customer.firstName,
|
||||
...baseInfo,
|
||||
age,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -57,6 +57,12 @@ als Factory-Default beim Initialisieren wieder einspielen lassen.
|
||||
|
||||
## ✅ Erledigt
|
||||
|
||||
- [x] **Anrede-Verhältnis Du/Sie pro Kunde**
|
||||
- Neues Feld `useInformalAddress` in Stammdaten (auch bei Firmenkunden)
|
||||
- Default: Sie (formell)
|
||||
- Geburtstagsgruß im Portal nutzt die Anrede: "Du"-Kunden bekommen "Herzlichen Glückwunsch, Max!", "Sie"-Kunden "Herzlichen Glückwunsch, Herr Müller!"
|
||||
- Komplett konsistent auch bei nachträglichen Glückwünschen ("hattest" vs "hatten")
|
||||
|
||||
- [x] **Geburtsdatum + Geburtsort auch bei Firmenkunden**
|
||||
- Felder werden jetzt unabhängig vom Kundentyp angezeigt
|
||||
- Ermöglicht z.B. Geburtstage für Ansprechpartner bei Firmen
|
||||
|
||||
Reference in New Issue
Block a user