mirror of
https://github.com/HendrikRauh/inventree-app.git
synced 2026-01-13 03:26:24 +00:00
Bug fix and refactoring
- Display difference between "in stock" and "unallocated stock" - Refactor to use single function in detail and list widgets
This commit is contained in:
parent
8d255885cf
commit
84edaef10a
3 changed files with 31 additions and 16 deletions
|
|
@ -269,17 +269,18 @@ class InvenTreePart extends InvenTreeModel {
|
|||
}
|
||||
|
||||
// Get the 'available stock' for this Part
|
||||
double get availableStock {
|
||||
double get unallocatedStock {
|
||||
|
||||
// Note that the 'available_stock' was not added until API v35
|
||||
if (jsondata.containsKey("available_stock")) {
|
||||
return double.tryParse(jsondata["available_stock"].toString()) ?? 0;
|
||||
if (jsondata.containsKey("unallocated_stock")) {
|
||||
return double.tryParse(jsondata["unallocated_stock"].toString()) ?? 0;
|
||||
} else {
|
||||
return inStock;
|
||||
}
|
||||
}
|
||||
|
||||
String get availableStockString {
|
||||
String q = simpleNumberString(availableStock);
|
||||
String get unallocatedStockString {
|
||||
String q = simpleNumberString(unallocatedStock);
|
||||
|
||||
if (units.isNotEmpty) {
|
||||
q += " ${units}";
|
||||
|
|
@ -288,6 +289,20 @@ class InvenTreePart extends InvenTreeModel {
|
|||
return q;
|
||||
}
|
||||
|
||||
String stockString({bool includeUnits = true}) {
|
||||
String q = unallocatedStockString;
|
||||
|
||||
if (unallocatedStock != inStock) {
|
||||
q += " / ${inStockString}";
|
||||
}
|
||||
|
||||
if (includeUnits && units.isNotEmpty) {
|
||||
q += " ${units}";
|
||||
}
|
||||
|
||||
return q;
|
||||
}
|
||||
|
||||
String get units => (jsondata["units"] ?? "") as String;
|
||||
|
||||
// Get the number of units being build for this Part
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue