fix(seed): upsert POs so re-running seed does not fail on duplicate poNumber; currency USD -> INR
This commit is contained in:
parent
7c31b0e838
commit
67beccc16d
1 changed files with 16 additions and 10 deletions
|
|
@ -185,14 +185,16 @@ async function main() {
|
|||
},
|
||||
});
|
||||
|
||||
// Sample POs
|
||||
const po1 = await db.purchaseOrder.create({
|
||||
data: {
|
||||
// Sample POs — upsert so re-running seed is safe
|
||||
const po1 = await db.purchaseOrder.upsert({
|
||||
where: { poNumber: "PO-2026-00001" },
|
||||
update: {},
|
||||
create: {
|
||||
poNumber: "PO-2026-00001",
|
||||
title: "Engine Room Spare Parts — MV Pelagia Star",
|
||||
status: "MGR_REVIEW",
|
||||
totalAmount: 8450.0,
|
||||
currency: "USD",
|
||||
currency: "INR",
|
||||
submittedAt: new Date(),
|
||||
submitterId: technical.id,
|
||||
vesselId: mv1.id,
|
||||
|
|
@ -214,13 +216,15 @@ async function main() {
|
|||
},
|
||||
});
|
||||
|
||||
await db.purchaseOrder.create({
|
||||
data: {
|
||||
await db.purchaseOrder.upsert({
|
||||
where: { poNumber: "PO-2026-00002" },
|
||||
update: {},
|
||||
create: {
|
||||
poNumber: "PO-2026-00002",
|
||||
title: "Crew Safety Equipment — MV Aegean Wind",
|
||||
status: "DRAFT",
|
||||
totalAmount: 3200.0,
|
||||
currency: "USD",
|
||||
currency: "INR",
|
||||
submitterId: technical.id,
|
||||
vesselId: mv2.id,
|
||||
accountId: acc2.id,
|
||||
|
|
@ -236,13 +240,15 @@ async function main() {
|
|||
},
|
||||
});
|
||||
|
||||
await db.purchaseOrder.create({
|
||||
data: {
|
||||
await db.purchaseOrder.upsert({
|
||||
where: { poNumber: "PO-2026-00003" },
|
||||
update: {},
|
||||
create: {
|
||||
poNumber: "PO-2026-00003",
|
||||
title: "Navigation Charts Update — Fleet",
|
||||
status: "MGR_APPROVED",
|
||||
totalAmount: 950.0,
|
||||
currency: "USD",
|
||||
currency: "INR",
|
||||
submittedAt: new Date(Date.now() - 5 * 86400000),
|
||||
approvedAt: new Date(Date.now() - 2 * 86400000),
|
||||
submitterId: technical.id,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue