Major refactoring for model data accessors

This commit is contained in:
Oliver Walters 2023-04-21 20:25:29 +10:00
parent bfb582efb2
commit bff2a5e2a9
7 changed files with 188 additions and 227 deletions

View file

@ -36,13 +36,13 @@ class InvenTreeBomItem extends InvenTreeModel {
}
// Extract the 'reference' value associated with this BomItem
String get reference => (jsondata["reference"] ?? "") as String;
String get reference => getString("reference");
// Extract the 'quantity' value associated with this BomItem
double get quantity => double.tryParse(jsondata["quantity"].toString()) ?? 0;
double get quantity => getDouble("quantity");
// Extract the ID of the related part
int get partId => int.tryParse(jsondata["part"].toString()) ?? -1;
int get partId => getInt("part");
// Return a Part instance for the referenced part
InvenTreePart? get part {
@ -69,5 +69,5 @@ class InvenTreeBomItem extends InvenTreeModel {
}
// Extract the ID of the related sub-part
int get subPartId => int.tryParse(jsondata["sub_part"].toString()) ?? -1;
int get subPartId => getInt("sub_part");
}