From 018a5842d0c72f73757bda2ac3369c161c4ad501 Mon Sep 17 00:00:00 2001 From: matze Date: Thu, 7 Nov 2024 18:34:56 +0100 Subject: [PATCH] fix value properties on price an regular quantitiy --- neofarm/orm/quantity.py | 12 ++++++------ test.py | 6 ++---- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/neofarm/orm/quantity.py b/neofarm/orm/quantity.py index f23fad8..b7656fb 100644 --- a/neofarm/orm/quantity.py +++ b/neofarm/orm/quantity.py @@ -14,7 +14,7 @@ class Quantity(jsonapi_requests.orm.ApiModel): @property def value(self): - return self.json_value['decimal'] + return float(self.json_value['decimal']) class Standard(Quantity): class Meta(Quantity.Meta): @@ -24,15 +24,15 @@ class Price(Quantity): class Meta(Quantity.Meta): name = 'price' type, path = Quantity.Meta.get_type_and_path(name) - json_unit_price = jsonapi_requests.orm.AttributeField('unit_price.decimal') - json_total_price = jsonapi_requests.orm.AttributeField('total_price.decimal') - + json_unit_price = jsonapi_requests.orm.AttributeField('unit_price') + json_total_price = jsonapi_requests.orm.AttributeField('total_price') + @property def unit_price(self): - return self.json_unit_price['decimal'] + return float(self.json_unit_price['decimal']) @property def total_price(self): - return self.json_total_price['decimal'] + return float(self.json_total_price['decimal']) class Material(Quantity): class Meta(Quantity.Meta): diff --git a/test.py b/test.py index 25aaa41..99ac199 100644 --- a/test.py +++ b/test.py @@ -1,7 +1,5 @@ import neofarm.lib as neo if __name__ == "__main__": - asset = neo.Asset.Plant.from_id("76f89f82-1238-43bb-b34f-796a92d491a2") - logs = asset.get_logs_of_type(neo.Log.Activity) - for log in logs: - print(log.name) \ No newline at end of file + log = neo.Log.Purchase.from_id("6ecc063f-3995-45e6-872e-952b811eaa94") + print(log.quantities[0].total_price) \ No newline at end of file