How to use the piecash._common.hybrid_property_gncnumeric function in piecash

To help you get started, we’ve selected a few piecash examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sdementen / piecash / tests / test_model_common.py View on Github external
def test_float_in_gncnumeric(self):
        Mock = collections.namedtuple('Mock', 'name')
        sqlcolumn_mock = Mock('')
        numeric = mc.hybrid_property_gncnumeric(sqlcolumn_mock, sqlcolumn_mock)
        with pytest.raises(TypeError) as excinfo:
            numeric.fset(None, 4020.19)
        assert ("Received a floating-point number 4020.19 where a decimal is expected. " +
                "Use a Decimal, str, or int instead") == str(excinfo.value)
github sdementen / piecash / tests / test_model_common.py View on Github external
def test_weird_type_in_gncnumeric(self):
        Mock = collections.namedtuple('Mock', 'name')
        sqlcolumn_mock = Mock('')
        numeric = mc.hybrid_property_gncnumeric(sqlcolumn_mock, sqlcolumn_mock)
        with pytest.raises(TypeError) as excinfo:
            numeric.fset(None, dict())
        assert ("Received an unknown type dict where a decimal is expected. " +
                "Use a Decimal, str, or int instead") == str(excinfo.value)
github sdementen / piecash / piecash / business / invoice.py View on Github external
_i_discount_denom = Column('i_discount_denom', BIGINT())
    _i_discount_denom_basis = None
    i_discount = hybrid_property_gncnumeric(_i_discount_num, _i_discount_denom)

    invoice_guid = Column('invoice', VARCHAR(length=32), ForeignKey("invoices.guid"))
    i_disc_type = Column('i_disc_type', VARCHAR(length=2048))
    i_disc_how = Column('i_disc_how', VARCHAR(length=2048))
    i_taxable = Column('i_taxable', INTEGER())
    i_taxincluded = Column('i_taxincluded', INTEGER())
    i_taxtable = Column('i_taxtable', VARCHAR(length=32))

    b_acct = Column('b_acct', VARCHAR(length=32))
    _b_price_num = Column('b_price_num', BIGINT())
    _b_price_denom = Column('b_price_denom', BIGINT())
    _b_price_denom_basis = None
    b_price = hybrid_property_gncnumeric(_b_price_num, _b_price_denom)
    bill = Column('bill', VARCHAR(length=32))
    b_taxable = Column('b_taxable', INTEGER())
    b_taxincluded = Column('b_taxincluded', INTEGER())
    b_taxtable = Column('b_taxtable', VARCHAR(length=32))
    b_paytype = Column('b_paytype', INTEGER())
    billable = Column('billable', INTEGER())
    billto_type = Column('billto_type', INTEGER())
    billto_guid = Column('billto_guid', VARCHAR(length=32))
    order_guid = Column('order_guid', VARCHAR(length=32), ForeignKey("orders.guid"))

    # relation definitions
    order = relation('Order', back_populates="entries")
    invoice = relation('Invoice', back_populates="entries")

    def __unirepr__(self):
        return "Entry<{}>".format(self.description)
github sdementen / piecash / piecash / business / person.py View on Github external
__tablename__ = 'employees'

    __table_args__ = {}

    # column definitions
    name = Column('username', VARCHAR(length=2048), nullable=False)
    # id is nullable as it is set during validation (happening after flush)
    language = Column('language', VARCHAR(length=2048), nullable=False)
    acl = Column('acl', VARCHAR(length=2048), nullable=False)
    ccard_guid = Column('ccard_guid', VARCHAR(length=32), ForeignKey('accounts.guid'))
    _workday_num = Column('workday_num', BIGINT(), nullable=False)
    _workday_denom = Column('workday_denom', BIGINT(), nullable=False)
    workday = hybrid_property_gncnumeric(_workday_num, _workday_denom)
    _rate_num = Column('rate_num', BIGINT(), nullable=False)
    _rate_denom = Column('rate_denom', BIGINT(), nullable=False)
    rate = hybrid_property_gncnumeric(_rate_num, _rate_denom)

    # relation definitions
    creditcard_account = relation('Account')

    def __init__(self,
                 name,
                 currency,
                 creditcard_account=None,
                 id=None,
                 active=1,
                 acl="",
                 language="",
                 workday=Decimal(0),
                 rate=Decimal(0),
                 address=None,
                 book=None):
github sdementen / piecash / piecash / business / person.py View on Github external
term (:class:`piecash.business.invoice.Billterm`): bill term of the customer
    """
    __tablename__ = 'customers'

    __table_args__ = {}

    # column definitions
    name = Column('name', VARCHAR(length=2048), nullable=False)
    # id is nullable as it is set during validation (happening after flush)
    notes = Column('notes', VARCHAR(length=2048), nullable=False)
    _discount_num = Column('discount_num', BIGINT(), nullable=False)
    _discount_denom = Column('discount_denom', BIGINT(), nullable=False)
    discount = hybrid_property_gncnumeric(_discount_num, _discount_denom)
    _credit_num = Column('credit_num', BIGINT(), nullable=False)
    _credit_denom = Column('credit_denom', BIGINT(), nullable=False)
    credit = hybrid_property_gncnumeric(_credit_num, _credit_denom)
    tax_override = Column('tax_override', INTEGER(), nullable=False)

    shipaddr_name = Column('shipaddr_name', VARCHAR(length=1024))
    shipaddr_addr1 = Column('shipaddr_addr1', VARCHAR(length=1024))
    shipaddr_addr2 = Column('shipaddr_addr2', VARCHAR(length=1024))
    shipaddr_addr3 = Column('shipaddr_addr3', VARCHAR(length=1024))
    shipaddr_addr4 = Column('shipaddr_addr4', VARCHAR(length=1024))
    shipaddr_phone = Column('shipaddr_phone', VARCHAR(length=128))
    shipaddr_fax = Column('shipaddr_fax', VARCHAR(length=128))
    shipaddr_email = Column('shipaddr_email', VARCHAR(length=256))
    shipping_address = composite(Address, shipaddr_name, shipaddr_addr1, shipaddr_addr2, shipaddr_addr3, shipaddr_addr4,
                                 shipaddr_email, shipaddr_fax, shipaddr_phone)

    term_guid = Column('terms', VARCHAR(length=32), ForeignKey('billterms.guid'))
    tax_included = Column('tax_included', ChoiceType(TaxIncludedType))
    taxtable_guid = Column('taxtable', VARCHAR(length=32), ForeignKey('taxtables.guid'))
github sdementen / piecash / piecash / business / invoice.py View on Github external
__table_args__ = {}

    # column definitions
    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), nullable=False)
    refcount = Column('refcount', INTEGER(), nullable=False)
    invisible = Column('invisible', INTEGER(), nullable=False)
    parent_guid = Column('parent', VARCHAR(length=32), ForeignKey('billterms.guid'))
    type = Column('type', VARCHAR(length=2048), nullable=False)
    duedays = Column('duedays', INTEGER())
    discountdays = Column('discountdays', INTEGER())
    _discount_num = Column('discount_num', BIGINT())
    _discount_denom = Column('discount_denom', BIGINT())
    discount = hybrid_property_gncnumeric(_discount_num, _discount_denom)
    cutoff = Column('cutoff', INTEGER())

    # relation definitions
    children = relation('Billterm',
                        back_populates='parent',
                        cascade='all, delete-orphan',
                        collection_class=CallableList,
                        )
    parent = relation('Billterm',
                      back_populates='children',
                      remote_side=guid,
                      )


class Entry(DeclarativeBaseGuid):
    __tablename__ = 'entries'
github sdementen / piecash / piecash / business / invoice.py View on Github external
owner_guid = Column('owner_guid', VARCHAR(length=32))

    # owner = generic_relationship(owner_type, owner_guid,
    #                              map_type2discriminator={"Customer": 2,
    #                                                      "Vendor": 1,
    #                                                      })
    term_guid = Column('terms', VARCHAR(length=32), ForeignKey('billterms.guid'))
    billing_id = Column('billing_id', VARCHAR(length=2048))
    post_txn_guid = Column('post_txn', VARCHAR(length=32), ForeignKey('lots.guid'))
    post_lot_guid = Column('post_lot', VARCHAR(length=32), ForeignKey('transactions.guid'))
    post_acc_guid = Column('post_acc', VARCHAR(length=32), ForeignKey('accounts.guid'))
    billto_type = Column('billto_type', INTEGER())
    billto_guid = Column('billto_guid', VARCHAR(length=32))
    _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):
github sdementen / piecash / piecash / business / person.py View on Github external
shipping_address (:class:`Address`): the shipping address of the customer
        tax_included (str): 'yes', 'no', 'use global'
        taxtable (:class:`piecash.business.tax.TaxTable`): tax table of the customer
        term (:class:`piecash.business.invoice.Billterm`): bill term of the customer
    """
    __tablename__ = 'customers'

    __table_args__ = {}

    # column definitions
    name = Column('name', VARCHAR(length=2048), nullable=False)
    # id is nullable as it is set during validation (happening after flush)
    notes = Column('notes', VARCHAR(length=2048), nullable=False)
    _discount_num = Column('discount_num', BIGINT(), nullable=False)
    _discount_denom = Column('discount_denom', BIGINT(), nullable=False)
    discount = hybrid_property_gncnumeric(_discount_num, _discount_denom)
    _credit_num = Column('credit_num', BIGINT(), nullable=False)
    _credit_denom = Column('credit_denom', BIGINT(), nullable=False)
    credit = hybrid_property_gncnumeric(_credit_num, _credit_denom)
    tax_override = Column('tax_override', INTEGER(), nullable=False)

    shipaddr_name = Column('shipaddr_name', VARCHAR(length=1024))
    shipaddr_addr1 = Column('shipaddr_addr1', VARCHAR(length=1024))
    shipaddr_addr2 = Column('shipaddr_addr2', VARCHAR(length=1024))
    shipaddr_addr3 = Column('shipaddr_addr3', VARCHAR(length=1024))
    shipaddr_addr4 = Column('shipaddr_addr4', VARCHAR(length=1024))
    shipaddr_phone = Column('shipaddr_phone', VARCHAR(length=128))
    shipaddr_fax = Column('shipaddr_fax', VARCHAR(length=128))
    shipaddr_email = Column('shipaddr_email', VARCHAR(length=256))
    shipping_address = composite(Address, shipaddr_name, shipaddr_addr1, shipaddr_addr2, shipaddr_addr3, shipaddr_addr4,
                                 shipaddr_email, shipaddr_fax, shipaddr_phone)
github sdementen / piecash / piecash / business / invoice.py View on Github external
# column definitions
    date = Column('date', _DateTime(), nullable=False)
    date_entered = Column('date_entered', _DateTime())
    description = Column('description', VARCHAR(length=2048))
    action = Column('action', VARCHAR(length=2048))
    notes = Column('notes', VARCHAR(length=2048))
    _quantity_num = Column('quantity_num', BIGINT())
    _quantity_denom = Column('quantity_denom', BIGINT())
    _quantity_denom_basis = None
    quantity = hybrid_property_gncnumeric(_quantity_num, _quantity_denom)

    i_acct = Column('i_acct', VARCHAR(length=32))
    _i_price_num = Column('i_price_num', BIGINT())
    _i_price_denom = Column('i_price_denom', BIGINT())
    _i_price_denom_basis = None
    i_price = hybrid_property_gncnumeric(_i_price_num, _i_price_denom)

    _i_discount_num = Column('i_discount_num', BIGINT())
    _i_discount_denom = Column('i_discount_denom', BIGINT())
    _i_discount_denom_basis = None
    i_discount = hybrid_property_gncnumeric(_i_discount_num, _i_discount_denom)

    invoice_guid = Column('invoice', VARCHAR(length=32), ForeignKey("invoices.guid"))
    i_disc_type = Column('i_disc_type', VARCHAR(length=2048))
    i_disc_how = Column('i_disc_how', VARCHAR(length=2048))
    i_taxable = Column('i_taxable', INTEGER())
    i_taxincluded = Column('i_taxincluded', INTEGER())
    i_taxtable = Column('i_taxtable', VARCHAR(length=32))

    b_acct = Column('b_acct', VARCHAR(length=32))
    _b_price_num = Column('b_price_num', BIGINT())
    _b_price_denom = Column('b_price_denom', BIGINT())