iOS: Verbrauchsgegenstand als dritte Gegenstands-Art (wie ein Lebensmittel)
Neuer Artikel: 3-Wege-Verwaltung fuer Gegenstaende (Menge je Lagerort / Einzelstuecke / Verbrauchsgegenstand). Verbrauchsgegenstaende laufen wie Lebensmittel als Charge (Einheit, Packung, MHD, Gruppe, Chargen-Ansicht, Mindestbestand mit Einheit) - foodLike = kein Gegenstand ODER bulk. Menge- Gegenstaende koennen jetzt ebenfalls einer Gruppe zugeordnet werden. ProductDetailView entsprechend auf foodLike umgestellt; NewProductRequest und ProductUpdateRequest um bulk/individual/base_unit erweitert. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -78,11 +78,13 @@ struct Product: Codable, Identifiable, Hashable {
|
||||
let fieldValues: [String: String?]?
|
||||
/// Gegenstand als Einzelstücke (Items mit UID/QR) statt als Menge geführt.
|
||||
let individual: Bool?
|
||||
/// Gegenstand als Verbrauchsgegenstand wie ein Lebensmittel (Charge) geführt.
|
||||
let bulk: Bool?
|
||||
/// Mindestbestand je Lagerort (zusaetzlich zum globalen Mindestbestand).
|
||||
let locationMinStocks: [LocationMinStock]?
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case id, barcode, name, brand, stock, kind, barcodes, tracking, individual
|
||||
case id, barcode, name, brand, stock, kind, barcodes, tracking, individual, bulk
|
||||
case locationMinStocks = "location_min_stocks"
|
||||
case datePrecision = "date_precision"
|
||||
case categoryId = "category_id"
|
||||
@@ -109,6 +111,11 @@ struct Product: Codable, Identifiable, Hashable {
|
||||
var isObject: Bool { tracking == "object" }
|
||||
/// Gegenstand, der als Einzelstücke (UID/QR) geführt wird?
|
||||
var isIndividual: Bool { individual == true }
|
||||
/// Verbrauchsgegenstand: Gegenstand, der wie ein Lebensmittel als Charge läuft.
|
||||
var isBulk: Bool { bulk == true }
|
||||
/// Nutzt die Lebensmittel-Pfade (Chargen, Einheit, MHD, Mindestbestand):
|
||||
/// echte Lebensmittel UND Verbrauchsgegenstände.
|
||||
var foodLike: Bool { !isObject || isBulk }
|
||||
|
||||
/// Bezeichnung der Artikeleinheit (Gebinde, sonst Produkteinheit).
|
||||
var articleUnitLabel: String {
|
||||
@@ -300,9 +307,11 @@ struct NewProductRequest: Codable {
|
||||
let groupId: Int?
|
||||
let categoryId: Int?
|
||||
var individual: Bool? = nil
|
||||
/// Verbrauchsgegenstand: Gegenstand wie ein Lebensmittel (Charge) geführt.
|
||||
var bulk: Bool? = nil
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case barcode, name, brand, individual
|
||||
case barcode, name, brand, individual, bulk
|
||||
case imageUrl = "image_url"
|
||||
case baseUnit = "base_unit"
|
||||
case packageSize = "package_size"
|
||||
@@ -500,9 +509,15 @@ struct ProductUpdateRequest: Encodable {
|
||||
var minStockInPackages: Bool? = nil
|
||||
var minStockUnitId: Int? = nil
|
||||
var sendMinStock = false
|
||||
// Verwaltungsart eines Gegenstands (Einzelstück/Verbrauchsgegenstand) und die
|
||||
// Basiseinheit nur senden, wenn ausdrücklich gewünscht – sonst nichts ändern.
|
||||
var baseUnit: String? = nil
|
||||
var individual: Bool? = nil
|
||||
var bulk: Bool? = nil
|
||||
var sendMode = false
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case name, brand
|
||||
case name, brand, individual, bulk
|
||||
case packageSize = "package_size"
|
||||
case packageLabel = "package_label"
|
||||
case datePrecision = "date_precision"
|
||||
@@ -514,6 +529,7 @@ struct ProductUpdateRequest: Encodable {
|
||||
case minStock = "min_stock"
|
||||
case minStockInPackages = "min_stock_in_packages"
|
||||
case minStockUnitId = "min_stock_unit_id"
|
||||
case baseUnit = "base_unit"
|
||||
}
|
||||
|
||||
func encode(to encoder: Encoder) throws {
|
||||
@@ -534,6 +550,11 @@ struct ProductUpdateRequest: Encodable {
|
||||
try container.encode(minStockInPackages, forKey: .minStockInPackages)
|
||||
try container.encode(minStockUnitId, forKey: .minStockUnitId)
|
||||
}
|
||||
if sendMode {
|
||||
try container.encode(individual, forKey: .individual)
|
||||
try container.encode(bulk, forKey: .bulk)
|
||||
if let baseUnit { try container.encode(baseUnit, forKey: .baseUnit) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user