# -*- coding: utf-8 -*-
from django.conf import settings

from oscar.apps.partner.prices import *  # pylint: disable=W0401,W0614


class TaxedPriceBase(Base):
    exists = is_tax_known = True

    @property
    def effective_price(self):
        if settings.OSCAR_OFFERS_INCL_TAX:
            return self.incl_tax
        else:
            return self.excl_tax


class ExcludingTaxPrice(TaxedPriceBase):
    """
    Specialised version of FixedPrice that must have tax passed.  It also
    specifies that offers should use the tax-inclusive price (which is the norm
    in the UK).
    """

    def __init__(self, currency, excl_tax, tax, tax_code=None):
        self.currency = currency
        self.excl_tax = excl_tax
        self.tax = tax
        self.tax_code = tax_code

    @property
    def incl_tax(self):
        if self.excl_tax is not None:
            return self.excl_tax + self.tax

        return None


class IncludingTaxPrice(TaxedPriceBase):
    def __init__(self, currency, incl_tax, tax, tax_code=None):
        self.currency = currency
        self.incl_tax = incl_tax
        self.tax = tax
        self.tax_code = tax_code

    @property
    def excl_tax(self):
        if self.incl_tax is not None:
            return self.incl_tax - self.tax

        return None
