mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 13:36:50 +00:00
Merge pull request #96 from inventree/building-quantity
Building quantity
This commit is contained in:
commit
87ce0d4464
@ -1,6 +1,7 @@
|
||||
import "dart:io";
|
||||
|
||||
import "package:inventree/api.dart";
|
||||
import "package:inventree/helpers.dart";
|
||||
import "package:inventree/inventree/stock.dart";
|
||||
import "package:inventree/inventree/company.dart";
|
||||
import "package:flutter/material.dart";
|
||||
@ -250,11 +251,7 @@ class InvenTreePart extends InvenTreeModel {
|
||||
|
||||
String get onOrderString {
|
||||
|
||||
if (onOrder == onOrder.toInt()) {
|
||||
return onOrder.toInt().toString();
|
||||
} else {
|
||||
return onOrder.toString();
|
||||
}
|
||||
return simpleNumberString(onOrder);
|
||||
}
|
||||
|
||||
// Get the stock count for this Part
|
||||
@ -262,11 +259,7 @@ class InvenTreePart extends InvenTreeModel {
|
||||
|
||||
String get inStockString {
|
||||
|
||||
String q = inStock.toString();
|
||||
|
||||
if (inStock == inStock.toInt()) {
|
||||
q = inStock.toInt().toString();
|
||||
}
|
||||
String q = simpleNumberString(inStock);
|
||||
|
||||
if (units.isNotEmpty) {
|
||||
q += " ${units}";
|
||||
@ -275,6 +268,41 @@ class InvenTreePart extends InvenTreeModel {
|
||||
return q;
|
||||
}
|
||||
|
||||
// Get the 'available stock' for this Part
|
||||
double get unallocatedStock {
|
||||
|
||||
// Note that the 'available_stock' was not added until API v35
|
||||
if (jsondata.containsKey("unallocated_stock")) {
|
||||
return double.tryParse(jsondata["unallocated_stock"].toString()) ?? 0;
|
||||
} else {
|
||||
return inStock;
|
||||
}
|
||||
}
|
||||
|
||||
String get unallocatedStockString {
|
||||
String q = simpleNumberString(unallocatedStock);
|
||||
|
||||
if (units.isNotEmpty) {
|
||||
q += " ${units}";
|
||||
}
|
||||
|
||||
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
|
||||
|
2
lib/l10n
2
lib/l10n
@ -1 +1 @@
|
||||
Subproject commit 581ce0a818532157ffa0a1b449bf1a240558a238
|
||||
Subproject commit 7cc9177c89a4dbd122892b96bbd25f9e9125dfbf
|
@ -5,6 +5,7 @@ import "package:font_awesome_flutter/font_awesome_flutter.dart";
|
||||
import "package:inventree/app_colors.dart";
|
||||
import "package:inventree/inventree/stock.dart";
|
||||
import "package:inventree/l10.dart";
|
||||
import "package:inventree/helpers.dart";
|
||||
import "package:inventree/widget/part_attachments_widget.dart";
|
||||
import "package:inventree/widget/part_notes.dart";
|
||||
import "package:inventree/widget/progress.dart";
|
||||
@ -208,19 +209,19 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
||||
subtitle: Text(L10().partCategoryTopLevel),
|
||||
leading: FaIcon(FontAwesomeIcons.sitemap, color: COLOR_CLICK),
|
||||
onTap: () {
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) => CategoryDisplayWidget(null)));
|
||||
Navigator.push(context, MaterialPageRoute(
|
||||
builder: (context) => CategoryDisplayWidget(null)));
|
||||
},
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Stock information
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().stock),
|
||||
title: Text(L10().availableStock),
|
||||
subtitle: Text(L10().stockDetails),
|
||||
leading: FaIcon(FontAwesomeIcons.boxes, color: COLOR_CLICK),
|
||||
trailing: Text("${part.inStockString}"),
|
||||
trailing: Text(part.stockString()),
|
||||
onTap: () {
|
||||
setState(() {
|
||||
tabIndex = 1;
|
||||
@ -229,48 +230,9 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
||||
),
|
||||
);
|
||||
|
||||
// Keywords?
|
||||
if (part.keywords.isNotEmpty) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text("${part.keywords}"),
|
||||
leading: FaIcon(FontAwesomeIcons.key),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// External link?
|
||||
if (part.link.isNotEmpty) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text("${part.link}"),
|
||||
leading: FaIcon(FontAwesomeIcons.link, color: COLOR_CLICK),
|
||||
onTap: () {
|
||||
part.openLink();
|
||||
},
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Tiles for "purchaseable" parts
|
||||
if (part.isPurchaseable) {
|
||||
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().suppliers),
|
||||
leading: FaIcon(FontAwesomeIcons.industry),
|
||||
trailing: Text("${part.supplierCount}"),
|
||||
/* TODO:
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => PartSupplierWidget(part))
|
||||
);
|
||||
},
|
||||
*/
|
||||
)
|
||||
);
|
||||
|
||||
// On order
|
||||
tiles.add(
|
||||
ListTile(
|
||||
@ -307,7 +269,7 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
||||
ListTile(
|
||||
title: Text(L10().building),
|
||||
leading: FaIcon(FontAwesomeIcons.tools),
|
||||
trailing: Text("${part.building}"),
|
||||
trailing: Text("${simpleNumberString(part.building)}"),
|
||||
onTap: () {
|
||||
// TODO
|
||||
},
|
||||
@ -316,6 +278,29 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
||||
}
|
||||
}
|
||||
|
||||
// Keywords?
|
||||
if (part.keywords.isNotEmpty) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text("${part.keywords}"),
|
||||
leading: FaIcon(FontAwesomeIcons.key),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// External link?
|
||||
if (part.link.isNotEmpty) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text("${part.link}"),
|
||||
leading: FaIcon(FontAwesomeIcons.link, color: COLOR_CLICK),
|
||||
onTap: () {
|
||||
part.openLink();
|
||||
},
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Tiles for "component" part
|
||||
if (part.isComponent && part.usedInCount > 0) {
|
||||
|
||||
@ -332,6 +317,25 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
||||
);
|
||||
}
|
||||
|
||||
if (part.isPurchaseable) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().suppliers),
|
||||
leading: FaIcon(FontAwesomeIcons.industry),
|
||||
trailing: Text("${part.supplierCount}"),
|
||||
/* TODO:
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => PartSupplierWidget(part))
|
||||
);
|
||||
},
|
||||
*/
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// TODO - Add request tests?
|
||||
/*
|
||||
if (part.isTrackable) {
|
||||
|
@ -86,8 +86,8 @@ class _PaginatedPartListState extends PaginatedSearchState<PaginatedPartList> {
|
||||
|
||||
return ListTile(
|
||||
title: Text(part.fullname),
|
||||
subtitle: Text("${part.description}"),
|
||||
trailing: Text("${part.inStockString}"),
|
||||
subtitle: Text(part.description),
|
||||
trailing: Text(part.stockString()),
|
||||
leading: InvenTreeAPI().getImage(
|
||||
part.thumbnail,
|
||||
width: 40,
|
||||
|
Loading…
x
Reference in New Issue
Block a user