Added the catalogue models and seed to support phase 5 of the POC prototype in the Persistence package.

This commit is contained in:
javier committed 2026-09-21 13:31:44 +02:00
1 parent 9403931109
commit 89a7a7b8e5
19 files changed
+990 -15

No files matched your search

@@ -29,6 +29,14 @@ public struct Shop: Sendable, Equatable {
public let returnsNote: String
/// The shop's description of itself.
public let about: String
/// Whether the seller sells as a private collector or as a business.
public let kind: Kind
/// The business's Chamber of Commerce (KvK) number, shown on its shop page.
public let kvkNumber: String?
/// The business's VAT (BTW) identifier.
public let vatID: String?
/// The business's registered name.
public let legalName: String?
// MARK: Initializers
@@ -45,7 +53,11 @@ public struct Shop: Sendable, Equatable {
handlingDays: Int,
shipsNote: String,
returnsNote: String,
about: String
about: String,
kind: Kind = .business,
kvkNumber: String? = nil,
vatID: String? = nil,
legalName: String? = nil
) {
self.slug = slug
self.name = name
@@ -60,6 +72,35 @@ public struct Shop: Sendable, Equatable {
self.shipsNote = shipsNote
self.returnsNote = returnsNote
self.about = about
self.kind = kind
self.kvkNumber = kvkNumber
self.vatID = vatID
self.legalName = legalName
}
}
// MARK: - Extensions
public extension Shop {
// MARK: Computed
/// Whether the shop ships from a member state of the European Union, so a delivery within it crosses no customs border.
var shipsFromEU: Bool {
ListingFilter.euCountries.contains(country)
}
}
// MARK: - Enumerations
public extension Shop {
/// How a seller sells, which decides what consumer law asks of them.
enum Kind: String, CaseIterable, Sendable {
/// A business: its KvK number shows on its shop page, and consumers get the 14-day right of withdrawal.
case business
/// A private collector selling their own books: no statutory right of withdrawal.
case privateSeller = "private"
}
}