more inventory management work
This commit is contained in:
28
app/contexts/inventory_product.py
Normal file
28
app/contexts/inventory_product.py
Normal file
@ -0,0 +1,28 @@
|
||||
from app.models.tcgplayer_product import TCGPlayerProduct
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
class InventoryProductContext:
|
||||
def __init__(self, product: TCGPlayerProduct, db: Session):
|
||||
self.product = product
|
||||
self.prices = product.most_recent_tcgplayer_price
|
||||
self.db = db
|
||||
|
||||
@property
|
||||
def market_price(self) -> float:
|
||||
return self.product.most_recent_tcgplayer_price.market_price
|
||||
|
||||
@property
|
||||
def low_price(self) -> float:
|
||||
return self.product.most_recent_tcgplayer_price.low_price
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return self.product.name
|
||||
|
||||
@property
|
||||
def image_url(self) -> str:
|
||||
return self.product.image_url
|
||||
|
||||
@property
|
||||
def id(self) -> int:
|
||||
return self.product.id
|
Reference in New Issue
Block a user