<commit_before># -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.utils import timezone
from django.db import models
from django.core.urlresolvers import reverse


class Code(models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=30)
    type = models.CharField(max_length=30)
    parrent = models.IntegerField(blank=True, null=True)
    entity = models.CharField(max_length=30)
    schema = models.CharField(max_length=30)
    created = models.DateTimeField(auto_now_add=True)
    updated = models.DateTimeField(auto_now=True)

    class Meta:
        verbose_name = 'Code'
        verbose_name_plural = 'Codes'

    def __unicode__(self):
        return self.name

    def get_absolute_url(self):
        return reverse('code-edit', kwargs={'pk': self.id})

class Tax (models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=30, blank=False)
    value = models.DecimalField(max_digits=5, decimal_places=2)
    created = models.DateTimeField(auto_now_add=True)
    updated = models.DateTimeField(auto_now=True)

    class Meta:
        verbose_name = 'Tax'
        verbose_name_plural = 'Taxes'

    def __unicode__(self):
        return self.name

    def get_absolute_url(self):
        return reverse('tax-edit', kwargs={'pk': self.id})

class Organization (models.Model):

    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=60)
    street_name = models.CharField(max_length=60, blank=True)
    street_number = models.CharField(max_length=10, blank=True)
    zip_code = models.CharField(max_length=60, blank=True)
    city = models.CharField(max_length=60, blank=True)
    country = models.CharField(max_length=60, blank=True)
    phone = models.CharField(max_length=15, blank=True)
    email = models.CharField(max_length=60, blank=True)
    org_nbr_1 = models.CharField(max_length=30, blank=True)
    org_nbr_2 = models.CharField(max_length=30, blank=True)
    org_type = models.ForeignKey(Code)
    created = models.DateTimeField(auto_now_add=True)
    updated = models.DateTimeField(auto_now=True)

    class Meta:
        verbose_name = 'Organization'
        verbose_name_plural = 'Organization'

    def __unicode__(self):
        return self.name

    def get_absolute_url(self):
        return reverse('organization-edit', kwargs={'pk': self.id})

class Project(models.Model):
    id = models.AutoField(primary_key=True)
    customer = models.ForeignKey(Organization)
    name = models.CharField(max_length=300)
    code = models.CharField(max_length=30)
    created = models.DateTimeField(auto_now_add=True)
    updated = models.DateTimeField(auto_now=True)

    class Meta:
        verbose_name = 'Projects'
        verbose_name_plural = 'Projects'

    def __unicode__(self):
        return self.name

    def get_absolute_url(self):
        return reverse('project-edit', kwargs={'pk': self.id})

class Material (models.Model):
    id = models.AutoField(primary_key=True)
    tax = models.ForeignKey(Tax, on_delete=models.CASCADE)
    name = models.CharField(max_length=60)
    group = models.ForeignKey(Code)
    manufacturer = models.ForeignKey(Organization, related_name='organization_manufacturer', blank=True, null=True)
    dealer = models.ForeignKey(Organization, related_name='organization_dealer', blank=True, null=True)
    price  = models.DecimalField(max_digits=5, decimal_places=2, blank=True, null=True)
    created = models.DateTimeField(auto_now_add=True)
    updated = models.DateTimeField(auto_now=True)

    class Meta:
        verbose_name = 'Material'
        verbose_name_plural = 'Materials'

    def __unicode__(self):
        return self.name

    def get_absolute_url(self):
        return reverse('material-edit', kwargs={'pk': self.id})

class Service (models.Model):
    id = models.AutoField(primary_key=True)
    tax = models.ForeignKey(Tax, on_delete=models.CASCADE)
    name = models.CharField(max_length=60)
    price_per_hour  = models.DecimalField(max_digits=5, decimal_places=2, blank=True, null=True)
    fixed_price = models.DecimalField(max_digits=5, decimal_places=2, blank=True, null=True)
    created = models.DateTimeField(auto_now_add=True)
    updated = models.DateTimeField(auto_now=True)

    class Meta:
        verbose_name = 'Service'
        verbose_name_plural = 'Service'

    def __unicode__(self):
        return self.name

    def get_absolute_url(self):
        return reverse('service-edit', kwargs={'pk': self.id})

class Invoice (models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=10)
    create_date = models.DateField()
    payment_date = models.DateField()
    status = models.ForeignKey(Code, related_name='code_status')
    company = models.ForeignKey(Organization, related_name='organization_company')
    customer = models.ForeignKey(Organization, related_name='organization_customer')
    payment_method = models.ForeignKey(Code, related_name='code_payment_method')
    literal_value = models.CharField(max_length=100)
    created = models.DateTimeField(auto_now_add=True)
    updated = models.DateTimeField(auto_now=True)
    objects = models.Manager()

    def get_absolute_url(self):
        return reverse('invoice', args=[str(self.id),str(self.name)])
    class Meta:
        verbose_name = 'Invoice'
        verbose_name_plural = 'Invoice'

    def __unicode__(self):
        return unicode(self.id) or u''

    def __int__(self):
        return self.id

class Invoice_Details (models.Model):
    id = models.AutoField(primary_key=True)
    service = models.ForeignKey(Service, on_delete=models.CASCADE, blank=True, null=True)
    material = models.ForeignKey(Material, on_delete=models.CASCADE, blank=True, null=True)
    invoice = models.ForeignKey(Invoice, on_delete=models.CASCADE)
    name = models.CharField(max_length=60)
    hour  = models.DecimalField(max_digits=5, decimal_places=2, blank=True, null=True)
    price  = models.DecimalField(max_digits=5, decimal_places=2, blank=True, null=True)
    created = models.DateTimeField(auto_now_add=True)
    updated = models.DateTimeField(auto_now=True)
    class Meta:
        verbose_name = 'Invoice detail'
        verbose_name_plural = 'Invoice details'
    def __unicode__(self):
        return self.name

class Event(models.Model):
    id = models.AutoField(primary_key=True)
    project = models.ForeignKey(Project, on_delete=models.CASCADE)
    start_date = models.DateField()
    end_date = models.DateField()
    type_code = models.CharField(max_length=2)
    name = models.CharField(max_length=300)
    hour  = models.DecimalField(max_digits=5, decimal_places=2)
    created = models.DateTimeField(auto_now_add=True)
    updated = models.DateTimeField(auto_now=True)

    class Meta:
        verbose_name = 'Events'
        verbose_name_plural = 'Events'

    def __unicode__(self):
        return self.name

    def get_absolute_url(self):
        return reverse('event_list', kwargs={'id': self.id})
<commit_msg>Invoice fix<commit_after># -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.utils import timezone
from django.db import models
from django.core.urlresolvers import reverse


class Code(models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=30)
    type = models.CharField(max_length=30)
    parrent = models.IntegerField(blank=True, null=True)
    entity = models.CharField(max_length=30)
    schema = models.CharField(max_length=30)
    created = models.DateTimeField(auto_now_add=True)
    updated = models.DateTimeField(auto_now=True)

    class Meta:
        verbose_name = 'Code'
        verbose_name_plural = 'Codes'

    def __unicode__(self):
        return self.name

    def get_absolute_url(self):
        return reverse('code-edit', kwargs={'pk': self.id})

class Tax (models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=30, blank=False)
    value = models.DecimalField(max_digits=5, decimal_places=2)
    created = models.DateTimeField(auto_now_add=True)
    updated = models.DateTimeField(auto_now=True)

    class Meta:
        verbose_name = 'Tax'
        verbose_name_plural = 'Taxes'

    def __unicode__(self):
        return self.name

    def get_absolute_url(self):
        return reverse('tax-edit', kwargs={'pk': self.id})

class Organization (models.Model):

    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=60)
    street_name = models.CharField(max_length=60, blank=True)
    street_number = models.CharField(max_length=10, blank=True)
    zip_code = models.CharField(max_length=60, blank=True)
    city = models.CharField(max_length=60, blank=True)
    country = models.CharField(max_length=60, blank=True)
    phone = models.CharField(max_length=15, blank=True)
    email = models.CharField(max_length=60, blank=True)
    org_nbr_1 = models.CharField(max_length=30, blank=True)
    org_nbr_2 = models.CharField(max_length=30, blank=True)
    org_type = models.ForeignKey(Code)
    created = models.DateTimeField(auto_now_add=True)
    updated = models.DateTimeField(auto_now=True)

    class Meta:
        verbose_name = 'Organization'
        verbose_name_plural = 'Organization'

    def __unicode__(self):
        return self.name

    def get_absolute_url(self):
        return reverse('organization-edit', kwargs={'pk': self.id})

class Project(models.Model):
    id = models.AutoField(primary_key=True)
    customer = models.ForeignKey(Organization)
    name = models.CharField(max_length=300)
    code = models.CharField(max_length=30)
    created = models.DateTimeField(auto_now_add=True)
    updated = models.DateTimeField(auto_now=True)

    class Meta:
        verbose_name = 'Projects'
        verbose_name_plural = 'Projects'

    def __unicode__(self):
        return self.name

    def get_absolute_url(self):
        return reverse('project-edit', kwargs={'pk': self.id})

class Invoice (models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=10)
    create_date = models.DateField()
    payment_date = models.DateField()
    status = models.ForeignKey(Code, related_name='code_status')
    company = models.ForeignKey(Organization, related_name='organization_company')
    customer = models.ForeignKey(Organization, related_name='organization_customer')
    payment_method = models.ForeignKey(Code, related_name='code_payment_method')
    literal_value = models.CharField(max_length=100)
    created = models.DateTimeField(auto_now_add=True)
    updated = models.DateTimeField(auto_now=True)
    objects = models.Manager()

    def get_absolute_url(self):
        return reverse('invoice', args=[str(self.id),str(self.name)])
    class Meta:
        verbose_name = 'Invoice'
        verbose_name_plural = 'Invoices'

    def __unicode__(self):
        return unicode(self.id) or u''

    def __int__(self):
        return self.id

class Material (models.Model):
    id = models.AutoField(primary_key=True)
    tax = models.ForeignKey(Tax, on_delete=models.CASCADE)
    name = models.CharField(max_length=60)
    group = models.ForeignKey(Code)
    manufacturer = models.ForeignKey(Organization, related_name='organization_manufacturer', blank=True, null=True)
    dealer = models.ForeignKey(Organization, related_name='organization_dealer', blank=True, null=True)
    price  = models.DecimalField(max_digits=14, decimal_places=2, blank=True, null=True)
    created = models.DateTimeField(auto_now_add=True)
    updated = models.DateTimeField(auto_now=True)

    class Meta:
        verbose_name = 'Material'
        verbose_name_plural = 'Materials'

    def __unicode__(self):
        return self.name

    def get_absolute_url(self):
        return reverse('material-edit', kwargs={'pk': self.id})

class Service (models.Model):
    id = models.AutoField(primary_key=True)
    tax = models.ForeignKey(Tax, on_delete=models.CASCADE)
    name = models.CharField(max_length=60)
    price_per_hour  = models.DecimalField(max_digits=5, decimal_places=2, blank=True, null=True)
    fixed_price = models.DecimalField(max_digits=5, decimal_places=2, blank=True, null=True)
    created = models.DateTimeField(auto_now_add=True)
    updated = models.DateTimeField(auto_now=True)

    class Meta:
        verbose_name = 'Service'
        verbose_name_plural = 'Service'

    def __unicode__(self):
        return self.name

    def get_absolute_url(self):
        return reverse('service-edit', kwargs={'pk': self.id})

class Invoice_Service (models.Model):
    id = models.AutoField(primary_key=True)
    invoice = models.ForeignKey(Invoice)
    service = models.ForeignKey(Service)
    hour  = models.DecimalField(max_digits=5, decimal_places=2, blank=True, null=True)
    created = models.DateTimeField(auto_now_add=True)
    updated = models.DateTimeField(auto_now=True)

    class Meta:
        verbose_name = 'Invoice Service'
        verbose_name_plural = 'Invoice Services'

class Invoice_Material (models.Model):
    id = models.AutoField(primary_key=True)
    invoice = models.ForeignKey(Invoice)
    material = models.ForeignKey(Material)
    item  = models.DecimalField(max_digits=5, decimal_places=2, blank=True, null=True)
    created = models.DateTimeField(auto_now_add=True)
    updated = models.DateTimeField(auto_now=True)

    class Meta:
        verbose_name = 'Invoice Material'
        verbose_name_plural = 'Invoice Materials'

class Event(models.Model):
    id = models.AutoField(primary_key=True)
    project = models.ForeignKey(Project, on_delete=models.CASCADE)
    start_date = models.DateField()
    end_date = models.DateField()
    type_code = models.CharField(max_length=2)
    name = models.CharField(max_length=300)
    hour  = models.DecimalField(max_digits=5, decimal_places=2)
    created = models.DateTimeField(auto_now_add=True)
    updated = models.DateTimeField(auto_now=True)

    class Meta:
        verbose_name = 'Events'
        verbose_name_plural = 'Events'

    def __unicode__(self):
        return self.name

    def get_absolute_url(self):
        return reverse('event_list', kwargs={'id': self.id})

{'fraction_non_alphanumeric': 0.1094024296046626, 'fraction_numerical': 0.009339231795519978, 'mean_word_length': 4.119338605319914, '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': '53232', 'n_tokens_mistral': 4630, 'n_tokens_neox': 4455, 'n_words': 795}