Is product liquid?

This commit is contained in:
cdricms
2025-09-27 19:05:12 +02:00
parent fa8baeff9d
commit 7be99711e1

View File

@@ -205,14 +205,8 @@ public class Product: Codable, ObjectDebugger {
public var waterQuantity: Units.UnitValue<Double>? {
guard let ingredient = ingredients?.first(where: { $0.isWater })
else {
print("The ingredient was not found.")
return nil
}
print(ingredient)
print("Product quantity", productQuantity)
print("Percent estimate", ingredient.percentEstimate)
print("Raw unit", productQuantityUnit)
guard let quantity = productQuantity,
let estimate = ingredient.percentEstimate,
@@ -225,6 +219,16 @@ public class Product: Codable, ObjectDebugger {
return Double(quantity * (estimate / 100))[unit]
}
public var isLiquid: Bool {
guard let rawUnit = productQuantityUnit,
let unit = Units.Unit(rawValue: rawUnit)
else {
return false
}
return unit.category == .volume
}
private enum CodingKeys: String, CodingKey {
// case images
case ingredients