yuyu/core/component/instances/invoice_handler.py

19 lines
595 B
Python
Raw Normal View History

2022-05-13 13:53:52 +07:00
from core.exception import PriceNotFound
from core.models import FlavorPrice, InvoiceInstance, PriceMixin
from core.component.base.invoice_handler import InvoiceHandler
class InstanceInvoiceHandler(InvoiceHandler):
INVOICE_CLASS = InvoiceInstance
KEY_FIELD = "instance_id"
PRICE_DEPENDENCY_FIELDS = ['flavor_id']
INFORMATIVE_FIELDS = ['name']
def get_price(self, payload) -> PriceMixin:
price = FlavorPrice.objects.filter(flavor_id=payload['flavor_id']).first()
if price is None:
raise PriceNotFound(identifier='flavor')
return price