<s> from __future__ import unicode_literals <EOL> from sqlalchemy import Column <EOL> from sqlalchemy import Integer <EOL> from sqlalchemy import Unicode <EOL> from sqlalchemy import Boolean <EOL> from sqlalchemy . schema import ForeignKey <EOL> from sqlalchemy . orm import relationship <EOL> from . base import DeclarativeBase <EOL> from . base import UTCDateTime <EOL> from . base import now_func <EOL> class Subscription ( DeclarativeBase ) : <EOL> """<STR_LIT>""" <EOL> __tablename__ = '<STR_LIT>' <EOL> guid = Column ( Unicode ( <NUM_LIT:64> ) , primary_key = True ) <EOL> customer_guid = Column ( <EOL> Unicode ( <NUM_LIT:64> ) , <EOL> ForeignKey ( <EOL> '<STR_LIT>' , <EOL> ondelete = '<STR_LIT>' , onupdate = '<STR_LIT>' <EOL> ) , <EOL> index = True , <EOL> nullable = False , <EOL> ) <EOL> plan_guid = Column ( <EOL> Unicode ( <NUM_LIT:64> ) , <EOL> ForeignKey ( <EOL> '<STR_LIT>' , <EOL> ondelete = '<STR_LIT>' , onupdate = '<STR_LIT>' <EOL> ) , <EOL> index = True , <EOL> nullable = False , <EOL> ) <EOL> funding_instrument_uri = Column ( Unicode ( <NUM_LIT> ) , index = True ) <EOL> amount = Column ( Integer ) <EOL> external_id = Column ( Unicode ( <NUM_LIT> ) , index = True ) <EOL> appears_on_statement_as = Column ( Unicode ( <NUM_LIT:32> ) ) <EOL> canceled = Column ( Boolean , default = False , nullable = False ) <EOL> next_invoice_at = Column ( UTCDateTime , nullable = False ) <EOL> started_at = Column ( UTCDateTime , nullable = False ) <EOL> canceled_at = Column ( UTCDateTime , default = None ) <EOL> created_at = Column ( UTCDateTime , default = now_func ) <EOL> updated_at = Column ( UTCDateTime , default = now_func ) <EOL> invoices = relationship ( <EOL> '<STR_LIT>' , <EOL> cascade = '<STR_LIT>' , <EOL> backref = '<STR_LIT>' , <EOL> lazy = '<STR_LIT>' , <EOL> order_by = '<STR_LIT>' <EOL> ) <EOL> @ property <EOL> def effective_amount ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . amount is None : <EOL> return self . plan . amount <EOL> return self . amount <EOL> @ property <EOL> def invoice_count ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . invoices . count ( ) <EOL> __all__ = [ <EOL> Subscription . __name__ , <EOL> ] </s>
