This commit is contained in:
seb
2026-08-15 03:04:14 +02:00
parent 6abe2032e8
commit e1a009ba5c
21 changed files with 751 additions and 10 deletions

View File

@@ -651,6 +651,93 @@ function buildProducts(categories, customerGroupIds) {
return { products, composites };
}
const CUSTOMER_FIRST_NAMES = [
'Max',
'Anna',
'Julia',
'Peter',
'Maria',
'Lukas',
'Sofia',
'Jonas',
'Laura',
'Felix',
'Elena',
'David',
];
const CUSTOMER_LAST_NAMES = [
'Mustermann',
'Schmidt',
'Weber',
'Müller',
'Fischer',
'Schneider',
'Wagner',
'Becker',
'Hoffmann',
'Koch',
'Richter',
'Klein',
];
const CUSTOMER_CITIES = [
['Musterstadt', '12345'],
['Berlin', '10115'],
['Hamburg', '20095'],
['München', '80331'],
['Köln', '50667'],
['Frankfurt', '60311'],
['Stuttgart', '70173'],
['Düsseldorf', '40213'],
['Leipzig', '04109'],
['Dresden', '01067'],
['Nürnberg', '90402'],
['Bremen', '28195'],
];
function buildCustomers(customerGroupIds) {
const customers = [];
const count = 24;
let lastChanged = 1;
const createdAt = formatDateTime(new Date('2024-01-20T09:00:00Z'));
for (let i = 0; i < count; i++) {
const id = i + 1;
const first = pick(CUSTOMER_FIRST_NAMES, i);
const last = pick(CUSTOMER_LAST_NAMES, i + 3);
const [city, postalCode] = CUSTOMER_CITIES[i % CUSTOMER_CITIES.length];
const streetNumber = 1 + (i % 60);
customers.push({
id: String(id),
customerNumber: `K-${String(1000 + i + 1)}`,
firstname: first,
lastname: last,
title: null,
company: null,
address: `Musterstraße ${streetNumber}`,
addressSupplement: null,
city,
postalCode,
state: null,
country: 'DE',
phone: i % 3 === 0 ? `+49 30 ${String(1000000 + i * 11111)}` : null,
email: `${first.toLowerCase()}.${last.toLowerCase()}@example.com`,
customerGroupId: String(pick(customerGroupIds, i)),
salutation: i % 2 === 0 ? 'Herr' : 'Frau',
birthday: i % 4 === 0 ? `${String((i % 28) + 1).padStart(2, '0')}.${String((i % 12) + 1).padStart(2, '0')}.${1970 + (i % 40)}` : null,
discount: '0.00',
taxIdNumber: i % 5 === 0 ? `DE${100000000 + i * 999}` : null,
lastChanged: String(lastChanged++),
debtorNumber: '0',
created: createdAt,
});
}
return customers;
}
async function main() {
console.log('Generating demo catalog…');
fs.mkdirSync(IMAGES_DIR, { recursive: true });
@@ -685,6 +772,7 @@ async function main() {
categories,
customerGroups.map((g) => Number(g.customerGroupId))
);
const customers = buildCustomers(customerGroups.map((g) => Number(g.customerGroupId)));
const perCategory = new Map();
for (const product of products) {
perCategory.set(product.categories_id, (perCategory.get(product.categories_id) || 0) + 1);
@@ -759,6 +847,7 @@ async function main() {
version: 1,
generatedAt: new Date().toISOString(),
customerGroups,
customers,
categories,
products,
composites,