fix value properties on price an regular quantitiy

This commit is contained in:
2024-11-07 18:34:56 +01:00
parent 275bc49ffd
commit 018a5842d0
2 changed files with 8 additions and 10 deletions

View File

@@ -14,7 +14,7 @@ class Quantity(jsonapi_requests.orm.ApiModel):
@property @property
def value(self): def value(self):
return self.json_value['decimal'] return float(self.json_value['decimal'])
class Standard(Quantity): class Standard(Quantity):
class Meta(Quantity.Meta): class Meta(Quantity.Meta):
@@ -24,15 +24,15 @@ class Price(Quantity):
class Meta(Quantity.Meta): class Meta(Quantity.Meta):
name = 'price' name = 'price'
type, path = Quantity.Meta.get_type_and_path(name) type, path = Quantity.Meta.get_type_and_path(name)
json_unit_price = jsonapi_requests.orm.AttributeField('unit_price.decimal') json_unit_price = jsonapi_requests.orm.AttributeField('unit_price')
json_total_price = jsonapi_requests.orm.AttributeField('total_price.decimal') json_total_price = jsonapi_requests.orm.AttributeField('total_price')
@property @property
def unit_price(self): def unit_price(self):
return self.json_unit_price['decimal'] return float(self.json_unit_price['decimal'])
@property @property
def total_price(self): def total_price(self):
return self.json_total_price['decimal'] return float(self.json_total_price['decimal'])
class Material(Quantity): class Material(Quantity):
class Meta(Quantity.Meta): class Meta(Quantity.Meta):

View File

@@ -1,7 +1,5 @@
import neofarm.lib as neo import neofarm.lib as neo
if __name__ == "__main__": if __name__ == "__main__":
asset = neo.Asset.Plant.from_id("76f89f82-1238-43bb-b34f-796a92d491a2") log = neo.Log.Purchase.from_id("6ecc063f-3995-45e6-872e-952b811eaa94")
logs = asset.get_logs_of_type(neo.Log.Activity) print(log.quantities[0].total_price)
for log in logs:
print(log.name)