Skip to content

Commit

Permalink
Merge pull request #30 from iconfinder/fix/ebook-rates
Browse files Browse the repository at this point in the history
Update e-book rates
  • Loading branch information
JanmanX authored Oct 5, 2020
2 parents 02625ab + fbab748 commit 85b87c0
Show file tree
Hide file tree
Showing 2 changed files with 137 additions and 24 deletions.
135 changes: 124 additions & 11 deletions pyvat/vat_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,118 @@ class AtVatRules(EuVatRulesMixin):
def get_vat_rate(self, item_type):
if item_type == ItemType.prepaid_broadcasting_service:
return Decimal(10)
elif item_type == ItemType.ebook:
return Decimal(10)
return Decimal(20)


class CzVatRules(ConstantEuVatRateRules):
"""VAT rules for Czech Republic.
"""

def get_vat_rate(self, item_type):
if item_type == ItemType.ebook:
return Decimal(10)

return super(CzVatRules, self).get_vat_rate(item_type)


class BeVatRules(ConstantEuVatRateRules):
"""VAT rules for Belgium.
"""

def get_vat_rate(self, item_type):
if item_type == ItemType.ebook:
return Decimal(6)

return super(BeVatRules, self).get_vat_rate(item_type)


class IeVatRules(ConstantEuVatRateRules):
"""VAT rules for Ireland.
"""

def get_vat_rate(self, item_type):
if item_type == ItemType.ebook:
return Decimal(9)

return super(IeVatRules, self).get_vat_rate(item_type)


class FiVatRules(ConstantEuVatRateRules):
"""VAT rules for Finland.
"""

def get_vat_rate(self, item_type):
if item_type == ItemType.ebook:
return Decimal(10)

return super(FiVatRules, self).get_vat_rate(item_type)


class NlVatRules(ConstantEuVatRateRules):
"""VAT rules for Netherlands.
"""

def get_vat_rate(self, item_type):
if item_type == ItemType.ebook:
return Decimal(9)

return super(NlVatRules, self).get_vat_rate(item_type)


class MtVatRules(ConstantEuVatRateRules):
"""VAT rules for Malta.
"""

def get_vat_rate(self, item_type):
if item_type == ItemType.ebook:
return Decimal(5)

return super(MtVatRules, self).get_vat_rate(item_type)


class GbVatRules(ConstantEuVatRateRules):
"""VAT rules for United Kingdom.
"""

def get_vat_rate(self, item_type):
return super(GbVatRules, self).get_vat_rate(item_type)


class SeVatRules(ConstantEuVatRateRules):
"""VAT rules for Sweden.
"""

def get_vat_rate(self, item_type):
if item_type == ItemType.ebook:
return Decimal(6)

return super(SeVatRules, self).get_vat_rate(item_type)


class HrVatRules(ConstantEuVatRateRules):
"""VAT rules for Croatia.
"""

def get_vat_rate(self, item_type):
if item_type == ItemType.ebook:
return Decimal(5)

return super(HrVatRules, self).get_vat_rate(item_type)


class PtVatRules(ConstantEuVatRateRules):
"""VAT rules for Portugal.
"""

def get_vat_rate(self, item_type):
if item_type == ItemType.ebook:
return Decimal(6)

return super(PtVatRules, self).get_vat_rate(item_type)


class FrVatRules(EuVatRulesMixin):
"""VAT rules for France.
"""
Expand Down Expand Up @@ -204,6 +313,8 @@ class LuVatRules(EuVatRulesMixin):
def get_vat_rate(self, item_type):
if item_type.is_broadcasting_service:
return Decimal(3)
elif item_type == ItemType.ebook:
return Decimal(3)
return Decimal(17)


Expand All @@ -214,6 +325,8 @@ class PlVatRules(EuVatRulesMixin):
def get_vat_rate(self, item_type):
if item_type.is_broadcasting_service:
return Decimal(8)
if item_type == ItemType.ebook:
return Decimal(5)
return Decimal(23)


Expand All @@ -233,40 +346,40 @@ class DeVatRules(EuVatRulesMixin):

def get_vat_rate(self, item_type):
if item_type == ItemType.ebook:
return Decimal(5)
return Decimal(7)
return Decimal(16)


# VAT rates are based on the report from January 1st, 2017
# http://ec.europa.eu/taxation_customs/sites/taxation/files/resources/documents/taxation/vat/how_vat_works/rates/vat_rates_en.pdf
VAT_RULES = {
'AT': AtVatRules(),
'BE': ConstantEuVatRateRules(21),
'BE': BeVatRules(21),
'BG': ConstantEuVatRateRules(20),
'CY': ConstantEuVatRateRules(19),
'CZ': ConstantEuVatRateRules(21),
'CZ': CzVatRules(21),
'DE': DeVatRules(),
'DK': ConstantEuVatRateRules(25),
'EE': ConstantEuVatRateRules(20),
'EL': ElVatRules(),
'GR': ElVatRules(), # Synonymous country code for Greece
'ES': EsVatRules(),
'FI': ConstantEuVatRateRules(24),
'FI': FiVatRules(24),
'FR': FrVatRules(),
'GB': ConstantEuVatRateRules(20),
'HR': ConstantEuVatRateRules(25),
'GB': GbVatRules(20),
'HR': HrVatRules(25),
'HU': ConstantEuVatRateRules(27),
'IE': ConstantEuVatRateRules(21),
'IE': IeVatRules(21),
'IT': ConstantEuVatRateRules(22),
'LT': ConstantEuVatRateRules(21),
'LU': LuVatRules(),
'LV': ConstantEuVatRateRules(21),
'MT': ConstantEuVatRateRules(18),
'NL': ConstantEuVatRateRules(21),
'MT': MtVatRules(18),
'NL': NlVatRules(21),
'PL': PlVatRules(),
'PT': ConstantEuVatRateRules(23),
'PT': PtVatRules(23),
'RO': ConstantEuVatRateRules(19),
'SE': ConstantEuVatRateRules(25),
'SE': SeVatRules(25),
'SK': ConstantEuVatRateRules(20),
'SI': ConstantEuVatRateRules(22),
}
Expand Down
26 changes: 13 additions & 13 deletions tests/test_sale_vat_charge.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
ItemType.generic_telecommunications_service: Decimal(20),
ItemType.generic_broadcasting_service: Decimal(20),
ItemType.prepaid_broadcasting_service: Decimal(10),
ItemType.ebook: Decimal(20),
ItemType.ebook: Decimal(10),
ItemType.enewspaper: Decimal(20),
},
'BE': {
Expand All @@ -27,7 +27,7 @@
ItemType.generic_telecommunications_service: Decimal(21),
ItemType.generic_broadcasting_service: Decimal(21),
ItemType.prepaid_broadcasting_service: Decimal(21),
ItemType.ebook: Decimal(21),
ItemType.ebook: Decimal(6),
ItemType.enewspaper: Decimal(21),
},
'BG': {
Expand All @@ -54,7 +54,7 @@
ItemType.generic_telecommunications_service: Decimal(21),
ItemType.generic_broadcasting_service: Decimal(21),
ItemType.prepaid_broadcasting_service: Decimal(21),
ItemType.ebook: Decimal(21),
ItemType.ebook: Decimal(10),
ItemType.enewspaper: Decimal(21),
},
'DE': {
Expand All @@ -63,7 +63,7 @@
ItemType.generic_telecommunications_service: Decimal(16),
ItemType.generic_broadcasting_service: Decimal(16),
ItemType.prepaid_broadcasting_service: Decimal(16),
ItemType.ebook: Decimal(5),
ItemType.ebook: Decimal(7),
ItemType.enewspaper: Decimal(16),
},
'DK': {
Expand Down Expand Up @@ -99,7 +99,7 @@
ItemType.generic_telecommunications_service: Decimal(24),
ItemType.generic_broadcasting_service: Decimal(24),
ItemType.prepaid_broadcasting_service: Decimal(24),
ItemType.ebook: Decimal(24),
ItemType.ebook: Decimal(10),
ItemType.enewspaper: Decimal(24),
},
'FR': {
Expand Down Expand Up @@ -144,7 +144,7 @@
ItemType.generic_telecommunications_service: Decimal(25),
ItemType.generic_broadcasting_service: Decimal(25),
ItemType.prepaid_broadcasting_service: Decimal(25),
ItemType.ebook: Decimal(25),
ItemType.ebook: Decimal(5),
ItemType.enewspaper: Decimal(25),
},
'HU': {
Expand All @@ -162,7 +162,7 @@
ItemType.generic_telecommunications_service: Decimal(21),
ItemType.generic_broadcasting_service: Decimal(21),
ItemType.prepaid_broadcasting_service: Decimal(21),
ItemType.ebook: Decimal(21),
ItemType.ebook: Decimal(9),
ItemType.enewspaper: Decimal(21),
},
'IT': {
Expand All @@ -189,7 +189,7 @@
ItemType.generic_telecommunications_service: Decimal(17),
ItemType.generic_broadcasting_service: Decimal(3),
ItemType.prepaid_broadcasting_service: Decimal(3),
ItemType.ebook: Decimal(17),
ItemType.ebook: Decimal(3),
ItemType.enewspaper: Decimal(17),
},
'LV': {
Expand All @@ -207,7 +207,7 @@
ItemType.generic_telecommunications_service: Decimal(18),
ItemType.generic_broadcasting_service: Decimal(18),
ItemType.prepaid_broadcasting_service: Decimal(18),
ItemType.ebook: Decimal(18),
ItemType.ebook: Decimal(5),
ItemType.enewspaper: Decimal(18),
},
'NL': {
Expand All @@ -216,7 +216,7 @@
ItemType.generic_telecommunications_service: Decimal(21),
ItemType.generic_broadcasting_service: Decimal(21),
ItemType.prepaid_broadcasting_service: Decimal(21),
ItemType.ebook: Decimal(21),
ItemType.ebook: Decimal(9),
ItemType.enewspaper: Decimal(21),
},
'PL': {
Expand All @@ -225,7 +225,7 @@
ItemType.generic_telecommunications_service: Decimal(23),
ItemType.generic_broadcasting_service: Decimal(8),
ItemType.prepaid_broadcasting_service: Decimal(8),
ItemType.ebook: Decimal(23),
ItemType.ebook: Decimal(5),
ItemType.enewspaper: Decimal(23),
},
'PT': {
Expand All @@ -234,7 +234,7 @@
ItemType.generic_telecommunications_service: Decimal(23),
ItemType.generic_broadcasting_service: Decimal(23),
ItemType.prepaid_broadcasting_service: Decimal(23),
ItemType.ebook: Decimal(23),
ItemType.ebook: Decimal(6),
ItemType.enewspaper: Decimal(23),
},
'RO': {
Expand All @@ -252,7 +252,7 @@
ItemType.generic_telecommunications_service: Decimal(25),
ItemType.generic_broadcasting_service: Decimal(25),
ItemType.prepaid_broadcasting_service: Decimal(25),
ItemType.ebook: Decimal(25),
ItemType.ebook: Decimal(6),
ItemType.enewspaper: Decimal(25),
},
'SI': {
Expand Down

0 comments on commit 85b87c0

Please sign in to comment.