mirror of
https://github.com/HendrikRauh/inventree-app.git
synced 2026-02-04 09:23:19 +00:00
Project code support (#336)
* Determine if project codes are supported * Add helpers for boolean functions * Adds helper methods for generic "model" class - Will allow us to do some good refactoring * Refactor the refactor * Add debug support and getMap function * Major refactoring for model data accessors * Handle null values * Add sentry reporting if key is used incorrectly * Fix typo * Refactor createFromJson function * Add model for ProjectCode * Display and edit project code for purchase orders
This commit is contained in:
parent
95573a2784
commit
e23a8b4d5e
13 changed files with 383 additions and 299 deletions
|
|
@ -12,9 +12,7 @@ class InvenTreeBomItem extends InvenTreeModel {
|
|||
InvenTreeBomItem.fromJson(Map<String, dynamic> json) : super.fromJson(json);
|
||||
|
||||
@override
|
||||
InvenTreeModel createFromJson(Map<String, dynamic> json) {
|
||||
return InvenTreeBomItem.fromJson(json);
|
||||
}
|
||||
InvenTreeModel createFromJson(Map<String, dynamic> json) => InvenTreeBomItem.fromJson(json);
|
||||
|
||||
@override
|
||||
String get URL => "bom/";
|
||||
|
|
@ -36,13 +34,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 +67,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");
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue