Ejemplo n.º 1
0
__all__ = ('convert', 'default', 'round_units', 'decompose')

from .form import *

import cbpos
logger = cbpos.get_logger(__name__)


def convert(price_in_src, src, dst):
    if price_in_src == 0:
        return 0

    if src == dst:
        return price_in_src

    logger.debug(u'Converting {} from {} to {}'.format(repr(price_in_src), src,
                                                       dst))

    price_in_dst = price_in_src * src.current_rate.reference_to_currency_ratio * dst.current_rate.currency_to_reference_ratio

    logger.debug(u'Price in {}: {}'.format(dst, repr(price_in_dst)))

    return price_in_dst


_default_cache = None


def get_default():
    global _default_cache
    if _default_cache is None:
Ejemplo n.º 2
0
from PySide import QtGui, QtCore

import cbpos

logger = cbpos.get_logger(__name__)

class InvalidPrinterFunction(ValueError):
    pass

class InvalidPrinterName(ValueError):
    pass

class PrinterManager(object):
    
    NoPrinter = -1
    
    def __init__(self):
        pass
    
    def prompt_printer(self, name, printer=None):
        """
        Opens a dialog to let the user configure a printer.
        """
        if printer is None:
            qprinter = QtGui.QPrinter()
        else:
            # TODO: On Windows (at least), the copy count is not showing in the dialog
            # and I suspect others too not to update...
            qprinter = QtGui.QPrinter(printer.qprinter)
        
        print_dialog = QtGui.QPrintDialog(qprinter)