2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-05-03 07:48:53 +00:00

Fixes for double.tryParse

This commit is contained in:
Oliver 2021-07-13 00:17:35 +10:00
parent 40613c9c36
commit f058cefad2
3 changed files with 5 additions and 6 deletions

View File

@ -199,10 +199,10 @@ class InvenTreePart extends InvenTreeModel {
}
// Get the number of stock on order for this Part
double get onOrder => double.tryParse(jsondata['ordering']) ?? 0;
double get onOrder => double.tryParse(jsondata['ordering'].toString()) ?? 0;
// Get the stock count for this Part
double get inStock => double.tryParse(jsondata['in_stock']) ?? 0;
double get inStock => double.tryParse(jsondata['in_stock'].toString()) ?? 0;
String get inStockString {
@ -214,7 +214,7 @@ class InvenTreePart extends InvenTreeModel {
}
// Get the number of units being build for this Part
double get building => double.tryParse(jsondata['building']) ?? 0;
double get building => double.tryParse(jsondata['building'].toString()) ?? 0;
// Get the number of BOM items in this Part (if it is an assembly)
int get bomItemCount => (jsondata['bom_items'] ?? 0) as int;

View File

@ -344,7 +344,7 @@ class InvenTreeStockItem extends InvenTreeModel {
String get serialNumber => jsondata['serial'] ?? "";
double get quantity => double.tryParse(jsondata['quantity']) ?? 0;
double get quantity => double.tryParse(jsondata['quantity'].toString()) ?? 0;
String get quantityString {

View File

@ -155,9 +155,8 @@ class QuantityField extends TextFormField {
if (value != null && value.isEmpty) return L10().quantityEmpty;
double quantity = double.tryParse(value ?? '0') ?? 0;
double quantity = double.tryParse(value.toString()) ?? 0;
if (quantity == null) return L10().quantityInvalid;
if (quantity <= 0) return L10().quantityPositive;
if ((max != null) && (quantity > max)) return "Quantity must not exceed ${max}";