from utils.models import FiscalYear, TemplateTrimester
from companies.models import Company
from years.models import Year
from trimesters.models import Trimester
from datetime import datetime

year = '2016'
trim = 4
date = datetime(2016, 10, 1)


fy = FiscalYear.objects.get(name=year)
if not fy:
    fy = FiscalYear(name=year)
    fy.save()

for t1 in TemplateTrimester.objects.all():
    t1.favorite = False
    t1.save()

for t2 in Trimester.objects.all():
    t2.favorite = False
    t2.save()

tts = TemplateTrimester.objects.filter(number=trim, year=fy)
if len(tts):
    tt = tts[0]
    tt.favorite = True
    tt.start_date = date
    tt.save()
Exemple #2
0
from users.models import UserProfile
from django.contrib.auth.models import User

u = User.objects.all()
up = UserProfile(user=u[0])
up.save()

from utils.models import Country, FiscalYear
fy1 = FiscalYear(name='2015')
fy1.save()
fy2 = FiscalYear(name='2016')
fy2.save()

country1 = Country(name='Belgium')
country1.save()

from companies.models import Company
c1 = Company(name='Alpha',slug='alpha',vat_number='123456789', country=country1, active=True)
c1.save()
up.add_company(c1)
c2 = Company(name='Beta',slug='beta',vat_number='123456780', country=country1, active=True)
c2.save()
up.add_company(c2)

from years.models import Year
y11 = Year(fiscal_year=fy1, refer_company=c1, active=True)
y11.save()
c1.add_year(y11)
y12 = Year(fiscal_year=fy2, refer_company=c1, active=True)
y12.save()
c1.add_year(y12)