payfrit-works-ios/PayfritWorks/Models/OrderLineItem.swift
John Pinkyfloyd 8d9fa1caa6 Migrate API endpoints from CFML to PHP
- Replace all .cfm endpoints with .php (PHP backend migration)
- Update debug strings and test walkthrough documentation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-03-14 17:16:36 -07:00

49 lines
1.9 KiB
Swift

import Foundation
struct OrderLineItem: Identifiable {
let lineItemId: Int
let parentLineItemId: Int
let itemId: Int
let itemName: String
let itemPrice: Double
let quantity: Int
let remark: String
let isModifier: Bool
let isCheckedByDefault: Bool
let isInvertedGroup: Bool
let removedDefaults: [String] // Array of item names that were removed from inverted groups
var id: Int { lineItemId }
init(json: [String: Any]) {
lineItemId = WorkTask.parseInt(json["LineItemID"]) ?? 0
parentLineItemId = WorkTask.parseInt(json["ParentLineItemID"]) ?? 0
itemId = WorkTask.parseInt(json["ItemID"]) ?? 0
itemName = (json["ItemName"] as? String) ?? ""
if let d = json["ItemPrice"] as? Double { itemPrice = d }
else if let i = json["ItemPrice"] as? Int { itemPrice = Double(i) }
else if let s = json["ItemPrice"] as? String, let d = Double(s) { itemPrice = d }
else { itemPrice = 0 }
quantity = WorkTask.parseInt(json["Quantity"]) ?? 1
remark = (json["Remark"] as? String) ?? ""
if let b = json["IsModifier"] as? Bool { isModifier = b }
else if let i = json["IsModifier"] as? Int { isModifier = i == 1 }
else { isModifier = false }
// Inverted group fields
if let b = json["IsCheckedByDefault"] as? Bool { isCheckedByDefault = b }
else if let i = json["IsCheckedByDefault"] as? Int { isCheckedByDefault = i == 1 }
else { isCheckedByDefault = false }
if let b = json["IsInvertedGroup"] as? Bool { isInvertedGroup = b }
else if let i = json["IsInvertedGroup"] as? Int { isInvertedGroup = i == 1 }
else { isInvertedGroup = false }
// Removed defaults array
if let arr = json["RemovedDefaults"] as? [String] {
removedDefaults = arr
} else {
removedDefaults = []
}
}
}