Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def vendors(self):
"""
gives easy access to all commodities in the book through a :class:`piecash.model_common.CallableList`
of :class:`piecash.business.people.Vendor`
"""
from ..business import Vendor
return CallableList(self.session.query(Vendor))
def commodities(self):
"""
gives easy access to all commodities in the book through a :class:`piecash.model_common.CallableList`
of :class:`piecash.core.commodity.Commodity`
"""
from .commodity import Commodity
return CallableList(self.session.query(Commodity))
def employees(self):
"""
gives easy access to all commodities in the book through a :class:`piecash.model_common.CallableList`
of :class:`piecash.business.people.Employee`
"""
from ..business import Employee
return CallableList(self.session.query(Employee))
def customers(self):
"""
gives easy access to all commodities in the book through a :class:`piecash.model_common.CallableList`
of :class:`piecash.business.people.Customer`
"""
from ..business import Customer
return CallableList(self.session.query(Customer))
_charge_amt_num = Column('charge_amt_num', BIGINT())
_charge_amt_denom = Column('charge_amt_denom', BIGINT())
charge_amt = hybrid_property_gncnumeric(_charge_amt_num, _charge_amt_denom)
# relation definitions
# todo: check all relations and understanding of types...
term = relation('Billterm')
currency = relation('Commodity')
post_account = relation('Account')
post_lot = relation('Lot')
post_txn = relation('Transaction')
entries = relation('Entry',
back_populates='invoice',
cascade='all, delete-orphan',
collection_class=CallableList,
)
def __unirepr__(self):
return "Invoice<{}>".format(self.id)
class Job(DeclarativeBaseGuid):
__tablename__ = 'jobs'
__table_args__ = {}
# column definitions
id = Column('id', VARCHAR(length=2048), nullable=False)
name = Column('name', VARCHAR(length=2048), nullable=False)
reference = Column('reference', VARCHAR(length=2048), nullable=False)
active = Column('active', INTEGER(), nullable=False)
# keep this line as we reference it in the primaryjoin
guid = Column('guid', VARCHAR(length=32), primary_key=True, nullable=False, default=lambda: uuid.uuid4().hex)
name = Column('name', VARCHAR(length=2048), nullable=False)
description = Column('description', VARCHAR(length=2048))
num_periods = Column('num_periods', INTEGER(), nullable=False)
# # relation definitions
recurrence = relation(Recurrence,
primaryjoin=foreign(Recurrence.obj_guid) == guid,
cascade='all, delete-orphan',
uselist=False)
amounts = relation('BudgetAmount',
back_populates="budget",
cascade='all, delete-orphan',
collection_class=CallableList,
)
def __unirepr__(self):
return "Budget<{}({}) for {} periods following pattern '{}' >".format(self.name, self.description,
self.num_periods, self.recurrence)
class BudgetAmount(DeclarativeBase):
"""
A GnuCash BudgetAmount
Attributes:
amount (:class:`decimal.Decimal`): the budgeted amount
account (:class:`piecash.core.account.Account`): the budgeted account
budget (:class:`Budget`): the budget of the amount
# relation definitions
commodity = relation('Commodity', back_populates='accounts')
children = relation('Account',
back_populates='parent',
cascade='all, delete-orphan',
collection_class=CallableList,
)
parent = relation('Account',
back_populates='children',
remote_side=guid,
)
splits = relation('Split',
back_populates='account',
cascade='all, delete-orphan',
collection_class=CallableList,
)
lots = relation('Lot',
back_populates='account',
cascade='all, delete-orphan',
collection_class=CallableList,
)
budget_amounts = relation('BudgetAmount',
back_populates='account',
cascade='all, delete-orphan',
collection_class=CallableList,
)
scheduled_transaction = relation('ScheduledTransaction',
back_populates='template_account',
cascade='all, delete-orphan',
uselist=False,
)
def __declare_last__(cls):
from .invoice import Job
owner_type = PersonType.get(cls, None)
if owner_type:
cls.jobs = relation('Job',
primaryjoin=and_(
cls.guid == foreign(Job.owner_guid),
owner_type == Job.owner_type,
),
cascade='all, delete-orphan',
collection_class=CallableList,
)
@event.listens_for(cls.jobs, "append")
def add(target, value, initiator):
value.owner_type = owner_type
value.owner_guid = target.guid
value._assign_id()
def transactions(self):
"""
gives easy access to all transactions in the book through a :class:`piecash.model_common.CallableList`
of :class:`piecash.core.transaction.Transaction`
"""
from .transaction import Transaction
return CallableList(self.session.query(Transaction))
parent_guid = Column('parent_guid', VARCHAR(length=32), ForeignKey('accounts.guid'))
code = Column('code', VARCHAR(length=2048))
description = Column('description', VARCHAR(length=2048))
hidden = Column('hidden', INTEGER())
_placeholder = Column('placeholder', INTEGER())
placeholder = mapped_to_slot_property(_placeholder,
slot_name="placeholder",
slot_transform=lambda v: "true" if v else None)
# relation definitions
commodity = relation('Commodity', back_populates='accounts')
children = relation('Account',
back_populates='parent',
cascade='all, delete-orphan',
collection_class=CallableList,
)
parent = relation('Account',
back_populates='children',
remote_side=guid,
)
splits = relation('Split',
back_populates='account',
cascade='all, delete-orphan',
collection_class=CallableList,
)
lots = relation('Lot',
back_populates='account',
cascade='all, delete-orphan',
collection_class=CallableList,
)
budget_amounts = relation('BudgetAmount',