upload
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
// n8n Code Node: "Monatsdaten vorbereiten"
|
||||
// Dieses Beispiel normalisiert eine DB-Zeile. Feldnamen an deine Tabellen anpassen.
|
||||
|
||||
const row = $json;
|
||||
const year = Number(row.report_year);
|
||||
const month = Number(row.report_month);
|
||||
const monthNames = ['Januar','Februar','Maerz','April','Mai','Juni','Juli','August','September','Oktober','November','Dezember'];
|
||||
|
||||
if (!Number.isInteger(year) || month < 1 || month > 12) {
|
||||
throw new Error('report_year/report_month ungueltig');
|
||||
}
|
||||
|
||||
const previous = new Date(Date.UTC(year, month - 2, 1));
|
||||
const previousLabel = `${monthNames[previous.getUTCMonth()]} ${previous.getUTCFullYear()}`;
|
||||
|
||||
return [{
|
||||
json: {
|
||||
publisher: row.publisher_name ?? 'Mein Reporting',
|
||||
customer: {
|
||||
id: row.customer_slug,
|
||||
name: row.customer_name,
|
||||
property_name: row.property_name,
|
||||
location: row.location,
|
||||
contact_line: row.contact_line ?? '',
|
||||
logo_data_uri: row.logo_data_uri || undefined,
|
||||
logo_text: row.logo_text ?? row.customer_name.slice(0, 2).toUpperCase()
|
||||
},
|
||||
design: {
|
||||
theme: row.theme ?? 'modern',
|
||||
primary_color: row.primary_color ?? '#1F5D66',
|
||||
secondary_color: row.secondary_color ?? '#2C7C82',
|
||||
accent_color: row.accent_color ?? '#DBA25D',
|
||||
text_color: row.text_color ?? '#24343A',
|
||||
muted_color: row.muted_color ?? '#718087',
|
||||
surface_color: row.surface_color ?? '#F2F6F5',
|
||||
font_family: row.font_family ?? 'Arial'
|
||||
},
|
||||
period: {
|
||||
year,
|
||||
month,
|
||||
label: `${monthNames[month - 1]} ${year}`,
|
||||
comparison_label: previousLabel
|
||||
},
|
||||
metrics: row.metrics,
|
||||
trends: row.trends,
|
||||
context: row.context ?? {},
|
||||
legal_note: row.legal_note
|
||||
}
|
||||
}];
|
||||
Reference in New Issue
Block a user