ciclos

commit 7174a6992aaf0562eb9d3f03a3b01b1beee08946

Author: Pedro Lucas Porcellis <pedrolucasporcellis@gmail.com>

Display product's balance if there is such

 src/types/balance.py | 2 +-
 src/types/product.py | 6 +++++-


diff --git a/src/types/balance.py b/src/types/balance.py
index b6fae1c590b49fed1c279b771ec7ffe787d912b1..ac55ac258d06b9b1e9cac44b313ac7fc1d1848f5 100644
--- a/src/types/balance.py
+++ b/src/types/balance.py
@@ -20,6 +20,6 @@         db.session.commit()
 
     def to_json(self):
         return {
-            "value": self.value,
+            "value": float(self.value),
             "updated_at": self.updated_at.__str__()
         }




diff --git a/src/types/product.py b/src/types/product.py
index f14d35bfc1e5a9944f6526991586a867b05acc42..c365f9463a68cfb96f85966510793f4d143b4964 100644
--- a/src/types/product.py
+++ b/src/types/product.py
@@ -13,6 +13,9 @@
     created_at = db.Column(db.DateTime, default = dt.utcnow)
     updated_at = db.Column(db.DateTime, default = dt.utcnow)
 
+
+    balance = db.relationship("Balance", backref = "product", lazy = True, uselist = False)
+
     def __init__(self, title, description, group_id, category_id):
         self.title = title
         self.description = description
@@ -35,5 +38,6 @@             "description": self.description,
             "group_id": self.group_id,
             "category_id": self.category_id,
             "created_at": self.created_at.__str__(),
-            "updated_at": self.updated_at.__str__()
+            "updated_at": self.updated_at.__str__(),
+            "balance": (self.balance.to_json() if self.balance else None)
         }