Skip to content

Commit 16a9ab1

Browse files
authored
fix: mark withdrawn Kronofogden auctions (#432)
1 parent a91e8e1 commit 16a9ab1

5 files changed

Lines changed: 37 additions & 1 deletion

File tree

i18n/locales/de.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -934,6 +934,8 @@
934934
"loading": "Lade …",
935935
"notFound": "Auktion nicht gefunden.",
936936
"cancelled": "Aufgehoben",
937+
"cancelledNoticeTitle": "Diese Auktion wurde zurückgezogen.",
938+
"cancelledNoticeText": "Die zuständige Behörde hat den Verkauf aufgehoben. Deshalb können Originaldokumente oder weitere Angaben nicht mehr verfügbar sein.",
937939
"untitled": "Zwangsversteigerung",
938940
"marketValue": "Verkehrswert",
939941
"original": "Original: {value}",

i18n/locales/en.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -934,6 +934,8 @@
934934
"loading": "Loading …",
935935
"notFound": "Auction not found.",
936936
"cancelled": "Cancelled",
937+
"cancelledNoticeTitle": "This auction has been withdrawn.",
938+
"cancelledNoticeText": "The responsible authority has cancelled the sale. Original documents or further details may therefore no longer be available.",
937939
"untitled": "Foreclosure auction",
938940
"marketValue": "Market value",
939941
"original": "Original: {value}",

pages/objekt/[platform]/[id].vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,10 @@ useHead(() => ({
184184
<span v-if="titleTranslated" class="text-xs text-muted-foreground">({{ $t('objektDetail.autoTranslatedHint') }})</span>
185185
</div>
186186
<p v-if="displayAddress" class="text-muted-foreground">{{ displayAddress }}</p>
187+
<div v-if="a.cancelled" class="rounded-md border border-destructive/40 bg-destructive/10 px-4 py-3 text-sm text-foreground">
188+
<p class="font-semibold text-destructive">{{ $t('objektDetail.cancelledNoticeTitle') }}</p>
189+
<p class="mt-1">{{ $t('objektDetail.cancelledNoticeText') }}</p>
190+
</div>
187191
</header>
188192

189193
<AuctionPhotoGallery :photos="photoUrls" :alt-base="displayTitle || $t('objektDetail.fallbackTitle')" />

server/crawlers/se/list.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,15 @@ function detailHtmlWithShowingAddress(id: string): string {
5757
`
5858
}
5959

60+
function withdrawnDetailHtml(id: string): string {
61+
return `
62+
<h3 id="h-Status">Status</h3><p class="normal">Utgår</p>
63+
<h3 id="h-Adress">Adress</h3><p class="normal">Testgatan ${id}</p>
64+
<h3 id="h-Kommun">Kommun</h3><p class="normal">Test kommun</p>
65+
<div id="datumet">2026-08-27</div>
66+
`
67+
}
68+
6069
function detailHtmlWithFarmArea(id: string): string {
6170
return `
6271
<h3 id="h-Adress">Adress</h3><p class="normal">Åse 360, Trångsviken</p>
@@ -469,6 +478,20 @@ describe('fetchListingById', () => {
469478
expect(fetchMock).toHaveBeenCalledOnce()
470479
})
471480

481+
it('marks a listing withdrawn when Kronofogden reports the status Utgår', async () => {
482+
const fetchMock = vi.fn(async (url: string | URL | Request) => {
483+
if (String(url) === `${BASE}/101867.html`) {
484+
return new Response(withdrawnDetailHtml('101867'), { status: 200 })
485+
}
486+
return new Response('not found', { status: 404 })
487+
})
488+
vi.stubGlobal('fetch', fetchMock)
489+
490+
const auction = await fetchListingById('101867', 'se-kronofogden')
491+
492+
expect(auction?.cancelled).toBe(true)
493+
})
494+
472495
it('rejects non-numeric ids before fetching', async () => {
473496
const fetchMock = vi.fn()
474497
vi.stubGlobal('fetch', fetchMock)

server/crawlers/se/list.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ async function fetchSearchIds(path: string): Promise<string[]> {
185185
}
186186

187187
function mapDetail(id: string, html: string, platformId: string): Auction | null {
188+
const status = extractFact(html, 'Status')
188189
const address = extractFact(html, 'Adress')
189190
const showingAddress = extractShowingAddress(html)
190191
const kommun = extractFact(html, 'Kommun')
@@ -280,7 +281,11 @@ function mapDetail(id: string, html: string, platformId: string): Auction | null
280281
marketValueText: marknadsvardRaw ? `${marknadsvardRaw} SEK` : null,
281282
auctionDateIso,
282283
auctionDateText: auctionDateIso,
283-
cancelled: false,
284+
// Kronofogden marks a withdrawn sale as "Utgår" (or, on the detail
285+
// page, "Objektet utgår från försäljning"). Keep it in the data so a
286+
// direct link can explain why documents or the original announcement may
287+
// no longer be available, while normal search results can hide it.
288+
cancelled: /^utg[åa]r\b/i.test(status ?? ''),
284289
sourceUpdatedIso: null,
285290
pdfUrl,
286291
detailUrl: `${SE_BASE}/${id}.html`,

0 commit comments

Comments
 (0)