Commit 7e41620b authored by Claire Zuliani's avatar Claire Zuliani

feature: add batches and tasks

parent 5dc35176
......@@ -2,6 +2,10 @@ from django.contrib import admin
from guardian.admin import GuardedModelAdmin
from .models import ClientInvoice
from .models import FreelanceInvoice
from .models import Batch
from .models import Task
admin.site.register(ClientInvoice)
admin.site.register(FreelanceInvoice)
admin.site.register(Batch)
admin.site.register(Task)
# -*- coding: utf-8 -*-
# Generated by Django 1.11.16 on 2018-11-03 18:18
# Generated by Django 1.11.16 on 2018-12-01 18:22
from __future__ import unicode_literals
import datetime
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
......@@ -15,18 +16,70 @@ class Migration(migrations.Migration):
operations = [
migrations.CreateModel(
name='Invoice',
name='Batch',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=255)),
('htAmount', models.DecimalField(decimal_places=2, max_digits=11)),
('creationDate', models.DateField(auto_now_add=True)),
('modificationDate', models.DateField(auto_now=True)),
],
options={
'permissions': (('view_batch', 'Read'), ('control_batch', 'Control')),
},
),
migrations.CreateModel(
name='ClientInvoice',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('identifier', models.CharField(max_length=255)),
('title', models.CharField(max_length=255)),
('state', models.CharField(choices=[('pending', 'en attente'), ('paid', 'réglée')], default='pending', max_length=255)),
('htAmount', models.DecimalField(decimal_places=2, max_digits=11)),
('tvaRate', models.DecimalField(decimal_places=2, max_digits=4)),
('creationDate', models.DateField(default=datetime.date.today)),
('modificationDate', models.DateField(default=datetime.date.today)),
('creationDate', models.DateField(auto_now_add=True)),
('modificationDate', models.DateField(auto_now=True)),
('invoicingDate', models.DateField(default=datetime.date.today)),
],
options={
'permissions': (('view_invoice', 'Read'), ('control_invoice', 'Control')),
},
),
migrations.CreateModel(
name='FreelanceInvoice',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('freelanceFullname', models.CharField(max_length=255)),
('identifier', models.CharField(max_length=255)),
('title', models.CharField(blank=True, max_length=255, null=True, verbose_name='Titre facture')),
('state', models.CharField(choices=[('pending', 'en attente'), ('sent', 'envoyé'), ('paid', 'payé')], default='pending', max_length=255)),
('htAmount', models.DecimalField(decimal_places=2, max_digits=11)),
('tvaRate', models.DecimalField(choices=[(0.0, 0.0), (20.0, 20.0)], decimal_places=2, default=20.0, max_digits=4)),
('creationDate', models.DateField(auto_now_add=True)),
('modificationDate', models.DateField(auto_now=True)),
('invoicingDate', models.DateField(default=datetime.date.today)),
],
options={
'permissions': (('view_freelance_invoice', 'Read'), ('control_freelance_invoice', 'Control')),
},
),
migrations.CreateModel(
name='Task',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=255)),
('htAmount', models.DecimalField(decimal_places=2, max_digits=11)),
('creationDate', models.DateField(auto_now_add=True)),
('modificationDate', models.DateField(auto_now=True)),
('batch', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='djangoldp_invoices.Batch')),
],
options={
'permissions': (('view_batch', 'Read'), ('control_batch', 'Control')),
},
),
migrations.AddField(
model_name='batch',
name='invoice',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='djangoldp_invoices.ClientInvoice'),
),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.11.16 on 2018-11-12 19:12
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('djangoldp_invoices', '0001_initial'),
]
operations = [
migrations.RenameModel(
old_name='Invoice',
new_name='ClientInvoice',
),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.11.16 on 2018-11-12 19:31
from __future__ import unicode_literals
import datetime
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('djangoldp_invoices', '0002_auto_20181112_1912'),
]
operations = [
migrations.CreateModel(
name='FreelanceInvoice',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('freelanceFullname', models.CharField(max_length=255)),
('identifier', models.CharField(max_length=255)),
('title', models.CharField(max_length=255)),
('htAmount', models.DecimalField(decimal_places=2, max_digits=11)),
('tvaRate', models.DecimalField(decimal_places=2, max_digits=4)),
('creationDate', models.DateField(default=datetime.date.today)),
('modificationDate', models.DateField(default=datetime.date.today)),
('invoicingDate', models.DateField(default=datetime.date.today)),
('uploadUrl', models.CharField(max_length=255)),
],
options={
'permissions': (('view_freelance_invoice', 'Read'), ('control_freelance_invoice', 'Control')),
},
),
]
......@@ -2,53 +2,96 @@ from django.conf import settings
from django.db import models
import datetime
class ClientInvoice(models.Model):
class FreelanceInvoice(models.Model):
# customer = models.ForeignKey(User, on_delete=models.CASCADE)
# provider = models.ForeignKey(User, on_delete=models.CASCADE)
STATES = (
('pending', 'en attente'),
('paid', 'réglée')
('sent', 'envoyé'),
('paid', 'payé')
)
TVA_RATES = (
(0.0, 0.0),
(20.0, 20.0)
)
freelanceFullname = models.CharField(max_length=255)
identifier = models.CharField(max_length=255)
title = models.CharField(max_length=255)
# state = models.CharField(max_length=1, choices=STATES, default = 'pending')
title = models.CharField(max_length=255, blank=True, null=True, verbose_name=u"Titre facture")
state = models.CharField(max_length=255, choices=STATES, default='pending')
htAmount = models.DecimalField(max_digits=11, decimal_places=2)
tvaRate = models.DecimalField(max_digits=4, decimal_places=2)
creationDate = models.DateField(default = datetime.date.today)
modificationDate = models.DateField(default = datetime.date.today)
tvaRate = models.DecimalField(choices=TVA_RATES, max_digits=4, decimal_places=2, default=20.0)
uploadUrl = models.URLField
creationDate = models.DateField(auto_now_add=True)
modificationDate = models.DateField(auto_now=True)
invoicingDate = models.DateField(default = datetime.date.today)
class Meta:
permissions = (
('view_invoice', 'Read'),
('control_invoice', 'Control'),
('view_freelance_invoice', 'Read'),
('control_freelance_invoice', 'Control'),
)
def __str__(self):
return '{} ({})'.format(self.identifier, self.title)
return '{} ({} / {})'.format(self.freelanceFullname, self.identifier, self.title)
class FreelanceInvoice(models.Model):
# customer = models.ForeignKey(User, on_delete=models.CASCADE)
# provider = models.ForeignKey(User, on_delete=models.CASCADE)
class ClientInvoice(models.Model):
# customer = models.ForeignKey('xxx.Client', on_delete=models.CASCADE)
# project = models.ForeignKey('xxx.Project', on_delete=models.CASCADE)
PENDING_STATE = 0
PAID_STATE = 1
STATES = (
('pending', 'en attente'),
('paid', 'réglée')
)
freelanceFullname = models.CharField(max_length=255)
identifier = models.CharField(max_length=255)
title = models.CharField(max_length=255)
# state = models.CharField(max_length=1, choices=STATES, default = 'pending')
state = models.CharField(max_length=255, choices=STATES, default='pending')
htAmount = models.DecimalField(max_digits=11, decimal_places=2)
tvaRate = models.DecimalField(max_digits=4, decimal_places=2)
creationDate = models.DateField(default = datetime.date.today)
modificationDate = models.DateField(default = datetime.date.today)
creationDate = models.DateField(auto_now_add=True)
modificationDate = models.DateField(auto_now=True)
invoicingDate = models.DateField(default = datetime.date.today)
uploadUrl = models.CharField(max_length=255)
class Meta:
permissions = (
('view_freelance_invoice', 'Read'),
('control_freelance_invoice', 'Control'),
('view_invoice', 'Read'),
('control_invoice', 'Control'),
)
def __str__(self):
return '{} ({})'.format(self.identifier, self.title)
# Lot =========================================================
class Batch(models.Model):
invoice = models.ForeignKey(ClientInvoice, on_delete=models.CASCADE)
title = models.CharField(max_length=255)
htAmount = models.DecimalField(max_digits=11, decimal_places=2)
creationDate = models.DateField(auto_now_add=True)
modificationDate = models.DateField(auto_now=True)
class Meta:
permissions = (
('view_batch', 'Read'),
('control_batch', 'Control'),
)
def __str__(self):
return '{} ({} € HT)'.format(self.title, self.htAmount)
class Task(models.Model):
batch = models.ForeignKey(Batch, on_delete=models.CASCADE)
title = models.CharField(max_length=255)
htAmount = models.DecimalField(max_digits=11, decimal_places=2)
creationDate = models.DateField(auto_now_add=True)
modificationDate = models.DateField(auto_now=True)
class Meta:
permissions = (
('view_batch', 'Read'),
('control_batch', 'Control'),
)
def __str__(self):
return '{} ({} / {})'.format(self.freelanceFullname, self.identifier, self.title)
\ No newline at end of file
return '{} ({} € HT)'.format(self.title, self.htAmount)
\ No newline at end of file
......@@ -3,8 +3,12 @@ from django.conf import settings
from djangoldp.views import LDPViewSet
from .models import ClientInvoice
from .models import FreelanceInvoice
from .models import Batch
from .models import Task
urlpatterns = [
url(r'^client-invoices', LDPViewSet.urls(model=ClientInvoice)),
url(r'^freelance-invoices', LDPViewSet.urls(model=FreelanceInvoice)),
url(r'^batches', LDPViewSet.urls(model=Batch)),
url(r'^tasks', LDPViewSet.urls(model=Task)),
]
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment