Merge branch 'Aufinal/fix_kfet_devdata' into 'master'
Données de test K-Fêt See merge request !191
This commit is contained in:
commit
a057869d77
1 changed files with 27 additions and 4 deletions
|
@ -12,7 +12,8 @@ from django.contrib.auth.models import User, Group, Permission, ContentType
|
|||
|
||||
from gestioncof.management.base import MyBaseCommand
|
||||
from gestioncof.models import CofProfile
|
||||
from kfet.models import Account, Article, OperationGroup, Operation, Checkout
|
||||
from kfet.models import (Account, Article, OperationGroup, Operation,
|
||||
Checkout, CheckoutStatement)
|
||||
|
||||
# Où sont stockés les fichiers json
|
||||
DATA_DIR = os.path.join(os.path.dirname(os.path.dirname(__file__)),
|
||||
|
@ -87,22 +88,44 @@ class Command(MyBaseCommand):
|
|||
|
||||
# Compte liquide
|
||||
|
||||
self.stdout.write("Création du compte liquide")
|
||||
liq_user, _ = User.objects.get_or_create(username='liquide')
|
||||
liq_profile, _ = CofProfile.objects.get_or_create(user=liq_user)
|
||||
liq_account, _ = Account.objects.get_or_create(cofprofile=liq_profile,
|
||||
trigramme='LIQ')
|
||||
|
||||
# Root account if existing
|
||||
|
||||
root_profile = CofProfile.objects.filter(user__username='root')
|
||||
if root_profile.exists():
|
||||
self.stdout.write("Création du compte K-Fêt root")
|
||||
root_profile = root_profile.get()
|
||||
Account.objects.get_or_create(cofprofile=root_profile,
|
||||
trigramme='AAA')
|
||||
|
||||
# ---
|
||||
# Caisse
|
||||
# ---
|
||||
|
||||
checkout, _ = Checkout.objects.get_or_create(
|
||||
checkout, created = Checkout.objects.get_or_create(
|
||||
created_by=Account.objects.get(trigramme='000'),
|
||||
name='Chaudron',
|
||||
valid_from=timezone.now(),
|
||||
valid_to=timezone.now() + timedelta(days=365)
|
||||
defaults={
|
||||
'valid_from': timezone.now(),
|
||||
'valid_to': timezone.now() + timedelta(days=730)
|
||||
},
|
||||
)
|
||||
|
||||
if created:
|
||||
CheckoutStatement.objects.create(
|
||||
by=Account.objects.get(trigramme='000'),
|
||||
checkout=checkout,
|
||||
balance_old=0,
|
||||
balance_new=0,
|
||||
amount_taken=0,
|
||||
amount_error=0
|
||||
)
|
||||
|
||||
# ---
|
||||
# Opérations
|
||||
# ---
|
||||
|
|
Loading…
Reference in a new issue