Manueller Auftrag: Neukundenzwang + Mails-Checkbox
- Neue E-Mail im Neuauftrag -> Pruefung; unbekannt => Stammdaten (Vor-/Nachname oder Firma + Adresse) werden erzwungen und beim Anlegen am Kundenkonto gespeichert (statt leerem Auto-Konto). - Checkbox "Mails an Kunden senden" je manuellem Auftrag; orders.mails_senden (Default true). Mailer unterdrueckt Kunden-Mails bei mails_senden=false. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -2053,7 +2053,16 @@ const handler = (router, { services, getSchema, logger }) => {
|
||||
const role = (await new RolesService({ schema, accountability: null }).readByQuery({
|
||||
filter: { name: { _eq: 'Kunde' } }, limit: 1, fields: ['id'],
|
||||
}))?.[0];
|
||||
customerId = await users.createOne({ email: kundeMail, password: zufallsPasswort(), role: role?.id ?? null, status: 'active' });
|
||||
// Neukunde mit den im Formular erfassten Stammdaten anlegen.
|
||||
const neuKunde = { email: kundeMail, password: zufallsPasswort(), role: role?.id ?? null, status: 'active',
|
||||
first_name: clean(body.customer_vorname) || null,
|
||||
last_name: clean(body.customer_nachname) || null,
|
||||
company: clean(body.customer_company) || null,
|
||||
person_type: body.customer_company ? 'unternehmen' : 'privat',
|
||||
};
|
||||
const adr = body.customer_address && typeof body.customer_address === 'object' ? body.customer_address : null;
|
||||
if (adr && (adr.street || adr.zip || adr.city)) neuKunde.billing_address = adr;
|
||||
customerId = await users.createOne(neuKunde);
|
||||
customerEmail = kundeMail;
|
||||
} catch (e) { logger.warn(`[skrift-orders] manual-order Kunde anlegen: ${e.message}`); customerEmail = kundeMail; }
|
||||
}
|
||||
@@ -2084,6 +2093,7 @@ const handler = (router, { services, getSchema, logger }) => {
|
||||
const orderData = {
|
||||
customer: customerId, customer_email: customerEmail,
|
||||
order_name: clean(body.order_name) || null,
|
||||
mails_senden: body.mails_senden !== false,
|
||||
product: product.id, format: formatId,
|
||||
person_type: body.person_type === 'unternehmen' ? 'unternehmen' : 'privat',
|
||||
font: ['tilda', 'alva', 'ellie'].includes(body.font) ? body.font : 'tilda',
|
||||
|
||||
Reference in New Issue
Block a user