tested to work for most entities NEXT: add logs property to asset
This commit is contained in:
@@ -1,31 +1,39 @@
|
||||
import jsonapi_requests
|
||||
from orm.my_meta import MyMeta
|
||||
|
||||
class Quantity(jsonapi_requests.orm.ApiModel):
|
||||
class Meta:
|
||||
class Meta(MyMeta):
|
||||
type = 'quantity'
|
||||
api = api
|
||||
@classmethod
|
||||
def get_type_and_path(cls, name):
|
||||
return (f"{cls.type}{api_type_spatrator}{name}", f"{cls.path}{api_path_separator}{name}")
|
||||
|
||||
|
||||
measure = jsonapi_requests.orm.AttributeField('measure')
|
||||
measure = jsonapi_requests.orm.AttributeField('value.decimal')
|
||||
units = jsonapi_requests.orm.RelationFieldField('units')
|
||||
json_value = jsonapi_requests.orm.AttributeField('value')
|
||||
units = jsonapi_requests.orm.RelationField('units')
|
||||
inventory_adjustment = jsonapi_requests.orm.AttributeField('inventory_adjustment')
|
||||
inventory_asset = jsonapi_requests.orm.RelationFieldField('inventory_asset')
|
||||
inventory_asset = jsonapi_requests.orm.RelationField('inventory_asset')
|
||||
|
||||
@property
|
||||
def value(self):
|
||||
return self.json_value['decimal']
|
||||
|
||||
class Standard(Quantity):
|
||||
class Meta(Quantity.Meta):
|
||||
name = 'standard'
|
||||
type, path = Asset.Meta.get_type_and_path(name)
|
||||
type, path = Quantity.Meta.get_type_and_path(name)
|
||||
class Price(Quantity):
|
||||
class Meta(Quantity.Meta):
|
||||
name = 'price'
|
||||
type, path = Asset.Meta.get_type_and_path(name)
|
||||
unit_price = jsonapi_requests.orm.AttributeField('unit_price.decimal')
|
||||
total_price = jsonapi_requests.orm.AttributeField('total_price.decimal')
|
||||
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')
|
||||
|
||||
@property
|
||||
def unit_price(self):
|
||||
return self.json_unit_price['decimal']
|
||||
@property
|
||||
def total_price(self):
|
||||
return self.json_total_price['decimal']
|
||||
|
||||
class Material(Quantity):
|
||||
class Meta(Quantity.Meta):
|
||||
name = 'material'
|
||||
type, path = Asset.Meta.get_type_and_path(name)
|
||||
unit_price = jsonapi_requests.orm.RelationField('material_type')
|
||||
type, path = Quantity.Meta.get_type_and_path(name)
|
||||
Reference in New Issue
Block a user