From dae74a19d3aec9d77d8a0e8a2008eccb318b4e16 Mon Sep 17 00:00:00 2001
From: Oliver Walters <oliver.henry.walters@gmail.com>
Date: Thu, 2 Jan 2020 20:25:59 +1100
Subject: [PATCH 1/2] Fix logic for decimal string helper

---
 InvenTree/InvenTree/helpers.py | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/InvenTree/InvenTree/helpers.py b/InvenTree/InvenTree/helpers.py
index 5ede677b9f..64e5b726f1 100644
--- a/InvenTree/InvenTree/helpers.py
+++ b/InvenTree/InvenTree/helpers.py
@@ -65,8 +65,19 @@ def decimal2string(d):
         A string representation of the input number
     """
 
+    try:
+        # Ensure that the provided string can actually be converted to a float
+        f = float(d)
+    except ValueError:
+        # Not a number
+        return str(d)
+
     s = str(d)
 
+    # Return entire number if there is no decimal place
+    if not '.' in s:
+        return s
+
     return s.rstrip("0").rstrip(".")
 
 

From 43d47686c51fe0b661c6f1deed6bbcbbc6357687 Mon Sep 17 00:00:00 2001
From: Oliver Walters <oliver.henry.walters@gmail.com>
Date: Thu, 2 Jan 2020 20:27:07 +1100
Subject: [PATCH 2/2] Style fixes

---
 InvenTree/InvenTree/helpers.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/InvenTree/InvenTree/helpers.py b/InvenTree/InvenTree/helpers.py
index 64e5b726f1..023bf5c451 100644
--- a/InvenTree/InvenTree/helpers.py
+++ b/InvenTree/InvenTree/helpers.py
@@ -67,7 +67,7 @@ def decimal2string(d):
 
     try:
         # Ensure that the provided string can actually be converted to a float
-        f = float(d)
+        float(d)
     except ValueError:
         # Not a number
         return str(d)
@@ -75,7 +75,7 @@ def decimal2string(d):
     s = str(d)
 
     # Return entire number if there is no decimal place
-    if not '.' in s:
+    if '.' not in s:
         return s
 
     return s.rstrip("0").rstrip(".")