Esempio n. 1
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. 2
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. 3
0
    def log_sale_discount(cls, store, sale_number, user_name, discount_value,
                          original_price, new_price):
        """
        Log the discount authorized by an user

        This will log on the event system when a user authorizes a discount
        greater than what is allowed on a sale

        :param store: a store
        :param sale_number: the sale's id that the discount was applied
        :param user_name: the user that authorized the discount
        :param discount_value: the percentage of discount applied
        :param original_price: the original price of product
        :param new_price: the price of product after discount
        """

        description = _(u"sale {sale_number}: User {user_name} authorized "
                        u"{discount_value} of discount changing the value from "
                        u"{original_price} to {new_price}.").format(
            sale_number=sale_number,
            user_name=user_name,
            discount_value=get_formatted_percentage(discount_value),
            original_price=get_formatted_price(original_price, symbol=True),
            new_price=get_formatted_price(new_price, symbol=True))

        cls(event_type=cls.TYPE_SALE,
            description=description,
            store=store)
Esempio n. 4
0
    def log_sale_discount(cls, store, sale_number, user_name, discount_value,
                          original_price, new_price):
        """
        Log the discount authorized by an user

        This will log on the event system when a user authorizes a discount
        greater than what is allowed on a sale

        :param store: a store
        :param sale_number: the sale's id that the discount was applied
        :param user_name: the user that authorized the discount
        :param discount_value: the percentage of discount applied
        :param original_price: the original price of product
        :param new_price: the price of product after discount
        """

        description = _(
            u"sale {sale_number}: User {user_name} authorized "
            u"{discount_value} of discount changing the value from "
            u"{original_price} to {new_price}.").format(
                sale_number=sale_number,
                user_name=user_name,
                discount_value=get_formatted_percentage(discount_value),
                original_price=get_formatted_price(original_price,
                                                   symbol=True),
                new_price=get_formatted_price(new_price, symbol=True))

        cls(event_type=cls.TYPE_SALE, description=description, store=store)
Esempio n. 5
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. 6
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