Skip to content

Instantly share code, notes, and snippets.

@jjangdm
Created December 15, 2012 08:03
Show Gist options
  • Save jjangdm/4292052 to your computer and use it in GitHub Desktop.
Save jjangdm/4292052 to your computer and use it in GitHub Desktop.
class Out1(models.Model):
money = models.IntegerField(verbose_name=META_NAME[1])
date = models.DateField(verbose_name='집행일')
executor = models.ForeignKey(Executor, verbose_name='집행자')
comment = models.TextField(blank=True, verbose_name='메모')
week = models.IntegerField(blank=True)
def save(self, *args, **kwargs):
if not self.week:
self.week = self.date.isocalendar()[1]
return super(Out1, self).save(*args, **kwargs)
class Meta:
ordering = ['-date']
verbose_name = META_NAME[1]
verbose_name_plural = META_NAME[1]
class Out2(models.Model):
money = models.IntegerField(verbose_name=META_NAME[2])
date = models.DateField(verbose_name='집행일')
executor = models.ForeignKey(Executor, verbose_name='집행자')
comment = models.TextField(blank=True, verbose_name='메모')
week = models.IntegerField(blank=True)
def save(self, *args, **kwargs):
if not self.week:
self.week = self.date.isocalendar()[1]
return super(Out2, self).save(*args, **kwargs)
class Meta:
ordering = ['-date']
verbose_name = META_NAME[2]
verbose_name_plural = META_NAME[2]
class Out3(models.Model):
money = models.IntegerField(verbose_name=META_NAME[3])
date = models.DateField(verbose_name='집행일')
executor = models.ForeignKey(Executor, verbose_name='집행자')
comment = models.TextField(blank=True, verbose_name='메모')
week = models.IntegerField(blank=True)
def save(self, *args, **kwargs):
if not self.week:
self.week = self.date.isocalendar()[1]
return super(Out3, self).save(*args, **kwargs)
class Meta:
ordering = ['-date']
verbose_name = META_NAME[3]
verbose_name_plural = META_NAME[3]
...
...
...
def report_month(request):
today = datetime.datetime.now()
budget_out1 = sum(Budget.objects.filter(year=today.year).values_list("out1", flat=True))
budget_out2 = sum(Budget.objects.filter(year=today.year).values_list("out2", flat=True))
budget_out3 = sum(Budget.objects.filter(year=today.year).vues_list("out3", flat=True)at=True))
...
...
...
yearSum_Out1 = sum(Out1.objects.filter(date__year=today.year).values_list("money", flat=True))
yearSum_Out2 = sum(Out2.objects.filter(date__year=today.year).values_list("money", flat=True))
yearSum_Out3 = sum(Out3.objects.filter(date__year=today.year).values_list("money", flat=True))
...
...
...
rate1 = yearSum_Out1 / float(budget_out1) *100
rate2 = yearSum_Out2 / float(budget_out2) *100
rate3 = yearSum_Out3 / float(budget_out3) *100
...
...
...
january = [0,
sum(Out1.objects.filter(date__month="1").values_list("money", flat=True)),
sum(Out2.objects.filter(date__month="1").values_list("money", flat=True)),
sum(Out3.objects.filter(date__month="1").values_list("money", flat=True)),
sum(Out4.objects.filter(date__month="1").values_list("money", flat=True)),
sum(Out5.objects.filter(date__month="1").values_list("money", flat=True)),
sum(Out6.objects.filter(date__month="1").values_list("money", flat=True)),
sum(Out7.objects.filter(date__month="1").values_list("money", flat=True)),
sum(Out8.objects.filter(date__month="1").values_list("money", flat=True)),
sum(Out9.objects.filter(date__month="1").values_list("money", flat=True)),
sum(Out10.objects.filter(date__month="1").values_list("money", flat=True)),
sum(Out11.objects.filter(date__month="1").values_list("money", flat=True)),
sum(Out12.objects.filter(date__month="1").values_list("money", flat=True)),
sum(Out13.objects.filter(date__month="1").values_list("money", flat=True)),
sum(Out14.objects.filter(date__month="1").values_list("money", flat=True)),
sum(Out15.objects.filter(date__month="1").values_list("money", flat=True)),
sum(Out16.objects.filter(date__month="1").values_list("money", flat=True)),
sum(Out17.objects.filter(date__month="1").values_list("money", flat=True)),
sum(Out18.objects.filter(date__month="1").values_list("money", flat=True)),
sum(Out19.objects.filter(date__month="1").values_list("money", flat=True)),
sum(Out20.objects.filter(date__month="1").values_list("money", flat=True)),
sum(Out21.objects.filter(date__month="1").values_list("money", flat=True)),
sum(Out22.objects.filter(date__month="1").values_list("money", flat=True)),
sum(Out23.objects.filter(date__month="1").values_list("money", flat=True)),
sum(Out24.objects.filter(date__month="1").values_list("money", flat=True)),
sum(Out25.objects.filter(date__month="1").values_list("money", flat=True)),
]
jan_management = sum(january[1:5])
jan_education = sum(january[5:8])
jan_feed = sum(january[8:14])
jan_reward = sum(january[14:18])
jan_mission = sum(january[18:22])
jan_operation = sum(january[22:26])
jan_total = sum(january)
febrary = [0,
sum(Out1.objects.filter(date__month="2").values_list("money", flat=True)),
sum(Out2.objects.filter(date__month="2").values_list("money", flat=True)),
sum(Out3.objects.filter(date__month="2").values_list("money", flat=True)),
sum(Out4.objects.filter(date__month="2").values_list("money", flat=True)),
sum(Out5.objects.filter(date__month="2").values_list("money", flat=True)),
sum(Out6.objects.filter(date__month="2").values_list("money", flat=True)),
sum(Out7.objects.filter(date__month="2").values_list("money", flat=True)),
sum(Out8.objects.filter(date__month="2").values_list("money", flat=True)),
sum(Out9.objects.filter(date__month="2").values_list("money", flat=True)),
sum(Out10.objects.filter(date__month="2").values_list("money", flat=True)),
sum(Out11.objects.filter(date__month="2").values_list("money", flat=True)),
sum(Out12.objects.filter(date__month="2").values_list("money", flat=True)),
sum(Out13.objects.filter(date__month="2").values_list("money", flat=True)),
sum(Out14.objects.filter(date__month="2").values_list("money", flat=True)),
sum(Out15.objects.filter(date__month="2").values_list("money", flat=True)),
sum(Out16.objects.filter(date__month="2").values_list("money", flat=True)),
sum(Out17.objects.filter(date__month="2").values_list("money", flat=True)),
sum(Out18.objects.filter(date__month="2").values_list("money", flat=True)),
sum(Out19.objects.filter(date__month="2").values_list("money", flat=True)),
sum(Out20.objects.filter(date__month="2").values_list("money", flat=True)),
sum(Out21.objects.filter(date__month="2").values_list("money", flat=True)),
sum(Out22.objects.filter(date__month="2").values_list("money", flat=True)),
sum(Out23.objects.filter(date__month="2").values_list("money", flat=True)),
sum(Out24.objects.filter(date__month="2").values_list("money", flat=True)),
sum(Out25.objects.filter(date__month="2").values_list("money", flat=True)),
]
feb_management = sum(febrary[1:5])
feb_education = sum(febrary[5:8])
feb_feed = sum(febrary[8:14])
feb_reward = sum(febrary[14:18])
feb_mission = sum(febrary[18:22])
feb_operation = sum(febrary[22:26])
feb_total = sum(febrary)
march = [0,
sum(Out1.objects.filter(date__month="3").values_list("money", flat=True)),
sum(Out2.objects.filter(date__month="3").values_list("money", flat=True)),
sum(Out3.objects.filter(date__month="3").values_list("money", flat=True)),
sum(Out4.objects.filter(date__month="3").values_list("money", flat=True)),
sum(Out5.objects.filter(date__month="3").values_list("money", flat=True)),
sum(Out6.objects.filter(date__month="3").values_list("money", flat=True)),
sum(Out7.objects.filter(date__month="3").values_list("money", flat=True)),
sum(Out8.objects.filter(date__month="3").values_list("money", flat=True)),
sum(Out9.objects.filter(date__month="3").values_list("money", flat=True)),
sum(Out10.objects.filter(date__month="3").values_list("money", flat=True)),
sum(Out11.objects.filter(date__month="3").values_list("money", flat=True)),
sum(Out12.objects.filter(date__month="3").values_list("money", flat=True)),
sum(Out13.objects.filter(date__month="3").values_list("money", flat=True)),
sum(Out14.objects.filter(date__month="3").values_list("money", flat=True)),
sum(Out15.objects.filter(date__month="3").values_list("money", flat=True)),
sum(Out16.objects.filter(date__month="3").values_list("money", flat=True)),
sum(Out17.objects.filter(date__month="3").values_list("money", flat=True)),
sum(Out18.objects.filter(date__month="3").values_list("money", flat=True)),
sum(Out19.objects.filter(date__month="3").values_list("money", flat=True)),
sum(Out20.objects.filter(date__month="3").values_list("money", flat=True)),
sum(Out21.objects.filter(date__month="3").values_list("money", flat=True)),
sum(Out22.objects.filter(date__month="3").values_list("money", flat=True)),
sum(Out23.objects.filter(date__month="3").values_list("money", flat=True)),
sum(Out24.objects.filter(date__month="3").values_list("money", flat=True)),
sum(Out25.objects.filter(date__month="3").values_list("money", flat=True)),
]
mar_management = sum(march[1:5])
mar_education = sum(march[5:8])
mar_feed = sum(march[8:14])
mar_reward = sum(march[14:18])
mar_mission = sum(march[18:22])
mar_operation = sum(march[22:26])
mar_total = sum(march)
april = [0,
sum(Out1.objects.filter(date__month="4").values_list("money", flat=True)),
sum(Out2.objects.filter(date__month="4").values_list("money", flat=True)),
sum(Out3.objects.filter(date__month="4").values_list("money", flat=True)),
sum(Out4.objects.filter(date__month="4").values_list("money", flat=True)),
sum(Out5.objects.filter(date__month="4").values_list("money", flat=True)),
sum(Out6.objects.filter(date__month="4").values_list("money", flat=True)),
sum(Out7.objects.filter(date__month="4").values_list("money", flat=True)),
sum(Out8.objects.filter(date__month="4").values_list("money", flat=True)),
sum(Out9.objects.filter(date__month="4").values_list("money", flat=True)),
sum(Out10.objects.filter(date__month="4").values_list("money", flat=True)),
sum(Out11.objects.filter(date__month="4").values_list("money", flat=True)),
sum(Out12.objects.filter(date__month="4").values_list("money", flat=True)),
sum(Out13.objects.filter(date__month="4").values_list("money", flat=True)),
sum(Out14.objects.filter(date__month="4").values_list("money", flat=True)),
sum(Out15.objects.filter(date__month="4").values_list("money", flat=True)),
sum(Out16.objects.filter(date__month="4").values_list("money", flat=True)),
sum(Out17.objects.filter(date__month="4").values_list("money", flat=True)),
sum(Out18.objects.filter(date__month="4").values_list("money", flat=True)),
sum(Out19.objects.filter(date__month="4").values_list("money", flat=True)),
sum(Out20.objects.filter(date__month="4").values_list("money", flat=True)),
sum(Out21.objects.filter(date__month="4").values_list("money", flat=True)),
sum(Out22.objects.filter(date__month="4").values_list("money", flat=True)),
sum(Out23.objects.filter(date__month="4").values_list("money", flat=True)),
sum(Out24.objects.filter(date__month="4").values_list("money", flat=True)),
sum(Out25.objects.filter(date__month="4").values_list("money", flat=True)),
]
apr_management = sum(april[1:5])
apr_education = sum(april[5:8])
apr_feed = sum(april[8:14])
apr_reward = sum(april[14:18])
apr_mission = sum(april[18:22])
apr_operation = sum(april[22:26])
apr_total = sum(april)
return render_to_response("report_month.html",
dict(
today=today,
budget_out1=budget_out1,
budget_out2= budget_out2,
budget_out3= budget_out3,
....
...
...
rate1= rate1,
rate2= rate2,
rate3= rate3,
....
...
...
rate1_total= rate1_total,
rate2_total= rate2_total,
rate3_total= rate3_total,
...
..
....
yearSum_Out1 = yearSum_Out1,
yearSum_Out2 = yearSum_Out2,
yearSum_Out3 = yearSum_Out3,
...
...
...
jan_Out1 = january[1],
jan_Out2 = january[2],
jan_Out3 = january[3],
jan_Out4 = january[4],
jan_Out5 = january[5],
jan_Out6 = january[6],
jan_Out7 = january[7],
jan_Out8 = january[8],
jan_Out9 = january[9],
jan_Out10 = january[10],
jan_Out11 = january[11],
jan_Out12 = january[12],
jan_Out13 = january[13],
jan_Out14 = january[14],
jan_Out15 = january[15],
jan_Out16 = january[16],
jan_Out17 = january[17],
jan_Out18 = january[18],
jan_Out19 = january[19],
jan_Out20 = january[20],
jan_Out21 = january[21],
jan_Out22 = january[22],
jan_Out23 = january[23],
jan_Out24 = january[24],
jan_Out25 = january[25],
jan_management = jan_management,
jan_education = jan_education,
jan_feed = jan_feed,
jan_reward = jan_reward,
jan_mission = jan_mission,
jan_operation = jan_operation,
jan_total = jan_total,
feb_Out1 = febrary[1],
feb_Out2 = febrary[2],
feb_Out3 = febrary[3],
feb_Out4 = febrary[4],
feb_Out5 = febrary[5],
feb_Out6 = febrary[6],
feb_Out7 = febrary[7],
feb_Out8 = febrary[8],
feb_Out9 = febrary[9],
feb_Out10 = febrary[10],
feb_Out11 = febrary[11],
feb_Out12 = febrary[12],
feb_Out13 = febrary[13],
feb_Out14 = febrary[14],
feb_Out15 = febrary[15],
feb_Out16 = febrary[16],
feb_Out17 = febrary[17],
feb_Out18 = febrary[18],
feb_Out19 = febrary[19],
feb_Out20 = febrary[20],
feb_Out21 = febrary[21],
feb_Out22 = febrary[22],
feb_Out23 = febrary[23],
feb_Out24 = febrary[24],
feb_Out25 = febrary[25],
feb_management = feb_management,
feb_education = feb_education,
feb_feed = feb_feed,
feb_reward = feb_reward,
feb_mission = feb_mission,
feb_operation = feb_operation,
feb_total = feb_total,
mar_Out1 = march[1],
mar_Out2 = march[2],
mar_Out3 = march[3],
mar_Out4 = march[4],
mar_Out5 = march[5],
mar_Out6 = march[6],
mar_Out7 = march[7],
mar_Out8 = march[8],
mar_Out9 = march[9],
mar_Out10 = march[10],
mar_Out11 = march[11],
mar_Out12 = march[12],
mar_Out13 = march[13],
mar_Out14 = march[14],
mar_Out15 = march[15],
mar_Out16 = march[16],
mar_Out17 = march[17],
mar_Out18 = march[18],
mar_Out19 = march[19],
mar_Out20 = march[20],
mar_Out21 = march[21],
mar_Out22 = march[22],
mar_Out23 = march[23],
mar_Out24 = march[24],
mar_Out25 = march[25],
mar_management = mar_management,
mar_education = mar_education,
mar_feed = mar_feed,
mar_reward = mar_reward,
mar_mission = mar_mission,
mar_operation = mar_operation,
mar_total = mar_total,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment