Align demo exchange seed graph
Build and deploy Docker image / build (push) Successful in 2m43s

This commit is contained in:
Ruslan Bakiev
2026-06-07 14:09:24 +07:00
parent 5c52a98ba8
commit 37bd31524f
+23 -6
View File
@@ -60,6 +60,10 @@ const suppliers = [
},
]
function quoteUuid(index: number) {
return `77777777-3333-4${String(index).padStart(3, '0')}-8${String(index).padStart(3, '0')}-777777${String(index).padStart(6, '0')}`
}
for (const product of products) {
await prisma.product.upsert({
where: { uuid: product.uuid },
@@ -77,14 +81,20 @@ for (const supplier of suppliers) {
}
for (let index = 0; index < 24; index += 1) {
const product = await prisma.product.findUniqueOrThrow({ where: { uuid: products[index % products.length].uuid } })
const supplier = await prisma.supplier.findUniqueOrThrow({ where: { uuid: suppliers[index % suppliers.length].uuid } })
const quoteUuid = `77777777-3333-4${String(index).padStart(3, '0')}-8${String(index).padStart(3, '0')}-777777${String(index).padStart(6, '0')}`
const productSeed = products[index % products.length]
const supplierSeed = suppliers[Math.floor(index / products.length) % suppliers.length]
const product = await prisma.product.findUniqueOrThrow({ where: { uuid: productSeed.uuid } })
const supplier = await prisma.supplier.findUniqueOrThrow({ where: { uuid: supplierSeed.uuid } })
const originPointUuid = [
'logistics-demo-hub-1',
'logistics-demo-hub-3',
'logistics-demo-hub-2',
][Math.floor(index / products.length) % suppliers.length]
await prisma.quote.upsert({
where: { uuid: quoteUuid },
where: { uuid: quoteUuid(index) },
create: {
uuid: quoteUuid,
uuid: quoteUuid(index),
supplierId: supplier.id,
productId: product.id,
status: 'active',
@@ -93,7 +103,7 @@ for (let index = 0; index < 24; index += 1) {
pricePerUnit: new Prisma.Decimal(900 + (index % 8) * 55),
currency: 'USD',
incotermsCode: index % 2 === 0 ? 'FOB' : 'DAP',
originPointUuid: `logistics-demo-hub-${(index % 4) + 1}`,
originPointUuid,
originName: supplier.name,
validUntil: new Date('2027-12-31'),
notes: 'Demo seed quote',
@@ -102,8 +112,15 @@ for (let index = 0; index < 24; index += 1) {
supplierId: supplier.id,
productId: product.id,
status: 'active',
quantity: new Prisma.Decimal(500 + index * 25),
unit: product.unit,
pricePerUnit: new Prisma.Decimal(900 + (index % 8) * 55),
currency: 'USD',
incotermsCode: index % 2 === 0 ? 'FOB' : 'DAP',
originPointUuid,
originName: supplier.name,
validUntil: new Date('2027-12-31'),
notes: 'Demo seed quote',
},
})
}