<commit_before>from django.conf import settings
from django.core.exceptions import ObjectDoesNotExist
from django.db import models
from corehq.apps.accounting.exceptions import HQAccountingSetupError
from corehq.apps.accounting.utils import EXCHANGE_RATE_DECIMAL_PLACES


class Currency(models.Model):
    """
    Keeps track of the current conversion rates so that we don't have to poll the free, but rate limited API
    from Open Exchange Rates. Necessary for billing things like MACH SMS.
    """
    code = models.CharField(max_length=3, unique=True)
    name = models.CharField(max_length=25, db_index=True)
    symbol = models.CharField(max_length=10)
    rate_to_default = models.DecimalField(default=1.0, max_digits=20, decimal_places=EXCHANGE_RATE_DECIMAL_PLACES)
    date_updated = models.DateField(auto_now=True)

    @classmethod
    def get_default(cls):
        try:
            return cls.objects.get(code=settings.DEFAULT_CURRENCY)
        except ObjectDoesNotExist:
            raise HQAccountingSetupError("You need initialize a default currency. Your current default is set to: %s"
                                         % settings.DEFAULT_CURRENCY)<commit_msg>initialize default currency if not already done<commit_after>from django.conf import settings
from django.core.exceptions import ObjectDoesNotExist
from django.db import models
from corehq.apps.accounting.exceptions import HQAccountingSetupError
from corehq.apps.accounting.utils import EXCHANGE_RATE_DECIMAL_PLACES


class Currency(models.Model):
    """
    Keeps track of the current conversion rates so that we don't have to poll the free, but rate limited API
    from Open Exchange Rates. Necessary for billing things like MACH SMS.
    """
    code = models.CharField(max_length=3, unique=True)
    name = models.CharField(max_length=25, db_index=True)
    symbol = models.CharField(max_length=10)
    rate_to_default = models.DecimalField(default=1.0, max_digits=20, decimal_places=EXCHANGE_RATE_DECIMAL_PLACES)
    date_updated = models.DateField(auto_now=True)

    @classmethod
    def get_default(cls):
        default, _ = Currency.objects.get_or_create(code=settings.DEFAULT_CURRENCY)
        return default
{'fraction_non_alphanumeric': 0.07032667876588022, 'fraction_numerical': 0.008166969147005444, 'mean_word_length': 4.212765957446808, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3845534', 'n_tokens_mistral': 668, 'n_tokens_neox': 646, 'n_words': 169}