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 "dart:io";
|
||||||
|
|
||||||
import "package:inventree/api.dart";
|
import "package:inventree/api.dart";
|
||||||
|
import "package:inventree/helpers.dart";
|
||||||
import "package:inventree/inventree/stock.dart";
|
import "package:inventree/inventree/stock.dart";
|
||||||
import "package:inventree/inventree/company.dart";
|
import "package:inventree/inventree/company.dart";
|
||||||
import "package:flutter/material.dart";
|
import "package:flutter/material.dart";
|
||||||
@ -250,11 +251,7 @@ class InvenTreePart extends InvenTreeModel {
|
|||||||
|
|
||||||
String get onOrderString {
|
String get onOrderString {
|
||||||
|
|
||||||
if (onOrder == onOrder.toInt()) {
|
return simpleNumberString(onOrder);
|
||||||
return onOrder.toInt().toString();
|
|
||||||
} else {
|
|
||||||
return onOrder.toString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the stock count for this Part
|
// Get the stock count for this Part
|
||||||
@ -262,11 +259,7 @@ class InvenTreePart extends InvenTreeModel {
|
|||||||
|
|
||||||
String get inStockString {
|
String get inStockString {
|
||||||
|
|
||||||
String q = inStock.toString();
|
String q = simpleNumberString(inStock);
|
||||||
|
|
||||||
if (inStock == inStock.toInt()) {
|
|
||||||
q = inStock.toInt().toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (units.isNotEmpty) {
|
if (units.isNotEmpty) {
|
||||||
q += " ${units}";
|
q += " ${units}";
|
||||||
@ -275,6 +268,41 @@ class InvenTreePart extends InvenTreeModel {
|
|||||||
return q;
|
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;
|
String get units => (jsondata["units"] ?? "") as String;
|
||||||
|
|
||||||
// Get the number of units being build for this Part
|
// 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/app_colors.dart";
|
||||||
import "package:inventree/inventree/stock.dart";
|
import "package:inventree/inventree/stock.dart";
|
||||||
import "package:inventree/l10.dart";
|
import "package:inventree/l10.dart";
|
||||||
|
import "package:inventree/helpers.dart";
|
||||||
import "package:inventree/widget/part_attachments_widget.dart";
|
import "package:inventree/widget/part_attachments_widget.dart";
|
||||||
import "package:inventree/widget/part_notes.dart";
|
import "package:inventree/widget/part_notes.dart";
|
||||||
import "package:inventree/widget/progress.dart";
|
import "package:inventree/widget/progress.dart";
|
||||||
@ -203,24 +204,24 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
tiles.add(
|
tiles.add(
|
||||||
ListTile(
|
ListTile(
|
||||||
title: Text(L10().partCategory),
|
title: Text(L10().partCategory),
|
||||||
subtitle: Text(L10().partCategoryTopLevel),
|
subtitle: Text(L10().partCategoryTopLevel),
|
||||||
leading: FaIcon(FontAwesomeIcons.sitemap, color: COLOR_CLICK),
|
leading: FaIcon(FontAwesomeIcons.sitemap, color: COLOR_CLICK),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.push(context, MaterialPageRoute(builder: (context) => CategoryDisplayWidget(null)));
|
Navigator.push(context, MaterialPageRoute(
|
||||||
},
|
builder: (context) => CategoryDisplayWidget(null)));
|
||||||
)
|
},
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stock information
|
|
||||||
tiles.add(
|
tiles.add(
|
||||||
ListTile(
|
ListTile(
|
||||||
title: Text(L10().stock),
|
title: Text(L10().availableStock),
|
||||||
subtitle: Text(L10().stockDetails),
|
subtitle: Text(L10().stockDetails),
|
||||||
leading: FaIcon(FontAwesomeIcons.boxes, color: COLOR_CLICK),
|
leading: FaIcon(FontAwesomeIcons.boxes, color: COLOR_CLICK),
|
||||||
trailing: Text("${part.inStockString}"),
|
trailing: Text(part.stockString()),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
tabIndex = 1;
|
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
|
// Tiles for "purchaseable" parts
|
||||||
if (part.isPurchaseable) {
|
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
|
// On order
|
||||||
tiles.add(
|
tiles.add(
|
||||||
ListTile(
|
ListTile(
|
||||||
@ -307,7 +269,7 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
|||||||
ListTile(
|
ListTile(
|
||||||
title: Text(L10().building),
|
title: Text(L10().building),
|
||||||
leading: FaIcon(FontAwesomeIcons.tools),
|
leading: FaIcon(FontAwesomeIcons.tools),
|
||||||
trailing: Text("${part.building}"),
|
trailing: Text("${simpleNumberString(part.building)}"),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
// TODO
|
// 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
|
// Tiles for "component" part
|
||||||
if (part.isComponent && part.usedInCount > 0) {
|
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?
|
// TODO - Add request tests?
|
||||||
/*
|
/*
|
||||||
if (part.isTrackable) {
|
if (part.isTrackable) {
|
||||||
|
@ -86,8 +86,8 @@ class _PaginatedPartListState extends PaginatedSearchState<PaginatedPartList> {
|
|||||||
|
|
||||||
return ListTile(
|
return ListTile(
|
||||||
title: Text(part.fullname),
|
title: Text(part.fullname),
|
||||||
subtitle: Text("${part.description}"),
|
subtitle: Text(part.description),
|
||||||
trailing: Text("${part.inStockString}"),
|
trailing: Text(part.stockString()),
|
||||||
leading: InvenTreeAPI().getImage(
|
leading: InvenTreeAPI().getImage(
|
||||||
part.thumbnail,
|
part.thumbnail,
|
||||||
width: 40,
|
width: 40,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user