mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 13:36:50 +00:00
Update stock display to indicate allocations
This commit is contained in:
parent
62df40f4b3
commit
591c6a5592
@ -451,7 +451,14 @@ class InvenTreeStockItem extends InvenTreeModel {
|
|||||||
|
|
||||||
String quantityString({bool includeUnits = false}){
|
String quantityString({bool includeUnits = false}){
|
||||||
|
|
||||||
String q = simpleNumberString(quantity);
|
String q = "";
|
||||||
|
|
||||||
|
if (allocated > 0) {
|
||||||
|
q += simpleNumberString(available);
|
||||||
|
q += " / ";
|
||||||
|
}
|
||||||
|
|
||||||
|
q += simpleNumberString(quantity);
|
||||||
|
|
||||||
if (includeUnits && units.isNotEmpty) {
|
if (includeUnits && units.isNotEmpty) {
|
||||||
q += " ${units}";
|
q += " ${units}";
|
||||||
@ -460,6 +467,10 @@ class InvenTreeStockItem extends InvenTreeModel {
|
|||||||
return q;
|
return q;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double get allocated => double.tryParse(jsondata["allocated"].toString()) ?? 0;
|
||||||
|
|
||||||
|
double get available => quantity - allocated;
|
||||||
|
|
||||||
int get locationId => (jsondata["location"] ?? -1) as int;
|
int get locationId => (jsondata["location"] ?? -1) as int;
|
||||||
|
|
||||||
bool isSerialized() => serialNumber.isNotEmpty && quantity.toInt() == 1;
|
bool isSerialized() => serialNumber.isNotEmpty && quantity.toInt() == 1;
|
||||||
@ -467,9 +478,11 @@ class InvenTreeStockItem extends InvenTreeModel {
|
|||||||
String serialOrQuantityDisplay() {
|
String serialOrQuantityDisplay() {
|
||||||
if (isSerialized()) {
|
if (isSerialized()) {
|
||||||
return "SN ${serialNumber}";
|
return "SN ${serialNumber}";
|
||||||
|
} else if (allocated > 0) {
|
||||||
|
return "${available} / ${quantity}";
|
||||||
|
} else {
|
||||||
|
return simpleNumberString(quantity);
|
||||||
}
|
}
|
||||||
|
|
||||||
return simpleNumberString(quantity);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String get locationName {
|
String get locationName {
|
||||||
|
@ -655,6 +655,9 @@
|
|||||||
"description": "Quantity"
|
"description": "Quantity"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"quantityAvailable": "Quantity Available",
|
||||||
|
"@quantityAvailable": {},
|
||||||
|
|
||||||
"quantityEmpty": "Quantity is empty",
|
"quantityEmpty": "Quantity is empty",
|
||||||
"@quantityEmpty": {},
|
"@quantityEmpty": {},
|
||||||
|
|
||||||
|
@ -513,7 +513,7 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
|||||||
} else {
|
} else {
|
||||||
tiles.add(
|
tiles.add(
|
||||||
ListTile(
|
ListTile(
|
||||||
title: Text(L10().quantity),
|
title: item.allocated > 0 ? Text(L10().quantityAvailable) : Text(L10().quantity),
|
||||||
leading: FaIcon(FontAwesomeIcons.cubes),
|
leading: FaIcon(FontAwesomeIcons.cubes),
|
||||||
trailing: Text("${item.quantityString()}"),
|
trailing: Text("${item.quantityString()}"),
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user