from decimal import Decimal as D

from django.utils.translation import gettext_lazy as _


class ShippingCostLineWrapper:
    """
    Wrapper object so we can show shipping costs in the order lines report as well.
    """

    def __init__(self, order):
        self.order_ = order

    @property
    def product(self):
        return None

    @property
    def title(self):
        return self.order_.shipping_method

    @property
    def order(self):
        return self.order_

    @property
    def quantity(self):
        return 1

    @property
    def unit_price_excl_tax(self):
        return self.order_.shipping_excl_tax

    @property
    def unit_price_incl_tax(self):
        return self.order_.shipping_incl_tax

    @property
    def line_price_tax(self):
        return self.order_.shipping_tax

    @property
    def line_price_excl_tax(self):
        return self.order_.shipping_excl_tax

    @property
    def line_price_incl_tax(self):
        return self.order_.shipping_incl_tax


class DiscountLineWrapper:
    """
    Wrapper object so we can show discount costs in the order lines report as well.
    """

    def __init__(self, order):
        self.order_ = order

    @property
    def product(self):
        return None

    @property
    def title(self):
        return _("Total discount #%(order_number)s") % {
            "order_number": self.order_.number
        }

    @property
    def order(self):
        return self.order_

    @property
    def quantity(self):
        return 1

    @property
    def unit_price_excl_tax(self):
        return self.order_.total_discount_excl_tax

    @property
    def unit_price_incl_tax(self):
        return self.order_.total_discount_incl_tax

    @property
    def line_price_tax(self):
        return D("0.00")

    @property
    def line_price_excl_tax(self):
        return self.order_.total_discount_excl_tax

    @property
    def line_price_incl_tax(self):
        return self.order_.total_discount_incl_tax


class SurchargeLineWrapper:
    """
    Wrapper object so we can show surcharge costs in the order lines report as well.
    """

    def __init__(self, order, surcharge):
        self.order_ = order
        self.surcharge = surcharge

    @property
    def product(self):
        return None

    @property
    def title(self):
        return self.surcharge.name

    @property
    def order(self):
        return self.order_

    @property
    def quantity(self):
        return 1

    @property
    def unit_price_excl_tax(self):
        return self.surcharge.excl_tax

    @property
    def unit_price_incl_tax(self):
        return self.surcharge.incl_tax

    @property
    def line_price_tax(self):
        return self.surcharge.incl_tax - self.surcharge.excl_tax

    @property
    def line_price_excl_tax(self):
        return self.surcharge.excl_tax

    @property
    def line_price_incl_tax(self):
        return self.surcharge.incl_tax
