iOS: Kaufpreis + Belege am Einzelstück
ItemEditView bekommt einen Kaufpreis (Betrag + CHF/EUR) und eine Beleg-Sektion: Rechnung/Garantieschein als Bild (Fotoauswahl) oder PDF (Datei-Import) hochladen, ansehen (QuickLook) und loeschen. Nach einem PDF-Upload schlaegt der Server "Garantie bis" und Kaufpreis vor – per Knopf uebernehmbar. Item-Model um priceCents/currency/documents erweitert; Client-Methoden fuer Upload, Download und Loeschen der Belege. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -583,6 +583,19 @@ enum RemovalReasons {
|
||||
|
||||
// MARK: - Einzelstücke (Items mit UID/QR)
|
||||
|
||||
struct ItemDocument: Codable, Identifiable, Hashable {
|
||||
let id: Int
|
||||
let filename: String
|
||||
let contentType: String
|
||||
let uploadedAt: String
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case id, filename
|
||||
case contentType = "content_type"
|
||||
case uploadedAt = "uploaded_at"
|
||||
}
|
||||
}
|
||||
|
||||
struct Item: Codable, Identifiable, Hashable {
|
||||
let id: Int
|
||||
let uid: String
|
||||
@@ -594,12 +607,15 @@ struct Item: Codable, Identifiable, Hashable {
|
||||
let acquiredOn: String? // "yyyy-MM-dd"
|
||||
let warrantyUntil: String?
|
||||
let note: String?
|
||||
let priceCents: Int?
|
||||
let currency: String?
|
||||
let createdAt: String
|
||||
let productName: String?
|
||||
let productBrand: String?
|
||||
let documents: [ItemDocument]
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case id, uid, note
|
||||
case id, uid, note, currency, documents
|
||||
case productId = "product_id"
|
||||
case locationId = "location_id"
|
||||
case locationName = "location_name"
|
||||
@@ -607,12 +623,26 @@ struct Item: Codable, Identifiable, Hashable {
|
||||
case shopName = "shop_name"
|
||||
case acquiredOn = "acquired_on"
|
||||
case warrantyUntil = "warranty_until"
|
||||
case priceCents = "price_cents"
|
||||
case createdAt = "created_at"
|
||||
case productName = "product_name"
|
||||
case productBrand = "product_brand"
|
||||
}
|
||||
}
|
||||
|
||||
/// 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?
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case id
|
||||
case suggestedWarrantyUntil = "suggested_warranty_until"
|
||||
case suggestedPriceCents = "suggested_price_cents"
|
||||
}
|
||||
}
|
||||
|
||||
struct ItemCreateRequest: Codable {
|
||||
let count: Int
|
||||
let locationId: Int?
|
||||
@@ -636,13 +666,16 @@ struct ItemUpdateRequest: Encodable {
|
||||
var acquiredOn: String?
|
||||
var warrantyUntil: String?
|
||||
var note: String?
|
||||
var priceCents: Int?
|
||||
var currency: String?
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case note
|
||||
case note, currency
|
||||
case locationId = "location_id"
|
||||
case shopId = "shop_id"
|
||||
case acquiredOn = "acquired_on"
|
||||
case warrantyUntil = "warranty_until"
|
||||
case priceCents = "price_cents"
|
||||
}
|
||||
|
||||
// Immer alle Felder senden (auch null), damit sich ein Feld leeren lässt.
|
||||
@@ -653,6 +686,8 @@ struct ItemUpdateRequest: Encodable {
|
||||
try c.encode(acquiredOn, forKey: .acquiredOn)
|
||||
try c.encode(warrantyUntil, forKey: .warrantyUntil)
|
||||
try c.encode(note, forKey: .note)
|
||||
try c.encode(priceCents, forKey: .priceCents)
|
||||
try c.encode(currency, forKey: .currency)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user