diff --git a/src/modules/host/services/host.service.ts b/src/modules/host/services/host.service.ts index 559483a..4ddc6ab 100644 --- a/src/modules/host/services/host.service.ts +++ b/src/modules/host/services/host.service.ts @@ -2742,7 +2742,7 @@ export class HostService { } /* -------------------------------- - * 8️⃣ CREATE VENUES WITH MEDIA & PRICES + * 8️⃣ CREATE VENUES WITH MEDIA & PRICES (DRAFT SAFE) * -------------------------------- */ for (const venue of payload.venues ?? []) { const venueRow = await tx.activityVenues.create({ @@ -2774,6 +2774,19 @@ export class HostService { // Create venue prices with taxes for (const price of venue.prices ?? []) { const sellPrice = Number(price.sellPrice); + + // On submit enforce > 0, on draft just skip invalid + if (!isDraft) { + if (!sellPrice || sellPrice <= 0) { + throw new ApiError( + 400, + 'sellPrice must be > 0 for submitted activities', + ); + } + } + + if (!sellPrice || sellPrice <= 0) continue; + const { basePrice, taxDetails } = computeBasePriceAndTaxes( sellPrice, rootTaxes, @@ -2901,7 +2914,21 @@ export class HostService { if (Array.isArray(payload.equipments) && payload.equipments.length) { for (const eq of payload.equipments) { - const totalPrice = toNumber(eq.equipmentTotalPrice) ?? 0; + const isChargeable = toBool(eq.isEquipmentChargeable); + const totalPrice = isChargeable + ? toNumber(eq.equipmentTotalPrice) ?? 0 + : 0; + + // On submit enforce > 0, on draft just skip invalid/zero + if (!isDraft && isChargeable && totalPrice <= 0) { + throw new ApiError( + 400, + 'equipmentTotalPrice must be > 0 when equipment is chargeable', + ); + } + + if (!isChargeable || totalPrice <= 0) continue; + const { basePrice, taxDetails } = computeBasePriceAndTaxes( totalPrice, rootTaxes, @@ -2911,7 +2938,7 @@ export class HostService { data: { activityXid, equipmentName: eq.equipmentName, - isEquipmentChargeable: toBool(eq.isEquipmentChargeable), + isEquipmentChargeable: isChargeable, equipmentBasePrice: basePrice, equipmentTotalPrice: totalPrice, }, @@ -3020,6 +3047,16 @@ export class HostService { for (const detail of transport.pickupDetails) { const totalPrice = toNumber(detail.transportTotalPrice) ?? 0; + // On submit enforce > 0, on draft just skip + if (!isDraft && totalPrice <= 0) { + throw new ApiError( + 400, + 'transportTotalPrice must be > 0 when chargeable', + ); + } + + if (totalPrice <= 0) continue; + const { basePrice, taxDetails } = computeBasePriceAndTaxes( totalPrice, rootTaxes, @@ -3345,7 +3382,7 @@ export class HostService { }, }, ActivityPQQSuggestions: { - where: { isActive: true }, + where: { isActive: true , isReviewed :false }, select: { id: true, title: true,