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
 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
 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
    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
    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
 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
 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
 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