add projekt cpn support
This commit is contained in:
@@ -128,3 +128,38 @@ def test_migration_runner_creates_registry_without_legacy_migrations(tmp_path):
|
||||
assert migrate_database() == []
|
||||
assert "schema_migration" in inspect(db.engine).get_table_names()
|
||||
assert migrate_database() == []
|
||||
|
||||
def test_global_vat_override_changes_50_percent_deduction(tmp_path):
|
||||
from decimal import Decimal
|
||||
from datetime import date
|
||||
from app.extensions import db
|
||||
from app.models import AppSetting
|
||||
from app.vat import effective_vat_rate
|
||||
|
||||
app = make_app(tmp_path, "global-vat.db")
|
||||
with app.app_context():
|
||||
for key, value in {
|
||||
"global_vat_override_enabled": "1",
|
||||
"global_vat_override_name": "CPN",
|
||||
"global_vat_override_rate": "8",
|
||||
"global_vat_override_start": "2026-07-01",
|
||||
"global_vat_override_end": "2026-07-31",
|
||||
}.items():
|
||||
db.session.merge(AppSetting(key=key, value=value))
|
||||
db.session.commit()
|
||||
rate = effective_vat_rate(Decimal("23"), date(2026, 7, 15))
|
||||
result = calculate_costs(Decimal("108"), rate, 50)
|
||||
assert rate == Decimal("8")
|
||||
assert result["net"] == Decimal("100.00")
|
||||
assert result["vat"] == Decimal("8.00")
|
||||
assert result["deductible_vat"] == Decimal("4.00")
|
||||
assert effective_vat_rate(Decimal("23"), date(2026, 8, 1)) == Decimal("23")
|
||||
|
||||
|
||||
def test_only_admin_can_change_global_vat(tmp_path):
|
||||
app = make_app(tmp_path, "global-vat-auth.db")
|
||||
client = app.test_client()
|
||||
client.post('/login', data={'email':'admin@example.com','password':'admin123!'})
|
||||
response = client.post('/admin/global-vat', data={'enabled':'on','name':'CPN','rate':'8','start':'2026-07-01','end':'2026-07-31'}, headers={'X-Requested-With':'XMLHttpRequest'})
|
||||
assert response.status_code == 200
|
||||
assert response.json['ok'] is True
|
||||
|
||||
Reference in New Issue
Block a user