
| Current Path : /var/www/wsgi/www/api/core/management/commands/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : /var/www/wsgi/www/api/core/management/commands/seed_contributions.py |
from django.core.management.base import BaseCommand
from core.models import EmployeeProfile, Contribution
from datetime import date, timedelta
import random
class Command(BaseCommand):
help = 'Seed contributions data'
def handle(self, *args, **options):
employees = EmployeeProfile.objects.all()
for employee in employees:
start_date = employee.hire_date
end_date = date.today()
current_date = start_date
while current_date <= end_date:
Contribution.objects.create(
employee=employee,
amount=round(employee.salary * 0.05, 2),
date=current_date
)
current_date += timedelta(days=30) # Mensuel