Files
jb-compta/compta/migrations/0001_initial.py
T

131 lines
7.8 KiB
Python

# Generated by Django 5.2.15 on 2026-06-29 20:53
import django.db.models.deletion
from decimal import Decimal
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Entreprise',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('nom', models.CharField(max_length=200)),
('siret', models.CharField(blank=True, max_length=20)),
('activite', models.CharField(choices=[('vente', 'Vente de marchandises (BIC)'), ('service_bic', 'Prestation de services (BIC)'), ('service_bnc', 'Prestation de services / libéral (BNC)')], default='service_bnc', max_length=20)),
('franchise_tva', models.BooleanField(default=False, help_text='Décochez si vous facturez et déclarez la TVA.', verbose_name='En franchise de TVA')),
('taux_tva_defaut', models.DecimalField(decimal_places=2, default=Decimal('20.00'), max_digits=4, verbose_name='Taux de TVA par défaut (%)')),
('versement_liberatoire', models.BooleanField(default=False, verbose_name='Option versement libératoire')),
('email', models.EmailField(blank=True, max_length=254)),
('adresse', models.TextField(blank=True)),
('cree_le', models.DateTimeField(auto_now_add=True)),
],
options={
'verbose_name': 'Entreprise',
'verbose_name_plural': 'Entreprises',
'ordering': ['nom'],
},
),
migrations.CreateModel(
name='Bareme',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('activite', models.CharField(choices=[('vente', 'Vente de marchandises (BIC)'), ('service_bic', 'Prestation de services (BIC)'), ('service_bnc', 'Prestation de services / libéral (BNC)')], max_length=20)),
('annee', models.PositiveIntegerField()),
('taux_urssaf', models.DecimalField(decimal_places=2, max_digits=5, verbose_name='Taux cotisations URSSAF (%)')),
('abattement_fiscal', models.DecimalField(decimal_places=2, max_digits=5, verbose_name='Abattement forfaitaire (%)')),
('taux_vl', models.DecimalField(decimal_places=2, max_digits=4, verbose_name='Taux versement libératoire (%)')),
('seuil_ca', models.DecimalField(decimal_places=2, max_digits=12, verbose_name='Plafond CA micro (€)')),
('seuil_tva_base', models.DecimalField(decimal_places=2, max_digits=12, verbose_name='Seuil franchise TVA (€)')),
('seuil_tva_majore', models.DecimalField(decimal_places=2, max_digits=12, verbose_name='Seuil franchise TVA majoré (€)')),
],
options={
'verbose_name': 'Barème',
'verbose_name_plural': 'Barèmes',
'ordering': ['-annee', 'activite'],
'unique_together': {('activite', 'annee')},
},
),
migrations.CreateModel(
name='Depense',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('date', models.DateField()),
('categorie', models.CharField(blank=True, max_length=100)),
('libelle', models.CharField(max_length=255)),
('montant_ttc', models.DecimalField(decimal_places=2, max_digits=12)),
('montant_tva', models.DecimalField(decimal_places=2, default=Decimal('0'), max_digits=12, verbose_name='TVA déductible (€)')),
('cree_le', models.DateTimeField(auto_now_add=True)),
('entreprise', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='depenses', to='compta.entreprise')),
],
options={
'verbose_name': 'Dépense',
'verbose_name_plural': 'Dépenses',
'ordering': ['-date'],
},
),
migrations.CreateModel(
name='Client',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('nom', models.CharField(max_length=200)),
('email', models.EmailField(blank=True, max_length=254)),
('siret', models.CharField(blank=True, max_length=20)),
('adresse', models.TextField(blank=True)),
('cree_le', models.DateTimeField(auto_now_add=True)),
('entreprise', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='clients', to='compta.entreprise')),
],
options={
'verbose_name': 'Client',
'verbose_name_plural': 'Clients',
'ordering': ['nom'],
},
),
migrations.CreateModel(
name='Facture',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('numero', models.CharField(max_length=50)),
('activite', models.CharField(choices=[('vente', 'Vente de marchandises (BIC)'), ('service_bic', 'Prestation de services (BIC)'), ('service_bnc', 'Prestation de services / libéral (BNC)')], max_length=20)),
('date_emission', models.DateField()),
('date_encaissement', models.DateField(blank=True, help_text="À renseigner une fois la facture payée. Le CA micro est compté à l'encaissement.", null=True)),
('statut', models.CharField(choices=[('brouillon', 'Brouillon'), ('envoyee', 'Envoyée'), ('encaissee', 'Encaissée'), ('annulee', 'Annulée')], default='brouillon', max_length=12)),
('montant_ht', models.DecimalField(decimal_places=2, default=Decimal('0'), max_digits=12)),
('montant_tva', models.DecimalField(decimal_places=2, default=Decimal('0'), max_digits=12)),
('montant_ttc', models.DecimalField(decimal_places=2, default=Decimal('0'), max_digits=12)),
('notes', models.TextField(blank=True)),
('cree_le', models.DateTimeField(auto_now_add=True)),
('client', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='factures', to='compta.client')),
('entreprise', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='factures', to='compta.entreprise')),
],
options={
'verbose_name': 'Facture',
'verbose_name_plural': 'Factures',
'ordering': ['-date_emission', 'numero'],
'unique_together': {('entreprise', 'numero')},
},
),
migrations.CreateModel(
name='LigneFacture',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('designation', models.CharField(max_length=255)),
('quantite', models.DecimalField(decimal_places=3, default=Decimal('1'), max_digits=12)),
('prix_unitaire_ht', models.DecimalField(decimal_places=2, max_digits=12)),
('taux_tva', models.DecimalField(decimal_places=2, default=Decimal('0'), max_digits=4)),
('facture', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='lignes', to='compta.facture')),
],
options={
'verbose_name': 'Ligne de facture',
'verbose_name_plural': 'Lignes de facture',
},
),
]