diff --git a/CHANGELOG.md b/CHANGELOG.md index 42de93c..3830377 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org) using the following scheme: MAJOR.MINOR.PATCH +## [0.51.0] - 2026-06-14 + +### Changed +- Clean extrafields on decode init + ## [0.50.0] - 2026-06-12 ### Added diff --git a/Sources/SwiftDolibarr/Models/Core/Common/CommonBusinessObject.swift b/Sources/SwiftDolibarr/Models/Core/Common/CommonBusinessObject.swift index 7392a4d..6122845 100644 --- a/Sources/SwiftDolibarr/Models/Core/Common/CommonBusinessObject.swift +++ b/Sources/SwiftDolibarr/Models/Core/Common/CommonBusinessObject.swift @@ -123,7 +123,11 @@ public class CommonBusinessObject: Equatable, Codable, DolibarrBusinessObject { } self.entityId = try container.decodeIfPresent(String.self, forKey: .entityId) if let dictArrayOptions = try? container.decode([String: MultiType].self, forKey: .arrayOptions) { - self.arrayOptions = dictArrayOptions + self.arrayOptions = Dictionary( + uniqueKeysWithValues: dictArrayOptions.map { key, value in + (key.hasPrefix("options_") ? String(key.dropFirst("options_".count)) : key, value) + } + ) } else { self.arrayOptions = nil } diff --git a/Sources/SwiftDolibarr/Models/Core/Common/CommonBusinessObjectLine.swift b/Sources/SwiftDolibarr/Models/Core/Common/CommonBusinessObjectLine.swift index b048cdc..b1e954f 100644 --- a/Sources/SwiftDolibarr/Models/Core/Common/CommonBusinessObjectLine.swift +++ b/Sources/SwiftDolibarr/Models/Core/Common/CommonBusinessObjectLine.swift @@ -80,7 +80,11 @@ public class CommonBusinessObjectLine: Equatable, Hashable, Codable, DolibarrObj id = try container.decode(String.self, forKey: .id) rang = try container.decode(String.self, forKey: .rang) if let dictArrayOptions = try? container.decode([String: MultiType].self, forKey: .arrayOptions) { - self.arrayOptions = dictArrayOptions + self.arrayOptions = Dictionary( + uniqueKeysWithValues: dictArrayOptions.map { key, value in + (key.hasPrefix("options_") ? String(key.dropFirst("options_".count)) : key, value) + } + ) } else { self.arrayOptions = nil }