<commit_before>from django.db import models
from django.utils import timezone


class Category(models.Model):
    name = models.CharField(max_length=50)
    number = models.CharField(max_length=50, unique=True)

    def __str__(self):
        return self.number


class Subcategory(models.Model):
    name = models.CharField(max_length=50)
    category = models.ForeignKey(Category)

    def __str__(self):
        return self.name


class Transaction(models.Model):
    IN = 'i'
    OUT = 'o'
    TYPE_CHOICES = (
        (IN, 'Money In'),
        (OUT, 'Money Out'),
    )
    transaction_type = models.CharField(max_length=5, choices=TYPE_CHOICES, default=OUT)
    category = models.ForeignKey(Category, blank=True)
    date = models.DateTimeField()
    subcategory = models.ForeignKey(Subcategory, blank=True)
    comment = models.CharField(max_length=200, blank=True)
    amount = models.DecimalField(decimal_places=2, max_digits=19)
    balance = models.DecimalField(decimal_places=2, max_digits=19)
    account = models.ForeignKey('accounts.Account')

    def __str__(self):
        return self.transaction_type + str(self.amount)

    @classmethod
    def first_year(cls):
        years = cls.objects.order_by('date')[0].date.year
        return years

    @classmethod
    def year_range(cls):
        year_range = [cls.first_year()]<commit_msg>Changes category and subcategory in Transaction class to accept blank and null values<commit_after>from django.db import models
from django.utils import timezone


class Category(models.Model):
    name = models.CharField(max_length=50)
    number = models.CharField(max_length=50, unique=True)

    def __str__(self):
        return self.number


class Subcategory(models.Model):
    name = models.CharField(max_length=50)
    category = models.ForeignKey(Category)

    def __str__(self):
        return self.name


class Transaction(models.Model):
    IN = 'i'
    OUT = 'o'
    TYPE_CHOICES = (
        (IN, 'Money In'),
        (OUT, 'Money Out'),
    )
    transaction_type = models.CharField(max_length=5, choices=TYPE_CHOICES, default=OUT)
    category = models.ForeignKey(Category, blank=True, null=True)
    date = models.DateTimeField()
    subcategory = models.ForeignKey(Subcategory, blank=True, null=True)
    comment = models.CharField(max_length=200, blank=True)
    amount = models.DecimalField(decimal_places=2, max_digits=19)
    balance = models.DecimalField(decimal_places=2, max_digits=19)
    account = models.ForeignKey('accounts.Account')

    def __str__(self):
        return self.transaction_type + str(self.amount)

    @classmethod
    def first_year(cls):
        years = cls.objects.order_by('date')[0].date.year
        return years

    @classmethod
    def year_range(cls):
        year_range = [cls.first_year()]
{'fraction_non_alphanumeric': 0.11063526052819414, 'fraction_numerical': 0.012134189864382585, 'mean_word_length': 3.6330578512396694, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2457217', 'n_tokens_mistral': 898, 'n_tokens_neox': 858, 'n_words': 177}