How to use the kiwi.currency.currency function in kiwi

To help you get started, we’ve selected a few kiwi 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 / kiwi / tests / test_datatypes.py View on Github external
def testPickleUS(self):
        if not set_locale(locale.LC_ALL, 'en_US'):
            return

        pickled_var = pickle.dumps(currency("12123.45"))
        recoverd_var = pickle.loads(pickled_var)
        self.assertEqual(recoverd_var.format(), '$12,123.45')
github stoq / stoq / stoq / gui / till.py View on Github external
def _update_total(self):
        balance = currency(self._get_till_balance())
        text = _(u"Total: %s") % converter.as_string(currency, balance)
        self.total_label.set_text(text)
github stoq / stoq / stoqlib / domain / till.py View on Github external
def get_credits_total(self):
        """Calculates the total credit for all entries in this till
        :returns: total credit
        :rtype: currency
        """
        results = self.store.find(
            TillEntry, And(TillEntry.value > 0,
                           TillEntry.till_id == self.id))
        return currency(results.sum(TillEntry.value) or 0)
github stoq / stoq / stoqlib / exporters / xlsexporter.py View on Github external
def set_column_types(self, column_types):
        css = []
        for i, column_type in enumerate(column_types):
            if column_type in (datetime.datetime, datetime.date):
                style = self._style_date
            elif column_type in [int, float, currency]:
                style = self._style_number
            else:
                style = self._style_general
            css.append(style)

        self._column_styles = css
        self._n_columns = len(column_types)
github stoq / stoq / stoqlib / gui / wizards / purchasequotewizard.py View on Github external
def _get_columns(self):
        return [Column('selected', title=" ", data_type=bool, editable=True),
                Column('description', title=_('Description'), data_type=str,
                       expand=True, sorted=True),
                Column('supplier', title=_('Supplier'), data_type=str,
                       expand=True),
                Column('quantity', title=_(u'Quantity'), data_type=Decimal),
                Column('ordered_quantity', title=_(u'Ordered'),
                       data_type=Decimal),
                Column('cost', title=_(u'Cost'), data_type=currency,
                       format_func=get_formatted_cost)]
github stoq / stoq / stoqlib / gui / slaves / paymentconfirmslave.py View on Github external
def get_calculated_interest(self, pay_penalty):
        return currency(sum(p.get_interest(self.close_date,
                                           pay_penalty=self.pay_penalty)
                            for p in self.payments))
github stoq / kiwi / kiwi / currency.py View on Github external
def format_price(value, symbol=True, precision=None):
    """
    Formats a price according to the current locales monetary
    settings

    :param value: number
    :param symbol: whether to include the currency symbol
    """

    return currency(value).format(symbol, precision)
github stoq / stoq / stoqlib / gui / dialogs / paymentdetails.py View on Github external
def _get_penalty(self):
        penalty = (self.model.paid_value -
                  (self.model.value - self.model.discount + self.model.interest))

        return currency(penalty)
github stoq / stoq / stoqlib / gui / search / sellablesearch.py View on Github external
SearchColumn('category_description', title=_('Category'),
                                data_type=str, width=120),
                   SearchColumn('description', title=_('Description'),
                                data_type=str, expand=True, sorted=True),
                   SearchColumn('location', title=_('Location'),
                                data_type=str, visible=False),
                   SearchColumn('manufacturer', title=_('Manufacturer'),
                                data_type=str, visible=False),
                   SearchColumn('model', title=_('Model'),
                                data_type=str, visible=False)]

        user = api.get_current_user(self.store)
        if user.profile.check_app_permission('purchase'):
            columns.append(SearchColumn('cost',
                                        title=_(u'Cost'),
                                        data_type=currency, visible=True))

        if hasattr(self.search_spec, 'price'):
            columns.append(SearchColumn('price',
                                        title=_(u'Price'),
                                        data_type=currency, visible=True))

        if hasattr(self.search_spec, 'minimum_quantity'):
            columns.append(SearchColumn('minimum_quantity',
                                        title=_(u'Minimum Qty'),
                                        data_type=Decimal, visible=False))

        if hasattr(self.search_spec, 'stock'):
            columns.append(QuantityColumn('stock', title=_(u'In Stock')))

        return columns
github stoq / stoq / stoqlib / domain / returnedsale.py View on Github external
def total_amount(self):
        """The total amount for this return

        See :meth:`.return_` for details of how this is used.
        """
        return currency(self.sale_total -
                        self.paid_total -
                        self.returned_total)