iOS: Kaufpreis + Beleg beim Anlegen; Kaufdatum/Shop-Vorschlag
- ItemAddSheet: Kaufpreis (+Währung) und Beleg (Bild/PDF). PDF wird beim Waehlen analysiert und Kaufdatum/Garantie/Preis/Shop vorbefuellt; erkannter neuer Shop wird beim Anlegen erstellt. Beleg haengt an das erste angelegte Stueck. - ItemEditView-Vorschlag zeigt/uebernimmt jetzt auch Kaufdatum und Shop (bekannten zuweisen, sonst anlegen). - Models/Client: DocumentSuggestions, analyzeItemDocument, ItemCreateRequest um price_cents/currency erweitert. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -712,25 +712,46 @@ struct Item: Codable, Identifiable, Hashable {
|
||||
}
|
||||
|
||||
/// Antwort nach dem Beleg-Upload – mit den aus dem PDF geschätzten Werten.
|
||||
struct ItemDocumentUpload: Codable {
|
||||
let id: Int
|
||||
let suggestedWarrantyUntil: String?
|
||||
let suggestedPriceCents: Int?
|
||||
let suggestedPriceCandidates: [Int]
|
||||
/// Aus einem Beleg-PDF geschätzte Werte (Analyse ohne Speichern).
|
||||
struct DocumentSuggestions: Codable {
|
||||
var suggestedWarrantyUntil: String? = nil
|
||||
var suggestedPriceCents: Int? = nil
|
||||
var suggestedPriceCandidates: [Int] = []
|
||||
var suggestedAcquiredOn: String? = nil
|
||||
var suggestedShopId: Int? = nil
|
||||
var suggestedShopName: String? = nil
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case id
|
||||
case suggestedWarrantyUntil = "suggested_warranty_until"
|
||||
case suggestedPriceCents = "suggested_price_cents"
|
||||
case suggestedPriceCandidates = "suggested_price_candidates"
|
||||
case suggestedAcquiredOn = "suggested_acquired_on"
|
||||
case suggestedShopId = "suggested_shop_id"
|
||||
case suggestedShopName = "suggested_shop_name"
|
||||
}
|
||||
|
||||
init() {}
|
||||
|
||||
init(from decoder: Decoder) throws {
|
||||
let c = try decoder.container(keyedBy: CodingKeys.self)
|
||||
id = try c.decode(Int.self, forKey: .id)
|
||||
suggestedWarrantyUntil = try c.decodeIfPresent(String.self, forKey: .suggestedWarrantyUntil)
|
||||
suggestedPriceCents = try c.decodeIfPresent(Int.self, forKey: .suggestedPriceCents)
|
||||
suggestedPriceCandidates = try c.decodeIfPresent([Int].self, forKey: .suggestedPriceCandidates) ?? []
|
||||
suggestedAcquiredOn = try c.decodeIfPresent(String.self, forKey: .suggestedAcquiredOn)
|
||||
suggestedShopId = try c.decodeIfPresent(Int.self, forKey: .suggestedShopId)
|
||||
suggestedShopName = try c.decodeIfPresent(String.self, forKey: .suggestedShopName)
|
||||
}
|
||||
}
|
||||
|
||||
struct ItemDocumentUpload: Codable {
|
||||
let id: Int
|
||||
let suggestions: DocumentSuggestions
|
||||
|
||||
enum IdKey: String, CodingKey { case id }
|
||||
|
||||
init(from decoder: Decoder) throws {
|
||||
id = try decoder.container(keyedBy: IdKey.self).decode(Int.self, forKey: .id)
|
||||
suggestions = try DocumentSuggestions(from: decoder)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -741,13 +762,16 @@ struct ItemCreateRequest: Codable {
|
||||
let acquiredOn: String?
|
||||
let warrantyUntil: String?
|
||||
let note: String?
|
||||
var priceCents: Int? = nil
|
||||
var currency: String? = nil
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case count, note
|
||||
case count, note, currency
|
||||
case locationId = "location_id"
|
||||
case shopId = "shop_id"
|
||||
case acquiredOn = "acquired_on"
|
||||
case warrantyUntil = "warranty_until"
|
||||
case priceCents = "price_cents"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user