Esempio n. 1
0
    def total_price_central_delivery(self):
        prices = []
        for item in self.items.all():
            if item.is_central_logistic_delivery:
                prices.append(item.price.netto)

        return round_float(sum(prices))
Esempio n. 2
0
    def total_price_central_delivery(self) -> Decimal:
        prices = []
        for item in self.cart_items:
            if item.is_central_logistic_delivery:
                prices.append(item.price.netto)

        return round_float(sum(prices))
Esempio n. 3
0
    def price_gross(self) -> float:
        gross = Decimal("0")
        items = sorted(self.calc_items, key=lambda item: item.seller)
        for seller_id, items in itertools.groupby(items,
                                                  lambda item: item.seller):
            gross_per_seller = self.calculate_gross_value_of_items(items)
            gross += gross_per_seller

        return round_float(gross)
Esempio n. 4
0
    def total_price_traidoo_delivery_or_third_party_delivery(self):
        prices = []

        for item in self.items.all():
            if (item.is_seller_delivery and item.product.third_party_delivery
                    and item.is_third_party_delivery):
                prices.append(item.price.netto)

        prices.append(self.total_price_central_delivery)

        return round_float(sum(prices))
Esempio n. 5
0
    def _vat_breakdown(self, obj):
        items_values = []
        for cart_item in obj.cart_items:
            items_values.append(cart_item.price)
            items_values.append(cart_item._delivery_fee())
            items_values.append(cart_item.buyer_platform_fee)
            items_values.append(cart_item.container_deposit)
        items_values = sorted(items_values, key=lambda item: item.vat_rate)
        vat_mounts_by_rates = {}
        for vat_rate, items_for_vat_rate in itertools.groupby(
                items_values, lambda item: item.vat_rate):
            sum_net_value = sum(value.netto for value in items_for_vat_rate)
            total_value = Value(sum_net_value, vat_rate)
            vat_mounts_by_rates[float(vat_rate)] = total_value.vat

        total_vat_amount = sum(list(vat_mounts_by_rates.values()))
        total_vat_amount = round_float(total_vat_amount)

        return vat_mounts_by_rates, total_vat_amount
Esempio n. 6
0
 def mangopay_fees(order_value):
     fees = 0.005 * order_value * 1.19
     return round_float(fees)
Esempio n. 7
0
 def price(self):
     total = sum(item.value.netto for item in self.calc_items)
     return round_float(total)
Esempio n. 8
0
def format_price(value):
    value = round_float(value)
    return "{:.2f}".format(value).replace(".", ",")