"""Ledger Accounting Run VAT model tests.""" from ledger.models.ledger_accounting_run_vat import LedgerAccountingRunVat from tests.utils.factories import LedgerAccountingRunVatFactory def test_create_ledger_accounting_run_vat(test_app, mock_event_fixtures): """Create a Ledger Accounting Run VAT.""" LedgerAccountingRunVatFactory.create() records = LedgerAccountingRunVat.query.all() assert len(records) == 1 def test_get_by_accounting_period_id(test_app_request, mock_event_fixtures): """Test getting count of contracts by VAT category for a specific accounting_period.""" (LedgerAccountingRunVatFactory.create(accounting_run_id=1),) (LedgerAccountingRunVatFactory.create(accounting_run_id=1),) LedgerAccountingRunVatFactory.create( accounting_run_id=2, exempt_reason='Test', country_of_tax_residence='USA' ) result = LedgerAccountingRunVat.get_ledger_accounting_run_vat_overview(1) assert len(result) == 2 assert result == [(2, 'vat_applied', 'GBR'), (1, 'vat_exempt', None)] def test_get_ledger_vat_list(test_app, mock_event_fixtures): """Test getting ledger_accounting_run_vat for an accounting period id.""" entry1 = LedgerAccountingRunVatFactory.create() entry2 = LedgerAccountingRunVatFactory.create( currency_code='USD', country_of_tax_residence='USA', gross_revenue=None, net_revenue=None, distribution_fee=None, gross_vat=None, distribution_vat=None, adjusted_net_revenue=None, exempt_reason='Non-UK citizen', ) vat_exempt_params = { 'accounting_period_id': 1, 'vat_category': 'vat_exempt', 'country_code': 'USA', 'limit': 10, 'offset': 0, } vat_applied_params = { 'accounting_period_id': 1, 'vat_category': 'vat_applied', 'country_code': 'GBR', 'limit': 10, 'offset': 0, } vat_exempt_records = LedgerAccountingRunVat.get_ledger_vat_list(**vat_exempt_params) assert len(vat_exempt_records) == 1 assert vat_exempt_records[0].accounting_run_id == entry2.accounting_run_id vat_applied_records = LedgerAccountingRunVat.get_ledger_vat_list( **vat_applied_params ) assert len(vat_applied_records) == 1 assert vat_applied_records[0].accounting_run_id == entry1.accounting_run_id def test_get_ledger_vat_list_count(test_app, mock_event_fixtures): """Test to get total_count of ledger_accounting_run_vat for an accounting period id.""" LedgerAccountingRunVatFactory.create( currency_code='USD', country_of_tax_residence='USA', gross_revenue=None, net_revenue=None, distribution_fee=None, gross_vat=None, distribution_vat=None, adjusted_net_revenue=None, exempt_reason='Non-UK citizen', ) vat_exempt_params = { 'accounting_period_id': 1, 'vat_category': 'vat_exempt', 'country_code': 'USA', } vat_exempt_count = LedgerAccountingRunVat.get_ledger_vat_list_count( **vat_exempt_params ) assert vat_exempt_count == 1