2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-18 21:15:41 +00:00

Add 'currency' option for company

- e.g. an external supplier might have a default currency
- Adds a form input which only allows selection of allowed currency codes
- Add unit testing for currency validation
This commit is contained in:
Oliver Walters
2020-11-12 11:02:10 +11:00
parent ebac06ebee
commit 1532be9c1e
7 changed files with 158 additions and 19 deletions

View File

@ -1,4 +1,5 @@
from django.test import TestCase
from django.core.exceptions import ValidationError
import os
@ -119,6 +120,30 @@ class CompanySimpleTest(TestCase):
self.assertIsNone(m3x12.get_price_info(3))
self.assertIsNotNone(m3x12.get_price_info(50))
def test_currency_validation(self):
"""
Test validation for currency selection
"""
# Create a company with a valid currency code (should pass)
company = Company.objects.create(
name='Test',
description='Toast',
currency='AUD',
)
company.full_clean()
# Create a company with an invalid currency code (should fail)
company = Company.objects.create(
name='test',
description='Toasty',
currency='XZY',
)
with self.assertRaises(ValidationError):
company.full_clean()
class ContactSimpleTest(TestCase):