How to use the sqlobject.FloatCol function in SQLObject

To help you get started, we’ve selected a few SQLObject 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 stoq / stoq / stoq / domain / payment / base.py View on Github external
STATUS_PAID:        _('Paid'),
                STATUS_REVIEWING:   _('Reviewing'),
                STATUS_CONFIRMED:   _('Confirmed'),
                STATUS_CANCELLED:   _('Cancelled')}

    # XXX The payment_id attribute will be an alternateID after 
    # fixing bug 2214
    payment_id = IntCol(default=None)
    status = IntCol(default=STATUS_PREVIEW)
    due_date = DateTimeCol()
    paid_date = DateTimeCol(default=None)
    paid_value = FloatCol(default=0.0)
    base_value = FloatCol()
    value = FloatCol()
    interest = FloatCol(default=0.0)
    discount = FloatCol(default=0.0)
    description = StringCol(default=None)
    payment_number = StringCol(default=None)

    method = ForeignKey('AbstractPaymentMethodAdapter')
    method_details = ForeignKey('PaymentMethodDetails', default=None)
    group = ForeignKey('AbstractPaymentGroup')
    destination = ForeignKey('PaymentDestination')
    

    #
    # SQLObject hooks
    #

    def _create(self, id, **kw):
        if not 'value' in kw:
            raise TypeError('You must provide a value argument')
github stoq / stoq / stoq / domain / till.py View on Github external
store after closing the till.
        - I{initial_cash_amount}: The total amount we have in the moment we
                                  are opening the till. This value is useful
                                  when providing change during sales.
        - I{branch}: a till operation is always associated with a branch 
                     which can means a store or a warehouse
    """

    (STATUS_PENDING, 
     STATUS_OPEN, 
     STATUS_CLOSED) = range(3)

    status = IntCol(default=STATUS_PENDING)
    balance_sent = FloatCol(default=None)
    initial_cash_amount = FloatCol(default=0.0)
    final_cash_amount = FloatCol(default=None)
    opening_date = DateTimeCol(default=datetime.datetime.now)
    closing_date = DateTimeCol(default=None)

    branch = ForeignKey('PersonAdaptToBranch')

    def get_balance(self):
        """ Return the total of all "extra" payments (like cash
        advance, till complement, ...) associated to this till
        operation *plus* all the payments, which payment method is
        money, of all the sales associated with this operation 
        *plus* the initial cash amount. 
        """

        conn = self.get_connection()
        result = Sale.selectBy(till=self, connection=conn)
github stoq / stoq / stoq / domain / sellable.py View on Github external
sellableitem_table = None
    (STATUS_AVAILABLE,
     STATUS_SOLD,
     STATUS_CLOSED,
     STATUS_BLOCKED) = range(4)


    statuses = {STATUS_AVAILABLE: _("Available"),
                STATUS_SOLD: _("Sold"),
                STATUS_CLOSED: _("Closed"),
                STATUS_BLOCKED: _("Blocked")}

    code = StringCol(alternateID=True, default="")
    status = IntCol(default=STATUS_AVAILABLE)
    markup = FloatCol(default=0.0)
    cost = FloatCol(default=0.0)
    unit = ForeignKey("SellableUnit", default=None)
    base_sellable_info = ForeignKey('BaseSellableInfo')
    on_sale_info = ForeignKey('OnSaleInfo')
    category = ForeignKey('SellableCategory', default=None)

    def _create(self, id, **kw):
        if not 'kw' in kw:
            conn = self.get_connection()
            if not 'on_sale_info' in kw:
                kw['on_sale_info'] = OnSaleInfo(connection=conn)
        InheritableModelAdapter._create(self, id, **kw)

    #
    # IContainer methods
    #
github stoq / stoq / stoq / domain / till.py View on Github external
financial operations can be done in this store.
        - I{balance_sent}: the amount total sent to the warehouse or main
                           store after closing the till.
        - I{initial_cash_amount}: The total amount we have in the moment we
                                  are opening the till. This value is useful
                                  when providing change during sales.
        - I{branch}: a till operation is always associated with a branch 
                     which can means a store or a warehouse
    """

    (STATUS_PENDING, 
     STATUS_OPEN, 
     STATUS_CLOSED) = range(3)

    status = IntCol(default=STATUS_PENDING)
    balance_sent = FloatCol(default=None)
    initial_cash_amount = FloatCol(default=0.0)
    final_cash_amount = FloatCol(default=None)
    opening_date = DateTimeCol(default=datetime.datetime.now)
    closing_date = DateTimeCol(default=None)

    branch = ForeignKey('PersonAdaptToBranch')

    def get_balance(self):
        """ Return the total of all "extra" payments (like cash
        advance, till complement, ...) associated to this till
        operation *plus* all the payments, which payment method is
        money, of all the sales associated with this operation 
        *plus* the initial cash amount. 
        """

        conn = self.get_connection()
github stoq / stoq / stoq / domain / payment / base.py View on Github external
STATUS_CANCELLED) = range(6)

    statuses = {STATUS_PREVIEW:     _('Preview'),
                STATUS_TO_PAY:      _('To Pay'),
                STATUS_PAID:        _('Paid'),
                STATUS_REVIEWING:   _('Reviewing'),
                STATUS_CONFIRMED:   _('Confirmed'),
                STATUS_CANCELLED:   _('Cancelled')}

    # XXX The payment_id attribute will be an alternateID after 
    # fixing bug 2214
    payment_id = IntCol(default=None)
    status = IntCol(default=STATUS_PREVIEW)
    due_date = DateTimeCol()
    paid_date = DateTimeCol(default=None)
    paid_value = FloatCol(default=0.0)
    base_value = FloatCol()
    value = FloatCol()
    interest = FloatCol(default=0.0)
    discount = FloatCol(default=0.0)
    description = StringCol(default=None)
    payment_number = StringCol(default=None)

    method = ForeignKey('AbstractPaymentMethodAdapter')
    method_details = ForeignKey('PaymentMethodDetails', default=None)
    group = ForeignKey('AbstractPaymentGroup')
    destination = ForeignKey('PaymentDestination')
    

    #
    # SQLObject hooks
    #
github mikrosimage / OpenRenderManagement / src / octopus / dispatcher / db / pulidb.py View on Github external
class PoolShares(SQLObject):
    class sqlmeta:
        lazyUpdate = True
    poolId = IntCol()
    nodeId = IntCol()
    maxRN = IntCol()
    archived = BoolCol()


class RenderNodes(SQLObject):
    class sqlmeta:
        lazyUpdate = True
    name = UnicodeCol()
    coresNumber = IntCol()
    speed = FloatCol()
    ip = UnicodeCol()
    port = IntCol()
    ramSize = IntCol()
    caracteristics = UnicodeCol()
    pools = RelatedJoin('Pools')
    performance = FloatCol()


def createTables():
    FolderNodes.createTable(ifNotExists=True)
    TaskNodes.createTable(ifNotExists=True)
    Dependencies.createTable(ifNotExists=True)
    TaskGroups.createTable(ifNotExists=True)
    Rules.createTable(ifNotExists=True)
    Tasks.createTable(ifNotExists=True)
    Commands.createTable(ifNotExists=True)
github hudora / huTools / huTools / huLint.py View on Github external
import sqlobject

DATABASE_URI = "sqlite:///Users/chris/Desktop/database.db"
MINIMUM_SCORE = 8.0


class PythonScore(sqlobject.SQLObject):
    """
    OO mapping of the score for a Python file
    """
    username = sqlobject.StringCol()
    pathname = sqlobject.StringCol()
    revision = sqlobject.StringCol()
    score = sqlobject.FloatCol()
    old_score = sqlobject.FloatCol()
    credit = sqlobject.FloatCol()
    date = sqlobject.DateTimeCol(default=sqlobject.DateTimeCol.now)


def process_file(filename):
    """
    Analyze the file with pylint and write the result
    to a database
    """
    linter = PyLinter()

    checkers.initialize(linter)
    linter.read_config_file()
    linter.quiet = 1

    filemods = linter.expand_files((filename, ))
    if filemods:
github jplusplus / rentswatch-scraper / rentswatch_scraper / db.py View on Github external
class Ad(SQLObject):
    # "listed" if needs more scraping, "scraped" if it's done
    status = StringCol(length=10, default=None)
    # Name of the website
    site = StringCol(length=30, notNull=True)
    # Date the ad was first scraped
    createdAt = DateTimeCol(default=DateTimeCol.now)
    # The unique ID from the site where it's scrapped from
    siteId = StringCol(length=100, notNull=True)
    # Extra costs (heating mostly)
    serviceCharge = FloatCol(default=None)
    serviceChargeOriginalCurrency = FloatCol(default=None)
    # Base costs (without heating)
    baseRent = FloatCol(default=None)
    baseRentOriginalCurrency = FloatCol(default=None)
    # Total cost
    totalRent = FloatCol(default=None)
    totalRentOriginalCurrency = FloatCol(default=None)
    # Country, 2 letter code
    country = StringCol(length=2, notNull=True)
    # Currency, 3 letter code
    currency = StringCol(length=3, default='EUR')
    # Surface in square meters
    livingSpace = FloatCol(default=None)
    # Price per square meter
    pricePerSqm = FloatCol(default=None)
    # True if the flat or house is furnished
    furnished = BoolCol(default=None)
    # y if realtor, n if rented by a physical person
    realtor = BoolCol(default=None)
    # The name of the realtor or person offering the flat
github stoq / stoq / stoq / domain / purchase.py View on Github external
IPaymentGroup)
from stoq.lib.parameters import sysparam

_ = gettext.gettext


class PurchaseItem(Domain):
    """This class stores information of the purchased items.
    
    B{Importante attributes}
        - I{base_cost}: the cost which helps the purchaser to define the 
                        main cost of a certain product.
    """
    quantity = FloatCol(default=1.0)
    quantity_received = FloatCol(default=0.0)
    base_cost = FloatCol()
    cost = FloatCol()
    sellable = ForeignKey('AbstractSellable')
    order = ForeignKey('PurchaseOrder')

    def _create(self, id, **kw):
        if 'base_cost' in kw:
            raise TypeError('You should not provide a base_cost'
                            'argument since it is set automatically')
        if not 'sellable' in kw:
            raise TypeError('You must provide a sellable argument')
        if not 'order' in kw:
            raise TypeError('You must provide a order argument')

        kw['base_cost'] = kw['sellable'].cost
        
        if kw['sellable'].id in [item.sellable.id
github stoq / stoq / stoq / domain / sellable.py View on Github external
return self.price * self.quantity

    def get_price_string(self):
        return get_formatted_price(self.price)


class OnSaleInfo(Domain):
    on_sale_price = FloatCol(default=0.0)
    on_sale_start_date = DateTimeCol(default=None)
    on_sale_end_date = DateTimeCol(default=None)


class BaseSellableInfo(Domain):
    implements(IDescribable)

    price = FloatCol(default=0.0)
    description = StringCol(default='')
    max_discount = FloatCol(default=0.0)
    commission = FloatCol(default=None)

    def get_commission(self):
        if self.commission is None:
            return 0.0
        return self.commission

    #
    # IDescribable implementation
    #

    def get_description(self):
        return self.description