Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 25.5% tax percentages (STAM-10) #179

Merged
merged 3 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions payments/migrations/0008_add_new_tax_percentage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 2.2.11 on 2024-08-17 13:04

from decimal import Decimal
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('payments', '0007_add_invoice_model'),
]

operations = [
migrations.AlterField(
model_name='orderline',
name='tax_percentage',
field=models.DecimalField(choices=[(Decimal('0.00'), '0.00'), (Decimal('10.00'), '10.00'), (Decimal('14.00'), '14.00'), (Decimal('24.00'), '24.00'), (Decimal('25.50'), '25.50')], decimal_places=2, default=Decimal('25.50'), max_digits=5, verbose_name='tax percentage'),
),
migrations.AlterField(
model_name='sapmaterialcode',
name='tax_percentage',
field=models.DecimalField(choices=[(Decimal('0.00'), '0.00'), (Decimal('10.00'), '10.00'), (Decimal('14.00'), '14.00'), (Decimal('24.00'), '24.00'), (Decimal('25.50'), '25.50')], decimal_places=2, default=Decimal('25.50'), max_digits=5, verbose_name='tax percentage'),
),
]
3 changes: 2 additions & 1 deletion payments/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@
"10.00",
"14.00",
"24.00",
"25.50",
)
]

DEFAULT_TAX_PERCENTAGE = Decimal("24.00")
DEFAULT_TAX_PERCENTAGE = Decimal("25.50")
PRICE_PER_PERIOD = "per_period"
PRICE_FIXED = "fixed"
PRICE_TYPE_CHOICES = (
Expand Down
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
24 changes: 24 additions & 0 deletions respa_pricing/migrations/0008_add_new_tax_percentage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 2.2.11 on 2024-08-17 15:15

from decimal import Decimal
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('respa_pricing', '0007_auto_20231218_1250'),
]

operations = [
migrations.AlterField(
model_name='eventtype',
name='tax_percentage',
field=models.DecimalField(choices=[(Decimal('0.00'), '0.00'), (Decimal('10.00'), '10.00'), (Decimal('14.00'), '14.00'), (Decimal('24.00'), '24.00'), (Decimal('25.50'), '25.50')], decimal_places=2, default=Decimal('25.50'), max_digits=5, verbose_name='tax percentage'),
),
migrations.AlterField(
model_name='usergroup',
name='tax_percentage',
field=models.DecimalField(choices=[(Decimal('0.00'), '0.00'), (Decimal('10.00'), '10.00'), (Decimal('14.00'), '14.00'), (Decimal('24.00'), '24.00'), (Decimal('25.50'), '25.50')], decimal_places=2, default=Decimal('25.50'), max_digits=5, verbose_name='tax percentage'),
),
]
3 changes: 2 additions & 1 deletion respa_pricing/models/price.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@
"10.00",
"14.00",
"24.00",
"25.50",
)
]

DEFAULT_TAX_PERCENTAGE = Decimal("24.00")
DEFAULT_TAX_PERCENTAGE = Decimal("25.50")

PRICE_PER_PERIOD = "per_period"
PRICE_FIXED = "fixed"
Expand Down
Loading