This commit is contained in:
+23
-6
@@ -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) {
|
for (const product of products) {
|
||||||
await prisma.product.upsert({
|
await prisma.product.upsert({
|
||||||
where: { uuid: product.uuid },
|
where: { uuid: product.uuid },
|
||||||
@@ -77,14 +81,20 @@ for (const supplier of suppliers) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (let index = 0; index < 24; index += 1) {
|
for (let index = 0; index < 24; index += 1) {
|
||||||
const product = await prisma.product.findUniqueOrThrow({ where: { uuid: products[index % products.length].uuid } })
|
const productSeed = products[index % products.length]
|
||||||
const supplier = await prisma.supplier.findUniqueOrThrow({ where: { uuid: suppliers[index % suppliers.length].uuid } })
|
const supplierSeed = suppliers[Math.floor(index / products.length) % suppliers.length]
|
||||||
const quoteUuid = `77777777-3333-4${String(index).padStart(3, '0')}-8${String(index).padStart(3, '0')}-777777${String(index).padStart(6, '0')}`
|
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({
|
await prisma.quote.upsert({
|
||||||
where: { uuid: quoteUuid },
|
where: { uuid: quoteUuid(index) },
|
||||||
create: {
|
create: {
|
||||||
uuid: quoteUuid,
|
uuid: quoteUuid(index),
|
||||||
supplierId: supplier.id,
|
supplierId: supplier.id,
|
||||||
productId: product.id,
|
productId: product.id,
|
||||||
status: 'active',
|
status: 'active',
|
||||||
@@ -93,7 +103,7 @@ for (let index = 0; index < 24; index += 1) {
|
|||||||
pricePerUnit: new Prisma.Decimal(900 + (index % 8) * 55),
|
pricePerUnit: new Prisma.Decimal(900 + (index % 8) * 55),
|
||||||
currency: 'USD',
|
currency: 'USD',
|
||||||
incotermsCode: index % 2 === 0 ? 'FOB' : 'DAP',
|
incotermsCode: index % 2 === 0 ? 'FOB' : 'DAP',
|
||||||
originPointUuid: `logistics-demo-hub-${(index % 4) + 1}`,
|
originPointUuid,
|
||||||
originName: supplier.name,
|
originName: supplier.name,
|
||||||
validUntil: new Date('2027-12-31'),
|
validUntil: new Date('2027-12-31'),
|
||||||
notes: 'Demo seed quote',
|
notes: 'Demo seed quote',
|
||||||
@@ -102,8 +112,15 @@ for (let index = 0; index < 24; index += 1) {
|
|||||||
supplierId: supplier.id,
|
supplierId: supplier.id,
|
||||||
productId: product.id,
|
productId: product.id,
|
||||||
status: 'active',
|
status: 'active',
|
||||||
|
quantity: new Prisma.Decimal(500 + index * 25),
|
||||||
unit: product.unit,
|
unit: product.unit,
|
||||||
|
pricePerUnit: new Prisma.Decimal(900 + (index % 8) * 55),
|
||||||
currency: 'USD',
|
currency: 'USD',
|
||||||
|
incotermsCode: index % 2 === 0 ? 'FOB' : 'DAP',
|
||||||
|
originPointUuid,
|
||||||
|
originName: supplier.name,
|
||||||
|
validUntil: new Date('2027-12-31'),
|
||||||
|
notes: 'Demo seed quote',
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user