Skip to content

Commit

Permalink
Add 25.5% tax percentage to Ceepos tax code mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
jorilindell committed Aug 19, 2024
1 parent e2e51f3 commit 7eddbce
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
2 changes: 2 additions & 0 deletions payments/providers/cpu_ceepos.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ def _get_order_line_description(order: Order) -> str:
def _get_ceepos_tax_code(order_line: OrderLine) -> str:
tax_pct = order_line.tax_percentage
ceepos_tax_codes = {
25_500_000: "255",
24_000_000: "24",
14_000_000: "14",
10_000_000: "10",
Expand All @@ -158,6 +159,7 @@ def _get_ceepos_tax_code(order_line: OrderLine) -> str:
# Tampere specific Ceepos tax codes in the production environment
if self.url_payment_api == "https://shop.tampere.fi/maksu.html":
ceepos_tax_codes = {
25_500_000: "35",
24_000_000: "15",
14_000_000: "14",
10_000_000: "13",
Expand Down
45 changes: 45 additions & 0 deletions payments/tests/test_cpu_ceepos.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import hmac
import json
from unittest import mock
from decimal import Decimal

import pytest
from django.http import HttpResponse
Expand Down Expand Up @@ -324,6 +325,50 @@ def test_payload_add_products_success(payment_provider, order_with_products):
assert "Description" in product


@pytest.mark.parametrize(
"tax_percentage,tax_code",
(
(Decimal('0'), "0"),
(Decimal('10.00'), "10"),
(Decimal('14.00'), "14"),
(Decimal('24.00'), "24"),
(Decimal('25.50'), "255"),
),
)
def test_tax_code_mapping_in_qa(payment_provider, order_with_products, tax_percentage, tax_code):
"""Test the tax percentage is mapped to a correct code in qa environment"""
payload = {}

order_with_products.order_lines.all().update(tax_percentage=tax_percentage)
payment_provider.payload_add_products(payload, order_with_products)

for product in payload["Products"]:
assert product["Taxcode"] == tax_code


@pytest.mark.parametrize(
"tax_percentage,tax_code",
(
(Decimal('0'), "18"),
(Decimal('10.00'), "13"),
(Decimal('14.00'), "14"),
(Decimal('24.00'), "15"),
(Decimal('25.50'), "35"),
),
)
def test_tax_code_mapping_in_production(provider_base_config, order_with_products, tax_percentage, tax_code):
"""Test the tax percentage is mapped to a correct code in production environment"""
provider_base_config["RESPA_PAYMENTS_CEEPOS_API_URL"] = "https://shop.tampere.fi/maksu.html"
payment_provider = CPUCeeposProvider(config=provider_base_config)
payload = {}

order_with_products.order_lines.all().update(tax_percentage=tax_percentage)
payment_provider.payload_add_products(payload, order_with_products)

for product in payload["Products"]:
assert product["Taxcode"] == tax_code


def test_payload_add_customer_success(payment_provider, order_with_products):
"""Test the customer data from order is added correctly into payload"""
payload = {}
Expand Down

0 comments on commit 7eddbce

Please sign in to comment.