Make demo tariffs usable in route search
Build and deploy Docker image / build (push) Successful in 2m31s
Build and deploy Docker image / build (push) Successful in 2m31s
This commit is contained in:
+12
-4
@@ -117,11 +117,9 @@ export async function ensureDemoWorkspaceData(access: DemoWorkspaceAccess): Prom
|
||||
])
|
||||
const needsCalculations = quotationCount === 0
|
||||
const needsOrders = orderCount === 0
|
||||
if (!needsCalculations && !needsOrders) return
|
||||
|
||||
for (const [index, route] of demoRoutes.entries()) {
|
||||
const createsOrder = index < 2
|
||||
if (!needsCalculations && !(needsOrders && createsOrder)) continue
|
||||
|
||||
const tariffUuid = stableUuid(access.teamUuid, 'demo-tariff', index)
|
||||
const tariff = await prisma.tariffReference.upsert({
|
||||
@@ -132,8 +130,6 @@ export async function ensureDemoWorkspaceData(access: DemoWorkspaceAccess): Prom
|
||||
createdByUserId: access.userId,
|
||||
name: route.title,
|
||||
status: 'active',
|
||||
operationCode: 'IMPORT',
|
||||
transportTypeCode: route.transportTypeCode,
|
||||
sourceCountryCode: route.sourceCountryCode,
|
||||
destinationCountryCode: route.destinationCountryCode,
|
||||
amountUsd: new Prisma.Decimal(route.amountUsd),
|
||||
@@ -146,13 +142,25 @@ export async function ensureDemoWorkspaceData(access: DemoWorkspaceAccess): Prom
|
||||
update: {
|
||||
teamUuid: access.teamUuid,
|
||||
createdByUserId: access.userId,
|
||||
name: route.title,
|
||||
status: 'active',
|
||||
operationCode: null,
|
||||
incotermsCode: null,
|
||||
transportTypeCode: null,
|
||||
tareTypeCode: null,
|
||||
sourceCountryCode: route.sourceCountryCode,
|
||||
destinationCountryCode: route.destinationCountryCode,
|
||||
amountUsd: new Prisma.Decimal(route.amountUsd),
|
||||
minPriceUsd: new Prisma.Decimal(route.amountUsd),
|
||||
etaDays: route.etaDays,
|
||||
priority: 50 + index,
|
||||
currency: 'USD',
|
||||
notes: demoNote,
|
||||
},
|
||||
})
|
||||
|
||||
if (!needsCalculations && !(needsOrders && createsOrder)) continue
|
||||
|
||||
const quotationUuid = stableUuid(access.teamUuid, 'demo-quotation', index)
|
||||
const quotation = await prisma.quotation.upsert({
|
||||
where: { uuid: quotationUuid },
|
||||
|
||||
@@ -1115,6 +1115,7 @@ export const teamResolvers = {
|
||||
|
||||
createQuotation: async (_: unknown, args: { input: CreateQuotationInput }, ctx: AuthContext) => {
|
||||
const access = assertScopedTeamAccess(ctx)
|
||||
await ensureDemoWorkspaceData(access)
|
||||
const actor = { userId: access.userId, label: actorLabel(access) }
|
||||
const created = await prisma.quotation.create({
|
||||
data: buildCreateQuotationData(args.input, access),
|
||||
|
||||
Reference in New Issue
Block a user