feat(interests): CM-2 Part B — EOI/doc generation honours berth price override
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -303,6 +303,28 @@ export async function buildEoiContext(interestId: string, portId: string): Promi
|
||||
const today = now.toISOString().slice(0, 10);
|
||||
const year = String(now.getFullYear());
|
||||
|
||||
// CM-2 Part B: deal-specific price override. The base berth price is the
|
||||
// canonical list price; an interest_berths.price_override (when set)
|
||||
// supersedes it for THIS interest's documents via the existing
|
||||
// {{berth.price}} / {{berth.priceCurrency}} tokens.
|
||||
let resolvedBerthPrice = berth?.price ?? null;
|
||||
let resolvedBerthCurrency = berth?.priceCurrency ?? port.defaultCurrency;
|
||||
if (berth && primaryBerthId) {
|
||||
const [ibOverride] = await db
|
||||
.select({
|
||||
priceOverride: interestBerths.priceOverride,
|
||||
priceOverrideCurrency: interestBerths.priceOverrideCurrency,
|
||||
})
|
||||
.from(interestBerths)
|
||||
.where(
|
||||
and(eq(interestBerths.interestId, interest.id), eq(interestBerths.berthId, primaryBerthId)),
|
||||
);
|
||||
if (ibOverride?.priceOverride != null) {
|
||||
resolvedBerthPrice = ibOverride.priceOverride;
|
||||
resolvedBerthCurrency = ibOverride.priceOverrideCurrency ?? berth.priceCurrency;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
client: {
|
||||
id: client.id,
|
||||
@@ -337,8 +359,8 @@ export async function buildEoiContext(interestId: string, portId: string): Promi
|
||||
mooringNumber: berth.mooringNumber,
|
||||
area: berth.area,
|
||||
lengthFt: berth.lengthFt,
|
||||
price: berth.price,
|
||||
priceCurrency: berth.priceCurrency,
|
||||
price: resolvedBerthPrice,
|
||||
priceCurrency: resolvedBerthCurrency,
|
||||
tenureType: berth.tenureType,
|
||||
}
|
||||
: null,
|
||||
|
||||
Reference in New Issue
Block a user