feat(interests): CM-2 Part B — interest_berths price override (data + resolver)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-19 10:40:17 +02:00
parent b3753b96a1
commit 039ef25fe5
4 changed files with 91 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
import { describe, it, expect } from 'vitest';
import { resolveBerthPriceForInterest } from '@/lib/services/interest-berths.service';
describe('resolveBerthPriceForInterest', () => {
it('uses the override when present', () => {
expect(
resolveBerthPriceForInterest(
{ priceOverride: '1000000', priceOverrideCurrency: 'EUR' },
{ price: '3880800', priceCurrency: 'USD' },
),
).toEqual({ price: '1000000', currency: 'EUR' });
});
it('falls back to the base list price when no override', () => {
expect(
resolveBerthPriceForInterest(
{ priceOverride: null, priceOverrideCurrency: null },
{ price: '3880800', priceCurrency: 'USD' },
),
).toEqual({ price: '3880800', currency: 'USD' });
});
it('uses the base currency when the override currency is null', () => {
expect(
resolveBerthPriceForInterest(
{ priceOverride: '900000', priceOverrideCurrency: null },
{ price: '3880800', priceCurrency: 'USD' },
),
).toEqual({ price: '900000', currency: 'USD' });
});
});