コード例 #1
0
 def __lt__(self, other):
     if other.currency != self.currency:
         from cbmod.currency.controllers import convert
         other_value = convert(other.value, other.currency, self.currency)
     else:
         other_value = other.value
     return self.value<other_value
コード例 #2
0
 def __lt__(self, other):
     if other.currency != self.currency:
         from cbmod.currency.controllers import convert
         other_value = convert(other.value, other.currency, self.currency)
     else:
         other_value = other.value
     return self.value < other_value
コード例 #3
0
ファイル: manager.py プロジェクト: coinbox/coinbox-mod-sales
 def update_ticket_currency(self):
     if self.ticket is not None:
         orig_c = self.currency
         for tl in self.ticket.ticketlines:
             tl.update(sell_price=currency.convert(tl.sell_price, orig_c, c))
         self.ticket.update(currency=c)
         
         self.update_taxes()
コード例 #4
0
ファイル: manager.py プロジェクト: coinbox/coinbox-mod-sales
    def update_ticket_currency(self):
        if self.ticket is not None:
            orig_c = self.currency
            for tl in self.ticket.ticketlines:
                tl.update(
                    sell_price=currency.convert(tl.sell_price, orig_c, c))
            self.ticket.update(currency=c)

            self.update_taxes()
コード例 #5
0
ファイル: manager.py プロジェクト: coinbox/coinbox-mod-sales
    def currency_display(self, value, src=None, dst=None):
        if dst is None:
            dst = self.currency

        if src is None:
            if self.ticket is None:
                return dst.format(value)

            src = self.ticket.currency

        if src == dst:
            return dst.format(value)
        else:
            return dst.format(currency.convert(value, src, dst))
コード例 #6
0
ファイル: manager.py プロジェクト: coinbox/coinbox-mod-sales
 def currency_display(self, value, src=None, dst=None):
     if dst is None:
         dst = self.currency
     
     if src is None:
         if self.ticket is None:
             return dst.format(value)
         
         src = self.ticket.currency
     
     if src == dst:
         return dst.format(value)
     else:
         return dst.format(currency.convert(value, src, dst))
コード例 #7
0
ファイル: ticket.py プロジェクト: coinbox/coinbox-mod-sales
 def add_product(self, p):
     session = cbpos.database.session()
     tls = session.query(TicketLine).filter((TicketLine.ticket_id == self.id) & \
                                            (TicketLine.product == p) & \
                                            ~TicketLine.is_edited
                                            )
     tl = tls.first()
     if tl is None:
         sell_price = currency.convert(p.price, p.currency, self.currency)
         tl = TicketLine(product=p, sell_price=sell_price)
         self.ticketlines.append(tl)
         return tl
     else:
         tl.amount = tl.amount + 1
         return tl
コード例 #8
0
ファイル: ticket.py プロジェクト: coinbox/coinbox-mod-sales
 def add_product(self, p):
     session = cbpos.database.session()
     tls = session.query(TicketLine).filter((TicketLine.ticket_id == self.id) & \
                                            (TicketLine.product == p) & \
                                            ~TicketLine.is_edited
                                            )
     tl = tls.first()
     if tl is None:
         sell_price = currency.convert(p.price, p.currency, self.currency)
         tl = TicketLine(product=p, sell_price=sell_price)
         self.ticketlines.append(tl)
         return tl
     else:
         tl.amount = tl.amount+1
         return tl
コード例 #9
0
 def debt(self):
     
     try:
         from cbmod.sales.models import TicketLine
         from cbmod.sales.models import Ticket
     except ImportError as e:
         return 0
     
     session = cbpos.database.session()
     query = session.query(func.sum(TicketLine.total), Currency) \
                          .filter((TicketLine.ticket_id == Ticket.id) & \
                                  (Ticket.customer == self) & \
                                  (Ticket.currency_id == Currency.id) & \
                                  (Ticket.payment_method == 'debt') & \
                                  ~Ticket.paid) \
                         .group_by(Ticket.currency_id)
     total = sum(currency.convert(c_total, c, self.currency) for (c_total, c) in query)
     return total
コード例 #10
0
    def debt(self):

        try:
            from cbmod.sales.models import TicketLine
            from cbmod.sales.models import Ticket
        except ImportError as e:
            return 0

        session = cbpos.database.session()
        query = session.query(func.sum(TicketLine.total), Currency) \
                             .filter((TicketLine.ticket_id == Ticket.id) & \
                                     (Ticket.customer == self) & \
                                     (Ticket.currency_id == Currency.id) & \
                                     (Ticket.payment_method == 'debt') & \
                                     ~Ticket.paid) \
                            .group_by(Ticket.currency_id)
        total = sum(
            currency.convert(c_total, c, self.currency)
            for (c_total, c) in query)
        return total