Files
ksef_app/tests/test_nfz.py
Mateusz Gruszczyński 35571df778 push
2026-03-13 11:03:13 +01:00

36 lines
1.7 KiB
Python

from decimal import Decimal
from app.extensions import db
from app.models.catalog import Customer, Product
from app.models.company import Company
from app.models.setting import AppSetting
def test_nfz_index_loads_with_module_enabled(auth_client, app):
with app.app_context():
company = Company.query.first()
AppSetting.set(f'company.{company.id}.modules.nfz_enabled', 'true')
db.session.add(Customer(company_id=company.id, name='NFZ Client', tax_id='1070001057', is_active=True))
db.session.add(Product(company_id=company.id, name='Swiadczenie', unit='usl', net_price=Decimal('100.00'), vat_rate=Decimal('8.00'), is_active=True))
db.session.commit()
response = auth_client.get('/nfz/')
assert response.status_code == 200
assert b'NFZ' in response.data
def test_nfz_index_uses_shared_quick_add_modals(auth_client, app):
with app.app_context():
company = Company.query.first()
AppSetting.set(f'company.{company.id}.modules.nfz_enabled', 'true')
if not Customer.query.filter_by(company_id=company.id, name='NFZ Modal Client').first():
db.session.add(Customer(company_id=company.id, name='NFZ Modal Client', tax_id='1070001057', is_active=True))
if not Product.query.filter_by(company_id=company.id, name='NFZ Modal Service').first():
db.session.add(Product(company_id=company.id, name='NFZ Modal Service', unit='usl', net_price=Decimal('50.00'), vat_rate=Decimal('8.00'), is_active=True))
db.session.commit()
response = auth_client.get('/nfz/')
assert response.status_code == 200
assert b'customerQuickAddModal' in response.data
assert b'productQuickAddModal' in response.data
assert b'Szybkie dodanie klienta' not in response.data