def _update_view(self):
        diff = self._get_diff_quantity()

        self.quantity.update(format_quantity(self._get_total_sum()))
        self.diff_quantity.update(format_quantity(abs(diff)))
        self.diff_quantity_lbl.set_text(
            _("Missing quantity:") if diff >= 0 else
            _("Outstanding quantity:"))

        self._append_or_update_dumb_row()
Esempio n. 2
0
    def _update_view(self):
        diff = self._get_diff_quantity()

        self.quantity.update(format_quantity(self._get_total_sum()))
        self.diff_quantity.update(format_quantity(abs(diff)))
        self.diff_quantity_lbl.set_text(
            _("Missing quantity:") if diff >= 0 else
            _("Outstanding quantity:"))

        self._append_or_update_dumb_row()
Esempio n. 3
0
    def _update_summary(self, results):
        total_quantity = reserved_quantity = total_price = 0
        for obj in results:
            total_quantity += obj.quantity
            reserved_quantity += obj.quantity_decreased
            total_price += obj.total

        self.quantity_label.set_label(_(u'Quantity: %s') %
                                      format_quantity(total_quantity))
        self.reserved_label.set_label(_(u'Delivered: %s') %
                                      format_quantity(reserved_quantity))
        self.total_label.set_label(_(u'Total: %s') %
                                   get_formatted_price(total_price))
Esempio n. 4
0
    def _update_summary(self, results):
        total_quantity = reserved_quantity = total_price = 0
        for obj in results:
            total_quantity += obj.quantity
            reserved_quantity += obj.quantity_decreased
            total_price += obj.total

        self.quantity_label.set_label(
            _(u'Quantity: %s') % format_quantity(total_quantity))
        self.reserved_label.set_label(
            _(u'Delivered: %s') % format_quantity(reserved_quantity))
        self.total_label.set_label(
            _(u'Total: %s') % get_formatted_price(total_price))
Esempio n. 5
0
File: sale.py Progetto: relsi/stoq
    def get_summary_row(self):
        total_sales = len(self._sales)
        if self._total_amount > 0:
            total_percentage = self._total_value * 100 / self._total_payment
            average_sale = self._total_amount / total_sales
        else:
            total_percentage = 0
            average_sale = 0

        sales_label = stoqlib_ngettext('%d sale', '%d sales',
                                       total_sales) % total_sales
        # TODO: Create a better way to add more lines to the summary row
        total_sales_label = get_formatted_price(self._total_amount)
        if self._sales_person:
            total_sales_label += ' (' + _("%s/sale") % (
                get_formatted_price(average_sale, )) + ')'

        summary_row = [sales_label,
                       total_sales_label,
                       get_formatted_price(self._total_payment),
                       get_formatted_percentage(total_percentage),
                       get_formatted_price(self._total_value),
                       format_quantity(self._total_sold)]
        if not self._sales_person:
            summary_row.insert(1, '')
        return summary_row
Esempio n. 6
0
 def _format_quantity(self, item, data):
     # FIXME: Why is this item sometimes None? It shouldn't ever be!
     if item is None:
         return ''
     if not item.changed:
         return ''
     return format_quantity(item.quantity)
Esempio n. 7
0
 def _format_quantity(self, item, data):
     # FIXME: Why is this item sometimes None? It shouldn't ever be!
     if item is None:
         return ''
     if not item.changed:
         return ''
     return format_quantity(item.quantity)
Esempio n. 8
0
 def test_get_quantity_received_as_string(self):
     item = self.create_purchase_order_item()
     item.quantity_received = 8
     item.sellable.unit = self.create_sellable_unit(description=u'XX')
     str = u"%s XX" % (format_quantity(item.quantity_received),)
     str_received = item.get_quantity_received_as_string()
     self.assertEquals(str, str_received)
Esempio n. 9
0
 def test_get_quantity_received_as_string(self):
     item = self.create_purchase_order_item()
     item.quantity_received = 8
     item.sellable.unit = self.create_sellable_unit(description=u'XX')
     str = u"%s XX" % (format_quantity(item.quantity_received), )
     str_received = item.get_quantity_received_as_string()
     self.assertEquals(str, str_received)
Esempio n. 10
0
File: sale.py Progetto: tmaxter/stoq
    def get_summary_row(self):
        total_sales = len(self._sales)
        if self._total_amount > 0:
            total_percentage = self._total_value * 100 / self._total_payment
            average_sale = self._total_amount / total_sales
        else:
            total_percentage = 0
            average_sale = 0

        sales_label = stoqlib_ngettext('%d sale', '%d sales',
                                       total_sales) % total_sales
        # TODO: Create a better way to add more lines to the summary row
        total_sales_label = get_formatted_price(self._total_amount)
        if self._sales_person:
            total_sales_label += ' (' + _("%s/sale") % (get_formatted_price(
                average_sale, )) + ')'

        summary_row = [
            sales_label, total_sales_label,
            get_formatted_price(self._total_payment),
            get_formatted_percentage(total_percentage),
            get_formatted_price(self._total_value),
            format_quantity(self._total_sold)
        ]
        if not self._sales_person:
            summary_row.insert(1, '')
        return summary_row
Esempio n. 11
0
    def _update_summary(self, klist):
        quantity = total = 0
        for obj in klist:
            quantity += obj.quantity
            total += obj.total_sold

        self.quantity_label.set_label(_(u'Total quantity: %s') % format_quantity(quantity))
        self.total_sold_label.set_label(_(u'Total sold: %s') % get_formatted_cost(total))
Esempio n. 12
0
File: sale.py Progetto: relsi/stoq
 def get_row(self, obj):
     data = [unicode(obj.identifier),
             get_formatted_price(obj.total_amount),
             get_formatted_price(obj.payment_amount),
             get_formatted_percentage(obj.commission_percentage),
             get_formatted_price(obj.commission_value),
             format_quantity(obj.quantity_sold)]
     if not self._sales_person:
         data.insert(1, obj.salesperson_name)
     return data
Esempio n. 13
0
    def _update_summary(self, klist):
        quantity = total = 0
        for obj in klist:
            quantity += obj.quantity
            total += obj.total_sold

        self.quantity_label.set_label(
            _(u'Total quantity: %s') % format_quantity(quantity))
        self.total_sold_label.set_label(
            _(u'Total sold: %s') % get_formatted_cost(total))
Esempio n. 14
0
File: sale.py Progetto: rosalin/stoq
 def get_row(self, obj):
     data = [unicode(obj.identifier),
             get_formatted_price(obj.get_total_amount()),
             get_formatted_price(obj.get_payment_amount()),
             get_formatted_percentage(obj.commission_percentage),
             get_formatted_price(obj.commission_value),
             format_quantity(obj.quantity_sold())]
     if not self._sales_person:
         data.insert(1, obj.salesperson_name)
     return data
Esempio n. 15
0
    def _update_summary(self, results):
        total_quantity = total = 0
        for obj in results:
            total_quantity += obj.quantity
            total += obj.total

        queries, having = self.search.parse_states()
        sale_results = self.store.using(*self.search_spec.tables)
        sale_results = sale_results.find(Count(Sale.id, distinct=True))
        if queries:
            sale_results = sale_results.find(And(*queries))

        sales = sale_results.one()
        items_per_sale = total_quantity / sales if sales > 0 else 0

        self.items_label.set_label(_(u'Sales: %s') % format_quantity(sales))
        self.quantity_label.set_label(
            _(u'Quantity: %s') % format_quantity(total_quantity))
        self.items_per_sale_label.set_label(
            _(u'Items per sale: %s') % format_quantity(items_per_sale))
        self.total_label.set_label(
            _(u'Total: %s') % get_formatted_price(total))
Esempio n. 16
0
    def _update_summary(self, results):
        total_quantity = total = 0
        for obj in results:
            total_quantity += obj.quantity
            total += obj.total

        queries, having = self.search.parse_states()
        sale_results = self.store.using(*self.search_spec.tables)
        sale_results = sale_results.find(Count(Sale.id, distinct=True))
        if queries:
            sale_results = sale_results.find(And(*queries))

        sales = sale_results.one()
        items_per_sale = total_quantity / sales if sales > 0 else 0

        self.items_label.set_label(_(u'Sales: %s') %
                                   format_quantity(sales))
        self.quantity_label.set_label(_(u'Quantity: %s') %
                                      format_quantity(total_quantity))
        self.items_per_sale_label.set_label(_(u'Items per sale: %s') %
                                            format_quantity(items_per_sale))
        self.total_label.set_label(_(u'Total: %s') %
                                   get_formatted_price(total))
Esempio n. 17
0
    def _format_func(self, obj, data):
        quantity = getattr(obj, self.attribute) or 0
        quantity_str = format_quantity(quantity)

        sellable = getattr(obj, 'sellable', None)
        product = getattr(obj, 'product', None)

        # If the product does not manage stock and the quantity is 0, show an
        # infinite symbol istead
        if product and not product.manage_stock and not quantity:
            return u"\u221E"

        if sellable and sellable.unit:
            unit_desc = obj.sellable.unit.description
        elif hasattr(obj, 'unit'):
            unit_desc = obj.unit or ''
        else:
            unit_desc = ''

        data = '%s %s' % (quantity_str, unit_desc)
        return data.strip()
Esempio n. 18
0
    def _format_func(self, obj, data):
        quantity = getattr(obj, self.attribute) or 0
        quantity_str = format_quantity(quantity)

        sellable = getattr(obj, 'sellable', None)
        product = getattr(obj, 'product', None)

        # If the product does not manage stock and the quantity is 0, show an
        # infinite symbol istead
        if product and not product.manage_stock and not quantity:
            return u"\u221E"

        if sellable and sellable.unit:
            unit_desc = obj.sellable.unit.description
        elif hasattr(obj, 'unit'):
            unit_desc = obj.unit or ''
        else:
            unit_desc = ''

        data = '%s %s' % (quantity_str, unit_desc)
        return data.strip()
Esempio n. 19
0
    def _format_func(self, obj, data):
        quantity = getattr(obj, self.attribute) or 0
        quantity_str = format_quantity(quantity)

        # The object must have a sellable and a product for this to work
        # properly. If not, just return the quantity. Dont use
        # sellable.product here to avoid to many queries
        sellable = getattr(obj, 'sellable', None)
        product = getattr(obj, 'product', None)
        if not sellable or not product:
            return quantity_str

        # If the product does not manage stock and the quantity is 0, show an
        # infinite symbol istead
        if not product.manage_stock and not quantity:
            return u"\u221E"

        if sellable.unit:
            unit_desc = obj.sellable.unit.description
        else:
            unit_desc = ''

        data = '%s %s' % (quantity_str, unit_desc)
        return data.strip()
Esempio n. 20
0
    def _format_func(self, obj, data):
        quantity = getattr(obj, self.attribute) or 0
        quantity_str = format_quantity(quantity)

        # The object must have a sellable and a product for this to work
        # properly. If not, just return the quantity. Dont use
        # sellable.product here to avoid to many queries
        sellable = getattr(obj, 'sellable', None)
        product = getattr(obj, 'product', None)
        if not sellable or not product:
            return quantity_str

        # If the product does not manage stock and the quantity is 0, show an
        # infinite symbol istead
        if not product.manage_stock and not quantity:
            return u"\u221E"

        if sellable.unit:
            unit_desc = obj.sellable.unit.description
        else:
            unit_desc = ''

        data = '%s %s' % (quantity_str, unit_desc)
        return data.strip()
Esempio n. 21
0
 def _format_qty(self, quantity):
     if quantity is ValueUnset:
         return None
     if quantity >= 0:
         return format_quantity(quantity)
Esempio n. 22
0
 def get_quantity_received_as_string(self):
     unit = self.sellable.unit
     return u"%s %s" % (format_quantity(self.quantity_received),
                        unit and unit.description or u"")
Esempio n. 23
0
 def get_quantity_as_string(self):
     return u"%s %s" % (format_quantity(self.quantity), self.unit or u"")
Esempio n. 24
0
 def test_get_quantity_as_string(self):
     item = self.create_purchase_order_item()
     item.sellable.unit = self.create_sellable_unit(description=u'XX')
     msg = u"%s XX" % (format_quantity(item.quantity),)
     str_quantity = item.get_quantity_as_string()
     self.assertEqual(msg, str_quantity)
Esempio n. 25
0
 def quantity_received_as_string(self):
     return u"%s %s" % (format_quantity(self.quantity_received),
                        self.unit or u"")
Esempio n. 26
0
 def quantity_received_as_string(self):
     return u"%s %s" % (format_quantity(self.quantity_received), self.unit
                        or u"")
Esempio n. 27
0
 def get_quantity_as_string(self):
     return u"%s %s" % (format_quantity(self.quantity),
                        self.unit or u"")
Esempio n. 28
0
 def get_quantity_received_as_string(self):
     unit = self.sellable.unit
     return u"%s %s" % (format_quantity(self.quantity_received),
                        unit and unit.description or u"")
Esempio n. 29
0
def format_data(data):
    # must return zero or report printed show None instead of 0
    if data is None:
        return 0
    return format_quantity(data)
Esempio n. 30
0
def format_data(data):
    # must return zero or report printed show None instead of 0
    if data is None:
        return 0
    return format_quantity(data)
Esempio n. 31
0
def format_data(data):
    # must return zero or relatory show None instead of 0
    if data is None:
        return 0
    return format_quantity(data)
Esempio n. 32
0
 def _format_qty(self, quantity):
     if quantity is ValueUnset:
         return None
     if quantity >= 0:
         return format_quantity(quantity)
Esempio n. 33
0
def test_format_quantity():
    assert formatters.format_quantity(1.69) == "1.690"